/* ==========================================
   iggi.boo - Analog Nostalgia Engine
   ========================================== */

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

html {
    scroll-behavior: smooth;
    scrollbar-color: #d4c4a8 #f5ead6;
}

html::-webkit-scrollbar {
    width: 8px;
}

html::-webkit-scrollbar-track {
    background: #f5ead6;
}

html::-webkit-scrollbar-thumb {
    background: #d4c4a8;
    border-radius: 4px;
}

body {
    background-color: #f5ead6;
    color: #3d3024;
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Chapter Base --- */
.chapter {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 720px);
    justify-content: center;
    padding: clamp(1.5rem, 8vw, 6rem);
    overflow: hidden;
}

/* --- Paper Texture Overlay --- */
.paper-texture {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse at center, transparent 40%, rgba(60,42,26,0.08) 100%);
    filter: url(#paper-noise);
    opacity: 0.04;
}

.paper-texture-dark {
    opacity: 0.06;
}

/* --- Coffee Stain Accent --- */
.coffee-stain {
    position: absolute;
    top: 20%;
    right: 10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle at 50% 50%, rgba(196,101,42,0.06) 0%, transparent 60%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

/* --- Torn Paper Edge --- */
.torn-edge-top {
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 30px;
    background: inherit;
    z-index: 2;
}

.chapter-postcard,
.chapter-radio,
.chapter-stamps,
.chapter-seal {
    clip-path: polygon(
        0 0, 5% 2%, 10% 0, 15% 1.5%, 20% 0, 25% 2.5%, 30% 0, 35% 1%, 40% 0, 45% 3%,
        50% 0, 55% 1.5%, 60% 0, 65% 2%, 70% 0, 75% 1%, 80% 0, 85% 2.5%, 90% 0, 95% 1.5%,
        100% 0, 100% 100%, 0 100%
    );
    margin-top: -15px;
    padding-top: calc(clamp(1.5rem, 8vw, 6rem) + 20px);
}

/* --- Diamond Crosshatch Divider --- */
.chapter::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background:
        repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(196,101,42,0.08) 8px, rgba(196,101,42,0.08) 9px),
        repeating-linear-gradient(-45deg, transparent, transparent 8px, rgba(196,101,42,0.08) 8px, rgba(196,101,42,0.08) 9px);
    z-index: 1;
}

.chapter-seal::after {
    display: none;
}

/* Shadow under each section for layered paper feel */
.chapter {
    box-shadow: 0 4px 10px rgba(212,196,168,0.5);
}

/* ==========================================
   Chapter 1: The Envelope (Hero)
   ========================================== */
.chapter-envelope {
    background-color: #f5ead6;
    background-image: linear-gradient(135deg, transparent 49.5%, rgba(212,196,168,0.3) 49.5%, rgba(212,196,168,0.3) 50.5%, transparent 50.5%);
    align-content: center;
    justify-items: center;
    text-align: center;
    z-index: 5;
}

.envelope-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.fold-line {
    width: 60%;
    max-width: 400px;
    height: 1px;
    background-color: #d4c4a8;
    transform: scaleX(0);
    margin-bottom: 1rem;
}

.fold-line.animate {
    animation: unfoldLine 700ms ease-out forwards;
}

@keyframes unfoldLine {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.mailing-label {
    border: 2px solid #d4c4a8;
    padding: 1rem 2.5rem;
    position: relative;
}

.domain-name {
    font-family: 'Alfa Slab One', serif;
    font-weight: 400;
    font-size: clamp(2.6rem, 7vw, 5.5rem);
    color: #2c2216;
    letter-spacing: 0.04em;
    line-height: 1.1;
    opacity: 0;
    transform: translateY(15px);
}

.domain-name.animate {
    animation: fadeUpIn 800ms ease-out forwards;
}

@keyframes fadeUpIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tagline-container {
    font-family: 'Special Elite', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.05rem);
    color: #2c2216;
    letter-spacing: 0.06em;
    min-height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tagline .char {
    opacity: 0;
    display: inline-block;
    transition: opacity 0.05s;
}

.tagline .char.visible {
    opacity: 1;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: #f0c674;
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

.typewriter-cursor.fade-out {
    animation: cursorFadeOut 400ms ease-out forwards;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes cursorFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ==========================================
   Chapter 2: The Postcard
   ========================================== */
.chapter-postcard {
    background-color: #ede2cd;
    align-content: center;
    z-index: 4;
}

.postcard-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0;
    align-items: start;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 900ms cubic-bezier(0.25, 0.1, 0.25, 1), transform 900ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.postcard-layout.revealed {
    opacity: 1;
    transform: translateY(0);
}

.postcard-message {
    padding-right: 2rem;
    text-align: left;
}

.chapter-heading {
    font-family: 'Alfa Slab One', serif;
    font-weight: 400;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #2c2216;
    letter-spacing: 0.02em;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.chapter-heading.revealed {
    opacity: 1;
    transform: translateY(0);
}

.postcard-text {
    font-family: 'Lora', Georgia, serif;
    color: #3d3024;
    margin-bottom: 1rem;
    text-align: left;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

.postcard-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

.postcard-message:hover .postcard-text {
    text-shadow: 0 0 8px rgba(240,198,116,0.2);
}

.postcard-divider {
    width: 1px;
    min-height: 100%;
    border-left: 2px dotted #d4c4a8;
    opacity: 0.4;
    transition: opacity 600ms ease;
}

.postcard-divider.pulse {
    animation: dividerPulse 600ms ease forwards;
}

@keyframes dividerPulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.7; }
    100% { opacity: 0.4; }
}

.postcard-stamp-side {
    padding-left: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 600ms ease-out 300ms, transform 600ms ease-out 300ms;
}

.postcard-stamp-side.revealed {
    opacity: 1;
    transform: translateY(0);
}

.decorative-stamp {
    width: 100px;
    height: 120px;
    background:
        radial-gradient(circle, transparent 5px, #ede2cd 5.5px) -6px -6px / 12px 12px repeat-x,
        radial-gradient(circle, transparent 5px, #ede2cd 5.5px) -6px calc(100% + 6px) / 12px 12px repeat-x,
        radial-gradient(circle, transparent 5px, #ede2cd 5.5px) -6px -6px / 12px 12px repeat-y,
        radial-gradient(circle, transparent 5px, #ede2cd 5.5px) calc(100% + 6px) -6px / 12px 12px repeat-y;
    padding: 8px;
}

.stamp-inner {
    width: 100%;
    height: 100%;
    background-color: rgba(196,101,42,0.08);
    border: 1px solid #d4c4a8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.stamp-icon {
    font-size: 2rem;
    color: #c4652a;
    line-height: 1;
}

.stamp-caption {
    font-family: 'Special Elite', monospace;
    font-size: 0.7rem;
    color: #6b5d4f;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.postcard-lines {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.address-line {
    height: 1px;
    background-color: #d4c4a8;
    opacity: 0.6;
}

/* ==========================================
   Chapter 3: The Radio Dial
   ========================================== */
.chapter-radio {
    background-color: #3a2a1a;
    align-content: center;
    justify-items: center;
    z-index: 3;
}

.scallop-pattern {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(circle at 50% 0%, transparent 18px, rgba(58,42,26,0.05) 19px, transparent 20px) 0 0 / 40px 40px repeat;
    opacity: 0.5;
}

.radio-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 900ms cubic-bezier(0.25, 0.1, 0.25, 1), transform 900ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.radio-content.revealed {
    opacity: 1;
    transform: translateY(0);
}

.radio-arcs {
    position: absolute;
    width: 400px;
    height: 400px;
    max-width: 80vw;
    max-height: 80vw;
}

.arc {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(212,196,168,0.15);
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.arc-outer {
    inset: 0;
    animation: spin 60s linear infinite;
}

.arc-middle {
    inset: 40px;
    animation: spin 45s linear infinite reverse;
}

.arc-inner {
    inset: 80px;
    animation: spin 30s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.radio-quote {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 500px;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(-3px); }
    50% { transform: translateY(3px); }
}

.quote-text {
    font-family: 'Alfa Slab One', serif;
    font-weight: 400;
    font-size: clamp(1.6rem, 3.5vw, 2.4rem);
    color: #f5ead6;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

/* ==========================================
   Chapter 4: The Stamp Collection
   ========================================== */
.chapter-stamps {
    background-color: #f5ead6;
    align-content: center;
    z-index: 2;
}

.dot-grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background: radial-gradient(circle, #d4c4a8 1px, transparent 1px);
    background-size: 16px 16px;
    opacity: 0.3;
}

.stamps-content {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 900ms cubic-bezier(0.25, 0.1, 0.25, 1), transform 900ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.stamps-content.revealed {
    opacity: 1;
    transform: translateY(0);
}

.stamps-content .chapter-heading {
    text-align: center;
    margin-bottom: 2.5rem;
}

.stamp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.stamp-card {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 500ms ease-out, transform 500ms ease-out;
}

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

.stamp-perforation {
    background:
        radial-gradient(circle, transparent 5px, #f5ead6 5.5px) -6px -6px / 12px 12px repeat-x,
        radial-gradient(circle, transparent 5px, #f5ead6 5.5px) -6px calc(100% + 6px) / 12px 12px repeat-x,
        radial-gradient(circle, transparent 5px, #f5ead6 5.5px) -6px -6px / 12px 12px repeat-y,
        radial-gradient(circle, transparent 5px, #f5ead6 5.5px) calc(100% + 6px) -6px / 12px 12px repeat-y;
    padding: 10px;
    opacity: 0.6;
    transition: opacity 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}

.stamp-perforation:hover {
    opacity: 1;
    transform: translateY(-4px) rotate(-1deg);
    box-shadow: 0 6px 16px rgba(60,42,26,0.15);
}

.stamp-perforation:active {
    opacity: 1;
    transform: translateY(-4px) rotate(-1deg);
    box-shadow: 0 6px 16px rgba(60,42,26,0.15);
    transition-duration: 150ms;
}

.stamp-card-inner {
    background-color: rgba(196,101,42,0.08);
    border: 1px solid #d4c4a8;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
}

.stamp-card-illustration {
    width: 60px;
    height: 60px;
}

.stamp-svg {
    width: 100%;
    height: 100%;
}

.stamp-card-caption {
    font-family: 'Special Elite', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    color: #6b5d4f;
    letter-spacing: 0.06em;
}

/* ==========================================
   Chapter 5: The Seal
   ========================================== */
.chapter-seal {
    background-color: #f5ead6;
    align-content: center;
    justify-items: center;
    text-align: center;
    z-index: 1;
    min-height: 80vh;
}

.seal-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.wax-seal {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #8b3a3a, #6b2a2a 60%, #4a1a1a);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.3), 0 4px 12px rgba(60,42,26,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.8) rotate(-15deg);
    opacity: 0;
    transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 600ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 600ms ease;
}

.wax-seal.animate {
    transform: scale(1) rotate(-8deg);
    opacity: 1;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.3), 0 4px 12px rgba(60,42,26,0.25);
}

.seal-monogram {
    font-family: 'Alfa Slab One', serif;
    font-size: 3rem;
    color: #f0c674;
    line-height: 1;
    opacity: 0;
    transition: opacity 200ms ease 600ms;
}

.wax-seal.animate .seal-monogram {
    opacity: 1;
}

.farewell-text {
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: #3d3024;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 600ms ease-out 800ms, transform 600ms ease-out 800ms;
}

.farewell-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

.farewell-subtext {
    font-family: 'Special Elite', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.05rem);
    color: #6b5d4f;
    letter-spacing: 0.06em;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 600ms ease-out 1000ms, transform 600ms ease-out 1000ms;
}

.farewell-subtext.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================
   Responsive / Mobile
   ========================================== */
@media (max-width: 768px) {
    .chapter {
        grid-template-columns: 1fr;
        padding: clamp(1.5rem, 5vw, 3rem);
    }

    .postcard-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .postcard-divider {
        width: 100%;
        min-height: 0;
        height: 1px;
        border-left: none;
        border-top: 2px dotted #d4c4a8;
    }

    .postcard-message {
        padding-right: 0;
    }

    .postcard-stamp-side {
        padding-left: 0;
    }

    .stamp-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .radio-arcs {
        width: 280px;
        height: 280px;
    }

    .arc-middle {
        inset: 30px;
    }

    .arc-inner {
        inset: 60px;
    }

    .fold-line {
        width: 80%;
    }

    .mailing-label {
        padding: 0.75rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .stamp-grid {
        grid-template-columns: 1fr;
    }

    .radio-arcs {
        width: 220px;
        height: 220px;
    }

    .arc-middle {
        inset: 25px;
    }

    .arc-inner {
        inset: 50px;
    }
}
