/* ============================================================
   Kim Cooper — cooper.kim
   "Golden hour on the Rift": a living equatorial sky above a
   horizon hairline, the name rising from still water.
   One page, four skies, driven by real Nairobi time (EAT).
   ============================================================ */

/* ---------- Fonts (self-hosted, OFL) ---------- */
@font-face {
    font-family: 'Italiana';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('assets/fonts/italiana-latin.woff2') format('woff2');
}
@font-face {
    font-family: 'Archivo';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('assets/fonts/archivo-latin.woff2') format('woff2');
}

/* ---------- Registered tokens: theme switches crossfade ---------- */
@property --sky-1 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sky-2 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sky-3 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --sky-4 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --water-1 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --water-2 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --water-3 { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --water-glow { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --ink { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --ink-w { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --accent { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --glow-c { syntax: '<color>'; inherits: true; initial-value: #000; }
@property --stars { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sun-op { syntax: '<number>'; inherits: true; initial-value: 1; }
@property --moon-op { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --glow-op { syntax: '<number>'; inherits: true; initial-value: 0; }

/* ---------- Theme palettes ---------- */
.theme-sunrise {
    --sky-1: #6e7fbb; --sky-2: #c98ba4; --sky-3: #f2a67f; --sky-4: #ffd9a3;
    --water-1: #e2a186; --water-2: #7a4c66; --water-3: #38264a;
    --water-glow: #ffcf9a;
    --ink: #32253f; --ink-w: #f4e6da; --accent: #a5712f;
    --glow-c: #ffbf80; --glow-op: 0.55;
    --stars: 0.18; --sun-op: 1; --moon-op: 0;
    color-scheme: light;
}
.theme-day {
    --sky-1: #4f97dd; --sky-2: #8cc4ee; --sky-3: #cfe8f7; --sky-4: #f2e6c8;
    --water-1: #b7d6ea; --water-2: #6f9cc4; --water-3: #3b5e85;
    --water-glow: #fdf0d0;
    --ink: #1d2d42; --ink-w: #1d2d42; --accent: #9c6f2e;
    --glow-c: #fff3cf; --glow-op: 0.28;
    --stars: 0; --sun-op: 1; --moon-op: 0;
    color-scheme: light;
}
.theme-sunset {
    --sky-1: #1f2c55; --sky-2: #5c4470; --sky-3: #c96a45; --sky-4: #f2a95c;
    --water-1: #c47a50; --water-2: #6d4057; --water-3: #272138;
    --water-glow: #ff9e50;
    --ink: #f7e7cd; --ink-w: #f7e7cd; --accent: #e0b36f;
    --glow-c: #ff8f3f; --glow-op: 0.6;
    --stars: 0.25; --sun-op: 1; --moon-op: 0;
    color-scheme: dark;
}
.theme-night {
    --sky-1: #04060e; --sky-2: #0a1226; --sky-3: #14203c; --sky-4: #24324e;
    --water-1: #101c33; --water-2: #070d1c; --water-3: #03050b;
    --water-glow: #2c3d5e;
    --ink: #e8edf5; --ink-w: #e8edf5; --accent: #d9b477;
    --glow-c: #5a74a8; --glow-op: 0.3;
    --stars: 1; --sun-op: 0; --moon-op: 1;
    color-scheme: dark;
}

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

html {
    --seam: 61dvh;
    --hair: color-mix(in oklab, var(--ink) 38%, transparent);
    --ink-soft: color-mix(in oklab, var(--ink) 80%, transparent);
    --ink-faint: color-mix(in oklab, var(--ink) 68%, transparent);
    height: 100%;
    transition:
        --sky-1 1.4s ease, --sky-2 1.4s ease, --sky-3 1.4s ease, --sky-4 1.4s ease,
        --water-1 1.4s ease, --water-2 1.4s ease, --water-3 1.4s ease, --water-glow 1.4s ease,
        --ink 1.4s ease, --ink-w 1.4s ease, --accent 1.4s ease, --glow-c 1.4s ease,
        --stars 1.6s ease, --sun-op 1.2s ease, --moon-op 1.2s ease, --glow-op 1.4s ease;
}

body {
    height: 100%;
    overflow: hidden;
    font-family: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
    color: var(--ink);
    background: var(--sky-3); /* pre-CSS-paint fallback */
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 1px, 1px); white-space: nowrap; border: 0;
}

/* ---------- The sky ---------- */
.sky {
    position: fixed;
    inset: 0 0 calc(100dvh - var(--seam)) 0;
    z-index: 0;
    background: linear-gradient(180deg,
        var(--sky-1) 0%,
        var(--sky-2) 38%,
        var(--sky-3) 72%,
        var(--sky-4) 100%);
    overflow: hidden;
}

.water {
    position: fixed;
    top: var(--seam); left: 0; right: 0; bottom: 0;
    z-index: 1;
    background: linear-gradient(180deg,
        var(--water-glow) 0%,
        var(--water-1) 12%,
        var(--water-2) 48%,
        var(--water-3) 100%);
}
/* faint still-water texture */
.water::after {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(180deg,
        color-mix(in oklab, var(--ink) 5%, transparent) 0 1px,
        transparent 1px 7px);
    opacity: 0.5;
}

/* stars — JS populates; visibility is theme-driven */
.stars { position: absolute; inset: 0; opacity: var(--stars); }
.star {
    position: absolute;
    border-radius: 50%;
    background: #e9efff;
    box-shadow: 0 0 4px rgba(210, 225, 255, 0.8);
}
.star.tw { animation: twinkle var(--d, 4s) ease-in-out var(--dl, 0s) infinite; }
@keyframes twinkle {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 1; }
}

/* sun / moon / atmosphere glow — positioned by app.js via --sx/--sy */
.sun, .moon, .glow {
    position: absolute;
    left: var(--sx, 50%);
    top: var(--sy, 30%);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    transition: left 1.4s ease, top 1.4s ease;
    pointer-events: none;
}
.sun {
    width: clamp(56px, 7vw, 96px);
    aspect-ratio: 1;
    background: radial-gradient(circle at 50% 42%, #fff9e6 0%, #ffe9b0 45%, #ffc76e 100%);
    box-shadow: 0 0 60px 20px rgba(255, 190, 90, 0.45), 0 0 140px 60px rgba(255, 150, 60, 0.18);
    opacity: var(--sun-op);
}
.moon {
    width: clamp(44px, 5.5vw, 72px);
    aspect-ratio: 1;
    background: radial-gradient(circle at 38% 35%, #f4f6fa 0%, #cfd8e6 55%, #aeb9cd 100%);
    box-shadow: 0 0 40px 12px rgba(200, 215, 255, 0.28);
    opacity: var(--moon-op);
}
.glow {
    width: 62vmax;
    aspect-ratio: 1;
    background: radial-gradient(circle, var(--glow-c) 0%, transparent 62%);
    mix-blend-mode: screen;
    opacity: var(--glow-op);
}

/* film grain: kills gradient banding, adds atmosphere */
.grain {
    position: fixed; inset: 0;
    z-index: 60;
    pointer-events: none;
    opacity: 0.05;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* ---------- Top bar ---------- */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(22px, env(safe-area-inset-top)) clamp(20px, 3vw, 36px) 0;
}

.locale {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}
.locale-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 3.2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

/* theme switch — quiet segmented control */
.theme-switch {
    display: flex;
    gap: 2px;
    padding: 4px;
    border-radius: 999px;
    border: 1px solid var(--hair);
    background: color-mix(in oklab, var(--ink) 6%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-faint);
    cursor: pointer;
    transition: color 0.25s ease, background 0.25s ease, transform 0.25s ease;
}
.theme-btn svg { width: 15px; height: 15px; }
.theme-btn:hover { color: var(--ink); }
.theme-btn[aria-pressed="true"] {
    color: var(--accent);
    background: color-mix(in oklab, var(--ink) 10%, transparent);
}

/* ---------- Stage: the lockup at the horizon ---------- */
.stage {
    position: relative;
    z-index: 10;
    height: 100dvh;
}

.lockup {
    position: absolute;
    left: 0; right: 0;
    bottom: calc(100dvh - var(--seam));
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.eyebrow {
    font-size: clamp(10px, 1.1vw, 12px);
    font-weight: 400;
    letter-spacing: 0.44em;
    margin-left: 0.44em; /* optically recenter tracked text */
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: clamp(14px, 2.4vh, 26px);
}

.name {
    font-family: 'Italiana', 'Times New Roman', serif;
    font-weight: 400;
    font-size: clamp(3.1rem, 12.5vw, 10.5rem);
    line-height: 1;
    letter-spacing: 0.1em;
    margin-left: 0.1em; /* recenter tracked caps */
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
}

/* the horizon: full-bleed hairline exactly at the name's baseline */
.horizon {
    width: 100vw;
    margin-left: calc(50% - 50vw - 0.05em);
    height: 1px;
    margin-top: -0.115em; /* pull up from line-box bottom to cap bottom */
    background: linear-gradient(90deg,
        transparent 0%,
        var(--hair) 12%,
        var(--hair) 88%,
        transparent 100%);
}

/* the reflection: the name in still water.
   The mask lives on the unflipped parent so it always fades
   away from the seam; the child flips around the seam itself. */
.reflection {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    mask-image: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 68%);
    -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, transparent 68%);
}
.reflection-text {
    font-family: 'Italiana', 'Times New Roman', serif;
    font-size: clamp(3.1rem, 12.5vw, 10.5rem);
    line-height: 1;
    letter-spacing: 0.1em;
    margin-left: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
    transform: scaleY(-0.82);
    transform-origin: 50% 0;
    opacity: 0.5;
    filter: blur(1.2px);
}

/* below the horizon */
.under {
    position: absolute;
    top: calc(var(--seam) + clamp(88px, 17vh, 160px));
    left: 0; right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(14px, 2.2vh, 22px);
    padding: 0 24px;
    text-align: center;
}

.tagline {
    font-family: 'Italiana', 'Times New Roman', serif;
    font-size: clamp(1.1rem, 2.1vw, 1.55rem);
    letter-spacing: 0.06em;
    line-height: 1.45;
    color: var(--ink-w);
    max-width: 34ch;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.5em;
    margin-left: 0.5em;
    text-transform: uppercase;
    color: color-mix(in oklab, var(--accent) 45%, var(--ink-w));
}
.status-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

/* ---------- Bottom bar ---------- */
.bottombar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    justify-content: center;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.contact {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    border-radius: 999px;
    border: 1px solid color-mix(in oklab, var(--ink-w) 48%, transparent);
    background: color-mix(in oklab, var(--ink-w) 8%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--ink-w);
    text-decoration: none;
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease, border-color 0.3s ease;
}
.contact svg { width: 15px; height: 15px; }
.contact:hover {
    transform: translateY(-2px);
    background: color-mix(in oklab, var(--ink-w) 14%, transparent);
    border-color: color-mix(in oklab, var(--ink-w) 60%, transparent);
}

/* ---------- Focus ---------- */
.theme-btn:focus-visible, .contact:focus-visible {
    outline: 1.5px solid var(--accent);
    outline-offset: 3px;
}

/* ---------- Entrance choreography ----------
   The name unmasks upward out of the horizon; everything else
   settles quietly after. Final states are the CSS defaults, so
   reduced-motion users and no-JS get the settled page. */
@media (prefers-reduced-motion: no-preference) {
    body:not(.ready) .name {
        clip-path: inset(100% -6% -30% -6%);
    }
    body.ready .name {
        clip-path: inset(-30% -6% -30% -6%);
        transition: clip-path 1.15s cubic-bezier(0.19, 0.8, 0.22, 1) 0.25s;
    }
    body:not(.ready) .horizon {
        transform: scaleX(0);
    }
    body.ready .horizon {
        transform: scaleX(1);
        transition: transform 1.1s cubic-bezier(0.19, 0.8, 0.22, 1) 0.1s;
    }
    body:not(.ready) .reflection { opacity: 0; }
    body.ready .reflection {
        opacity: 1;
        transition: opacity 1.4s ease 1s;
    }
    body:not(.ready) .eyebrow,
    body:not(.ready) .tagline,
    body:not(.ready) .status,
    body:not(.ready) .topbar,
    body:not(.ready) .bottombar {
        opacity: 0;
        transform: translateY(12px);
    }
    body.ready .eyebrow {
        opacity: 1; transform: none;
        transition: opacity 0.9s ease 0.7s, transform 0.9s ease 0.7s;
    }
    body.ready .tagline {
        opacity: 1; transform: none;
        transition: opacity 0.9s ease 1.25s, transform 0.9s ease 1.25s;
    }
    body.ready .status {
        opacity: 1; transform: none;
        transition: opacity 0.9s ease 1.4s, transform 0.9s ease 1.4s;
    }
    body.ready .topbar, body.ready .bottombar {
        opacity: 1; transform: none;
        transition: opacity 1s ease 1.55s, transform 1s ease 1.55s;
    }
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
    html { --seam: 57dvh; }
    .name, .reflection-text { letter-spacing: 0.07em; margin-left: 0.07em; }
    .horizon { margin-left: calc(50% - 50vw - 0.035em); }
    .reflection-text { opacity: 0.3; }
    .locale { font-size: 10px; letter-spacing: 0.18em; }
    .under { top: calc(var(--seam) + clamp(56px, 12vh, 96px)); }
}

/* short landscape screens (phones rotated, short windows) */
@media (max-height: 560px) {
    html { --seam: 66dvh; }
    .name, .reflection-text { font-size: clamp(2.4rem, 11vh, 5rem); }
    .under { top: calc(var(--seam) + 5vh); gap: 10px; }
    .eyebrow { margin-bottom: 10px; }
}
