/* Chrome for the lab itself. Deliberately neutral and quiet: every specimen
   inside it is loud and opinionated, and the frame must not compete with them.
   No specimen loads this file — it only styles the index and the caption strips. */

:root {
  --ink:        #0a0b0d;
  --ink-raised: #101215;
  --line:       #1e2229;
  --line-bright:#2c323b;
  --text:       #c3c8d1;
  --text-dim:   #8d96a3;
  --text-faint: #6b7480;
  --accent:     #7dd3c0;
  --accent-dim: #2f6055;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --strand-tui:     #7dd3c0;
  --strand-hud:     #e0736d;
  --strand-cyber:   #f2e14c;
  --strand-minimal: #8b93a1;
  --strand-motion:  #b58cd6;
  --strand-react:   #6aa9ff;
  --strand-era:     #d8b46a;
  --strand-input:   #e0a86a;
  --strand-data:    #6ad8c4;
  --strand-type:    #c9a0e0;
  --strand-composite: #e58fb8;
}

* { box-sizing: border-box; }

body.lab {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 13px/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration-color: var(--accent-dim); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

.wrap { max-width: 1560px; margin: 0 auto; padding: 0 28px 96px; }

/* ---------------------------------------------------------------- masthead */
.masthead { padding: 56px 0 32px; border-bottom: 1px solid var(--line); margin-bottom: 34px; }
.masthead h1 {
  margin: 0 0 14px; font-size: 26px; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: #e8ecf2;
}
.masthead h1 span { color: var(--accent); }
.masthead p { margin: 0; max-width: 78ch; color: var(--text-dim); }
.masthead .meta { margin-top: 18px; color: var(--text-faint); font-size: 11px; letter-spacing: .1em; }

/* ------------------------------------------------------------------ filters */
.filters { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; margin-bottom: 34px; }
/* Beats `.filters`'s own display:flex, which a bare [hidden] would not. */
.filters[hidden] { display: none; }

/* Not rendered above the breakpoint: the panel is only collapsible where it
   needs to be, so a desktop reader never meets a control that does nothing. */
.filters-toggle { display: none; }
.filter-group { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.filter-group > .lbl {
  color: var(--text-faint); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; margin-right: 4px;
}
.chip {
  appearance: none; cursor: pointer; font: inherit; font-size: 11px;
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 2px; padding: 4px 11px;
  transition: color .12s, border-color .12s, background .12s;
}
.chip:hover { color: var(--text); border-color: var(--line-bright); }
.chip[aria-pressed="true"] { color: var(--ink); background: var(--accent); border-color: var(--accent); }

/* -------------------------------------------------------------------- grid */
.strand-head {
  display: flex; align-items: baseline; gap: 14px;
  margin: 46px 0 4px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
}
.strand-head h2 {
  margin: 0; font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--sc, var(--text));
}
.strand-head .blurb { color: var(--text-faint); font-size: 11px; }
.strand-head .count { margin-left: auto; color: var(--text-faint); font-size: 11px; }

/* `minmax(430px, 1fr)` is a HARD 430px minimum, so on any viewport narrower
   than that plus the wrap's padding the track is wider than its container and
   every card overflows the right edge — the left inset stays, the right one
   does not, which is exactly what it looks like on a phone.

   The tidy fix is `minmax(min(430px, 100%), 1fr)`, and it works in Chrome and
   did NOT fix it in mobile Safari: `min()` inside a `minmax()` track inside
   `repeat()` is the one place Safari's grid sizing has never been reliable. So
   the breakpoint below does it with a plain single-column rule instead, which
   has no such corner. */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
        gap: 22px; margin-top: 22px; }

.card {
  border: 1px solid var(--line); border-radius: 3px; overflow: hidden;
  background: var(--ink-raised); display: flex; flex-direction: column;
  transition: border-color .15s;
}
.card:hover { border-color: var(--line-bright); }
.card.is-hidden { display: none; }

.card .stage { position: relative; aspect-ratio: 16 / 10; background: #000; border-bottom: 1px solid var(--line); }
.card .stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }

/* SCALED PREVIEWS. Every specimen is a desktop layout, so in a card narrower
   than it expects it does not reflow, it CROPS -- the first card's terminal
   reads "ernel / ptime / ink" with both edges cut off, which is worse than
   small. So on a phone the iframe is laid out at a real desktop width and the
   whole thing is scaled down to fit, which is a thumbnail of the specimen
   rather than a slice of it. `--pv-w` is the layout width and `--pv-s` the
   factor; index.html measures the card and sets the factor. */
.card .stage[data-scaled] { overflow: hidden; }
.card .stage[data-scaled] iframe {
  inset: auto; top: 0; left: 0;
  width: var(--pv-w, 900px);
  height: calc(var(--pv-w, 900px) * 10 / 16);
  transform: scale(var(--pv-s, 1));
  transform-origin: top left;
}

/* Placeholder until the card scrolls into view. Every live specimen at once
   would blow past the browser's WebGL context limit, so iframes mount lazily. */
.card .stage .idle {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 8px;
  color: var(--text-faint); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
}
.card .stage .idle::after {
  content: ''; display: block; height: 1px; background: var(--line-bright);
  animation: idle-sweep 1.6s ease-in-out infinite;
}
@keyframes idle-sweep { 0%, 100% { transform: scaleX(.2); opacity: .35; } 50% { transform: scaleX(1); opacity: 1; } }

.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card .titles { display: flex; align-items: baseline; gap: 10px; }
.card .titles h3 { margin: 0; font-size: 14px; font-weight: 600; color: #e8ecf2; }
.card .titles .num { color: var(--text-faint); font-size: 11px; }
.card .proj { color: var(--sc, var(--accent)); font-size: 11px; }
.card .proj .ver { color: var(--text-faint); }
.card .what { margin: 0; color: var(--text-dim); font-size: 12px; }
.card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 4px; }

.tag {
  font-size: 10px; letter-spacing: .06em; padding: 2px 7px; border-radius: 2px;
  border: 1px solid var(--line-bright); color: var(--text-dim); white-space: nowrap;
}
.tag.motion { border-color: var(--accent-dim); color: var(--accent); }

.card .links { display: flex; gap: 14px; font-size: 11px; padding-top: 2px; }
.card .links .open { margin-left: auto; }

/* The specimen caption strip lives in lab/bar.css -- it must not share this
   file, whose generic class names would leak into specimen pages. */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------------------ footer */
/* A rule and faint type, the same two devices the masthead uses. The credits
   link is the reason this exists: the attribution has to be reachable from the
   published site, not only from a repo that stays private. */
.lab-foot {
  margin-top: 64px; padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--text-faint); font-size: 11px; letter-spacing: .08em;
}
.lab-foot p { margin: 0 0 6px; }
.lab-foot code { color: var(--text-dim); }

/* --- narrow screens ---------------------------------------------------------
   The contact sheet had no width breakpoint at all. 28px of side padding is a
   sixth of a phone's width, and the masthead's 56px top rule pushes the first
   specimen off the first screen. */
@media (max-width: 640px) {
  .wrap { padding: 0 20px 96px; }
  .masthead { padding: 34px 0 22px; margin-bottom: 24px; }
  /* One column, stated outright. See above: this is the rule that actually
     holds in Safari. */
  .grid { grid-template-columns: 1fr; gap: 16px; }

  /* Eleven strands and twenty-two motion techniques is about two screens
     between the masthead and the first specimen. */
  .filters-toggle {
    display: flex; width: 100%; align-items: center; gap: 10px;
    appearance: none; cursor: pointer; font: inherit; font-size: 11px;
    letter-spacing: .16em; text-transform: uppercase;
    background: transparent; color: var(--text-dim);
    border: 1px solid var(--line); border-radius: 2px;
    padding: 11px 13px; margin-bottom: 20px;
  }
  .filters-toggle:hover { color: var(--text); border-color: var(--line-bright); }
  .filters-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .filters-toggle .caret { transition: transform .15s ease; font-size: 14px; line-height: 1; }
  .filters-toggle[aria-expanded="true"] .caret { transform: rotate(90deg); }
  .filters-toggle .state {
    margin-left: auto; text-transform: none; letter-spacing: 0;
    color: var(--text-faint); text-align: right; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .filters-toggle .state[data-on="yes"] { color: var(--accent); }

  .filters { flex-direction: column; gap: 14px; margin-bottom: 24px; }
  .card { min-width: 0; }
  /* Left at 16/10, matching the scaled iframe's own height. A 4/3 stage here
     leaves a black band under every preview, because the iframe is laid out at
     PV_W by PV_W*10/16 and then scaled -- the box and its contents have to
     agree on a ratio or one of them pads. */
}

/* --- scrollbars ------------------------------------------------------------
   The index, the contact sheet and the five measurement pages. Same treatment
   as lab/bar.css gives the specimens, keyed to this file's own tokens; no
   opt-out guard is needed because nothing here loads a vendored era sheet.
   The card previews are iframes, and an iframe scrolls in its own document, so
   these rules stop at the frame boundary by construction -- each specimen
   brings its own from bar.css. */
:root { scrollbar-width: thin; scrollbar-color: var(--line-bright) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-bright); background-clip: padding-box;
  border: 2px solid transparent; border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: #414b59; background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
