/* One Loop, Twelve Grades: page-specific layer on top of house-style.css.
   The palette is a neutral graphite on purpose: a colorless surround lets each grade read true. */

@font-face {
  font-family: 'IBM Plex Mono';
  src: url(fonts/IBMPlexMono-normal-400.woff2) format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url(fonts/IBMPlexMono-normal-500.woff2) format('woff2');
  font-weight: 500;
  font-display: swap;
}

/* ---------- Stage layers ---------- */
.stage { background: #000; user-select: none; -webkit-user-select: none; }
.layers, .layer { position: absolute; inset: 0; }
.layer { width: 100%; height: 100%; object-fit: cover; display: block; }
.layer-source { z-index: 1; }
.layer-grade { z-index: 2; }
.layer-grade.incoming { z-index: 3; }
.layer-grid { z-index: 4; object-fit: contain; background: #000; }
.stage-top { z-index: 8; }

/* the incoming grade wipes in left to right, like the reel */
.layer-grade.wipe { animation: wipe 0.5s cubic-bezier(0.65, 0, 0.35, 1) both; }
@keyframes wipe {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* hold O: the flat source on top of everything */
.stage.holding .layer-source { z-index: 6; }
.hold-label {
  position: absolute; left: 50%; bottom: 18px; z-index: 7; transform: translateX(-50%);
  padding: 7px 12px; border: 1px solid var(--glass-line); border-radius: 4px;
  background: var(--glass); backdrop-filter: blur(10px);
  font: 500 11px / 1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink);
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.stage.holding .hold-label { opacity: 1; }

/* ---------- Compare ---------- */
.stage[data-view='compare'] .layer-grade { clip-path: inset(0 0 0 var(--split, 50%)); animation: none; }
.compare-ui { position: absolute; inset: 0; z-index: 5; cursor: ew-resize; touch-action: pan-y; }
.cmp-handle {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%); width: 44px; margin-left: -22px;
  display: grid; place-items: center; cursor: ew-resize;
}
.cmp-handle::before { content: ''; position: absolute; top: 0; bottom: 0; left: 21.5px; width: 1px; background: var(--ink); box-shadow: 0 0 0 0.5px #0006; }
.cmp-handle span {
  position: relative; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(10px);
}
.cmp-handle span::before, .cmp-handle span::after {
  content: ''; position: absolute; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-left: 1.6px solid var(--accent); border-bottom: 1.6px solid var(--accent);
}
.cmp-handle span::before { left: 9px; transform: rotate(45deg); }
.cmp-handle span::after { right: 9px; transform: rotate(-135deg); }
.cmp-handle:focus-visible { outline: none; }
.cmp-handle:focus-visible span { outline: 2px solid var(--accent); outline-offset: 3px; }
.cmp-label {
  position: absolute; bottom: 16px; padding: 7px 10px; border: 1px solid var(--glass-line); border-radius: 4px;
  background: var(--glass); backdrop-filter: blur(10px); pointer-events: none;
  font: 500 11px / 1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
}
.cmp-left { left: 18px; }
.cmp-right { right: 18px; color: var(--accent); }

/* ---------- All twelve: clickable tiles over the grid video (4 x 3, 1920 x 816) ---------- */
.grid-hits {
  position: absolute; left: 50%; top: 50%; z-index: 5; transform: translate(-50%, -50%);
  width: 100%; aspect-ratio: 1920 / 816;
  display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(3, 1fr);
}
.grid-hits button {
  position: relative; border: 1px solid transparent; text-align: left;
}
.grid-hits button:hover, .grid-hits button:focus-visible { border-color: var(--accent); outline: none; }
.grid-hits button span {
  position: absolute; left: 8px; bottom: 8px; padding: 4px 7px; border-radius: 3px;
  background: var(--glass); font: 500 10px / 1.2 var(--mono); letter-spacing: 0.06em; color: var(--ink);
}
.grid-hits button:hover span, .grid-hits button[aria-current='true'] span { color: var(--accent); }

/* play / pause tool */
#play-btn .i-play { display: none; }
#play-btn.paused .i-play { display: block; }
#play-btn.paused .i-pause { display: none; }

/* ---------- Layout: stage and recipe on the left, the rail on the right ---------- */
.stage-layout { grid-template-areas: 'stage rail' 'recipe rail'; align-items: start; row-gap: 0; }
.stage-layout > .stage-wrap { grid-area: stage; }
.stage-layout > .rail { grid-area: rail; }
.stage-layout > .recipe { grid-area: recipe; }

/* ---------- Rail ---------- */
.rail { min-width: 0; }
.rail-label { display: flex; justify-content: space-between; }
.rail-count { font-variant-numeric: tabular-nums; }
.rail-item { padding: 10px 0; gap: 12px; }
.rail-item strong { margin-bottom: 3px; }
.rail-item small { display: block; line-height: 1.35; }
.rail-item .num { width: 16px; flex: none; font-variant-numeric: tabular-nums; }
.rail-item .thumb { flex: none; margin-left: auto; width: 48px; height: 27px; object-fit: cover; border: 1px solid #fff2; border-radius: 2px; }
.rail-item.source strong { color: var(--muted); }
.rail-item.selected .thumb { border-color: var(--accent); }

/* ---------- Recipe card ---------- */
.recipe {
  display: grid; grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.25fr); gap: 28px;
  margin: 22px 0 0; padding: 24px 26px;
}
.recipe .eyebrow { margin-bottom: 10px; }
.recipe h2 { font-size: 44px; }
.recipe-about { margin: 14px 0 0; max-width: 46ch; font-size: 13px; line-height: 1.6; color: var(--muted); }
.recipe-method { margin: 14px 0 0; font: 12px / 1.5 var(--mono); color: var(--ink); }
.recipe-method b { margin-right: 8px; font-weight: 500; font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.recipe-ops { list-style: none; margin: 0; padding: 0; counter-reset: op; align-self: start; }
.recipe-ops li {
  display: grid; grid-template-columns: 28px 150px minmax(0, 1fr); gap: 10px; align-items: baseline;
  padding: 8px 0; border-top: 1px solid var(--rule); font: 12.5px / 1.5 var(--mono);
}
.recipe-ops li:last-child { border-bottom: 1px solid var(--rule); }
.recipe-ops li::before { counter-increment: op; content: counter(op, decimal-leading-zero); font-size: 10px; color: var(--muted); }
.recipe-ops .op { color: var(--accent); }
.recipe-ops .args { color: var(--ink); overflow-wrap: anywhere; }
.recipe-ops .empty { display: block; grid-column: 1 / -1; color: var(--muted); }
.recipe-ops .empty::before { content: none; }

/* ---------- Three ideas ---------- */
.ideas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; padding: 44px 0 72px; }
.ideas > div { padding-top: 18px; border-top: 1px solid var(--rule); }
.ideas h2 { margin: 0 0 12px; font: 400 32px / 1.02 'Instrument Serif', serif; letter-spacing: -0.02em; }
.ideas p:not(.eyebrow) { margin: 0; font-size: 13px; line-height: 1.65; color: var(--muted); }
.ideas .term { color: var(--ink); }

/* ---------- Showreel drawer ---------- */
.reel-drawer .drawer-body video { display: block; width: 100%; aspect-ratio: 16 / 9; margin: 6px 0 16px; background: #000; }
.reel-drawer .drawer-body h2 { font-size: 44px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stage-layout { grid-template-areas: 'stage' 'rail' 'recipe'; row-gap: 22px; }
  .recipe { margin-top: 0; }
  .rail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .rail-item:last-of-type { border-bottom: 0; }
  .rail-list { border-bottom: 1px solid var(--rule); }
}
@media (max-width: 800px) {
  .recipe { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
  .recipe-ops li { grid-template-columns: 24px minmax(0, 1fr); }
  .recipe-ops .args { grid-column: 2; }
  .ideas { grid-template-columns: 1fr; gap: 26px; padding: 32px 0 56px; }
  .sc-arrows { display: none !important; }
  .grid-hits button span { left: 4px; bottom: 4px; padding: 2px 4px; font-size: 8px; }
}
@media (max-width: 480px) {
  .rail-list { grid-template-columns: 1fr; }
  .rail-item:last-of-type { border-bottom: 1px solid var(--rule); }
  .rail-list { border-bottom: 0; }
  .recipe h2 { font-size: 36px; }
  .shortcut-row button span { font-size: 9px; }
  .grid-hits button span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .layer-grade.wipe { animation: none; }
}

/* Glossary tips: out of layout until shown (a hidden tip near the right edge must not widen the page),
   and kept inside the viewport by app.js */
.term-tip { display: none; max-width: min(260px, calc(100vw - 32px)); white-space: normal; }
.term:hover .term-tip, .term:focus-visible .term-tip, .term[aria-expanded='true'] .term-tip { display: block; }

@media (max-width: 800px) {
  .action-row > .action:first-child { grid-column: 1 / -1; }
}

/* eyebrow: when the second phrase wraps, it starts flush left instead of keeping its 28px gap */
.eyebrow { display: flex; flex-wrap: wrap; column-gap: 28px; row-gap: 4px; }
.eyebrow .edition { margin: 0; }

/* Controls sit along the bottom edge of the picture so they never cover her face;
   the compare and hold labels move to the top edge instead. */
.stage-top { inset: auto 18px 16px; align-items: end; }
.cmp-label { top: 16px; bottom: auto; }
.hold-label { top: 18px; bottom: auto; }
@media (max-width: 800px) {
  .stage-top { inset: auto 12px 12px; align-content: end; grid-template-columns: auto 1fr auto; grid-template-areas: 'badges shortcuts tools'; }
  .stage-top .shortcut-row { position: static; transform: none; }
  .cmp-label { top: 12px; }
  .hold-label { top: 12px; }
}
@media (max-width: 600px) {
  /* phones: the picture is small, so the controls sit just under it in two rows
     (the shortcut pill, then the view menu and the tools) instead of covering it */
  .stage { overflow: visible; margin-bottom: 96px; }
  .stage-top { inset: calc(100% + 10px) 0 auto; align-content: start; grid-template-columns: 1fr auto; grid-template-areas: 'shortcuts shortcuts' 'badges tools'; row-gap: 6px; }
  .cmp-left { left: 12px; }
  .cmp-right { right: 12px; }
}

/* ---------- Credit line and shared footer ---------- */
.credit-line { margin: 0; padding: 0 0 40px; max-width: 90ch; font-size: 13px; line-height: 1.6; color: var(--muted); }
.credit-line a { color: var(--ink); text-underline-offset: 3px; white-space: nowrap; }
.credit-line a:hover { color: var(--accent); }
.page-end {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 40px; padding: 26px 4.2%;
  border-top: 1px solid var(--rule); background: var(--exploration-footer-bg); font: 500 12px / 1.4 var(--mono);
}
.page-end .id { letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.page-end a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; }
.page-end a:hover { color: var(--accent); }
/* the shared runtime fills this slot with the creation links; the footer draws the rule and background */
.page-end [data-exploration-controls] { flex: 1 1 320px; display: flex; justify-content: flex-end; border-top: 0; background: none; }
