@import url("./tokens.css");
@import url("./fonts.css");

/* Motion and hover values that tokens.css does not carry (they come from analysis/interactions.json).
   --ease-page approximates the reference's custom ease:
     M0,0 C0,0 0.081,0.01 0.159,0.178 0.24,0.353 0.329,0.649 0.482,0.828 0.651,1.026 1,1 1,1
   linear() samples that path every 5% of time; the cubic-bezier() is the closest single curve (RMS error 0.006),
   kept for browsers without linear(). */
:root {
  --ease-page: cubic-bezier(0.35, 0.2, 0.2, 1.05);
  --ease-ui: cubic-bezier(0.4, 0, 0.2, 1);          /* links and header: 0.15 s colour, 0.3 s transform */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);       /* GSAP power2.out (the header sliding away) */
  --link-hover: #959595;                            /* --content-action-hover on the reference */
  --link-hover-duration: 150ms;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root { --ease-page: linear(0, 0.026 5%, 0.078 10%, 0.159 15%, 0.273 20%, 0.398 25%, 0.516 30%, 0.622 35%, 0.713 40%, 0.788 45%, 0.848 50%, 0.89 55%, 0.922 60%, 0.945 65%, 0.963 70%, 0.977 75%, 0.988 80%, 0.995 85%, 0.999 90%, 1.001 95%, 1); }
}

@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "DM Mono", ui-monospace, Menlo, monospace; font-size: var(--label-size); line-height: var(--label-line); letter-spacing: var(--label-tracking); min-height: 100vh; }
a { color: inherit; text-decoration: none; transition: color var(--link-hover-duration) var(--ease-ui); }
a:hover { color: var(--link-hover); }
/* Focus stays visible (the reference removes it). currentColor keeps it readable inside the blended header too. */
a:focus-visible, button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
p, h1, h2, h3, ul, ol, figure { margin: 0; padding: 0; font: inherit; }
ul, ol { list-style: none; }
/* Headings break into balanced lines and paragraphs avoid a lone last word (the critique's 18 stragglers) */
h1, h2, h3, .subhead, .lead { text-wrap: balance; }
p, li, figcaption, blockquote { text-wrap: pretty; }
img, svg { display: block; max-width: 100%; }

/* The 12-column grid every row uses (6 columns at phone width, from tokens.css) */
.row { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); column-gap: var(--gutter); padding-inline: var(--margin); }
.block-tight { margin-bottom: var(--space-block-tight); }
.block { margin-bottom: var(--space-block); }
.block-large { margin-bottom: var(--space-block-large); }

/* Visible grid lines, built as the reference builds them: a flex row of gutters and columns. An edge gutter 1px wide
   with one pink line, then columns alternating with inner gutters (grey line on the left edge, pink on the right),
   then a last 1px edge gutter. site.js fills it from --columns. Each line is its own element. */
/* Grid lines sit under the content (Amit, 25 Nov 2026): text, images and the rising sheet cover them. The reference draws them on top. */
.grid-lines { position: fixed; inset: 0; z-index: -1; pointer-events: none; display: flex; padding-inline: var(--margin); }
.grid-lines i { display: block; }
.grid-lines .gl-col { flex: 1 1 0; min-width: 0; }
.grid-lines .gl-gutter { flex: 0 0 var(--gutter); display: flex; justify-content: space-between; }
.grid-lines .gl-gutter--edge { flex-basis: var(--grid-line-width); }
.grid-lines .gl-line { width: var(--grid-line-width); height: 100%; background: var(--grid-line); }
.grid-lines .gl-line--alt { background: var(--grid-line-alt); }

/* Type roles */
.lead { font-size: var(--lead-size); line-height: var(--lead-line); letter-spacing: var(--lead-tracking); }
.title { font-size: var(--title-size); line-height: var(--title-line); letter-spacing: var(--title-tracking); }
.subhead { font-family: "Host Grotesk", Helvetica, Arial, sans-serif; font-weight: var(--subhead-weight); font-size: var(--subhead-size); line-height: var(--subhead-line); letter-spacing: var(--subhead-tracking); }
/* The tagline in the menu's size at every width (Amit, 25 Nov: at phone width the measured 10px was too small; at 1440
   the two were already equal, 14px) */
.tagline { font-size: var(--label-size); line-height: var(--label-line); letter-spacing: var(--label-tracking); }

/* The wordmark: full width on Home, small in the header elsewhere. Same view-transition name, so it morphs between pages. */
.wordmark { display: block; color: var(--ink); view-transition-name: wordmark; }
.wordmark svg, .wordmark img { width: 100%; height: auto; overflow: visible; }
.wordmark--home { grid-column: 1 / -1; }
.wordmark--header { grid-column: 1 / span 3; width: min(var(--wordmark-header-width), 100%); padding-top: var(--margin); }

/* Header text, as on the reference: white with mix-blend-mode difference, so it reads dark on light and light on dark.
   The blend sits on the element that is position: fixed (a blended child of a fixed parent would only blend inside it).
   Hover keeps the reference's declared grey, so under the same blend it renders the same grey as theirs. */
.header-text { color: var(--header-color); mix-blend-mode: var(--header-blend); }
/* On dark paper the blend would render the hover grey far too faint, so the header hover is set to what renders as
   the dark pages' hover colour. */
[data-theme="dark"] .header-text a:hover { color: #dddddd; }
/* Stage 5 contrast (Amit, 25 Nov): the reference's #959595 hover reaches only 3.86:1 on the dark paper. On dark pages
   the hover is #a4a4a4 (4.63:1); in the header #dddddd renders as #a4a4a4 under the blend (0xdd - 0x39 = 0xa4).
   Since 29 Nov the site header on dark pages is outside the blend and takes var(--link-hover) from the dark rules
   below, so the #dddddd rule no longer applies to it. */
[data-theme="dark"] { --link-hover: #a4a4a4; }
/* Dark inner pages (Amit, 29 Nov 2026: the header's Dekalo is white, as on Home in space). White under the difference
   blend renders #c6c6c6 on #393939 and can never reach the ink, so on a dark page the site header leaves the blend and
   takes the ink colour itself: 9.69:1 on #393939. The tagline keeps its 0.8. The hover is the dark pages' --link-hover
   as it is (#a4a4a4; the Sage on About), not a value for the blend to turn into it. Home's layer (main.home.header-text)
   is not a .site-header and keeps the blend. */
[data-theme="dark"] .site-header.header-text { color: var(--ink); mix-blend-mode: normal; }
[data-theme="dark"] .site-header.header-text a:hover { color: var(--link-hover); }
/* Browser-drawn parts (scrollbars, form controls) follow the dark pages */
[data-theme="dark"] { color-scheme: dark; }

/* Header rhythm, from the reference: tagline 24px under the wordmark (8px at phone width), the menu row 24px under
   the tagline (16px at phone width). The tagline is at opacity 0.8. */
:root { --header-gap: 24px; --menu-gap: 24px; }
.header-text .tagline { grid-column: 1 / span 6; opacity: 0.8; }

/* The menu, the same on every page and only on the right, placed as the reference places its index on Home: the
   first item in column 9 and the numbered list starting in column 10 on the same row, one entry per line. Ours:
   00 About in column 9, the cases in column 10; adding a case is adding one <li>. */
.menu { margin-top: var(--menu-gap); align-items: start; }
.menu-about { grid-column: 9; justify-self: start; }
/* Between the phone grid and about 1120 wide, column 9 is narrower than 00•[About], which ran into the cases
   (-12px at 880 on /about); there About ends at column 9's right edge instead, one gutter from the cases */
@media (min-width: 880px) and (max-width: 1119px) { .menu-about { grid-column: 8 / span 2; justify-self: end; } }
.menu .index { grid-column: 10 / span 3; }
.menu a { display: inline-block; white-space: nowrap; }
.menu .number { margin-inline-end: 0.5ch; }
/* Current page, as on the reference: 01•[Case Management] */
.menu a[aria-current="page"] .number { margin-inline-end: 0; }
.menu a[aria-current="page"] .label::before { content: "•["; }
.menu a[aria-current="page"] .label::after { content: "]"; }

/* Site header on inner pages, as on the reference's chapter pages: one fixed layer over the content holding the plain
   wordmark, the tagline and the menu. On light pages it is white under the difference blend of .header-text, so it
   reads on paper and on images. On dark pages it is the ink, outside the blend (see the dark rules below).
   The mark takes the header colour through currentColor; on a light page at opacity 0.8 it renders #3f3f3f on light
   paper, as the reference's does. Past 200px of scroll the wordmark and tagline slide up and the menu row stays at
   the top (site.js). --site-header-h is measured by site.js; the fallback is the phone layout with one case
   (3.855 is the aspect of dekalo.svg). */
:root {
  --site-header-h: calc(var(--margin) + min(var(--wordmark-header-width), 100vw - 2 * var(--margin)) / 3.855 + var(--header-gap) + 3 * var(--tagline-size) * var(--tagline-line) + var(--menu-gap) + var(--label-size) * var(--label-line));
  --site-header-shift: 0px;
}
.site-header { position: fixed; top: 0; left: 0; right: 0; z-index: 4; pointer-events: none; }
.site-header a { pointer-events: auto; }
/* The blended (light page) case; dark pages set the opacity to 1 below. */
.site-header .wordmark { color: inherit; opacity: 0.8; }
/* Without scripts, or when the fetch fails, the mark stays an <img>, which draws currentColor as black: black under a
   difference blend changes nothing, so the mark would vanish. Inverted, it is white like the inlined one. This is the
   blended (light page) case; dark pages override the filter below. */
.site-header .wordmark img { filter: invert(1); }
/* On a dark page the header is not blended (above): the mark is the ink at full strength, and the <img> fallback is
   white dimmed to the ink (255 x 0.92 = 235, #ebebeb). */
[data-theme="dark"] .site-header .wordmark { opacity: 1; }
[data-theme="dark"] .site-header .wordmark img { filter: invert(1) brightness(0.92); }
.site-header .tagline-row { margin-top: var(--header-gap); }
.site-header.is-hidden { transform: translateY(calc(-1 * var(--site-header-shift))); }
/* Inner pages (data-menu-band on <html>): past the header's own height only the menu row shows, on a paper band, in
   both scroll directions; the wordmark and tagline stay out of sight. Same offset as the slide-up, so nothing jumps.
   From the case study page, approved by Amit 25 Nov. */
.header-band { display: none; }
html[data-menu-band] .header-band { display: block; position: fixed; top: 0; left: 0; right: 0; height: var(--menu-band-h, calc(var(--margin) * 2 + var(--label-size) * var(--label-line))); background: var(--paper); z-index: 3; opacity: 0; pointer-events: none; transition: opacity 200ms; }
html[data-menu-band] .site-header.is-hidden ~ .header-band { opacity: 1; }
html[data-menu-band].is-past-top .site-header { transform: translateY(calc(-1 * var(--site-header-shift))); }
html[data-menu-band].is-past-top .site-header .wordmark,
html[data-menu-band].is-past-top .site-header .tagline-row { visibility: hidden; }
html[data-menu-band].is-past-top .header-band { opacity: 1; }
/* A view transition captures the wordmark on its own, outside the blend, where white would flash on the paper.
   the page's head script sets .vt-capture around the capture, so the mark is captured in ink. Where relative colours
   work, it is captured in the colour the blend renders: white under difference is 255 minus the paper, at the same
   0.8, so the mark does not jump when the transition ends. On a light page that is close to the ink. A dark page's
   header is not blended, so it has its own rule below. */
.vt-capture .site-header .wordmark { color: var(--ink); opacity: 1; }
@supports (color: rgb(from red r g b)) {
  .vt-capture .site-header .wordmark { color: rgb(from var(--paper) calc(255 - r) calc(255 - g) calc(255 - b)); opacity: 0.8; }
}
/* A dark page's header is not blended, so its mark is captured as it is drawn: the ink, at full strength */
[data-theme="dark"].vt-capture .site-header .wordmark { color: var(--ink); opacity: 1; }
/* The fixed header stays over the top of the page: a focused or targeted element must stop below all of it */
html:has(.site-header) { scroll-padding-top: calc(var(--site-header-h) + var(--margin)); }

/* The cursor dot */
.cursor-dot { position: fixed; left: 0; top: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--ink); pointer-events: none; z-index: 10; transform: translate(-100px, -100px); }
.has-cursor-dot, .has-cursor-dot a, .has-cursor-dot button { cursor: none; }

/* Gallery. The main slot stacks its labels in one cell, so a change cross-fades the old label out and the new one in
   (site.js, 1200 ms, as recorded on the reference). */
.gallery [data-gallery-main] > * { grid-area: 1 / 1; }
.gallery button.expand { width: auto; height: auto; border: 0; padding: 4px 0; text-decoration: underline; text-underline-offset: 4px; margin-inline-start: auto; }
/* "Expand": the current slot in a native dialog (Esc, focus trap and focus return come with it). As on the reference,
   a centred panel two thirds of the screen wide and full height on the paper colour, growing from the slot's place in
   300 ms while the page fades out (site.js and the animations below). The dialog sits above the cursor dot, so it
   gets a normal cursor back. */
.expand-dialog { width: calc(100vw * 2 / 3); height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0 auto; border: 0; padding: var(--margin); background: var(--paper); color: var(--ink); }
.expand-dialog::backdrop { background: var(--paper); }
.expand-dialog[open] { display: grid; grid-template-rows: auto 1fr; gap: var(--gutter); }
.expand-dialog form { justify-self: end; }
.expand-dialog, .expand-dialog button { cursor: auto; }
.expand-dialog button { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* A sheet: a full-width surface that rises over the page as its row scrolls into view (the journey map on Project).
   The row stays in place (site.js observes it); its inner .sheet moves. */
.sheet { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: start; background: var(--paper); border-top: 1px solid var(--ink); padding-top: var(--space-block); }

/* Footer, as the reference's pages end: contact, CV, copyright (About only; Home has no footer) */
.footer { padding-block: var(--space-block-large) var(--margin); row-gap: var(--space-block-large); align-items: start; }
.footer li { white-space: nowrap; }
.footer .copyright { grid-column: 1 / -1; }

/* Labelled image slots: never an invented picture */
.slot { display: grid; place-items: center; text-align: center; padding: 24px; border: 1px dashed var(--ink); min-height: 240px; }
/* min-height 0: with aspect-ratio, the 240px minimum would also set a 427px minimum width and overflow a phone */
.slot--wide { grid-column: 1 / -1; aspect-ratio: 16 / 9; min-height: 0; }

/* Load sequence, about 2 s, once per browser session. The inline script in each page's head adds .is-loading only when
   motion is allowed and the sequence has not played in this session, so hidden start states never apply without
   scripts or under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  .js.is-loading .grid-lines .gl-line { transform: scaleY(0); }
  /* The rest state reaches 6px outside the box, so the clip never cuts the focus outline of the wordmark link */
  .js.is-loading .wordmark { clip-path: inset(-6px 100% -6px -6px); }
  .js.is-loading [data-enter] { opacity: 0; transform: translateY(8px); }
  .grid-lines .gl-line { transition: transform 900ms var(--ease-page); transform-origin: top; }
  .wordmark { transition: clip-path 1100ms var(--ease-page); clip-path: inset(-6px); }
  /* Inner-page header: slides away in 300 ms (power2.out); site.js shortens it to 200 ms for the return near the top */
  .site-header { transition: transform var(--header-slide, 300ms) var(--ease-out); }
  /* Expand: the page fades out under the panel in 300 ms, and back when it closes */
  .expand-dialog[open]::backdrop { animation: fade-in 300ms cubic-bezier(0.45, 0, 0.55, 1); }
  .expand-dialog.is-closing, .expand-dialog.is-closing::backdrop { animation: fade-out 300ms cubic-bezier(0.45, 0, 0.55, 1) forwards; }
  [data-enter] { transition: opacity 500ms linear, transform 700ms var(--ease-page); transition-delay: calc(900ms + var(--enter-order, 0) * 90ms); }
  .js [data-rise]:not(.is-in) { transform: translateY(12vh); opacity: 0; }
  [data-rise] { transition: transform 900ms var(--ease-page), opacity 500ms linear; }
  /* Arrival and scroll reveal (Amit, 30 Nov, from studies/page-motion/). On an inner page that does not play the load
     sequence, the header's text and the blocks on the first screen rise in its motion (8px and a fade, 90 ms apart);
     on every inner page each block below the first screen rises the same way as it comes into view. The head script
     adds .is-arriving before the first paint; site.js marks the blocks [data-reveal] and adds .is-in. Rows that hold
     a sheet or a riser keep their own motion. */
  .js.is-arriving .site-header [data-enter],
  .js.is-arriving main > .row:not([data-sheet]):not(:has([data-sheet], [data-rise])) { opacity: 0; transform: translateY(8px); }
  .js [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(8px); }
  [data-reveal] { transition: opacity 500ms linear, transform 700ms var(--ease-page); transition-delay: var(--reveal-delay, 0ms); }
  .sheet { transition: transform 900ms var(--ease-page); }
  /* The start state is here and not set by site.js, so the first frame already has the sheet down (a module script
     can run after the first paint). site.js adds .is-up; each page's head script does it if site.js never runs. */
  .js [data-sheet]:not(.is-up) > .sheet { transform: translateY(30vh); }
  ::view-transition-group(wordmark) { animation-duration: 800ms; animation-timing-function: var(--ease-page); }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 400ms; }
}
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

@media (max-width: 879px) {
  :root { --header-gap: 8px; --menu-gap: 16px; }
  .header-text .tagline { grid-column: 1 / -1; }
  /* The menu on one row in the 6-column grid: 00 About in columns 1-2, the cases beside it in columns 3-6, which
     leaves room for 01•[Case Management] at 320 wide */
  .menu-about { grid-column: 1 / span 2; }
  .menu .index { grid-column: 3 / span 4; }
  .wordmark--header { grid-column: 1 / -1; }
  .footer { row-gap: var(--space-block); }
  .footer h2, .footer ul { grid-column: 1 / -1; }
  .footer ul { margin-bottom: var(--space-block-large); }
  .cursor-dot { display: none; }
  .has-cursor-dot, .has-cursor-dot a, .has-cursor-dot button { cursor: auto; }
}

/* Visually hidden, read by assistive tech (case.css has its own .vh with the same effect) */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Skip link (WCAG 2.4.1): hidden until focused, then on paper at the top left, above the header */
.skip-link { position: fixed; left: var(--margin); top: var(--margin); z-index: 10; padding: 4px 8px; background: var(--paper); color: var(--ink); transform: translateY(-200%); }
.skip-link:focus-visible { transform: none; }
/* Menu tap targets at phone width: a 24px line box (WCAG 2.5.8) without moving the text */
@media (max-width: 879px) { .menu a { padding-block: 5px; margin-block: -5px; } }
