/* ==========================================================================
   Sheron Yang — stylesheet
   One screen, framed like an instrument: a masthead above the top axis, the
   particle field in the band between the axes, controls below the bottom
   axis. Views (home, index, project, contact) are body[data-view] and
   body[data-overlay] states; js/main.js switches them.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Font: Lekton, a typewriter face drawn after Olivetti machines (subset
   WOFF2s built by fonts/build.py; OFL, see fonts/OFL-Lekton.txt). One typed
   voice throughout, like a hand-typed label: hierarchy comes from size,
   weight, case and spacing.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Lekton";
  src: url("../fonts/Lekton-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Lekton";
  src: url("../fonts/Lekton-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
  /* The palette is symmetric (light = 255 - dark), so the cursor lens maps
     each theme exactly onto the other with a plain invert(1). */
  --bg: #121212;
  --ink: #e8e8e8;
  --ink-2: #9b9b9b;   /* secondary text, 6.7:1 on --bg */
  --ink-3: #5c5c5c;   /* ticks and quiet marks */

  --type: "Lekton", "Courier New", ui-monospace, monospace;

  /* Layout anchors. The axes sit --line from the top and bottom edges; the
     rows of controls anchor to the same value, --gap away from their axis. */
  --line: 15vh;
  --mid: 50vh;
  --edge: clamp(16px, 2.6vw, 72px);
  --gap: clamp(12px, 1.7vh, 26px);
  --panel-w: clamp(400px, 42vw, 1100px);
  --pad: clamp(20px, 2.8vw, 76px);

  /* Type scales with the viewport width up to large desktop displays. */
  --fs-label: clamp(11px, 8.6px + 0.27vw, 14.5px);   /* typed caps: nav, controls */
  --fs-small: calc(var(--fs-label) * 0.95);           /* readout, status */
  --fs-spec: clamp(12.5px, 10.6px + 0.22vw, 16px);    /* typed spec lines */
  --fs-name: min(clamp(1.4rem, 2.1vw, 3.2rem), var(--line) * 0.32); /* fits short screens */
  --fs-title: clamp(1.4rem, 0.7rem + 1.6vw, 3rem);
  --fs-heading: clamp(1.25rem, 0.8rem + 0.7vw, 2rem);
  --fs-about: clamp(13px, 10.6px + 0.3vw, 17px);
  --fs-body: clamp(15px, 13px + 0.2vw, 18px);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

@supports (height: 100dvh) {
  :root { --line: 15dvh; --mid: 50dvh; }
}

[data-theme="light"] {
  --bg: #ededed;
  --ink: #171717;
  --ink-2: #646464;   /* 5.1:1 on --bg */
  --ink-3: #a3a3a3;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none; /* no pull-to-refresh or bounce on phones */
  background: var(--bg);
  color: var(--ink);
}

html {
  -webkit-text-size-adjust: 100%; /* iOS would inflate text in landscape */
  text-size-adjust: 100%;
}

body {
  font: 400 var(--fs-body) / 1.7 var(--type);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Without view transitions, the theme cross-fades instead of sweeping. */
@supports not (view-transition-name: none) {
  body { transition: background-color 0.5s ease, color 0.5s ease; }
}

h1, h2, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }

button {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}

a, button { -webkit-tap-highlight-color: transparent; }

.nowrap { white-space: nowrap; }

/* Read by assistive tech, not shown. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 5px;
}

::selection { background: var(--ink); color: var(--bg); }

/* Typed caps, like the field names on a label: navigation, controls,
   counters, readouts. */
.nav, .readout, .status, .theme, .row-no, .panel-top, .panel-steps {
  font-size: var(--fs-label);
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Typed spec lines (sentence case), like "Eau de Parfum / 50 ml". */
.row-meta, .panel-meta, .panel-link, .contact-list li > span, .source {
  font-size: var(--fs-spec);
  line-height: 1.6;
  letter-spacing: 0.02em;
}

/* The frame's labels sit on paper, so project rows ghosting past the axes
   pass behind them instead of through them. */
.name a, .nav a, .theme button, .status {
  --chip-y: 0.25em;
  --chip-x: 0.5em;
  padding: var(--chip-y) var(--chip-x);
  margin: calc(-1 * var(--chip-y)) calc(-1 * var(--chip-x));
  background: var(--bg);
}

/* Touch screens: every control's target is at least 24px tall (the padding
   grows; the text stays where it is). */
@media (pointer: coarse) {
  .nav a, .theme button, .panel-close, .panel-steps a {
    --chip-y: 6px;
    padding-top: var(--chip-y);
    padding-bottom: var(--chip-y);
    margin-top: calc(-1 * var(--chip-y));
    margin-bottom: calc(-1 * var(--chip-y));
  }
  .name a { --chip-y: 4px; }
  .panel-link, .source a { padding: 3px 0; margin: -3px 0; }
}

/* --------------------------------------------------------------------------
   Frame: masthead, axes, band, footer
   -------------------------------------------------------------------------- */

/* The name floats centered in the band above the top axis (the controls,
   by contrast, sit on the axes): typed caps, spaced like a label. */
.name {
  position: fixed;
  z-index: 40;
  top: 0;
  left: var(--edge);
  height: var(--line);
  display: flex;
  align-items: center;
  font: 400 var(--fs-name) / 1 var(--type);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.name a {
  display: block;
  transition: letter-spacing 0.9s var(--ease-out);
}

/* The name breathes out, its letters easing apart. */
@media (hover: hover) {
  .name a:hover { letter-spacing: 0.24em; }
}

.nav {
  position: fixed;
  z-index: 40;
  right: var(--edge);
  bottom: calc(100% - var(--line) + var(--gap));
  display: flex;
  gap: 2.6em;
}

.count {
  margin-left: 0.45em;
  font-size: 0.82em;
  vertical-align: 0.45em;
  color: var(--ink-2);
}

/* Square markers: hover shows an outline, the current view a solid one. */
.nav a, .theme button, .panel-close, .panel-steps a {
  position: relative;
  display: inline-block;
  transition: transform 0.5s var(--ease-out);
}

.nav a::before, .theme button::before {
  content: "";
  position: absolute;
  left: calc(var(--chip-x) - 1.15em); /* measured from the text, not the chip */
  top: 50%;
  width: 0.5em;
  height: 0.5em;
  margin-top: -0.3em;
  border: 1px solid currentColor;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.35s ease, transform 0.5s var(--ease-out), background-color 0.3s ease;
}

.nav a[aria-current]::before, .theme button[aria-pressed="true"]::before {
  opacity: 1;
  transform: none;
  background: currentColor;
}

.theme button[aria-pressed="false"] { color: var(--ink-2); }

@media (hover: hover) {
  .nav a:hover::before, .theme button:hover::before { opacity: 1; transform: none; }
  .theme button:hover { color: var(--ink); }
}

.axis {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ink);
  pointer-events: none;
}

.axis-top    { top: var(--line); }
.axis-bottom { bottom: var(--line); }

/* Ruler ticks hang into the band: minor every 1/48 of the span, major every
   1/6. */
.axis::before, .axis::after {
  content: "";
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  background-repeat: repeat-x;
}

.axis::before {
  height: 4px;
  background-image: linear-gradient(to right, var(--ink-3) 1px, transparent 0);
  background-size: calc((100% - 1px) / 48) 100%;
}

.axis::after {
  height: 8px;
  background-image: linear-gradient(to right, var(--ink-2) 1px, transparent 0);
  background-size: calc((100% - 1px) / 6) 100%;
}

.axis-top::before, .axis-top::after { top: 1px; }
.axis-bottom::before, .axis-bottom::after { bottom: 1px; }

/* The pointer's position, marked on both axes. */
.caret {
  position: absolute;
  left: 0;
  top: -5px;
  width: 1px;
  height: 11px;
  background: var(--ink);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.is-probing .caret { opacity: 1; }

.band {
  position: fixed;
  z-index: 1;
  top: var(--line);
  bottom: var(--line);
  left: 0;
  right: 0;
  overflow: hidden;
}

/* A finger drags across the field to probe it (pinch zoom still works). */
.band, .about { touch-action: pinch-zoom; }

.field {
  display: block;
  width: 100%;
  height: 100%;
}

/* A caption on the field's bottom-left, mirroring the readout at top-right:
   both sit --gap inside their axis. */
.about {
  position: fixed;
  z-index: 6;
  left: var(--edge);
  bottom: calc(1.02*(var(--line) + var(--gap)));
  max-width: min(48ch, 100vw - 2 * var(--edge)); /* 46 characters + tracking */
  font: 400 var(--fs-about) / 1.45 var(--type);
  letter-spacing: 0.005em;
  text-wrap: balance;
  transition: opacity 0.7s var(--ease-out) 0.25s, transform 1s var(--ease-out) 0.25s, visibility 0s;
}

[data-view="projects"] .about {
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.4em);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s 0.3s;
}

.readout {
  position: fixed;
  z-index: 6;
  right: var(--edge);
  top: calc(var(--line) + var(--gap));
  font-size: var(--fs-small);
  white-space: pre;
  color: var(--ink-3);
}

.is-probing .readout { color: var(--ink-2); }

.status, .theme {
  position: fixed;
  z-index: 40;
  top: calc(100% - var(--line) + var(--gap));
}

.status {
  left: var(--edge);
  font-size: var(--fs-small);
  white-space: pre;
  color: var(--ink-2);
}

.theme {
  right: var(--edge);
  display: flex;
  gap: 2.6em;
}

/* --------------------------------------------------------------------------
   Typing (js/text.js typeIn): while an element types itself in, each
   character is a key, hidden until it is struck. Keys are custom elements
   (<type-key>), so no rule written for the page's spans can restyle them.
   -------------------------------------------------------------------------- */

type-key { visibility: hidden; }
type-key.is-struck { visibility: inherit; }

/* --------------------------------------------------------------------------
   Project index
   -------------------------------------------------------------------------- */

/* The list scrolls from anywhere on the page; its text keeps to the left of
   where a panel opens. Rows are in full ink between the axes and ghost at
   15% beyond them (hard stops: they never fade). Set --ghost to 0 to hide
   rows outside the band entirely. */
.index {
  --ghost: 0.15;
  position: fixed;
  z-index: 5;
  inset: 0;
  padding: calc(var(--line) + clamp(28px, 7vh, 72px)) 2vw calc(var(--line) + 30vh) var(--edge);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(rgb(0 0 0 / var(--ghost)) var(--line), #000 var(--line),
    #000 calc(100% - var(--line)), rgb(0 0 0 / var(--ghost)) calc(100% - var(--line)));
  mask-image: linear-gradient(rgb(0 0 0 / var(--ghost)) var(--line), #000 var(--line),
    #000 calc(100% - var(--line)), rgb(0 0 0 / var(--ghost)) calc(100% - var(--line)));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0s 0.35s;
}

.index::-webkit-scrollbar { display: none; }

.index-list { max-width: calc(100vw - var(--panel-w) - var(--edge) - 2vw); }

[data-view="projects"] .index {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
}

.row + .row { margin-top: clamp(26px, 4.6vh, 50px); }

.row-link {
  display: grid;
  grid-template-columns: 4.4em 1fr;
  align-items: baseline;
  transition: opacity 0.45s ease;
}

.row-no {
  grid-row: 1 / span 2;
  color: var(--ink-2);
  white-space: nowrap;
}

/* A short rule grows out of the number toward the active/hovered title
   (scaled, not resized, so it animates without relayout). */
.row-no::after {
  content: "";
  display: inline-block;
  width: 1.6em;
  height: 1px;
  margin-left: 0.6em;
  vertical-align: 0.3em;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease-out);
}

.row-title {
  display: block;
  font: 400 var(--fs-title) / 1.15 var(--type);
  text-wrap: balance;
  transition: transform 0.7s var(--ease-out);
}

.row-meta {
  grid-column: 2;
  margin-top: 0.5em;
  color: var(--ink-2);
}

/* Titles type themselves in (js/main.js); numbers and specs follow. */
.row-no, .row-meta {
  opacity: 0;
  transition: opacity 0s 0.35s, color 0.4s ease;
}

[data-view="projects"] .row-no,
[data-view="projects"] .row-meta {
  opacity: 1;
  transition: opacity 0.9s var(--ease-out) calc(0.3s + var(--i) * 0.06s), color 0.4s ease;
}

.row.is-active .row-title { transform: translateX(0.35em); }
.row.is-active .row-no::after { transform: none; }
.row.is-active .row-no { color: var(--ink); }
/* With a project open the other rows recede, but not the one under the
   pointer: hovering lights a row the same way before and after. */
[data-overlay="project"] .row:not(.is-active) .row-link:not(:hover) { opacity: 0.32; }

@media (hover: hover) {
  .index-list.has-hover .row-link:not(:hover) { opacity: 0.32; }
  .row-link:hover .row-title { transform: translateX(0.35em); }
  .row-link:hover .row-no::after { transform: none; }
  .row-link:hover .row-no, .row-link:hover .row-meta { color: var(--ink); }
}

/* --------------------------------------------------------------------------
   Panels (a project, contact): full-height sheets under the frame; their
   content scrolls inside the band.
   -------------------------------------------------------------------------- */

.panel {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  background: var(--bg);
  border-left: 1px solid var(--ink);
  transform: translateX(101%);
  visibility: hidden;
  transition: transform 0.85s var(--ease-in-out), visibility 0s 0.85s;
}

/* The arriving panel passes over the leaving one. */
.panel.is-open {
  z-index: 21;
  transform: none;
  visibility: visible;
  transition: transform 1.05s var(--ease-out);
}

/* Project to project: cross-fade in place. */
.panel.is-swap {
  transform: none;
  opacity: 0;
  transition: opacity 0.35s ease, visibility 0s 0.35s;
}

.panel.is-swap.is-open {
  opacity: 1;
  transition: opacity 0.6s var(--ease-out) 0.1s;
}

.panel-top, .panel-steps {
  position: absolute;
  left: var(--pad);
  display: flex;
  gap: 2.6em;
}

.panel-top { bottom: calc(100% - var(--line) + var(--gap)); }
.panel-steps { top: calc(100% - var(--line) + var(--gap)); }

.panel-count { font: inherit; color: var(--ink-2); }

.panel-close::before {
  content: "×";
  display: inline-block;
  margin-right: 0.55em;
  transition: transform 0.6s var(--ease-out);
}

@media (hover: hover) {
  .panel-close:hover::before { transform: rotate(90deg); }
  .panel-steps a:hover { transform: translateX(0.25em); }
  .panel-steps a:first-child:hover { transform: translateX(-0.25em); }
}

.panel-scroll {
  position: absolute;
  top: var(--line);
  bottom: var(--line);
  left: 0;
  right: 0;
  padding: clamp(28px, 5.5vh, 60px) var(--pad) clamp(40px, 9vh, 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.panel-scroll::-webkit-scrollbar { display: none; }

.panel-body h2 {
  font: 700 var(--fs-heading) / 1.3 var(--type);
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.panel h2 { outline: none; } /* focused programmatically when a panel opens */

/* The specs, stacked between hairlines like the typed lines on a label;
   the rules appear as the specs start typing (--delay, set by js/main.js). */
.panel-meta {
  margin-top: 1.4em;
  padding: 0.8em 0;
  border-top: 1px solid var(--ink-3);
  border-bottom: 1px solid var(--ink-3);
  white-space: pre-line;
  color: var(--ink-2);
}

.panel.is-open .panel-meta { animation: rule-in 0.4s ease var(--delay, 0s) backwards; }

@keyframes rule-in {
  from { border-color: transparent; }
}

.panel-body > p:not(.panel-meta) {
  max-width: 36em;
  margin-top: 1.6em;
}

.panel-body > p + p:not(.panel-meta) { margin-top: 1.4em; }

/* Typed links: underlined, nothing else. */
.panel-link, .source a, .contact-list a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--ink-3);
  transition: text-decoration-color 0.3s ease, transform 0.6s var(--ease-out);
}

@media (hover: hover) {
  .panel-link:hover, .source a:hover, .contact-list a:hover { text-decoration-color: currentColor; }
}

/* Panel content arrives in sequence once the sheet is moving; the heading
   and specs type themselves in, and js/main.js sets the --delay of what
   follows them (and of the contact rows, each with its typed link). */
.panel-top, .panel-steps, .panel-body > :not(h2, .panel-meta, .contact-list), .contact-list li {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0s 0.85s;
}

.panel.is-open :is(.panel-top, .panel-steps, .panel-body > :not(h2, .panel-meta, .contact-list), .contact-list li) {
  opacity: 1;
  transform: none;
  transition: opacity 0.9s var(--ease-out) var(--delay, 0.45s), transform 1.1s var(--ease-out) var(--delay, 0.45s);
}

.panel-top { --delay: 0.3s; }
.panel-steps { --delay: 0.66s; }

/* Contact */
.contact-list li + li { margin-top: clamp(18px, 3.4vh, 34px); }

.contact-list a {
  display: inline-block;
  font: 400 clamp(1.8rem, 1rem + 2.2vw, 3.2rem) / 1.15 var(--type);
}

.contact-list li > span {
  display: block;
  margin-top: 0.5em;
  color: var(--ink-2);
}

@media (hover: hover) {
  .contact-list a:hover { transform: translateX(0.12em); }
}

.source {
  margin-top: clamp(40px, 9vh, 96px);
  color: var(--ink-2);
}

.source, .panel-body > p:has(> .panel-link) { text-wrap: balance; }

/* --------------------------------------------------------------------------
   Cursor: a lens that inverts what is under it (js/cursor.js moves it)
   -------------------------------------------------------------------------- */

.cursor {
  position: fixed;
  z-index: 100;
  top: -18px;
  left: -18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
  -webkit-backdrop-filter: invert(1);
  backdrop-filter: invert(1);
}

@supports not ((backdrop-filter: invert(1)) or (-webkit-backdrop-filter: invert(1))) {
  .cursor { border: 1px solid var(--ink); }
}

.is-sweeping .cursor { visibility: hidden; }

@media (hover: none) {
  .cursor { display: none; }
}

/* --------------------------------------------------------------------------
   Intro: a line draws across the middle, then parts into the two axes and
   the band opens between them; the type arrives last.
   -------------------------------------------------------------------------- */

/* The line draws out (scale) and the axes part (translate) as separate
   transitions, so the parting starts fresh, on the same frame as the
   shutters below. */
.intro .axis-top    { translate: 0 calc(var(--mid) - var(--line)); scale: 0 1; }
.intro .axis-bottom { translate: 0 calc(var(--line) - var(--mid)); scale: 0 1; }

.intro-draw :is(.axis-top, .axis-bottom) {
  scale: none;
  transition: scale 0.8s var(--ease-out);
}

.intro-open :is(.axis-top, .axis-bottom) {
  translate: none;
  transition: scale 0.8s var(--ease-out), translate 1.2s var(--ease-in-out);
}

/* The band opens behind two shutters, halves of paper that part with the
   axes: transforms on the axes' curve and clock, so the opening keeps to
   the lines in every frame (js/main.js times the field's rise by the same
   clock). Open, they rest just outside the band, which clips them. */
.band::before, .band::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: calc(50% - 1px);
  background: var(--bg);
}

.band::before { top: 0; transform: translateY(-100%); }
.band::after  { bottom: 0; transform: translateY(100%); }

.intro .band::before, .intro .band::after { transform: none; }

.intro-open .band::before { transform: translateY(-100%); }
.intro-open .band::after  { transform: translateY(100%); }
.intro-open .band::before, .intro-open .band::after { transition: transform 1.2s var(--ease-in-out); }

.intro .name { visibility: hidden; } /* typed in as the intro ends */

/* (The footer's controls are named, not `.footer > *`: a class change on
   <body> then restyles just them, not the whole page.) */
.nav, .status, .theme, .readout {
  transition: opacity 1s var(--ease-out) 0.35s, transform 1.2s var(--ease-out) 0.35s, color 0.4s ease;
}

.intro :is(.nav, .status, .theme, .readout, .about) {
  opacity: 0;
  transform: translateY(8px);
}

/* --------------------------------------------------------------------------
   Theme sweep (View Transitions): the new palette rises from the bottom axis
   -------------------------------------------------------------------------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  animation: sweep 0.95s var(--ease-in-out) both;
}

@keyframes sweep {
  from { clip-path: inset(calc(100% - var(--line)) 0 var(--line) 0); }
  to   { clip-path: inset(0); }
}

/* For the instant the palette switches (js/main.js setTheme). */
.is-retheming *, .is-retheming *::before, .is-retheming *::after { transition: none !important; }

/* --------------------------------------------------------------------------
   Touch screens have no hovering pointer to probe with.
   -------------------------------------------------------------------------- */

/* Touch screens show the readout and carets only while a finger probes. */
@media (hover: none) {
  .readout {
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .is-probing .readout { opacity: 1; }
}

/* --------------------------------------------------------------------------
   Phones and portrait tablets: the index takes the full width and panels
   become sheets that rise from the bottom and cover the frame.
   -------------------------------------------------------------------------- */

@media (max-width: 720px), (max-width: 1100px) and (orientation: portrait) {
  :root { --panel-w: 100vw; }

  .index { padding-right: var(--edge); }
  .index-list { max-width: none; }

  .panel {
    z-index: 50;
    border-left: 0;
    transform: translateY(100%);
  }

  .panel.is-open { z-index: 51; }

  .panel-top, .panel-steps { left: var(--edge); right: var(--edge); justify-content: space-between; }
  .panel-top { bottom: auto; top: calc(var(--line) - var(--gap) - 1.4em); }
  .panel-scroll {
    padding-left: var(--edge);
    padding-right: var(--edge);
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
  }
}

/* Phones: controls stack in their corners. */
@media (max-width: 720px) {
  :root { --fs-title: clamp(1.5rem, 6.2vw, 2rem); }

  .nav, .theme {
    flex-direction: column;
    align-items: flex-end;
    gap: max(0.7em, 12px); /* room for the 24px touch targets */
  }

  .theme { flex-direction: column-reverse; }

  .nav a::before, .theme button::before { left: auto; right: calc(var(--chip-x) - 1.1em); }

  .status { display: none; }

  .row-link { grid-template-columns: 2.9em 1fr; }
  .row-no::after { display: none; }
}

/* The narrowest phones: the caption still sets as four lines. */
@media (max-width: 359px) {
  :root { --fs-about: 12px; }
}

/* --------------------------------------------------------------------------
   Reduced motion: every state change is immediate.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
    animation-duration: 0s !important;
    animation-delay: 0s !important;
  }
}
