/* =========================================================
   FONTS: self-hosted (D12), so visitors never contact Google
   Paths are relative to THIS css file, hence the ../
   Variable fonts: one file holds every weight in the range
   font-display: swap shows fallback text right away instead of invisible text
   ========================================================= */
@font-face {
  font-family: "Cinzel";
  src: url("../assets/fonts/cinzel-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../assets/fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("../assets/fonts/instrument-sans-latin-wght-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("../assets/fonts/silkscreen-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* =========================================================
   DESIGN TOKENS: the one place to restyle the whole site
   Palette: white with Japanese-inspired greens (D19, after dazprojects.com)
   WCAG AA: text needs 4.5:1, borders, focus rings and icons need 3:1.
   Contrast is noted as day / night against the page background
   ========================================================= */
:root {
  /* Two themes (D22): Day and Lantern (night). A third, Moss, was removed (D36).
     color-scheme tells the browser which themes we support; light-dark(day, night)
     then picks a value from the visitor's OS setting, so night = Lantern.
     Bonus: scrollbars and form controls turn dark at night for free */
  color-scheme: light dark;

  /* Palette: named colors, the SAME in every theme.
     Pages don't use these directly; the role colors below and the stripes do */
  --color-pine: #385850;       /* deep pine */
  --color-jade: #59877D;       /* jade */
  --color-jade-deep: #496962;  /* muted deep jade */
  --color-sage: #909E87;       /* sage, decoration only (2.8:1 on white, never text) */
  --color-sand: #D0C0A0;       /* sand, decoration only (1.8:1 on white, never text) */
  --color-sand-tint: #E8E0D0;  /* half sand, half white */
  --color-gunjo: #3B5BA5;      /* gunjō ultramarine */
  --color-kamenozoki: #A5DEE4; /* kamenozoki, pale jar blue */
  --color-beni: #B0204C;       /* beni (safflower) pink, decoration only */
  --color-chochin: #FF7A59;    /* chōchin, paper-lantern red-orange: Lantern's highlight */
  --color-akabeni: #7A2430;    /* akabeni, deep lantern red: WAS Lantern's footer band until 2026-11-15 (now --color-ai, D41). Unused, kept for reference */
  --color-cinnamon: #F5C07B;   /* Cinnamon Buff (Sanzo Wada's color dictionary): the night "in progress" dots (was the theme drum's sun) */
  --color-washi: #F4F1E8;      /* washi paper: the unlit theme lantern */
  --color-sumi: #1F1F1F;       /* sumi ink black: shadows and lines on the theme dimmer */
  --color-paper: #FFFFFF;      /* plain white: the theme dimmer's surface by day */
  --color-blueprint: #1D3F7A;  /* blueprint paper: the trading cards (homyles.css) */
  --color-blueprint-ink: #EAF2FF; /* blueprint linework and text: 9.1:1 on blueprint */
  --color-tokiwa: #007B43;     /* tokiwa, evergreen: the "live" status dot by day */
  --color-yamabuki-deep: #A86F00; /* deep yamabuki gold: "in progress" by day (brighter yellows fail on pale paper) */
  --color-cardstock: #FBF7EC;  /* cream index-card stock: the Code page cards, the same in both themes (ink 12.3, muted 5.4, amber 4.0) */
  --color-ai: #1F3F5F;         /* ai indigo: WAS the night footer (D41, 11-15) until the greyscale night (D43). Unused, kept for reference */
  --color-dusk-day: #ECECEC;   /* light grey: the page just before halfway on the dimmer (D41, D43). Grey text 4.9 */
  --color-dusk-night: #262626; /* lifted charcoal: the page just after halfway (D41, D43). Grey text 6.0 */
  --color-charcoal: #1A1A1A;   /* the footer band at night (D43). White text 17.4 */

  /* Roles: what each color is FOR. light-dark(Day, Night).
     Day = white pages, pine as the one brand colour. Night = a greyscale gallery (owner, 2026-11-15,
     D43, after comparing with dazprojects): near-black page, white text and links, no colour except
     the objects on it (cards, pictures, status dots, stripes fading to grey). The night theme's code
     name stays "lantern" (D35); it was a rainy Japanese street until D43 */
  /* Page background: white / near-black at the ends of the dimmer. Between them it DRIFTS
     toward dusk (D41), so the whole slide moves, not just the stripes: the Day side goes
     white -> --color-dusk-day as --dim goes 0 -> 0.5; the Night side goes --color-dusk-night ->
     #121212 as --dim goes 0.5 -> 1. It still flips at halfway (D37: text has to switch), but the
     flip is smaller and crossfades. Each dusk colour is as far as text contrast allows.
     min()/max() clamp --dim to that side's half; "* 200%" turns half a slide into 0-100%.
     OKLab, not OKLCH: white has no hue, so an OKLCH mix had an undefined hue that the browser
     drew as hue 0 (a pink tint). OKLab has no hue angle at all, so greys stay grey */
  --color-bg: light-dark(
    color-mix(in oklab, #FFFFFF, var(--color-dusk-day) calc(min(var(--dim), 0.5) * 200%)),
    color-mix(in oklab, #121212, var(--color-dusk-night) calc((1 - max(var(--dim), 0.5)) * 200%)));
  --color-surface: light-dark(#F7F5F0, #1C1C1C);    /* panels and cards: washi off-white / charcoal */
  --color-ink: light-dark(#303030, #EDEDED);        /* main text: 13.2 / 16.0 */
  --color-muted: light-dark(#666666, #A3A3A3);      /* captions, secondary text: 5.7 / 7.4 */
  --color-line: light-dark(#DFDFDF, #2E2E2E);       /* hairlines (decoration) */
  /* The veil over a picture when its caption shows (Home's mosaic, the Art grid; O4, D51).
     The same in both themes: it sits on a photo, not on the page. 62% ink black keeps white
     small text at 4.5:1 even over the grey CAD renders (#B3B3B3) */
  --color-veil: color-mix(in srgb, var(--color-sumi) 62%, transparent);
  --color-on-veil: #FFFFFF;
  /* The hover lift on a picture (Home's mosaic, Art, the CAD index). Owner, 2026-11-24: first "a slight
     raise, very small", then "smoother and less subtle": it grows 3%, rises 4px and casts a deeper
     shadow. 3% of a 380px tile is about 6px each side, still inside the 16px gaps */
  --lift: -4px;
  --lift-scale: 1.03;
  --shadow-lift: 0 0.75rem 1.5rem -0.75rem color-mix(in srgb, var(--color-sumi) 55%, transparent);
  --color-accent: light-dark(var(--color-pine), #F5F5F5);              /* links, headings: 7.8 / 17.2 */
  --color-highlight: light-dark(var(--color-jade), #BDBDBD);           /* underlines, rings, markers: 4.05 (not small text) / 10.0 */
  /* The footer band (E1, D53): pine by day, charcoal at night, as in D38. Text on it: 7.8 / 14.5 */
  --color-band: light-dark(var(--color-pine), var(--color-charcoal));
  --color-on-band: light-dark(#FFFFFF, #EDEDED);

  /* Project status dots (Code page, R3). Graphics need 3:1 (WCAG 1.4.11); numbers are on --color-surface.
     Each status also has its own SHAPE (filled, half, ring), so colour is never the only clue */
  --color-status-live: light-dark(var(--color-tokiwa), #6CC48A);              /* green: 4.9 / 8.0 */
  --color-status-wip: light-dark(var(--color-yamabuki-deep), var(--color-cinnamon)); /* amber: 3.9 / 10.3 */
  --color-status-archived: var(--color-muted);                                 /* grey ring: 5.3 / 6.8 */

  /* The active (hovered or focused) word: only color + fake bold change (D20).
     At night the words are already white, so the fake bold does the work */
  --color-active: light-dark(var(--color-gunjo), #FFFFFF);            /* most links: 6.5 / 18.7 */
  --color-active-menu: light-dark(var(--color-jade-deep), #FFFFFF);   /* header menu: 6.0 on white / 18.1 */

  /* The neon glow around active words belonged to the rainy-street night; the greyscale night
     has none (D43). Kept as a token, so --faux-bold below doesn't change */
  --color-glow: transparent;

  /* Fake bold: a hairline shadow on each side of the letters. Real font-weight
     makes the word wider and shoves its neighbors sideways; this doesn't.
     The third, blurred shadow is the night glow (invisible by day) */
  --faux-bold: 0.04em 0 0 currentColor, -0.04em 0 0 currentColor, 0 0 0.6em var(--color-glow);

  /* Fonts: every stack ends in fallbacks in case a file fails to load */
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "Instrument Sans", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --font-pixel: "Silkscreen", "Courier New", monospace;
  --tracking-caps: 0.08em;   /* letter spacing for the small mono CAPITALS labels: capitals set tight look cramped */

  /* Motion: how long hovers and moves take. Every transition uses one of these,
     so the whole site feels like it moves at one pace */
  --speed-fast: 150ms;   /* small responses: a hover lift, a fade, the ▸ arrow turning */
  --speed: 300ms;        /* most transitions: theme crossfade, picture zoom, frames settling */
  --speed-slow: 450ms;   /* big moves: the home card stack shuffling, the cards drawer opening */
  /* The easing for things that glide: a fast start and a long, gentle stop (an "ease-out quint").
     It feels smoother than plain ease, which speeds up and slows down evenly */
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);

  /* Fluid type scale: clamp(min, preferred, max) grows smoothly with screen width,
     so no media queries are needed just to resize text */
  --step--2: clamp(0.72rem, 0.7rem + 0.1vw, 0.78rem);   /* chips, tags, tiny labels: never under 11.5px (R1's 11px floor) */
  --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);   /* small print, captions */
  --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);    /* body text */
  --step-1: clamp(1.2rem, 1.1rem + 0.5vw, 1.45rem);     /* small headings */
  --step-2: clamp(1.45rem, 1.25rem + 0.9vw, 1.9rem);    /* section headings */
  --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.6rem);     /* page title (h1) */
  --step-4: clamp(2.1rem, 1.5rem + 2.8vw, 3.6rem);      /* hero / museum sign */

  /* Spacing scale: use these for margin, padding and gap instead of random numbers */
  --space-1: 0.25rem;  /*  4px */
  --space-2: 0.5rem;   /*  8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2rem;     /* 32px */
  --space-7: 3rem;     /* 48px */
  --space-8: 4rem;     /* 64px */

  /* Layout */
  --measure: 65ch;         /* comfortable reading width for paragraphs */
  --content-max: 72rem;    /* widest the page content gets (~1152px) */
  --gutter: clamp(var(--space-4), 5vw, var(--space-7));  /* side padding of .wrapper: 16px on phones, up to 48px */
  --radius: 4px;           /* small, crisp corners to keep it minimal */
  --radius-soft: 6px;      /* photos and floating panels: About's pictures, the profile card popover */
  --radius-pill: 999px;    /* fully round ends (the outline buttons): any value over half the height works */
  --golden: 1.618;         /* φ, the golden ratio: used for spacing that should feel "just right" */
  --theme-size: 2.5rem;    /* the round theme button in the header (40px: an easy tap, still small) */
  --header-row: var(--space-7);   /* the header's top row on phones: the Menu button's 48px height */

  /* Where every page's content starts below the header (owner's pick B, 2026-11-08):
     60px on phones, growing smoothly to 80px on wide screens. (It used to make room for the
     theme drum hanging under the header too; the drum went in O1, D51.) Home sets its own,
     smaller one: its first line is a quiet row of links, not a page title (homyles.css) */
  --page-top: clamp(3.75rem, 2.5rem + 2.5vw, 5rem);

  /* 3D displays: the CAD carousel (projyles.css), later the spin reel (3.7).
     Ring tilt = the spinning-coin view: how far the ring tips toward you.
     0deg = flat, edge-on. Negative = seen from above (back figures show above the front);
     positive = seen from below. Tried: -8 subtle, -12, -14 (picked), -20 strong */
  --ring-tilt: -14deg;
  /* Camera distance: the original carousel's 1000px. A fixed length (not scaled with the ring)
     keeps the strong perspective lines that make the carousel work (owner, 2026-11-05).
     Smaller = camera closer = stronger perspective */
  --ring-perspective: 1000px;

  /* (--salon-tilt / --salon-nudge, the tilted art frames, went with the Art grid, R4e / D48) */
}

/* Theme picked with the toggle (task 1.14). js/themcript.js sets data-theme on <html>.
   No attribute = follow the OS (Day or Lantern). Forcing color-scheme makes
   every light-dark() above pick the matching side */
:root[data-theme="day"] { color-scheme: light; }
:root[data-theme="lantern"] { color-scheme: dark; }

/* PRINT (and "Save as PDF"): always the Day colours, whatever theme is picked.
   Dark pages waste ink and print badly. Forcing color-scheme: light makes every
   light-dark() pick its Day side; :root[data-theme] matches as strongly as the
   Lantern rule above and comes later, so it wins */
@media print {
  :root,
  :root[data-theme] { color-scheme: light; }
}

/* =========================================================
   RESET: smooth out browser defaults so every page starts level
   Kept small on purpose: only fixes we actually need
   ========================================================= */

/* width now includes padding and border, so "width: 50%" really means 50% */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Browsers add margins to body, headings, p, figure...; we set spacing ourselves with --space-* */
* {
  margin: 0;
}

/* Media never overflows its container, and sits on its own line (no gap under images) */
img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Form controls don't inherit fonts by default, which looks off next to the body text */
input,
button,
textarea,
select {
  font: inherit;
}

/* =========================================================
   BASE TYPOGRAPHY: the tokens first show up on the page here
   ========================================================= */
body {
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;                /* airy body text is easier to read */
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  color: var(--color-accent);      /* pine headings: color in the page, not only in links */
  line-height: 1.2;               /* big text needs less line gap than body text */
  text-wrap: balance;              /* evens out line lengths in multi-line headings */
}

/* Daz pass X2 (D44): only the page title wears Cinzel, so one thing on the page stands out.
   Section headings use the body font. Headings that want Cinzel (the CAD entry titles)
   ask for it by class */
h1 { font-family: var(--font-display); }
h2,
h3 { font-family: var(--font-body); }

h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p {
  max-width: var(--measure);       /* ~65 characters per line, comfortable to read */
  text-wrap: pretty;               /* avoids a lonely last word on its own line */
}

a {
  color: var(--color-accent);
  text-underline-offset: 0.2em;    /* underline sits below descenders (g, y, p) */
}

/* Only the underline changes (jade by day, orange at night): jade text would fail contrast, a line doesn't */
a:hover {
  text-decoration-color: var(--color-highlight);
}

/* Keyboard focus only (mouse clicks don't trigger :focus-visible).
   Buttons and other controls get a pine ring */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Links: no box, the word itself changes color (gunjō blue by day, white at night) and turns bold */
a:focus-visible {
  outline: none;
  color: var(--color-active);
  text-shadow: var(--faux-bold);
}

code,
pre {
  font-family: var(--font-mono);
}

/* The only section divider: a sage hairline (no shadows or boxes) */
hr {
  border: 0;
  border-top: 1px solid var(--color-sage);
  margin-block: var(--space-7);
}

/* Retro label (was 2.7, owner's call in R1): the small typewriter caps used over
   headings and sections, like the labels on a drawing or a museum case.
   One shared class instead of the same five lines in every page's CSS.
   Each page adopts it in its refinement task (R1 Home first) */
.retro-label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 400;
  color: var(--color-muted);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

/* =========================================================
   ACCESSIBILITY HELPERS
   ========================================================= */

/* Hidden from sight but still read by screen readers and reachable with Tab.
   display: none or visibility: hidden would remove it for everyone, keyboard included */
.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);   /* trims the 1px box down to nothing */
  white-space: nowrap;     /* stops screen readers from reading the words squashed together */
}

/* The skip link reappears in the top-left corner when it gets keyboard focus */
.skip-link:focus {
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;            /* sits above the header */
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  clip-path: none;
  background-color: var(--color-surface);
  color: var(--color-ink);
  border-radius: var(--radius);
}

/* =========================================================
   LAYOUT: one centered, minimal column (D17)
   Mobile-first: base styles are for phones, and min-width queries add to them
   Breakpoints: 40rem (~640px, tablet) and 64rem (~1024px, desktop).
   They're typed out because var() doesn't work inside @media conditions
   ========================================================= */

/* Reusable column: add class="wrapper" to anything that should line up with the page */
.wrapper {
  width: 100%;                     /* needed because auto margins in a flex column would shrink it */
  max-width: var(--content-max);   /* stops lines getting too wide on big screens */
  margin-inline: auto;             /* centers it (inline = left and right) */
  padding-inline: var(--gutter);
}

/* Flex column on the page wrapper: main grows to fill the space, so the footer stays at the bottom */
.site {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;              /* dvh = the visible height on phones, minus the browser's address bar */
}

/* The top is the same on every page (--page-top), so page files never add their own
   space above their first element. Only the bottom steps up with the screen */
.site-main {
  flex: 1;
  padding-top: var(--page-top);
  padding-bottom: var(--space-6);
}

@media (min-width: 40rem) {
  .site-main { padding-bottom: var(--space-7); }
}

@media (min-width: 64rem) {
  .site-main { padding-bottom: var(--space-8); }
}

/* =========================================================
   FOOTER: a slim pine band that closes every page (owner's pick E1, D53).
   It was a full pine band (D38), then one quiet line on the page colour (O2, D51);
   the owner wanted the pine back, but slimmer. Everything is centred, like the
   header, so the page opens and closes the same way:
     GITHUB · MAKERWORLD · EMAIL · RESUME
              © 2026 Zach Nott
                        ▔▔▔▔▔▔▔▔▔  <- the stripe mark, exactly as wide as the name
   Declutter (D-a, 2026-11-23): it holds only what the header doesn't, the
   outside links and the © line.
   ========================================================= */
.site-footer {
  font-size: var(--step--1);
  background-color: var(--color-band);
  color: var(--color-on-band);
}

/* One centred column: the links row, then the © line */
.footer-inner {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding-block: var(--space-5);
  text-align: center;
}

/* styles.css gives every <p> a reading width (65ch); the footer lays out its own lines */
.footer-inner p {
  max-width: none;
  margin: 0;
}

/* The group names (Elsewhere, Get in touch) are hidden the screen-reader-text way:
   one row of four links doesn't need them on screen, but screen readers still
   hear which group a link is in */
.footer-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Both groups, and the lists inside them, become one centred, wrapping row.
   Same reset as .header-left-list: no bullets or indent */
.footer-extras,
.footer-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-extras {
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* From 40rem the four links fit on one line, so a dot goes between them. (On phones
   they may wrap, and a dot at the start of a line looks like a mistake, so no dots there.)
   It's decoration from CSS, so screen readers skip it (content: "·" / "" speaks nothing) */
@media (min-width: 40rem) {
  .footer-extras li + li::before,
  .footer-extras .footer-group + .footer-group li:first-child::before {
    content: "·" / "";
    margin-right: var(--space-4);
    opacity: 0.6;
  }
}

/* The stripe mark, small this time: under your name on the © line and exactly as wide
   as it (left: 0 and right: 0 stretch it to the span). position: absolute keeps it out
   of the line, so the band is no taller than the text. --stripe-mark is the same
   gradient as the header's mark (STRIPE COLOURS, near the end of this file) */
.footer-name {
  position: relative;
  display: inline-block;
}

.footer-name::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 2px);
  height: 3px;
  background-image: var(--stripe-mark);
}

/* On the band the links are the band's text colour; underline only on hover keeps it quiet.
   The site-wide link focus turns words gunjo blue, which is hard to read on pine, so the
   footer uses a ring in the text colour instead (a class + :focus-visible beats a:focus-visible) */
.footer-link {
  color: inherit;
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.footer-link:focus-visible {
  color: inherit;
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* =========================================================
   HEADER: the same markup is copied into every page.
   Order: frame, links, Menu button, Lab dropdown, then one phone block
   and one desktop block at the end, so every screen-size change for the
   header lives in one place.
   Use classes here, never a bare "header" selector: projects.html has a second
   <header> inside its article, and a bare selector would style that too
   ========================================================= */

/* ---------- Frame ---------- */

/* No band and no hairline (O1, D51): the header sits on the page colour, like the reference,
   so the first thing under it is the work. (It was a white band with a hairline, D43) */
.site-header {
  position: relative;                  /* the theme button is placed inside it (see THEME BUTTON) */
  padding-block: var(--space-4);
}

/* Phone layout. Named grid areas: each part says where it goes by name,
   and the desktop block at the end rearranges the same names */
/* 1fr auto 1fr: two equal side columns keep the logo centered on the band (owner, R1),
   the Menu button sits in the right one and an empty "." cell balances it on the left */
.main-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas:
    ".     logo  toggle"
    "left  left  left"
    "right right right";
  align-items: center;
  column-gap: var(--space-4);
}

.header-column-center { grid-area: logo; }
.menu-toggle          { grid-area: toggle; justify-self: end; }
.header-column-left   { grid-area: left; }
.header-column-right  { grid-area: right; }

/* Your name, the Home link (O1, D51; it replaced the ZcN logo image, which stays in
   assets/images/logo.svg). Bold mono capitals with wide spacing, like the reference's wordmark.
   position: relative anchors the stripe mark below it */
.size-spacing-style-logo {
  position: relative;
  display: inline-block;
  color: var(--color-ink);
  text-decoration: none;
}

.header-name {
  font-family: var(--font-mono);
  font-size: var(--step-0);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* THE STRIPE MARK (O2, owner's pick S2): the five 70s stripes, now a small bar under the name
   instead of a band down the right edge. position: absolute keeps it out of the layout, so the
   name still lines up with the links beside it. It's decoration from CSS, so screen readers skip it.
   The colours are --stripe-1 to --stripe-5 (they fade to greys at Night, D43) */
.size-spacing-style-logo::after {
  content: "";
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 50%;
  translate: -50% 0;
  width: var(--space-7);
  height: var(--space-1);
  background-image: var(--stripe-mark);   /* the five stripes (STRIPE COLOURS); the footer's mark uses it too */
}

/* The site-wide link focus (colour + fake bold) works on the name too, but a ring is clearer
   for the one link that looks like a logo (a class plus :focus-visible beats a:focus-visible) */
.size-spacing-style-logo:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

/* ---------- Links ---------- */

/* One step smaller than body text, in spaced capitals with no underline, like the reference (O1, D51).
   The HTML says "Code", the CSS draws CODE: screen readers read a word, not letters */
.menu-link {
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-ink);
}

/* Hover and Tab: only the color and fake bold change, with no background or extra line.
   Covers the top links, the dropdown and the phone menu (they all use .menu-link) */
.menu-link:hover,
.menu-link:focus-visible {
  color: var(--color-active-menu);
  text-shadow: var(--faux-bold);
}

/* "You are here": an underline, like the reference. Each page marks its own link with
   aria-current="page" in the HTML. Screen readers announce "current page", and styling the
   ATTRIBUTE (not a separate class) means the visible marker and the spoken one can never disagree */
.menu-link[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.4em;
}

/* No bullets or indent; the left and right lists share these rules */
.header-left-list,
.menu-horizontal {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Phones: one link per row, and the padding makes each row a big tap target */
/* The Lab link is hidden until the Lab exists (R1). The desktop block below gives
   .header-right-item a display value, which would beat the hidden attribute,
   so this rule says it again with a stronger selector (an id beats a class) */
#item-lab[hidden] {
  display: none;
}

.header-left-item,
.header-right-item {
  padding: var(--space-4);         /* was 15px: now on the spacing scale */
  white-space: nowrap;
}

/* ---------- Menu button (phones) ----------
   Both buttons start with the hidden attribute (see js/script.js).
   Never set display on them outside the desktop block, or hidden stops
   working and a dead button shows when JS is off */
.menu-toggle {
  min-height: var(--space-7);          /* 48px: a comfortable finger-sized target */
  padding-inline: var(--space-4);
  border: 1px solid var(--color-line);  /* the same hairline as the theme button beside it (O1) */
  border-radius: var(--radius);
  background: none;
  color: var(--color-ink);
  font-size: var(--step--1);
  cursor: pointer;
}

/* The narrowest phones can't fit the centered logo AND "☰ Menu" on both sides of it,
   so the button keeps only the ☰ icon (a 48px square) and the word is hidden the
   screen-reader-text way: still read aloud, so the button's name stays "Menu" */
@media (width < 24rem) {
  .menu-toggle {
    min-width: var(--space-7);
    padding-inline: 0;
  }

  .menu-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ---------- Lab dropdown ----------
   Phones: a ▸ button folds the sub-links open and shut inside the Menu.
   Desktop: the sub-links float in a panel that opens on hover or keyboard focus */
.mega-sub-menu {
  list-style: none;
  margin: 0;
  padding-inline-start: var(--space-4);   /* indented under "The Laboratory" */
}

.mega-sub-menu li {
  padding-block: var(--space-2);
}

/* No underlines: a stack of them looked clunky */
.mega-sub-menu .menu-link {
  text-decoration: none;
}

.submenu-toggle {
  min-width: var(--space-7);           /* 48px tap target */
  min-height: var(--space-7);
  border: none;
  background: none;
  color: var(--color-ink);
  font-size: var(--step-2);            /* the ▸ character is drawn small, so size it up */
  cursor: pointer;
}

/* transform needs a box, and an inline span isn't one, hence inline-block */
.submenu-toggle span {
  display: inline-block;
  transition: transform var(--speed-fast);
}

/* Points down when open */
.submenu-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
}

/* ---------- Phones only: closed states ----------
   "~" means "any later sibling", so each button must come before what it hides.
   (width < 64rem) ends exactly where the desktop block begins */
@media (width < 64rem) {
  .menu-toggle[aria-expanded="false"] ~ .header-column-left,
  .menu-toggle[aria-expanded="false"] ~ .header-column-right,
  .submenu-toggle[aria-expanded="false"] ~ .mega-sub-menu {
    display: none;
  }
}

/* ---------- Desktop ---------- */
@media (min-width: 64rem) {
  /* 1fr auto 1fr: the logo column is only as wide as the logo, and the two sides
     split the rest equally, so the logo stays truly centered */
  .main-nav {
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "left logo right";
    gap: var(--space-5);
  }

  /* Links sit in a row, the left ones pushed toward the logo */
  .header-column-left {
    text-align: right;
  }

  .header-left-item,
  .header-right-item {
    display: inline-block;
  }

  /* Hover and focus do the opening here, so no buttons */
  .menu-toggle,
  .submenu-toggle {
    display: none;
  }

  /* The panel measures its position from this li (its nearest positioned ancestor) */
  #item-lab {
    position: relative;
  }

  /* top: 100% puts the panel flush under the li. The li's own padding is
     part of the li, so the mouse never crosses a gap where :hover would end */
  .mega-sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;                       /* above the page content */
    padding: var(--space-3) var(--space-5);
    background: var(--color-bg);
    border: 1px solid var(--color-sage);
    border-top: 3px solid var(--color-accent);   /* a pine strip, like a vintage label */
  }

  /* Tighter rows than on phones: a mouse doesn't need a finger-sized target */
  .mega-sub-menu li {
    padding-block: var(--space-1);
  }

  /* :focus-within = this li or anything inside it has focus, so tabbing
     through the sub-links keeps the panel open, and tabbing out closes it */
  #item-lab:hover .mega-sub-menu,
  #item-lab:focus-within .mega-sub-menu {
    display: block;
  }
}

/* =========================================================
   STRIPE COLOURS: the five 70s stripes (D38, D43). Since O2 (D51) they are
   only the small mark under the name (HEADER above, and the footer's © line since D53); until then they ran
   down the right edge of every page (git log -S "RETRO STRIPES" has the band).
   By day they are the palette colours; at Night each one is a grey, light to
   dark, so the mark stays calm on the near-black page
   ========================================================= */
:root {
  /* OKLab: fading TO grey needs no hue path */
  --stripe-1: color-mix(in oklab, var(--color-gunjo), #EDEDED calc(var(--dim) * 100%));
  --stripe-2: color-mix(in oklab, var(--color-jade), #BFBFBF calc(var(--dim) * 100%));
  --stripe-3: color-mix(in oklab, var(--color-sage), #8F8F8F calc(var(--dim) * 100%));
  --stripe-4: color-mix(in oklab, var(--color-sand), #636363 calc(var(--dim) * 100%));
  --stripe-5: color-mix(in oklab, var(--color-beni), #3D3D3D calc(var(--dim) * 100%));

  /* The mark itself, used twice: under the name in the header and under it in the footer.
     Hard stops (each colour starts where the last ends) give solid stripes, not a blend */
  --stripe-mark: linear-gradient(to right,
    var(--stripe-1) 0%  20%,
    var(--stripe-2) 20% 40%,
    var(--stripe-3) 40% 60%,
    var(--stripe-4) 60% 80%,
    var(--stripe-5) 80% 100%);
}

/* =========================================================
   THEME: Auto, Day and Night (task 1.14, D35, D37; one round button since O1, D51).
   --dim is 0 by day and 1 at night; a few colours mix with it (the page
   background, the stripe greys). js/themcript.js only sets data-theme on <html>.
   (The drum dimmer it replaced set in-between levels too: git log -S "THEME DIMMER")
   ========================================================= */

/* No choice (Auto): follow the OS. A choice: data-theme decides */
:root { --dim: 0; }
@media (prefers-color-scheme: dark) { :root { --dim: 1; } }
:root[data-theme="day"] { --dim: 0; }
:root[data-theme="lantern"] { --dim: 1; }

/* Paper doesn't print dark: always the Day level on paper */
@media print { :root { --dim: 0 !important; } }

/* The page switches with a short crossfade instead of a jump */
@media (prefers-reduced-motion: no-preference) {
  body {
    transition: background-color var(--speed) ease, color var(--speed) ease;
  }
}

/* =========================================================
   PAGE TRANSITIONS (owner, 2026-11-26): going from page to page, say from the Code
   workshop to CAD, cross-fades instead of flashing blank. A cross-document View
   Transition: when BOTH pages opt in with this rule (all of them load styles.css,
   except thelab.html), the browser snapshots the old page and fades it into the new.
   Browsers without it (Firefox, for now) just change page as before. Links to other
   sites never fade. A fade isn't movement, so it stays for reduced-motion users too
   ========================================================= */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: page-out var(--speed) ease both;
}

::view-transition-new(root) {
  animation: page-in var(--speed-slow) var(--ease-smooth) both;
}

@keyframes page-out {
  to { opacity: 0; }
}

@keyframes page-in {
  from { opacity: 0; }
}

/* ---------- THE THEME BUTTON ----------
   A plain <button>: Enter, Space, click and screen readers work for free.
   Never set display on it, or the hidden attribute stops working (no JS = no button).
   Phones: in the empty cell left of the name, level with the Menu button.
   Desktop: at the right end of the header row */
.theme-button {
  position: absolute;
  top: calc(var(--space-4) + (var(--header-row) - var(--theme-size)) / 2);   /* centred on the top row */
  left: var(--gutter);
  width: var(--theme-size);
  height: var(--theme-size);
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  background: none;
  color: var(--color-ink);
  cursor: pointer;
}

.theme-button:hover {
  border-color: var(--color-highlight);
}

@media (min-width: 64rem) {
  .theme-button {
    top: 50%;
    left: auto;
    right: var(--gutter);
    translate: 0 -50%;
  }
}

/* The icon: drawn in the text colour with thin lines, like the rest of the header.
   All three icons are in the HTML; data-mode (set by the script) shows one */
.theme-icon {
  display: block;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon g {
  display: none;
}

.theme-button[data-mode="auto"] .icon-auto,
.theme-button[data-mode="day"] .icon-day,
.theme-button[data-mode="lantern"] .icon-night {
  display: inline;
}

/* Auto's filled half */
.icon-auto path {
  fill: currentColor;
  stroke: none;
}
