/* ============================================================================
 * main.css — Synthesizer 2027 : Hamburg Legacy Studio
 *
 * Dark, layered UI with a brass/gold Eurorack hardware accent — design tokens
 * and "module" feel borrowed from Sasha's DSP Lab. Pure native CSS3, no build.
 * ========================================================================== */

:root {
    /* layered surfaces (dark -> raised) */
    --bg-0: #08090c;
    --bg-1: #0d0f14;
    --bg-2: #12141c;
    --bg-3: #181b25;
    --bg-4: #20242f;

    --line: #262b38;
    --line-soft: #1c2029;
    --line-strong: #333a4a;

    --ink: #e8eaf2;
    --ink-dim: #aab2c2;     /* lifted for WCAG AA on dark surfaces */
    --ink-mute: #828ca3;    /* lifted for WCAG AA on small labels */
    --ink-faint: #3a4150;

    /* signature brass / gold hardware accent */
    --brass: #d9a441;
    --brass-bright: #f0c562;
    --brass-deep: #8a6520;
    --brass-glow: #d9a4414d;

    --accent: #ff2e88;
    --accent-soft: #ff2e8824;
    --accent-line: #ff2e8873;

    --cyan: #2ea3ff;
    --green: #16d68a;
    --amber: #ffb43a;

    --r-s: 6px;
    --r-m: 9px;
    --r-l: 14px;
    --shadow-card: 0 1px 0 #ffffff06 inset, 0 6px 22px -10px #000c;

    --f-display: "Space Grotesk", "Helvetica Neue", system-ui, sans-serif;
    --f-mono: "JetBrains Mono", "SFMono-Regular", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body.dark-theme {
    background-color: var(--bg-0);
    color: var(--ink);
    font-family: var(--f-display);
    margin: 0;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-shell { height: 100vh; display: flex; flex-direction: column; }

/* ---- header --------------------------------------------------------------- */
.app-header {
    height: 70px;
    flex: 0 0 70px;
    background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
.brand-title { display: flex; align-items: center; gap: 12px; }
.brand-title h1 { font-size: 1.2rem; margin: 0; letter-spacing: 0.3px; font-weight: 600; }
.badge {
    background: var(--brass);
    color: #1a1404;
    padding: 3px 7px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: var(--r-s);
    font-family: var(--f-mono);
    box-shadow: 0 0 14px var(--brass-glow);
}
.tagline { margin: 0; color: var(--ink-dim); font-size: 0.85rem; }

/* ---- layout --------------------------------------------------------------- */
.studio-container { display: flex; flex: 1 1 auto; min-height: 0; width: 100vw; }

.timeline-sidebar {
    width: 35%;
    max-width: 460px;
    border-right: 1px solid var(--line);
    background: var(--bg-1);
}
.sidebar-scroll-container { padding: 20px; height: 100%; overflow-y: auto; box-sizing: border-box; }

/* ---- timeline cards ------------------------------------------------------- */
.timeline-card {
    position: relative;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--r-m);
    padding: 16px 16px 16px 18px;
    margin-bottom: 16px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    box-shadow: var(--shadow-card);
}
.timeline-card::before {
    content: "";
    position: absolute;
    left: 0; top: 12px; bottom: 12px;
    width: 3px;
    border-radius: 3px;
    background: var(--line-strong);
    transition: background 0.2s ease;
}
.timeline-card:hover { border-color: var(--ink-mute); transform: translateY(-1px); }
.timeline-card.active { border-color: var(--brass); box-shadow: 0 0 18px var(--brass-glow), var(--shadow-card); }
.timeline-card.active::before { background: var(--brass); }
.timeline-card h3 { font-size: 1rem; margin: 0 0 6px; font-weight: 600; }
.timeline-card p { font-size: 0.84rem; color: var(--ink-dim); margin: 0; line-height: 1.5; }

.time-marker { font-family: var(--f-mono); font-weight: 700; color: var(--brass-bright); font-size: 1.05rem; margin-bottom: 6px; letter-spacing: 1px; }
.tech-tag {
    display: inline-block;
    font-size: 0.68rem;
    color: var(--accent);
    border: 1px solid var(--accent-line);
    background: var(--accent-soft);
    padding: 2px 7px;
    border-radius: var(--r-s);
    margin-top: 10px;
    font-family: var(--f-mono);
}

/* ---- sandbox -------------------------------------------------------------- */
.sandbox-workspace { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--bg-0); }

.node-canvas-wrapper {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
    background-color: var(--bg-1);
    background-image: radial-gradient(#1c2233 1px, transparent 0);
    background-size: 24px 24px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}
#node-canvas { position: absolute; inset: 0; display: block; }

.node-display-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 92%;
    max-width: 760px;
    pointer-events: none;
}
.node-block {
    background: rgba(18, 20, 28, 0.82);
    border: 1px solid var(--line-strong);
    border-top: 2px solid var(--brass-deep);
    border-radius: var(--r-m);
    padding: 14px 16px;
    min-width: 132px;
    text-align: center;
    backdrop-filter: blur(5px);
    box-shadow: var(--shadow-card);
}
.node-block#node-modifier { border-top-color: var(--brass); }
.node-block#node-output { border-top-color: var(--accent); }
.node-type { font-size: 0.58rem; letter-spacing: 2px; color: var(--ink-mute); display: block; font-family: var(--f-mono); }
.node-block h4 { margin: 6px 0 0; font-size: 0.92rem; font-weight: 600; color: var(--ink); }

.node-block-spacer { flex: 1 1 auto; height: 2px; position: relative; }
.node-block-spacer::before {
    content: "";
    position: absolute;
    inset: 0 8px;
    top: 50%;
    border-top: 1px dashed var(--line-strong);
}

/* ---- macro deck + rotary knobs ------------------------------------------- */
.macro-control-deck {
    flex: 0 0 170px;
    background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
}
.macro-knob-wrapper { display: flex; flex-direction: column; align-items: center; width: 30%; }
.macro-knob-wrapper label {
    font-family: var(--f-mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--ink-dim);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}
.knob-dial-container { position: relative; display: flex; flex-direction: column; align-items: center; }

.knob {
    width: 84px;
    height: 84px;
    touch-action: none;
    cursor: ns-resize;
    filter: drop-shadow(0 4px 8px #0008);
}
.knob-bezel { fill: var(--bg-4); stroke: var(--line-strong); stroke-width: 1.5; }
.knob-face { fill: #1b1e28; stroke: var(--brass-deep); stroke-width: 1; }
.knob-track { fill: none; stroke: var(--line); stroke-width: 4; stroke-linecap: round; }
.knob-value { fill: none; stroke: var(--brass); stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 0 4px var(--brass-glow)); }
.knob-pointer { stroke: var(--brass-bright); stroke-width: 3; stroke-linecap: round; }

/* native range input: kept for keyboard a11y, visually replaced by the knob */
.knob-dial-container input[type="range"] {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 84px; height: 84px;
    margin: 0;
    opacity: 0;
    pointer-events: none;          /* knob handles pointer; arrows still work on focus */
}
.knob-dial-container:has(input[type="range"]:focus-visible) .knob {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
    border-radius: 50%;
}
.knob-value-readout {
    font-family: var(--f-mono);
    font-size: 0.82rem;
    color: var(--brass-bright);
    margin-top: 10px;
    letter-spacing: 0.5px;
}

/* ---- toolbar -------------------------------------------------------------- */
.sandbox-toolbar {
    flex: 0 0 62px;
    background: var(--bg-0);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
}
.btn {
    border: none;
    padding: 10px 18px;
    font-weight: 600;
    border-radius: var(--r-s);
    cursor: pointer;
    font-size: 0.84rem;
    font-family: var(--f-display);
    transition: background 0.12s, box-shadow 0.12s, transform 0.06s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brass); color: #1a1404; box-shadow: 0 0 0 1px var(--brass-deep) inset; }
.btn-primary:hover { background: var(--brass-bright); }
.btn-primary.engine-on { background: var(--accent); color: #fff; box-shadow: 0 0 16px var(--accent-soft); }
.btn-secondary { background: var(--bg-3); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--bg-4); }
.btn-icon { display: inline-flex; align-items: center; }
.toolbar-divider { height: 24px; width: 1px; background: var(--line-strong); margin: 0 6px; }

.rec-dot { display: inline-block; width: 8px; height: 8px; background: var(--ink-mute); border-radius: 50%; margin-right: 7px; }
#btn-record-session.recording { border-color: var(--accent); color: var(--accent); }
#btn-record-session.recording .rec-dot { background: var(--accent); animation: pulse 1.2s infinite; }

@keyframes pulse { 0% { opacity: 0.35; } 50% { opacity: 1; } 100% { opacity: 0.35; } }

/* ---- back-to-timeline button --------------------------------------------- */
.btn-home {
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--ink-dim);
    font-family: var(--f-mono);
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    padding: 5px 10px;
    border-radius: var(--r-s);
    cursor: pointer;
    margin-right: 6px;
    transition: color 0.15s, border-color 0.15s;
}
.btn-home:hover { color: var(--ink); border-color: var(--ink-mute); }

/* ---- accessibility utilities --------------------------------------------- */
.visually-hidden {
    position: absolute !important; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.skip-link {
    position: fixed; top: 8px; left: 8px; z-index: 300;
    background: var(--brass); color: #1a1404; font-weight: 600;
    padding: 10px 16px; border-radius: var(--r-s);
    transform: translateY(-150%); transition: transform 0.15s ease;
    text-decoration: none;
}
.skip-link:focus { transform: translateY(0); }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.timeline-card:focus-visible { outline-offset: -2px; }

/* ---- workspace stage : node canvas + scope rack module ------------------- */
.stage { flex: 1 1 auto; min-height: 0; display: flex; border-bottom: 1px solid var(--line); }
.stage .node-canvas-wrapper { flex: 1 1 auto; min-width: 0; border-bottom: none; }

.rack-rail {
    flex: 0 0 230px;
    border-left: 1px solid var(--line);
    background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
    padding: 12px; display: flex; flex-direction: column; overflow: hidden;
}
.rack-module {
    background: var(--bg-2); border: 1px solid var(--line-strong);
    border-top: 2px solid var(--brass); border-radius: var(--r-m);
    padding: 10px; box-shadow: var(--shadow-card);
    display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
}
.rack-module-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.scope-title { font-family: var(--f-mono); font-size: 0.62rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-dim); }
.scope-live { font-family: var(--f-mono); font-size: 0.56rem; letter-spacing: 1px; color: var(--ink-mute); display: flex; align-items: center; gap: 6px; }
.scope-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); flex: 0 0 auto; }
.scope-module.live { border-top-color: var(--green); }
.scope-module.live .scope-dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.4s infinite; }
#scope-canvas { display: block; width: 100%; flex: 1 1 auto; min-height: 120px; border-radius: var(--r-s); background: #06070a; }
.rack-module-cap { font-size: 0.72rem; color: var(--ink-dim); line-height: 1.45; margin: 10px 0 0; }

/* ---- info line (synthesis blurb / focused-knob hint) --------------------- */
.info-line {
    flex: 0 0 auto; margin: 0; padding: 9px 18px;
    background: var(--bg-1); border-bottom: 1px solid var(--line);
    color: var(--ink-dim); font-size: 0.84rem; line-height: 1.4; min-height: 1.4em;
}
.info-line em { color: var(--brass-bright); font-style: normal; }

/* ---- landing page : eras dangling from a time-wire ------------------------ */
.landing {
    position: fixed; inset: 0; z-index: 100;
    background: radial-gradient(circle at 50% -10%, #181226 0%, var(--bg-0) 58%);
    display: flex; align-items: center; justify-content: center;
    padding: 28px; overflow: auto;
    transition: opacity 0.55s ease, visibility 0.55s ease;
}
.landing--hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.landing-inner { width: 100%; max-width: 1000px; display: flex; flex-direction: column; align-items: center; gap: 44px; }

.landing-head { text-align: center; }
.landing-head .badge { font-size: 0.8rem; }
.landing-head h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); margin: 16px 0 12px; font-weight: 700; letter-spacing: 0.3px; }
.landing-head h1 em { color: var(--brass-bright); font-style: normal; font-weight: 500; }
.landing-head p { color: var(--ink-dim); max-width: 540px; margin: 0 auto; line-height: 1.65; font-size: 0.95rem; }

.time-wire-stage { position: relative; width: 100%; display: flex; align-items: flex-start; gap: 16px; padding-top: 26px; }
.time-flow {
    font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 1px;
    color: var(--ink-mute); white-space: nowrap; flex: 0 0 auto; margin-top: 0;
    text-transform: uppercase;
}

.time-wire { position: relative; flex: 1 1 auto; display: flex; justify-content: space-around; align-items: flex-start; min-height: 250px; }
.time-wire::before {
    content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent, var(--brass-deep) 6%, var(--brass) 50%, var(--brass-deep) 94%, transparent);
    box-shadow: 0 0 12px var(--brass-glow);
}

.era {
    appearance: none; -webkit-appearance: none; background: none; border: none; padding: 0;
    font: inherit; color: inherit; cursor: pointer;
    position: relative; display: flex; flex-direction: column; align-items: center;
    flex: 1 1 0; min-width: 0; max-width: 152px;
    transform-origin: top center;
    animation: sway 6s ease-in-out infinite;
}
.era:nth-child(odd) { animation-delay: -1.2s; }
.era:nth-child(even) { animation-delay: -3.6s; }
.era:nth-child(3n) { animation-delay: -0.4s; }
.era:hover { animation-play-state: paused; }
.era:focus-visible { outline: none; }
.era:focus-visible .era-card { border-color: var(--cyan); box-shadow: 0 0 0 2px var(--cyan), var(--shadow-card); }

.era-knot { width: 14px; height: 14px; border-radius: 50%; background: var(--brass-bright); border: 2px solid #1a1404; box-shadow: 0 0 12px var(--brass); z-index: 2; }
.era-cable { width: 2px; height: 36px; background: linear-gradient(var(--brass), var(--brass-deep)); }
.era-card {
    background: var(--bg-2); border: 1px solid var(--line-strong);
    border-top: 2px solid var(--brass); border-radius: var(--r-m);
    padding: 13px 11px; text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    min-width: 0; width: 100%; box-shadow: var(--shadow-card);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.era:hover .era-card { border-color: var(--brass); box-shadow: 0 0 24px var(--brass-glow), var(--shadow-card); transform: translateY(-4px); }
.era-year { font-family: var(--f-mono); font-size: 1.15rem; font-weight: 700; color: var(--brass-bright); letter-spacing: 0.5px; }
.era-name { font-size: 0.92rem; font-weight: 600; color: var(--ink); }
.era-sub { font-size: 0.7rem; color: var(--ink-dim); line-height: 1.3; }
.era-card .tech-tag { margin-top: 3px; font-size: 0.62rem; }

/* visited markers (light gamification, no scoring) */
.era.visited .era-knot { background: var(--green); box-shadow: 0 0 12px var(--green); }
.era.visited .era-card { border-top-color: var(--green); }
.era.visited .era-year::after { content: " \2713"; color: var(--green); font-size: 0.8rem; }

.landing-footer { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.timeline-progress { font-family: var(--f-mono); font-size: 0.72rem; color: var(--ink-mute); letter-spacing: 0.5px; }
.enter-studio { font-size: 0.95rem; padding: 13px 28px; }

/* museum lore — revealed on the active sidebar card */
.card-lore { display: none; font-size: 0.82rem; color: var(--ink-dim); line-height: 1.6; margin-top: 8px; }
.timeline-card.active .card-lore { display: block; }
.card-lore em { color: var(--brass-bright); font-style: normal; }
.timeline-card.visited::after {
    content: "\2713"; position: absolute; top: 12px; right: 14px;
    color: var(--green); font-family: var(--f-mono); font-size: 0.8rem;
}

/* toast (timeline-complete reward) */
.toast {
    position: fixed; left: 50%; bottom: 28px;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-3); border: 1px solid var(--brass); border-radius: var(--r-m);
    color: var(--ink); font-size: 0.85rem; line-height: 1.5;
    padding: 12px 18px; max-width: min(90vw, 460px); text-align: center;
    box-shadow: 0 0 24px var(--brass-glow), var(--shadow-card);
    opacity: 0; pointer-events: none; z-index: 200;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* medium widths — wrap the seven eras instead of cramming the wire */
@media (max-width: 980px) and (min-width: 721px) {
    .time-wire { flex-wrap: wrap; justify-content: center; gap: 16px; min-height: 0; }
    .time-wire::before { display: none; }
    .era { flex: 0 0 auto; width: 140px; animation: none; }
    .era-cable, .era-knot { display: none; }
}

@keyframes sway { 0%, 100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2.2deg); } }

@media (prefers-reduced-motion: reduce) {
    .era { animation: none; }
}

@media (max-width: 720px) {
    .time-wire-stage { flex-direction: column; align-items: stretch; }
    .time-flow { display: none; }
    .time-wire { flex-direction: column; align-items: center; min-height: 0; gap: 26px; }
    .time-wire::before { display: none; }
    .era { width: 100%; max-width: 320px; animation: none; }
    .era-cable, .era-knot { display: none; }
}

/* reduce motion globally for users who ask for it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* larger hit targets on touch devices */
@media (pointer: coarse) {
    .btn, .btn-home { min-height: 44px; }
    .timeline-card { padding: 18px; }
}

/* ---- responsive : tablet / iPad (stack sidebar above workspace) ----------- */
@media (max-width: 820px) {
    body.dark-theme { overflow: auto; }
    .app-shell { height: auto; min-height: 100vh; }
    .studio-container { flex-direction: column; height: auto; }
    .timeline-sidebar { width: 100%; max-width: none; border-right: none; border-bottom: 1px solid var(--line); max-height: 44vh; }
    .sandbox-workspace { min-height: 62vh; }
    .tagline { display: none; }
}

/* ---- responsive : phones (stripped-down variant) -------------------------- */
@media (max-width: 600px) {
    .stage { flex-direction: column; }
    .node-canvas-wrapper { display: none; }          /* drop the decorative signal-flow canvas */
    .rack-rail { flex: 0 0 auto; border-left: none; padding: 10px 12px; }
    #scope-canvas { min-height: 108px; }
    .app-header { height: auto; min-height: 60px; padding: 10px 14px; flex-wrap: wrap; gap: 6px 10px; }
    .brand-title h1 { font-size: 1rem; }
    .macro-control-deck { flex: 0 0 auto; padding: 14px 4px; gap: 2px; }
    .macro-knob-wrapper { width: 32%; }
    .knob { width: 64px; height: 64px; }
    .macro-knob-wrapper label { font-size: 0.6rem; }
    .knob-value-readout { font-size: 0.75rem; }
    .sandbox-toolbar { flex: 0 0 auto; flex-wrap: wrap; height: auto; padding: 10px; gap: 8px; }
    /* timeline becomes a compact horizontal swipe strip so controls stay reachable */
    .timeline-sidebar { max-height: none; }
    .sidebar-scroll-container {
        display: flex; gap: 10px; overflow-x: auto; padding: 12px;
        scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    }
    .timeline-card { flex: 0 0 82%; margin-bottom: 0; scroll-snap-align: start; }
    .card-lore { display: none !important; }
}
