/* CMO Soundtrack — /demo instrument.
   Shares the type scale and palette of the landing page so the two surfaces
   read as one property. */

:root {
  color-scheme: dark;
  --bg: #02070e;
  --panel: rgba(10, 18, 30, 0.74);
  --panel-solid: #0a1220;
  --line: rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.07);
  --text: #f5f8fc;
  --muted: #c2d1e4;
  --dim: #a3b6cf;
  --gold: #f4bf70;
  --cyan: #8ddcff;
  --teal: #4fc4be;
  --spring: #f0a830;
  --summer: #ff8244;
  --autumn: #a983f0;
  --winter: #6ea4ff;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
  --radius: 1.25rem;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 16%, rgba(79, 196, 190, 0.14), transparent 26%),
    radial-gradient(circle at 86% 12%, rgba(244, 191, 112, 0.15), transparent 24%),
    radial-gradient(circle at 52% 88%, rgba(141, 220, 255, 0.08), transparent 32%),
    linear-gradient(180deg, #02070e 0%, #050b14 42%, #02070e 100%);
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a {
  color: var(--cyan);
  text-decoration-color: rgba(141, 220, 255, 0.45);
  text-underline-offset: 0.22em;
}

a:hover,
a:focus-visible {
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 0.4rem;
}

h1,
h2 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.3rem, 5vw, 3.9rem);
  max-width: 16ch;
}

h2 {
  font-size: clamp(1.9rem, 3.6vw, 3rem);
  max-width: 20ch;
}

p {
  margin: 0;
}

/* Nothing sits flush against the viewport edge — the instrument needs air on
   every side, including inside the landing-page embed. */
.page {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: clamp(1.4rem, 3.2vw, 3rem);
  display: grid;
  gap: clamp(1.7rem, 3.4vw, 2.8rem);
}

.kicker {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 500;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 2.1vw, 1.6rem);
  backdrop-filter: blur(14px);
}

.section-intro {
  display: grid;
  gap: 0.85rem;
  max-width: 46rem;
  margin-bottom: clamp(1.2rem, 2.4vw, 1.9rem);
}

.section-intro p:not(.kicker) {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
}

/* Header */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.7rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.5rem;
  letter-spacing: 0.03em;
  color: var(--gold);
}

.brand-sub {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: var(--dim);
}

.masthead-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  font-size: 0.9rem;
}

/* Deck */

.deck {
  display: grid;
  gap: 1rem;
  justify-items: start;
}

.lede {
  max-width: 44rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.08rem);
  line-height: 1.78;
}

.deck-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.2rem;
}

.button,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.75rem 1.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button {
  background: linear-gradient(135deg, var(--gold), #f6e3b4);
  color: #07111b;
  box-shadow: 0 14px 30px rgba(244, 191, 112, 0.2);
}

.button-secondary {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(8, 16, 27, 0.62);
  color: var(--text);
}

.button:hover,
.button:focus-visible,
.button-secondary:hover,
.button-secondary:focus-visible {
  transform: translateY(-2px);
}

.button[disabled] {
  cursor: progress;
  opacity: 0.72;
  transform: none;
}

.status {
  color: var(--dim);
  font-size: 0.92rem;
}

.status[data-tone="live"] {
  color: var(--teal);
}

.status[data-tone="warn"] {
  color: var(--gold);
}

/* Instrument */

.instrument {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(min(100%, 20rem), 0.98fr);
  gap: clamp(1rem, 2vw, 1.5rem);
  align-items: stretch;
}

.wheel-card {
  display: grid;
  gap: 1rem;
  margin: 0;
  align-content: start;
}

.wheel-frame {
  position: relative;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.wheel-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.wheel-label {
  position: absolute;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: clamp(0.56rem, 1.4vw, 0.68rem);
  line-height: 1.5;
  color: var(--dim);
}

/* The ring is drawn at 0.285 of the frame, so the side labels stay under 18%
   of the width and never sit on top of an arc. */
.wheel-label--spring,
.wheel-label--autumn {
  left: 50%;
  max-width: 44%;
  transform: translateX(-50%);
}

.wheel-label--summer,
.wheel-label--winter {
  top: 50%;
  max-width: 18%;
  transform: translateY(-50%);
}

.wheel-label--spring {
  top: 0.2rem;
}

.wheel-label--autumn {
  bottom: 0.2rem;
}

.wheel-label--summer {
  right: 0;
}

.wheel-label--winter {
  left: 0;
}

.wheel-frame[data-movement="spring"] .wheel-label--spring,
.wheel-frame[data-movement="summer"] .wheel-label--summer,
.wheel-frame[data-movement="autumn"] .wheel-label--autumn,
.wheel-frame[data-movement="winter"] .wheel-label--winter {
  color: var(--text);
}

/* Width and base size are set from the drawn hub in demo.js so the movement
   name never spills onto the ring, at any frame size. */
.wheel-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46%;
  font-size: 1.6rem;
  text-align: center;
  display: grid;
  gap: 0.25rem;
}

.wheel-center-kicker {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  color: var(--dim);
}

.wheel-center-name {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1em;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.wheel-center-phase {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.wheel-frame[data-compact="true"] .wheel-center-kicker {
  display: none;
}

.wheel-frame[data-compact="true"] .wheel-center-phase {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}

.wheel-card figcaption {
  color: var(--dim);
  font-size: 0.88rem;
  line-height: 1.7;
  border-top: 1px solid var(--line-soft);
  padding-top: 0.9rem;
}

/* HUD */

.hud {
  display: grid;
  gap: 1.15rem;
  align-content: start;
}

.hud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.channel-badge {
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--cyan);
  color: #05101a;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.channel-badge[data-channel="advisory"] { background: #63d8d0; }
.channel-badge[data-channel="warning"] { background: var(--gold); }
.channel-badge[data-channel="critical"] { background: #ff9878; }
.channel-badge[data-channel="recovery"] { background: #7fe6b4; }
.channel-badge[data-channel="opportunity"] { background: #ffd479; }
.channel-badge[data-channel="handoff"] { background: #c3aaff; }

.hud-event {
  font-size: 1.06rem;
  font-weight: 500;
  word-break: break-word;
}

.vector {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 1.05rem 0;
}

.vector-glyph {
  position: relative;
  width: 5.5rem;
  aspect-ratio: 1 / 1;
}

.vector-glyph canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.vector-rows {
  display: grid;
  gap: 0.6rem;
  margin: 0;
}

.vector-row dt {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.vector-row dt span {
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: none;
}

.vector-row dd {
  margin: 0.3rem 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.8rem;
  gap: 0.6rem;
  align-items: center;
}

.meter {
  display: block;
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  transition: width 420ms ease;
}

.vector-row dd b {
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  text-align: right;
}

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.2rem, 1fr));
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chips li {
  display: grid;
  gap: 0.15rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line-soft);
  border-radius: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
}

.chips span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
}

.chips b {
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
}

.hud-notes {
  display: grid;
  gap: 0.7rem;
  margin: 0;
  border-top: 1px solid var(--line-soft);
  padding-top: 1rem;
}

.hud-notes dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--gold);
}

.hud-notes dd {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.hud-notes b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Gate */

.gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}

.counters {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.7rem, 1.6vw, 1.2rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.counter {
  display: grid;
  gap: 0.2rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}

.counter b {
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums lining-nums;
}

.counter span {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
}

.counter--admit b { color: var(--teal); }
.counter--duplicate b { color: var(--cyan); }
.counter--reject b { color: var(--gold); }

.log-card,
.json-card {
  display: grid;
  gap: 0.9rem;
  align-content: start;
  min-width: 0;
}

.log-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.contract-source {
  font-size: 0.76rem;
  color: var(--dim);
}

.log {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.log li {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.7rem;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
  line-height: 1.5;
}

.log-empty {
  display: block !important;
  color: var(--dim);
}

.log-verdict {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.66rem;
  font-weight: 700;
  align-self: center;
}

.log li[data-verdict="admitted"] .log-verdict { color: var(--teal); }
.log li[data-verdict="duplicate"] .log-verdict { color: var(--cyan); }
.log li[data-verdict="rejected"] .log-verdict { color: var(--gold); }

.log-body {
  min-width: 0;
}

.log-body strong {
  font-weight: 500;
  color: var(--text);
}

.log-body em {
  display: block;
  font-style: normal;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.json {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  border: 1px solid var(--line-soft);
  background: rgba(2, 7, 14, 0.72);
  color: var(--muted);
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.65;
  overflow-x: auto;
  max-height: 22rem;
}

/* Mapping */

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: clamp(0.8rem, 1.8vw, 1.2rem);
  margin: 0;
}

.mapping-item {
  display: grid;
  gap: 0.4rem;
  align-content: start;
}

.mapping-item dt {
  font-size: 0.95rem;
  font-weight: 700;
}

.mapping-item dd {
  margin: 0;
  color: var(--dim);
  font-size: 0.88rem;
}

.mapping-item b {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

/* Provenance */

.provenance-card {
  display: grid;
  gap: 1rem;
  justify-items: start;
  border-color: rgba(244, 191, 112, 0.26);
}

.badge {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(244, 191, 112, 0.4);
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  font-weight: 700;
}

.provenance-card p:not(.badge) {
  max-width: 48rem;
  color: var(--muted);
  line-height: 1.78;
}

.provenance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 0.88rem;
}

/* Embed mode: the landing page frames this document at roughly 34rem tall,
   so the embed shows the instrument only and sends sound to the full page. */

.embed-only {
  display: none;
}

.is-embedded .standalone-only {
  display: none;
}

.is-embedded .embed-only {
  display: inline-flex;
}

.is-embedded p.embed-only {
  display: block;
}

.is-embedded .page {
  padding: clamp(0.9rem, 2.2vw, 1.4rem);
  gap: 1rem;
}

.is-embedded .deck {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.3rem 1.5rem;
}

.is-embedded .kicker,
.is-embedded h1,
.is-embedded .lede {
  grid-column: 1;
}

.is-embedded .deck-actions {
  grid-column: 2;
  grid-row: 1 / span 3;
  margin: 0;
}

.is-embedded h1 {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  max-width: 24ch;
}

.is-embedded .lede {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 52ch;
}

.is-embedded .status {
  display: none;
}

.is-embedded .card {
  padding: 1rem 1.1rem;
}

.is-embedded .wheel-frame {
  max-width: min(19rem, 56vh);
}

.is-embedded .wheel-card figcaption,
.is-embedded .hud-notes,
.is-embedded .chips {
  display: none;
}

.is-embedded .hud {
  gap: 0.85rem;
}

.is-embedded .vector {
  grid-template-columns: 4.6rem minmax(0, 1fr);
  padding: 0.8rem 0;
}

.is-embedded .vector-glyph {
  width: 4.6rem;
}

.is-embedded .chips li {
  padding: 0.45rem 0.6rem;
}

/* A narrow embed cannot hold the readout as well, so it keeps the promise the
   landing page makes: watch the season wheel move. */
@media (max-width: 780px) {
  .is-embedded .hud {
    display: none;
  }

  .is-embedded .wheel-frame {
    max-width: 15rem;
  }
}

@media (max-width: 940px) {
  .instrument {
    grid-template-columns: minmax(0, 1fr);
  }

  .gate-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 620px) {
  .brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .counters {
    grid-template-columns: minmax(0, 1fr);
  }

  .counter {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: baseline;
    gap: 0.8rem;
  }

  .log li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  html {
    scroll-behavior: auto;
  }
}
