/* =============================================================================
   Čaroděj — design tokens, reset, base typography, layout helpers.

   Aesthetic direction: "observatory". An engraved star atlas printed on
   ink-blue paper, ruled with gold-leaf hairlines and brass instrument marks.
   Dark-only by design — there is no light theme and none is planned.
   ============================================================================= */

:root {
    color-scheme: dark;

    /* --- Backgrounds ----------------------------------------------------- */
    --color-bg: #0a0d18;            /* deep midnight ink, deliberately not black */
    --color-bg-deep: #06080f;       /* recessed areas: footer, admin chrome */
    --color-surface: #111726;
    --color-surface-2: #171e30;
    --color-surface-hover: #1b2337;

    /* --- Text ------------------------------------------------------------ */
    --color-text: #f2efe8;          /* warm parchment white, not #fff */
    --color-text-secondary: #bdb8ac;
    --color-text-muted: #838b9e;
    --color-text-inverse: #12100a;  /* on gilded surfaces */

    /* --- Gold & copper accents ------------------------------------------- */
    --color-gold: #d8b36b;
    --color-gold-bright: #f0d8a2;
    --color-gold-hover: #e7c88a;
    --color-gold-deep: #a5813c;
    --color-gold-dim: rgb(216 179 107 / 55%);
    --color-gold-line: rgb(216 179 107 / 28%);
    --color-gold-wash: rgb(216 179 107 / 8%);
    --color-copper: #c07a4b;
    --color-copper-hover: #d68f5e;
    --color-copper-line: rgb(192 122 75 / 32%);

    /* --- Borders --------------------------------------------------------- */
    --color-border: rgb(226 225 222 / 10%);
    --color-border-strong: rgb(226 225 222 / 18%);

    /* --- Status ---------------------------------------------------------- */
    --color-success: #6fbf8e;
    --color-warning: #e0a85b;
    --color-danger: #e2716b;
    --color-info: #7fa8d8;

    /* --- Spacing (4px base, loosening at the top of the scale) ----------- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --space-9: 6rem;
    --space-10: 8rem;

    /* --- Radii — small on purpose; engraved plates have sharp corners ---- */
    --radius-xs: 2px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* --- Elevation & glow ------------------------------------------------ */
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow-md: 0 14px 34px -16px rgb(0 0 0 / 75%);
    --shadow-lg: 0 30px 70px -24px rgb(0 0 0 / 85%);
    --glow-gold: 0 0 40px -18px rgb(216 179 107 / 70%);
    --glow-inset: inset 0 1px 0 rgb(255 255 255 / 6%);

    /* --- Typography ------------------------------------------------------ */
    --font-display: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
    --font-body: 'Commissioner', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SFMono-Regular', 'Cascadia Mono', Menlo, Consolas, monospace;

    --text-2xs: 0.6875rem;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1.0625rem;         /* 17px — a touch larger, dark type reads smaller */
    --text-lg: 1.1875rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;
    --text-4xl: 3rem;
    --text-display: clamp(2.5rem, 1.4rem + 4.4vw, 4.75rem);

    --leading-tight: 1.08;
    --leading-snug: 1.28;
    --leading-normal: 1.65;
    --leading-relaxed: 1.8;

    --tracking-tight: -0.015em;
    --tracking-wide: 0.06em;
    --tracking-wider: 0.14em;
    --tracking-widest: 0.22em;

    /* --- Motion ---------------------------------------------------------- */
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --transition-fast: 140ms var(--ease);
    --transition: 240ms var(--ease);
    --transition-slow: 600ms var(--ease);

    /* --- Layout ---------------------------------------------------------- */
    --container: 68rem;
    --container-narrow: 46rem;
}

/* =============================================================================
   Reset
   ============================================================================= */

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

* {
    margin: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scrollbar-color: rgb(216 179 107 / 30%) transparent;
    scrollbar-width: thin;
}

body {
    min-height: 100dvh;
    font: 400 var(--text-base) / var(--leading-normal) var(--font-body);
    font-feature-settings: 'kern', 'liga';
    color: var(--color-text);
    background-color: var(--color-bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgb(216 179 107 / 10%), transparent 70%),
        radial-gradient(ellipse 55% 45% at 8% 6%, rgb(192 122 75 / 7%), transparent 65%),
        radial-gradient(ellipse 90% 55% at 88% 102%, rgb(76 92 158 / 10%), transparent 70%);
    background-attachment: fixed;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* The star field. Two tiles of different sizes give a parallax-free but
   layered sky; the mask keeps stars out of the reading area lower down. */
body::before {
    position: fixed;
    z-index: -2;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgb(242 239 232 / 45%), transparent 100%),
        radial-gradient(1px 1px at 70% 12%, rgb(242 239 232 / 30%), transparent 100%),
        radial-gradient(1px 1px at 45% 78%, rgb(216 179 107 / 38%), transparent 100%),
        radial-gradient(1.4px 1.4px at 88% 62%, rgb(242 239 232 / 22%), transparent 100%),
        radial-gradient(1.6px 1.6px at 15% 65%, rgb(255 250 235 / 55%), transparent 100%),
        radial-gradient(1.2px 1.2px at 62% 35%, rgb(216 179 107 / 45%), transparent 100%),
        radial-gradient(2px 2px at 82% 88%, rgb(255 250 235 / 26%), transparent 100%);
    background-size: 300px 260px, 300px 260px, 300px 260px, 300px 260px, 660px 570px, 660px 570px, 660px 570px;
    mask-image: linear-gradient(180deg, #000, rgb(0 0 0 / 35%) 55%, transparent);
    pointer-events: none;
    content: '';
}

/* Paper grain. Keeps the flat gradients from looking like plastic. */
body::after {
    position: fixed;
    z-index: -1;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.035;
    mix-blend-mode: overlay;
    pointer-events: none;
    content: '';
}

img,
svg,
video,
canvas {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: 0;
}

:target {
    scroll-margin-block-start: var(--space-8);
}

/* =============================================================================
   Base typography
   ============================================================================= */

h1,
h2,
h3,
h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--color-text);
    text-wrap: balance;
}

h1 {
    font-size: var(--text-4xl);
}

h2 {
    font-size: var(--text-3xl);
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
    letter-spacing: 0;
}

p,
li {
    text-wrap: pretty;
}

strong,
b {
    font-weight: 600;
    color: var(--color-text);
}

small {
    font-size: var(--text-sm);
}

code,
kbd,
samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

a {
    color: var(--color-gold);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-decoration-color: var(--color-gold-line);
    text-underline-offset: 0.22em;
    transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
    color: var(--color-gold-hover);
    text-decoration-color: currentcolor;
}

::selection {
    color: var(--color-text);
    background: rgb(216 179 107 / 28%);
}

:focus-visible {
    border-radius: var(--radius-xs);
    outline: 2px solid var(--color-gold);
    outline-offset: 3px;
}

/* =============================================================================
   Layout helpers
   ============================================================================= */

.container {
    width: 100%;
    max-width: var(--container);
    padding-inline: var(--space-5);
    margin-inline: auto;
}

.container--narrow {
    max-width: var(--container-narrow);
}

.stack > * + * {
    margin-block-start: var(--stack-space, var(--space-5));
}

.cluster {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cluster-space, var(--space-4));
    align-items: center;
}

.cluster--center {
    justify-content: center;
}

.section {
    padding-block: var(--section-space, var(--space-9));
}

.measure {
    max-width: 58ch;
}

.text-center {
    text-align: center;
}

.center {
    margin-inline: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    inset-inline-start: var(--space-4);
    inset-block-start: var(--space-4);
    z-index: 100;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text-inverse);
    text-decoration: none;
    background: var(--color-gold);
    border-radius: var(--radius-sm);
    transform: translateY(-200%);
    transition: transform var(--transition);
}

.skip-link:focus-visible {
    transform: none;
}

/* =============================================================================
   Motion — one orchestrated page-load reveal, staggered by --delay.
   ============================================================================= */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes drift {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.reveal {
    animation: rise 900ms var(--ease) backwards;
    animation-delay: var(--delay, 0ms);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    /* The delay has to go too, not just the duration: .reveal fills backwards,
       so a stagger left in place would keep content invisible for half a
       second before snapping in — the opposite of what was asked for. */
    *,
    *::before,
    *::after {
        animation-delay: 0ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
