/* ============================================
   heisei.day — Styles
   Sepia-toned cinematic nostalgia
   Heisei Era (1989-2019)
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #F5EDE0;
    color: #3D3228;
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- SVG Grain Filter (hidden) --- */
#grain-svg {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Grain Overlay --- */
.grain-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
}

.grain-warm {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.05;
}

.grain-transition {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.035;
}

.grain-cool {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.025;
}

.grain-minimal {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    opacity: 0.02;
}

/* --- Fixed Site Logo --- */
#site-logo {
    position: fixed;
    top: 24px;
    left: 24px;
    font-family: 'Shippori Mincho', serif;
    font-size: 14px;
    font-weight: 800;
    color: #5C4A32;
    letter-spacing: 0.06em;
    z-index: 100;
    opacity: 0;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

#site-logo.visible {
    opacity: 1;
}

/* --- Scroll Progress Bar --- */
#progress-bar {
    position: fixed;
    top: 0;
    right: 24px;
    width: 3px;
    height: 100vh;
    background: rgba(200, 190, 176, 0.2);
    z-index: 100;
}

#progress-fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(to bottom, #C4935A, #8B7355, #6B8EA6);
    transition: height 100ms linear;
}

.progress-notch {
    position: absolute;
    left: -3px;
    width: 9px;
    height: 2px;
    background: #A0927B;
}

/* --- Timeline Thread (right margin dotted line) --- */
#timeline-thread {
    position: fixed;
    top: 0;
    right: 25px;
    width: 1px;
    height: 100vh;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 4px,
        rgba(160, 146, 123, 0.3) 4px,
        rgba(160, 146, 123, 0.3) 8px
    );
    z-index: 99;
    pointer-events: none;
}

/* ============================================
   OPENING SEQUENCE
   ============================================ */
.section-opening {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #F5EDE0;
    overflow: hidden;
}

.opening-content {
    text-align: center;
    z-index: 2;
}

.hero-kanji {
    font-family: 'Shippori Mincho', serif;
    font-weight: 800;
    font-size: 12vw;
    color: #C4935A;
    opacity: 0;
    letter-spacing: 0.06em;
    line-height: 1.15;
    transition: opacity 1200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.hero-kanji.animate-in {
    opacity: 0.15;
}

.hero-dates {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.4vw, 0.95rem);
    letter-spacing: 0.15em;
    color: #8B7355;
    opacity: 0;
    margin-top: 1.5rem;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.hero-dates.animate-in {
    opacity: 1;
}

.hero-subtitle {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 300;
    font-size: 1rem;
    color: #8B7355;
    opacity: 0;
    margin-top: 0.8rem;
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.hero-subtitle.animate-in {
    opacity: 1;
}

/* Scroll Chevron */
.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
    animation: chevron-pulse 2.5s ease-in-out infinite;
}

.scroll-chevron.animate-in {
    opacity: 1;
}

@keyframes chevron-pulse {
    0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
    50% { transform: translateX(-50%) translateY(8px); opacity: 1; }
}

/* ============================================
   CHAPTERS — Common
   ============================================ */
.chapter {
    position: relative;
    width: 100%;
    padding: 6rem 0;
    overflow: hidden;
}

/* --- Kanji Watermarks --- */
.kanji-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Shippori Mincho', serif;
    font-weight: 800;
    font-size: 20vw;
    color: #5C4A32;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
    user-select: none;
}

/* --- Year Markers --- */
.year-marker {
    position: relative;
    width: 60%;
    margin: 4rem auto;
    text-align: center;
    z-index: 2;
}

.year-line {
    width: 100%;
    height: 2px;
    display: block;
}

.year-number {
    display: inline-block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.4vw, 0.95rem);
    letter-spacing: 0.1em;
    color: #A0927B;
    margin-top: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
}

.year-number.typewriter-animate {
    animation: typewriter-reveal 800ms steps(4) forwards;
    width: 0;
    display: inline-block;
}

@keyframes typewriter-reveal {
    from { width: 0; }
    to { width: 3.2em; }
}

.timeline-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #C4935A;
    margin: 0.5rem auto 0;
}

.timeline-dot.dot-transition {
    background: #8B7D6B;
}

.timeline-dot.dot-cool {
    background: #6B8EA6;
}

/* --- Fade Reveal --- */
.fade-reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.fade-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   CHAPTER ONE: EARLY HEISEI (1989-1999)
   ============================================ */
.chapter-early {
    background-color: #F5EDE0;
    padding-left: 15%;
    padding-right: 15%;
}

/* CRT Scan Lines */
.scanline-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    opacity: 0.05;
    pointer-events: none;
    z-index: 1;
    transition: opacity 400ms ease;
}

.scanline-intensify .scanline-overlay {
    opacity: 0.1;
}

/* Memory Cards (Early) */
.memory-card {
    position: relative;
    z-index: 2;
    max-width: 580px;
    margin-left: 5%;
    padding: 2rem 2.5rem;
}

.card-early {
    border: 1px solid #B8A68E;
    border-radius: 12px;
    background: rgba(245, 237, 224, 0.6);
    margin-bottom: 2rem;
}

.card-heading-en {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    letter-spacing: 0.04em;
    color: #8B7355;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.card-text-jp {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    color: #3D3228;
    margin-bottom: 1rem;
}

.card-text-en {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    line-height: 1.75;
    color: #6B5D4F;
    font-style: italic;
}

/* --- CSS Artifacts --- */
.artifact {
    position: absolute;
    z-index: 1;
    opacity: 0.1;
    pointer-events: none;
}

/* Cassette Tape */
.artifact-cassette {
    width: 50px;
    height: 32px;
    border-radius: 4px;
    background: linear-gradient(135deg, #C4935A 0%, #D4A574 50%, #B8A68E 100%);
    right: 8%;
    top: 18%;
}

.artifact-cassette::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 18px;
    border: 1px solid rgba(92, 74, 50, 0.3);
    border-radius: 2px;
}

/* CD Disc */
.artifact-cd {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #B8A68E;
    right: 12%;
    top: 42%;
}

.artifact-cd::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #B8A68E;
}

.artifact-cd::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(184, 166, 142, 0.4);
}

/* TV Screen */
.artifact-tv {
    width: 45px;
    height: 35px;
    border-radius: 6px;
    border: 2px solid #B8A68E;
    right: 6%;
    top: 68%;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(196, 147, 90, 0.08) 2px,
        rgba(196, 147, 90, 0.08) 4px
    );
}

.artifact-tv::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 4px;
    background: #B8A68E;
    border-radius: 2px;
}

/* ============================================
   TRANSITION ZONE
   ============================================ */
.transition-zone {
    position: relative;
    min-height: 200vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #F5EDE0, #E8DDD0 25%, #8B8578 50%, #2A3040 75%, #1C1E26);
    overflow: hidden;
}

.transition-year {
    text-align: center;
    z-index: 2;
    position: sticky;
    top: 50%;
}

.transition-2000 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 6vw;
    letter-spacing: 0.1em;
    background: linear-gradient(to right, #C4935A, #6B8EA6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   CHAPTER TWO: MIDDLE HEISEI (2000-2010)
   ============================================ */
.chapter-middle {
    background-color: #2A3040;
    padding-left: 12%;
    padding-right: 12%;
}

.chapter-middle .kanji-watermark {
    color: #C8BEB0;
    opacity: 0.03;
}

.chapter-middle .year-number {
    color: #8B8578;
}

/* Split Content Layout */
.split-content {
    position: relative;
    display: flex;
    gap: 5%;
    margin-bottom: 4rem;
    z-index: 2;
}

.split-left {
    flex: 0 0 55%;
}

.split-right {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    justify-content: center;
}

.card-heading-en.heading-dark {
    color: #D4A574;
}

.card-text-dark {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.85;
    letter-spacing: 0.02em;
    color: #C8BEB0;
    margin-bottom: 1rem;
}

.card-text-dark-en {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.5vw, 0.95rem);
    line-height: 1.75;
    color: #A0927B;
    font-style: italic;
}

/* Middle section cards (implicit card styling) */
.split-left {
    border: 1px solid #4A5568;
    border-radius: 6px;
    padding: 2rem 2.5rem;
    background: rgba(42, 48, 64, 0.5);
}

/* Data Visualization Bars */
.data-bar {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.data-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    letter-spacing: 0.1em;
    color: #A0927B;
    text-transform: uppercase;
}

.bar-track {
    width: 100%;
    height: 4px;
    background: rgba(74, 85, 104, 0.5);
    border-radius: 2px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: #6B8EA6;
    border-radius: 2px;
    transition: width 1200ms cubic-bezier(0.25, 0.1, 0.25, 1);
    width: 0 !important;
}

.bar-fill.animate-bar {
    width: var(--target-width) !important;
}

.bar-fill-cool {
    background: #6B8EA6;
}

.data-value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.75rem, 1.3vw, 0.85rem);
    letter-spacing: 0.08em;
    color: #6B8EA6;
}

/* ============================================
   CHAPTER THREE: LATE HEISEI (2011-2019)
   ============================================ */
.chapter-late {
    background-color: #1C1E26;
    padding-left: 0;
    padding-right: 0;
}

.chapter-late .kanji-watermark {
    color: #C8BEB0;
    opacity: 0.03;
}

.chapter-late .year-marker {
    width: 60%;
}

.chapter-late .year-number {
    color: #6B8EA6;
}

/* Late Cards (full-width stacked bands) */
.late-card {
    position: relative;
    z-index: 2;
    max-width: 520px;
    margin: 0 auto 4rem;
    padding: 3rem 2rem;
    text-align: center;
    border: none;
    border-radius: 0;
}

.late-card:nth-child(odd) {
    background: rgba(28, 30, 38, 0.8);
}

.late-card:nth-child(even) {
    background: rgba(42, 48, 64, 0.4);
}

.card-heading-en.heading-late {
    color: #6B8EA6;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
}

.card-text-late {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.6vw, 1rem);
    line-height: 1.7;
    letter-spacing: 0.02em;
    color: #C8BEB0;
    margin-bottom: 1rem;
}

.card-text-late-en {
    font-family: 'Zen Kaku Gothic New', sans-serif;
    font-weight: 300;
    font-size: clamp(0.8rem, 1.4vw, 0.9rem);
    line-height: 1.7;
    color: #A0927B;
    font-style: italic;
}

/* Full-width band wrappers for late section */
.chapter-late .year-marker + .late-card {
    max-width: 100%;
    padding-left: calc(50% - 260px);
    padding-right: calc(50% - 260px);
}

/* ============================================
   CLOSING SEQUENCE
   ============================================ */
.section-closing {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #1C1E26;
    overflow: hidden;
}

.closing-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.closing-date {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.6vw, 1.1rem);
    letter-spacing: 0.15em;
    color: #A0927B;
    margin-bottom: 3rem;
}

.closing-reiwa {
    font-family: 'Shippori Mincho', serif;
    font-weight: 800;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.06em;
    color: #D4A574;
    margin-bottom: 3rem;
    line-height: 1.15;
}

.reiwa-char {
    display: inline-block;
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.reiwa-char.char-visible {
    opacity: 1;
}

.closing-reiwa.reiwa-faded .reiwa-char {
    opacity: 0.08;
    transition: opacity 1500ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.closing-final {
    font-family: 'Shippori Mincho', serif;
    font-weight: 600;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: 0.06em;
    color: #D4C4A8;
    line-height: 1.15;
}

/* Fade to Black */
.fade-to-black {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to bottom, transparent, #0D0F14);
    pointer-events: none;
    z-index: 3;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .chapter-early {
        padding-left: 6%;
        padding-right: 6%;
    }

    .chapter-middle {
        padding-left: 6%;
        padding-right: 6%;
    }

    .memory-card {
        max-width: 100%;
        margin-left: 0;
        padding: 1.5rem;
    }

    .split-content {
        flex-direction: column;
        gap: 2rem;
    }

    .split-left {
        flex: 1;
    }

    .split-right {
        flex: 1;
    }

    .year-marker {
        width: 80%;
    }

    .artifact {
        display: none;
    }

    .late-card {
        max-width: 90%;
        padding: 2rem 1.5rem;
    }

    .chapter-late .year-marker + .late-card {
        max-width: 90%;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    #site-logo {
        top: 16px;
        left: 16px;
        font-size: 12px;
    }

    #progress-bar {
        right: 12px;
    }

    #timeline-thread {
        right: 13px;
    }

    .hero-kanji {
        font-size: 20vw;
    }
}

@media (max-width: 480px) {
    .transition-2000 {
        font-size: 12vw;
    }

    .closing-reiwa {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }
}
