/* ===== Firri Start — shared foundations (tokens, backdrop, a11y) =====
   Loaded by both the start page and the IP-check page. */

:root {
    color-scheme: dark;

    /* Accent (the IP page swaps these at runtime via its palette picker) */
    --accent: #7c9cff;
    --accent-hover: #9db4ff;
    --accent-strong: #4f6bff;
    --on-accent: #ffffff;

    /* Text */
    --txt: #f5f7ff;
    --txt-muted: rgba(245, 247, 255, 0.74);
    --txt-faint: rgba(245, 247, 255, 0.52);

    /* Surfaces */
    --ink: #080a14;
    --glass: rgba(16, 20, 36, 0.48);
    --glass-strong: rgba(12, 15, 28, 0.74);
    --glass-hover: rgba(34, 40, 68, 0.58);
    --line: rgba(255, 255, 255, 0.13);
    --line-strong: rgba(255, 255, 255, 0.28);

    /* Shape & motion */
    --radius: 20px;
    --radius-sm: 12px;
    --blur: blur(20px) saturate(150%);
    --shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 8px 24px -8px rgba(0, 0, 0, 0.5);
    --ease: 0.28s cubic-bezier(0.16, 1, 0.3, 1);

    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI",
            Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    color: var(--txt);
    background: var(--ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ===== Backdrop =====
   .backdrop  → always-on gradient (what you see offline / before the picture loads)
   .bg        → APOD picture, fades in once downloaded and decoded
   .scrim     → light, localised darkening so text stays legible without
                dimming the whole photograph                                  */
.backdrop,
.bg,
.scrim {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.backdrop {
    z-index: -4;
    background:
        radial-gradient(60% 50% at 12% 8%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 62%),
        radial-gradient(50% 45% at 88% 18%, rgba(167, 139, 250, 0.26), transparent 62%),
        radial-gradient(60% 60% at 72% 100%, rgba(34, 197, 235, 0.16), transparent 62%),
        var(--ink);
}

.bg {
    z-index: -3;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    transform: scale(1.035);
    transition: opacity 1.1s ease, transform 9s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.bg.loaded { opacity: 1; transform: scale(1); }

.scrim {
    z-index: -1;
    background:
        radial-gradient(70% 55% at 50% 46%, rgba(8, 10, 20, 0.34) 0%, transparent 100%),
        linear-gradient(180deg, rgba(8, 10, 20, 0.30) 0%, rgba(8, 10, 20, 0.06) 38%, rgba(8, 10, 20, 0.12) 62%, rgba(8, 10, 20, 0.52) 100%);
    transition: opacity 0.6s ease;
}

/* ===== Buttons shared by dialogs, panels and cards ===== */
.btn-primary,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease);
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    color: var(--on-accent);
    box-shadow: 0 8px 22px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px color-mix(in srgb, var(--accent) 90%, transparent); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-ghost {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line);
    color: var(--txt);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--line-strong); }
.btn-ghost:active { transform: scale(0.98); }

/* ===== Glass fallback: browsers without backdrop-filter get a firmer surface ===== */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    :root {
        --glass: rgba(16, 20, 36, 0.78);
        --glass-strong: rgba(12, 15, 28, 0.92);
    }
}

/* ===== Focus & a11y ===== */
:focus-visible {
    outline: 2px solid var(--accent-hover);
    outline-offset: 3px;   /* the outline follows each element's own border-radius */
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.sr-only:focus-visible {
    position: fixed;
    top: 0.75rem; left: 0.75rem;
    width: auto; height: auto;
    margin: 0; padding: 0.55rem 0.9rem;
    clip: auto;
    z-index: 100;
    background: var(--glass-strong);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .bg { transform: none; }
}
