/* === Visual acuity converter (tool id "acuity") ===
   Sits inside <section class="panel dark tool-panel">. Reuses .pill, .fchip and the dark-panel
   rules from style.css / pages.css; everything new is prefixed tl-acuity-. Colours come from the
   theme variables so both site themes work. Reading text is 16px or more. */

.tl-acuity { width: 100%; min-width: 0; color: #fff; font-size: clamp(16px, 1.05vw, 20px); line-height: 1.5; }
.tl-acuity *, .tl-acuity *::before, .tl-acuity *::after { box-sizing: border-box; }
.tl-acuity :focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.tl-acuity [hidden] { display: none !important; }

/* Two cards side by side: input on the dark panel, result on white */
.tl-acuity-grid { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: clamp(16px, 1.6vw, 32px); align-items: stretch; }
.tl-acuity-card { display: flex; flex-direction: column; gap: clamp(16px, 1.3vw, 26px); min-width: 0; padding: clamp(22px, 2.4vw, 48px); border-radius: var(--r); }
.tl-acuity-in { border: 1px solid rgb(255 255 255 / 0.16); background: rgb(255 255 255 / 0.05); }
.tl-acuity-out { background: #fff; color: var(--navy); }
.tl-acuity-out :focus-visible { outline-color: var(--blue); }
.tl-acuity-h { font-size: clamp(24px, 1.9vw, 38px); font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.tl-acuity-in .tl-acuity-h { color: #fff; }
.tl-acuity-lead { margin-top: -6px; color: rgb(255 255 255 / 0.82); }

/* Fields */
.tl-acuity-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tl-acuity-field label { color: #fff; font-size: clamp(16px, 1vw, 19px); font-weight: 500; line-height: 1.3; }
.tl-acuity-input { width: 100%; min-width: 0; height: clamp(52px, 3.5vw, 66px); padding: 0 16px; border: 1px solid rgb(255 255 255 / 0.38); border-radius: 14px; background: rgb(255 255 255 / 0.08); color: #fff; font-size: clamp(17px, 1.15vw, 22px); font-weight: 500; transition: border-color 0.25s, background-color 0.25s; }
.tl-acuity-input::placeholder { color: rgb(255 255 255 / 0.45); font-weight: 400; }
.tl-acuity-input:hover { border-color: rgb(255 255 255 / 0.7); }
.tl-acuity-input:focus { border-color: #fff; background: rgb(255 255 255 / 0.14); }
.tl-acuity-input:focus-visible { outline: 2px solid var(--soft); outline-offset: 2px; }
.tl-acuity-input[aria-invalid="true"] { border-color: var(--pale); box-shadow: inset 0 0 0 1px var(--pale); }
.tl-acuity-input-lg { height: clamp(58px, 4vw, 76px); font-size: clamp(20px, 1.5vw, 28px); }
.tl-acuity-select { position: relative; }
.tl-acuity-select::after { content: ""; position: absolute; right: 16px; top: 50%; width: 10px; height: 10px; margin-top: -7px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); pointer-events: none; }
.tl-acuity-select select { padding-right: 42px; -webkit-appearance: none; appearance: none; cursor: pointer; text-overflow: ellipsis; }
.tl-acuity select option { background: #fff; color: var(--navy); }
.tl-acuity-hint { color: rgb(255 255 255 / 0.74); font-size: 16px; line-height: 1.4; }
.tl-acuity-err { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; background: rgb(255 255 255 / 0.1); color: #fff; font-size: 16px; line-height: 1.4; }
.tl-acuity-err::before { content: "!"; display: grid; flex: none; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--pale); color: var(--navy); font-size: 14px; font-weight: 700; line-height: 1; }

.tl-acuity-set { min-width: 0; margin: 0; padding: 0; border: 0; }
.tl-acuity-set legend { display: block; width: 100%; margin-bottom: 12px; padding: 14px 0 0; border-top: 1px solid rgb(255 255 255 / 0.14); color: var(--pale); font-size: clamp(14px, 0.85vw, 16px); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.tl-acuity-row { display: grid; gap: 14px; align-items: start; }
.tl-acuity-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tl-acuity-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.tl-acuity-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-acuity-chips-l { flex: 1 0 100%; color: rgb(255 255 255 / 0.74); font-size: 16px; }
.tl-acuity .fchip { height: 44px; padding: 0 18px; font-size: 16px; }
.tl-acuity .fchip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.tl-acuity-tools { display: flex; flex-wrap: wrap; gap: 12px; }

/* "Same result, every notation" strip at the foot of the input card */
.tl-acuity-same { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding: clamp(16px, 1.4vw, 24px); border-radius: calc(var(--r) * 0.7); background: rgb(var(--soft-rgb) / 0.12); }
.tl-acuity-same-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.tl-acuity-same-row span { padding: 6px 14px; border-radius: 999px; background: #fff; color: var(--navy); font-size: clamp(16px, 1.05vw, 20px); font-weight: 500; white-space: nowrap; }
.tl-acuity-same-row i { color: var(--pale); font-style: normal; font-weight: 500; }
.tl-acuity-same-cap { color: rgb(255 255 255 / 0.82); font-size: 16px; }
.tl-acuity .pill:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Result card */
.tl-acuity-head { display: flex; flex-direction: column; gap: 6px; }
.tl-acuity-eyebrow { color: var(--gray-500); font-size: clamp(14px, 0.85vw, 16px); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }
.tl-acuity-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; }
.tl-acuity-big-a { color: var(--blue); font-size: clamp(52px, 5vw, 104px); font-weight: 500; line-height: 1; letter-spacing: -0.03em; }
.tl-acuity-big-a small { display: block; margin-bottom: 4px; color: var(--gray-500); font-size: 16px; letter-spacing: 0; line-height: 1.2; }
.tl-acuity-big-b { color: var(--gray-700); font-size: clamp(18px, 1.4vw, 28px); font-weight: 500; }
.tl-acuity-big.is-words .tl-acuity-big-a { font-size: clamp(34px, 3vw, 60px); letter-spacing: -0.02em; }
.is-empty .tl-acuity-big-a { color: rgb(var(--navy-rgb) / 0.25); }

/* Acuity scale: weaker on the left, sharper on the right (logMAR 1.3 to -0.3). acuity.js places the
   marker and ticks from the left, so on right-to-left pages the scale keeps this direction (rtl:ignore). */
.tl-acuity-scale { padding-top: 4px; }
/*rtl:begin:ignore*/
.tl-acuity-track { position: relative; height: 14px; border-radius: 999px; background: linear-gradient(to right, rgb(var(--blue-rgb) / 0.14) 0 18.75%, rgb(var(--blue-rgb) / 0.32) 18.75% 59%, rgb(var(--blue-rgb) / 0.6) 59% 74.5%, var(--blue) 74.5% 100%); }
.tl-acuity-marker { position: absolute; top: 50%; left: 50%; width: 28px; height: 28px; border: 5px solid var(--navy); border-radius: 50%; background: #fff; box-shadow: 0 6px 16px -4px rgb(var(--ink-rgb) / 0.45); transform: translate(-50%, -50%); transition: left 0.7s var(--ease), opacity 0.3s; }
.is-empty .tl-acuity-marker { opacity: 0; }
.tl-acuity-ticks { position: relative; height: 30px; margin-top: 8px; }
.tl-acuity-tick { position: absolute; top: 0; padding-top: 8px; color: var(--gray-700); font-size: 14px; font-weight: 500; white-space: nowrap; transform: translateX(-50%); }
.tl-acuity-tick::before { content: ""; position: absolute; left: 50%; top: 0; width: 1px; height: 6px; background: rgb(var(--navy-rgb) / 0.3); }
.tl-acuity-tick.is-end { transform: translateX(-100%); }
.tl-acuity-tick.is-end::before { left: auto; right: 0; }
/*rtl:end:ignore*/
.tl-acuity-ends { display: flex; justify-content: space-between; color: var(--gray-500); font-size: 14px; }
.tl-acuity-ends span:first-child::before { content: "\2190  "; }
.tl-acuity-ends span:last-child::after { content: "  \2192"; }

.tl-acuity-empty { padding: 16px 18px; border: 1.5px dashed rgb(var(--blue-rgb) / 0.35); border-radius: 16px; background: var(--tint); color: var(--navy); }
.tl-acuity-note { padding: 12px 16px; border-radius: 14px; background: var(--tint); color: var(--navy); font-size: 16px; line-height: 1.45; }
.tl-acuity-msg { padding: 18px 22px; border-radius: 16px; background: var(--navy); color: #fff; font-size: clamp(17px, 1.15vw, 22px); line-height: 1.45; }
.tl-acuity-out[data-band="normal"] .tl-acuity-msg, .tl-acuity-out[data-band="better"] .tl-acuity-msg { background: var(--blue-dk); }

.tl-acuity-tiles { display: grid; gap: 10px; }
.tl-acuity-tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tl-acuity-tiles-5 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tl-acuity-tiles-5 > :nth-child(-n+3) { grid-column: span 2; }
.tl-acuity-tiles-5 > :nth-child(n+4) { grid-column: span 3; }
.tl-acuity-tiles-pct { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tl-acuity-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px 16px; border-radius: 16px; background: var(--tint); }
.tl-acuity-tile-l { color: var(--gray-500); font-size: 15px; font-weight: 500; line-height: 1.3; }
.tl-acuity-tile-v { color: var(--navy); font-size: clamp(22px, 1.7vw, 34px); font-weight: 500; line-height: 1.1; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tl-acuity-tile-v small { display: block; margin-bottom: 2px; color: var(--gray-500); font-size: 14px; font-weight: 500; letter-spacing: 0; }
.tl-acuity-tile-n { margin-top: auto; color: var(--gray-700); font-size: 16px; line-height: 1.4; }
.tl-acuity-tile.is-undef .tl-acuity-tile-v { color: var(--gray-500); font-size: clamp(18px, 1.3vw, 26px); }

.tl-acuity-details { border-top: 1px solid rgb(var(--navy-rgb) / 0.12); padding-top: 14px; }
.tl-acuity-details summary { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--blue-dk); font-weight: 500; cursor: pointer; list-style: none; }
.tl-acuity-details summary::-webkit-details-marker { display: none; }
.tl-acuity-details summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.25s; }
.tl-acuity-details[open] summary::before { transform: rotate(45deg); }
.tl-acuity-exact { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin: 8px 0 0; }
.tl-acuity-exact div { min-width: 0; }
.tl-acuity-exact dt { color: var(--gray-500); font-size: 15px; font-weight: 500; line-height: 1.3; }
.tl-acuity-exact dd { margin: 2px 0 0; color: var(--navy); font-size: clamp(18px, 1.25vw, 24px); font-weight: 500; }
.tl-acuity-always { margin-top: auto; padding-top: 16px; border-top: 1px solid rgb(var(--navy-rgb) / 0.12); color: var(--gray-700); font-size: 16px; line-height: 1.5; }

/* Reference table */
.tl-acuity-ref { margin-top: clamp(16px, 1.6vw, 32px); border: 1px solid rgb(255 255 255 / 0.16); border-radius: var(--r); background: rgb(255 255 255 / 0.05); }
.tl-acuity-ref > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: clamp(16px, 1.4vw, 26px) clamp(20px, 2.4vw, 48px); color: #fff; font-size: clamp(18px, 1.3vw, 26px); font-weight: 500; cursor: pointer; list-style: none; }
.tl-acuity-ref > summary::-webkit-details-marker { display: none; }
.tl-acuity-ref > summary::after { content: "+"; display: grid; flex: none; place-items: center; width: 40px; height: 40px; border: 1px solid rgb(255 255 255 / 0.5); border-radius: 50%; font-size: 24px; font-weight: 400; line-height: 1; transition: transform 0.3s var(--ease); }
.tl-acuity-ref[open] > summary::after { transform: rotate(45deg); }
.tl-acuity-refhint { padding: 0 clamp(20px, 2.4vw, 48px) 12px; color: rgb(255 255 255 / 0.78); }
.tl-acuity-tblwrap { overflow-x: auto; padding: 0 clamp(8px, 1.6vw, 32px) clamp(12px, 1.6vw, 32px); }
.tl-acuity-tbl { width: 100%; border-collapse: collapse; font-size: clamp(16px, 1.02vw, 20px); font-variant-numeric: tabular-nums; }
.tl-acuity-tbl th, .tl-acuity-tbl td { padding: 10px clamp(10px, 1.1vw, 20px); text-align: left; vertical-align: middle; line-height: 1.35; }
.tl-acuity-tbl thead th { border-bottom: 1px solid rgb(255 255 255 / 0.22); color: var(--pale); font-size: clamp(13px, 0.8vw, 15px); font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: bottom; }
.tl-acuity-tbl tbody tr + tr > * { border-top: 1px solid rgb(255 255 255 / 0.1); }
.tl-acuity-tbl td { color: rgb(255 255 255 / 0.86); }
.tl-acuity-tbl tr.is-strong td, .tl-acuity-tbl tr.is-strong .tl-acuity-rowbtn { font-weight: 700; }
.tl-acuity-tbl tr.is-current > * { background: rgb(255 255 255 / 0.12); color: #fff; }
.tl-acuity-tbl tr.is-current > :first-child { box-shadow: inset 4px 0 0 var(--soft); }
.tl-acuity-rowbtn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid rgb(255 255 255 / 0.3); border-radius: 999px; background: transparent; color: #fff; font-size: inherit; font-weight: 500; white-space: nowrap; transition: background-color 0.25s, color 0.25s, border-color 0.25s; }
.tl-acuity-rowbtn:hover, .tl-acuity-tbl tr.is-current .tl-acuity-rowbtn { border-color: #fff; background: #fff; color: var(--navy); }

.tl-acuity-disc { max-width: 62em; margin-top: clamp(16px, 1.6vw, 32px); color: rgb(255 255 255 / 0.8); font-size: 16px; line-height: 1.55; }
.tl-acuity-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: clamp(16px, 1.6vw, 28px); }

/* Tablet: one column */
@media (max-width: 991.98px) {
  .tl-acuity-grid { grid-template-columns: minmax(0, 1fr); }
}
/* Phone */
@media (max-width: 640px) {
  .tl-acuity-card { gap: 16px; padding: 20px 18px; border-radius: 22px; }
  .tl-acuity-row-2, .tl-acuity-row-3 { grid-template-columns: minmax(0, 1fr); }
  .tl-acuity-tiles-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tl-acuity-tiles-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tl-acuity-tiles-5 > :nth-child(-n+3), .tl-acuity-tiles-5 > :nth-child(n+4) { grid-column: span 1; }
  .tl-acuity-tiles-5 > :first-child { grid-column: span 2; }
  .tl-acuity-tiles-pct { grid-template-columns: minmax(0, 1fr); }
  .tl-acuity-tile { padding: 12px 14px; }
  .tl-acuity-msg { padding: 16px 18px; }
  .tl-acuity-tick.is-end { display: none; }
  .tl-acuity-same-row { gap: 6px 8px; }
  .tl-acuity-same-row span { padding: 5px 11px; }
  .tl-acuity-ref { border-radius: 22px; }
  .tl-acuity-ref > summary { padding: 16px 18px; }
  .tl-acuity-refhint { padding: 0 18px 10px; }
  /* The table becomes one compact card per line: the line button, then its four values */
  .tl-acuity-tblwrap { padding: 0 10px 12px; }
  .tl-acuity-tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tl-acuity-tbl, .tl-acuity-tbl tbody { display: block; }
  .tl-acuity-tbl tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; padding: 12px 8px; }
  .tl-acuity-tbl tbody tr + tr { border-top: 1px solid rgb(255 255 255 / 0.12); }
  .tl-acuity-tbl tbody tr + tr > * { border-top: 0; }
  .tl-acuity-tbl tbody th, .tl-acuity-tbl tbody td { display: block; padding: 0; }
  .tl-acuity-tbl tbody th { grid-column: 1 / -1; }
  .tl-acuity-tbl tbody td { font-size: 16px; }
  .tl-acuity-tbl tbody td::before { content: attr(data-label); display: block; margin-bottom: 1px; color: var(--pale); font-size: 13px; font-weight: 500; line-height: 1.3; }
  .tl-acuity-tbl tr.is-current { border-radius: 14px; background: rgb(255 255 255 / 0.12); box-shadow: inset 4px 0 0 var(--soft); }
  .tl-acuity-tbl tr.is-current > * { background: none; }
  .tl-acuity-tbl tr.is-current > :first-child { box-shadow: none; }
  .tl-acuity-actions .pill { width: 100%; white-space: normal; text-align: center; line-height: 1.2; }
}

@media (prefers-reduced-motion: reduce) {
  .tl-acuity-marker, .tl-acuity-input, .tl-acuity-rowbtn, .tl-acuity-details summary::before, .tl-acuity-ref > summary::after { transition: none !important; }
}

@media print {
  .tl-acuity { color: #000; }
  .tl-acuity-in, .tl-acuity-ref, .tl-acuity-actions { display: none !important; }
  .tl-acuity-grid { grid-template-columns: 1fr; }
  .tl-acuity-out { border: 1px solid #999; }
  .tl-acuity-disc { color: #000; }
}

/* Right-to-left pages: the scale reads left to right like its marker and ticks; numbers (logMAR -0.3,
   Snellen 6/12) are typed left to right */
/*rtl:begin:ignore*/
[dir="rtl"] .tl-acuity-scale { direction: ltr; }
[dir="rtl"] .tl-acuity-input { direction: ltr; text-align: right; }
/*rtl:end:ignore*/
