/* ========================================
   lottery.day — Styles
   A found lottery ticket from 1947
   ======================================== */

/* ----- CSS Custom Properties ----- */
:root {
    --paper-white: #FAF8F3;
    --midnight-ink: #1A1A2E;
    --warm-parchment: #F5F0E8;
    --soft-graphite: #3D3D3D;
    --lottery-red: #C4382A;
    --stamp-blue: #2B5C8A;
    --faded-gold: #C9A84C;
    --faded-stamp: #8B8B8B;
    --paper-shadow: #D4C8B0;

    --font-heading: 'Nunito', sans-serif;
    --font-body: 'Quicksand', sans-serif;

    --void-height: 50vh;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: var(--soft-graphite);
    background-color: var(--paper-white);
    overflow-x: hidden;
    position: relative;
}

/* ----- Paper Grain Overlay ----- */
.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='1' height='1' fill='%23000' opacity='0.4'/%3E%3Crect x='2' y='1' width='1' height='1' fill='%23000' opacity='0.3'/%3E%3Crect x='1' y='3' width='1' height='1' fill='%23000' opacity='0.5'/%3E%3Crect x='3' y='2' width='1' height='1' fill='%23000' opacity='0.2'/%3E%3C/svg%3E");
    background-size: 4px 4px;
}

/* ----- Foxing Spots ----- */
.foxing-spots {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.foxing-spot {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(180, 160, 130, 0.08) 0%, transparent 70%);
}

/* ----- Grid Fragments ----- */
.grid-fragment {
    position: fixed;
    width: 80px;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
}

.grid-fragment--left {
    left: 0;
    top: 0;
}

.grid-fragment--right {
    right: 0;
    top: 0;
}

/* ----- Scroll Progress Indicator ----- */
.scroll-indicator {
    position: fixed;
    top: 10%;
    right: 16px;
    width: 2px;
    height: 0%;
    max-height: 80%;
    background-color: var(--faded-stamp);
    z-index: 999;
    opacity: 0.4;
    transition: height 0.1s linear;
    border-radius: 1px;
}

/* ----- Chamber Base ----- */
.chamber {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    z-index: 2;
}

.chamber--dormant > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.chamber--active > * {
    opacity: 1;
    transform: translateY(0);
}

/* ----- Chamber Void ----- */
.chamber-void {
    height: var(--void-height);
    position: relative;
    z-index: 2;
}

/* ========================================
   CHAMBER 1: THE ENVELOPE
   ======================================== */
#chamber-1 {
    justify-content: center;
    padding: 0 10vw;
}

.chamber-1__content {
    position: relative;
    margin-left: 20%;
    max-width: 600px;
}

.chamber-1__title-wrap {
    position: relative;
    margin-bottom: 40px;
}

/* Morph line — the line that resolves into the title */
.morph-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 200px;
    height: 2px;
    background-color: var(--midnight-ink);
    transform: translateY(-50%);
    opacity: 1;
    transition: opacity 0.6s ease-out;
}

.morph-line--hidden {
    opacity: 0;
}

.chamber-1__title {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(48px, 8vw, 96px);
    letter-spacing: 0.04em;
    line-height: 1.0;
    color: var(--midnight-ink);
    opacity: 0;
    clip-path: inset(0 100% 0 0);
    transition: clip-path 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.5s ease-out;
}

.chamber-1__title--revealed {
    opacity: 1;
    clip-path: inset(0 0% 0 0);
}

.chamber-1__tagline {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: var(--soft-graphite);
    max-width: 420px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1.2s ease-out 2.8s, transform 1.2s ease-out 2.8s;
}

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

/* ========================================
   CHAMBER 2: THE NUMBERS
   ======================================== */
#chamber-2 {
    justify-content: center;
    padding: 0 5vw;
}

.chamber-2__content {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.chamber-2__numbers {
    display: flex;
    justify-content: center;
    gap: clamp(20px, 4vw, 60px);
    flex-wrap: wrap;
    margin-bottom: 80px;
}

.lottery-number {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: rotate(var(--rotation, 0deg)) translateY(var(--offset-y, 0px));
}

.number-halo {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(201, 168, 76, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

.number-glyph {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(64px, 12vw, 144px);
    letter-spacing: 0.04em;
    line-height: 1.0;
    color: var(--midnight-ink);
    position: relative;
    z-index: 2;
    clip-path: circle(0% at 50% 50%);
    transition: clip-path 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.number-glyph--red {
    color: var(--lottery-red);
}

.lottery-number--revealed .number-glyph {
    clip-path: circle(75% at 50% 50%);
}

.chamber-2__caption {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-stamp);
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

/* ========================================
   CHAMBER 3: THE FOLD
   ======================================== */
#chamber-3 {
    flex-direction: column;
    justify-content: center;
    padding: 0 10vw;
}

.chamber-3__content {
    width: 100%;
    max-width: 800px;
    position: relative;
}

.chamber-3__above {
    padding-bottom: 60px;
    padding-left: 15%;
}

.chamber-3__below {
    padding-top: 60px;
    padding-right: 15%;
    margin-left: auto;
    text-align: right;
}

.chamber-3__text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: var(--soft-graphite);
    max-width: 480px;
}

.chamber-3__text--above {
    transform: translateX(-4px);
}

.chamber-3__text--below {
    transform: translateX(4px);
    margin-left: auto;
}

/* Fold Line */
.fold-line {
    position: relative;
    width: 100%;
    height: 30px;
}

.fold-line__crease {
    position: absolute;
    top: 50%;
    left: -10vw;
    right: -10vw;
    height: 6px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(212, 200, 176, 0.15) 40%,
        rgba(196, 56, 42, 0.12) 50%,
        rgba(212, 200, 176, 0.15) 60%,
        transparent 100%
    );
    transform: translateY(-50%);
}

.fold-line__shadow {
    position: absolute;
    top: calc(50% + 3px);
    left: -10vw;
    right: -10vw;
    height: 20px;
    background: linear-gradient(
        to bottom,
        rgba(212, 200, 176, 0.05) 0%,
        transparent 100%
    );
}

.fold-line__lift {
    position: absolute;
    top: calc(50% - 23px);
    left: -10vw;
    right: -10vw;
    height: 20px;
    background: linear-gradient(
        to top,
        rgba(212, 200, 176, 0.03) 0%,
        transparent 100%
    );
}

/* ========================================
   CHAMBER 4: THE REVEAL
   ======================================== */
#chamber-4 {
    flex-direction: column;
    justify-content: center;
    padding: 10vh 10vw;
    background-color: var(--paper-white);
    transition: background-color 1.5s ease-in-out;
    overflow: hidden;
}

#chamber-4.chamber-4--dark {
    background-color: var(--midnight-ink);
}

.chamber-4__bg-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

/* Probability Curves */
.probability-curve {
    position: absolute;
    width: 100%;
    height: 200px;
    top: 30%;
    left: 0;
    opacity: 0.06;
}

.probability-curve--2 {
    top: 55%;
    opacity: 0.04;
}

.probability-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 3s ease-out;
}

#chamber-4.chamber-4--dark .probability-path {
    stroke-dashoffset: 0;
}

/* Binary Rain */
.binary-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

#chamber-4.chamber-4--dark .binary-rain {
    opacity: 1;
}

.binary-column {
    position: absolute;
    top: -100%;
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 12px;
    line-height: 1.8;
    color: var(--warm-parchment);
    opacity: 0.03;
    white-space: nowrap;
    animation: binaryFall linear infinite;
    will-change: transform;
}

@keyframes binaryFall {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(200%);
    }
}

/* Chamber 4 Content */
.chamber-4__content {
    position: relative;
    z-index: 3;
    max-width: 700px;
    margin-left: 15%;
}

.chamber-4__heading {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(36px, 6vw, 72px);
    letter-spacing: 0.04em;
    line-height: 1.0;
    color: var(--midnight-ink);
    margin-bottom: 60px;
    transition: color 1.5s ease-in-out;
}

#chamber-4.chamber-4--dark .chamber-4__heading {
    color: var(--warm-parchment);
}

.chamber-4__text-block {
    margin-bottom: 40px;
}

.chamber-4__text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: var(--soft-graphite);
    transition: color 1.5s ease-in-out;
}

#chamber-4.chamber-4--dark .chamber-4__text {
    color: var(--warm-parchment);
}

/* Morph text: blur-to-sharp */
.morph-text {
    filter: blur(8px);
    opacity: 0.3;
    transition: filter 1.2s ease-out, opacity 1.2s ease-out, color 1.5s ease-in-out;
}

.morph-text--sharp {
    filter: blur(0);
    opacity: 1;
}

/* Number reveal */
.chamber-4__number-reveal {
    margin-top: 80px;
    text-align: center;
}

.reveal-number {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(48px, 8vw, 120px);
    letter-spacing: 0.04em;
    color: var(--lottery-red);
    opacity: 0;
    transition: opacity 2s ease-out 0.5s;
}

#chamber-4.chamber-4--dark .reveal-number {
    opacity: 1;
}

/* ========================================
   CHAMBER 5: THE STUB
   ======================================== */
#chamber-5 {
    flex-direction: column;
    justify-content: center;
    padding: 0 10vw;
    padding-top: 40px;
    min-height: 60vh;
}

/* Perforation Edge */
.perforation-edge {
    position: relative;
    width: calc(100% + 20vw);
    margin-left: -10vw;
    height: 24px;
    margin-bottom: 60px;
}

.perforation-svg {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 12px;
    transform: translateY(-50%);
    opacity: 0.3;
}

.perforation-line {
    stroke-dasharray: 0 0;
    transition: stroke-dasharray 2s ease-out;
}

.perforation-line--dashed {
    stroke-dasharray: 8 12;
}

.perforation-circles {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 12px;
    transform: translateY(-50%);
    background-image: radial-gradient(circle 3px at center, var(--paper-shadow) 100%, transparent 100%);
    background-size: 16px 12px;
    background-repeat: repeat-x;
    mix-blend-mode: multiply;
    opacity: 0.5;
}

/* Stub Content */
.chamber-5__content {
    max-width: 700px;
    margin-left: 20%;
}

.stub-details {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 40px;
}

.stub-detail {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-stamp);
}

.stub-message {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: clamp(24px, 4vw, 48px);
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--midnight-ink);
    margin-bottom: 60px;
}

.stub-footer {
    padding-top: 30px;
    border-top: 1px solid rgba(212, 200, 176, 0.3);
}

.stub-fine-print {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faded-stamp);
    display: block;
    padding-bottom: 60px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    .chamber-1__content {
        margin-left: 5%;
    }

    .chamber-2__numbers {
        gap: 16px;
    }

    .number-halo {
        width: 120px;
        height: 120px;
    }

    .chamber-3__above {
        padding-left: 0;
    }

    .chamber-3__below {
        padding-right: 0;
    }

    .chamber-4__content {
        margin-left: 0;
    }

    .chamber-5__content {
        margin-left: 0;
    }

    .stub-details {
        flex-direction: column;
        gap: 12px;
    }

    .grid-fragment {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 16px;
    }

    .chamber {
        padding-left: 5vw;
        padding-right: 5vw;
    }

    #chamber-1,
    #chamber-3,
    #chamber-4,
    #chamber-5 {
        padding-left: 5vw;
        padding-right: 5vw;
    }

    .fold-line__crease,
    .fold-line__shadow,
    .fold-line__lift {
        left: -5vw;
        right: -5vw;
    }

    .perforation-edge {
        width: calc(100% + 10vw);
        margin-left: -5vw;
    }
}
