/* Know your eye medicines (DEC-079, DEC-082): a reference table on wide screens, one card per medicine on phones.
   Logical properties throughout, so the same rules serve English (left to right) and Arabic (right to left). */

.med.wrap {
  max-width: 84rem;
}
.med {
  display: grid;
  gap: 24px;
  padding-block: 20px 48px;
}
.med-head {
  display: grid;
  gap: 12px;
  max-width: 56rem;
  margin-inline: auto;
  padding-top: 12px;
  text-align: center;
}
.med-head h1 {
  font-size: clamp(2.25rem, 7vw, 3.5rem);
  text-wrap: balance;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.med-head h1:focus {
  outline: none;
}
/* DEC-080: the opening of the page is centred and uses the full width: the warning signs in two columns on wide
   screens, the search box and the groups in the middle. */
.med-head .lead-big {
  text-wrap: balance;
}
@media (min-width: 760px) {
  .med .urgency {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 40px;
    padding: 32px 36px;
  }
  .med .urgency b {
    grid-column: 1 / -1;
  }
  .med .urgency span {
    margin-top: 0;
  }
}

/* Arabic: the system's Arabic typeface (Figtree has no Arabic letters), a little more line spacing,
   and no negative letter spacing, which would break the joined letters. */
:root[lang='ar'] body {
  line-height: 1.7;
}
:root[lang='ar'] .med-head h1,
:root[lang='ar'] .urgency b,
:root[lang='ar'] .med h2 {
  letter-spacing: 0;
  line-height: 1.3;
}

.lang-btn {
  min-height: var(--target-min);
  padding-inline: 20px;
  border: 2px solid var(--color-graphite);
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.lang-btn:hover {
  background: var(--color-mist);
}

/* Search and the jump list */
.med-find {
  /* DEC-082: the search is the page's main control: large, and pinned to the top while the list scrolls. A white
     band the width of the page sits behind it, so rows never show through. */
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  gap: 6px;
  margin-inline: calc(-1 * var(--gutter));
  padding: 10px var(--gutter);
  background: var(--color-page);
  transition: box-shadow 200ms ease;
}
.med-find.pinned {
  box-shadow: 0 10px 18px -14px rgba(35, 39, 46, 0.45);
}
.med-field {
  position: relative;
  width: 100%;
  max-width: 44rem;
  margin-inline: auto;
}
.med-search {
  width: 100%;
  min-height: 64px;
  padding-inline: 56px 64px;
  border: 2px solid var(--color-graphite);
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-size: 1.1875rem;
  caret-color: var(--color-graphite);
  box-shadow: 0 6px 20px -10px rgba(35, 39, 46, 0.35);
  transition:
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 150ms;
  -webkit-appearance: none;
  appearance: none;
}
@media (max-width: 480px) {
  .med-search {
    min-height: 58px;
    padding-inline: 50px 56px;
    font-size: 1.0625rem;
  }
  .med-glass {
    inset-inline-start: 18px;
  }
}
.med-search::placeholder {
  color: var(--color-muted);
  opacity: 1;
}
.med-search::-webkit-search-cancel-button {
  display: none;
}
.med-search:focus {
  outline: none;
  box-shadow:
    0 0 0 5px rgba(242, 169, 0, 0.55),
    0 10px 28px -12px rgba(35, 39, 46, 0.4);
}
.med-glass,
.med-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.med-glass {
  position: absolute;
  inset-inline-start: 22px;
  top: 50%;
  translate: 0 -50%;
  pointer-events: none;
  transition: scale 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.med-field:focus-within .med-glass {
  scale: 1.12;
}
.med-slash,
.med-clear {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  translate: 0 -50%;
}
.med-slash {
  display: none;
  min-width: 30px;
  padding: 2px 8px;
  border: 1.5px solid var(--color-line);
  border-radius: 8px;
  color: var(--color-muted);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  text-align: center;
  inset-inline-end: 18px;
}
@media (hover: hover) and (pointer: fine) {
  .med-field:not(:focus-within) .med-search:placeholder-shown ~ .med-slash {
    display: block;
  }
}
.med-clear {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--color-mist);
  color: var(--color-graphite);
  cursor: pointer;
}
.med-clear:hover {
  background: var(--color-line);
}
.med-count {
  min-height: 0;
  color: var(--color-muted);
  font-weight: 600;
  text-align: center;
}
.med-count:empty {
  display: none;
}

/* Quick searches */
.med-quick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: -12px;
}
.med-quick-label {
  color: var(--color-muted);
  font-weight: 600;
}
.med-chip {
  min-height: var(--target-min);
  padding-inline: 18px;
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 150ms,
    border-color 150ms,
    color 150ms;
}
.med-chip:hover {
  border-color: var(--color-graphite);
}
.med-chip[aria-pressed='true'] {
  border-color: var(--color-graphite);
  background: var(--color-graphite);
  color: #fff;
}
.med-note {
  max-width: 44rem;
  margin-inline: auto;
  color: var(--color-muted);
  text-align: center;
}

/* The drawing: an eye-drop bottle is pressed, one drop falls, the eye blinks. Visible and still by default; the
   motion runs only while .play is set and never for people who ask for less motion. */
.med-art {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}
.med-art svg {
  width: clamp(120px, 24vw, 168px);
  height: auto;
  overflow: visible;
}
.art-line {
  fill: none;
  stroke: var(--color-graphite);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.art-white {
  fill: #fff;
}
.art-cap,
.art-iris {
  fill: var(--color-amber);
}
.art-drop {
  fill: #7cc8f0;
}
.art-ripple {
  fill: none;
  stroke: #7cc8f0;
  stroke-width: 2.5;
  opacity: 0;
}
.art-bottle,
.art-drop,
.art-ripple,
.art-eye {
  transform-box: fill-box;
  transform-origin: center;
}
@media (prefers-reduced-motion: no-preference) {
  .med-art.play .art-bottle {
    animation: art-press 2s both;
  }
  .med-art.play .art-drop {
    animation: art-drop 2s both;
  }
  .med-art.play .art-ripple {
    animation: art-ripple 2s both;
  }
  .med-art.play .art-eye {
    animation: art-blink 2s both;
  }
}
@keyframes art-press {
  0%,
  18% {
    transform: none;
  }
  28% {
    transform: scale(0.92, 1.05);
  }
  40%,
  100% {
    transform: none;
  }
}
@keyframes art-drop {
  0%,
  22% {
    transform: translateY(-8px) scale(0.2);
    opacity: 0;
  }
  36% {
    transform: none;
    opacity: 1;
  }
  46% {
    transform: none;
    animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45);
  }
  62% {
    transform: translateY(24px) scale(0.9, 1.12);
    opacity: 1;
  }
  66%,
  88% {
    transform: translateY(26px) scale(0.4);
    opacity: 0;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}
@keyframes art-ripple {
  0%,
  62% {
    transform: scale(0.5);
    opacity: 0;
  }
  65% {
    opacity: 0.9;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}
@keyframes art-blink {
  0%,
  63% {
    transform: none;
  }
  70% {
    transform: scaleY(0.1);
  }
  78%,
  100% {
    transform: none;
  }
}

.med-jump ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.med-jump a {
  display: inline-flex;
  align-items: center;
  min-height: var(--target-min);
  padding-inline: 16px;
  border-radius: var(--radius-pill);
  background: var(--color-mist);
  font-weight: 600;
  text-decoration: none;
}
.med-jump a:hover {
  background: var(--color-line);
}
.med-jump-n {
  margin-inline-start: 8px;
  min-width: 26px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--color-page);
  color: var(--color-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
mark {
  padding: 0 1px;
  border-radius: 3px;
  background: #ffe08a;
  color: inherit;
}
::selection {
  background: #ffe08a;
  color: var(--color-graphite);
}
.med-none {
  font-weight: 600;
  text-align: center;
}

/* One group of medicines */
.med-group {
  display: grid;
  gap: 8px;
  scroll-margin-top: 120px; /* clear of the pinned search box */
}
.med-group h2,
.med-how h2 {
  font-size: clamp(1.5rem, 4.5vw, 1.875rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.med-intro {
  max-width: 44rem;
}

.med-table {
  width: 100%;
  table-layout: fixed;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 1rem;
  line-height: 1.45;
}
.med-table th,
.med-table td {
  padding: 14px 12px;
  text-align: start;
  vertical-align: top;
  border-bottom: 1px solid var(--color-line);
}
.med-table thead th {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--color-muted);
  border-bottom: 2px solid var(--color-graphite);
}
.med-table tbody th {
  font-weight: 400;
}
.med-table tbody tr {
  transition:
    background-color 150ms,
    border-color 150ms;
}
@media (hover: hover) {
  .med-table tbody tr:hover {
    background: #f8f9fa;
  }
}
.c-n {
  width: 3rem;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}
.c-name {
  width: 21%;
}
.c-why,
.c-how,
.c-notice {
  width: 18%;
}
.med-title {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.form-art {
  flex: none;
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--color-graphite);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.form-art .f-cap {
  fill: var(--color-amber);
}
/* DEC-084: a bottle or tube's cap in its colour from the cap colour code, or white when the code gives none. */
.form-art.capped .f-cap {
  fill: var(--cap, #fff);
}
.form-art.no-cap .f-cap {
  fill: #fff;
}
.cap-dot {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cap);
  box-shadow: inset 0 0 0 1px rgba(35, 39, 46, 0.35);
}
.tag-cap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.med-name {
  display: block;
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.3;
}
.med-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-mist);
  font-size: 0.875rem;
  font-weight: 600;
}
.tag-all {
  background: var(--color-graphite);
  color: #fff;
}
.tag-none {
  background: #fff3cf;
}
.brands {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.brands li {
  padding: 3px 10px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
}
.brands small {
  font-weight: 400;
  color: var(--color-muted);
}

.med-how {
  display: grid;
  gap: 12px;
  padding: 24px 20px;
  border-radius: 24px;
  background: var(--color-mist);
}
@media (min-width: 760px) {
  .med-how {
    padding: 32px 36px;
  }
  .med-how ol {
    display: block;
    columns: 2;
    column-gap: 48px;
  }
  .med-how li {
    break-inside: avoid;
    margin-bottom: 8px;
  }
}
.med-small {
  max-width: 56rem;
  margin-inline: auto;
  font-size: 0.9375rem;
  text-align: center;
}

/* Phones and tablets: each medicine becomes a card, each column a labelled paragraph. */
@media (max-width: 1099px) {
  .med-table,
  .med-table tbody,
  .med-table tr,
  .med-table th,
  .med-table td {
    display: block;
  }
  .med-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .med-table tbody tr {
    margin-top: 16px;
    padding: 18px 16px;
    border: 1px solid var(--color-line);
    border-radius: 20px;
  }
  @media (hover: hover) {
    .med-table tbody tr:hover {
      border-color: var(--color-graphite);
      background: var(--color-page);
    }
  }
  .med-table tbody tr[hidden] {
    display: none;
  }
  .med-table th,
  .med-table td {
    width: auto;
    padding: 0;
    border: 0;
  }
  .med-table .c-n {
    font-size: 0.875rem;
    text-align: end;
  }
  .med-table td[data-label] {
    margin-top: 14px;
  }
  .med-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 0.9375rem;
  }
}

/* DEC-084: the cap colour key. Closed, it shows the colours side by side; they spread apart on hover and when open. */
.med-caps {
  width: 100%;
  max-width: 56rem;
  margin-inline: auto;
  padding-inline: 20px;
  border: 1.5px solid var(--color-line);
  border-radius: 20px;
  background: var(--color-page);
  transition: border-color 150ms;
}
.med-caps:hover,
.med-caps[open] {
  border-color: var(--color-graphite);
}
.med-caps summary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 56px;
  padding-block: 8px;
  padding-inline-end: 32px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.med-caps summary::-webkit-details-marker {
  display: none;
}
/* The arrow keeps its place at the end of the first line, and points down (up when open) in both languages. */
.med-caps summary::after {
  content: '';
  position: absolute;
  inset-inline-end: 6px;
  top: 22px;
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.med-caps[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}
.med-caps-row {
  display: flex;
  flex-wrap: wrap;
  row-gap: 4px;
  min-width: 0;
  padding-inline-start: 4px;
}
.med-caps-row .cap-dot {
  width: 20px;
  height: 20px;
  margin-inline-start: -5px;
  box-shadow:
    0 0 0 2px var(--color-page),
    inset 0 0 0 1px rgba(35, 39, 46, 0.35);
  transition: margin 400ms cubic-bezier(0.16, 1, 0.3, 1);
}
.med-caps summary:hover .cap-dot,
.med-caps[open] .med-caps-row .cap-dot {
  margin-inline-start: 3px;
}
.med-caps-intro {
  margin: 0 0 14px;
  color: var(--color-muted);
}
.med-caps-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.med-cap {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  height: 100%;
  min-height: var(--target-min);
  padding: 10px 14px;
  border: 1.5px solid var(--color-line);
  border-radius: 14px;
  background: var(--color-page);
  color: var(--color-graphite);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition:
    background-color 150ms,
    border-color 150ms;
}
.med-cap:hover {
  border-color: var(--color-graphite);
}
.med-cap[aria-pressed='true'] {
  border-color: var(--color-graphite);
  background: var(--color-mist);
  box-shadow: inset 0 0 0 1.5px var(--color-graphite);
}
.med-cap .cap-dot {
  width: 24px;
  height: 24px;
}
.med-cap b {
  display: block;
}
.med-cap-means {
  display: block;
  color: var(--color-muted);
  line-height: 1.35;
}
@media (prefers-reduced-motion: no-preference) {
  .med-caps[open] .med-caps-list li {
    animation: cap-in 420ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
    animation-delay: calc(var(--i, 0) * 28ms);
  }
  .med-cap .cap-dot {
    transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .med-cap:hover .cap-dot,
  .med-cap[aria-pressed='true'] .cap-dot {
    transform: scale(1.15);
  }
}
@keyframes cap-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media print {
  .lang-btn,
  .med-find,
  .med-jump {
    display: none;
  }
  .med-table tr {
    break-inside: avoid;
  }
}
