/* davidzgray.com v4 theme "Index": one set of tabbed dividers, one per world.
   Shared by every frame. Worlds set their own tokens on <body class="w-...">. */

@font-face {
  font-family: "Recursive";
  font-style: oblique 0deg 15deg;
  font-weight: 300 1000;
  font-display: block;
  src: url(fonts/recursive-latin-full-normal.woff2) format("woff2-variations");
}

:root {
  /* Neutrals (shared by all worlds) */
  --paper: #EDEEEA;
  --ink: #15171A;
  --graphite: #5A5E63;
  --rule: #C8CAC4;
  --night: #131416;
  --night-2: #1E2023;
  --smoke: #9EA2A6;

  /* One accent per world (no hue 230-330) */
  --c-work: #2B4A6F;       /* slate blue, hue 212, low chroma (quiet world) */
  --c-lab: #F2A007;        /* terminal amber, hue 40 */
  --c-consult: #3E6B58;    /* grey eucalyptus, hue 154, low chroma (quiet world) */
  --c-studio: #E0402F;     /* lantern red, hue 5 */
  --c-games: #22B3C8;      /* v4: CRT cyan, hue 188 (David: no neon yellow) */

  /* Per-world defaults (Home) */
  --bg: var(--paper);
  --fg: var(--ink);
  --muted: var(--graphite);
  --line: var(--rule);
  --w: var(--ink);
  --w-ink: var(--paper);

  /* Recursive axes */
  --mono: 0;
  --casl: 0;
  --slnt: 0;

  /* Grid */
  --margin: clamp(20px, 4.4vw, 64px);
  --gutter: clamp(16px, 1.7vw, 24px);
  --cols: 12;
  --nav-h: 56px;
  --chamfer: 12px;
  /* v3: content stops growing at 1680 px; the page colour still runs full width */
  --maxw: 1680px;
  --edge: max(var(--margin), calc((100% - var(--maxw)) / 2));

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Recursive", ui-sans-serif, system-ui, sans-serif;
  font-variation-settings: "MONO" var(--mono), "CASL" var(--casl), "slnt" var(--slnt), "CRSV" 0.5;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }

/* World token sets */
.w-work    { --w: var(--c-work);    --w-ink: #FFFFFF; }
.w-lab     { --w: var(--c-lab);     --w-ink: var(--ink); --bg: var(--night); --fg: #E9E6DF; --muted: var(--smoke); --line: #2E3034; --mono: 1; }
.w-consult { --w: var(--c-consult); --w-ink: #FFFFFF; }
.w-studio  { --w: var(--c-studio);  --w-ink: #FFFFFF; --bg: var(--night); --fg: #F1EEE8; --muted: var(--smoke); --line: #2E3034; }
.w-games   { --w: var(--c-games);   --w-ink: var(--ink); --casl: 1; }

/* The grid: 12 columns on desktop, 4 on phone */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gutter);
  padding-inline: var(--edge);
}
@media (max-width: 760px) { :root { --cols: 4; --nav-h: 52px; } }

/* The chamfer: the one shape of the family. Top-right corner cut at 45 degrees.
   Used on tabs and on the main action. No border-radius anywhere. */
.chamfer { clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%); }

/* Name mark */
.mark {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px;
  font-weight: 720;
  font-variation-settings: "MONO" 0, "CASL" 0, "slnt" 0, "CRSV" 0.5;
  font-size: 18px; letter-spacing: -0.01em;
  text-decoration: none; color: var(--fg);
  white-space: nowrap;
}
.mark i {
  width: 14px; height: 18px; background: currentColor; display: block;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 0 100%);
}

/* v4: ONE world rail for every page. Desktop and tablet (761 px and up): it is fixed on the right
   side and the page scrolls on the left. Phone: the same five tabs are a bar at the foot.
   Order (David, 19 Oct 2026): Work, Consulting, Lab, Studio, Games & Live. Markup: rail.js.
   Hover rule (v4 bug fix): only the tab under the pointer moves out. No tab is pulled out
   at rest, no script moves a tab, and :focus never moves a tab (focus shows an outline only). */
:root { --rail-w: clamp(176px, 21vw, 460px); }
.rail { display: none; }
@media (min-width: 761px) {
  body.has-rail { padding-right: var(--rail-w); }
  .rail {
    position: fixed; z-index: 30; top: 0; right: 0; bottom: 0; width: var(--rail-w);
    display: flex; flex-direction: column;
    background: var(--bg); border-left: 1px solid var(--line);
    font-variation-settings: "MONO" 0, "CASL" 0, "slnt" 0, "CRSV" 0.5;
  }
  .rail .mark { flex: none; height: clamp(64px, 7vh, 104px); padding: 0 clamp(14px, 1.4vw, 28px); }
  .rail ol { list-style: none; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: clamp(4px, 0.6vh, 8px); padding-bottom: clamp(8px, 1.6vh, 20px); }
  .rail li { flex: 1 1 0; min-height: 0; display: flex; }
  .rail li.also { flex: 0 0 auto; padding: 6px clamp(14px, 1.4vw, 28px) 0; font-size: clamp(13px, 0.8vw, 18px); line-height: 1.3; color: var(--muted); }
  .rail .rt {
    --c: var(--ink); --k: #fff;
    position: relative; flex: 1; min-height: 48px; overflow: hidden;
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    padding: 0 clamp(14px, 1.4vw, 30px);
    text-decoration: none; background: var(--c); color: var(--k);
    clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
    transition: transform 200ms var(--ease-out);
  }
  .rail .rt b { font-size: clamp(17px, 1.7vw, 42px); line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
  .rail .rt span { font-size: clamp(13px, 0.85vw, 20px); line-height: 1.3; opacity: 0.9; max-width: 28ch; }
  /* The page you are on: a band of the page colour on the tab's inner edge, as if the tab
     is joined to the sheet. It does not move, so it never reads as a second hovered tab. */
  .rail .rt[aria-current="page"] { box-shadow: inset clamp(8px, 0.7vw, 14px) 0 0 var(--bg); padding-left: calc(clamp(14px, 1.4vw, 30px) + clamp(8px, 0.7vw, 14px)); }
  .rail .rt:active { transform: translateX(-6px); }
  @media (hover: hover) and (pointer: fine) {
    .rail .rt:hover { transform: translateX(-12px); }
  }
  /* Small world marks: calm line drawings (Studio: a small still). Only on tall, wide screens. */
  .rail .gl { display: none; }
  @media (min-width: 1280px) and (min-height: 760px) {
    .rail .gl { display: block; position: absolute; right: clamp(16px, 1.4vw, 32px); bottom: clamp(10px, 1.2vh, 20px); width: clamp(44px, 3.4vw, 92px); height: auto; opacity: 0.55; pointer-events: none; }
    .rail .gl * { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; }
    .rail .gl .f { fill: currentColor; stroke: none; }
    .rail .rt span { padding-right: clamp(48px, 3.8vw, 100px); }
    .rail .rt img.gl { opacity: 1; width: clamp(56px, 4.6vw, 120px); aspect-ratio: 16 / 9; object-fit: cover; padding: 3px; background: #F7F7F4; transform: rotate(-2deg); }
    .rail .rt:has(img.gl) span { padding-right: clamp(60px, 5vw, 128px); }
  }
  /* Short screens (a phone held sideways): labels only */
  @media (max-height: 560px) {
    .rail .mark { height: 52px; font-size: 16px; }
    .rail .rt span, .rail li.also { display: none; }
    .rail .rt b { font-size: 15px; }
    .rail ol { gap: 3px; padding-bottom: 6px; }
  }
}
.rail .rt[data-w="work"]    { --c: var(--c-work);    --k: #fff; }
.rail .rt[data-w="consult"] { --c: var(--c-consult); --k: #fff; }
.rail .rt[data-w="lab"]     { --c: var(--c-lab);     --k: var(--ink); }
.rail .rt[data-w="studio"]  { --c: var(--c-studio);  --k: #fff; }
.rail .rt[data-w="games"]   { --c: var(--c-games);   --k: var(--ink); }

/* Phone: the five tabs are a bar at the foot of the screen, each at least 48 px.
   No hover styles here, so a tap never leaves a tab lit. */
.dock { display: none; }
@media (max-width: 760px) {
  :root { --nav-h: 52px; }
  .dock {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) repeat(2, minmax(0, 1.4fr)); gap: 3px;
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    padding: 4px 6px env(safe-area-inset-bottom);
    background: var(--bg); border-top: 1px solid var(--line);
    list-style: none;
  }
  .dock a {
    --t: var(--ink);
    position: relative; display: flex; align-items: center; justify-content: center; text-align: center;
    height: 56px; min-width: 0; padding: 6px 2px 0;
    font-size: 13px; line-height: 1.1; font-weight: 600;
    font-variation-settings: "MONO" 0, "CASL" 0, "slnt" 0, "CRSV" 0.5;
    text-decoration: none; color: var(--fg);
    background: color-mix(in srgb, var(--fg) 6%, transparent);
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%);
    -webkit-tap-highlight-color: transparent;
  }
  .dock a::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--t); }
  .dock a[data-w="work"] { --t: var(--c-work); } .dock a[data-w="consult"] { --t: var(--c-consult); }
  .dock a[data-w="lab"] { --t: var(--c-lab); } .dock a[data-w="studio"] { --t: var(--c-studio); } .dock a[data-w="games"] { --t: var(--c-games); }
  .dock a[aria-current="page"] { background: var(--t); color: var(--k, #fff); }
  .dock a[data-w="lab"][aria-current="page"], .dock a[data-w="games"][aria-current="page"] { --k: var(--ink); }
  body.has-rail { padding-bottom: 68px; }
}
/* Phone top bar: the name mark (the rail holds it on larger screens) */
.pbar { display: none; }
@media (max-width: 760px) {
  .pbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; padding-inline: 20px; }
}

/* Main action: the chamfer button */
.act {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px 0 22px;
  background: var(--w); color: var(--w-ink);
  font-weight: 640; font-size: 16px; text-decoration: none; white-space: nowrap;
  border: 0; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - var(--chamfer)) 0, 100% var(--chamfer), 100% 100%, 0 100%);
  transition: transform 160ms var(--ease-out);
}
.act:active { transform: scale(0.97); }
.link {
  display: inline-flex; align-items: center; min-height: 48px;
  font-weight: 560; text-decoration: underline; text-decoration-thickness: 2px;
  text-underline-offset: 5px; text-decoration-color: var(--w);
}

.link .todo { margin-left: 8px; text-decoration: none; }


/* v4: fact slot. A place for a career fact that David still has to send (his CV).
   It must look planned, not broken: a quiet proof mark with a bar in the world colour.
   It is never an invented claim. */
.fact-slot {
  font-variation-settings: "MONO" 1, "CASL" 0, "slnt" 0, "CRSV" 0.5;
  font-size: 0.8em; font-weight: 500; font-style: normal; letter-spacing: 0;
  color: color-mix(in srgb, var(--fg) 78%, transparent);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  border-left: 3px solid var(--w);
  padding: 0.12em 0.45em 0.12em 0.5em;
  display: inline-block; max-width: 100%;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
/* Big type keeps its size; the slot only marks it */
h1 .fact-slot, h2 .fact-slot, b .fact-slot, dd .fact-slot { font-size: 0.9em; font-weight: inherit; }

/* World transition (idea, shown in THEME.md): the clicked tab's colour slab grows from the
   tab's own box to the full screen (clip-path), then the world paints. Back = the reverse. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}

/* Coming soon (UNLOCK.md): a locked world stays visible but is not a link. No hover, no pull, default cursor. */
.rail .rt.soon, .rail .rt.soon:hover, .rail .rt.soon:active { cursor: default; transform: none; background: #DEE0DB; color: var(--ink); box-shadow: inset 6px 0 0 var(--c); }
.rail .rt.soon .cs { opacity: 1; font-weight: 600; color: var(--ink); }
.rail .rt.soon b { color: var(--graphite); }
.rail .rt.soon .gl { opacity: 0.35; filter: grayscale(1); }
.soon-note { display: inline-block; font-weight: 700; font-size: 0.95em; color: var(--ink); cursor: default; border-bottom: 2px dotted var(--graphite); }
@media (max-width: 760px) {
  .dock .soon { font-variation-settings: "MONO" 0, "CASL" 0, "slnt" 0, "CRSV" 0.5; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; height: 56px; min-width: 0; padding: 6px 2px 0; font-size: 13px; line-height: 1.1; font-weight: 600; cursor: default; color: var(--graphite); background: #DEE0DB; clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 0 100%); }
  .dock .soon::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--graphite); opacity: 0.5; }
  .dock .soon i { font-style: normal; font-size: 12px; line-height: 1.1; font-weight: 600; color: var(--ink); margin-top: 3px; white-space: nowrap; }
}

/* AC-36: designed hover and keyboard focus.
   Chamfered shapes (clip-path) cut an outside outline, so they show an inset ring in their own colours. */
@media (hover: hover) and (pointer: fine) {
  .act { transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out); }
  .act:hover { box-shadow: inset 0 0 0 100px rgb(255 255 255 / 0.12), inset 0 -4px 0 rgb(0 0 0 / 0.25); }
  .link { transition: text-underline-offset 160ms var(--ease-out), text-decoration-thickness 160ms var(--ease-out); }
  .link:hover { text-decoration-thickness: 4px; text-underline-offset: 7px; }
}
.act:focus-visible { outline: 2px solid currentColor; outline-offset: -6px; }
.rail .rt:focus-visible { outline: none; box-shadow: inset 0 0 0 4px var(--k); }
.rail .rt[aria-current="page"]:focus-visible { box-shadow: inset clamp(8px, 0.7vw, 14px) 0 0 var(--bg), inset 0 0 0 4px var(--k); }
.rail .mark:focus-visible { outline-offset: -4px; }
@media (max-width: 349px) { .dock .soon i { font-size: 11px; } }
