/* #stack: the tech stack as a 3D circuit board. The picture is WebGL (js/sections/pcb/scene.js);
   everything around it is plain DOM: the readout, a hint, and a tile grid when WebGL is unavailable. */

/* The board follows the hero directly, so the section opens tighter than the others. */
#stack.pcb { padding-top: clamp(32px, 4.2vw, 60px); padding-bottom: clamp(72px, 8vw, 120px); }
.pcb__head { margin-bottom: clamp(0px, 0.8vw, 10px); }

.pcb__grid {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
}
.pcb__board { grid-column: 2; grid-row: 1; position: relative; min-width: 0; margin-right: calc(var(--gutter) * -0.55); }
.pcb__readout { grid-column: 1; grid-row: 1; min-width: 0; min-height: 300px; display: flex; flex-direction: column; justify-content: center; }

/* ── The stage ─────────────────────────────────────────── */
.pcb__stage { position: relative; aspect-ratio: 1.6 / 1; min-height: 340px; }
.pcb__gl { position: absolute; inset: 0; }
.pcb__canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: pan-y; outline: none;
  opacity: 0; transition: opacity 1.1s var(--ease);
  /* Feather every edge so the picture dissolves into the page instead of ending in a box. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent), linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent), linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
  mask-composite: intersect;
}
.pcb__stage[data-state='gl'] .pcb__canvas { opacity: 1; }
.pcb__board:has(.pcb__opt:focus-visible) .pcb__stage { outline: 2px solid var(--heat-4); outline-offset: 8px; border-radius: 14px; }

.pcb__hint {
  position: absolute; left: 50%; bottom: 4px; z-index: 2; translate: -50% 0;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 14px; border-radius: 999px;
  border: 1px solid var(--line-3); background: rgba(12, 10, 9, 0.72);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-size: 14px; font-weight: 550; letter-spacing: -0.01em; color: var(--text); white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  pointer-events: none; transition: opacity 0.6s var(--ease), translate 0.6s var(--ease);
  animation: pcb-hint-bob 2.6s var(--ease-io) infinite;
}
/* A live ember dot with a ripple: the universal "touch here" signal. */
.pcb__hint i { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ember); flex-shrink: 0; }
.pcb__hint i::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--ember); animation: pcb-ripple 1.6s var(--ease) infinite; }
@keyframes pcb-ripple { from { transform: scale(0.5); opacity: 0.9; } to { transform: scale(2.2); opacity: 0; } }
@keyframes pcb-hint-bob { 50% { translate: -50% -4px; } }
@media (prefers-reduced-motion: reduce) { .pcb__hint, .pcb__hint i::after { animation: none; } }
.pcb__stage[data-state='tiles'] .pcb__hint, .pcb__stage.is-used .pcb__hint { opacity: 0; }

/* ── Readout ───────────────────────────────────────────── */
.pcb__lead { font-size: var(--fs-lead); line-height: 1.5; color: var(--text-2); max-width: 30ch; }
.pcb__legend { margin-top: 30px; border-top: 1px solid var(--line); }
.pcb__lg {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 2ch; gap: 16px; align-items: baseline;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.pcb__lg dt { color: var(--text); }
.pcb__lgp { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.pcb__lgc { font-variant-numeric: tabular-nums; color: var(--text-2); text-align: right; }

.pcb__detail[hidden], .pcb__idle[hidden] { display: none; }
.pcb__tag { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.pcb__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); transition: background 0.25s; }
.pcb__readout[data-live='1'] .pcb__dot { background: var(--ember); }
.pcb__name {
  margin: 16px 0 16px; font-family: var(--font-display); font-weight: 600;
  font-size: clamp(38px, 4.6vw, 64px); line-height: 1.02; letter-spacing: -0.04em; text-wrap: balance;
}
.pcb__line { font-size: var(--fs-lead); line-height: 1.5; color: var(--text); max-width: 32ch; text-wrap: pretty; }
.pcb__ref { margin-top: 26px; display: flex; gap: 18px; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.pcb__detail.is-pressed .pcb__name { animation: pcb-press 0.32s var(--ease); }
@keyframes pcb-press { 0% { transform: translateY(0); } 30% { transform: translateY(3px); } 100% { transform: none; } }

/* ── Fallback tiles ────────────────────────────────────── */
.pcb__tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pcb__tiles[hidden] { display: none; }
.pcb__stage[data-state='tiles'] { aspect-ratio: auto; min-height: 0; }
.pcb__tile {
  display: grid; gap: 4px; align-content: start; text-align: left; padding: 14px 14px 12px;
  border-radius: 12px; border: 1px solid var(--line-2); background: #0b0a09;
  transition: border-color 0.3s, background 0.3s, transform 0.4s var(--ease);
}
.pcb__tile:hover, .pcb__tile.is-on { border-color: var(--line-3); background: var(--bg-3); }
.pcb__tile:active { transform: translateY(1px); }
.pcb__tref { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.pcb__tname { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.pcb__tgrp { font-size: 12px; color: var(--text-3); }
.pcb__tile.is-on .pcb__tref { color: var(--ember); }

/* ── Narrow screens: the board leads at full width, the readout sits under it ── */
@media (max-width: 900px) {
  .pcb__grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .pcb__board, .pcb__readout { grid-column: 1; }
  .pcb__board { grid-row: 1; margin-right: 0; }
  .pcb__readout { grid-row: 2; min-height: 210px; justify-content: flex-start; }
  .pcb__lead { max-width: none; }
  .pcb__name { font-size: clamp(36px, 8vw, 52px); }
}
/* Phones: the board turns a quarter turn (scene.js) and fills the screen edge to edge. */
@media (max-width: 640px) {
  .pcb__board { margin-inline: calc(var(--gutter) * -1); }
  .pcb__stage { aspect-ratio: 0.78 / 1; min-height: 0; }
  .pcb__canvas { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 6%, #000 94%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 6%, #000 94%, transparent); }
  .pcb__hint { bottom: 8px; font-size: 13px; }
  .pcb__name { font-size: clamp(36px, 11vw, 52px); }
}
@media (prefers-reduced-motion: reduce) {
  .pcb__canvas { transition: none; }
  .pcb__detail.is-pressed .pcb__name { animation: none; }
}
