/* ==========================================================================
   Akshayaa Kashyap — portfolio
   Mono-first type with one script display face, decorative trailing glyphs
   on section headings, soft shadows.

   Grounds and inks are tokens here, per time of day (light and dark, plus
   desk mode's own four). The accent family is rebuilt at run time from the
   day's Sanzo Wada combination by js/palette.js; the navy values below are
   only the fallback.

   The home page is the desk: index.html carries data-mode="desk" on <html>,
   and the desk's rules are css/desk.css. The other pages have no data-mode.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   Stacking order (z-index)

   Values are grouped rather than sequential; new layers should slot into a
   band rather than inventing a number between two existing ones.

     0        hero stage background (the desk's tabletop)
     1-8      hero props, ordered back-to-front (--z on each element)
     20       hero name lockup, above every prop
     40       dragged / hovered element lifted out of its band
     60       hero mode switcher, above everything drawn in the hero
     100      fixed site header
     200      skip link, above everything
   -------------------------------------------------------------------------- */

:root {
  /* Ground — cool paper, never pure white */
  --bg: #f4f7fa;
  --bg-raised: #fbfcfe;
  --bg-sunken: #e9eff6;
  --surface: #ffffff;
  --surface-muted: #dbe4ee;

  /* Ink — all navy-derived */
  --ink: #16283d;
  --ink-body: #1e3a5f;
  --ink-soft: #3c5a7a;
  --ink-muted: #4e6880;   /* 5.40:1 on paper */

  /* Accent — sampled from public/assets/favicon.png.
     --accent is the mid blue from the mark's petals; it already clears AA for
     text (7.72:1), so unlike the previous orange there is no separate ink
     tier. --accent-deep is the near-black navy at the mark's centre. */
  --accent: #094e94;
  --accent-ink: #094e94;
  --accent-deep: #00317a;
  --accent-hover: #002d6b;
  --accent-pale: #b2d5e7;   /* pale highlight from the mark — decorative */
  --accent-mid: #80b1d7;
  /* The photograph popover's veil. It does not flip with the theme on
     purpose: it is a darkened room around a lit picture, and a light room
     would be a different idea, not a light-mode version of this one. The
     caption sits on it in white in both themes. */
  --veil-centre: rgba(6, 12, 20, 0.62);
  --veil-edge:   rgba(4, 8, 14, 0.95);
  /* The day's three Wada colours, named for what they first coloured (the
     graph's Projects and Hobbies maps, and the name between them). The graph
     is gone; they now colour the bracelet's beads, the desk's paint chip and
     the About pieces. These values are only the fallback: js/palette.js
     rebuilds all three from the day's combination, stepped until each
     measures against the ground. */
  --graph-projects:  #00317a;
  --graph-hobbies:   #2f7ab5;
  --graph-name:      #1e4f7a;

  --accent-tint: rgba(9, 78, 148, 0.09);
  --accent-tint-strong: rgba(9, 78, 148, 0.18);
  --link: #094e94;
  /* Text over a photograph or a light photographic prop, never over a page
     ground — so it stays light in both themes and is NOT flipped in the dark
     block below. Used by the hobby card labels. */
  --on-photo: #f2f6fa;
  /* Hover colour for a title sitting on a photo. Like --on-photo it has
     no dark counterpart on purpose: the hobby card's text sits on its own
     dark gradient, not on the theme ground, so it must not flip. Light
     mode used to inherit --accent-ink (#094e94) here, which put dark navy
     on a near-black overlay and all but erased the title. 9.5:1 on the
     gradient. */
  --on-photo-accent: #8fb8e8;

  /* Lines */
  --line: rgba(22, 40, 61, 0.14);
  --line-strong: rgba(22, 40, 61, 0.28);

  /* Shadows — cool and soft, never harsh black */
  --shadow-card: 0 2px 10px 1px rgba(28, 55, 90, 0.14);
  --shadow-card-hover: 0 10px 28px 2px rgba(28, 55, 90, 0.22);

  /* Type */
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --font-script: 'Caveat', 'Segoe Script', 'Bradley Hand', cursive;
  --font-serif: 'Libre Caslon Text', Georgia, 'Times New Roman', serif;

  /* --pill-bg: the time-of-day menu's highlighted row. --term-*: the
     laptop's terminal (css/desk.css), near-black in both themes. */
  --pill-bg: rgba(22, 40, 61, 0.1);
  --term-bg: #0a0a0a;
  --term-ink: #e5e5e5;
  --term-dim: rgba(229, 229, 229, 0.55);

  /* Rhythm — the reference leans hard on a 10px beat */
  --gap: 10px;
  --gap-lg: 24px;
  --section-gap: 56px;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-pill: 100px;

  /* The nav's three tiers, after emilycampbell.co, which carries the same
     three as --nav-color / -hover / -active on its header. The reference is
     dark-only and can use white at 50%; this site has a light theme too, and
     an ink at 50% on paper measures 3.0:1, which is below the bar for text.
     So the light theme uses the measured ink ramp and the dark theme uses the
     reference's own rgba whites, which come out at 4.8:1 on this ground. */
  --nav-color: var(--ink-muted);
  --nav-color-hover: var(--ink-body);
  --nav-color-active: var(--ink);

  --measure: 1120px;
  --measure-narrow: 720px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  /* Interaction feedback only — every use of --dur is a hover/focus
     transition. 0.45s read as lag on a link; reveals set their own 0.6s. */
  --dur: 0.16s;

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   1a. Dark theme

   Set as data-theme="dark" on <html> by js/boot.js and js/theme.js for the
   evening and night periods of the viewer's clock (evening stays light in
   desk mode), or when a lamp or the time-of-day menu overrides the clock for
   the tab's session.

   Same navy family as the light theme, inverted: the deep navy that was ink
   becomes the ground, and the pale blues that were decorative become text.
   Every value here is checked against its background for WCAG AA — the ratios
   in the comments are measured, not estimated.
   -------------------------------------------------------------------------- */
:root[data-theme='dark'] {
  /* Ground — deep navy, never pure black */
  --bg: #0c1620;
  --bg-raised: #16232f;
  --bg-sunken: #091220;
  --surface: #16232f;
  --surface-muted: #22323f;

  /* Ink — pale blues on navy */
  --ink: #eaf1f8;         /* 15.8:1 on --bg */
  --ink-body: #d5e2ee;    /* 12.8:1 */
  --ink-soft: #b3c6d8;    /*  8.9:1 */
  --ink-muted: #93a9bd;   /*  6.3:1 */

  /* Accent — the light theme's blues are far too dark to read on navy, so the
     pale end of the same ramp carries the accent role here. */
  --accent: #7db8e8;
  --accent-ink: #9ccbf2;      /* 8.4:1 on --bg — safe for text */
  --accent-deep: #b2d5e7;
  --accent-hover: #cfe6f5;
  --accent-pale: #1d3a52;     /* decorative fills flip dark */
  --accent-mid: #2d5878;
  --graph-projects:  #bcd9f5;
  --graph-hobbies:   #5f9fd4;
  --graph-name:      #9cc3e6;

  --accent-tint: rgba(125, 184, 232, 0.12);
  --accent-tint-strong: rgba(125, 184, 232, 0.24);
  --link: #9ccbf2;

  /* Lines — light on dark, slightly stronger to survive the darker ground */
  --line: rgba(210, 228, 245, 0.16);
  --line-strong: rgba(210, 228, 245, 0.32);

  /* Shadows read as depth only if they are darker than the ground */
  --shadow-card: 0 2px 10px 1px rgba(0, 0, 0, 0.44);
  --shadow-card-hover: 0 10px 28px 2px rgba(0, 0, 0, 0.55);

  /* The menu's highlight inverts; the terminal stays black. */
  --pill-bg: rgba(234, 241, 248, 0.12);
  --term-bg: #04070b;
  --term-ink: #e5e5e5;
  --term-dim: rgba(229, 229, 229, 0.55);

  --header-bg: rgba(12, 22, 32, 0.85);
  --nav-color: rgba(255, 255, 255, 0.5);
  --nav-color-hover: rgba(255, 255, 255, 0.9);
  --nav-color-active: rgba(255, 255, 255, 0.95);
  /* Text drawn ON --accent-deep, which is a pale blue here — so it must be
     dark, not the white the light theme uses. 11.4:1 on #b2d5e7. */
  --on-accent-deep: #0c1620;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Time of day
   js/boot.js writes data-time from the viewer's clock (or the visitor's pick
   from the greeting's menu): morning 5-10, day 10-17, evening 17-20, night
   20-5. The pages other than the home page show only two of them: a light
   theme for morning and day, a dark one for evening and night
   (data-theme="dark"). Both are near-neutral greys with the mildest cool
   tint, no gradients, and do not follow the desk's palette (the block after
   this one). The accent family
   is the day's Wada palette (js/palette.js), re-measured against whichever
   ground is showing. The base :root and [data-theme='dark'] values above
   remain the fallback when data-time is missing.

   The home page wears these too, everywhere below the hero (2026-11-04):
   its evening is light (the desk's rule), so evening joins the light block
   there. Only the hero, and the header while it sits over the hero, wear
   the desk's grounds (the block after this one).

   Contrast, measured for ink / body / soft / muted against the WORST of
   --bg, --bg-raised, --bg-sunken and --surface:
     light 15.4 / 12.4 / 7.7 / 5.4      dark 14.4 / 11.8 / 8.4 / 5.8
   The dark theme's nav text (white at 50%) measures 4.8 on --bg-raised.
   -------------------------------------------------------------------------- */
:root { --lamp-glow: #ffbf5e; }
:root[data-theme='dark'] { --lamp-glow: #ffb347; }

:root[data-time='morning'],
:root[data-time='day'],
:root[data-mode='desk'][data-time='evening'] {
  --bg: #f6f7f8;
  --bg-raised: #fbfbfc;
  --bg-sunken: #eceef0;
  --surface: #ffffff;
  --surface-muted: #e1e3e6;
  --ink: #15171a;
  --ink-body: #272a2e;
  --ink-soft: #464a50;
  --ink-muted: #5c6168;
  --line: rgba(20, 22, 26, 0.12);
  --line-strong: rgba(20, 22, 26, 0.26);
  --pill-bg: rgba(20, 22, 26, 0.07);
  --header-bg: rgba(246, 247, 248, 0.96);
  --lamp-glow: #ffd877;
}
:root[data-theme='dark'][data-time='evening'],
:root[data-theme='dark'][data-time='night'] {
  --bg: #141517;
  --bg-raised: #1d1f22;
  --bg-sunken: #0e0f11;
  --surface: #1d1f22;
  --surface-muted: #2a2d31;
  --ink: #eeeff1;
  --ink-body: #d8dadd;
  --ink-soft: #b6b9be;
  --ink-muted: #969aa0;
  --line: rgba(235, 238, 242, 0.14);
  --line-strong: rgba(235, 238, 242, 0.28);
  --pill-bg: rgba(238, 240, 242, 0.12);
  --header-bg: rgba(20, 21, 23, 0.86);
  --lamp-glow: #ffb347;
}

/* --------------------------------------------------------------------------
   Time of day, desk mode
   The desk (the home page) wears the colours of emilycampbell.co at the same
   time of day; the other pages keep the plain light and dark above. That site multiplies
   a shader's light and shadow onto one ground per period (morning #f9dcc3,
   midday #f9f7f6, golden #fbcbbc, moonlight #66718f); --bg here is what it
   actually RENDERS on lit wall, mix(bg, bg * output, blendLight), checked
   against a screenshot (night excepted, below). js/desk-wall.js draws the leaf shadows from the same
   numbers. Evening is a light period here, as it is there: js/theme.js sets
   data-theme="dark" for evening only outside desk mode.

   Inks are hers, black (white at night) at 90 / 78 / 68 % over the ground,
   the last tier raised until it passes. Contrast for ink / body / soft /
   muted against the WORST of --bg, --bg-raised, --bg-sunken and --surface:
     day     12.0 / 8.7 / 6.3 / 4.6    morning 15.1 / 10.3 / 7.0 / 4.6
     evening 11.2 / 8.3 / 6.0 / 4.6    night  8.0 /  7.1 / 6.3 / 5.3
   Night is the owner's own pair, not hers: the background #1a1e2c (--bg),
   darker than the leaves #485374, the slate surfaces between them.

   Scoped to the hero and to the header while it is over the hero (any
   state but 'revealed', which js/nav.js sets mid-page): the desk's grounds
   stop where the desk does (2026-11-04). js/palette.js measures the accents
   against both these grounds and the plain ones, so they pass on either.
   -------------------------------------------------------------------------- */
[data-mode='desk'] .hero { background-color: var(--bg); color: var(--ink-body); }
[data-mode='desk'][data-time='day'] :is(.hero, .site-header:not([data-nav-state='revealed'])) {
  --bg: #f9d4b8;
  --bg-raised: #fbe3d1;
  --bg-sunken: #efccb1;
  --surface: #fcecdf;
  --surface-muted: #e3c1a7;
  --ink: #191512;
  --ink-body: #372f28;
  --ink-soft: #50443b;
  --ink-muted: #66574b;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.17);
  --pill-bg: rgba(0, 0, 0, 0.08);
  --header-bg: rgba(249, 212, 184, 0.96);
  --lamp-glow: #f2c27e;
}
[data-mode='desk'][data-time='morning'] :is(.hero, .site-header:not([data-nav-state='revealed'])) {
  --bg: #f9f7f6;
  --bg-raised: #fbfaf9;
  --bg-sunken: #efedec;
  --surface: #fcfbfb;
  --surface-muted: #e3e1e0;
  --ink: #191919;
  --ink-body: #373636;
  --ink-soft: #504f4f;
  --ink-muted: #6b6a6a;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.17);
  --pill-bg: rgba(0, 0, 0, 0.08);
  --header-bg: rgba(249, 247, 246, 0.96);
  --lamp-glow: #ffd877;
}
[data-mode='desk'][data-time='evening'] :is(.hero, .site-header:not([data-nav-state='revealed'])) {
  --bg: #fbc8a9;
  --bg-raised: #fcdbc7;
  --bg-sunken: #f1c0a2;
  --surface: #fde6d8;
  --surface-muted: #e4b699;
  --ink: #191411;
  --ink-body: #372c25;
  --ink-soft: #504036;
  --ink-muted: #645043;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.17);
  --pill-bg: rgba(0, 0, 0, 0.08);
  --header-bg: rgba(251, 200, 169, 0.96);
  --lamp-glow: #ff9a5c;
}
[data-mode='desk'][data-time='night'] :is(.hero, .site-header:not([data-nav-state='revealed'])) {
  --bg: #1a1e2c;
  --bg-raised: #414b69;
  --bg-sunken: #141724;
  --surface: #3f4865;
  --surface-muted: #5a6482;
  --ink: #f6f6f8;
  --ink-body: #e7e9ed;
  --ink-soft: #dadde3;
  --ink-muted: #c8cbd5;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.18);
  --pill-bg: rgba(255, 255, 255, 0.1);
  --header-bg: rgba(26, 30, 44, 0.92);
  /* The dark theme's white-at-50% nav measures 3.2 on this ground. */
  --nav-color: var(--ink-muted);
  --nav-color-hover: var(--ink-body);
  --nav-color-active: var(--ink);
  --lamp-glow: #7fd6ff;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,

*::before,

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

html {
  -webkit-text-size-adjust: 100%;
  /* The horizontal clip lives here, not on <body>. overflow-x on body makes
     body a scroll container, which silently breaks `position: sticky` on
     anything inside it. On <html> the guard works and sticky keeps working. */
  overflow-x: hidden;
}

/* Smooth scrolling is opt-in. Applied globally and ungated it also animates
   the skip link's jump, which is the single most-cited reduced-motion
   failure: a motion-sensitive user activating "skip to content" gets the
   whole page swept past them instead of an instant jump. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink-body);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

/* Three families, no more: Libre Caslon for anything read as a sentence,
   IBM Plex Mono for labels, data and code (the body default, since most of
   what is not a sentence here is one of those), and Caveat for the name and
   the handwriting. Prose that would otherwise inherit the mono is listed
   here. */
.tile__desc,
.hobbies__intro,
.readings__intro,
.shelf__caption,
.contact p,
.hero__sub,
.detail__tagline,
.detail__glance dd,
.hobby__blurb,
.notfound p {
  font-family: var(--font-serif);
  letter-spacing: 0;
}

h1,

h2,

h3,

h4 {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

p { margin: 0 0 var(--gap); }
ul { margin: 0; padding: 0; list-style: none; }

img,

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

a {
  color: var(--ink);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
a:hover { color: var(--accent-ink); }

button { font: inherit; }

::selection {
  background: var(--accent-tint-strong);
  color: var(--ink);
}

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

/* The focus ring follows whatever radius the element already has. This used
   to force border-radius: 4px on every focused element, which squared off
   pill buttons the moment they were focused. */
:focus-visible:not([class*="btn"]):not(.nav a):not(.nav-burger) {
  border-radius: 4px;
}

/* <main> carries tabindex="-1" purely so the skip link can move focus to it.
   It is not an interactive control, so it should not paint a focus ring. */
main:focus,

main:focus-visible { outline: none; }

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--gap);
  z-index: 200;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: top 0.2s var(--ease);
}
.skip-link:focus {
  top: var(--gap);
  color: var(--bg);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   3. Layout helpers
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gap-lg);
}

.section {
  padding: var(--section-gap) 0;
}

/* Section headings */
.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--gap);
  margin-bottom: var(--gap-lg);
}
.section-head h2 {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
/* After khy.com: rows of tiles are left-aligned, the bands between them
   (About, Skills, Contact) are centred. */
.info .section-head,
#skills .section-head,
.contact .section-head { justify-content: center; }

/* --------------------------------------------------------------------------
   4. Header / nav

   Rebuilt after emilycampbell.co: a fixed, completely transparent bar, kept
   compact at 56px tall (the reference's is 80px), the mark and the links pushed left, the clock and the lamp pushed
   right, and the whole thing sliding up out of the way on a downward scroll
   and back on an upward one. No ground, no blur, no rule under it — the page
   simply runs beneath it.
   -------------------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: none;
  /* A stacking context of its own, so the links never blend with whatever the
     hero is drawing underneath them. */
  isolation: isolate;
  transform: translateY(0);
  transition: transform 0.4s var(--ease), background-color 0.2s var(--ease);
}
/* Out of the way on the way down, back on the way up. Driven by js/nav.js. */
.site-header[data-nav-state='hidden'] { transform: translateY(-100%); }
/* Transparent only at the top, over the hero it was drawn for. Coming back
   down mid-page it is over body text, and without a ground its links printed
   straight on top of the paragraph underneath. */
.site-header[data-nav-state='revealed'] {
  background-color: var(--header-bg, rgba(246, 247, 248, 0.96));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--line);
}

/* The bar is a row of controls over a page that scrolls under it, so its own
   empty middle must not swallow clicks meant for the page. */
.site-header { pointer-events: none; }
.site-header a,
.site-header button { pointer-events: auto; }

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  /* A fixed height, not --header-h: js/theme.js measures --header-h off this
     very bar, so reading it back here could never let the bar shrink. */
  min-height: 56px;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 24px;
}
.site-header__start,
.site-header__end {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}
.site-header__end { gap: 14px; }

/* The mark alone, no wordmark — the reference carries only its logo, and the
   name is the first thing the page itself says. */
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--nav-color-active);
}
.brand__mark {
  width: 22px;
  height: 22px;
  flex: none;
  object-fit: contain;
}

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 12px, 1px of tracking, uppercase, and only the colour changes — over
   0.6s, which is slow enough to read as a fade rather than a flick. In the
   body's mono: the reference's system UI face was a fourth family. */
.nav a {
  display: grid;
  color: var(--nav-color);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 1px;
  line-height: 1.5;
  text-transform: uppercase;
  transition: color 0.6s var(--ease);
}
.nav a:hover { color: var(--nav-color-hover); }
.nav a.is-active {
  color: var(--nav-color-active);
  font-weight: 600;
}

/* Both labels sit in the same grid cell. The second is the bold state, kept
   in the layout but never painted, so the link is already as wide as it will
   ever be and going active cannot shove the rest of the row sideways. */
.nav__label {
  grid-area: 1 / 1;
}
.nav__label--measure {
  font-weight: 600;
  visibility: hidden;
  height: 0;
}

/* --- the clock --- */
.nav-clock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--nav-color);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}
/* Tabular, so the minute ticking over does not shuffle the greeting beside it. */
.nav-clock__time { font-variant-numeric: tabular-nums; }

/* --- the time-of-day picker ---
   The greeting is a button that opens a small menu (js/theme.js): Auto, or
   one of the four periods. Set like the clock beside it; the menu is a
   native popover in the top layer, placed under the button by script. */
.timepick__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--nav-color);
  font: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.6s var(--ease);
}
.timepick__btn:hover,
.timepick:has(.timepick__menu:popover-open) .timepick__btn { color: var(--nav-color-hover); }
.timepick__btn:focus-visible,
.lightpull:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.timepick__caret {
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.3px solid currentColor;
  border-bottom: 1.3px solid currentColor;
  rotate: 45deg;
}
.timepick__menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-raised);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  pointer-events: auto;
}
.timepick__menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: 13px/1.2 var(--font-mono);
  text-align: left;
  cursor: pointer;
}
.timepick__menu button:hover,
.timepick__menu button:focus-visible { background: var(--pill-bg); outline: none; }
/* The chosen one carries a tick; the others keep its room so nothing shifts. */
.timepick__menu button::before { content: ''; width: 12px; flex: none; }
.timepick__menu button[aria-pressed='true'] { font-weight: 600; }
.timepick__menu button[aria-pressed='true']::before { content: '\2713'; }
.timepick__now { color: var(--ink-muted); font-weight: 400; }

/* --- the lamp ---
   A line drawing of desk mode's lamp. Its glow (--lamp-glow, behind the
   shade, coloured per period under "Time of day") behaves differently at each time of day: the morning warms on
   slowly, the afternoon holds steady, the evening flickers as it dims, the
   night pulses. With reduced motion each simply holds its own brightness.
   Hidden in desk mode, where the desk's own lamp is the switch. */
.lightpull {
  display: inline-flex;
  /* A 22px drawing in a 38px hit area; the negative margin keeps the bar's
     layout exactly where the bare drawing had it. */
  padding: 8px;
  margin: -8px;
  border: 0;
  background: none;
  color: var(--nav-color);
  cursor: pointer;
  transition: color 0.6s var(--ease);
}
.lightpull:hover { color: var(--nav-color-hover); }
.lightpull svg { overflow: visible; }
.lightpull__glow { transform-box: fill-box; transform-origin: center; opacity: 0.5; }
.lightpull__bulb { fill: var(--lamp-glow); fill-opacity: 0.55; }
:root[data-time='morning'] .lightpull__glow { opacity: 0.45; }
:root[data-time='day'] .lightpull__glow { opacity: 0.4; }
:root[data-time='evening'] .lightpull__glow { opacity: 0.6; }
:root[data-time='night'] .lightpull__glow { opacity: 0.85; }
:root[data-time='night'] .lightpull__bulb { fill-opacity: 0.9; }
@media (min-width: 900px) {
  [data-mode='desk'] .lightpull { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .js:root[data-time='morning'] .lightpull__glow { animation: lamp-warm 6s ease-in-out infinite alternate; }
  .js:root[data-time='day'] .lightpull__glow { animation: lamp-steady 9s ease-in-out infinite alternate; }
  .js:root[data-time='evening'] .lightpull__glow { animation: lamp-flicker 3.4s linear infinite; }
  .js:root[data-time='night'] .lightpull__glow { animation: lamp-pulse 2.8s ease-in-out infinite; }
}
/* Morning: the light warming on, slowly, from almost nothing. */
@keyframes lamp-warm {
  from { opacity: 0.08; scale: 0.8; }
  to { opacity: 0.7; scale: 1; }
}
/* Afternoon: on and steady; the faintest drift, so it reads as lit, not drawn. */
@keyframes lamp-steady {
  from { opacity: 0.38; }
  to { opacity: 0.5; }
}
/* Evening: a lamp on its way down, catching and dimming. */
@keyframes lamp-flicker {
  0%, 18%, 22%, 54%, 100% { opacity: 0.62; }
  20% { opacity: 0.25; }
  56% { opacity: 0.35; }
  58% { opacity: 0.6; }
  76% { opacity: 0.2; }
  79% { opacity: 0.55; }
}
/* Night: the room's one light, breathing. */
@keyframes lamp-pulse {
  0%, 100% { opacity: 0.55; scale: 0.92; }
  50% { opacity: 1; scale: 1.08; }
}

/* --- the burger, for the narrow layout --- */
.nav-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  margin: -7px;
  padding: 0 12px;
  border: 0;
  background: none;
  cursor: pointer;
}
.nav-burger span {
  display: block;
  height: 1.4px;
  background: currentColor;
  color: var(--nav-color-active);
  transition: transform 0.28s var(--ease), opacity 0.28s var(--ease);
}
.nav-burger span:nth-child(1) { width: 20px; }
.nav-burger span:nth-child(2) { width: 14px; }
.nav-burger span:nth-child(3) { width: 20px; }
.nav-burger[aria-expanded='true'] span:nth-child(1) { transform: translateY(5.4px) rotate(45deg); }
.nav-burger[aria-expanded='true'] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded='true'] span:nth-child(3) { transform: translateY(-5.4px) rotate(-45deg); }

/* The bar is out of the flow, so every page needs the height back. The hero
   cancels it again below, which is what puts the desk under the bar. */
body { padding-top: var(--header-h, 80px); }

/* --------------------------------------------------------------------------
   5. Hero — a full-viewport stage
   The desk (css/desk.css): the name and the line under it on the wall, the
   case studies on the laptop's screen (.hero__work, also css/desk.css).
   Below 900px there is no desk and the three stack in the flow.
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  /* The fixed header sits over this section. Pulling the hero up under it by
     the header's height gives a true full-viewport stage anchored at y=0,
     which is what the desk is laid out against. */
  margin-top: calc(-1 * var(--header-h, 80px));
}

.stage {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
}

/* --- The name, on the wall above the desk ------------------------------- */
.hero__lockup {
  position: absolute;
  left: 50%;
  top: calc(var(--header-h, 80px) + 8.5svh);
  z-index: 20;   /* above everything on the desk, however high it is stacked */
  width: min(600px, 44vw);
  translate: -50% 0;
  text-align: center;
  /* Things can be dragged under it, so its empty space must not eat presses. */
  pointer-events: none;
}
.hero__name {
  margin: 0 0 16px;
  font-family: var(--font-script);
  font-size: clamp(3rem, 5.4vw, 80px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--ink);
}
.hero__sub {
  margin: 0 auto;
  max-width: 34ch;
  color: var(--ink-body);
  font-size: clamp(17px, 1.35vw, 20px);
  line-height: 1.45;
  text-wrap: balance;
}

/* --- Below 900px: a phone on the desk -----------------------------------
   The desk shows only its wall and tabletop (css/desk.css), and a phone
   (.handset) stands on the tabletop in place of the laptop. Its screen is a
   home screen: the name as a widget with today's date (js/script.js), the
   case studies (.hero__work) and the sections (.apps) as app icons
   (css/desk.css), and contact as the dock at the foot of the screen.
   At 900px and up the two wrappers are display: contents. */
.handset, .handset__screen { display: contents; }
.hero__today, .apps, .dock { display: none; }
@media (max-width: 899.98px) {
  .hero { margin-top: 0; }
  .stage {
    display: flex;
    justify-content: center;
    min-height: calc(100svh - var(--header-h, 64px));
    padding: 22px var(--gap-lg) 7svh;   /* the phone's foot lands on the tabletop */
  }
  .handset {
    display: block;
    position: relative;
    z-index: 2;
    align-self: flex-end;
    width: min(340px, 100%);
    padding: 10px;
    border-radius: 48px;
    background: var(--device);
    box-shadow: 0 0 0 1px var(--line-strong), 0 22px 26px -14px var(--prop-shadow);
  }
  /* The camera island. */
  .handset::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 21px;
    z-index: 1;
    width: 84px;
    height: 24px;
    translate: -50% 0;
    border-radius: 12px;
    background: var(--device);
  }
  .handset__screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: min(640px, calc(100svh - var(--header-h, 64px) - 22px - 7svh - 20px));
    padding: 46px 12px 12px;
    border-radius: 38px;
    background: linear-gradient(170deg, var(--bg), var(--bg-sunken));
    overflow: hidden;
  }
  .hero__lockup {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    translate: none;
    padding: 16px 16px 18px;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    text-align: left;
    pointer-events: auto;
  }
  .hero__today {
    display: block;
    margin: 0 0 6px;
    color: var(--accent-ink);
    font: 500 10px/1.3 var(--font-mono);
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .hero__today:empty { display: none; }
  .hero__name { white-space: normal; margin-bottom: 6px; font-size: clamp(2rem, 10vw, 2.6rem); }
  .hero__sub { margin: 0; max-width: none; font-size: 14.5px; }
  .apps { display: block; margin-top: -2px; }
  .dock {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: auto;
    padding: 10px 4px;
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }
  .dock a {
    display: grid;
    justify-items: center;
    gap: 4px;
    color: var(--ink);
    font: 500 10px/1.2 var(--font-mono);
    text-decoration: none;
  }
  .dock .icon { width: 44px; height: 44px; padding: 11px; border-radius: 13px; background: var(--ink); color: var(--bg); }
  .dock a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 13px; }
}

/* --------------------------------------------------------------------------
   6. Outside work
   Hobbies and Readings, after Contact, as two parts of one section. The
   skills are the bracelet in About (css/info.css).
   -------------------------------------------------------------------------- */
.outside__part + .outside__part { margin-top: var(--section-gap); }
/* Hobbies left, Readings right. The shelf keeps its caption under it here:
   beside it there is no room in half a row. */
@media (min-width: 900px) {
  .outside__parts {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr);
    gap: 48px;
  }
  .outside__part + .outside__part { margin-top: 0; }
  .outside .readings { display: block; }
  .outside .shelf__caption { margin: 12px 0 0; min-width: 0; }
}
.outside__h {
  margin-bottom: 4px;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   7. Work: one row of tiles, then "View more projects"
   -------------------------------------------------------------------------- */

/* --- Tiles ---------------------------------------------------------
   One row of four, after khy.com's product rows: picture, kicker, title,
   one line, then the meta in small caps.
   Pictures are `contain` on a sunken ground: a phone render is a shape, and
   cropping it crops the device. */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px 18px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}
.tile__img {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-sunken);
}
.tile__img img,
.tile__img video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.tile__kicker {
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.tile__title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.tile__desc {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.4;
}
.tile__meta {
  color: var(--ink-soft);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tile:hover .tile__title { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
@media (prefers-reduced-motion: no-preference) {
  .js .tile__img img { transition: transform 0.5s var(--ease); }
  .js .tile:hover .tile__img img { transform: scale(1.03); }
}
/* Below 900px the row becomes one you swipe, the next card peeking in.
   The experience badges (css/experience.css) and the bracelet (css/info.css)
   do the same. */
@media (max-width: 899.98px) {
  .tiles {
    display: flex;
    gap: 14px;
    margin-inline: calc(-1 * var(--gap-lg));
    padding: 2px var(--gap-lg);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gap-lg);
    scrollbar-width: none;
  }
  .tile {
    flex: 0 0 min(78%, 320px);
    scroll-snap-align: start;
    padding: 10px 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .tile__title { font-size: 17px; }
}

/* projects.html filter: four line-drawn buttons, equal gaps, stuck under
   the header. They are checkboxes, so nothing ticked shows everything and
   ticking any shows only those groups; :has() does it without JS. */
.pfilter {
  position: sticky;
  top: var(--header-h, 80px);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px clamp(8px, 4vw, 40px);
  min-width: 0;
  margin: 0 0 28px;
  padding: 12px 0;
  border: 0;
  background: var(--bg);
  transition: top 0.4s var(--ease);
}
/* The header slides away on the way down (js/nav.js); the bar takes its
   place at the very top instead of leaving a gap the tiles show through. */
body:has(.site-header[data-nav-state='hidden']) .pfilter { top: 0; }
.pfilter label { position: relative; cursor: pointer; }
.pfilter input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.pfilter span {
  display: inline-block;
  min-height: 36px;
  padding: 8px clamp(10px, 3vw, 18px);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: clamp(0.04em, 0.5vw, 0.1em);
  line-height: 18px;
  text-transform: uppercase;
}
@media (hover: hover) {
  .pfilter label:hover span { border-color: var(--accent-ink); color: var(--accent-ink); }
}
.pfilter input:checked + span {
  border-color: var(--accent-ink);
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.pfilter input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
/* Four on one row on a phone; an even two-by-two, not three and one, on the
   narrowest. */
@media (max-width: 559.98px) {
  .pfilter { gap: 8px 6px; }
  .pfilter span { padding: 7px 10px; font-size: 11px; letter-spacing: 0.04em; }
}
@media (max-width: 389.98px) {
  .pfilter { display: grid; grid-template-columns: repeat(2, max-content); }
}
main:has(.pfilter :checked) .pcard { display: none; }
main:has(#f-products:checked) .pcard[data-group='products'],
main:has(#f-research:checked) .pcard[data-group='research'],
main:has(#f-experiments:checked) .pcard[data-group='experiments'],
main:has(#f-industry:checked) .pcard[data-group='industry'] { display: grid; }

/* projects.html: two cards a row, each in two halves,
   picture | title and description. One card a row below 900px, and below 560px the
   halves stack. Overrides the home row's swipe (.tiles below 900px). */
.tiles--all {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 48px;
  margin-inline: 0;
  padding: 0;
  overflow: visible;
}
.pcard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.pcard__img {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.pcard__img img,
.pcard__img video { width: 100%; height: 100%; object-fit: contain; }
/* The picture lifts and grows a little when its card is pointed at or its
   title has focus. The wrapper moves, not the image, so nothing is cropped. */
@media (prefers-reduced-motion: no-preference) {
  .pcard__img { transition: transform 0.35s var(--ease); }
  .pcard:hover .pcard__img,
  .pcard:focus-within .pcard__img { transform: translateY(-6px) scale(1.03); }
}
.pcard__title { margin: -4px 0 0; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.35; }
.pcard__title a { color: var(--ink); text-decoration: none; }
.pcard__title a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
/* The line between the halves: the "|" in picture | description. */
.pcard__desc {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: stretch;
  padding-left: 20px;
  border-left: 1px solid var(--line-strong);
}
.pcard__desc p { margin: 0; }
.pcard__live a {
  display: inline-block;
  padding: 5px 0;
  color: var(--accent-ink);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (max-width: 899.98px) {
  .tiles--all { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 559.98px) {
  .pcard { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pcard__desc { padding-left: 0; padding-top: 12px; border-left: 0; border-top: 1px solid var(--line-strong); }
}

/* --- "View more projects" ------------------------------------------
   Plain text under the row, no arrow. */
.rm-more {
  margin: 20px 0 0;
  font-size: 13px;
}
.rm-more a {
  /* A 28px target (WCAG 2.5.8 asks for 24). */
  display: inline-block;
  padding: 5px 0;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.rm-more a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* --- Readings ------------------------------------------------------
   A shelf of books that turn. Each one stands as a spine and, when it is the
   chosen one, rotates a quarter turn in place to face you — the spine going
   edge-on as the cover comes round. There is no separate preview panel: the
   cover appears where the book already was, and the shelf opens a gap for it.

   The geometry: .book is a 3D box hinged on its left edge. The spine fills it
   and faces the viewer; the cover sits at the same left edge pre-rotated 90deg,
   so it is edge-on and invisible at rest. Turning the box -90deg swaps them,
   and because the cover was hinged at the same edge it lands exactly in the
   space the slot has grown into.

   Sizes are real. One scale (PX_PER_MM in js/script.js) turns each edition's
   trim into pixels and its page count into spine thickness, so the shelf is
   uneven for the reason a real shelf is.

   The books are <button>s, not links: they change what this page shows, which
   is what a button is for, and it means the shelf works by tap as well as by
   hover. */
.readings__intro {
  max-width: 60ch;
  margin-bottom: 14px;
  color: var(--ink-soft);
  font-size: 14px;
}
.readings__asof {
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.readings { margin-top: 10px; }

.shelf__books {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  list-style: none;
  margin: 0;
  padding: 0 0 10px;
  /* The vanishing point the books turn against. Without it the rotation is a
     flat squash rather than a book turning. */
  perspective: 1500px;
  perspective-origin: 50% 60%;
  /* The board is as long as the books need: every spine, plus room for one
     cover to open (--shelf-w, measured in js/script.js). Run the full width
     of the column, it was a long empty plank with four books at one end.
     The shadow sits under the board only; a blurrier one bled up both ends
     and drew the plank as an empty box. */
  width: var(--shelf-w, fit-content);
  max-width: 100%;
  /* Longer than a phone is wide: the shelf scrolls inside itself rather
     than widening the page (it made a 390px screen 537px wide). */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  border-bottom: 3px solid var(--line-strong);
  box-shadow: 0 8px 6px -6px rgb(0 0 0 / 0.45);
}

/* The slot is the gap on the shelf. It is as wide as the spine until the book
   turns, then as wide as the cover — so the neighbours slide aside rather than
   being covered up. */
.book-slot {
  flex: none;
  width: var(--bt, 22px);
  transition: width 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* The button fills whatever the slot currently is, and does NOT turn. Putting
   the rotation on the button made its own box edge-on at 90 degrees, so the
   pointer left the element it was hovering, the slot closed, the pointer was
   back over it, and the book flickered instead of staying open long enough to
   be clicked. The box inside it turns; the hit target never moves. */
.book {
  position: relative;
  display: block;
  width: 100%;
  height: var(--bh, 240px);
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
}
.book__turn {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--bt, 22px);
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Both faces are hinged on the same left edge. backface-visibility keeps each
   from showing through the other as they pass. */
.book__spine,
.book__cover {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 2px 3px 3px 2px;
  overflow: hidden;
}

.book__spine {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 0;
  background: var(--spine-bg, #d9dde2);
  color: var(--spine-ink, #10161d);
  /* renderReadings() fits each title by mono advance widths. */
  font-family: var(--font-mono);
  /* The head-band and the shadow in the gutter, as two gradients rather than
     two more elements. */
  box-shadow:
    inset -5px 0 0 -3px rgb(255 255 255 / 0.22),
    inset 5px 0 8px -5px rgb(0 0 0 / 0.5),
    0 2px 4px rgb(0 0 0 / 0.22);
}

.book__cover {
  width: var(--bw, 160px);
  transform-origin: left center;
  transform: rotateY(90deg);
  box-shadow: 0 10px 22px -12px rgb(0 0 0 / 0.55);
}
.book__cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* A book whose cover has not been supplied yet: the spine's colour (black,
   js/script.js) with the title set on it. */
.book__cover {
  background: var(--spine-bg, #111);
  /* A hairline, so a black cover still has an edge on the dark theme. */
  outline: 1px solid rgb(255 255 255 / 0.08);
  outline-offset: -1px;
}
.cover-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12%;
  color: var(--spine-ink, #fbfcfd);
  font-family: var(--font-serif, serif);
  font-size: calc(var(--w, 150px) * 0.11);
  line-height: 1.15;
  text-align: center;
  text-wrap: balance;
}
.book__cover .cover-blank { font-size: 15px; }

/* Vertical type, reading bottom-to-top as a spine on a shelf does. */
.spine__title,
.spine__author {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 0;
}
/* The title takes whatever the author leaves; min-height:0 is what lets a flex
   item shrink below its content at all. */
.spine__title {
  flex: 0 1 auto;
  font-size: var(--spine-fs, 12px);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.spine__author {
  flex: none;
  max-height: 46%;
  font-size: 9px;
  letter-spacing: 0.04em;
  opacity: 0.74;
}

/* Without :has() the slot cannot widen, so the cover would open over its
   neighbours. Fall back to no turn at all: three spines and the caption is
   still the section, just static. */
@supports not selector(:has(*)) {
  .book__turn { transform: none !important; }
}

/* The turn is the whole gesture, so under `reduce` it is dropped rather than
   shortened — the cover swaps in without sweeping, and the slot still opens. */
@media (prefers-reduced-motion: reduce) {
  .book__turn,
  .book-slot { transition: none; }
}

.shelf__caption {
  margin: 16px 0 0;
  min-height: 3em;
  max-width: 62ch;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.shelf__caption b { color: var(--ink); font-weight: 500; }

/* With the width for it, the caption stands beside the shelf, level with the
   board, in the space the plank used to leave empty. The shelf's width already
   allows for an open cover, so turning a book never shoves the caption.
   The shelf is pinned to the top of the row, not the bottom: when a long
   note made the caption taller than the shelf, the row grew and a
   bottom-aligned shelf rode down with it, so the books jumped as the pointer
   moved between them. The caption keeps a floor on its width for the same
   reason — squeezed, it is what grows tall. */
@media (min-width: 900px) {
  .readings { display: flex; align-items: flex-end; gap: 48px; }
  .shelf__books { flex: none; align-self: flex-start; }
  .shelf__caption { flex: 0 1 46ch; min-width: 28ch; margin: 0 0 16px; }
}

@media (max-width: 599.98px) {
  .shelf__books { gap: 4px; }
  .shelf__caption { font-size: 13.5px; }
}

/* --------------------------------------------------------------------------
   10. Info
   The intro: one centred column of serif prose, signed in Caveat. No
   decoration; the signature is the last line.
   -------------------------------------------------------------------------- */
.info__intro {
  max-width: 640px;
  margin: 40px auto 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: clamp(17px, 2.6vw, 22px);
  line-height: 1.5;
  text-align: center;
}
.info__intro p { margin: 0 0 0.75em; }
.info__hello { font-style: italic; }

.info__signed { display: block; margin-top: 0.3em; }
.info__intro .info__sig {
  margin: 0;
  font-family: var(--font-script);
  font-size: 1.9em;
  line-height: 1;
  transform: rotate(-4deg);
}

/* --------------------------------------------------------------------------
   10b. Contact
   -------------------------------------------------------------------------- */
.contact { text-align: center; }
.contact p {
  max-width: 520px;
  margin: 0 auto var(--gap-lg);
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.6;
}
.contact__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
}

/* --- Buttons --------------------------------------------------------------
   Used by the contact row here and by the project detail pages. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.2;
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.btn:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-tint);
}
.btn--primary {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: var(--on-accent-deep, #fff);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent-deep, #fff);
}

/* --------------------------------------------------------------------------
   11. Footer
   Three parts: who she is and the way to the sections; the three ways to
   reach her; and a base line with the copyright and a way back up.
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: var(--gap-lg) 0 calc(var(--gap-lg) * 0.75);
  margin-top: var(--section-gap);
}
.site-footer__inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gap-lg);
  color: var(--ink-muted);
  font-size: 13px;
}
.site-footer__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px 48px;
  align-items: start;
}
.site-footer__name {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-script);
  font-size: 36px;
  line-height: 1;
}
.site-footer__role {
  max-width: 40ch;
  margin: 8px 0 0;
  color: var(--ink-body);
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.5;
}
.site-footer__nav {
  display: grid;
  gap: 8px;
  justify-items: start;
}
.site-footer__nav a,
.site-footer__up { color: var(--ink-body); text-decoration: none; }
.site-footer__nav a:hover,
.site-footer__up:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.site-footer__social {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer__social a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
}
.site-footer__social a:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--on-accent-deep, #fff); }
.site-footer__social a:focus-visible,
.site-footer__up:focus-visible,
.site-footer__nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.site-footer__base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.site-footer__base p { margin: 0; }
.site-footer__up { font-family: var(--font-mono); }

@media (max-width: 599.98px) {
  .site-footer__top { grid-template-columns: minmax(0, 1fr); }
  .site-footer__nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
  .site-footer__nav a,
  .site-footer__up { display: inline-flex; align-items: center; min-height: 44px; }
  .site-footer__social a { min-height: 44px; padding: 10px 14px; }
  .site-footer__inner { font-size: 13px; }
}

/* --------------------------------------------------------------------------
   12. Reveal animation — gated on .js AND reduced-motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0.001;
    transform: translateY(20px);
    transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  }
  .js .reveal.is-visible {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   12a. Page-load choreography
   The hero's pieces fade in on mount: the name, the line under it, then
   the list on the laptop. Only opacity animates.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .js :is(.hero__name, .hero__sub, .hero__work) { animation: appear 0.62s var(--ease) backwards; }
  .js .hero__name { animation-delay: 0.05s; }
  .js .hero__sub { animation-delay: 0.14s; }
  .js .hero__work { animation-delay: 0.3s; }
}

@keyframes appear {
  from { opacity: 0.001; }
  to { opacity: 1; }
}

/* --------------------------------------------------------------------------
   13. Small screens

   The nav collapses at the same 899.98px the hero stage does, so there is
   no band where the desktop stage and the mobile dropdown coexist.
   js/nav.js matches this value.
   -------------------------------------------------------------------------- */
@media (max-width: 899.98px) {
  :root { --section-gap: 44px; }

  /* Below the reference's own breakpoint the links leave the bar and become a
     panel under it. The bar keeps the mark, the burger, the clock and the
     lamp — which is what the reference keeps too. */
  .nav-burger { display: flex; }
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: var(--header-h, 80px);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px var(--gap-lg) 18px;
    background: var(--header-bg, rgba(244, 247, 250, 0.96));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    pointer-events: auto;
  }
  .nav[hidden] { display: none; }
  .nav a { padding: 12px 0; min-height: 44px; align-content: center; }
  .nav-clock { display: none; }

}

@media print {
  .site-header,

  .stage,

  .nav-burger { display: none !important; }
  body { background: #fff; color: #000; background-image: none; padding-top: 0; }
}

/* --------------------------------------------------------------------------
   15. Hobbies — a camera and a brush on a wall shelf, each gallery's
   photographs in orbit round its icon on hover/focus (js/hobbies.js)
   -------------------------------------------------------------------------- */
.hobbies__intro {
  max-width: var(--measure-narrow);
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

/* The rack: a wall shelf (a plank with two brackets, shadowed like the
   bookshelf's board) and the two icons standing on it. The space above is
   for the orbit to open into. */
.hob-rack {
  position: relative;
  max-width: 460px;
  padding: 84px 0 30px;
}
.hob-shelf {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-around;
  margin: 0;
  padding: 0 24px;
  list-style: none;
}
.hob-item { position: relative; }
/* Fixed over the icon, inside the ring's empty middle: the ring is sized
   (--r in js/hobbies.js) so no photograph reaches it. */
.hob-label {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
.hob-icon {
  position: relative;
  z-index: 1;
  display: block;
  padding: 8px;
  color: var(--ink);
}
.hob-icon svg { display: block; }
.hob-icon:hover { color: var(--accent-ink); }
.hob-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hob-board {
  position: relative;
  height: 8px;
  border-radius: 2px;
  background: var(--ink-muted);
  box-shadow: 0 8px 6px -6px rgb(0 0 0 / 0.45);
}
.hob-board i {
  position: absolute;
  top: 8px;
  left: 14%;
  width: 18px;
  height: 28px;
  background: var(--ink-muted);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.hob-board i + i { left: auto; right: 14%; clip-path: polygon(0 0, 100% 0, 100% 100%); }

/* The orbit: a zero-size ring on the icon's centre, the photographs placed
   round it at --a and pushed out to --r when the item is pointed at or
   focused. The item's ::before is a disc under the icon and the ring, so the
   pointer can cross from the icon to a photograph without the ring closing. */
.hob-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: 0;
  height: 0;
  pointer-events: none;
}
.hob-item::before {
  content: '';
  position: absolute;
  z-index: 0;
  left: calc(50% - var(--r) - 24px);
  top: calc(50% - var(--r) - 24px);
  width: calc(2 * var(--r) + 48px);
  height: calc(2 * var(--r) + 48px);
  border-radius: 50%;
}
.hob-orb {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--bg), 0 4px 10px -4px rgb(0 0 0 / 0.5);
  opacity: 0;
  pointer-events: none;
  transform: rotate(var(--a)) translate(0) rotate(calc(-1 * var(--a))) scale(0.3);
}
.hob-orb img { width: 100%; height: 100%; object-fit: cover; }
.hob-item::before { pointer-events: none; }
.hob-item:is(:hover, :focus-within)::before { pointer-events: auto; }
.hob-item:is(:hover, :focus-within) .hob-orb {
  opacity: 1;
  pointer-events: auto;
  transform: rotate(var(--a)) translate(var(--r)) rotate(calc(-1 * var(--a)));
}
.hob-orb:hover { box-shadow: 0 0 0 2px var(--accent), 0 6px 14px -4px rgb(0 0 0 / 0.55); z-index: 1; }
.hob-orb:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 50%; }

.hob-cap {
  max-width: 460px;
  min-height: 1.5em;
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  text-align: center;
}

/* The slow turn, only while open, held while a photograph is pointed at;
   each image turns back the other way so it stays upright. */
@media (prefers-reduced-motion: no-preference) {
  .js .hob-icon { transition: color 0.25s var(--ease); }
  .js .hob-orb { transition: transform 0.45s var(--ease), opacity 0.3s var(--ease); }
  .js .hob-ring,
  .js .hob-orb img { animation: hob-spin 40s linear infinite paused; }
  .js .hob-orb img { animation-direction: reverse; }
  .js .hob-item:is(:hover, :focus-within) .hob-ring,
  .js .hob-item:is(:hover, :focus-within) .hob-orb img { animation-play-state: running; }
  .js .hob-ring:has(.hob-orb:hover) ,
  .js .hob-ring:has(.hob-orb:hover) .hob-orb img { animation-play-state: paused; }
}
@keyframes hob-spin { to { transform: rotate(360deg); } }
/* --------------------------------------------------------------------------
   16. Phone (<=599px)

   The existing breakpoints stop at 600px, so nothing below that was tuned for
   a phone. Findings this block addresses, from an audit across six device
   widths x both themes x five pages:

     - tap targets under the 44px minimum (WCAG 2.5.5): footer links, mode
       toggle buttons, nav toggle, player button, detail back-links
     - body text under 13px: share-card copy, palette meta, table cells
     - the marquee deliberately overflows; everything else that did has been
       contained rather than clipped

   Horizontal overflow measured 0px on every combination before and after.
   -------------------------------------------------------------------------- */
@media (max-width: 599.98px) {
  /* --- tap targets ---------------------------------------------------- */
  /* Padding rather than min-height: these are inline links inside flowing
     text, so growing the box keeps them in the layout instead of stretching
     their line. */
  .detail__back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  .btn { padding: 12px 18px; }
  .brand { padding: 11px 0; }
  .timepick__btn { min-height: 44px; }

  /* --- legibility ------------------------------------------------------ */
  /* Nothing below 13px: iOS also zooms the page when tapped text is smaller. */

  /* --- spacing ---------------------------------------------------------- */
  /* A phone has no room for desktop section rhythm. */
  .section { padding: 34px 0; }
  :root { --gap-lg: 18px; --section-gap: 34px; }

}

/* Remaining mobile tap targets: several sat at 41-42px, just under the 44px
   minimum. Raising the shared paddings clears them all rather than patching
   each selector. */
@media (max-width: 599.98px) {
  .nav a { padding: 12px; min-height: 44px; display: flex; align-items: center; }
  .contact__links .btn,

  .notfound__actions .btn { min-height: 46px; }
  .skip-link { padding: 13px 18px; }
  .code-copy { min-height: 44px; padding: 11px 14px; }
  .hob-shot figcaption { font-size: 12.5px; }
}

/* --------------------------------------------------------------------------
   404 page

   Lives here rather than in project.css: these few rules were the only thing
   404.html used out of that file, so the page was downloading an entire
   stylesheet to render six lines of text.
   -------------------------------------------------------------------------- */
/* The page is one short block; without this the footer floated mid-window
   with an empty band under it. */
body:has(.notfound) {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}
body:has(.notfound) main { flex: 1; }
.notfound {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  min-height: 68vh;
  text-align: center;
}
.notfound__code {
  font-family: var(--font-script);
  font-size: clamp(4rem, 16vw, 8rem);
  line-height: 1;
  color: var(--accent); /* decorative at this size; aria-hidden in the markup */
}
.notfound h1 { font-size: clamp(1.4rem, 4vw, 2rem); }
/* :not() so the numeral, also a <p>, keeps its accent. */
.notfound p:not(.notfound__code) { color: var(--ink-soft); max-width: 420px; }
/* Its own row under the copy. It used to borrow .hero__actions, which is
   absolutely placed under the header, so the buttons floated 260px above
   the text they answer, touching each other. */
.notfound__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--gap);
  margin-top: 10px;
}

/* ==========================================================================
   The popover — a native <dialog>, built by js/lightbox.js

   showModal() carries focus trapping, page inertness, Escape-to-close and
   ::backdrop, so none of that is reimplemented here. What is left is the one
   photograph at its own size, floated over a darkened, blurred, vignetted
   version of the page it came from.
   ========================================================================== */
.lightbox {
  inset: 0;
  margin: auto;
  width: fit-content;
  max-width: 96vw;
  max-height: 96vh;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

/* Dark, blurred and vignetted: the page is still there behind the photograph,
   but only as a texture. ::backdrop does not inherit from the page in every
   engine, so each token carries its literal as a var() fallback rather than
   silently resolving to nothing and leaving a transparent veil. */
.lightbox::backdrop {
  background:
    radial-gradient(ellipse 80% 80% at 50% 50%,
      var(--veil-centre, rgba(6, 12, 20, 0.62)) 0%,
      var(--veil-edge, rgba(4, 8, 14, 0.95)) 100%);
  backdrop-filter: blur(8px) saturate(0.7);
}

.lightbox__frame {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.lightbox__fig {
  position: relative;
  margin: 0;
  min-width: 0;
  line-height: 0;
}
/* Its own pixels, never scaled up — only scaled down when the photograph is
   bigger than the room the viewport has for it. */
.lightbox__fig img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 92vh;
}

/* The caption is on the photograph and only while the pointer is on it, so
   the resting state is the photograph alone. It stays in the accessibility
   tree throughout, and the alt text says the same thing. */
.lightbox__fig figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 26px 16px 12px;
  background: linear-gradient(to top, rgba(6, 12, 20, 0.86), rgba(6, 12, 20, 0));
  color: #fff;
  font-size: 14px;
  font-style: italic;
  line-height: 1.45;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.lightbox__fig:hover figcaption,
.lightbox__fig:focus-within figcaption { opacity: 1; }
/* Nothing hovers on a touch screen. */
@media (hover: none) {
  .lightbox__fig figcaption { opacity: 1; }
}

.lightbox__close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lightbox__close:hover { background: var(--accent-deep); color: var(--on-accent-deep, #fff); }

/* On a phone the gutter is worth more as picture than as margin, so the
   button comes inside the frame's top-right corner. */
@media (max-width: 599.98px) {
  .lightbox { max-width: 100vw; }
  .lightbox__frame { position: relative; }
  .lightbox__close { position: absolute; top: 8px; right: 8px; }
}

/* --------------------------------------------------------------------------
   Cursor cue (js/cursor.js)
   A label that follows the pointer and names what is under it. The system
   cursor is left alone; this sits beside it.
   -------------------------------------------------------------------------- */
.cue {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 200;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--accent-deep);
  color: var(--on-accent-deep, #fff);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;   /* never intercepts the click it is describing */
}
.cue.is-on { opacity: 1; }
/* Only the fade eases. The position is written every frame from the pointer,
   so easing it as well would leave the label trailing behind the thing it
   names. */
.cue--eased { transition: opacity 120ms var(--ease); }
/* Nothing behind a modal is reachable, so its cue is a label for something
   that cannot be clicked. */
body:has(dialog[open]) .cue { display: none; }


/* ==========================================================================
   17. The project grid, the screen, and the shelf overlay
   ========================================================================== */


/* --- The shelf --------------------------------------------------------
   Spines, and only spines, until the pointer or the keyboard reaches one:
   that slot widens and its book turns. Nothing is open at rest, so the shelf
   reads as a shelf. Driven by :hover / :focus-within rather than by a stored
   aria-pressed state, because turning to look at a book is not a choice the
   page has to remember. */
.book-slot:hover,
.book-slot:has(.book:focus-visible) { width: var(--bw, 160px); }
.book-slot:hover .book__turn,
.book-slot:has(.book:focus-visible) .book__turn { transform: rotateY(-90deg); }

/* --- Taking one off the shelf ----------------------------------------
   The overlay is not a panel. The dialog fills the viewport, has no ground of
   its own, and the whole site is vignetted behind it through ::backdrop — so
   the only thing on screen is the book. --veil-centre / --veil-edge are the lightbox's own two values and do
   not flip with the theme: a dark room around a lit object is dark in both.
   ::backdrop does not inherit custom properties in every engine, so each is
   used with its literal as a var() fallback. */
.bookview {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  overflow: hidden;
}
.bookview::backdrop {
  background: radial-gradient(ellipse at 50% 46%,
    var(--veil-centre, rgba(6, 12, 20, 0.62)) 0%,
    var(--veil-edge, rgba(4, 8, 14, 0.95)) 100%);
  backdrop-filter: blur(3px);
}
.bookview__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 6vw, 72px);
  width: 100%;
  height: 100%;
  padding: 24px;
}
.bookview__close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.08);
  color: #fbfcfd;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.bookview__close:hover { background: rgb(255 255 255 / 0.18); }
/* Previous / next along the shelf. Same glass as the close button, centred
   on each side, clear of the book at any size the book is drawn. */
.bookview__step {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.08);
  color: #fbfcfd;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.bookview__step--prev { left: clamp(10px, 3vw, 40px); }
.bookview__step--next { right: clamp(10px, 3vw, 40px); }
.bookview__step:hover { background: rgb(255 255 255 / 0.18); }
.bookview__step:focus-visible,
.bookview__close:focus-visible { outline: 2px solid #fbfcfd; outline-offset: 3px; }

/* --- The book, as a box ---
   Six faces on one shared 3-D transform. --rx / --ry are written by
   js/script.js as the book is dragged; everything else about how it is put
   together lives here. The faces are hinged off the centre, so the box is
   W x H x T and turning it needs no per-face maths. */
.book3d {
  flex: none;
  width: var(--w);
  height: var(--h);
  perspective: 1400px;
  cursor: grab;
  touch-action: none;
  /* A book you turn, not a file you drag off the page. */
  user-select: none;
  -webkit-user-select: none;
  animation: book-lift 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  /* The shadow lives HERE and not on the box below. A filter on an element
     forces its transform-style to flat, which collapses the six faces into
     paint order and leaves the back cover sitting on top of the front one.
     This element is only the perspective, so it can carry a filter safely. */
  filter: drop-shadow(0 26px 40px rgb(0 0 0 / 0.55));
}
.book3d.is-turning { cursor: grabbing; }
.book3d:focus-visible { outline: 2px solid #fbfcfd; outline-offset: 12px; }

.book3d__box {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 8deg)) rotateY(var(--ry, -32deg));
}

.book3d__face {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  background: #efe9df;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.12);
}
/* The two big faces. */
.book3d__face--front,
.book3d__face--back {
  width: var(--w);
  height: var(--h);
}
.book3d__face--front { transform: translateZ(calc(var(--t) / 2)); }
.book3d__face--front img,
.book3d__face--back img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  pointer-events: none;
}
.book3d__face--back { transform: rotateY(180deg) translateZ(calc(var(--t) / 2)); }
/* No back covers: the back, and a front still waiting for its cover, are the
   spine's own colour. */
.book3d__face--front,
.book3d__face--back { background: var(--spine-bg, #111); }

/* The spine and the fore-edge, hinged on the left and right edges. */
.book3d__face--spine,
.book3d__face--fore {
  width: var(--t);
  height: var(--h);
}
.book3d__face--spine {
  left: calc(var(--w) / 2 - var(--t) / 2);
  transform: rotateY(-90deg) translateZ(calc(var(--w) / 2));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  background: var(--spine-bg, #d9dde2);
  color: var(--spine-ink, #10161d);
  box-shadow:
    inset -5px 0 0 -3px rgb(255 255 255 / 0.22),
    inset 5px 0 8px -5px rgb(0 0 0 / 0.5);
}
.book3d__face--spine .spine__title { font-size: 13px; }
.book3d__face--fore {
  left: calc(var(--w) / 2 - var(--t) / 2);
  transform: rotateY(90deg) translateZ(calc(var(--w) / 2));
  /* The block of pages, as a ruling rather than a texture. */
  background:
    repeating-linear-gradient(to right,
      #f2ede4 0 1px, #d8d1c4 1px 2px);
}

/* Head and tail: the same block of pages seen end-on. */
.book3d__face--head,
.book3d__face--tail {
  width: var(--w);
  height: var(--t);
  background: repeating-linear-gradient(to bottom,
    #f2ede4 0 1px, #d8d1c4 1px 2px);
}
.book3d__face--head {
  top: calc(var(--h) / 2 - var(--t) / 2);
  transform: rotateX(90deg) translateZ(calc(var(--h) / 2));
}
.book3d__face--tail {
  top: calc(var(--h) / 2 - var(--t) / 2);
  transform: rotateX(-90deg) translateZ(calc(var(--h) / 2));
}

@keyframes book-lift {
  from { opacity: 0; transform: translateY(26px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .book3d { animation: none; }
}
