/* Tools · The Workshop. Workshop tokens come from thread.css (body[data-material="workshop"]).
   Station tints color icons, machine graphics, and the bleed only; text stays on ink, muted, and copper. */

/* Color bleed: the station in view (or under a fine pointer) eases its tint into the floor, 10% mix, 600 ms. */
@property --bleed { syntax: '<color>'; inherits: true; initial-value: #17140f; }
@supports (background: color-mix(in oklab, red 50%, blue)) {
  body[data-material="workshop"] { background: color-mix(in oklab, #17140f 90%, var(--bleed)); transition: --bleed .6s ease; }
}
body[data-station="gold"] { --bleed: #f0d3a8; }
body[data-station="ember"] { --bleed: #c9714a; }
body[data-station="copper"] { --bleed: #dda884; }
body[data-station="sage"] { --bleed: #9fb89a; }
html[data-still] body[data-material="workshop"] { transition: none; }

.ws-kicker { margin: 0; font: 11px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }

/* 0 · The bench */
.bench { position: relative; display: grid; align-content: end; gap: 20px; min-height: 78svh; padding: clamp(48px, 8vw, 120px) var(--pad) 0; }
.crumbs { display: flex; gap: 8px; font: 11px/1.5 var(--mono); letter-spacing: .08em; color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.bench-title { max-width: 15ch; font: 400 clamp(60px, 8.4vw, 132px)/.92 var(--serif); letter-spacing: -.02em; }
.bench-title em { font-style: italic; color: var(--accent); }
.bench-dek { max-width: 54ch; font-size: clamp(17px, 1.4vw, 20px); color: var(--muted); }
.bench-hl { color: var(--ink); }
.bench-machines { display: flex; align-items: flex-end; gap: clamp(20px, 5vw, 72px); margin-top: clamp(24px, 4vw, 56px); }
.bench-machines svg { width: clamp(44px, 6vw, 72px); height: auto; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.bench-machines svg:nth-child(1) { color: #f0d3a8; }
.bench-machines svg:nth-child(2) { color: #c9714a; }
.bench-machines svg:nth-child(3) { color: #dda884; }
.bench-machines svg:nth-child(4) { color: #9fb89a; }
.bench .thread-horizon { margin: 0 calc(-1 * var(--pad)); }

/* 1-4 · Stations. Phones: stacked cards, machine above the items. Desktop: the machine pins while the text passes. */
.station { --tint: #dda884; display: grid; gap: clamp(28px, 4vw, 44px); padding: clamp(64px, 9vw, 140px) var(--pad); border-top: 1px solid var(--line); }
.station[data-station="gold"] { --tint: #f0d3a8; }
.station[data-station="ember"] { --tint: #c9714a; }
.station[data-station="sage"] { --tint: #9fb89a; }
.station-head { display: grid; justify-items: start; gap: 16px; max-width: 56ch; }
.station-head h2 { font: 400 clamp(36px, 4.4vw, 64px)/1.02 var(--serif); letter-spacing: -.02em; }
.station-lead { color: var(--muted); line-height: 1.7; }
.station-body { display: grid; gap: clamp(28px, 4vw, 44px); min-width: 0; }
@media (min-width: 900px) {
  .station { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "head machine" "body machine"; column-gap: clamp(40px, 6vw, 96px); align-items: start; min-height: 170vh; }
  .station:is([data-station="ember"], [data-station="sage"]) { grid-template-areas: "machine head" "machine body"; }
  .station-head { grid-area: head; }
  .station-body { grid-area: body; }
  .station > .machine { grid-area: machine; position: sticky; top: 32px; }
}

/* The machine: a fixed dark plate (so the stills match whatever the bleed is doing), canvas or still. */
.machine { display: grid; gap: 14px; margin: 0; min-width: 0; }
.machine-screen { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #0f0d0a; border: 1px solid var(--line); border-radius: 2px; }
.machine-screen canvas, .machine-still { position: absolute; inset: 0; width: 100%; height: 100%; }
.machine-still { object-fit: cover; }
/* Stills show by default: no JS, a stalled or failed module, reduced motion, the pause. A still steps aside only
   once the engine has painted its canvas (figure[data-painted]) while the bench is live and unpaused. */
.machine[data-painted] .machine-still { display: none; }
html[data-bench="static"] .machine .machine-still, html[data-still] .machine .machine-still { display: block; }
html[data-bench="static"] .machine-screen canvas, html[data-still] .machine-screen canvas { display: none; }
.machine figcaption { max-width: 62ch; font-size: 14px; line-height: 1.6; color: var(--muted); }

/* Context machine controls (JS only, shown by the live machine) */
.ctx-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ctx-total { display: flex; flex-basis: 100%; align-items: baseline; gap: 10px; margin: 0; font: 11px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ctx-output { font: 15px/1.2 var(--mono); letter-spacing: 0; text-transform: none; color: var(--ink); }
.ctx-hint { flex-basis: 100%; margin: 0; font: 11px/1.5 var(--mono); letter-spacing: .08em; color: var(--muted); }
.ctx-skill, .ctx-reset { min-height: 44px; padding: 0 14px; font: 12px/1 var(--mono); color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 2px; cursor: pointer; }
.ctx-skill[aria-pressed="true"] { color: var(--muted); border-style: dashed; text-decoration: line-through; }
.ctx-reset { color: var(--accent); }
.ctx-skill:focus-visible, .ctx-reset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html[data-still] .ctx-controls, html[data-bench="static"] .ctx-controls { display: none; }

/* Icons: hand-drawn line art in the station tint. Drawn in on scroll where supported; otherwise fully drawn. */
.icon { display: block; flex: none; width: 48px; height: 48px; color: var(--tint); }
.station-head .icon { width: 56px; height: 56px; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    html:not([data-still]) .icon { view-timeline-name: --icon; }
    html:not([data-still]) .icon :is(path, circle, line) { stroke-dasharray: 1; stroke-dashoffset: 1; animation: icon-draw linear both; animation-timeline: --icon; animation-range: entry 10% cover 35%; }
  }
}
@keyframes icon-draw { to { stroke-dashoffset: 0; } }

/* Items inside a station */
.item { display: grid; grid-template-columns: 48px minmax(0, 1fr); column-gap: 18px; row-gap: 8px; padding-top: 24px; border-top: 1px solid var(--line); }
.item > .icon { grid-row: span 4; }
.item > :not(.icon) { grid-column: 2; }
.item.item--plain { grid-template-columns: minmax(0, 1fr); }
.item.item--plain > :not(.icon) { grid-column: 1; }
.item-kicker { margin: 0; font: 11px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.item h3 { font: 400 clamp(24px, 2.2vw, 32px)/1.1 var(--serif); }
.item-blurb { color: var(--muted); line-height: 1.7; }
.item-blurb code { font: .92em var(--mono); color: var(--ink); }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; font: 11px/1.5 var(--mono); letter-spacing: .06em; color: var(--muted); }
.item-go { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--accent); }
.item-go:hover { color: var(--ink); }

/* Actions, pills, panels, stats */
.ws-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.ws-button { display: inline-flex; align-items: center; gap: 14px; min-height: 48px; padding: 0 18px; font-size: 14px; color: #151a18; background: var(--accent); border: 1px solid var(--accent); border-radius: 2px; transition: background .25s, border-color .25s; }
.ws-button:hover { background: #edbd9d; }
.ws-button--ghost { color: var(--ink); background: transparent; border-color: var(--line); }
.ws-button--ghost:hover { background: transparent; border-color: var(--accent); }
.pill { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; font: 11px/1 var(--mono); letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; }
.panel { display: grid; gap: 18px; padding: clamp(20px, 3vw, 32px); background: #0f0d0a; border: 1px solid var(--line); border-radius: 2px; }
.panel p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.stat .n { font: 400 clamp(32px, 3.4vw, 48px)/1 var(--serif); }
.stat .k { margin-top: 6px; font: 11px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.panel-note { max-width: 42ch; font-size: 14px; color: var(--muted); }

/* Second Brain video: an ordinary link to the MP4 that video.js enhances into a shadow box (from the old inline block + operator.css) */
.video-frame { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; background: #000; border: 1px solid var(--line); }
a.video-frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.video-frame > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.video-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem; color: #fff; background: radial-gradient(ellipse at center, rgba(10, 10, 10, .1), rgba(10, 10, 10, .55)); }
.video-play { display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 50%; background: rgba(245, 245, 243, .96); transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
@media (hover: hover) and (pointer: fine) { .video-frame:hover .video-play { transform: scale(1.08); } }
.video-play svg { width: 24px; height: 24px; margin-left: 4px; color: #0a0a0a; }
.video-cap { display: inline-flex; align-items: center; gap: .6rem; font: 11px/1.4 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.video-cap .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.video-duration { position: absolute; right: 14px; bottom: 14px; padding: 4px 9px; font: 11px/1.4 var(--mono); color: var(--ink); background: rgba(10, 10, 10, .55); pointer-events: none; }
.video-modal { border: 0; padding: 0; background: #000; width: min(92vw, 1560px); max-height: 92vh; }
.video-modal::backdrop { background: rgba(5, 5, 5, .85); backdrop-filter: blur(8px); }
.video-modal .video-frame { border: 0; }
.video-modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; cursor: pointer; color: #f5f5f3; background: rgba(10, 10, 10, .65); border: 1px solid var(--line); font-family: var(--mono); font-size: 1.2rem; line-height: 1; }
@media (hover: hover) and (pointer: fine) { .video-modal-close:hover { background: rgba(10, 10, 10, .9); } }
.video-modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html.modal-open, html.modal-open body { overflow: hidden; }

/* 5 · Take it: the toolbox */
.toolbox { display: grid; gap: 18px; padding: clamp(64px, 9vw, 140px) var(--pad); border-top: 1px solid var(--line); }
.toolbox h2, .ws-close h2 { font: 400 clamp(36px, 4.4vw, 64px)/1.02 var(--serif); letter-spacing: -.02em; }
.toolbox-intro { max-width: 54ch; color: var(--muted); }
.tool-rows { margin: 12px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--ink); }
.tool-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1.3fr); gap: 10px 24px; align-items: start; padding: 22px 0; border-bottom: 1px solid var(--line); }
.tool-no { padding-top: 6px; font: 11px/1.5 var(--mono); letter-spacing: .08em; color: var(--accent); }
.tool-name { font: 400 clamp(22px, 2vw, 28px)/1.15 var(--serif); }
.tool-use { margin-top: 6px; font-size: 15px; color: var(--muted); }
.tool-action { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; min-width: 0; }
.tool-cmd { flex: 1 1 100%; min-width: 0; padding: 12px 14px; overflow-x: auto; white-space: nowrap; font: 13px/1.4 var(--mono); color: var(--ink); background: #0f0d0a; border: 1px solid var(--line); border-radius: 2px; }
.copy { min-height: 44px; padding: 0 16px; font: 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #151a18; background: var(--accent); border: 0; border-radius: 2px; cursor: pointer; }
.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
html:not(.js) .copy { display: none; }
.tool-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--ink); }
.tool-link:hover { color: var(--accent); }
.copy-status { font: 11px/1.5 var(--mono); letter-spacing: .06em; color: var(--accent); }
@media (max-width: 860px) {
  .tool-row { grid-template-columns: 40px minmax(0, 1fr); }
  .tool-action { grid-column: 2; }
}

/* The Field Notes close (same form shape as Insights; styled here, press.css is never loaded on Tools) */
.ws-close { display: grid; gap: 16px; margin-top: clamp(48px, 7vw, 96px); padding-top: clamp(40px, 6vw, 72px); border-top: 1px solid var(--line); }
.ws-close h2 { max-width: 20ch; }
.ws-close-lead { max-width: 54ch; color: var(--muted); }
.press-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 12px; max-width: 820px; margin-top: 8px; }
.press-field { display: grid; gap: 6px; font: 11px/1.5 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.press-field input { padding: 10px 0; font: 17px/1.3 var(--sans); color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; }
.press-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.press-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.press-submit { min-height: 48px; padding: 0 22px; font: 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #151a18; background: var(--accent); border: 0; border-radius: 2px; cursor: pointer; }
.press-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.press-submit:disabled { opacity: .6; cursor: progress; }
.press-form-status { grid-column: 1 / -1; min-height: 1.5em; margin: 0; }
.press-form.is-stamped .press-form-status { font: 400 22px/1.2 var(--serif); color: var(--accent); }
@media (max-width: 860px) { .press-form { grid-template-columns: 1fr; } }

/* 6 · Next room: contour lines rise out of the floor (CSS only; static under reduced motion or the pause) */
.next-room > span { position: relative; z-index: 1; }
.next-room-contours { position: absolute; left: 0; bottom: 0; width: 100%; height: 55%; color: #9fb89a; opacity: .45; pointer-events: none; transition: transform .6s cubic-bezier(.2, .7, .2, 1), opacity .6s; }
.next-room-contours path { fill: none; stroke: currentColor; stroke-width: 1.25; }
.next-room:hover .next-room-contours, .next-room:focus-visible .next-room-contours { transform: translateY(-14px); opacity: .7; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    html:not([data-still]) .next-room-contours { view-timeline-name: --contours; }
    html:not([data-still]) .next-room-contours path { animation: contour-rise linear both; animation-timeline: --contours; animation-range: entry 0% cover 40%; }
    html:not([data-still]) .next-room-contours path:nth-child(2) { animation-range: entry 5% cover 45%; }
    html:not([data-still]) .next-room-contours path:nth-child(3) { animation-range: entry 10% cover 50%; }
    html:not([data-still]) .next-room-contours path:nth-child(4) { animation-range: entry 15% cover 55%; }
    html:not([data-still]) .next-room-contours path:nth-child(5) { animation-range: entry 20% cover 60%; }
  }
}
@keyframes contour-rise { from { transform: translateY(28px); opacity: 0; } to { transform: none; opacity: 1; } }
html[data-still] .next-room:hover .next-room-contours, html[data-still] .next-room:focus-visible .next-room-contours { transform: none; }

@media (prefers-reduced-motion: reduce) {
  body[data-material="workshop"], .ws-button, .video-play, .next-room-contours { transition: none; }
  .next-room:hover .next-room-contours, .next-room:focus-visible .next-room-contours { transform: none; }
}

/* Still capture (scripts/capture-bench-stills.mjs): nothing overlays the canvases. */
html[data-bench-capture] .thread-rail, html[data-bench-capture] .thread-cursor { visibility: hidden; }
