/* Chain Symphony — a midnight concert hall. Fraunces + Manrope, gold & rose on ink, glass cards, legato motion. */
:root {
  --ink: #05030b;
  --ink-2: #0c0718;
  --plum: #1a1030;
  --glass: rgba(18, 11, 34, 0.56);
  --glass-2: rgba(28, 17, 52, 0.62);
  --hair: rgba(245, 236, 220, 0.10);
  --hair-2: rgba(245, 236, 220, 0.20);
  --gold: #f2c46d;
  --gold-2: #ffd99a;
  --rose: #ff6fa8;
  --aqua: #6ee7ff;
  --lilac: #b79cff;
  --cream: #f5ecdc;
  --muted: #a99fb8;
  --faint: #6c6380;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --r: 18px;
  color-scheme: dark;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--cream); font: 15px/1.5 var(--sans); overflow-x: clip; -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
.muted { color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- hall grid */
.hall {
  position: relative;
  height: 100svh;
  min-height: 660px;
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr) minmax(270px, 330px);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: 'top top top' 'brand brand brand' 'now hero orch' 'dock dock dock';
  gap: 0 clamp(14px, 2vw, 28px);
  padding: 0 clamp(14px, 2.4vw, 32px) clamp(14px, 2vw, 24px);
  isolation: isolate;
  overflow: clip;
}
.stage-wrap { position: absolute; inset: 0; z-index: -1; }
.stage-wrap canvas { display: block; width: 100%; height: 100%; }
/* no-WebGL fallback: a calm static stage; the music and data still work */
.nogl { position: absolute; inset: 0; background: radial-gradient(40% 35% at 50% 42%, rgba(255, 111, 168, 0.35), transparent 70%), radial-gradient(70% 50% at 50% 40%, rgba(91, 43, 214, 0.35), transparent 75%), var(--ink); }
.veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 45%, transparent 55%, rgba(5, 3, 11, 0.55) 100%),
    linear-gradient(180deg, rgba(5, 3, 11, 0.55) 0%, transparent 18%, transparent 78%, rgba(5, 3, 11, 0.7) 100%);
}

/* ---------------------------------------------------------------- header */
.top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 0 10px; min-width: 0; }
.mark { display: flex; align-items: center; gap: 12px; color: var(--cream); min-width: 0; }
.mark:hover { text-decoration: none; }
.glyph { width: 40px; height: 40px; flex: none; fill: none; stroke-linecap: round; }
.g-ring { stroke: var(--gold); stroke-width: 1.2; opacity: 0.7; }
.g-staff { stroke: var(--cream); stroke-width: 0.8; opacity: 0.35; }
.g-note { fill: var(--gold); animation: bob 2.4s ease-in-out infinite; }
.g-note2 { fill: var(--rose); animation-delay: -1.2s; }
.g-stem { stroke: var(--gold); stroke-width: 1.4; }
@keyframes bob { 50% { transform: translateY(-1.5px); } }
.word { display: flex; flex-direction: column; min-width: 0; }
.word b { font: 500 22px/1.05 var(--serif); font-style: italic; letter-spacing: -0.01em; font-variation-settings: 'opsz' 96; white-space: nowrap; }
.word i { font: 500 11px/1.4 var(--sans); font-style: normal; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--hair); backdrop-filter: blur(14px);
  font: 600 11px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.live .dot { background: var(--gold); box-shadow: 0 0 12px var(--gold); animation: pulse 2s ease-in-out infinite; }
.pill.warn .dot { background: var(--rose); box-shadow: 0 0 12px var(--rose); }
@keyframes pulse { 50% { opacity: 0.35; } }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--hair); backdrop-filter: blur(14px); cursor: pointer;
  transition: border-color 0.3s, background 0.3s;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--cream); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover, .icon-btn[aria-pressed='true'] { border-color: var(--gold); background: rgba(242, 196, 109, 0.12); }

.brandbar {
  grid-area: brand; justify-self: center;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: 100%; padding: 8px 14px; margin-bottom: 6px;
  border-radius: 14px; background: var(--glass); border: 1px solid var(--hair-2); backdrop-filter: blur(14px);
  font-size: 12px;
}
.bb-ticker { font: 600 14px/1 var(--serif); font-style: italic; color: var(--gold); }
.bb-label { font: 700 10px/1 var(--sans); letter-spacing: 0.2em; color: var(--muted); }
.bb-ca { font: 500 12px/1.35 var(--mono); overflow-wrap: anywhere; word-break: break-all; min-width: 0; }
.bb-copy, .bb-x { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--hair-2); background: transparent; color: var(--gold); font: 600 11px/1 var(--sans); cursor: pointer; white-space: nowrap; }
.bb-copy:hover, .bb-x:hover { background: rgba(242, 196, 109, 0.12); text-decoration: none; }

/* ---------------------------------------------------------------- hero */
.hero::before { content: ''; position: absolute; left: 50%; top: 62%; width: 130%; height: 70%; transform: translate(-50%, -50%); z-index: -1; background: radial-gradient(closest-side, rgba(5, 3, 11, 0.72), rgba(5, 3, 11, 0.35) 60%, transparent); pointer-events: none; }
.hero { position: relative; grid-area: hero; align-self: center; justify-self: center; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; max-width: 520px; padding: 0 8px; transition: opacity 1.2s ease, transform 1.2s ease; }
.hero.played { opacity: 0; transform: translateY(14px) scale(0.98); pointer-events: none; }
.start {
  position: relative; width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 1px solid rgba(242, 196, 109, 0.55);
  background: radial-gradient(circle at 35% 30%, rgba(255, 217, 154, 0.35), rgba(26, 16, 48, 0.75) 62%);
  box-shadow: 0 0 60px rgba(242, 196, 109, 0.25), inset 0 0 30px rgba(255, 111, 168, 0.15);
  backdrop-filter: blur(6px);
  transition: transform 0.4s cubic-bezier(.2, .8, .2, 1), box-shadow 0.4s;
}
.start:hover { transform: scale(1.06); box-shadow: 0 0 90px rgba(242, 196, 109, 0.4), inset 0 0 30px rgba(255, 111, 168, 0.25); }
.start svg { width: 38px; height: 38px; fill: var(--gold-2); margin-left: 5px; filter: drop-shadow(0 0 10px rgba(242, 196, 109, 0.6)); }
.start-ring { position: absolute; inset: -10px; border-radius: 50%; border: 1px solid rgba(242, 196, 109, 0.35); animation: ripple 3.2s cubic-bezier(.2, .6, .3, 1) infinite; }
.start-ring.r2 { animation-delay: -1.6s; border-color: rgba(255, 111, 168, 0.3); }
@keyframes ripple { from { transform: scale(0.92); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.hero-title { margin: 8px 0 0; font: 380 clamp(30px, 4.4vw, 56px)/1.02 var(--serif); letter-spacing: -0.025em; font-variation-settings: 'opsz' 144; text-shadow: 0 0 10px rgba(5, 3, 11, 0.85), 0 4px 40px rgba(5, 3, 11, 0.9); }
.hero-title em { font-style: italic; color: var(--gold-2); }
.hero-sub { margin: 0; max-width: 430px; font-size: 14px; color: rgba(245, 236, 220, 0.86); text-shadow: 0 0 6px rgba(5, 3, 11, 0.95), 0 0 18px rgba(5, 3, 11, 0.9), 0 0 36px rgba(5, 3, 11, 0.8); }

/* ---------------------------------------------------------------- cards */
.card {
  position: relative; align-self: end; min-width: 0;
  padding: 18px 18px 16px;
  border-radius: var(--r);
  background: linear-gradient(160deg, rgba(36, 22, 66, 0.55), rgba(12, 7, 24, 0.62));
  border: 1px solid var(--hair);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  transition: opacity 0.6s, transform 0.6s;
}
.card::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: linear-gradient(140deg, rgba(242, 196, 109, 0.35), transparent 35%, transparent 70%, rgba(255, 111, 168, 0.25)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.now { grid-area: now; }
.orch { grid-area: orch; }
.card-k { font: 700 10.5px/1 var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); margin-bottom: 12px; }
.card-k .muted { letter-spacing: 0.08em; text-transform: none; font-weight: 500; }
.now-key { display: flex; flex-direction: column; margin-bottom: 14px; }
.now-key span { font: 400 36px/1 var(--serif); font-style: italic; letter-spacing: -0.02em; font-variation-settings: 'opsz' 144; }
.now-key small { margin-top: 6px; font: 500 13px/1.3 var(--sans); color: var(--muted); }
.now-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 14px; margin: 0; font-size: 13px; align-items: baseline; }
.now-grid dt { font: 600 10.5px/1.6 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.now-grid dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.now-grid b { font-weight: 600; }
.now-grid a { font-family: var(--mono); font-size: 12.5px; }
.meter { display: inline-block; width: 64px; height: 5px; border-radius: 3px; background: rgba(245, 236, 220, 0.1); vertical-align: middle; margin-right: 6px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--rose)); border-radius: inherit; transition: width 0.8s ease; }
.now-wait { margin-top: 12px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 111, 168, 0.08); border: 1px dashed rgba(255, 111, 168, 0.3); font-size: 12px; color: var(--rose); }

.sections { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sections li button {
  width: 100%; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 7px 8px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left;
  transition: background 0.25s, opacity 0.25s;
}
.sections li button:hover { background: rgba(245, 236, 220, 0.05); }
.sections li button[aria-pressed='true'] { opacity: 0.38; }
.sections li button[aria-pressed='true'] .s-inst::after { content: ' · muted'; color: var(--rose); }
.s-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 0 var(--c); transition: box-shadow 0.25s, transform 0.25s; }
.s-dot.hit { box-shadow: 0 0 14px 3px var(--c); transform: scale(1.25); }
.s-name { display: flex; flex-direction: column; min-width: 0; }
.s-name b { font: 600 13px/1.25 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-inst { font: 400 12px/1.3 var(--serif); font-style: italic; color: var(--muted); }
.s-n { font: 500 12px/1 var(--mono); color: var(--cream); min-width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.rhythm { margin: 12px 2px 0; font-size: 11.5px; color: var(--faint); }

/* ---------------------------------------------------------------- dock */
.dock { grid-area: dock; display: flex; align-items: center; gap: 18px; padding-top: 14px; min-width: 0; }
.transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: none; }
.t-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--hair-2); backdrop-filter: blur(14px);
  font: 600 13px/1 var(--sans); cursor: pointer; white-space: nowrap; color: var(--cream);
  transition: background 0.3s, border-color 0.3s, transform 0.2s;
}
.t-btn:hover:not(:disabled) { border-color: var(--gold); text-decoration: none; }
.t-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.t-btn svg { width: 16px; height: 16px; fill: currentColor; }
.t-btn .i-stop { display: none; }
.t-btn.primary { background: linear-gradient(135deg, rgba(242, 196, 109, 0.95), rgba(255, 150, 140, 0.9)); color: #1b0f24; border-color: transparent; }
.t-btn.primary[aria-pressed='true'] { background: var(--glass); color: var(--cream); border-color: var(--gold); }
.t-btn.primary[aria-pressed='true'] .i-play { display: none; }
.t-btn.primary[aria-pressed='true'] .i-stop { display: inline; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rose); }
.t-btn.rec.on { border-color: var(--rose); color: var(--rose); }
.t-btn.rec.on .rec-dot { animation: pulse 1s ease-in-out infinite; box-shadow: 0 0 10px var(--rose); }
.t-btn.dl { color: var(--gold); }
.vol { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--hair); backdrop-filter: blur(14px); }
.vol svg { width: 16px; height: 16px; fill: var(--muted); flex: none; }
.vol input { width: 96px; }
input[type='range'] { -webkit-appearance: none; appearance: none; height: 20px; background: transparent; cursor: pointer; }
input[type='range']::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--gold), var(--rose)); }
input[type='range']::-moz-range-track { height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--gold), var(--rose)); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--cream); box-shadow: 0 0 12px rgba(242, 196, 109, 0.7); }
input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--cream); }

.ticker { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; justify-content: flex-end; flex: 1; min-width: 0; overflow: clip; mask-image: linear-gradient(90deg, transparent, #000 12%); }
.ticker li {
  flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--hair); backdrop-filter: blur(12px);
  font-size: 12px; white-space: nowrap; animation: tin 0.6s cubic-bezier(.2, .8, .2, 1);
}
@keyframes tin { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.ticker li i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
.ticker li b { font-weight: 600; }
.ticker li a { font: 500 11px/1 var(--mono); color: var(--muted); }
.ticker li a:hover { color: var(--gold); }
.ticker li.fail { border-color: rgba(255, 77, 109, 0.35); }

/* ambient mode: only the performance */
body.ambient .card, body.ambient .dock .ticker, body.ambient .hero, body.ambient .brandbar, body.ambient .word, body.ambient .pill { opacity: 0; pointer-events: none; }
body.ambient .transport { opacity: 0.25; transition: opacity 0.4s; }
body.ambient .transport:hover { opacity: 1; }

/* ---------------------------------------------------------------- explain + footer */
.explain { max-width: 1120px; margin: 0 auto; padding: clamp(48px, 7vw, 96px) clamp(16px, 3vw, 32px) 24px; }
.explain h2 { margin: 0 0 14px; font: 380 clamp(30px, 4vw, 48px)/1.05 var(--serif); letter-spacing: -0.02em; font-variation-settings: 'opsz' 144; }
.explain h2 em { color: var(--gold-2); }
.ex-lead { max-width: 720px; margin: 0 0 30px; color: var(--muted); font-size: 15.5px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.ex { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--r); background: linear-gradient(160deg, rgba(36, 22, 66, 0.5), rgba(12, 7, 24, 0.5)); border: 1px solid var(--hair); }
.ex b { font: 500 22px/1.1 var(--serif); font-style: italic; color: var(--gold-2); }
.ex span { font-size: 14px; color: var(--muted); }
.ex code { align-self: flex-start; margin-top: auto; padding: 4px 9px; border-radius: 8px; background: rgba(245, 236, 220, 0.06); font: 500 12px/1.4 var(--mono); color: var(--cream); }
.foot { max-width: 1120px; margin: 0 auto; padding: 18px clamp(16px, 3vw, 32px) 40px; }
.foot p { margin: 0; font-size: 12px; color: var(--faint); border-top: 1px solid var(--hair); padding-top: 18px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .hall { grid-template-columns: minmax(250px, 300px) minmax(0, 1fr) minmax(250px, 300px); }
  .ticker li:nth-child(n + 4) { display: none; }
}
@media (max-width: 880px) {
  .hall {
    height: auto; min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(54svh, auto) auto auto auto;
    grid-template-areas: 'top' 'brand' 'hero' 'dock' 'now' 'orch';
    gap: 14px;
  }
  .stage-wrap { bottom: auto; height: calc(84svh); }
  .stage-wrap .veil { background: radial-gradient(120% 80% at 50% 45%, transparent 55%, rgba(5, 3, 11, 0.5) 100%), linear-gradient(180deg, rgba(5, 3, 11, 0.5) 0%, transparent 15%, transparent 70%, var(--ink) 100%); }
  .top { padding-top: 14px; }
  .hero { align-self: end; padding-bottom: 8px; }
  .dock { flex-direction: column; align-items: stretch; gap: 12px; }
  .transport { justify-content: center; }
  .ticker { justify-content: flex-start; flex-wrap: wrap; mask-image: none; }
  .ticker li:nth-child(n + 4) { display: none; }
  .card { align-self: stretch; }
}
@media (max-width: 480px) {
  #fsBtn, #ambientBtn { display: none; }
  .word b { font-size: 19px; }
  .word i { font-size: 9.5px; letter-spacing: 0.16em; }
  .glyph { width: 34px; height: 34px; }
  .pill { padding: 6px 10px; letter-spacing: 0.1em; }
  .icon-btn { width: 34px; height: 34px; }
  .start { width: 88px; height: 88px; }
  .hero-sub { font-size: 13px; }
  .t-btn { height: 40px; padding: 0 13px; font-size: 12.5px; }
  .vol input { width: 70px; }
  .now-key span { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
