/* =====================================================================
   RetroBU — the theme. spleach.org's "Halo" design system (dark ink,
   teal as the one accent, glass surfaces over a faint diamond lattice,
   Outfit / Sora / Space Grotesk), with this site's own shell: the header,
   the footer and the page frame. Fonts are self-hosted (fonts/, SIL OFL
   1.1), so the apps work offline and no third party sees a visit.
   ===================================================================== */

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/outfit.woff2') format('woff2');
}

@font-face {
    font-family: 'Sora';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('../fonts/sora.woff2') format('woff2');
}

@font-face {
    font-family: 'Space Grotesk';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url('../fonts/space-grotesk.woff2') format('woff2');
}

:root {
    /* ---- Ink scale ------------------------------------------------- */
    --ink-0: #080a0a;
    --ink-1: #0e1212;
    --ink-2: #141a1a;
    --ink-3: #1b2222;

    /* ---- Hairlines -------------------------------------------------- */
    --line: rgba(255,255,255,.08);
    --line-2: rgba(255,255,255,.14);

    /* ---- Teal (the only accent) ------------------------------------- */
    --teal: #10cabc;
    --teal-bright: #46e6d7;
    --teal-deep: #0a8e85;

    /* ---- Signals ---------------------------------------------------- */
    --warn: #f0b43c;
    --danger: #ff6b6b;
    --danger-deep: #c94a4a;
    --ok: #3ddc97;

    /* ---- Foreground ------------------------------------------------- */
    --fg-0: #f3f7f6;
    --fg-1: #aebbb9;
    --fg-2: #6f807e;
    --fg-on-teal: #04201e;

    /* ---- Gradients -------------------------------------------------- */
    --grad-teal: linear-gradient(135deg,#2fe0d0 0%,#10cabc 45%,#0a8e85 100%);
    --grad-teal-soft: linear-gradient(120deg,#46e6d7,#0a8e85);
    --glow-teal: radial-gradient(58% 46% at 50% -4%, rgba(16,202,188,.30), rgba(16,202,188,.04) 55%, transparent 72%);

    /* ---- Type ------------------------------------------------------- */
    --font-display: 'Outfit', system-ui, sans-serif;
    --font-ui: 'Outfit', system-ui, sans-serif;
    --font-meta: 'Sora', system-ui, sans-serif;
    --font-mono: 'Space Grotesk', ui-monospace, monospace;

    --text-h3: 22px;
    --text-lg: 19px;
    --text-body: 16px;
    --text-sm: 14px;
    --text-xs: 13px;

    /* ---- Radii ------------------------------------------------------ */
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --r-pill: 999px;

    /* ---- Elevation -------------------------------------------------- */
    --shadow-card: 0 8px 40px rgba(0,0,0,.35);
    --shadow-pop: 0 16px 60px rgba(0,0,0,.45);
    --shadow-teal: 0 10px 30px rgba(16,202,188,.28);

    /* ---- The device's safe areas (phones; viewport-fit=cover) ------- */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    /* legacy aliases the ported library styles use */
    --background-darker: var(--ink-0);
    --background-dark: var(--ink-1);
    --background-light: var(--ink-2);
    --accent-light: var(--teal);
    --accent-dark: var(--teal-deep);
    --accent-clicked: var(--teal-deep);
    --label-font: var(--font-meta);

    color-scheme: dark;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

html, body {
    width: 100%;
    margin: 0;
    background-color: var(--ink-0);
    color: var(--fg-0);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* a faint full-bleed lattice + halo behind everything */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image: repeating-linear-gradient( 45deg, transparent 0 25px, rgba(16,202,188,.045) 25px 26px), repeating-linear-gradient(-45deg, transparent 0 25px, rgba(16,202,188,.045) 25px 26px);
    -webkit-mask-image: radial-gradient(120% 80% at 50% 0%, #000 25%, transparent 75%);
    mask-image: radial-gradient(120% 80% at 50% 0%, #000 25%, transparent 75%);
    pointer-events: none;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background: var(--glow-teal);
    pointer-events: none;
}

::selection {
    background: rgba(16,202,188,.35);
    color: var(--fg-0);
}

:focus-visible {
    outline: 2px solid var(--teal-bright);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

/* ---- Utilities -------------------------------------------------------- */
.fx-diamond {
    background-image: repeating-linear-gradient( 45deg, transparent 0 25px, rgba(16,202,188,.055) 25px 26px), repeating-linear-gradient(-45deg, transparent 0 25px, rgba(16,202,188,.055) 25px 26px);
}

.fx-glow {
    background: var(--glow-teal);
}

.fx-glass {
    background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
    backdrop-filter: blur(16px) saturate(1.1);
    -webkit-backdrop-filter: blur(16px) saturate(1.1);
    border: 1px solid var(--line);
}

.tgrad {
    background: var(--grad-teal);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.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;
}

/* ---- Typography ------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--fg-0);
    letter-spacing: -.02em;
    line-height: 1.1;
}

h1 {
    font-size: clamp(34px, 4.6vw, 48px);
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1.05;
}

h2 {
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 600;
}

h3 {
    font-size: var(--text-h3);
    font-weight: 600;
    letter-spacing: -.01em;
}

p, ul, ol, li {
    font-family: var(--font-ui);
    font-size: var(--text-body);
    line-height: 1.65;
    color: var(--fg-1);
}

hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 32px 0;
}

a {
    color: var(--teal);
    text-decoration: none;
}

    a:hover {
        color: var(--teal-bright);
    }

    a:active {
        color: var(--teal-deep);
    }

code {
    font-family: var(--font-mono);
    font-size: .92em;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(255,255,255,.06);
    color: var(--fg-0);
}

/* ---- Semantic classes ------------------------------------------------- */
.ds-eyebrow, .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-family: var(--font-meta);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: .04em;
    color: var(--fg-1);
}

    .ds-eyebrow::before, .eyebrow::before {
        content: "";
        width: 7px;
        height: 7px;
        border-radius: 9px;
        background: var(--teal);
        box-shadow: 0 0 10px var(--teal);
    }

.ds-tag {
    font-family: var(--font-meta);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--teal-bright);
}

.ds-meta {
    font-family: var(--font-meta);
    font-size: var(--text-sm);
    color: var(--fg-2);
}

/* ---- Buttons ---------------------------------------------------------- */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: var(--text-body);
    padding: 13px 24px;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    background: none;
    color: var(--fg-0);
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease, opacity .12s ease;
}

    .ds-btn:disabled, .ds-btn[aria-disabled="true"] {
        opacity: .5;
        cursor: not-allowed;
        transform: none;
    }

.ds-btn--primary {
    color: var(--fg-on-teal);
    background: var(--grad-teal);
    box-shadow: var(--shadow-teal);
}

    .ds-btn--primary:hover:not(:disabled) {
        transform: translateY(-1px);
        color: var(--fg-on-teal);
    }

    .ds-btn--primary:visited, .ds-btn--primary:visited:hover {
        color: var(--fg-on-teal);
    }

.ds-btn--ghost {
    color: var(--fg-0);
    background: rgba(255,255,255,.04);
    border-color: var(--line-2);
}

    .ds-btn--ghost:hover:not(:disabled) {
        background: rgba(255,255,255,.08);
        color: var(--fg-0);
    }

.ds-btn--danger {
    color: #fff;
    background: linear-gradient(135deg, #ff8080, var(--danger) 45%, var(--danger-deep));
}

    .ds-btn--danger:hover:not(:disabled) {
        transform: translateY(-1px);
        color: #fff;
    }

.ds-btn--small {
    padding: 8px 14px;
    font-size: var(--text-sm);
    border-radius: var(--r-sm);
}

.ds-btn--block {
    width: 100%;
}

/* ---- Form controls ---------------------------------------------------- */
.ds-input, .ds-select {
    width: 100%;
    padding: 11px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--line-2);
    background: var(--ink-2);
    color: var(--fg-0);
    font: inherit;
    font-size: var(--text-body);
}

    .ds-input:focus, .ds-select:focus {
        outline: none;
        border-color: var(--teal);
        box-shadow: 0 0 0 3px rgba(16,202,188,.2);
    }

.ds-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--fg-1);
    font-size: var(--text-sm);
    line-height: 1.5;
    cursor: pointer;
}

    .ds-check input {
        margin-top: 3px;
        width: 18px;
        height: 18px;
        accent-color: var(--teal);
        flex: none;
    }

/* ---- The shell: header ------------------------------------------------ */
.sh-header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: calc(14px + var(--safe-top)) calc(24px + var(--safe-right)) 0 calc(24px + var(--safe-left));
}

.sh-nav {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px 8px 16px;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
}

.sh-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 14px;
    color: var(--fg-0);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    letter-spacing: -.02em;
    white-space: nowrap;
}

    .sh-brand:hover {
        color: var(--fg-0);
    }

.sh-mark {
    width: 30px;
    height: 30px;
    flex: none;
    filter: drop-shadow(0 0 12px rgba(16,202,188,.45));
}

.sh-links {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.sh-link {
    padding: 9px 14px;
    border-radius: var(--r-sm);
    color: var(--fg-1);
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
    transition: background .12s ease, color .12s ease;
}

    .sh-link:hover {
        background: rgba(255,255,255,.05);
        color: var(--fg-0);
    }

    .sh-link.is-active {
        color: var(--teal);
    }

.sh-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sh-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--r-pill);
    font-family: var(--font-meta);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--fg-1);
    border: 1px solid var(--line-2);
    background: rgba(255,255,255,.03);
    white-space: nowrap;
}

    .sh-chip[data-tone="ok"] {
        color: var(--teal-bright);
        border-color: rgba(16,202,188,.35);
    }

    .sh-chip[data-tone="warn"] {
        color: var(--warn);
        border-color: rgba(240,180,60,.35);
    }

/* ---- The page frame --------------------------------------------------- */
main.page {
    display: block;
    flex: 1 0 auto;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 48px calc(32px + var(--safe-right)) 40px calc(32px + var(--safe-left));
    color: var(--fg-1);
}

main.page--narrow {
    max-width: 760px;
}

.page-h {
    margin: 14px 0 0;
}

.page-lead {
    font-size: var(--text-lg);
    max-width: 640px;
    margin-top: 14px;
}

/* the ported library pages' wrapper (spleach.org's .m-page) */
.m-page {
    max-width: 1120px;
    margin: 0 auto;
}

.m-page-h {
    margin-top: 18px;
    max-width: 760px;
    font-size: clamp(34px, 4.6vw, 48px);
}

/* ---- Footer ------------------------------------------------------------ */
.sh-footer {
    flex: none;
    border-top: 1px solid var(--line);
    margin-top: 48px;
    width: 100%;
    padding-bottom: var(--safe-bottom);
}

.sh-footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px calc(32px + var(--safe-right)) 28px calc(32px + var(--safe-left));
    display: flex;
    align-items: center;
    gap: 10px 22px;
    flex-wrap: wrap;
    font-family: var(--font-meta);
    font-size: var(--text-sm);
    color: var(--fg-2);
}

    .sh-footer-inner a {
        color: var(--fg-1);
    }

        .sh-footer-inner a:hover {
            color: var(--teal-bright);
        }

.sh-footer-end {
    margin-left: auto;
}

.sh-footer-legal {
    flex-basis: 100%;
    margin: 0;
    font-size: 12px;
}

/* ---- The apps: no browser chrome above, so the header sits under the
   status bar's safe area (theme.css's --safe-*), and a tap never selects. */
html.is-app body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

html.is-app input, html.is-app textarea, html.is-app [contenteditable] {
    -webkit-user-select: text;
    user-select: text;
}

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 760px) {
    .sh-header {
        padding: calc(10px + var(--safe-top)) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
    }

    .sh-nav {
        padding: 6px 8px 6px 12px;
        gap: 2px;
    }

    .sh-brand {
        margin-right: 4px;
        font-size: 17px;
    }

    .sh-name {
        display: none;
    }

    .sh-link {
        padding: 8px 10px;
        font-size: 14px;
    }

    .sh-chip {
        display: none;
    }

    main.page {
        padding: 28px calc(16px + var(--safe-right)) 32px calc(16px + var(--safe-left));
    }

    .sh-footer-inner {
        padding: 20px calc(16px + var(--safe-right)) 24px calc(16px + var(--safe-left));
    }

    .sh-footer-end {
        margin-left: 0;
    }
}
