/* theme.css - Squall Design System Implementation (rain/storm palette, 02/11) */
:root {
  /* Color Tokens */
  --bg: #090d14;
  --surface: #121722;
  --surface-2: #171e2b;
  --line: rgba(173,208,255,.09);
  --line-2: rgba(173,208,255,.16);
  --text: #eaf1fb;
  --text-2: #a7b4cb;
  --muted: #74819b;
  --accent: #4fc3f7;
  --accent-2: #bfe8ff;
  --ink: #051320;
  --up: #39d98a;
  --down: #ff6b6b;
  --terrain: #0b1424;
  
  /* Legacy Tokens for Backward Compatibility */
  --panel: var(--surface);
  --panel2: var(--surface-2);
  --acc: var(--accent);
  --acc2: var(--accent-2);
  --text2: var(--text-2);
  --line2: var(--line-2);
  --display: 'Instrument Serif', Georgia, serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --grad: none;
  --grain: none;
  
  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  
  /* Spacing */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-7: 56px;
  --space-8: 64px;
  
  /* Motion */
  --motion-fast: 180ms ease-out;
  --motion-normal: 240ms ease-out;
  
  /* Border Radius */
  --radius-1: 4px;
  --radius-2: 8px;
  --radius-3: 12px;
  --radius-4: 14px;
  --radius-5: 20px;
  --radius-6: 999px;
  
  /* Shadows */
  --shadow-1: 0 30px 80px -40px rgba(0,0,0,.7);
  --shadow-2: 0 1px 0 rgba(255,255,255,.04);
}

/* Halloween override removed 02/11: the rain/storm palette (Squall) replaces the gold skin this was built for;
   html[data-event="halloween"] still gets set by public/js/boot.js until it expires on its own, it's just inert now. */

/* Base Styles */
* {
  box-sizing: border-box;
}

html {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-size: clamp(16px, 2.5vw, 18px);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: .98;
  letter-spacing: -.01em;
  margin-top: 0;
  margin-bottom: var(--space-2);
  text-transform: none;
}

h1 {
  font-size: clamp(44px, 6.4vw, 92px);
  text-transform: none;
}

h2 {
  font-size: clamp(36px, 4vw, 56px);
}

h3 {
  font-size: clamp(24px, 3vw, 32px);
}

h4 {
  font-size: clamp(20px, 2.5vw, 24px);
}

p {
  margin-top: 0;
  margin-bottom: var(--space-2);
  font-size: clamp(16px, 2.5vw + 1px, 18px);
  line-height: 1.55;
}

b {
  font-weight: 600;
}

small {
  font-size: .875em;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--motion-fast);
}

a:hover {
  color: var(--accent-2);
}

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Utility Classes */
.clamp {
  font-size: clamp(16px, 2.5vw, 18px);
}

/* Top Bar */
.top {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background-color: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-display);
}

.brand .mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: var(--accent);
  border-radius: var(--radius-1);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 600;
  font-family: var(--font-display);
}

.brand .word {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  text-transform: none;
}

.brand .word small {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.nav a {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  text-transform: none;
}

.nav a:hover {
  color: var(--accent);
}

.right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pill {
  padding: 6px 12px;
  border-radius: var(--radius-6);
  background-color: var(--surface-2);
  color: var(--text);
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
  height: 48px;
  border-radius: var(--radius-3);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--motion-fast);
  text-decoration: none;
}

.btn.primary {
  background-color: var(--accent);
  color: var(--ink);
}

.btn.primary:hover {
  background-color: var(--accent-2);
}

.btn.ghost {
  border: 1px solid var(--line-2);
  color: var(--text);
  background-color: transparent;
}

.btn.ghost:hover {
  background-color: var(--surface-2);
}

#soundBtn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

/* Ticker */
.ticker {
  position: relative;
  height: 40px;
  overflow: hidden;
  background-color: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tk-hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  animation: ticker-scroll 30s linear infinite;
}

.tk-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  animation: ticker-scroll 30s linear infinite;
  animation-delay: -15s;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Section Shells */
.panel {
  background-color: var(--surface);
  border-radius: var(--radius-5);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(var(--shadow-2), var(--shadow-2));
}

.pc {
  padding: var(--space-3);
}

.pc-in {
  max-width: 1200px;
  margin: 0 auto;
}

.p-hero {
  padding: var(--space-5) var(--space-3);
}

.p-hero .pc-in {
  padding-top: clamp(64px, 9vh, 112px);
}

.num {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

/* Hero Section */
.hero-grid.has-book {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

.hero-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kicker {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.title.huge {
  font-size: clamp(44px, 6.4vw, 92px);
  line-height: .98;
  letter-spacing: -.01em;
  text-transform: none;
  margin-bottom: var(--space-2);
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: none;
}

.hero-accent {
  font-style: italic;
  color: var(--accent);
}

.hero-live {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  margin: 18px 0 0;
  font: 500 14px/1.5 var(--mono);
  color: var(--muted);
}

.hero-live b {
  color: var(--text);
  font-weight: 500;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.live-dot::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 4px 1px rgba(233, 162, 59, 0.5);
}

.tag {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--space-2);
}

.hero-act {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.cta-mega {
  padding: 0 var(--space-4);
  height: 64px;
  font-size: 1.25rem;
  font-weight: 600;
}

.demo-note {
  margin-top: var(--space-3);
  font-size: .875rem;
  color: var(--muted);
}

/* Pot Panel */
section.hero-roll {
  position: relative;
  background-color: var(--terrain);
  border-radius: var(--radius-5);
  overflow: hidden;
  padding: 28px;
  margin-top: var(--space-4);
}

svg.terrain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

.terrain-line {
  stroke: rgba(123,154,255,.14);
  stroke-width: 1;
}

.pot-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: var(--space-3);
}

.pot-figure {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  color: var(--accent);
  margin: 18px 0 8px;
}

svg.gauge {
  width: 220px;
  height: 132px;
  display: block;
  margin-top: 18px;
}

.gauge-track {
  stroke: var(--line-2);
  stroke-width: 6;
  stroke-linecap: round;
  fill: none;
}

.gauge-fill {
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  fill: none;
  transition: stroke-dashoffset var(--motion-normal);
}

.roll-rows {
  margin-top: 18px;
}

.roll-button {
  width: 100%;
  padding: 0 var(--space-4);
  height: 48px;
  margin-top: var(--space-3);
  font-weight: 600;
  background-color: var(--accent);
  color: var(--ink);
}

.roll-button:disabled {
  opacity: .55;
}

.roll-mini-hits h3 {
  margin-bottom: var(--space-2);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}

.roll-mini-hits li {
  display: flex;
  justify-content: space-between;
  padding: var(--space-1) 0;
  font-size: .875rem;
  border-bottom: 1px solid var(--line);
}

.roll-mini-hits li:last-child {
  border-bottom: none;
}

.roll-mini-hits b {
  color: var(--up);
}

.netviz.is-hidden {
  display: none;
}

/* Flow Timeline */
.flow {
  position: relative;
  padding: var(--space-3) 0;
}

.flow-rail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: var(--line-2);
  z-index: 1;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 2;
}

.flow-num {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .75rem;
  font-weight: 600;
  color: var(--text);
  width: 10px;
  height: 10px;
  background-color: var(--accent);
  border: none;
}

.flow-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  margin-bottom: var(--space-1);
}

.flow-line {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-2);
}

/* Section 03 */
.how {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}

.hc {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.hc .n {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--muted);
}

.hc h3 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: var(--space-1);
  text-transform: none;
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: none;
}

.worked-example {
  margin-top: var(--space-3);
  background-color: var(--surface-2);
  border-radius: var(--radius-4);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: .875rem;
  line-height: 1.5;
}

.strat-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  margin-bottom: var(--space-3);
  text-transform: none;
}

.strats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-3);
}

.strat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.strat h4 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 0;
  text-transform: none;
}

.strat p {
  font-size: 1rem;
  line-height: 1.55;
}

.strat b {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
}

.strat small {
  font-size: .75rem;
  color: var(--muted);
}

/* Roll Section */
.roll-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-3);
}

.roll-tag {
  font-size: .875rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
}

.roll-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 0;
  text-transform: none;
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: none;
}

.roll-pot {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  margin: var(--space-4) 0;
}

.roll-table-container {
  overflow-x: auto;
  margin-bottom: var(--space-3);
}

.roll-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: .875rem;
}

.roll-table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  border-bottom: 1px solid var(--line);
}

.roll-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.roll-chip.win {
  color: var(--up);
}

.roll-chip.lose {
  color: var(--down);
}

.roll-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  font-size: .875rem;
}

.roll-verify {
  margin-top: var(--space-3);
  text-align: center;
}

/* Footer */
.foot {
  background-color: var(--surface);
  border-top: 1px solid var(--line);
  padding: var(--space-4) var(--space-3);
  margin-top: var(--space-5);
}

.copy {
  text-align: center;
  font-size: .875rem;
  color: var(--muted);
}

/* Studio Page */
.studio {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.studio-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 720px;
}

.studio-card {
  background-color: var(--surface);
  border-radius: var(--radius-5);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  padding: var(--space-4);
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(var(--shadow-2), var(--shadow-2));
}

.studio-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.preset-card {
  background-color: var(--surface-2);
  border-radius: var(--radius-4);
  border: 1px solid var(--line);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--motion-fast);
  position: relative;
}

.preset-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.preset-card:hover {
  border-color: var(--accent);
}

.preset-card.selected {
  border: 1px solid var(--accent);
  background-color: color-mix(in srgb, var(--accent), var(--surface-2) 8%);
}

.preset-svg {
  width: 100%;
  height: 120px;
  margin-bottom: var(--space-2);
}

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line-2);
  border-radius: 2px;
  outline: none;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,.2);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--line-2);
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.studio input,
.studio textarea,
.studio select {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-3);
  background-color: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text);
  transition: all var(--motion-fast);
}

.studio input:focus,
.studio textarea:focus,
.studio select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.drop-zone {
  border: 2px dashed var(--line-2);
  border-radius: var(--radius-3);
  padding: var(--space-4);
  text-align: center;
  transition: all var(--motion-fast);
}

.drop-zone:hover {
  border-color: var(--accent);
}

details.advanced summary {
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  background-color: var(--surface-2);
  border-radius: var(--radius-3);
  font-weight: 500;
}

.summary {
  position: sticky;
  top: 88px;
  z-index: 10;
  background-color: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
}

.summary-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  margin-bottom: var(--space-2);
  text-transform: none;
  font-family: var(--font-display);
  font-weight: 400;
  text-transform: none;
}

.receipt {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: var(--space-3);
  background-color: var(--surface-2);
  border-radius: var(--radius-4);
  overflow: hidden;
}

.receipt > div {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  font-size: .875rem;
  border-bottom: 1px solid var(--line);
}

.receipt > div:last-child {
  border-bottom: none;
}

.receipt span {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  text-align: left;
}

.receipt b {
  font-family: var(--font-mono);
  font-size: 14px;
  text-align: right;
}

.summary-cta {
  width: 100%;
  padding: 0 var(--space-4);
  height: 48px;
  margin-top: var(--space-3);
  font-weight: 600;
}

.summary-cta[disabled] {
  opacity: .55;
}

.summary-note {
  margin-top: var(--space-3);
  font-size: .875rem;
  color: var(--muted);
}

/* Hidden Elements */
.king.empty,
.k-pic,
.hud,
.radar,
.gh,
.sheet-bg,
.hero-head::before,
body::before,
.rail,
.progress,
.glow,
.intro,
.roll-tapes,
.roll-vessel,
.sticker {
  display: none !important;
}

.empty {
  border-radius: 14px;
  padding: 24px;
}

/* Responsive Design */
@media (max-width: 760px) {
  .hero-grid.has-book {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  
  .how {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  
  .preset-row {
    grid-template-columns: 1fr;
  }
  
  .flow-step {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  
  .flow-rail {
    display: none;
  }
  
  .flow-num {
    position: static;
    margin-bottom: var(--space-1);
  }
  
  .flow-title {
    font-size: 24px;
  }
  
  .panel {
    padding: var(--space-3);
  }
  
  .pc {
    padding: var(--space-2);
  }
  
  .p-hero {
    padding: var(--space-4) var(--space-2);
  }
  
  h1 {
    font-size: 44px;
  }
  
  .num {
    font-size: 1.25rem;
  }
  
  .studio-card {
    padding: var(--space-3);
  }
  
  .summary {
    top: 60px;
    padding: var(--space-2);
  }
  
  .summary-title {
    font-size: 24px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
