/* ============================================================
   Jackdaw — shared design system for Binaural + Psychoacoustics
   A dark "field lab" identity: graphite panels, a pale ice-eye
   glow for anything live, and one warm brass accent for the
   controls worth noticing.
   ============================================================ */

:root {
    --bg-0: #08090b;
    --bg-1: #0e1116;
    --bg-2: #161a20;
    --panel: #1b2027;
    --panel-raised: #232933;
    --line: #2c323c;
    --line-soft: #232830;

    --text: #e8eaee;
    --text-dim: #9aa2ae;
    --text-faint: #5c6472;

    --eye: #bcd9e6;
    --eye-bright: #8fe1ff;
    --brass: #c99a55;
    --brass-deep: #9c7038;
    --brass-bright: #e3b876;
    --danger: #c9695a;
    --danger-deep: #8f3f34;
    --good: #7cb686;

    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sans: 'Work Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --display: 'Space Grotesk', var(--sans);

    --radius: 10px;
    --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(120% 70% at 50% -10%, #161b22, transparent 55%),
        var(--bg-0);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* faint grain, keeps flat panels from looking like a flat gradient render */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 200;
    opacity: 0.035;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--brass-deep); color: #fff; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

a { color: var(--eye); }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: 0.01em; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------
   App shell: header, brand mark, tool switcher
   --------------------------------------------------------------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 12px 22px;
    background: rgba(10, 12, 15, 0.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line-soft);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: var(--text);
    margin-right: auto;
}

.brand img {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: block;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text strong {
    font-family: var(--display);
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}

.brand-text span {
    font-size: 0.72rem;
    color: var(--text-faint);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tool-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.tool-switch button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--display);
    font-size: 0.86rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.tool-switch button:hover { color: var(--text); }

.tool-switch button.tool-active {
    background: linear-gradient(180deg, var(--brass-bright), var(--brass-deep));
    color: #201306;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.tool-panel { display: none; }
.tool-panel.tool-visible { display: block; }

/* ---------------------------------------------------------------
   Generic controls shared by both tools
   --------------------------------------------------------------- */

button {
    font-family: var(--sans);
    cursor: pointer;
}

select, .protocol-input, textarea {
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
}

select:focus, .protocol-input:focus, textarea:focus, button:focus-visible, input:focus-visible {
    outline: 2px solid var(--eye-bright);
    outline-offset: 1px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 4px;
    background: var(--bg-1);
    border: 1px solid var(--line);
}
input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 4px;
    background: var(--bg-1);
    border: 1px solid var(--line);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border-radius: 50%;
    background: linear-gradient(180deg, #f2f5f7, var(--eye));
    border: 1px solid var(--brass-deep);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(180deg, #f2f5f7, var(--eye));
    border: 1px solid var(--brass-deep);
}

input[type="checkbox"] { accent-color: var(--brass); }

/* base pushbutton, used verbatim or extended by each tool's own classes */
.btn {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text);
    background: linear-gradient(180deg, var(--panel-raised), var(--panel));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 5px rgba(0, 0, 0, 0.35);
    transition: filter 0.12s ease, transform 0.08s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

.btn-primary {
    color: #201306;
    background: linear-gradient(180deg, var(--brass-bright), var(--brass-deep));
    border-color: var(--brass-deep);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 16px rgba(201, 154, 85, 0.35), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.btn-danger {
    color: #fbe9e5;
    background: linear-gradient(180deg, #c9695a, var(--danger-deep));
    border-color: var(--danger-deep);
}

/* generic "selected / toggled on" state, used by preset tabs, filter chips,
   protocol apply/disable, and anywhere else that flips a plain .btn on */
.btn.active {
    color: #201306;
    background: linear-gradient(180deg, var(--brass-bright), var(--brass-deep));
    border-color: var(--brass-deep);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 12px rgba(201, 154, 85, 0.35);
}

/* generic "currently playing" state for a button, matches the live-dot glow */
.btn.live {
    color: #06222b;
    background: linear-gradient(180deg, #b8ecff, var(--eye-bright));
    border-color: #2c94b3;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 12px rgba(143, 225, 255, 0.4);
}

.btn-sm { padding: 7px 9px; font-size: 0.8rem; }

/* a small pale dot that lights up eye-bright when something is playing */
.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #3a3f47, #1c2027 70%);
    box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.6);
    display: inline-block;
}
.live-dot.live {
    background: radial-gradient(circle at 35% 30%, #eafcff, var(--eye-bright) 60%, #2c94b3 100%);
    box-shadow: 0 0 8px var(--eye-bright), 0 0 16px rgba(143, 225, 255, 0.55);
    animation: eyePulse 2.2s ease-in-out infinite;
}
@keyframes eyePulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.35); }
}

/* glass "LED" readout, reused by the frequency display and the scope readouts */
.led {
    font-family: var(--mono);
    color: var(--eye-bright);
    letter-spacing: 0.06em;
    text-shadow: 0 0 6px rgba(143, 225, 255, 0.75), 0 0 14px rgba(143, 225, 255, 0.3);
    background: radial-gradient(120% 90% at 50% 0%, #10151b, #05070a 75%);
    border: 1px solid #000;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.85), 0 1px 0 rgba(255, 255, 255, 0.05);
}

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