/* ============================================================
   haru.news — Mineral Crystal Formation Design System
   ============================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    /* Palette: Muted Mineral */
    --color-bg:         #F5F3EF;  /* Primary background: warm near-white, chalcedony */
    --color-surface:    #EDE9E3;  /* Secondary surface: card color */
    --color-spine:      #C8C4BC;  /* Muted warm gray: spine, hairline rules */
    --color-stone-mid:  #9E9389;  /* Medium stone: secondary text, labels */
    --color-text:       #5C5248;  /* Deep warm gray: primary body text */
    --color-accent-warm:#B8A89A;  /* Rose-tinged stone: right-side nodes */
    --color-accent-sage:#A8B4A8;  /* Sage mineral green: left-side nodes */
    --color-amber:      #D4C4B4;  /* Pale amber: crystalline breaks */
    --color-display:    #3A3330;  /* Deepest value: large display type only */

    /* Typography */
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'DM Sans', system-ui, sans-serif;

    /* Spacing */
    --timeline-entry-gap: 80px;
    --spine-width: 3px;
    --node-size: 16px;
    --card-max-width: 520px;
    --card-min-width: 280px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.5vw, 1.05rem);
    line-height: 1.75;
    overflow-x: hidden;
    /* Marble texture as atmospheric infrastructure (barely visible) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='bg-marble'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.018 0.022' numOctaves='3' seed='99'/%3E%3CfeColorMatrix type='saturate' values='0.1'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23bg-marble)' opacity='0.06'/%3E%3C/svg%3E");
}

/* ---------- Hidden SVG Filter Container ---------- */
#svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ============================================================
   HERO SECTION
   ============================================================ */

.hero {
    position: relative;
    height: 85vh;
    min-height: 500px;
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Marble texture band — centered vertically, full width, 20vh tall */
.hero-marble-band {
    position: relative;
    width: 100%;
    height: 20vh;
    min-height: 120px;
    background-color: var(--color-amber);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='200'%3E%3Cfilter id='mv'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.015 0.02' numOctaves='4' seed='42'/%3E%3CfeColorMatrix type='matrix' values='0.16 0.08 0.06 0 0.83 0.13 0.08 0.05 0 0.79 0.10 0.06 0.04 0 0.75 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='600' height='200' filter='url(%23mv)' opacity='0.18'/%3E%3C/svg%3E");
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Crystal cluster accent near wordmark */
.crystal-cluster {
    position: absolute;
    left: calc(50% - 340px);
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 60px;
    pointer-events: none;
}

.crystal-cluster-svg {
    width: 100%;
    height: 100%;
}

.hero-wordmark-wrap {
    text-align: center;
    z-index: 3;
    position: relative;
}

.hero-wordmark {
    font-family: var(--font-display);
    font-size: clamp(3.5rem, 8vw, 9rem);
    font-weight: 300;
    color: var(--color-display);
    letter-spacing: -0.02em;
    line-height: 1;
    /* Variable font axes: wonk animated via JS, optical-size auto */
    font-variation-settings: "wght" 300, "WONK" 0, "opsz" 72;
    animation: wonk-breathe 8s ease-in-out infinite alternate;
}

@keyframes wonk-breathe {
    0%   { font-variation-settings: "wght" 300, "WONK" 0, "opsz" 72; }
    50%  { font-variation-settings: "wght" 320, "WONK" 0.6, "opsz" 72; }
    100% { font-variation-settings: "wght" 300, "WONK" 1, "opsz" 72; }
}

.hero-tagline {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    color: var(--color-stone-mid);
    margin-top: 0.75rem;
    text-transform: uppercase;
}

/* Spine start — connects hero to timeline */
.spine-start {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: var(--spine-width);
    height: 80px;
    background: linear-gradient(to bottom, transparent, rgba(180,170,158,0.3));
    z-index: 1;
}

/* Micro-crystal field in hero */
.crystal-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.micro-crystal {
    position: absolute;
    animation: crystal-rotate 12s ease-in-out infinite alternate;
    transform-origin: center;
    will-change: transform;
}

.micro-crystal:nth-child(2) { animation-delay: -2s; animation-duration: 14s; }
.micro-crystal:nth-child(3) { animation-delay: -4s; animation-duration: 10s; }
.micro-crystal:nth-child(4) { animation-delay: -1s; animation-duration: 16s; }
.micro-crystal:nth-child(5) { animation-delay: -6s; animation-duration: 11s; }
.micro-crystal:nth-child(6) { animation-delay: -3s; animation-duration: 13s; }
.micro-crystal:nth-child(7) { animation-delay: -5s; animation-duration: 9s; }
.micro-crystal:nth-child(8) { animation-delay: -7s; animation-duration: 15s; }

@keyframes crystal-rotate {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(8deg); }
}

/* ============================================================
   TIMELINE SECTION
   ============================================================ */

.timeline {
    position: relative;
    width: 100%;
    padding: 60px 0 80px;
}

/* The central crystalline spine */
.spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    width: var(--spine-width);
    background: linear-gradient(
        to bottom,
        rgba(180,170,158,0.3),
        rgba(180,170,158,0.6) 50%,
        rgba(180,170,158,0.3)
    );
    z-index: 1;
    pointer-events: none;
}

/* ---- Timeline Entry ---- */
.timeline-entry {
    position: relative;
    width: 100%;
    margin-bottom: var(--timeline-entry-gap);
    display: flex;
    align-items: center;
    min-height: 160px;
}

/* Right-side entries */
.entry-right {
    justify-content: flex-end;
}

.entry-right .spine-node {
    left: calc(50% - 8px);
}

.entry-right .connector-line {
    left: 50%;
    width: calc(5% + 8px);
}

.entry-right .story-card {
    margin-right: 4%;
    margin-left: calc(50% + 5% + 8px);
    width: min(40vw, var(--card-max-width));
}

/* Left-side entries */
.entry-left {
    justify-content: flex-start;
}

.entry-left .spine-node {
    left: calc(50% - 8px);
}

.entry-left .connector-line {
    right: 50%;
    width: calc(5% + 8px);
    left: auto;
}

.entry-left .story-card {
    margin-left: 4%;
    margin-right: calc(50% + 5% + 8px);
    width: min(40vw, var(--card-max-width));
}

/* ---- Spine Diamond Nodes ---- */
.spine-node {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: var(--node-size);
    height: var(--node-size);
    background-color: var(--node-color, #B8A89A);
    opacity: 0.7;
    z-index: 3;
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}

.timeline-entry:hover .spine-node {
    transform: translateY(-50%) rotate(45deg) scale(1.5);
    opacity: 0.9;
}

/* ---- Connector Hairlines ---- */
.connector-line {
    position: absolute;
    top: 50%;
    height: 1px;
    border-top: 1px dashed rgba(180,170,158,0.4);
    z-index: 2;
    pointer-events: none;
}

/* ---- Story Cards ---- */
.story-card {
    position: relative;
    min-width: var(--card-min-width);
    padding: 2rem;
    background: rgba(248,246,242,0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(92,82,72,0.06);
    transition:
        transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        box-shadow 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* Left-edge accent: thin stone vein */
    border-left: 4px solid;
    border-image: linear-gradient(to bottom, var(--color-accent-warm), var(--color-accent-sage), var(--color-amber)) 1;
    z-index: 4;
}

/* Crystalline facet clipping — right card: bottom-right corner clipped */
.card-right {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 24px), calc(100% - 24px) 100%, 0 100%);
}

/* Crystalline facet clipping — left card: bottom-left corner clipped */
.card-left {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 24px 100%, 0 calc(100% - 24px));
}

.story-card:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 32px rgba(92,82,72,0.12);
}

/* Hover: weight axis shift on headline — handled by parent hover selector */
.story-card:hover .card-headline {
    font-variation-settings: "wght" 650, "opsz" 20;
}

/* Card Meta (timestamp + category) */
.card-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}

.card-timestamp,
.card-category {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--color-stone-mid);
    text-transform: uppercase;
}

.card-separator {
    color: var(--color-spine);
    font-size: 0.75rem;
}

/* Card Headline */
.card-headline {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.5vw, 2.2rem);
    font-weight: 400;
    font-variation-settings: "wght" 400, "opsz" 20;
    color: var(--color-display);
    line-height: 1.25;
    margin-bottom: 0.85rem;
    transition: font-variation-settings 0.4s ease-out;
}

/* Card Body */
.card-body {
    font-family: var(--font-body);
    font-size: clamp(0.92rem, 1.4vw, 1rem);
    font-weight: 400;
    color: var(--color-text);
    line-height: 1.75;
    max-width: 52ch;
    margin-bottom: 1rem;
}

/* Read time indicator */
.card-readtime {
    display: block;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--color-stone-mid);
    text-transform: uppercase;
    text-align: right;
    font-variant: small-caps;
}

/* ============================================================
   CRYSTALLINE BREAK SECTIONS
   ============================================================ */

.crystal-break {
    position: relative;
    width: 100%;
    min-height: 180px;
    background-color: var(--color-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='200'%3E%3Cfilter id='mb'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.015 0.02' numOctaves='4' seed='13'/%3E%3CfeColorMatrix type='matrix' values='0.22 0.10 0.07 0 0.78 0.18 0.09 0.06 0 0.74 0.14 0.07 0.05 0 0.70 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='800' height='200' filter='url(%23mb)' opacity='0.35'/%3E%3C/svg%3E");
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 10%;
    margin-bottom: var(--timeline-entry-gap);
    overflow: hidden;
    z-index: 2;
}

.break-quote {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 3vw, 3rem);
    font-weight: 300;
    font-style: italic;
    font-variation-settings: "wght" 300, "opsz" 36;
    color: #8E8578;
    text-align: center;
    max-width: 70ch;
    line-height: 1.4;
    position: relative;
    z-index: 2;
}

/* Break micro-crystals */
.break-crystal {
    position: absolute;
    animation: crystal-rotate 12s ease-in-out infinite alternate;
    transform-origin: center;
    pointer-events: none;
    z-index: 1;
}

.break-crystal:nth-child(2) { animation-delay: -2.5s; animation-duration: 15s; }
.break-crystal:nth-child(3) { animation-delay: -5s;   animation-duration: 10s; }
.break-crystal:nth-child(4) { animation-delay: -1.5s; animation-duration: 13s; }
.break-crystal:nth-child(5) { animation-delay: -7s;   animation-duration: 11s; }
.break-crystal:nth-child(6) { animation-delay: -3s;   animation-duration: 14s; }
.break-crystal:nth-child(7) { animation-delay: -6s;   animation-duration: 9s;  }
.break-crystal:nth-child(8) { animation-delay: -4s;   animation-duration: 16s; }

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
    position: relative;
    background-color: var(--color-bg);
    border-top: 1px solid rgba(200,196,188,0.3);
    padding: 60px 20px 80px;
    text-align: center;
    overflow: hidden;
}

.footer-spine-end {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: var(--spine-width);
    height: 60px;
    background: linear-gradient(to bottom, rgba(180,170,158,0.4), transparent);
}

.footer-content {
    position: relative;
    z-index: 2;
}

.footer-wordmark {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 300;
    font-variation-settings: "wght" 300, "WONK" 0, "opsz" 36;
    color: var(--color-display);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.footer-sub {
    font-family: var(--font-body);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    color: var(--color-stone-mid);
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.footer-note {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--color-stone-mid);
    max-width: 40ch;
    margin: 0 auto;
    line-height: 1.7;
}

/* ============================================================
   SCROLL FADE-IN (JS-driven via IntersectionObserver)
   ============================================================ */

.card-hidden {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* crystal-break also uses these classes; don't interfere with scale hover */
.story-card.card-visible:hover {
    transform: scale(1.02);
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */

@media (max-width: 768px) {
    :root {
        --node-size: 12px;
    }

    /* Collapse timeline to single column with spine as left-edge accent */
    .spine {
        left: 24px;
        transform: none;
    }

    .spine-start {
        left: 24px;
        transform: none;
    }

    .footer-spine-end {
        left: 24px;
        transform: none;
    }

    .timeline-entry {
        flex-direction: column;
        align-items: flex-start;
        padding-left: 56px;
    }

    .entry-right,
    .entry-left {
        justify-content: flex-start;
    }

    .entry-right .story-card,
    .entry-left .story-card {
        width: calc(100% - 16px);
        min-width: unset;
        margin: 0;
    }

    .entry-right .spine-node,
    .entry-left .spine-node {
        left: 16px;
    }

    .connector-line {
        display: none;
    }

    .story-card {
        padding: 1.5rem;
    }

    .card-right,
    .card-left {
        clip-path: none;
    }

    .crystal-cluster {
        display: none;
    }

    .hero-marble-band {
        padding: 0 20px;
    }
}

@media (max-width: 480px) {
    .break-quote {
        font-size: 1.5rem;
    }

    .hero-wordmark {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }
}
