/* ══════════════════════════════════════════════════════════
   op_amp_oscillator.html  ·  page-specific styles
   ══════════════════════════════════════════════════════════ */

:root {
    --bg: #0a0a10;
    --bg-2: #12131c;
    --bg-panel: rgba(22, 23, 32, 0.75);
    --fg: #eef0f5;
    --text: #eef0f5;
    --text-dim: #d4d7e0;
    --muted: #8b90a3;
    --border: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(255, 255, 255, 0.18);

    /* page semantic palette */
    --c-input: #58a6ff;
    /* feedback signal trace */
    --c-output: #ffcf5c;
    /* oscillator output trace */
    --c-output2: #7be089;
    /* magnitude trace */
    --c-thresh: #ff5c7a;
    /* Barkhausen marker */
    --c-thresh-h: #ff8aa6;
    --c-thresh-l: #c44263;
    --c-rail: rgba(255, 255, 255, 0.30);
    --c-band: rgba(255, 207, 92, 0.14);

    --accent: var(--site-accent);
    --accent-soft: var(--site-accent-soft);
    --accent-soft-faint: var(--site-accent-soft-faint);
    --accent-soft-edge: var(--site-accent-soft-edge);

    --grid-line: rgba(255, 255, 255, 0.06);
    --grid-zero: rgba(255, 255, 255, 0.30);
    --tick-line: rgba(255, 255, 255, 0.25);
    --slider-track: rgba(255, 255, 255, 0.12);
    --pill-bg: rgba(255, 255, 255, 0.03);

    --body-size: 17px;
    --math-size: 18px;
    --hero-size: 60px;
}

[data-theme="light"] {
    --bg: #f5f5f7;
    --bg-2: #ffffff;
    --bg-panel: rgba(255, 255, 255, 0.92);
    --fg: #1a1a1e;
    --text: #1a1a1e;
    --text-dim: #2b2d38;
    --muted: #6a6f7c;
    --border: rgba(0, 0, 0, 0.10);
    --border-hover: rgba(0, 0, 0, 0.22);

    --c-input: #1d4ed8;
    --c-output: #b88200;
    --c-output2: #2f8f3f;
    --c-thresh: #dc2626;
    --c-thresh-h: #b8253a;
    --c-thresh-l: #851725;
    --c-rail: rgba(0, 0, 0, 0.30);
    --c-band: rgba(184, 130, 0, 0.10);

    --grid-line: rgba(0, 0, 0, 0.07);
    --grid-zero: rgba(0, 0, 0, 0.32);
    --tick-line: rgba(0, 0, 0, 0.22);
    --slider-track: rgba(0, 0, 0, 0.12);
    --pill-bg: rgba(0, 0, 0, 0.03);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    background: var(--bg);
    color: var(--fg);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: var(--body-size);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body {
    overflow-x: hidden;
    min-height: 100vh;
}

.katex {
    font-size: var(--math-size) !important;
}

.katex-display {
    margin: 0.6em 0 !important;
}

.katex-display>.katex {
    font-size: calc(var(--math-size) * 1.06) !important;
}

h1 .katex,
h2 .katex,
h3 .katex {
    font-size: inherit !important;
}

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

/* ─── Brand and back ─── */
.brand {
    position: fixed;
    top: 20px;
    left: 24px;
    z-index: 40;
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand .mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: conic-gradient(var(--c-input), var(--c-output), var(--c-thresh), var(--c-output2), var(--c-input));
}

.back-btn {
    position: fixed;
    top: 14px;
    right: 56px;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--fg);
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    transition: all 0.15s;
}

.back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ─── Landing hero ─── */
.landing {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 120px 56px 80px;
    text-align: center;
    position: relative;
}

.landing .meta {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 28px;
}

h1.hero {
    font-size: var(--hero-size);
    line-height: 1.02;
    font-weight: 600;
    letter-spacing: -0.025em;
    margin: 0 auto 24px;
    max-width: 22ch;
}

h1.hero em {
    font-style: normal;
    background: linear-gradient(135deg, var(--c-input), var(--c-output));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.landing .sub {
    color: var(--muted);
    font-size: 18px;
    max-width: 64ch;
    margin: 12px auto 0;
    line-height: 1.6;
}

.landing .tags {
    margin-top: 36px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.field-tag {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    display: inline-block;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.scroll-hint {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.2em;
    color: var(--muted);
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.scroll-hint .line {
    width: 1px;
    height: 32px;
    background: linear-gradient(var(--muted), transparent);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* ─── Scene layout ─── */
section.scene {
    min-height: 50vh;
    padding: 100px 40px 80px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    gap: 32px;
    align-items: start;
    border-bottom: 1px solid var(--border);
}

section.scene.wide {
    grid-template-columns: 1fr;
}

section.scene .copy {
    max-width: 640px;
}

section.scene .copy.full {
    max-width: 1100px;
    margin: 0 auto;
}

.eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.eyebrow .num {
    color: var(--accent);
}

.eyebrow .bar {
    flex: 0 0 28px;
    height: 1px;
    background: var(--accent);
}

h2 {
    font-size: 34px;
    line-height: 1.12;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0 0 18px;
    color: var(--fg);
}

h2 em {
    font-style: normal;
}

h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 22px 0 8px;
    color: var(--fg);
    letter-spacing: -0.01em;
}

p {
    margin: 0 0 14px;
    color: var(--text-dim);
}

p.lead {
    font-size: calc(var(--body-size) + 1px);
    color: var(--fg);
}

p.dim {
    color: var(--muted);
}

ul.bullets {
    list-style: none;
    padding: 0;
    margin: 12px 0 14px;
}

ul.bullets li {
    color: var(--text-dim);
    padding: 6px 0 6px 18px;
    position: relative;
    font-size: 15px;
    line-height: 1.55;
}

ul.bullets li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 14px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

strong {
    color: var(--fg);
    font-weight: 600;
}

.eq-block {
    display: block;
    margin: 16px 0;
    padding: 14px 18px;
    background: var(--accent-soft-faint);
    border: 1px solid var(--accent-soft-edge);
    border-radius: 10px;
    text-align: center;
    color: var(--fg);
    overflow-x: auto;
}

.callout {
    margin-top: 18px;
    padding: 14px 18px;
    border-left: 2px solid var(--accent);
    background: var(--accent-soft-faint);
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.7;
}

.callout em {
    font-style: italic;
}

/* ─── Plot stack ─── */
.plot-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

.plot-box {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-2);
    overflow: hidden;
    width: 100%;
}

.plot-box.block {
    aspect-ratio: 1.9 / 1;
}

.plot-box.circuit {
    aspect-ratio: 1 / 1;
}

.plot-box.bode-pair {
    aspect-ratio: 1.05 / 1;
}

.plot-box.bark-nyquist {
    height: 760px;
    min-height: 760px;
}

#barkhausen-wrap {
    width: 100%;
}

.bark-toolbar {
    justify-content: flex-start;
    margin-bottom: 10px;
}

.plot-box.hp-lp {
    aspect-ratio: 1.2 / 1;
}

.plot-box.wien-decomp {
    aspect-ratio: 1.2 / 1;
}

.plot-box.scope {
    aspect-ratio: 2.0 / 1;
}

.plot-box svg {
    display: block;
    width: 100%;
    height: 100%;
}

.plot-box canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.plot-box.scope {
    position: relative;
}

.scope-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.scope-overlay foreignObject {
    overflow: visible;
}

.plot-box.circuit svg,
.plot-box.block svg,
.plot-box.wien-decomp svg {
    padding: 16px;
}

.plot-box .label {
    position: absolute;
    top: 10px;
    left: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    z-index: 2;
    pointer-events: none;
}

.plot-box .label b {
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--fg);
}

/* ─── Controls and toolbar ─── */
.toolbar {
    display: flex;
    gap: 10px 14px;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
}

.toolbar .divider {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 4px;
}

.toolbar .slider-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
}

.toolbar .slider-group .lab {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    flex: 0 0 auto;
    min-width: 9ch;
    line-height: 1;
}

.toolbar .slider-group .lab .katex {
    font-size: 12px !important;
}

.toolbar .slider-group .val {
    color: var(--fg);
    min-width: 6ch;
    text-align: left;
    line-height: 1;
    white-space: nowrap;
    flex: 0 0 auto;
}

.toolbar .slider-group input[type="range"] {
    flex: 0 0 130px;
}

.toolbar input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 130px;
    height: 4px;
    background: var(--slider-track);
    border-radius: 999px;
    outline: none;
}

.toolbar input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-2);
}

.toolbar input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-2);
}

.ctrl-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--fg);
    background: var(--pill-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.15s;
}

.ctrl-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.ctrl-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft-faint);
}

/* Section 03 · Wien decomposition toolbar + side-by-side layout */
#wien-decomp-wrap {
    width: 100%;
}

.wien-toolbar {
    justify-content: flex-start;
    margin-bottom: 10px;
}

.wien-decomp-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.wien-decomp-grid>.plot-box {
    min-width: 0;
    width: 100%;
    aspect-ratio: 1.15 / 1;
}

.wien-decomp-grid .plot-box svg {
    padding: 6px;
}

.wien-decomp-grid .plot-box .label {
    font-size: 9px;
    top: 6px;
    left: 8px;
}

/* ─── SVG plot styling ─── */
svg.bode text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    fill: var(--muted);
}

svg.bode .grid line {
    stroke: var(--grid-line);
    stroke-width: 1;
}

svg.bode .grid line.major {
    stroke: var(--grid-zero);
    stroke-width: 1.2;
}

svg.bode .axis-line {
    stroke: var(--grid-zero);
    stroke-width: 1.4;
}

svg.bode .axis-tick text {
    fill: var(--muted);
    font-size: 12px;
}

svg.bode .axis-tick line {
    stroke: var(--tick-line);
    stroke-width: 1;
}

svg.bode .trace {
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

svg.bode .trace.input {
    stroke: var(--c-input);
}

svg.bode .trace.output {
    stroke: var(--c-output);
}

svg.bode .trace.output2 {
    stroke: var(--c-output2);
}

svg.bode .trace.thresh {
    stroke: var(--c-thresh);
    stroke-dasharray: 5 4;
    stroke-width: 1.6;
}

svg.bode .trace.rail {
    stroke: var(--c-rail);
    stroke-dasharray: 2 4;
    stroke-width: 1;
}

svg.bode foreignObject {
    overflow: visible;
}

/* ─── Application cards (Section 05) ─── */
.card-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 28px;
}

.card {
    padding: 18px 18px 16px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    position: relative;
}

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

.card-num {
    position: absolute;
    top: 14px;
    right: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.card h3 {
    margin: 0 0 8px;
    font-size: 15px;
    padding-right: 24px;
}

.card p {
    margin: 0;
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.55;
}

/* ─── Footer ─── */
footer {
    padding: 60px 56px 80px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

@media (max-width: 900px) {
    section.scene {
        grid-template-columns: 1fr;
        padding: 80px 24px 60px;
    }

    h1.hero {
        font-size: 42px;
    }

    h2 {
        font-size: 26px;
    }

    .brand {
        top: 16px;
        left: 16px;
    }
}