/* =========================================================
   tanso.day — a day-long carbon narrative
   Retro-futuristic + vaporwave + temporal sky cycle
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
    /* Palette (from DESIGN.md) */
    --predawn: #1a1040;
    --dawn: #e87461;
    --morning: #4a8bc2;
    --midday: #3078b0;
    --afternoon: #c4944a;
    --golden: #e8a84a;
    --dusk: #6a3a8a;
    --night: #0a0e2a;
    --twilight-violet: #3a2060;

    /* Adaptive text */
    --text-light: #f0f0f0;
    --text-dark: #1a1a2a;

    /* Card surfaces */
    --glass-light: rgba(255, 255, 255, 0.12);
    --glass-light-edge: rgba(255, 255, 255, 0.20);
    --glass-dark: rgba(0, 0, 0, 0.08);
    --glass-dark-edge: rgba(0, 0, 0, 0.18);

    /* Type scale */
    --f-display: 'Righteous', system-ui, sans-serif;
    --f-head: 'Quicksand', system-ui, sans-serif;
    --f-body: 'Mulish', system-ui, sans-serif;
    --f-mono: 'Cousine', 'Courier New', monospace;

    /* Layout */
    --card-max: 680px;
    --gutter: clamp(20px, 4vw, 56px);

    /* Live theme variables (driven by JS) */
    --text: var(--text-light);
    --text-soft: rgba(240, 240, 240, 0.66);
    --card-bg: var(--glass-light);
    --card-edge: var(--glass-light-edge);
    --accent: var(--dawn);
    --celest-color: #fff5d6;
    --celest-glow: rgba(255, 235, 180, 0.55);
    --horizon-fill: #060818;
}

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

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    background: #060818;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--f-body);
    font-size: 16px;
    line-height: 26px;
    font-weight: 400;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    transition: color 300ms ease;
    min-height: 100vh;
}

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

button {
    font-family: inherit;
    cursor: pointer;
    background: none;
    border: none;
    color: inherit;
    padding: 0;
}

a { color: inherit; text-decoration: none; }

/* =========================================================
   Sky gradient — fixed, full-bleed, scroll-driven
   ========================================================= */
.sky {
    position: fixed;
    inset: 0;
    z-index: -10;
    background:
        linear-gradient(
            180deg,
            var(--predawn)   0%,
            #2a1860        10%,
            var(--dawn)    20%,
            #d77a7d        30%,
            var(--morning) 50%,
            var(--midday)  60%,
            var(--afternoon) 70%,
            var(--golden)  78%,
            var(--dusk)    88%,
            var(--twilight-violet) 94%,
            var(--night)   100%
        );
    /* Track scroll progress through CSS var --p (0..1) */
    background-size: 100% 600vh;
    background-position: 0% calc(var(--p, 0) * 500vh);
    transition: background-position 80ms linear;
}

/* Soft vignette for atmosphere */
.sky::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 30%, transparent 30%, rgba(0,0,0,0.18) 100%),
        radial-gradient(ellipse at 50% 100%, rgba(0,0,0,0.20), transparent 60%);
    pointer-events: none;
}

/* =========================================================
   Stars — pre-dawn + night
   ========================================================= */
.stars {
    position: fixed;
    inset: 0;
    z-index: -8;
    pointer-events: none;
    opacity: var(--star-opacity, 1);
    transition: opacity 600ms ease;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    animation: twinkle 3.4s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: var(--s-base, 0.5); transform: scale(1); }
    50%      { opacity: calc(var(--s-base, 0.5) + 0.3); transform: scale(1.2); }
}

/* =========================================================
   Carbon cloud wisps
   ========================================================= */
.clouds {
    position: fixed;
    inset: 0;
    z-index: -6;
    pointer-events: none;
    overflow: hidden;
    opacity: var(--cloud-opacity, 0.8);
    transition: opacity 500ms ease;
}

.cloud {
    position: absolute;
    display: block;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50% 60% 55% 45% / 60% 50% 50% 60%;
    filter: blur(18px);
    will-change: transform;
}

.cloud-a { top: 12%; left: -20%; width: 360px; height: 90px; animation: drift-a 38s linear infinite; }
.cloud-b { top: 28%; left: -15%; width: 280px; height: 70px; animation: drift-b 30s linear infinite; }
.cloud-c { top: 44%; left: -25%; width: 420px; height: 110px; animation: drift-c 44s linear infinite; }
.cloud-d { top: 60%; left: -18%; width: 320px; height: 80px; animation: drift-a 34s linear infinite; }
.cloud-e { top: 72%; left: -22%; width: 380px; height: 95px; animation: drift-b 40s linear infinite; }
.cloud-f { top: 86%; left: -10%; width: 240px; height: 60px; animation: drift-c 26s linear infinite; }

@keyframes drift-a {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(140vw, -10px, 0); }
}
@keyframes drift-b {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(140vw, 8px, 0); }
}
@keyframes drift-c {
    from { transform: translate3d(0, 0, 0); }
    to   { transform: translate3d(140vw, -4px, 0); }
}

/* =========================================================
   Celestial body — sun & moon
   ========================================================= */
.celestial {
    position: fixed;
    inset: 0;
    z-index: -7;
    pointer-events: none;
}

.sun, .moon {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    transform: translate3d(var(--cx, 10vw), var(--cy, 90vh), 0);
    transition: opacity 600ms ease;
    will-change: transform, opacity;
}

.sun {
    background:
        radial-gradient(circle at 35% 35%, #fff7d4 0%, #ffd97a 35%, #f5a648 70%, rgba(245, 166, 72, 0) 78%);
    box-shadow:
        0 0 36px 6px rgba(255, 217, 122, 0.55),
        0 0 90px 20px rgba(245, 166, 72, 0.30);
    opacity: var(--sun-opacity, 0);
    animation: sun-pulse 5s ease-in-out infinite;
}

@keyframes sun-pulse {
    0%, 100% { box-shadow: 0 0 36px 6px rgba(255, 217, 122, 0.55), 0 0 90px 20px rgba(245, 166, 72, 0.30); }
    50%      { box-shadow: 0 0 50px 10px rgba(255, 217, 122, 0.70), 0 0 120px 30px rgba(245, 166, 72, 0.42); }
}

.moon {
    background:
        radial-gradient(circle at 38% 36%, #f4f7ff 0%, #d8def0 55%, #aab4cd 100%),
        radial-gradient(circle at 65% 62%, rgba(80, 90, 120, 0.18) 0 8%, transparent 9%),
        radial-gradient(circle at 28% 70%, rgba(80, 90, 120, 0.14) 0 5%, transparent 6%),
        radial-gradient(circle at 55% 30%, rgba(80, 90, 120, 0.12) 0 4%, transparent 5%);
    background-blend-mode: normal, multiply, multiply, multiply;
    box-shadow: 0 0 28px 4px rgba(220, 230, 255, 0.30);
    opacity: var(--moon-opacity, 1);
}

/* =========================================================
   Horizon silhouette
   ========================================================= */
.horizon {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 22vh;
    z-index: -5;
    pointer-events: none;
}

.horizon svg {
    width: 100%;
    height: 100%;
}

#horizon-path {
    fill: var(--horizon-fill);
    opacity: 0.42;
    transition: fill 600ms ease, opacity 600ms ease;
}

/* =========================================================
   Time markers (left margin)
   ========================================================= */
.time-markers {
    position: fixed;
    left: 22px;
    top: 0;
    height: 100vh;
    width: 64px;
    z-index: 6;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18vh 0 18vh;
    font-family: var(--f-mono);
    font-size: 12px;
    line-height: 16px;
    color: var(--text);
}

.tm {
    opacity: 0.5;
    transform: translateX(0) scale(1);
    transition: opacity 300ms ease, transform 300ms ease, color 300ms ease;
    letter-spacing: 0.06em;
}

.tm.is-active {
    opacity: 1;
    transform: scale(1.1);
}

.tm span {
    display: inline-block;
    padding-left: 14px;
    border-left: 1px solid currentColor;
}

/* =========================================================
   Clock navigation (top-right)
   ========================================================= */
.nav-clock {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 30;
    color: var(--text);
}

.clock-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--card-edge);
    color: var(--text);
    transition: background 300ms ease, border-color 300ms ease, color 300ms ease;
}

.clock-svg {
    width: 32px;
    height: 32px;
    color: var(--text);
}

#clock-hand {
    transform-origin: 16px 16px;
    transform: rotate(0deg);
    transition: transform 220ms ease;
}

.clock-label {
    font-family: var(--f-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    opacity: 0.85;
}

.clock-menu {
    position: absolute;
    top: 56px;
    right: 0;
    margin: 0;
    padding: 10px;
    list-style: none;
    min-width: 220px;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border: 1px solid var(--card-edge);
    border-radius: 14px;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease, background 300ms ease, border-color 300ms ease;
}

.nav-clock.is-open .clock-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.clock-menu li + li { margin-top: 2px; }

.clock-menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-family: var(--f-head);
    font-weight: 500;
    font-size: 14px;
    border-radius: 10px;
    transition: background 200ms ease;
}

.clock-menu a em {
    font-style: normal;
    font-family: var(--f-mono);
    font-size: 11px;
    opacity: 0.65;
    margin-right: 14px;
    letter-spacing: 0.08em;
}

.clock-menu a:hover { background: rgba(255, 255, 255, 0.10); }

/* =========================================================
   Page layout
   ========================================================= */
.page {
    position: relative;
    z-index: 1;
    padding: 0 var(--gutter) 0 calc(var(--gutter) + 60px);
    max-width: 1100px;
    margin: 0 auto;
}

/* =========================================================
   Hero
   ========================================================= */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    text-align: center;
    padding: 80px 0 60px;
}

.hero-inner {
    max-width: 760px;
    position: relative;
    z-index: 2;
}

.kicker {
    display: inline-block;
    font-family: var(--f-mono);
    font-size: 12px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.7;
    margin-bottom: 26px;
    padding: 4px 14px;
    border: 1px solid var(--card-edge);
    border-radius: 999px;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.display {
    font-family: var(--f-display);
    font-weight: 400;
    color: var(--accent);
    letter-spacing: -0.01em;
    margin: 0;
    line-height: 1;
    text-shadow: 0 2px 30px rgba(0, 0, 0, 0.25);
}

#site-title {
    font-size: clamp(72px, 14vw, 168px);
    margin-bottom: 26px;
    opacity: 0;
    animation: title-in 1800ms ease-out 1.2s forwards;
}

@keyframes title-in {
    0%   { opacity: 0; transform: translateY(20px) scale(0.96); letter-spacing: 0.08em; }
    100% { opacity: 1; transform: translateY(0)    scale(1);    letter-spacing: -0.01em; }
}

.hero-sub {
    font-family: var(--f-head);
    font-weight: 400;
    font-size: clamp(16px, 1.6vw, 19px);
    line-height: 1.6;
    color: var(--text);
    opacity: 0;
    max-width: 520px;
    margin: 0 auto;
    animation: fade-up 1400ms ease-out 2.2s forwards;
}

@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 0.92; transform: translateY(0); }
}

.hero-arrow {
    width: 28px;
    height: 44px;
    margin: 60px auto 0;
    color: var(--text);
    opacity: 0;
    animation: fade-arrow 1200ms ease-out 3s forwards, bob 2.4s ease-in-out 4.2s infinite;
}

@keyframes fade-arrow { to { opacity: 0.7; } }
@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(8px); }
}

/* Pre-dawn "line of sunrise coral" rising along the bottom edge */
.dawn-line {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0;
    background: linear-gradient(180deg, transparent 0%, var(--dawn) 40%, var(--dawn) 100%);
    opacity: 0.55;
    pointer-events: none;
    animation: dawn-rise 3.4s ease-out 1s forwards;
    filter: blur(2px);
}

@keyframes dawn-rise {
    0%   { height: 0;   opacity: 0; }
    20%  { height: 2px; opacity: 0.7; }
    100% { height: 38vh; opacity: 0.32; }
}

/* =========================================================
   Chapters / cards
   ========================================================= */
.chapter {
    position: relative;
    min-height: 88vh;
    padding: 90px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.time-rings {
    position: relative;
    width: 200px;
    height: 200px;
    margin-bottom: 36px;
    pointer-events: none;
}

.time-rings span {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(255, 255, 255, 0.30);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: border-color 400ms ease;
}

.time-rings span:nth-child(1) { width: 120px; height: 120px; animation: ring-pulse 6s ease-in-out infinite; }
.time-rings span:nth-child(2) { width: 160px; height: 160px; animation: ring-pulse 6s ease-in-out 1s infinite; }
.time-rings span:nth-child(3) { width: 200px; height: 200px; animation: ring-pulse 6s ease-in-out 2s infinite; }

body.theme-day .time-rings span { border-color: rgba(0, 0, 0, 0.22); }

@keyframes ring-pulse {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 0.85; }
}

.card {
    position: relative;
    width: 100%;
    max-width: var(--card-max);
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-edge);
    border-radius: 18px;
    padding: clamp(28px, 4vw, 48px);
    color: var(--text);
    transition: background 400ms ease, border-color 400ms ease, color 300ms ease, opacity 700ms ease, transform 700ms ease;
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.45);
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.time-tag {
    display: inline-block;
    font-family: var(--f-mono);
    font-size: 12px;
    line-height: 16px;
    letter-spacing: 0.10em;
    color: var(--text);
    opacity: 0.7;
    margin-bottom: 18px;
    text-transform: uppercase;
}

.card .display {
    font-size: clamp(56px, 8vw, 88px);
    color: var(--accent);
    margin-bottom: 18px;
    line-height: 0.95;
}

/* Headings inherit Quicksand for non-display contexts */
h1, h2, h3 {
    font-family: var(--f-head);
    font-weight: 700;
}

.lede {
    font-family: var(--f-head);
    font-weight: 500;
    font-size: clamp(18px, 1.7vw, 22px);
    line-height: 1.55;
    margin: 0 0 18px;
    color: var(--text);
}

.card p {
    margin: 0 0 14px;
    color: var(--text);
    opacity: 0.94;
}

.card p:last-child { margin-bottom: 0; }

/* Data strips inside cards */
.data-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--card-edge);
}

.data-strip > div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.data-strip em {
    font-style: normal;
    font-family: var(--f-display);
    font-size: clamp(20px, 2vw, 26px);
    color: var(--accent);
    line-height: 1;
}

.data-strip span {
    font-family: var(--f-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}

/* Sign-off block */
.signoff {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--card-edge);
    display: flex;
    align-items: center;
    gap: 14px;
}

.sig-mark {
    font-family: var(--f-display);
    font-size: 24px;
    color: var(--accent);
}

.signoff p {
    margin: 0;
    font-family: var(--f-head);
    font-size: 14px;
    opacity: 0.78;
}

/* =========================================================
   Footer
   ========================================================= */
.page-foot {
    padding: 60px 0 80px;
    color: var(--text);
}

.foot-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    align-items: center;
    justify-content: space-between;
    padding: 22px 26px;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-edge);
    border-radius: 14px;
    font-family: var(--f-head);
    font-size: 13px;
    opacity: 0.85;
}

.foot-row .mono { font-family: var(--f-mono); letter-spacing: 0.08em; }

/* =========================================================
   Themes — driven by JS via body class
   theme-night | theme-dawn | theme-day | theme-golden | theme-dusk
   ========================================================= */
body.theme-night {
    --text: var(--text-light);
    --text-soft: rgba(240, 240, 240, 0.7);
    --card-bg: var(--glass-light);
    --card-edge: var(--glass-light-edge);
    --accent: #f4d4a8;
    --horizon-fill: #050714;
    --star-opacity: 1;
    --cloud-opacity: 0.55;
}

body.theme-dawn {
    --text: var(--text-light);
    --text-soft: rgba(240, 240, 240, 0.78);
    --card-bg: var(--glass-light);
    --card-edge: var(--glass-light-edge);
    --accent: #ffd6c4;
    --horizon-fill: #2a0e1a;
    --star-opacity: 0.25;
    --cloud-opacity: 0.95;
}

body.theme-day {
    --text: var(--text-dark);
    --text-soft: rgba(26, 26, 42, 0.7);
    --card-bg: var(--glass-dark);
    --card-edge: var(--glass-dark-edge);
    --accent: #1a2c4a;
    --horizon-fill: #0e2a4a;
    --star-opacity: 0;
    --cloud-opacity: 0.5;
}

body.theme-golden {
    --text: var(--text-dark);
    --text-soft: rgba(26, 26, 42, 0.7);
    --card-bg: var(--glass-dark);
    --card-edge: var(--glass-dark-edge);
    --accent: #5a2818;
    --horizon-fill: #3a1a08;
    --star-opacity: 0;
    --cloud-opacity: 0.85;
}

body.theme-dusk {
    --text: var(--text-light);
    --text-soft: rgba(240, 240, 240, 0.74);
    --card-bg: var(--glass-light);
    --card-edge: var(--glass-light-edge);
    --accent: #ffd1a6;
    --horizon-fill: #1a0830;
    --star-opacity: 0.4;
    --cloud-opacity: 0.7;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 800px) {
    .page { padding: 0 22px; }
    .time-markers { left: 8px; width: 56px; padding: 14vh 0; }
    .nav-clock { top: 14px; right: 14px; }
    .clock-label { display: none; }
    .clock-menu { min-width: 180px; }
    .time-rings { width: 160px; height: 160px; margin-bottom: 28px; }
    .time-rings span:nth-child(1) { width: 90px; height: 90px; }
    .time-rings span:nth-child(2) { width: 120px; height: 120px; }
    .time-rings span:nth-child(3) { width: 160px; height: 160px; }
    .data-strip { grid-template-columns: 1fr 1fr; }
    .foot-row { flex-direction: column; align-items: flex-start; }
    .sun, .moon { width: 64px; height: 64px; }
}

@media (max-width: 500px) {
    .data-strip { grid-template-columns: 1fr; }
    .time-markers { display: none; }
    .page { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
