/*
 * Global Design System — Angus Uelsmann
 * Include this FIRST on every page: <link rel="stylesheet" href="/global/css/global.css">
 * Version is managed by global.js cache buster — do not add query strings manually.
 */

/* ============================================================
   FONTS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES (Dark theme = default)
   ============================================================ */

:root {
    /* Brand */
    --accent: #005F73;
    --accent-hover: #0A9396;
    --accent-subtle: rgba(0, 95, 115, 0.12);
    --accent-glow: rgba(0, 95, 115, 0.25);

    /* Backgrounds */
    --bg: #001219;
    --bg-raised: #001F2B;
    --bg-hover: #002A3A;
    --surface: #00303D;

    /* Borders */
    --border: #0A4A5C;
    --border-subtle: #062F3D;

    /* Text — no pure black, no pure white */
    --text: #C8D6DA;
    --text-strong: #E8F0F2;
    --text-muted: #6B8A94;
    --text-faint: #3D6370;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
    --text-xs:   clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
    --text-sm:   clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
    --text-base: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
    --text-lg:   clamp(1.05rem, 1rem + 0.25vw, 1.125rem);
    --text-xl:   clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
    --text-2xl:  clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --text-3xl:  clamp(1.8rem, 1.5rem + 1.5vw, 2.5rem);
    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.7;
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* Spacing */
    --space-2xs: 0.25rem;
    --space-xs:  0.5rem;
    --space-sm:  0.75rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Radius */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-base:   250ms ease;
    --transition-slow:   400ms ease;
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Z-Index */
    --z-base:     1;
    --z-dropdown: 100;
    --z-sticky:   200;
    --z-overlay:  300;
    --z-modal:    400;
    --z-toast:    500;
    --z-tooltip:  600;
}

/* ============================================================
   LIGHT THEME OVERRIDE
   ============================================================ */

[data-theme="light"] {
    --bg: #F8F9FA;
    --bg-raised: #FFFFFF;
    --bg-hover: #F0F1F3;
    --surface: #E9ECEF;
    --border: #DEE2E6;
    --border-subtle: #E9ECEF;
    --text: #212529;
    --text-strong: #111318;
    --text-muted: #6C757D;
    --text-faint: #ADB5BD;
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   ANIMATION OVERRIDE — Brand decision: always animate
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: revert !important;
        animation-play-state: running !important;
        transition-duration: revert !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-normal);
    line-height: var(--leading-normal);
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

/* ============================================================
   TYPOGRAPHY BASE
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    line-height: var(--leading-tight);
    font-weight: var(--weight-semibold);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p {
    line-height: var(--leading-relaxed);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

code, pre {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

code {
    background: var(--surface);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-sm);
}

pre {
    background: var(--surface);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

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

/* ============================================================
   GLOBAL FOOTER (injected by global.js)
   ============================================================ */

.au-global-footer {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
    margin-top: var(--space-3xl);
    border-top: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.au-global-footer .au-footer__heart {
    color: var(--accent);
    display: inline-block;
    animation: au-heartbeat 2s ease-in-out infinite;
}

.au-global-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.au-global-footer a:hover {
    color: var(--accent);
}

@keyframes au-heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
}

/* ============================================================
   UPDATE NOTIFICATION TOAST
   ============================================================ */

.au-update-toast {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-toast);
    max-width: 340px;
    min-width: 260px;
    display: flex;
    overflow: hidden;
    transform: translateY(calc(100% + var(--space-lg) + 4px));
    opacity: 0;
    visibility: hidden;
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease, visibility 0s 400ms;
}

.au-update-toast.au-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 300ms ease, visibility 0s;
}

.au-update-toast__accent {
    width: 4px;
    flex-shrink: 0;
    background: var(--accent);
}

.au-update-toast__body {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    min-width: 0;
}

.au-update-toast__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-bottom: var(--space-2xs);
}

.au-update-toast__tag {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--accent-hover);
    background: var(--accent-subtle);
    padding: 0.1em 0.5em;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.au-update-toast__message {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: var(--leading-normal);
}

.au-update-toast__close {
    background: none;
    border: none;
    color: var(--text-faint);
    cursor: pointer;
    font-size: var(--text-base);
    line-height: 1;
    padding: var(--space-2xs);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
    flex-shrink: 0;
}

.au-update-toast__close:hover {
    color: var(--text);
    background: var(--bg-hover);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.au-container {
    max-width: 1100px;
    margin-inline: auto;
    padding-inline: var(--space-lg);
}

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

/* ============================================================
   THEME TOGGLE (injected by global.js)
   ============================================================ */

.au-theme-toggle {
    position: fixed;
    bottom: var(--space-lg);
    left: var(--space-lg);
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 3px;
    z-index: var(--z-sticky);
    box-shadow: var(--shadow-md);
}

.au-theme-toggle__option {
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-faint);
    transition: all var(--transition-fast);
    border: none;
    background: none;
    cursor: pointer;
    line-height: 1;
}

.au-theme-toggle__option:hover {
    color: var(--text);
}

.au-theme-toggle__option.active {
    background: var(--accent);
    color: #fff;
}

/* ============================================================
   MAINTENANCE OVERLAY
   ============================================================ */

.au-maint {
    position: fixed;
    inset: 0;
    background: rgba(0, 18, 25, 0.0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    opacity: 0;
    transition: opacity 400ms ease, background 600ms ease, backdrop-filter 600ms ease;
    pointer-events: none;
}

.au-maint--visible {
    opacity: 1;
    background: rgba(0, 18, 25, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    pointer-events: auto;
}

.au-maint--full {
    background: rgba(0, 18, 25, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.au-maint--exit {
    opacity: 0;
    transition: opacity 500ms ease;
}

[data-theme="light"] .au-maint--visible {
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .au-maint--full {
    background: rgba(255, 255, 255, 0.95);
}

.au-maint__box {
    text-align: center;
    max-width: 440px;
    width: 100%;
    animation: au-maint-in 500ms ease;
}

@keyframes au-maint-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.au-maint__icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    animation: au-maint-wobble 2s ease-in-out infinite;
}

@keyframes au-maint-wobble {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-8deg); }
    75% { transform: rotate(8deg); }
}

.au-maint__title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-strong);
    margin-bottom: var(--space-sm);
}

.au-maint__message {
    font-size: var(--text-base);
    color: var(--text-muted);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-lg);
}

.au-maint__eta {
    display: inline-flex;
    flex-direction: column;
    gap: var(--space-2xs);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-lg);
    margin-bottom: var(--space-lg);
}

.au-maint__eta-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

.au-maint__eta-value {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--accent-hover);
}

.au-maint__pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-hover);
    margin: 0 auto var(--space-md);
    animation: au-pulse 2s infinite;
}

@keyframes au-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.au-maint__sub {
    font-size: var(--text-xs);
    color: var(--text-faint);
}

/* ============================================================
   MAINTENANCE GRACE BANNER (non-blocking)
   ============================================================ */

.au-maint-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99998;
    transform: translateY(-100%);
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.au-maint-banner--visible {
    transform: translateY(0);
    pointer-events: auto;
}

.au-maint-banner__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(135deg, #c04040, #a03030);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-align: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.au-maint-banner__icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.au-maint-banner__text {
    line-height: var(--leading-normal);
}

.au-maint-banner__text strong {
    font-family: var(--font-mono);
    font-size: var(--text-base);
}

/* ============================================================
   CUSTOM CHECKBOX
   ============================================================ */

.au-check,
.perm-check input[type="checkbox"],
.perm-toggle,
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    flex-shrink: 0;
    vertical-align: middle;
}

.au-check:hover,
.perm-check input[type="checkbox"]:hover,
.perm-toggle:hover,
input[type="checkbox"]:hover {
    border-color: var(--accent);
}

.au-check:checked,
.perm-check input[type="checkbox"]:checked,
.perm-toggle:checked,
input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.au-check:checked::after,
.perm-check input[type="checkbox"]:checked::after,
.perm-toggle:checked::after,
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.au-check:focus-visible,
input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.au-check:disabled,
.perm-toggle:disabled,
input[type="checkbox"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================
   COOKIE BANNER
   ============================================================ */

.au-cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-toast, 9999);
    background: var(--bg-raised, #0a1628);
    border-top: 1px solid var(--border-subtle, #1a2a3a);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
}

.au-cookie-banner--visible {
    transform: translateY(0);
}

.au-cookie-banner__inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.au-cookie-banner__text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-muted, #a0aec0);
    line-height: 1.5;
    min-width: 200px;
}

.au-cookie-banner__text strong {
    color: var(--text-strong, #fff);
}

.au-cookie-banner__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.au-cookie-banner__btn {
    font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 1.2rem;
    border-radius: var(--radius-md, 8px);
    border: 1px solid var(--border, #2a3a4a);
    cursor: pointer;
    transition: all 200ms ease;
    white-space: nowrap;
}

.au-cookie-banner__btn--accept {
    background: var(--accent, #005F73);
    border-color: var(--accent, #005F73);
    color: #fff;
}

.au-cookie-banner__btn--accept:hover {
    background: var(--accent-hover, #0A9396);
    border-color: var(--accent-hover, #0A9396);
}

.au-cookie-banner__btn--decline {
    background: transparent;
    color: var(--text-muted, #a0aec0);
    border-color: var(--border, #2a3a4a);
}

.au-cookie-banner__btn--decline:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.04));
    color: var(--text, #e0e0e0);
}

@media (max-width: 560px) {
    .au-cookie-banner__inner {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .au-cookie-banner__actions {
        justify-content: center;
    }
}
