/* ========================================
   SSETTL.com - Design System
   Glitch-Nostalgia / Warm-Inviting
   ======================================== */

/* --- Custom Properties --- */
:root {
    --color-bg-primary: #f0e6d2;
    --color-bg-secondary: #e3d5bc;
    --color-bg-deep: #3d2e1f;
    --color-text-primary: #2c1e10;
    --color-text-muted: #7a7261;
    --color-accent-warm: #c4653a;
    --color-accent-cool: #5e8a7a;
    --color-glitch: #d45b8a;
    --color-card-surface: #f0e6d2;
    --color-card-shadow: #b8a88a;
    --color-ochre: #c4a76c;
    --font-display: 'Playfair Display', serif;
    --font-body: 'Libre Baskerville', serif;
    --font-ui: 'DM Sans', sans-serif;
    --blur-base: 12px;
    --transition-blur: filter 1200ms ease-out, opacity 1200ms ease-out;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* --- Grain Overlay --- */
.grain-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 300px 300px;
}

/* --- Scanline Overlay --- */
.scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0,0,0,0.03) 2px,
        rgba(0,0,0,0.03) 4px
    );
}

/* --- Blur-Focus Animation System --- */
.blur-target {
    filter: blur(var(--blur-base));
    opacity: 0;
    transition: var(--transition-blur);
}

.blur-target.revealed {
    filter: blur(0);
    opacity: 1;
}

.blur-target.secondary {
    transition-delay: 300ms;
}

/* --- Chapters Base --- */
.chapter {
    min-height: 100vh;
    position: relative;
    transition: background-color 800ms ease-in-out;
}

/* ========================================
   CHAPTER 1: HERO
   ======================================== */
.chapter-1 {
    background-color: var(--color-bg-primary);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 8%;
    animation: heroBreathing 30s ease-in-out infinite;
}

@keyframes heroBreathing {
    0%, 100% { background-color: #c4a76c; }
    50% { background-color: #e3d5bc; }
}

.hero-content {
    position: relative;
}

/* --- Hero Wordmark with Glitch --- */
.hero-wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18vw;
    letter-spacing: -0.03em;
    line-height: 0.9;
    position: relative;
    display: inline-block;
}

.glitch-layer {
    display: block;
}

.glitch-base {
    position: relative;
    color: var(--color-text-primary);
}

.glitch-magenta {
    position: absolute;
    top: 0;
    left: 0;
    color: var(--color-glitch);
    mix-blend-mode: screen;
    animation: glitchMagenta 6s ease-in-out infinite;
}

.glitch-copper {
    position: absolute;
    top: 0;
    left: 0;
    color: var(--color-accent-cool);
    mix-blend-mode: screen;
    animation: glitchCopper 6s ease-in-out infinite;
}

@keyframes glitchMagenta {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(2px, -1px); }
    50% { transform: translate(-1px, 2px); }
    75% { transform: translate(3px, 1px); }
}

@keyframes glitchCopper {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-2px, 1px); }
    50% { transform: translate(1px, -2px); }
    75% { transform: translate(-3px, -1px); }
}

/* VHS pixel displacement */
.hero-wordmark.vhs-glitch .glitch-base {
    animation: vhsDisplace 8s step-end infinite;
}

@keyframes vhsDisplace {
    0%, 98%, 100% { clip-path: inset(0 0 0 0); }
    98.5% { clip-path: inset(20% 0 40% 0); }
    99% { clip-path: inset(60% 0 10% 0); }
    99.5% { clip-path: inset(10% 0 70% 0); }
}

.hero-tagline {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    color: var(--color-text-muted);
    margin-top: 1.5rem;
}

/* ========================================
   CHAPTER 2: TWO-COLUMN NARRATIVE
   ======================================== */
.chapter-2 {
    background-color: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    padding: 10vh 8%;
}

.chapter-2-inner {
    display: flex;
    gap: 6vw;
    max-width: 1400px;
    width: 100%;
}

.narrative-column {
    flex: 0 0 65%;
}

.chapter-heading {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(3rem, 12vw, 10rem);
    letter-spacing: -0.03em;
    line-height: 0.9;
    color: var(--color-text-primary);
    margin-bottom: 2rem;
}

.fleuron {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-text-muted);
    opacity: 0.5;
    margin: 1.5rem 0;
}

.body-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--color-text-primary);
    margin-bottom: 1.5rem;
}

.icon-column {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
}

.iso-icon {
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
}

.iso-icon:hover {
    transform: perspective(400px) rotateY(8deg) scale(1.5);
}

.iso-icon svg {
    width: 64px;
    height: 64px;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.iso-icon:hover svg {
    width: 96px;
    height: 96px;
}

/* ========================================
   CHAPTER 3: TYPOGRAPHY AS ARCHITECTURE
   ======================================== */
.chapter-3 {
    background-color: var(--color-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120vh;
    position: relative;
    overflow: hidden;
}

.oversized-word {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 60vw;
    letter-spacing: -0.03em;
    line-height: 0.85;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.letter-span {
    display: inline-block;
    position: relative;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    transition: transform 0.3s ease-out;
}

.letter-span[data-color="#c4653a"] { background-color: #c4653a; }
.letter-span[data-color="#5e8a7a"] { background-color: #5e8a7a; }
.letter-span[data-color="#7a7261"] { background-color: #7a7261; }
.letter-span[data-color="#d45b8a"] { background-color: #d45b8a; }
.letter-span[data-color="#3d2e1f"] { background-color: #3d2e1f; }

.chapter-3-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0,0,0,0.04) 2px,
        rgba(0,0,0,0.04) 4px
    );
}

/* ========================================
   CHAPTER 4: STAGGERED CARDS
   ======================================== */
.chapter-4 {
    background-color: var(--color-bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10vh 8%;
}

.staggered-cards {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    max-width: 800px;
    width: 100%;
}

.content-card {
    background-color: var(--color-card-surface);
    padding: 3rem 2.5rem;
    position: relative;
    transform: rotate(var(--rotation));
    box-shadow: 4px 4px 0 var(--color-card-shadow);
    width: 100%;
    max-width: 650px;
}

.card-1 { margin-left: -5%; }
.card-2 { margin-right: -8%; }
.card-3 { margin-left: -3%; }

/* Corner brackets */
.card-bracket-tl,
.card-bracket-br {
    position: absolute;
    width: 20px;
    height: 20px;
}

.card-bracket-tl {
    top: 12px;
    left: 12px;
    border-top: 1px solid var(--color-card-shadow);
    border-left: 1px solid var(--color-card-shadow);
}

.card-bracket-br {
    bottom: 12px;
    right: 12px;
    border-bottom: 1px solid var(--color-card-shadow);
    border-right: 1px solid var(--color-card-shadow);
}

.card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
}

.content-card .fleuron {
    margin: 0.75rem 0;
}

.card-body {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.6vw, 1.125rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--color-text-primary);
}

/* Ornamental rule */
.content-card::after {
    content: '';
    position: absolute;
    bottom: -1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
    background-color: var(--color-card-shadow);
    opacity: 0;
}

.content-card:not(:last-child)::after {
    opacity: 0.5;
}

/* ========================================
   CHAPTER 5: CLOSING
   ======================================== */
.chapter-5 {
    background-color: var(--color-bg-deep);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 10vh 8%;
}

.close-content {
    text-align: right;
}

.close-message {
    font-family: var(--font-body);
    font-style: italic;
    font-size: clamp(1.25rem, 3vw, 2rem);
    color: var(--color-bg-primary);
    line-height: 1.5;
    margin-bottom: 3rem;
}

.close-wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 8vw;
    letter-spacing: -0.03em;
    line-height: 0.9;
    position: relative;
    display: inline-block;
}

.glitch-base-light {
    position: relative;
    color: var(--color-bg-primary);
}

.close-wordmark .glitch-magenta {
    color: var(--color-glitch);
    animation: glitchMagenta 6s ease-in-out infinite;
}

.close-wordmark .glitch-copper {
    color: var(--color-accent-cool);
    animation: glitchCopper 6s ease-in-out infinite;
}

/* ========================================
   FLOATING NAVIGATION CUBE
   ======================================== */
.nav-cube {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9000;
    opacity: 0;
    transition: opacity 600ms ease;
}

.nav-cube.visible {
    opacity: 1;
}

.cube-glyph {
    width: 32px;
    height: 32px;
    cursor: pointer;
    animation: cubePulse 4s ease-in-out infinite, cubeRotate 20s linear infinite;
    transition: transform 0.3s ease;
}

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

@keyframes cubeRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.nav-cube:hover .cube-glyph {
    animation-play-state: paused, paused;
    transform: scale(1.1);
    opacity: 1;
}

.radial-menu {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-cube:hover .radial-menu {
    pointer-events: auto;
    opacity: 1;
}

.radial-item {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--color-bg-primary);
    box-shadow: 2px 2px 8px rgba(44, 30, 16, 0.2);
    text-decoration: none;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease;
    transform: translate(0, 0) scale(0);
}

.nav-cube:hover .radial-item {
    transform: translate(
        calc(cos(var(--angle)) * -70px),
        calc(sin(var(--angle)) * -70px)
    ) scale(1);
}

.radial-item:hover {
    background-color: var(--color-accent-warm);
}

.radial-item::after {
    content: attr(data-label);
    position: absolute;
    right: calc(100% + 8px);
    white-space: nowrap;
    font-family: var(--font-ui);
    font-size: 0.65rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.radial-item:hover::after {
    opacity: 1;
}

/* --- Link Underline Draw-On Effect --- */
a {
    color: var(--color-accent-warm);
    text-decoration: none;
    background-image: linear-gradient(var(--color-accent-warm), var(--color-accent-warm));
    background-position: 0% 100%;
    background-repeat: no-repeat;
    background-size: 0% 1px;
    transition: background-size 0.3s ease;
}

a:hover {
    background-size: 100% 1px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chapter-2-inner {
        flex-direction: column;
    }

    .narrative-column {
        flex: 1 1 auto;
    }

    .icon-column {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        flex: 1 1 auto;
    }

    .hero-wordmark {
        font-size: 22vw;
    }

    .oversized-word {
        font-size: 30vw;
    }

    .staggered-cards {
        gap: 2rem;
    }

    .content-card {
        padding: 2rem 1.5rem;
    }

    .card-1, .card-2, .card-3 {
        margin-left: 0;
        margin-right: 0;
    }

    .nav-cube {
        bottom: 1rem;
        right: 1rem;
    }
}
