/* Forty-six focuses — blurart radius sweep.
 * Dark ground on purpose: the prints are saturated speckle and they only sing
 * against an unlit surround, the way a chart is read in an unlit exam room. */

@font-face {
  font-family: "Snellen";
  src: url("/fonts/Snellen.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Optician Sans";
  src: url("/fonts/Optician-Sans.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --bg:      #0b0e13;
  --surface: #141a24;
  --raised:  #1c2431;
  --line:    #27313f;
  --ink:     #e8eef5;
  --dim:     #7d8da3;
  --faint:   #4d5b6e;
  /* Duochrome — the red/green pair an optometrist uses to find the endpoint of a
   * refraction. Here it encodes the same thing: green where the focus reconstructs
   * well, red where the blur has taken too much away. */
  --duo-green: #3dd68c;
  --duo-red:   #e5484d;

  --ui: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --maxw: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: clamp(0.975rem, 0.9rem + 0.3vw, 1.075rem);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Faint vignette: an illuminated chart in a dark room. */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 90% 60% at 50% 0%, #16202c 0%, var(--bg) 70%);
}

img { max-width: 100%; height: auto; display: block; }

:focus-visible {
  outline: 2px solid var(--duo-green);
  outline-offset: 3px;
}

/* ── masthead ─────────────────────────────────────────────────────────── */

.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(3rem, 9vw, 6.5rem) var(--gutter) clamp(2rem, 5vw, 3.25rem);
}

.eyebrow {
  font-family: "Optician Sans", var(--ui);
  font-size: 0.75rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 clamp(1.5rem, 4vw, 2.5rem);
}

.display {
  font-family: "Snellen", Georgia, serif;
  font-weight: 400;
  /* Snellen is an optotype face: the caps fill the whole em box, so it needs a
   * line-height at or above 1 — anything tighter and the rows collide. */
  /* Snellen's advance is ~1.03em — much wider than a normal face — so the floor
   * has to stay fluid or "FORTY-SIX" runs off a phone screen. */
  font-size: clamp(1.75rem, 9vw, 6.25rem);
  line-height: 1.04;
  letter-spacing: 0.005em;
  overflow-wrap: normal;
  hyphens: none;
  text-transform: uppercase;
  margin: 0 0 clamp(1.5rem, 4vw, 2.25rem);
}

.lede {
  max-width: 46ch;
  color: var(--dim);
  font-size: clamp(1rem, 0.95rem + 0.4vw, 1.2rem);
  margin: 0;
}
.lede em { color: var(--ink); font-style: normal; }

/* ── bench ────────────────────────────────────────────────────────────── */

/* Wider than the prose: the plates are 1280px native and want to land as close
 * to 1:1 as possible — at this width each plate is ~640 CSS px, which is exactly
 * 1:1 on a 2x display, where the speckle reads as itself instead of as moire. */
.bench {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(3rem, 8vw, 5rem);
}

.plates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

.plate { margin: 0; }

.plate-label {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding-bottom: 0.7rem;
  flex-wrap: wrap;
}

.tick {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--faint);
  letter-spacing: 0.05em;
}

.plate-name {
  font-family: "Optician Sans", var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
}

.plate-note {
  color: var(--faint);
  font-size: 0.78rem;
  margin-left: auto;
}

/* The stack: every frame is a layer, so changing radius is an opacity swap
 * between already-decoded images. The <img> is never emptied, so it never
 * blanks or half-paints. */
.stack {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  line-height: 0;
}

.stack-base { width: 100%; }

.stack .layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}
.stack .layer.is-active { opacity: 1; }

/* ── dial ─────────────────────────────────────────────────────────────── */

.dial {
  margin-top: clamp(1.75rem, 4vw, 2.75rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: clamp(1.1rem, 3vw, 1.75rem);
}

.dial-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.dial-label {
  font-family: "Optician Sans", var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--dim);
}

.readout-r {
  font-family: var(--mono);
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.unit {
  font-size: 0.36em;
  color: var(--faint);
  margin-left: 0.35em;
  letter-spacing: 0.08em;
}

.track-wrap {
  position: relative;
  height: 64px;
}

.curve {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The range input sits transparently over the curve; the curve is the track. */
.slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: ew-resize;
}
.slider::-webkit-slider-runnable-track { height: 100%; background: none; }
.slider::-moz-range-track { height: 100%; background: none; }

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 3px;
  height: 64px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--bg), 0 0 12px rgba(232, 238, 245, 0.45);
}
.slider::-moz-range-thumb {
  width: 3px;
  height: 64px;
  border: 0;
  border-radius: 1px;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--bg), 0 0 12px rgba(232, 238, 245, 0.45);
}

.scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--faint);
  margin-top: 0.5rem;
}
.scale-mid { color: var(--dim); }

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.75rem, 2vw, 1.5rem);
  margin: clamp(1.1rem, 3vw, 1.6rem) 0 0;
  padding-top: clamp(1rem, 2.5vw, 1.4rem);
  border-top: 1px solid var(--line);
}
.metric { min-width: 0; }
.metric dt {
  font-family: "Optician Sans", var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  color: var(--dim);
  margin-bottom: 0.3rem;
}
.metric dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}
.of { color: var(--faint); font-size: 0.7em; }
.metric-note {
  font-family: var(--ui) !important;
  font-size: 0.72rem !important;
  color: var(--faint);
  line-height: 1.45;
  margin-top: 0.3rem !important;
}

/* ── notes ────────────────────────────────────────────────────────────── */

.notes {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) var(--gutter) clamp(4rem, 10vw, 7rem);
  border-top: 1px solid var(--line);
}

.section-head {
  font-family: "Optician Sans", var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--dim);
  margin: 0 0 clamp(1.5rem, 4vw, 2.25rem);
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: clamp(1.5rem, 4vw, 2.75rem);
}
.note-grid h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  letter-spacing: -0.005em;
}
.note-grid p {
  margin: 0;
  color: var(--dim);
  font-size: 0.9rem;
}
.note-grid em { color: var(--ink); font-style: normal; }

.colophon {
  margin: clamp(2.5rem, 6vw, 4rem) 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.78rem;
  max-width: 60ch;
}

/* ── responsive ───────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .plates { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .plate-note { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
