/* heisei.day — corrupted pastoral memoir
   Palette: warm-earthy · Layout: horizontal-scroll · Type: mono + serif display
*/

:root {
    --bg: #f4ede4;
    --bg-end: #e8ddd0;
    --text: #3d2e1f;
    --display: #6b4226;
    --accent-warm: #c4956a;
    --accent-cool: #8b7355;
    --glitch-a: #d4785a;
    --glitch-b: #7a9e8c;
    --grain: #b8a48c;
    --deep: #2a1f14;
    --annot: #a08060;

    /* Progressive degradation variables, driven by JS */
    --scroll-progress: 0;
    --grain-opacity: 0.04;
    --aberration-offset: 1px;
    --wobble-amplitude: 2px;
    --bg-shift: 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Mono", "Courier New", monospace;
    font-weight: 300;
    letter-spacing: 0.02em;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    position: relative;
    background: linear-gradient(
        to right,
        var(--bg) 0%,
        var(--bg) 70%,
        var(--bg-end) 100%
    );
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* ===========================================================
   Persistent overlay layers
   =========================================================== */

.noise-layer {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 90;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0.722  0 0 0 0 0.643  0 0 0 0 0.549  0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    background-size: 220px 220px;
    will-change: transform, opacity;
    animation: grain-flicker 0.083s steps(1) infinite;
    mix-blend-mode: multiply;
}

@keyframes grain-flicker {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-6px, 4px); }
    50%  { transform: translate(5px, -3px); }
    75%  { transform: translate(-3px, -5px); }
    100% { transform: translate(4px, 2px); }
}

.scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 91;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 1px,
        rgba(42, 31, 20, 0.035) 1px,
        rgba(42, 31, 20, 0.035) 2px
    );
    opacity: 0.7;
}

.haze {
    position: fixed;
    top: 0;
    left: 0;
    width: 300vw;
    height: 100vh;
    pointer-events: none;
    z-index: 80;
    background: linear-gradient(
        to right,
        rgba(244, 237, 228, 0.0),
        rgba(244, 237, 228, 0.35) 50%,
        rgba(244, 237, 228, 0.0) 100%
    );
    animation: haze-drift 60s linear infinite;
    mix-blend-mode: screen;
}

@keyframes haze-drift {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-150vw); }
}

/* ===========================================================
   Main horizontal canvas
   =========================================================== */

main#canvas {
    position: relative;
    width: 1000vw;
    height: 100vh;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.zone {
    position: absolute;
    top: 0;
    width: 200vw;
    height: 100vh;
    overflow: visible;
}

/* Zone-specific tints (atmosphere) */
.zone-1 {
    background: linear-gradient(
        to right,
        rgba(196, 149, 106, 0.08),
        rgba(196, 149, 106, 0.04) 100%
    );
}
.zone-2 {
    background: linear-gradient(
        to right,
        rgba(139, 115, 85, 0.06),
        rgba(160, 128, 96, 0.09) 100%
    );
}
.zone-3 {
    background: linear-gradient(
        to right,
        rgba(196, 149, 106, 0.07),
        rgba(122, 158, 140, 0.06) 100%
    );
}
.zone-4 {
    background: linear-gradient(
        to right,
        rgba(139, 115, 85, 0.10),
        rgba(107, 66, 38, 0.10) 100%
    );
}
.zone-5 {
    background: linear-gradient(
        to right,
        rgba(107, 66, 38, 0.12),
        rgba(42, 31, 20, 0.14) 100%
    );
}

/* ===========================================================
   Reveal animation (fade-reveal)
   =========================================================== */

.reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
    will-change: opacity, transform;
}

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

/* ===========================================================
   Typography — Display & Body
   =========================================================== */

.display-title {
    font-family: "Cormorant Garamond", "Times New Roman", serif;
    font-weight: 300;
    font-size: clamp(5rem, 10vw, 9rem);
    color: var(--display);
    letter-spacing: 0.05em;
    line-height: 1;
    text-shadow:
        calc(var(--aberration-offset) * -1) 0 var(--glitch-a),
        var(--aberration-offset) 0 var(--glitch-b);
}

.title-wrap {
    position: absolute;
    width: 40vw;
}

.title-line {
    width: 0;
    height: 1px;
    background: var(--accent-warm);
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    animation: line-draw 2400ms ease-out 900ms forwards;
}

@keyframes line-draw {
    to { width: 32vw; }
}

.title-sub {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 0.88rem;
    color: var(--accent-cool);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.era-marker {
    position: absolute;
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    font-size: clamp(1.4rem, 2.2vw, 2.2rem);
    color: var(--display);
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.fragment {
    position: absolute;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 400;
    font-size: clamp(0.88rem, 1.6vw, 1.08rem);
    color: var(--text);
    line-height: 1.75;
    letter-spacing: 0.02em;
}

.fragment.light {
    font-weight: 300;
    color: var(--accent-cool);
}

.margin-note {
    position: absolute;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 200;
    font-size: clamp(0.62rem, 0.9vw, 0.78rem);
    color: var(--annot);
    opacity: 0.7;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.page-number {
    position: absolute;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 200;
    font-size: 0.7rem;
    color: var(--annot);
    opacity: 0.55;
    letter-spacing: 0.14em;
}

.page-fold {
    position: absolute;
    top: 10vh;
    width: 1px;
    height: 80vh;
    background: var(--annot);
    opacity: 0.3;
}

.page-fold.fade {
    opacity: 0.12;
}

sup.footnote {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    font-size: 0.95em;
    color: var(--accent-warm);
    margin-left: 0.15em;
    vertical-align: super;
    line-height: 0;
}

/* Chromatic aberration intensities */
.aberrate-sm {
    text-shadow:
        -1px 0 var(--glitch-a),
        1px 0 var(--glitch-b);
}
.aberrate-md {
    text-shadow:
        -2.5px 0 var(--glitch-a),
        2.5px 0 var(--glitch-b);
}
.aberrate-lg {
    text-shadow:
        -4px 0 var(--glitch-a),
        4px 0 var(--glitch-b);
}

/* Color bleed (overlapping duplicate) via pseudo-elements */
.color-bleed {
    position: relative;
}
.color-bleed::before,
.color-bleed::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: multiply;
}

/* ===========================================================
   Haiku blocks
   =========================================================== */

.haiku {
    position: absolute;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: clamp(0.92rem, 1.6vw, 1.1rem);
    color: var(--text);
    line-height: 2.1;
    letter-spacing: 0.04em;
    padding: 0.5rem 1rem 0.5rem 1.2rem;
    border-left: 1px solid var(--accent-warm);
}

.haiku.right {
    border-left: none;
    border-right: 1px solid var(--accent-cool);
    text-align: right;
    padding: 0.5rem 1.2rem 0.5rem 1rem;
}

.haiku p {
    font-style: italic;
}

/* ===========================================================
   Book page motif
   =========================================================== */

.book-page {
    position: absolute;
    width: 28vw;
    max-width: 420px;
    padding: 2rem 2.2rem;
    background: rgba(244, 237, 228, 0.55);
    border: 1px solid rgba(160, 128, 96, 0.3);
    box-shadow:
        0 0 0 1px rgba(160, 128, 96, 0.08),
        0 20px 50px -20px rgba(42, 31, 20, 0.25);
    transform: rotate(-1.5deg);
    font-family: "IBM Plex Mono", monospace;
    backdrop-filter: blur(0.4px);
    filter: drop-shadow(-1px 0 rgba(212, 120, 90, 0.4)) drop-shadow(1px 0 rgba(122, 158, 140, 0.4));
}

.book-page.small {
    width: 22vw;
    padding: 1.4rem 1.6rem;
    transform: rotate(1deg);
}

.book-page .book-title {
    font-family: "Cormorant Garamond", serif;
    font-weight: 600;
    font-size: 1.35rem;
    color: var(--display);
    letter-spacing: 0.03em;
    margin-bottom: 1rem;
}

.book-page .book-body {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 0.84rem;
    color: var(--text);
    line-height: 1.85;
    margin-bottom: 1rem;
}

.book-page .book-cite {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 200;
    font-size: 0.68rem;
    color: var(--annot);
    letter-spacing: 0.1em;
    text-align: right;
    font-style: italic;
}

/* ===========================================================
   Palimpsest (layered overlapping text)
   =========================================================== */

.palimpsest {
    position: absolute;
    width: 30vw;
    font-family: "IBM Plex Mono", monospace;
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    line-height: 1.8;
}

.palimpsest .layer {
    position: relative;
}

.palimpsest .layer-a {
    color: var(--text);
    opacity: 0.8;
}

.palimpsest .layer-b {
    color: var(--glitch-a);
    opacity: 0.55;
    transform: translate(3px, -0.3em);
    font-weight: 300;
    mix-blend-mode: multiply;
}

.palimpsest .layer-c {
    color: var(--glitch-b);
    opacity: 0.5;
    transform: translate(-4px, -0.5em);
    font-weight: 300;
    mix-blend-mode: multiply;
}

/* ===========================================================
   Field gradient (pastoral rice paddies, zone 3)
   =========================================================== */

.field-gradient {
    position: absolute;
    bottom: 0;
    left: 40vw;
    width: 140vw;
    height: 40vh;
    pointer-events: none;
    background:
        linear-gradient(to bottom,
            transparent 0%,
            rgba(122, 158, 140, 0.18) 25%,
            rgba(196, 149, 106, 0.22) 50%,
            rgba(139, 115, 85, 0.25) 75%,
            rgba(107, 66, 38, 0.2) 100%
        ),
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent 14px,
            rgba(139, 115, 85, 0.1) 14px,
            rgba(139, 115, 85, 0.1) 15px
        );
    filter: blur(20px);
    opacity: 0.6;
}

/* ===========================================================
   Light leaks
   =========================================================== */

.light-leak {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    mix-blend-mode: screen;
    filter: blur(60px);
    animation: leak-pulse 6s ease-in-out infinite;
}

.leak-a {
    top: 10vh;
    left: 55vw;
    width: 36vw;
    height: 36vw;
    background: radial-gradient(circle, rgba(196, 149, 106, 0.35), transparent 70%);
}

.leak-b {
    top: 20vh;
    left: 30vw;
    width: 32vw;
    height: 32vw;
    background: radial-gradient(circle, rgba(196, 149, 106, 0.3), transparent 70%);
    animation-delay: -2s;
}

.leak-c {
    top: 30vh;
    left: 140vw;
    width: 38vw;
    height: 38vw;
    background: radial-gradient(circle, rgba(212, 120, 90, 0.22), transparent 70%);
    animation-delay: -4s;
}

@keyframes leak-pulse {
    0%, 100% { opacity: 0.32; transform: scale(1); }
    50%      { opacity: 0.48; transform: scale(1.08); }
}

/* ===========================================================
   VHS glitch bands
   =========================================================== */

.glitch-band {
    position: absolute;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(212, 120, 90, 0.15),
        rgba(139, 115, 85, 0.2),
        rgba(122, 158, 140, 0.12),
        transparent
    );
    mix-blend-mode: multiply;
    pointer-events: none;
    animation: band-wobble 3.8s ease-in-out infinite;
    will-change: transform;
}

.band-a { height: 4px; animation-duration: 4.2s; }
.band-b { height: 6px; animation-duration: 5.1s; animation-delay: -1.2s; }
.band-c { height: 5px; animation-duration: 3.5s; }
.band-d { height: 7px; animation-duration: 4.8s; animation-delay: -1s; }
.band-e { height: 4px; animation-duration: 6.2s; animation-delay: -2.3s; }
.band-f { height: 8px; animation-duration: 2.9s; }
.band-g { height: 6px; animation-duration: 3.7s; animation-delay: -0.8s; }
.band-h { height: 10px; animation-duration: 4.1s; animation-delay: -1.9s; }
.band-i { height: 7px; animation-duration: 3.2s; animation-delay: -2.6s; }

@keyframes band-wobble {
    0%   { transform: translateX(0) translateY(0); opacity: 0.55; }
    20%  { transform: translateX(calc(var(--wobble-amplitude) * -1)) translateY(1px); opacity: 0.9; }
    40%  { transform: translateX(var(--wobble-amplitude)) translateY(-1px); opacity: 0.6; }
    60%  { transform: translateX(calc(var(--wobble-amplitude) * -0.6)) translateY(2px); opacity: 0.8; }
    80%  { transform: translateX(calc(var(--wobble-amplitude) * 0.8)) translateY(-2px); opacity: 0.5; }
    100% { transform: translateX(0) translateY(0); opacity: 0.55; }
}

/* ===========================================================
   Zone 5 — Terminal Nostalgia heaviness
   =========================================================== */

.heisei-ghost {
    position: absolute;
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: clamp(6rem, 14vw, 14rem);
    color: var(--display);
    opacity: 0.18;
    letter-spacing: 0.08em;
    text-shadow:
        -6px 0 var(--glitch-a),
        6px 0 var(--glitch-b);
    filter: blur(1px);
    animation: ghost-flicker 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes ghost-flicker {
    0%, 100% { opacity: 0.16; filter: blur(1px); }
    25%      { opacity: 0.26; filter: blur(0.6px); }
    50%      { opacity: 0.10; filter: blur(2px); }
    75%      { opacity: 0.22; filter: blur(0.8px); }
}

.ending {
    position: absolute;
    width: 24vw;
    text-align: center;
}

.owari {
    font-family: "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: clamp(4rem, 8vw, 7rem);
    color: var(--display);
    letter-spacing: 0.05em;
    line-height: 1;
    opacity: 0.9;
    text-shadow: none;
}

.owari-sub {
    margin-top: 1.8rem;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 0.95rem;
    color: var(--text);
    letter-spacing: 0.1em;
    text-shadow: none;
    opacity: 0.95;
}

/* ===========================================================
   Timeline
   =========================================================== */

.timeline {
    position: fixed;
    bottom: 22px;
    left: 5vw;
    right: 5vw;
    height: 2px;
    background: rgba(196, 149, 106, 0.15);
    z-index: 100;
    pointer-events: none;
}

.timeline-fill {
    height: 100%;
    width: 0;
    background: rgba(196, 149, 106, 0.55);
    transition: width 120ms linear;
}

.tick {
    position: absolute;
    top: -4px;
    width: 1px;
    height: 10px;
    background: rgba(160, 128, 96, 0.6);
    transform: translateX(-0.5px);
}

.tick-label {
    position: absolute;
    top: 10px;
    transform: translateX(-50%);
    font-family: "IBM Plex Mono", monospace;
    font-weight: 200;
    font-size: 0.62rem;
    color: var(--annot);
    letter-spacing: 0.15em;
    opacity: 0.65;
}

.tick-label.end {
    transform: translateX(-100%);
}

/* ===========================================================
   Scroll hint
   =========================================================== */

.scroll-hint {
    position: fixed;
    bottom: 48px;
    right: 5vw;
    z-index: 101;
    font-family: "IBM Plex Mono", monospace;
    font-weight: 300;
    font-size: 0.72rem;
    color: var(--accent-cool);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    opacity: 0;
    pointer-events: none;
    transition: opacity 900ms ease-out;
    animation: hint-pulse 2.4s ease-in-out infinite;
}

.scroll-hint.is-shown {
    opacity: 0.8;
}

.scroll-hint.is-hidden {
    opacity: 0 !important;
}

@keyframes hint-pulse {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(6px); }
}
