/* base */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-text);
  color: var(--ink);
  background: var(--bg-base);
  display: grid;
  align-content: start;
  justify-items: center;
  min-height: 100vh;
  padding-top: var(--space-5);
  overflow: hidden;
}

/* top deck: page switcher merged into the title row */
.deckbar {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  margin: 0 0 var(--space-5);
}
.deck-theme {
  justify-self: start; margin: 0 0 0 var(--space-7);
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; padding: 0;
  color: var(--ink); background: var(--surface-glass);
  -webkit-backdrop-filter: var(--glass-panel);
  backdrop-filter: var(--glass-panel);
  border: 1px solid var(--hairline-soft); border-top-color: var(--hairline);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-raised), var(--sheen-top);
  cursor: pointer;
}
.deck-theme .icon { width: 1.4em; height: 1.4em; }
.deck-theme:hover { border-color: var(--hairline); }
.deck-theme:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.deck {
  position: relative; justify-self: center;
  display: inline-flex; padding: var(--space-1);
  background: var(--surface-glass);
  -webkit-backdrop-filter: var(--glass-panel);
  backdrop-filter: var(--glass-panel);
  border: 1px solid var(--hairline-soft); border-top-color: var(--hairline);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-panel), var(--sheen-top);
}
.deck-glider {
  position: absolute; z-index: 0; top: var(--space-1); bottom: var(--space-1); left: var(--space-1);
  width: calc(50% - var(--space-1));
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--brand-sheen) 0%, var(--brand) 48%, var(--brand-strong) 100%);
  box-shadow: var(--shadow-button), var(--sheen-top);
  transition: transform 300ms var(--ease-spring);
}
.deck.at-1 .deck-glider { transform: translateX(100%); }
.deck:has(.tab:nth-child(1):hover) .deck-glider { transform: translateX(0); }
.deck:has(.tab:nth-child(2):hover) .deck-glider { transform: translateX(100%); }
.tab {
  position: relative; z-index: 1; flex: none; width: 168px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: 0.2px;
  color: var(--ink-muted); text-decoration: none; white-space: nowrap;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  transition: color 200ms ease;
}
.tab .icon { width: 1.2em; height: 1.2em; }
.tab[aria-current="page"] { color: var(--ink-onbrand); }
.tab:not([aria-current="page"]):hover { color: var(--ink-onbrand); }
.deck:has(.tab:not([aria-current="page"]):hover) .tab[aria-current="page"] { color: var(--ink-muted); }

.stage {
  position: relative;
  width: 1280px; height: 820px;
  overflow: hidden;
  background: var(--bg-base);
  padding: var(--space-8);
  display: flex; flex-direction: column;
  transform: scale(var(--stage-scale, 1));
  transform-origin: top center;
}
.bg { position: absolute; inset: 0; z-index: 0; transform: scaleX(1.08); }
.plane { position: absolute; border-radius: var(--radius-lg); }
.pl-warm  { background: var(--backdrop-warm); width: 560px; height: 460px; right: -120px; top: -140px; }
.pl-brand { background: var(--brand);         width: 300px; height: 520px; right: 180px;  top: 120px; }
.pl-teal  { background: var(--support-teal);  width: 460px; height: 300px; left: -140px;  bottom: -120px; }
.pl-deep  { background: var(--backdrop-deep);  width: 360px; height: 360px; left: 260px;  bottom: -180px; }
.disc { position: absolute; border-radius: var(--radius-pill); }
.d-accent { background: var(--accent);      width: 220px; height: 220px; right: 90px;  top: 40px;  opacity: .5; }
.d-sheen  { background: var(--brand-sheen); width: 130px; height: 130px; right: 420px; top: 300px; opacity: .5; }
.d-gold   { background: var(--support-gold);width: 90px;  height: 90px;  left: 220px;  top: 120px; opacity: .9; }
.d-white  { background: var(--ink);         width: 70px;  height: 70px;  left: 520px;  bottom: 60px; opacity: .22; }

.section-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 26px; line-height: 30px; letter-spacing: 0.2px;
  color: var(--ink);
  margin: 0 0 var(--space-5);
}

.window {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  background: var(--surface-glass);
  -webkit-backdrop-filter: var(--glass-panel);
  backdrop-filter: var(--glass-panel);
  border: 1px solid var(--hairline-soft);
  border-top-color: var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel), var(--sheen-top), inset 0 -1px 0 rgba(0,0,0,0.10);
  padding: var(--space-7);
}
.window::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), transparent 40%);
}
.window > * { position: relative; z-index: 1; }
.divider { background: var(--hairline-soft); align-self: stretch; }
.col { min-width: 0; display: flex; flex-direction: column; }
.hero { align-items: center; text-align: center; justify-content: center; }
.hero .section-title { font-size: 34px; line-height: 40px; }
.hero .caption { font-size: 15px; line-height: 22px; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.btn-row { display: flex; gap: var(--space-3); }
/* helpers*/
.caption {
  font-size: 12px; line-height: 17px; font-style: italic;
  color: var(--ink-muted); margin: 0 0 var(--space-5);
}
.label {
  display: block; font-size: 12px; line-height: 16px; font-weight: 600;
  letter-spacing: 0.6px; color: var(--ink-muted); margin: 0 0 var(--space-2);
}
.status { margin: 0; font-size: 12px; line-height: 17px; font-weight: 600; color: var(--ink-muted);
  display: flex; align-items: center; gap: var(--space-2); }
.status.ok   { color: var(--support-teal); }
.status.warn { color: var(--support-gold); }
.status.err  { color: var(--critical); }
.status a { color: inherit; text-decoration: underline; }

.col .status { margin: var(--space-2) 0 0; }
/* glass button secondary +*/
.btn {
  display: inline-flex; width: 100%;
  align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-text); font-size: 15px; font-weight: 600;
  color: var(--ink-onbrand);
  border: 1px solid var(--brand-strong);
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  text-align: center; text-decoration: none;
  background: linear-gradient(180deg, var(--brand-sheen) 0%, var(--brand) 48%, var(--brand-strong) 100%);
  box-shadow: var(--shadow-button), var(--sheen-top);
  transition: background 120ms ease, box-shadow 120ms ease, transform 160ms var(--ease-spring);
}
.btn.lg { font-size: 18px; padding: var(--space-4) var(--space-6); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* hover: brighten the gradient */
.btn:hover { background: linear-gradient(180deg, var(--brand-sheen) 0%, var(--brand) 62%, var(--brand-strong) 100%); }
/* pressed gives flat brand to brand-strong, drop the drop-shadow (keep sheen-top), and nudge down 1px */
.btn:active {
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  box-shadow: var(--sheen-top);
  transform: translateY(1px);
}
.btn:disabled { opacity: var(--disabled); cursor: not-allowed; transform: none; }

.btn.glass {
  color: var(--ink);
  background: var(--surface-glass-strong);
  -webkit-backdrop-filter: var(--glass-panel);
  backdrop-filter: var(--glass-panel);
  border: 1px solid var(--hairline-soft); border-top-color: var(--hairline);
  box-shadow: var(--shadow-raised), var(--sheen-top);
}
.btn.glass:hover { background: var(--surface-glass-strong); border-color: var(--hairline); }
.btn.glass:active {
  background: var(--surface-glass-strong);
  box-shadow: var(--sheen-top);
  transform: translateY(1px);
}

/*code input field*/
.code-input, .field {
  width: 100%;
  font-family: var(--font-mono); font-size: 15px; line-height: 22px;
  font-weight: 600; letter-spacing: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.35);
}
.code-input { color: var(--ink-faint); }
.code-input.set { color: var(--ink); }
.field { color: var(--ink); }
.field::placeholder { color: var(--ink-faint); letter-spacing: normal; }
.field:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* reference readout */
.code-input.ref, .code-input.ref.set {
  font-size: 13px; letter-spacing: 1px; color: var(--ink-muted);
  background: transparent; box-shadow: none; border-style: dashed;
  padding: var(--space-2) var(--space-3);
}
/*modals and scrim*/
.scrim {
  position: fixed; inset: 0; z-index: 200;
  display: none; place-items: center; padding: var(--space-5);
  background: rgba(0, 0, 0, var(--scrim));
  -webkit-backdrop-filter: var(--glass-overlay);
  backdrop-filter: var(--glass-overlay);
}
.scrim.open { display: grid; }
.modal {
  width: min(440px, 100%);
  display: flex; flex-direction: column; gap: var(--space-4);
  background: var(--surface-glass-strong);
  -webkit-backdrop-filter: var(--glass-panel);
  backdrop-filter: var(--glass-panel);
  border: 1px solid var(--hairline-soft); border-top-color: var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel), var(--sheen-top);
  padding: var(--space-7);
}
.modal:focus { outline: none; }
.modal-title { margin: 0; color: var(--ink); }
.modal-body { margin: 0; font-size: 15px; line-height: 22px; color: var(--ink-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-2); }
.modal-actions .btn { width: auto; }

.btn.glass.danger { color: var(--critical); }
.btn.glass.danger:hover { border-color: var(--critical); }

.btn.ico { width: auto; min-width: 52px; padding: var(--space-3); }
.btn.ico .icon { width: 1.4em; height: 1.4em; }

.slider-val { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--ink); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 0;
  border-radius: var(--radius-pill); cursor: pointer;
  background: var(--surface-sunken); border: 1px solid var(--hairline-soft);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}
input[type="range"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--brand-sheen) 0%, var(--brand) 55%, var(--brand-strong) 100%);
  border: 1px solid var(--brand-strong); box-shadow: var(--shadow-button), var(--sheen-top); margin-top: -8px;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--brand-sheen) 0%, var(--brand) 55%, var(--brand-strong) 100%);
  border: 1px solid var(--brand-strong); box-shadow: var(--shadow-button), var(--sheen-top);
}

/* projection preview popup (INFRA-SIM) */
.sim-panel {
  width: min(860px, 100%);
  display: flex; flex-direction: column; gap: var(--space-4);
  background: var(--surface-glass-strong);
  -webkit-backdrop-filter: var(--glass-panel); backdrop-filter: var(--glass-panel);
  border: 1px solid var(--hairline-soft); border-top-color: var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel), var(--sheen-top);
  padding: var(--space-6);
}
.sim-panel #sim-close { align-self: flex-start; }
.sim-body { display: grid; grid-template-columns: 1fr 260px; gap: var(--space-5); align-items: start; }
.sim-stage {
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--hairline-soft);
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.45);
  background: #000;
}
.sim-canvas { display: block; width: 100%; height: 100%; }
.sim-ctrls { display: flex; flex-direction: column; gap: var(--space-3); }
.sim-row .label { margin: 0 0 var(--space-1); }
.sim-unit { font-weight: 400; text-transform: none; letter-spacing: 0; }
.sim-slider { display: flex; align-items: center; gap: var(--space-3); }
.sim-slider input[type="range"] { flex: 1; }
.sim-slider .slider-val { min-width: 48px; text-align: right; }
.sim-checks { display: flex; gap: var(--space-4); margin: var(--space-1) 0; }
.sim-check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 13px; color: var(--ink-muted); cursor: pointer; }
.sim-check input { accent-color: var(--brand); }
.sim-readout {
  display: flex; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) 0; margin: var(--space-1) 0;
  border-top: 1px solid var(--hairline-soft); border-bottom: 1px solid var(--hairline-soft);
  font-size: 12px; color: var(--ink-muted);
}
.sim-readout strong { color: var(--ink); font-family: var(--font-mono); }
.sim-ctrls .btn { width: 100%; }

/* icons */
.icon { width: 1em; height: 1em; flex: none; overflow: visible; display: inline-block; vertical-align: -0.125em; }

/* accessibility fallbacks */
@media (prefers-reduced-transparency: reduce) {
  .deck, .deck-theme, .window, .device, .btn.glass, .modal, .sim-panel {
    -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface-raised);
  }
  .scrim { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(0,0,0,0.72); }
  .window::before { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .tab, .deck-glider { transition: none; }
  .btn:active { transform: none; }
}
