/* Dice XOR Lab instrument stylesheet.
   Recovered from the Operator's standalone lab (dice_xor_lab.html) and re-tuned
   to the site chassis: IBM Plex typography, site bronze accent, site ground
   colours. The lab's own ALPHA–THETA theme variables are preserved so the
   theme bar in the instrument still drives every colour.

   Tunables live in the :root block below — change values there, not in rules.
   Body markup is the Operator's own; do not editorialize it. */

@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/ibm-plex-sans-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/ibm-plex-sans-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Sans'; src: url('/fonts/ibm-plex-sans-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Serif'; src: url('/fonts/ibm-plex-serif-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Serif'; src: url('/fonts/ibm-plex-serif-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

/* ---------- tunables --------------------------------------------------- */
:root {
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;

  /* lab palette — ALPHA default; overridden per theme by lab-dice.js */
  --void: #0A0B0A;
  --panel: #101210;
  --panel-2: #151813;
  --ink: #E7E5DA;
  --muted: #9C9C90;
  --turquoise: #C9A227;      /* site antique gold — the accent */
  --turquoise-dim: #7d5b16;
  --silver: #CFCBBE;
  --silver-bright: #F3F1EA;
  --accent: #C9A227;
  --danger: #C25A1E;
  --signal: #B4531F;

  --line-weight: 1px;
  --signal-density: 3;
  --motion-duration: 260ms;
  --radius: 2px;
  --rule: #23251F;

  color-scheme: dark;
}

/* ---------- reset / chassis -------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { min-width: 0; background: var(--void); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-width: 0; min-height: 100vh;
  font-family: var(--sans); font-size: 1rem; line-height: 1.6;
  background:
    linear-gradient(rgba(201,162,39,calc(.022*var(--signal-density))) var(--line-weight), transparent var(--line-weight)),
    linear-gradient(90deg,rgba(201,162,39,calc(.016*var(--signal-density))) var(--line-weight), transparent var(--line-weight)),
    radial-gradient(ellipse at 72% 8%, #1C1A11 0, transparent 38%),
    var(--void);
  background-size: 34px 34px, 34px 34px, auto, auto;
  transition: background-color var(--motion-duration) ease, color var(--motion-duration) ease;
}
button, input, textarea, select { font: inherit; min-width: 0; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--turquoise); outline-offset: 3px; }

.skip { position: absolute; left: 1rem; top: -5rem; padding: .7rem 1rem; background: var(--silver-bright); color: #111; z-index: 5; }
.skip:focus { top: 1rem; }

.shell { width: min(1180px, 100%); margin: auto; padding: clamp(12px, 2vw, 26px); }

/* ---------- header ------------------------------------------------------ */
header {
  display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: end;
  border-bottom: var(--line-weight) solid var(--turquoise-dim); padding: 12px 0 18px;
}
.eyebrow, .mono, .readout, table, code { font-family: var(--mono); }
.eyebrow { color: var(--turquoise); font-size: .72rem; letter-spacing: .19em; text-transform: uppercase; margin: 0 0 8px; }
h1 { font-family: var(--serif); font-size: clamp(1.65rem, 4vw, 3.25rem); font-weight: 400; letter-spacing: .025em; line-height: 1.05; margin: 0; color: var(--silver-bright); }
h1 span { display: block; color: var(--turquoise); font-size: .58em; letter-spacing: .06em; margin-top: .35em; }
.header-mark {
  width: 72px; height: 72px; border: 1px solid var(--turquoise-dim); border-radius: 50%;
  display: grid; place-items: center; position: relative; color: var(--turquoise);
  font-family: var(--mono); font-size: .62rem; letter-spacing: .12em; text-align: center;
}
.header-mark:before, .header-mark:after {
  content: ""; position: absolute; inset: 9px;
  border-top: 1px solid var(--turquoise-dim); border-bottom: 1px solid var(--turquoise-dim);
  transform: rotate(45deg);
}
.return-link {
  display: inline-block; margin-bottom: 14px; color: var(--muted);
  font-family: var(--mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
  text-decoration: none; border-bottom: 1px solid var(--rule);
}
.return-link:hover { color: var(--turquoise); border-bottom-color: var(--turquoise-dim); }

/* ---------- status / theme bar ------------------------------------------ */
.status-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; font-size: .7rem; color: var(--muted); font-family: var(--mono); letter-spacing: .08em; }
.status-strip span { border: 1px solid var(--rule); padding: 5px 9px; background: var(--bg-sink, #050605); }
.status-strip .ok { color: var(--turquoise); border-color: var(--turquoise-dim); }

.theme-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; align-items: center; }
.theme-bar button { flex: 0 1 auto; padding: 7px 10px; font-size: .68rem; }
.theme-label { color: var(--muted); font-size: .68rem; letter-spacing: .1em; margin-left: 4px; }

/* ---------- tabs / panels ------------------------------------------------ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--turquoise-dim); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--rule); border-bottom: 0; background: var(--bg-sink, #050605); color: var(--muted);
  padding: 11px 16px; letter-spacing: .08em; text-transform: uppercase; font-size: .74rem;
}
.tab[aria-selected=true] { background: var(--silver); color: #0A0B0A; border-color: var(--silver); }
.panel { display: none; }
.panel.active { display: block; }

.instrument {
  border: 1px solid var(--rule); background: linear-gradient(145deg, #14160F, #0C0D0A);
  box-shadow: inset 0 0 0 1px #050605, 0 16px 40px #0006; position: relative; overflow: hidden;
}
.instrument:before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(231,229,218,.06); pointer-events: none; }

.grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 1px; background: var(--rule); }
.section { background: linear-gradient(150deg, #14160F, #0D0E0B); padding: clamp(14px, 2vw, 24px); min-width: 0; }
.section h2 { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; line-height: 1.25; color: var(--silver-bright); margin: 0 0 18px; letter-spacing: .03em; }
.section h3 { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--turquoise); margin: 0 0 10px; font-weight: 500; }

/* ---------- forms --------------------------------------------------------- */
label { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
textarea, input, select {
  width: 100%; border: 1px solid #3A3D33; border-radius: var(--radius);
  background: #070807; color: var(--silver-bright); padding: 11px 12px; line-height: 1.45;
}
textarea { resize: vertical; min-height: 116px; font-family: var(--mono); }
input, textarea { font-size: 16px; }
select { color: var(--silver-bright); background: #070807; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; }

button {
  border: 1px solid var(--silver-dim, #6f7c7e); background: linear-gradient(#D8D3C2, #9C978A); color: #0A0B0A;
  border-radius: var(--radius); padding: 10px 13px; font-size: .76rem; font-weight: 600;
  letter-spacing: .055em; text-transform: uppercase; font-family: var(--sans);
}
button:hover { background: var(--silver-bright); }
button.secondary { background: #12140F; color: var(--turquoise); border-color: var(--turquoise-dim); }
button.secondary:hover { background: #191B14; color: var(--silver-bright); }
button.danger { background: #241512; color: #E9B39A; border-color: #6E3420; }
button:disabled { opacity: .45; cursor: not-allowed; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.controls button { flex: 1 1 150px; }

/* ---------- readouts ------------------------------------------------------ */
.readout { border: 1px solid var(--turquoise-dim); background: #070806; padding: 14px; color: var(--turquoise); min-height: 52px; overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.55; }
.readout.small { font-size: .72rem; }
.readout:empty:before { content: "—"; color: #4C5049; }

.dice-stage { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.die-unit { border: 1px solid var(--rule); background: #070807; padding: 12px; text-align: center; position: relative; overflow: hidden; }
.die-label { font-size: .62rem; letter-spacing: .18em; color: var(--muted); font-family: var(--mono); }
.die-face { font-family: var(--serif); font-weight: 400; font-size: clamp(3.5rem, 10vw, 6rem); line-height: 1; color: var(--silver-bright); margin: 8px 0; position: relative; z-index: 1; transition: transform .2s ease; }
.pip {
  position: absolute; inset: 8px 28%; opacity: .14;
  background: radial-gradient(circle, var(--turquoise) 0 2px, transparent 2.5px);
  background-size: 25% 33.333%;
}

.audit { max-height: 190px; overflow: auto; border: 1px solid var(--rule); background: #070807; padding: 8px; font-size: .7rem; color: var(--muted); font-family: var(--mono); }
.audit div { padding: 4px 2px; border-bottom: 1px solid #191B16; }
.audit .reject { color: #D9A18C; }
.audit .accept { color: var(--turquoise); }

.notice { border-left: 2px solid var(--turquoise); padding: 10px 12px; background: #0C0E0A; color: #B6B3A8; font-size: .78rem; line-height: 1.55; }
.notice code { color: var(--turquoise); }
.warning { border-left-color: #C19A5D; }
.error { color: var(--danger); font-size: .78rem; min-height: 1.2em; margin-top: 8px; }

.tunable { border: 1px dashed #3F4238; padding: 12px; color: var(--muted); font-size: .76rem; line-height: 1.55; }
.tunable code { color: var(--turquoise); }
.map-ref { font-size: .68rem; color: var(--muted); margin-top: 8px; line-height: 1.4; }

progress, .progress { height: 4px; background: #191B16; margin: 6px 0; border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--turquoise); width: 0; transition: width .3s; }

details { margin-top: 12px; }
summary { cursor: pointer; color: var(--turquoise); font-size: .73rem; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- go board -------------------------------------------------------- */
.go-board {
  position: relative; width: min(100%, 440px); aspect-ratio: 1; margin: 12px auto;
  border-radius: 4px; overflow: hidden;
  background: linear-gradient(145deg, var(--panel), var(--void));
  box-shadow: inset 0 0 0 1px var(--turquoise-dim), 0 8px 24px #0004;
}
.go-line { position: absolute; background: var(--muted); opacity: .6; pointer-events: none; }
.go-line.h { height: 1.5px; left: 10%; right: 10%; }
.go-line.v { width: 1.5px; top: 10%; bottom: 10%; }
.go-stone {
  position: absolute; width: 4.2%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%); box-shadow: 0 1px 3px #0008, inset 0 0 2px #0004; pointer-events: none;
}
.go-stone.black { background: radial-gradient(circle at 32% 32%, #C9A227, #6E5114); }
.go-stone.white { background: radial-gradient(circle at 32% 32%, #F3F1EA, #CFCCC0); }
.go-star { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); opacity: .7; transform: translate(-50%, -50%); }

/* ---------- utility classes (CSP replacements for inline styles) ------------ */
/* !important so utilities win over component rules such as `.section h3`. */
.m0 { margin: 0 !important; }
.mt-14 { margin-top: 14px !important; }
.mt-18 { margin-top: 18px !important; }

footer {
  margin: 20px 0 8px; border-top: var(--line-weight) solid var(--rule); padding-top: 12px;
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  color: var(--muted); font-size: .68rem; letter-spacing: .06em;
}
footer a { color: var(--turquoise); }

/* ---------- responsive ------------------------------------------------------- */
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } .header-mark { display: none; } header { grid-template-columns: 1fr; } }
@media (max-width: 360px) { .shell { padding: 8px; } .tab { flex: 1; padding: 10px 6px; } .dice-stage { grid-template-columns: 1fr; } .row > * { flex-basis: 100%; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }
