/* ============================================
   SSETTL.com - Warm Sedimentary Design System
   A surreal memory theatre
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --settle-parchment: #F5EDE3;
    --settle-fired-clay: #2C1A0E;
    --settle-espresso: #3D2B1F;
    --settle-walnut: #4A3728;
    --settle-sienna-glow: #C4956A;
    --settle-umber: #8B6D4E;
    --settle-sandstone: #D4B896;
    --settle-amber-flame: #D4843E;
    --settle-bone: #EDE0D0;
    --settle-faded-sienna: #A08060;

    --settle-ease: cubic-bezier(0.25, 0.1, 0.25, 1.0);
    --settle-grid-gap: 48px;
    --settle-outer-margin: 80px;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--settle-parchment);
    color: var(--settle-walnut);
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
    position: relative;
}

/* --- Paper Texture Noise Overlay --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    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='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Horizon Rule --- */
#horizon-rule {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--settle-sienna-glow);
    z-index: 1000;
    opacity: 0.97;
    animation: horizon-pulse 4s var(--settle-ease) infinite alternate;
}

@keyframes horizon-pulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.97; }
    100% { opacity: 0.45; }
}

/* --- Depth Indicator --- */
#depth-indicator {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 1000;
    opacity: 0.8;
    animation: depth-pulse 3s var(--settle-ease) infinite alternate;
}

@keyframes depth-pulse {
    0% { opacity: 0.5; }
    100% { opacity: 0.9; }
}

#depth-indicator svg {
    display: block;
}

/* --- Grid Overlay --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: var(--settle-outer-margin);
    right: var(--settle-outer-margin);
    height: 100vh;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 2s var(--settle-ease);
}

#grid-overlay.visible {
    opacity: 1;
}

.grid-line {
    width: 1px;
    height: 100%;
    background-color: var(--settle-sandstone);
    opacity: 0.06;
    transition: opacity 0.6s var(--settle-ease), background-color 0.6s var(--settle-ease);
}

.grid-line.pulse {
    opacity: 0.15;
    background-color: var(--settle-sienna-glow);
}

/* --- Floating Ephemera --- */
.ephemera {
    position: absolute;
    pointer-events: none;
    z-index: 2;
    top: var(--ep-top);
    left: var(--ep-left);
    will-change: transform;
}

.ephemera-stamp {
    width: 48px;
    height: 56px;
    border: 1.5px solid var(--settle-umber);
    opacity: 0.08;
    border-radius: 2px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        var(--settle-sandstone) 3px,
        var(--settle-sandstone) 4px
    );
}

.ephemera-stamp::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1px solid var(--settle-sienna-glow);
    opacity: 0.5;
    border-radius: 50%;
}

.ephemera-coffee {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 35%, var(--settle-sienna-glow) 36%, var(--settle-sienna-glow) 42%, transparent 43%);
    opacity: 0.04;
}

.ephemera-dots {
    width: 28px;
    height: 28px;
    display: grid;
    grid-template-columns: repeat(3, 4px);
    grid-template-rows: repeat(3, 4px);
    gap: 4px;
    opacity: 0.1;
}

.ephemera-dots::before {
    content: '';
    position: absolute;
    width: 28px;
    height: 28px;
    background-image: radial-gradient(circle, var(--settle-sandstone) 1.5px, transparent 1.5px);
    background-size: 8px 8px;
    background-position: 2px 2px;
}

/* --- Strata (Sections) --- */
.stratum {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stratum-content {
    width: 100%;
    max-width: calc(100vw - 2 * var(--settle-outer-margin));
    margin: 0 auto;
    padding: 0 var(--settle-outer-margin);
    position: relative;
}

/* --- ACT 1: Surface Stratum --- */
#stratum-surface {
    background-color: var(--settle-parchment);
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-main {
    font-family: 'Source Serif 4', serif;
    font-weight: 600;
    font-size: 12vw;
    color: var(--settle-espresso);
    letter-spacing: -0.015em;
    text-align: center;
    line-height: 1;
    display: flex;
    justify-content: center;
    gap: 0.02em;
}

.letter {
    display: inline-block;
    opacity: 0.02;
    animation: letter-appear 800ms var(--settle-ease) forwards;
    animation-delay: calc(var(--delay) * 400ms + 300ms);
}

@keyframes letter-appear {
    0% {
        opacity: 0.02;
        transform: translateY(20px);
    }
    100% {
        opacity: 0.97;
        transform: translateY(0);
    }
}

/* --- Torn Edge Transitions --- */
.torn-edge {
    position: relative;
    z-index: 5;
    margin-top: -2px;
    margin-bottom: -2px;
    height: 80px;
    overflow: hidden;
}

.torn-edge svg {
    display: block;
    width: 100%;
    height: 100%;
}

.torn-edge-1,
.torn-edge-2 {
    background-color: var(--settle-parchment);
}

.torn-edge-1 svg path,
.torn-edge-2 svg path {
    fill: var(--settle-parchment);
}

.torn-edge-3 {
    background-color: var(--settle-parchment);
}

.torn-edge-3 svg path {
    fill: var(--settle-fired-clay);
}

.torn-edge-4 {
    background-color: var(--settle-fired-clay);
}

.torn-edge-4 svg path {
    fill: var(--settle-parchment);
}

/* Deep reveal strip between torn edges */
.torn-edge::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--settle-fired-clay);
    z-index: -1;
}

/* --- ACT 2: First Excavation --- */
.stratum-excavation {
    background-color: var(--settle-parchment);
    min-height: 120vh;
    padding: 120px 0 80px;
}

.excavation-layout {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--settle-grid-gap);
    align-items: start;
}

.excavation-photo {
    grid-column: 2 / 6;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.photo-frame {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
}

.photo-svg {
    display: block;
    width: 100%;
    height: auto;
}

.settle-photo {
    filter: sepia(0.3) contrast(0.9) brightness(1.05) saturate(0.8);
}

.contour-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.contour-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s var(--settle-ease);
}

.contour-draw.animated .contour-path {
    stroke-dashoffset: 0;
}

.excavation-text {
    grid-column: 1 / 3;
    margin-top: 200px;
}

.body-text {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.75;
    color: var(--settle-walnut);
    margin-bottom: 1.5em;
}

.excavation-margin {
    grid-column: 5 / 7;
    margin-top: 60px;
}

.margin-note {
    font-family: 'Alegreya', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 22px;
    color: var(--settle-umber);
    line-height: 1.5;
}

/* --- ACT 3: Deep Strata --- */
.stratum-deep {
    background-color: var(--settle-fired-clay);
    min-height: 100vh;
    padding: 100px 0;
}

.deep-layout {
    display: flex;
    justify-content: center;
}

.deep-column {
    max-width: 520px;
    width: 100%;
}

.section-heading {
    font-family: 'Source Serif 4', serif;
    font-weight: 600;
    font-size: 48px;
    color: var(--settle-bone);
    letter-spacing: -0.015em;
    margin-bottom: 40px;
    line-height: 1.15;
}

.body-text-light {
    color: var(--settle-bone);
    opacity: 0.92;
}

.meta-timestamp {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 12px;
    color: var(--settle-faded-sienna);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

/* --- ACT 4: Artifact Gallery --- */
.stratum-gallery {
    background-color: var(--settle-parchment);
    min-height: 150vh;
    padding: 100px 0 120px;
}

.gallery-layout {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--settle-grid-gap);
    row-gap: 80px;
    padding: 0 var(--settle-outer-margin);
    max-width: 100vw;
}

.artifact-card {
    position: relative;
    background-color: var(--settle-bone);
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 8px 32px rgba(44, 26, 14, 0.12);
    grid-column: span 2;
    transition: transform 0.4s var(--settle-ease), box-shadow 0.4s var(--settle-ease);
}

.artifact-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(44, 26, 14, 0.18);
}

/* Zigzag placement */
.artifact-card:nth-child(1) { grid-column: 1 / 3; }
.artifact-card:nth-child(2) { grid-column: 4 / 6; margin-top: 120px; }
.artifact-card:nth-child(3) { grid-column: 2 / 4; margin-top: -40px; }
.artifact-card:nth-child(4) { grid-column: 5 / 7; margin-top: 80px; }
.artifact-card:nth-child(5) { grid-column: 3 / 5; margin-top: -20px; }

.card-photo {
    width: 100%;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.card-photo svg {
    display: block;
    width: 100%;
    height: auto;
}

.card-contour {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    pointer-events: none;
    aspect-ratio: 4/3;
}

.card-text {
    padding: 20px 24px 28px;
}

.card-caption {
    font-family: 'Libre Franklin', sans-serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.65;
    color: var(--settle-walnut);
}

.card-torn-edge {
    position: absolute;
    right: -2px;
    top: 10%;
    bottom: 10%;
    width: 4px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--settle-fired-clay) 10%,
        transparent 20%,
        var(--settle-fired-clay) 35%,
        transparent 45%,
        var(--settle-fired-clay) 55%,
        transparent 65%,
        var(--settle-fired-clay) 75%,
        transparent 85%,
        var(--settle-fired-clay) 95%,
        transparent 100%
    );
    opacity: 0.3;
    border-radius: 2px;
}

/* --- ACT 5: Settled Ground --- */
.stratum-settled {
    background-color: var(--settle-parchment);
    height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.settled-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.settled-converge {
    position: relative;
}

.settled-closing {
    font-family: 'Alegreya', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 24px;
    color: var(--settle-umber);
    line-height: 1.6;
    opacity: 0.02;
    transition: opacity 1.6s var(--settle-ease);
}

.settled-closing.visible {
    opacity: 0.97;
}

/* Converging grid lines effect for Act 5 */
.stratum-settled::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(to bottom, transparent 0%, var(--settle-sandstone) 100%) no-repeat center / 1px 100%,
        linear-gradient(173deg, transparent 0%, transparent 90%, var(--settle-sandstone) 100%) no-repeat 20% 0 / 1px 100%,
        linear-gradient(187deg, transparent 0%, transparent 90%, var(--settle-sandstone) 100%) no-repeat 80% 0 / 1px 100%,
        linear-gradient(176deg, transparent 0%, transparent 85%, var(--settle-sandstone) 100%) no-repeat 35% 0 / 1px 100%,
        linear-gradient(184deg, transparent 0%, transparent 85%, var(--settle-sandstone) 100%) no-repeat 65% 0 / 1px 100%;
    opacity: 0.06;
    pointer-events: none;
}

/* --- Fade-In Animation for Scroll Elements --- */
.fade-in-element {
    opacity: 0.02;
    transform: translateY(30px);
    transition: opacity 0.8s var(--settle-ease), transform 0.8s var(--settle-ease);
}

.fade-in-element.visible {
    opacity: 0.97;
    transform: translateY(0);
}

/* Stagger delays */
.fade-in-element[data-stagger="0"] { transition-delay: 0ms; }
.fade-in-element[data-stagger="1"] { transition-delay: 100ms; }
.fade-in-element[data-stagger="2"] { transition-delay: 200ms; }
.fade-in-element[data-stagger="3"] { transition-delay: 300ms; }
.fade-in-element[data-stagger="4"] { transition-delay: 400ms; }
.fade-in-element[data-stagger="5"] { transition-delay: 500ms; }
.fade-in-element[data-stagger="6"] { transition-delay: 600ms; }

/* --- Responsive Adjustments --- */
@media (max-width: 1024px) {
    :root {
        --settle-outer-margin: 40px;
        --settle-grid-gap: 32px;
    }

    .title-main {
        font-size: 16vw;
    }

    .section-heading {
        font-size: 36px;
    }

    .excavation-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .excavation-photo {
        grid-column: 1;
    }

    .excavation-text {
        grid-column: 1;
        margin-top: 0;
    }

    .excavation-margin {
        grid-column: 1;
        margin-top: 0;
    }

    .gallery-layout {
        grid-template-columns: 1fr 1fr;
        padding: 0 40px;
        row-gap: 48px;
    }

    .artifact-card {
        grid-column: span 1 !important;
        margin-top: 0 !important;
    }

    .artifact-card:nth-child(even) {
        margin-top: 60px !important;
    }
}

@media (max-width: 640px) {
    :root {
        --settle-outer-margin: 24px;
        --settle-grid-gap: 20px;
    }

    .title-main {
        font-size: 20vw;
    }

    .section-heading {
        font-size: 28px;
    }

    .body-text {
        font-size: 16px;
    }

    .settled-closing {
        font-size: 20px;
        padding: 0 24px;
    }

    .gallery-layout {
        grid-template-columns: 1fr;
        padding: 0 24px;
    }

    .artifact-card {
        margin-top: 0 !important;
    }

    .artifact-card:nth-child(even) {
        margin-top: 0 !important;
    }

    .deep-column {
        padding: 0 24px;
    }

    .stratum-content {
        padding: 0 24px;
    }

    #grid-overlay {
        left: 24px;
        right: 24px;
    }
}

/* --- Selection Color --- */
::selection {
    background-color: var(--settle-sienna-glow);
    color: var(--settle-parchment);
}
