/* 3d-work-consoleui.css: ConsoleUI case page.
   Layout: on wide screens the hero and the reading column sit left, and a sticky stage on the right carries the slab of
   character cells (drawn in the canvas, placed by this slot). Below 1180px the stage is a block above the text.
   Phosphor / cell-grid language on the page: mono numbers, hairline rules at cell pitch, graphite + lime. */

.case-pin { position: relative; }

/* ------------------------------------------------------------------ the stage slot (canvas draws behind it) */

.cell-rail { position: relative; pointer-events: none; }
.cell-stage {
  position: relative;
  width: 100%;
  height: min(60vw, 420px);
  display: grid; place-items: center;
}
/* the flat fallback: a window made of CSS, ASCII inside so every glyph is in the mono face */
.cell-fallback {
  display: none; margin: 0; position: relative;
  font: 500 clamp(13px, 1.5vw, 18px)/1.7 var(--font-mono); color: var(--accent-2); letter-spacing: 0; white-space: pre;
  font-variant-ligatures: none;
  padding: 26px 28px 20px; border: 1px solid rgba(var(--accent-rgb), 0.38); border-radius: 4px;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.05), rgba(var(--bg-rgb), 0.4));
  width: fit-content; max-width: 100%; margin-inline: auto;
}
.cell-fallback::before {                           /* the title sits on the border, as in the library */
  content: attr(data-title); position: absolute; left: 18px; top: -0.85em; padding: 0 8px;
  background: var(--bg); color: var(--ink); letter-spacing: 0.04em;
}
html:not(.gl) .cell-fallback { display: block; }
html.gl-lost .cell-fallback { display: block; }

/* ------------------------------------------------------------------ hero */

.case-hero { position: relative; }
.case-hero .kicker { display: flex; align-items: center; gap: 12px; }
.case-hero .kicker::after { content: ""; width: 56px; height: 1px; background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.7), transparent); }
.case-hero h1 { max-width: none; font-size: clamp(56px, 8.4vw, 136px); line-height: 0.88; margin: 6px 0 22px; }
.case-hero .lede { font-size: clamp(16px, 1.45vw, 19px); line-height: 1.55; color: var(--ink-dim); max-width: 600px; }

/* facts: a spec strip, numbers in mono, one hairline per column, counted up by the page script.
   Bone numerals with a lime tick: the lime stays for the slab */
.facts {
  display: grid; grid-template-columns: repeat(5, minmax(0, auto)); justify-content: start; gap: 0;
  margin: 34px 0 0; padding: 0;
  border-block: 1px solid var(--line-strong);
}
.facts div {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 18px 28px 16px 0; margin-right: 26px;
  border-right: 1px solid var(--line-strong);
  position: relative;
}
.facts div:last-child { border-right: 0; margin-right: 0; padding-right: 0; }
.facts div::before {
  content: ""; position: absolute; left: 0; top: -1px; width: 22px; height: 1px; background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6);
}
.facts dt { font-family: var(--font-mono); font-weight: 500; font-size: clamp(30px, 3.1vw, 42px); line-height: 1; color: var(--ink); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.facts dd { margin: 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }

/* ------------------------------------------------------------------ the sequence: chain, read, stage */

.case-read { margin-top: 40px; }
.chain { gap: 0; }
.chain::before {                                   /* the spine */
  content: ""; position: absolute; left: 7px; top: 14px; bottom: 14px; width: 1px;
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.5), var(--line-strong) 30%, var(--line-strong));
}
.chain li {
  position: relative;
  padding: 14px 8px 15px 34px;
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  color: var(--ink-faint);
}
.chain li::before {                                /* the cell on the spine */
  content: ""; position: absolute; left: 3px; top: 20px; width: 9px; height: 9px;
  border: 1px solid rgba(var(--ink-rgb), 0.3); background: var(--bg); border-radius: 2px;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease), box-shadow 0.5s var(--ease), transform 0.5s var(--ease);
}
.chain li i { color: var(--ink-faint); }
.chain li b { font-size: 17px; letter-spacing: -0.025em; transition: color 0.4s var(--ease); }
.chain li span { max-width: 28ch; transition: color 0.4s var(--ease); }
.chain li.is-on { border: 0; background: transparent; box-shadow: none; color: var(--ink-dim); }
.chain li.is-on b { color: var(--ink); }
.chain li.is-on::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.55); }
.chain li.is-on i { color: var(--accent); }
.chain li.is-on:has(+ li:not(.is-on)), .chain li.is-on:last-child { color: var(--ink); }
.chain li.is-on:has(+ li:not(.is-on))::before, .chain li.is-on:last-child::before { transform: scale(1.35); }
.chain li.is-on:has(+ li:not(.is-on)) b::after, .chain li.is-on:last-child b::after {   /* the cursor of the step being drawn */
  content: ""; display: inline-block; width: 0.55em; height: 0.95em; margin-left: 8px; vertical-align: -0.12em; background: var(--accent);
  animation: caret 1.05s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
html[data-calm] .chain li.is-on b::after { animation-duration: 2.2s; }

.read-line { font-size: 19px; line-height: 1.55; }
.case-read .read-line::first-letter { color: var(--paper); }

@media (min-width: 1180px) {
  .case.wrap { width: min(1320px, calc(100% - 56px)); }
  .case-pin > .cell-rail { position: absolute; top: 0; bottom: 0; right: 0; width: 47%; }
  .cell-stage { position: sticky; top: calc(var(--header) + 14px); height: calc(100vh - var(--header) - 40px); height: calc(100svh - var(--header) - 40px); max-height: 820px; }
  /* text columns stop short of the bezel: about 6% of air between them */
  .case-pin > .case-hero { width: 46%; min-height: calc(100svh - var(--header) - 90px); display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding-bottom: 36px; }
  .case-pin > .case-hero .facts { align-self: flex-start; max-width: calc(100% - 20px); }
  .case-pin > .case-read { width: 46%; grid-template-columns: clamp(196px, 17vw, 236px) minmax(0, 1fr); gap: clamp(22px, 2.4vw, 34px); margin-top: 6vh; padding-bottom: 30vh; }
  .case-pin .chain { top: max(calc(var(--header) + 22px), 17vh); }
  .case-pin .read-line { margin-bottom: min(36vh, 320px); max-width: 44ch; font-size: clamp(17px, 1.4vw, 19px); }
  .case-pin .read-line:last-child { margin-bottom: 0; }
  .case-pin > .case-read .read { padding-top: 6vh; }
}
@media (min-width: 1180px) and (max-width: 1359px) {
  .facts div { padding: 16px 16px 14px 0; margin-right: 14px; }
  .facts dt { font-size: 30px; }
  .facts dd { font-size: 10px; letter-spacing: 0.1em; }
}
@media (min-width: 1700px) {                       /* large screens: a wider room, the slab bleeds toward the edge */
  .case.wrap { width: min(1560px, calc(100% - 120px)); }
  .case-pin > .cell-rail { width: 50%; }
  .case-pin > .case-hero, .case-pin > .case-read { width: 45%; }
}

/* ------------------------------------------------------------------ the code box: a window made of cells */

.codebox {
  --cw: 9px; --ch: 18px;
  position: relative;
  margin: 18px 0 70px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.035), transparent 40%),
    repeating-linear-gradient(90deg, transparent 0 calc(var(--cw) - 1px), rgba(var(--ink-rgb), 0.028) calc(var(--cw) - 1px) var(--cw)),
    repeating-linear-gradient(0deg, transparent 0 calc(var(--ch) - 1px), rgba(var(--ink-rgb), 0.028) calc(var(--ch) - 1px) var(--ch)),
    #0a0c0a;                                       /* opaque: nothing of the canvas shows through */
  box-shadow: 0 50px 90px -40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0, 0, 0, 0.4);
  max-width: 880px;
  overflow: visible;
}
.codebox::before, .codebox::after {                /* corner brackets, the cell-grid mark */
  content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none;
  border: 1px solid var(--accent);
}
.codebox::before { left: -5px; top: -5px; border-right: 0; border-bottom: 0; }
.codebox::after { right: -5px; bottom: -5px; border-left: 0; border-top: 0; }
.codebar {
  background: rgba(var(--ink-rgb), 0.035); color: var(--ink-faint);
  border-radius: 5px 5px 0 0;
  padding: 11px 18px; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  position: relative;
}
.codebar span:first-child { color: var(--ink); display: flex; align-items: center; gap: 10px; }
.codebar span:first-child::before { content: ""; width: 7px; height: 7px; border-radius: 1px; background: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.7); }
.codebox pre {
  counter-reset: ln;
  padding: 22px 22px 24px 0; font-size: 14.5px; line-height: 1.7; tab-size: 4;
  background: transparent; color: #d9d6c8; overflow-x: auto;
}
.codebox .ln { display: block; padding-left: 62px; position: relative; white-space: pre; counter-increment: ln; min-height: 1.7em; }
.codebox .ln::before {
  content: counter(ln) / ""; position: absolute; left: 0; width: 44px; text-align: right; color: var(--ink-faint); opacity: 0.55;
  font-variant-numeric: tabular-nums;
}
.codebox .ln:hover { background: rgba(var(--accent-rgb), 0.045); }
.codebox .ln:hover::before { color: var(--accent); opacity: 1; }
.tk-k { color: var(--accent); } .tk-s { color: #e6c07b; } .tk-f { color: #7fd0ff; }
html.js-3d:not(.reveal-off) .codebox:not(.is-in) .ln { opacity: 0; transform: translateX(-10px); }
html.js-3d .codebox .ln { transition: opacity 0.7s var(--ease) calc(var(--i, 0) * 70ms + 0.2s), transform 0.9s var(--ease) calc(var(--i, 0) * 70ms + 0.2s), background 0.25s; }
html[data-calm] .codebox .ln { transition-delay: 0s; }

/* ------------------------------------------------------------------ shots: a line of text and a frame, side by side, alternating */

.shot-pair { margin: 0 0 clamp(40px, 7vh, 84px); }
.shot-pair > .read-line { margin: 0 0 18px; }
.shot-pair > .case-shot { margin: 0; }
.case-shot figcaption { font-size: 12px; letter-spacing: 0.04em; }
/* the enlarge hint lives in the caption row: it never covers a piece of the picture and does not scroll away with a swipe */
.case-shot .shot-frame::after { display: none; }
.case-shot figcaption::after {
  content: "Click to enlarge" / ""; float: right; margin: 1px 0 0 18px;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); white-space: nowrap;
  opacity: 0; transform: translateX(-4px); transition: opacity 0.3s, transform 0.4s var(--ease);
}
.case-shot:hover figcaption::after, .case-shot:focus-within figcaption::after { opacity: 0.9; transform: none; }
@media (hover: none) { .case-shot figcaption::after { content: "Tap to enlarge" / ""; opacity: 0.7; transform: none; } }
@media (hover: none) and (max-width: 800px) {   /* on a phone the frame is wider than the screen: say so */
  .case-shot figcaption::after { content: "Swipe to pan · tap to enlarge" / ""; float: none; display: block; margin: 8px 0 0; }
}
html.lb-open .cursor[data-mode="view"]::after { content: "Close"; }     /* the ring says what a click does now */

@media (min-width: 1180px) {
  .case { --shotw: min(70%, calc((100vh - var(--header) - 130px) * 1.316)); --shotw: min(70%, calc((100svh - var(--header) - 130px) * 1.316)); }
  .shot-pair { display: grid; grid-template-columns: minmax(0, 1fr) var(--shotw); column-gap: clamp(32px, 4vw, 64px); align-items: center; }
  .shot-pair.is-flip { grid-template-columns: var(--shotw) minmax(0, 1fr); }
  .shot-pair > .read-line { margin: 0; max-width: 28ch; }
  .shot-pair.is-flip > .read-line { grid-column: 2; grid-row: 1; justify-self: end; }
  .shot-pair.is-flip > .case-shot { grid-column: 1; grid-row: 1; }
  /* the themes block: the line, the wall, then one frame, parked to the left (the sides alternate all the way down) */
  #themes-line { max-width: 46ch; }
  #themes-line ~ .case-shot { width: var(--shotw); }
}

.case-shot[data-gallery] { scroll-margin-top: calc(var(--header) + 14px); }     /* a wall tile scrolls its frame to here */
.gal-tabs {
  background: transparent; border-bottom: 0; padding: 0 0 14px; gap: 8px;
}
.chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px; border-radius: 999px;
  background: rgba(var(--bg-rgb), 0.7);
  font-size: 13px;
}
.chip[data-src^="theme-"] { padding-left: 11px; }
.chip[data-src^="theme-"]::before {                /* the palette of the theme: panel, accent */
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sw-a, #222) 0 50%, var(--sw-b, #888) 50% 100%);
  box-shadow: 0 0 0 1px rgba(var(--ink-rgb), 0.25), inset 0 0 0 2px var(--sw-c, #000);
  flex: none;
}
.chip[aria-selected="true"] { box-shadow: 0 0 22px -4px rgba(var(--accent-rgb), 0.6); }
.chip[aria-selected="true"][data-src^="theme-"]::before { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 2px var(--sw-c, #000); }

/* ------------------------------------------------------------------ theme wall (canvas draws the planes) */

.theme-wall {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 30px 20px;
  margin: 18px 0 34px; padding: 22px 6px 14px;
}
.theme-wall .tile {
  position: relative; display: block; padding: 0; text-align: left; cursor: pointer;
  border-radius: 8px; outline-offset: 6px;
}
.theme-wall .tile:nth-child(5n + 2), .theme-wall .tile:nth-child(5n + 4) { margin-top: 20px; }
.theme-wall .tile img { width: 100%; height: auto; aspect-ratio: 900 / 684; }
.theme-wall .tile-name {
  display: block; margin-top: 10px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint);
  transition: color 0.3s;
}
.theme-wall .tile:hover .tile-name { color: var(--accent); }
html:not(.gl) .theme-wall, html.gl-lost .theme-wall { display: none; }      /* the chips carry the same choice */

/* ------------------------------------------------------------------ the aside: forty-two widgets */

.case-aside { position: relative; }
.case-aside > .cell-rail { position: relative; margin-bottom: 26px; }
.case-aside h2 { max-width: 14ch; }
.case-aside .read-line { max-width: 46ch; }
@media (min-width: 1180px) {
  .case-aside { padding-bottom: 10vh; }
  .case-aside > .cell-rail { position: absolute; top: 36px; bottom: 0; right: 0; width: 46%; margin: 0; }
  .case-aside > .cell-rail .cell-stage { top: calc(var(--header) + 14px); }
  .case-aside > .kicker, .case-aside > h2, .case-aside > .read { width: 46%; }
  .case-aside .read-line { margin-bottom: 8vh; }
  .case-aside .read-line:last-child { margin-bottom: 0; }
}
@media (min-width: 1700px) {
  .case-aside > .cell-rail { width: 50%; }
  .case-aside > .kicker, .case-aside > h2, .case-aside > .read { width: 45%; }
}

/* ------------------------------------------------------------------ narrow screens */

@media (max-width: 1179px) {
  .case-pin > .cell-rail { margin: 0 -6px 4px; }
  .cell-stage { height: min(74vw, 460px, calc(100svh - var(--header) - 60px)); }
  .case-hero h1 { font-size: clamp(54px, 15vw, 104px); }
  .case-aside > .cell-rail .cell-stage { height: min(74vw, 460px, calc(100svh - var(--header) - 60px)); }
}
@media (max-height: 500px) { :root { --header: 56px; } }     /* a phone on its side */
@media (max-width: 800px) {
  .chain { position: relative; top: 0; }
  .facts { grid-template-columns: repeat(3, minmax(0, auto)); background: linear-gradient(var(--line-strong), var(--line-strong)) 0 50% / 100% 1px no-repeat; }
  .facts div { padding: 14px 18px 12px 0; margin-right: 18px; }
  .facts div:nth-child(3) { border-right: 0; margin-right: 0; }
  .facts div:nth-child(4) { grid-column: 1; }
  .case-read { margin-top: 28px; }
  .chain li { padding-left: 30px; }
  .chain li span { max-width: none; }
  .codebox { margin: 14px 0 54px; }
  .codebox pre { font-size: 12.5px; }
  .codebox .ln { padding-left: 46px; }
  .codebox .ln::before { width: 30px; }
  .theme-wall { gap: 16px 8px; padding: 16px 0 6px; }
  .theme-wall .tile:nth-child(5n + 2), .theme-wall .tile:nth-child(5n + 4) { margin-top: 10px; }
  .theme-wall .tile-name { display: none; }
  .gal-tabs { padding-bottom: 12px; }
  .shot-pair { margin-bottom: 8px; }
  /* small mono type reads better a size up on a phone */
  .chain li i, .facts dd, .kicker, .back, .codebar, .site-footer { font-size: 12px; }
  .case-shot figcaption { font-size: 13px; }
}

/* ------------------------------------------------------------------ touch: targets of at least 44px, without changing the look */

.back { padding: 6px 0; }
@media (pointer: coarse) {
  .back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px; padding: 0; }
  .chip { min-height: 44px; }
  .site-footer a { display: inline-block; padding: 14px 6px; margin: -14px -6px; }
  .menu-btn { min-height: 44px; min-width: 48px; }
  .calm-toggle { position: relative; }
  .calm-toggle::before { content: ""; position: absolute; inset: -7px 0; }
}
@media (max-width: 640px) and (min-width: 360px) {
  .calm-toggle .calm-label { display: inline; }     /* a bare circle with a dash does not say "motion" */
}

/* ------------------------------------------------------------------ shared-chrome tweaks that belong in 3d.css (kept here so this page ships them now) */

/* the page is black until the stage has warmed up: say something */
html.js-3d::before {
  content: "CSG"; position: fixed; inset: 0; z-index: 401; display: grid; place-items: center; pointer-events: none;
  font: 500 12px var(--font-mono); letter-spacing: 0.34em; text-indent: 0.34em; color: var(--accent);
  opacity: 0; transition: opacity 0.35s;
}
html.js-3d:not(.is-ready):not(.reveal-off)::before { opacity: 1; animation: boot-pulse 1.6s ease-in-out infinite; }
@keyframes boot-pulse { 0%, 100% { color: rgba(var(--accent-rgb), 0.35); } 50% { color: var(--accent); } }

/* OS reduced motion gets the same calm CSS as the Calm toggle */
@media (prefers-reduced-motion: reduce) {
  .chain li.is-on:has(+ li:not(.is-on)) b::after, .chain li.is-on:last-child b::after { animation-duration: 2.2s; }
  html.js-3d .codebox .ln { transition-delay: 0s; }
  .status-pill i { animation-duration: 6s; }
  html.js-3d :is([data-reveal], .sec-label, .prose p, .lede, .read-line, .card, .work-row, .badge, .case-shot):not(.is-in) { translate: 0 10px !important; }
  html.js-3d::before { animation: none; }
}

/* ------------------------------------------------------------------ no WebGL: flat but finished */

html.no-webgl .cell-rail { margin-bottom: 8px; }
html.no-webgl .cell-rail--b, html.gl-lost .cell-rail--b { display: none; }     /* the second stage has nothing to show without the canvas */
html.no-webgl .cell-stage { height: auto; }
@media (min-width: 1180px) {
  html.no-webgl .case-pin > .cell-rail { position: absolute; }
  html.no-webgl .cell-stage { position: sticky; height: auto; display: block; padding-top: 12vh; }
}
html.no-webgl .cell-fallback { display: block; }
