/* Dellz Car Development - workshop spec-sheet look: steel greys, amber for power, blue for torque/data */
:root {
  --bg: #111215;
  --surface: #191b1f;
  --surface-2: #22252a;
  --line: #2e3138;
  --fg: #ecebe7;
  --muted: #9b9da4;
  --amber: #ffad1f;
  --blue: #52a9ff;
  --good: #41c97d;
  --bad: #ff5c5c;
  --on-amber: #111215;
  --display: 'Saira Condensed', 'Arial Narrow', sans-serif;
  --body: 'Figtree', 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f1ed; --surface: #ffffff; --surface-2: #eeede8; --line: #d9d7d0; --fg: #1b1c1f; --muted: #62646b;
    --amber: #b86e00; --blue: #1c68bd; --good: #17904f; --bad: #cf3434; --on-amber: #ffffff; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f1ed; --surface: #ffffff; --surface-2: #eeede8; --line: #d9d7d0; --fg: #1b1c1f; --muted: #62646b;
  --amber: #b86e00; --blue: #1c68bd; --good: #17904f; --bad: #cf3434; --on-amber: #ffffff; color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.55; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); text-transform: uppercase; line-height: 1.02; margin: 0; text-wrap: balance; letter-spacing: 0.01em; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.9em; }

.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* Header */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .wrap { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 54px; height: 54px; border-radius: 50%; display: block; flex: none; }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 20px; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1; }
.brand-name small { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.22em; color: var(--muted); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; padding: 6px 11px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); background: var(--surface-2); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.credits { font-family: var(--mono); font-size: 12px; padding: 5px 10px; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); }

/* Buttons and inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 18px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea {
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; max-width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--amber); }
input[type="color"] { width: 44px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

/* Tool layout */
.tool-head { padding-block: 28px 18px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.tool-head > div { min-width: 0; }
.tool-head h1 { font-size: clamp(34px, 5vw, 52px); font-weight: 800; }
.tool-head p { color: var(--muted); max-width: 62ch; margin-top: 6px; }
.tool { display: grid; grid-template-columns: 340px 1fr; gap: 20px; padding-bottom: 48px; align-items: start; }
.tool > * { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.panel-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel h2 { font-size: 19px; font-weight: 700; letter-spacing: 0.03em; }
.group { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: none; padding-bottom: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--amber); color: var(--fg); background: color-mix(in srgb, var(--amber) 15%, transparent); }
.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 24px 16px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--amber); color: var(--fg); }
.dropzone strong { display: block; color: var(--fg); margin-bottom: 4px; }
.stage { position: relative; height: 620px; overflow: hidden; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage-tag { position: absolute; left: 12px; top: 12px; }
.notice { padding: 12px 14px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 14px; }
.notice.bad { color: var(--bad); }
.notice.good { color: var(--good); }
.pill { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.pill.amber { color: var(--amber); }
.tabular { font-variant-numeric: tabular-nums; }
.busy::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { border-top: 1px solid var(--line); padding-block: 28px; color: var(--muted); font-size: 13px; }
.footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer nav { display: flex; gap: 16px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .tool { grid-template-columns: 1fr; }
  .stage { height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Live radio in the header */
.radio { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-2); }
.radio-play { width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--amber); color: var(--on-amber); display: grid; place-items: center; cursor: pointer; flex: none; }
.radio-play:focus-visible, .radio select:focus-visible, .radio-vol:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.radio-live { width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.radio[data-state="on"] .radio-live { background: var(--bad); animation: radio-pulse 1.6s ease-in-out infinite; }
.radio[data-state="loading"] .radio-live { background: var(--amber); }
.radio select { border: none; background: transparent; padding: 2px 2px; font-size: 13px; font-weight: 600; color: var(--fg); cursor: pointer; }
.radio select option { background: var(--surface); color: var(--fg); }
.radio-vol { width: 70px; }
.radio-resume .radio-play { animation: radio-pulse 1.2s ease-in-out infinite; }
@keyframes radio-pulse { 50% { opacity: 0.35; } }
@media (max-width: 600px) { .radio-vol { display: none; } }
@media (prefers-reduced-motion: reduce) { .radio-live, .radio-play { animation: none !important; } }

/* Christmas background (assets/christmas.js): one canvas behind everything */
.xmas-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.topbar, main, .footer { position: relative; z-index: 1; }
.topbar { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(6px); }

/* Northern History RP bauble (assets/rp.js) */
.rp-bauble { position: fixed; z-index: 30; width: 110px; pointer-events: none; }
.rp-swing { display: flex; flex-direction: column; align-items: center; transform-origin: 50% 0; animation: rp-swing 3.4s ease-in-out infinite; }
.rp-bauble:hover .rp-swing { animation-duration: 1.2s; }
.rp-string { width: 2px; height: 46px; background: linear-gradient(#e8c35a, #b8902e); }
.rp-cap { width: 22px; height: 10px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, #8a6a20, #ffe08a, #8a6a20); margin-bottom: -3px; position: relative; z-index: 1; }
.rp-ball { pointer-events: auto; width: 96px; height: 96px; padding: 0; border-radius: 50%; border: 2px solid #b26bff; background: #0d0518; cursor: pointer; overflow: hidden; display: block;
  box-shadow: 0 0 18px rgba(170, 80, 255, 0.85), 0 0 42px rgba(170, 80, 255, 0.35), inset -10px -14px 22px rgba(0, 0, 0, 0.45); transition: transform 0.2s; }
.rp-ball img { width: 100%; height: 100%; display: block; }
.rp-ball:hover { transform: scale(1.08); }
.rp-ball:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.rp-tag { margin-top: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; color: #f0e6ff;
  background: rgba(60, 20, 100, 0.85); border: 1px solid #8a4ddb; padding: 2px 8px; border-radius: 10px; }
@keyframes rp-swing { 0%, 100% { transform: rotate(7deg); } 50% { transform: rotate(-7deg); } }

.rp-card { display: flex; gap: 20px; align-items: center; padding: 20px; border-color: #6b35b8; box-shadow: 0 0 30px rgba(140, 60, 230, 0.25); }
.rp-card .rp-logo { width: 160px; height: 160px; border-radius: 50%; flex: none; box-shadow: 0 0 24px rgba(170, 80, 255, 0.5); }
.rp-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rp-body h3 { font-size: 30px; }
.rp-live { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 0; }
.rp-live b { color: var(--fg); }
.rp-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.rp-live[data-online="true"] .rp-dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
.rp-live[data-online="false"] .rp-dot { background: var(--bad); }
.rp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-connect { background: #8a3df0; border-color: #8a3df0; color: #fff; }
.rp-connect:hover { background: #7a2ee0; border-color: #b26bff; }
.rp-discord { background: #5865f2; border-color: #5865f2; color: #fff; }
.rp-ip { font-size: 13px; color: var(--muted); margin: 0; }
.rp-ip kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.rp-copy { font: inherit; font-size: 12px; background: none; border: 1px solid var(--line); color: var(--fg); border-radius: 4px; padding: 1px 6px; cursor: pointer; margin-left: 4px; }
.rp-pop { position: fixed; z-index: 40; right: 16px; width: min(560px, calc(100vw - 32px)); background: var(--surface); }
.rp-pop .rp-logo { width: 120px; height: 120px; }
.rp-close { position: absolute; top: 6px; right: 10px; background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }
@media (max-width: 600px) {
  .rp-bauble { width: 76px; }
  .rp-ball { width: 62px; height: 62px; }
  .rp-string { height: 30px; }
  .rp-tag { font-size: 9px; }
  .rp-card { flex-direction: column; text-align: center; }
  .rp-actions { justify-content: center; }
}

/* text that sits straight on the animated background stays readable over the town */
main h1, main h2, main .section > p, main .tool-head p, main .hero p, main .label { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 14px rgba(5, 6, 20, 0.95); }
.panel h1, .panel h2, .panel p, .panel .label { text-shadow: none; }

/* "Est. 2020" under the wordmark */
.brand-est { display: block; margin-top: 3px; font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: 0.3em; text-transform: uppercase; color: var(--amber); }

/* Christmas border round the radio: candy-cane stripes, holly and a cap of snow */
.radio { position: relative; border: 3px solid transparent; border-radius: 22px;
  background: linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
              repeating-linear-gradient(45deg, #d4142e 0 7px, #ffffff 7px 14px) border-box;
  box-shadow: 0 0 12px rgba(212, 20, 46, 0.35); }
.radio::before { content: ""; position: absolute; left: -10px; top: -12px; width: 34px; height: 26px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 26'%3E%3Cpath fill='%231f7a3a' d='M3 15c3-1 4-4 3-7 3 1 5-1 6-3 1 3 3 4 6 4-2 2-2 5 0 7-3 0-5 1-6 4-1-3-3-4-6-3 1-1 0-2-3-2z'/%3E%3Cpath fill='%232a9a4a' d='M31 15c-3-1-4-4-3-7-3 1-5-1-6-3-1 3-3 4-6 4 2 2 2 5 0 7 3 0 5 1 6 4 1-3 3-4 6-3-1-1 0-2 3-2z'/%3E%3Ccircle cx='15' cy='16' r='3' fill='%23e3122d'/%3E%3Ccircle cx='19.5' cy='17.5' r='3' fill='%23c40f27'/%3E%3Ccircle cx='17' cy='12.5' r='3' fill='%23ff2a45'/%3E%3Ccircle cx='16' cy='11.5' r='.9' fill='%23fff' opacity='.8'/%3E%3C/svg%3E") no-repeat center / contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.radio::after { content: ""; position: absolute; left: 22px; right: 18px; top: -6px; height: 7px; pointer-events: none; border-radius: 6px 6px 3px 3px;
  background: radial-gradient(circle at 10% 70%, #fff 3px, transparent 3.5px), radial-gradient(circle at 35% 60%, #fff 4px, transparent 4.5px),
              radial-gradient(circle at 62% 70%, #fff 3px, transparent 3.5px), radial-gradient(circle at 88% 60%, #fff 4px, transparent 4.5px), #f2f6ff;
  opacity: 0.95; }
