/* =====================================================================
   Two palettes, one site.

   Dark is the original and stays the default. Light is a second set of the
   same tokens, chosen so the app panels read like the product's own light
   theme rather than like a dark screenshot on white paper.

   Nothing here styles anything. Every colour the stylesheets use is a
   token, and this file decides what the tokens mean.
   ===================================================================== */

:root {
    color-scheme: dark;

    --w01: rgba(255, 255, 255, 0.01);
    --w012: rgba(255, 255, 255, 0.012);
    --w015: rgba(255, 255, 255, 0.015);
    --w018: rgba(255, 255, 255, 0.018);
    --w02: rgba(255, 255, 255, 0.02);
    --w022: rgba(255, 255, 255, 0.022);
    --w025: rgba(255, 255, 255, 0.025);
    --w03: rgba(255, 255, 255, 0.03);
    --w04: rgba(255, 255, 255, 0.04);
    --w045: rgba(255, 255, 255, 0.045);
    --w05: rgba(255, 255, 255, 0.05);
    --w06: rgba(255, 255, 255, 0.06);
    --w07: rgba(255, 255, 255, 0.07);
    --w08: rgba(255, 255, 255, 0.08);
    --w09: rgba(255, 255, 255, 0.09);
    --w1: rgba(255, 255, 255, 0.1);
    --w10: rgba(255, 255, 255, 0.10);
    --w11: rgba(255, 255, 255, 0.11);
    --w12: rgba(255, 255, 255, 0.12);
    --w13: rgba(255, 255, 255, 0.13);
    --w14: rgba(255, 255, 255, 0.14);
    --w15: rgba(255, 255, 255, 0.15);
    --w16: rgba(255, 255, 255, 0.16);
    --w18: rgba(255, 255, 255, 0.18);
    --w2: rgba(255, 255, 255, 0.2);
    --w22: rgba(255, 255, 255, 0.22);
    --w3: rgba(255, 255, 255, 0.3);
    --w4: rgba(255, 255, 255, 0.4);
    --w6: rgba(255, 255, 255, 0.6);
    --w9: rgba(255, 255, 255, 0.9);
    --k15: rgba(0, 0, 0, 0.15);
    --k2: rgba(0, 0, 0, 0.2);
    --k22: rgba(0, 0, 0, 0.22);
    --k25: rgba(0, 0, 0, 0.25);
    --k28: rgba(0, 0, 0, 0.28);
    --k3: rgba(0, 0, 0, 0.3);
    --k35: rgba(0, 0, 0, 0.35);
    --k4: rgba(0, 0, 0, 0.4);
    --k5: rgba(0, 0, 0, 0.5);
    --k6: rgba(0, 0, 0, 0.6);
    --k7: rgba(0, 0, 0, 0.7);
    --k8: rgba(0, 0, 0, 0.8);
    --k85: rgba(0, 0, 0, 0.85);
    --k9: rgba(0, 0, 0, 0.9);
    --k95: rgba(0, 0, 0, 0.95);

    /* Structural colours the old stylesheet hard-coded. */
    --panel-deep: #070c15;
    --panel: #0c1422;
    --panel-raised: #101a28;
    --panel-inset: #0a1120;
    --code-bg: rgba(0, 0, 0, 0.28);
    --aurora-strength: 1;
    --glow-strength: 1;

    /* What the charts draw with (src/charts.js reads these). */
    --chart-surface: #111b2c;
    --chart-ink: #6c7f96;
    --chart-ink-strong: #eef3f8;
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-axis: rgba(255, 255, 255, 0.10);
    --chart-accent: #22d3ee;
    --chart-accent-soft: rgba(34, 211, 238, 0.22);
    --chart-success: #34d399;
    --chart-warning: #fbbf24;
    --chart-danger: #f87171;
}

:root[data-theme="light"] {
    color-scheme: light;

    /* The page */
    --bg-deep: #f6f8fb;
    --bg-elevated: #ffffff;
    --bg-surface: #eef2f7;
    --bg-hover: #e2e8f0;

    --text-primary: #0b1220;
    --text-secondary: #46566b;
    --text-muted: #6b7a8d;

    /* The accents keep their hue and gain the contrast paper needs. */
    --accent-primary: #2563eb;
    --accent-glow: #3b82f6;
    --accent-cyan: #2456c8;
    --success: #059669;
    --warning: #b45309;
    --danger: #dc2626;

    --hairline: rgba(15, 23, 42, 0.11);

    --panel-deep: #ffffff;
    --panel: #ffffff;
    --panel-raised: #ffffff;
    --panel-inset: #f8fafc;
    --code-bg: #f1f5f9;
    --aurora-strength: 0.3;
    --glow-strength: 0.4;

    --chart-surface: #ffffff;
    --chart-ink: #6b7a8d;
    --chart-ink-strong: #0f172a;
    --chart-grid: rgba(15, 23, 42, 0.08);
    --chart-axis: rgba(15, 23, 42, 0.16);
    --chart-accent: #2b62d8;
    --chart-accent-soft: rgba(43, 98, 216, 0.18);
    --chart-success: #059669;
    --chart-warning: #b45309;
    --chart-danger: #dc2626;

    --w01: rgba(15, 23, 42, 0.0135);
    --w012: rgba(15, 23, 42, 0.0162);
    --w015: rgba(15, 23, 42, 0.0203);
    --w018: rgba(15, 23, 42, 0.0243);
    --w02: rgba(15, 23, 42, 0.027);
    --w022: rgba(15, 23, 42, 0.0297);
    --w025: rgba(15, 23, 42, 0.0338);
    --w03: rgba(15, 23, 42, 0.0405);
    --w04: rgba(15, 23, 42, 0.054);
    --w045: rgba(15, 23, 42, 0.0607);
    --w05: rgba(15, 23, 42, 0.0675);
    --w06: rgba(15, 23, 42, 0.081);
    --w07: rgba(15, 23, 42, 0.0945);
    --w08: rgba(15, 23, 42, 0.108);
    --w09: rgba(15, 23, 42, 0.1215);
    --w1: rgba(15, 23, 42, 0.135);
    --w10: rgba(15, 23, 42, 0.135);
    --w11: rgba(15, 23, 42, 0.1485);
    --w12: rgba(15, 23, 42, 0.162);
    --w13: rgba(15, 23, 42, 0.1755);
    --w14: rgba(15, 23, 42, 0.189);
    --w15: rgba(15, 23, 42, 0.2025);
    --w16: rgba(15, 23, 42, 0.216);
    --w18: rgba(15, 23, 42, 0.243);
    --w2: rgba(15, 23, 42, 0.27);
    --w22: rgba(15, 23, 42, 0.297);
    --w3: rgba(15, 23, 42, 0.405);
    --w4: rgba(15, 23, 42, 0.54);
    --w6: rgba(15, 23, 42, 0.81);
    --w9: rgba(15, 23, 42, 0.9);
    --k15: rgba(15, 23, 42, 0.033);
    --k2: rgba(15, 23, 42, 0.044);
    --k22: rgba(15, 23, 42, 0.0484);
    --k25: rgba(15, 23, 42, 0.055);
    --k28: rgba(15, 23, 42, 0.0616);
    --k3: rgba(15, 23, 42, 0.066);
    --k35: rgba(15, 23, 42, 0.077);
    --k4: rgba(15, 23, 42, 0.088);
    --k5: rgba(15, 23, 42, 0.11);
    --k6: rgba(15, 23, 42, 0.132);
    --k7: rgba(15, 23, 42, 0.154);
    --k8: rgba(15, 23, 42, 0.176);
    --k85: rgba(15, 23, 42, 0.187);
    --k9: rgba(15, 23, 42, 0.198);
    --k95: rgba(15, 23, 42, 0.209);
}

/* The product panels follow the app's own light theme. */
:root[data-theme="light"] .appui {
    --fg-accent: #2b62d8;
    --fg-accent-text: #1f4fbf;
    --fg-accent-wash: rgba(43, 98, 216, 0.10);
    --fg-bg-primary: #ffffff;
    --fg-bg-secondary: #ffffff;
    --fg-bg-elevated: #f8fafc;
    --fg-bg-surface: #f1f5f9;
    --fg-bg-inset: #f8fafc;
    --fg-text-primary: #0f172a;
    --fg-text-secondary: #46566b;
    --fg-text-muted: #6b7a8d;
    --fg-border: rgba(15, 23, 42, 0.11);
    --fg-success: #059669;
    --fg-warning: #b45309;
    --fg-danger: #dc2626;

    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 18px 40px -28px rgba(15, 23, 42, 0.35);
}

/* Light needs less shine: the aurora and the glows step back. */
:root[data-theme="light"] .hero-aurora,
:root[data-theme="light"] .cta-bg { opacity: var(--aurora-strength); }
:root[data-theme="light"] .btn-glow { box-shadow: 0 10px 30px -12px rgba(37, 99, 235, 0.55); }

body { background: var(--bg-deep); color: var(--text-primary); }


/* --- The switch ------------------------------------------------------- */
.theme-toggle {
    width: 34px; height: 34px;
    display: none; place-items: center;
    border: 1px solid var(--hairline);
    border-radius: 10px;
    background: var(--w03);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.theme-toggle:hover { color: var(--text-primary); border-color: var(--w15); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle__sun { display: none; }
:root[data-theme="light"] .theme-toggle__sun { display: block; }
:root[data-theme="light"] .theme-toggle__moon { display: none; }
@media (min-width: 1024px) { .theme-toggle { display: grid; } }

.theme-toggle-mobile {
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Light mode asks for a few things the dark one did not. */
:root[data-theme="light"] .header { background: rgba(255, 255, 255, 0.82); border-bottom: 1px solid var(--hairline); }
/* Two wordmarks: white letters for ink, dark letters for paper. The shield
   is blue in both, because it works on either. */
img.logo-img--light { display: none; }
:root[data-theme="light"] img.logo-img--dark { display: none; }
:root[data-theme="light"] img.logo-img--light { display: block; }

/* The brand marks are white artwork. On paper they become their silhouette,
   which is what they were on ink: one flat colour at low contrast. */
:root[data-theme="light"] .marks-item img,
:root[data-theme="light"] img[src*="/brands/"],
:root[data-theme="light"] img[src*="_white"],
:root[data-theme="light"] img[src*="-white"],
:root[data-theme="light"] img[src*="monotone"] {
    filter: brightness(0);
    opacity: 0.42;
}

/* The NEW chip had the dark theme's pale cyan on it. */
:root[data-theme="light"] .nav-tag {
    background: rgba(43, 98, 216, 0.12);
    color: #1f4fbf;
}
:root[data-theme="light"] .btn-ghost { border-color: var(--hairline); color: var(--text-primary); }
:root[data-theme="light"] .btn-ghost:hover { background: var(--w05); }
:root[data-theme="light"] .code-card .code-body { color: #1f4fbf; background: var(--code-bg); }
:root[data-theme="light"] .appui-chart text { fill: var(--fg-text-muted); }
:root[data-theme="light"] .mobile-menu { background: var(--bg-elevated); }

/* Status chips need more ink on paper than they do on ink. */
:root[data-theme="light"] .appui-badge { background: var(--w05); color: var(--fg-text-secondary); border-color: var(--fg-border); }
:root[data-theme="light"] .appui-badge--ok { background: rgba(5, 150, 105, 0.10); color: #047857; border-color: rgba(5, 150, 105, 0.22); }
:root[data-theme="light"] .appui-badge--warn { background: rgba(180, 83, 9, 0.10); color: #b45309; border-color: rgba(180, 83, 9, 0.24); }
:root[data-theme="light"] .flow-active { background: rgba(5, 150, 105, 0.10); color: #047857; }
:root[data-theme="light"] .flow-every { color: #1f4fbf; }
:root[data-theme="light"] .ui-cta.is-on { background: rgba(43, 98, 216, 0.10); color: #1f4fbf; border-color: rgba(43, 98, 216, 0.26); }
:root[data-theme="light"] .run-no { background: var(--w06); }
:root[data-theme="light"] .rep-mark { background: rgba(43, 98, 216, 0.10); color: #1f4fbf; }
:root[data-theme="light"] .field input,
:root[data-theme="light"] .field select,
:root[data-theme="light"] .field textarea { border-color: var(--hairline); background: #ffffff; }
:root[data-theme="light"] .calc-meter.is-tight .calc-bar i { background: #d97706; }
:root[data-theme="light"] .fork-card { background: #ffffff; }
:root[data-theme="light"] .fork-card--wp { background: linear-gradient(180deg, rgba(43, 98, 216, 0.06), #ffffff 55%); }

/* =====================================================================
   Buttons

   A button should look like something you can press: a surface with a
   light source above it, a thin ring, and a shadow that says how far it
   sits off the page. Both themes get the same shape and their own light.
   ===================================================================== */

:root {
    --btn-primary-top: #3d7bf0;
    --btn-primary-bottom: #1f56cc;
    --btn-primary-ring: rgba(255, 255, 255, 0.16);
    --btn-primary-sheen: rgba(255, 255, 255, 0.30);
    --btn-primary-cast: rgba(31, 86, 204, 0.75);
    --btn-quiet-face: rgba(255, 255, 255, 0.045);
    --btn-quiet-face-hover: rgba(255, 255, 255, 0.08);
    --btn-quiet-ring: rgba(255, 255, 255, 0.13);
    --btn-quiet-sheen: rgba(255, 255, 255, 0.07);
    --btn-quiet-cast: rgba(0, 0, 0, 0.35);
    --btn-focus: rgba(91, 155, 255, 0.45);
}

:root[data-theme="light"] {
    --btn-primary-top: #4c8dff;
    --btn-primary-bottom: #2563eb;
    --btn-primary-ring: rgba(15, 23, 42, 0.08);
    --btn-primary-sheen: rgba(255, 255, 255, 0.34);
    --btn-primary-cast: rgba(37, 99, 235, 0.42);
    --btn-quiet-face: #ffffff;
    --btn-quiet-face-hover: #ffffff;
    --btn-quiet-ring: rgba(15, 23, 42, 0.13);
    --btn-quiet-sheen: rgba(255, 255, 255, 0.9);
    --btn-quiet-cast: rgba(15, 23, 42, 0.10);
    --btn-focus: rgba(37, 99, 235, 0.35);
}

.btn {
    position: relative;
    isolation: isolate;
    border-radius: 12px;
    padding: 0.78rem 1.4rem;
    font-weight: 560;
    letter-spacing: -0.006em;
    line-height: 1.2;
    transition:
        transform 0.18s cubic-bezier(0.2, 0.8, 0.3, 1),
        box-shadow 0.28s ease,
        background 0.28s ease,
        border-color 0.28s ease,
        color 0.2s ease;
}
.btn svg { transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.3, 1); }
.btn:hover svg:last-of-type { transform: translateX(2px); }
.btn:active { transform: scale(0.985); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--btn-focus); }

/* The one you are meant to press. */
.btn-primary,
.btn-primary:hover {
    color: #fff;
    border: 1px solid var(--btn-primary-ring);
}
.btn-primary {
    background: linear-gradient(180deg, var(--btn-primary-top), var(--btn-primary-bottom));
    box-shadow:
        inset 0 1px 0 var(--btn-primary-sheen),
        0 1px 2px var(--btn-quiet-cast),
        0 14px 28px -14px var(--btn-primary-cast);
}
.btn-primary:hover {
    background: linear-gradient(180deg, var(--btn-primary-top), var(--btn-primary-top));
    box-shadow:
        inset 0 1px 0 var(--btn-primary-sheen),
        0 2px 4px var(--btn-quiet-cast),
        0 20px 40px -16px var(--btn-primary-cast);
}
/* The legacy rule lifted it; nothing here moves up on hover. */
.btn:hover { transform: none; }
.btn-primary:active {
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.22), 0 1px 2px var(--btn-quiet-cast);
}

/* The one beside it. Glass on ink, a pressed key on paper. */
.btn-ghost {
    background: var(--btn-quiet-face);
    color: var(--text-primary);
    border: 1px solid var(--btn-quiet-ring);
    box-shadow: inset 0 1px 0 var(--btn-quiet-sheen), 0 1px 2px var(--btn-quiet-cast);
}
.btn-ghost:hover {
    background: var(--btn-quiet-face-hover);
    border-color: var(--text-muted);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 var(--btn-quiet-sheen), 0 6px 16px -8px var(--btn-quiet-cast);
}
.btn-ghost:active { box-shadow: inset 0 2px 4px var(--btn-quiet-cast); }

.btn-large { padding: 0.95rem 1.8rem; border-radius: 13px; }
.btn-header { padding: 0.62rem 1.15rem; border-radius: 11px; }

/* The halo on the closing call, kept as a halo and not as a floodlight. */
.btn-glow {
    box-shadow:
        inset 0 1px 0 var(--btn-primary-sheen),
        0 1px 2px var(--btn-quiet-cast),
        0 18px 44px -18px var(--btn-primary-cast),
        0 0 0 1px var(--btn-primary-ring);
}
.btn-glow:hover {
    box-shadow:
        inset 0 1px 0 var(--btn-primary-sheen),
        0 2px 6px var(--btn-quiet-cast),
        0 26px 60px -20px var(--btn-primary-cast),
        0 0 0 1px var(--btn-primary-ring);
}

@media (prefers-reduced-motion: reduce) {
    .btn, .btn svg { transition: none; }
    .btn:active { transform: none; }
}

/* --- The language switch --------------------------------------------- */
/* One button, however many languages there end up being. */
.lang { display: none; position: relative; }
@media (min-width: 1024px) { .lang { display: block; } }

.lang > summary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px 6px 9px;
    border: 1px solid var(--hairline);
    border-radius: 9px;
    background: var(--w03);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    list-style: none;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.lang > summary::-webkit-details-marker { display: none; }
.lang > summary:hover { color: var(--text-primary); background: var(--w06); }
.lang[open] > summary { color: var(--text-primary); background: var(--w06); border-color: var(--hairline); }

.lang__globe { width: 14px; height: 14px; opacity: 0.75; }
.lang__caret { width: 10px; height: 10px; opacity: 0.6; transition: transform var(--transition-fast); }
.lang[open] .lang__caret { transform: rotate(180deg); }

.lang__list {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 168px;
    padding: 5px;
    margin: 0;
    list-style: none;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--bg-elevated);
    box-shadow: 0 18px 40px var(--k35);
    z-index: 60;
}

.lang__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.lang__item em { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: 0.6px; opacity: 0.5; }
.lang__item:hover { color: var(--text-primary); background: var(--w06); }
.lang__item.is-on { color: var(--text-primary); background: var(--w06); }
.lang__item.is-on em { color: var(--accent-primary); opacity: 1; }

.mobile-lang__item.is-on { color: var(--text-primary); font-weight: 600; }

/* The visualisation panels carried their own dark gradient. On paper they
   are a white card like every other panel. */
:root[data-theme="light"] {
    --viz-bg: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
    --viz-line: rgba(15, 23, 42, 0.10);
    --viz-line-soft: rgba(15, 23, 42, 0.06);
    --viz-accent: #2563eb;
    --viz-accent-2: #2b62d8;
}
:root[data-theme="light"] .viz,
:root[data-theme="light"] .platform-card { border: 1px solid var(--hairline); }

/* Changelog kinds: the dark theme's pastels vanish on paper. */
:root[data-theme="light"] .log-kind--added { background: rgba(5, 150, 105, 0.11); color: #046c51; }
:root[data-theme="light"] .log-kind--improved { background: rgba(14, 116, 144, 0.11); color: #0e6b82; }
:root[data-theme="light"] .log-kind--fixed { background: rgba(180, 83, 9, 0.12); color: #9a4a06; }
:root[data-theme="light"] .log-kind--security { background: rgba(190, 18, 60, 0.10); color: #a81238; }
:root[data-theme="light"] .log-filter a.is-on {
    color: #1f4fbf;
    border-color: rgba(43, 98, 216, 0.35);
    background: rgba(43, 98, 216, 0.08);
}

/* The light overrides above are more specific than the error state. */
:root[data-theme="light"] .field.is-bad input,
:root[data-theme="light"] .field.is-bad select,
:root[data-theme="light"] .field.is-bad textarea { border-color: var(--danger); background: #fffdfd; }

/* The code step needs a paper-friendly ground, like the platform code card. */
:root[data-theme="light"] .code-step { background: var(--code-bg); color: #334155; }
:root[data-theme="light"] .code-step .c-k { color: #1f4fbf; }
:root[data-theme="light"] .code-step .c-s { color: #047857; }
