/* ============================================
   SSETTL.com — Styles
   Sepia-toned archival descent
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --parchment: #f5f0e6;
    --parchment-deep: #ede4d0;
    --raw-sienna: #c4733b;
    --foxing-red: #8b3a3a;
    --dark-loam: #2c2416;
    --strata-mid: #c4a97d;
    --strata-light: #e8dcc8;
    --strata-deep: #8b7355;
    --brass: #9e8a5e;
    --cream-text: #f0ebe0;
    --charcoal-ink: #2a2520;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Source Serif 4', 'Georgia', serif;
    --font-annotation: 'IM Fell English', 'Georgia', serif;
    --font-mono: 'Courier Prime', 'Courier New', monospace;
}

/* --- 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-size: 18px;
    line-height: 1.75;
    color: var(--charcoal-ink);
    background-color: var(--parchment);
    overflow-x: hidden;
    cursor: crosshair;
}

/* --- Paper Grain Texture Overlay --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* --- Selection --- */
::selection {
    background-color: rgba(196, 169, 125, 0.4);
    color: var(--charcoal-ink);
}

/* ============================================
   Section 1: The Survey Line
   ============================================ */
.section-survey {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #faf7f0, var(--parchment));
    z-index: 5;
}

.survey-line-container {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    padding: 0 4%;
}

.survey-svg {
    width: 100%;
    height: 2px;
    display: block;
}

#survey-path {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: none;
}

#survey-path.animate {
    animation: drawSurveyLine 2s ease-in-out forwards;
}

@keyframes drawSurveyLine {
    to {
        stroke-dashoffset: 0;
    }
}

.title-container {
    position: relative;
    margin-top: 20px;
    text-align: center;
}

.title-letters {
    display: inline-flex;
    gap: 0.05em;
}

.letter {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 7rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--charcoal-ink);
    display: inline-block;
    opacity: 0;
    transform: translateY(-40px);
}

.letter.settled {
    opacity: 1;
    transform: translateY(0);
    animation: letterBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes letterBounce {
    0% {
        opacity: 0;
        transform: translateY(-40px);
    }
    50% {
        opacity: 1;
        transform: translateY(4px);
    }
    70% {
        transform: translateY(-2px);
    }
    85% {
        transform: translateY(1px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.dust-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: var(--strata-mid);
    opacity: 0;
    animation: dustDrift 0.4s ease-out forwards;
}

@keyframes dustDrift {
    0% {
        opacity: 0.6;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), 20px) scale(0.3);
    }
}

.subtitle {
    font-family: var(--font-annotation);
    font-style: italic;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--brass);
    margin-top: 24px;
    opacity: 0;
    transition: opacity 0.6s ease;
    padding-left: 6%;
}

.subtitle.visible {
    opacity: 1;
}

.scroll-chevron {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: chevronPulse 2s ease-in-out infinite;
    animation-delay: 3s;
}

.scroll-chevron.visible {
    opacity: 1;
}

@keyframes chevronPulse {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-50%) translateY(0);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) translateY(6px);
    }
}

/* ============================================
   Section 2: The Ledger
   ============================================ */
.section-ledger {
    position: relative;
    z-index: 6;
    padding: 0 4%;
    margin-top: -60px;
}

.ledger-page {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
    background-color: var(--parchment);
    padding: 80px 60px;
    box-shadow: 0 4px 20px rgba(44, 36, 22, 0.15);
    margin-left: calc(50% - 550px + 4%);
}

@media (max-width: 1200px) {
    .ledger-page {
        margin-left: auto;
        margin-right: auto;
    }
}

/* Torn Edge Top */
.torn-edge-top {
    position: absolute;
    top: -12px;
    left: 0;
    width: 100%;
    height: 14px;
    background-color: var(--parchment);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 14'%3E%3Cpath d='M0 14 L0 6 Q30 2 60 5 Q90 8 120 3 Q150 0 180 4 Q210 7 240 2 Q270 0 300 5 Q330 9 360 4 Q390 1 420 6 Q450 8 480 3 Q510 0 540 5 Q570 7 600 2 Q630 0 660 4 Q690 8 720 3 Q750 1 780 6 Q810 9 840 4 Q870 0 900 5 Q930 7 960 2 Q990 0 1020 4 Q1050 8 1080 3 Q1110 1 1140 6 Q1170 8 1200 4 L1200 14 Z' fill='white'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 14'%3E%3Cpath d='M0 14 L0 6 Q30 2 60 5 Q90 8 120 3 Q150 0 180 4 Q210 7 240 2 Q270 0 300 5 Q330 9 360 4 Q390 1 420 6 Q450 8 480 3 Q510 0 540 5 Q570 7 600 2 Q630 0 660 4 Q690 8 720 3 Q750 1 780 6 Q810 9 840 4 Q870 0 900 5 Q930 7 960 2 Q990 0 1020 4 Q1050 8 1080 3 Q1110 1 1140 6 Q1170 8 1200 4 L1200 14 Z' fill='white'/%3E%3C/svg%3E");
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
}

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

.foxing-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--strata-mid);
    opacity: 0.3;
}

.foxing-dot:nth-child(2n) {
    width: 6px;
    height: 6px;
    opacity: 0.2;
}

.foxing-dot:nth-child(3n) {
    width: 10px;
    height: 10px;
    opacity: 0.15;
}

/* Margin Annotations */
.margin-annotation {
    position: absolute;
    font-family: var(--font-annotation);
    font-style: italic;
    font-size: 14px;
    color: var(--charcoal-ink);
    opacity: 0.4;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    pointer-events: none;
    z-index: 2;
}

.left-margin {
    left: 16px;
}

.right-margin {
    right: 16px;
}

/* Ledger Columns */
.ledger-columns {
    display: flex;
    gap: 0;
    position: relative;
    z-index: 3;
}

.ledger-col {
    flex: 1;
    padding: 0 30px;
}

.ledger-divider {
    width: 1px;
    background-color: var(--brass);
    opacity: 0.4;
    flex-shrink: 0;
}

.ledger-heading {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--charcoal-ink);
    margin-bottom: 8px;
}

.heading-rule {
    width: 100%;
    height: 2px;
    display: block;
    margin-bottom: 28px;
}

.ledger-col p {
    margin-bottom: 20px;
    font-weight: 400;
}

.annotation-text {
    color: var(--foxing-red);
    font-weight: 600;
}

/* Ledger Ruled Lines */
.ledger-rules {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 27px,
        rgba(196, 169, 125, 0.2) 27px,
        rgba(196, 169, 125, 0.2) 28px
    );
}

/* ============================================
   Section 3: The Strata
   ============================================ */
.section-strata {
    position: relative;
    z-index: 4;
    margin-top: 100px;
    padding: 0;
}

.stratum {
    position: relative;
    width: 100%;
    padding: 80px 8%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s linear;
}

.stratum + .stratum {
    margin-top: 4px;
}

.stratum-1 {
    background-color: var(--strata-light);
}

.stratum-2 {
    background-color: var(--strata-mid);
}

.stratum-3 {
    background-color: var(--strata-deep);
}

/* Torn edge bottom for strata */
.stratum-3::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 0;
    width: 100%;
    height: 14px;
    background-color: var(--strata-deep);
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 14'%3E%3Cpath d='M0 0 L0 8 Q30 12 60 9 Q90 6 120 11 Q150 14 180 10 Q210 7 240 12 Q270 14 300 9 Q330 5 360 10 Q390 13 420 8 Q450 6 480 11 Q510 14 540 9 Q570 7 600 12 Q630 14 660 10 Q690 6 720 11 Q750 13 780 8 Q810 5 840 10 Q870 14 900 9 Q930 7 960 12 Q990 14 1020 10 Q1050 6 1080 11 Q1110 13 1140 8 Q1170 6 1200 10 L1200 0 Z' fill='white'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 14'%3E%3Cpath d='M0 0 L0 8 Q30 12 60 9 Q90 6 120 11 Q150 14 180 10 Q210 7 240 12 Q270 14 300 9 Q330 5 360 10 Q390 13 420 8 Q450 6 480 11 Q510 14 540 9 Q570 7 600 12 Q630 14 660 10 Q690 6 720 11 Q750 13 780 8 Q810 5 840 10 Q870 14 900 9 Q930 7 960 12 Q990 14 1020 10 Q1050 6 1080 11 Q1110 13 1140 8 Q1170 6 1200 10 L1200 0 Z' fill='white'/%3E%3C/svg%3E");
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
}

.stratum-content {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 800px;
    padding-left: 4%;
}

.stratum-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--charcoal-ink);
}

.stratum-3 .stratum-title {
    color: var(--cream-text);
}

/* Survey line between strata */
.stratum::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background-color: var(--brass);
    opacity: 0.5;
}

.stratum-1::before {
    display: none;
}

/* Wax Seal */
.wax-seal {
    flex-shrink: 0;
    filter: drop-shadow(1px 2px 2px rgba(44, 36, 22, 0.3));
}

/* ============================================
   Section 4: The Archive
   ============================================ */
.section-archive {
    position: relative;
    z-index: 3;
    padding: 100px 6%;
    margin-top: 80px;
}

.archive-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(200px, auto);
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    margin-left: calc(50% - 600px - 3%);
}

@media (max-width: 1300px) {
    .archive-grid {
        margin-left: auto;
        margin-right: auto;
    }
}

.archive-card {
    position: relative;
    overflow: hidden;
    cursor: crosshair;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    box-shadow: 0 4px 20px rgba(44, 36, 22, 0.15);
    opacity: 0;
    transform: scale(0.95);
}

.archive-card.visible {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.2s ease-out;
}

.archive-card:hover {
    transform: translateY(-6px) scale(1);
    box-shadow: 0 8px 40px rgba(44, 36, 22, 0.25);
}

.card-landscape {
    grid-column: span 2;
    min-height: 240px;
}

.card-portrait {
    grid-row: span 2;
    min-height: 400px;
}

.card-square {
    min-height: 240px;
}

.card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.card-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(44, 36, 22, 0.5) 100%);
    transition: background 0.2s ease;
}

.archive-card:hover .card-vignette {
    background: radial-gradient(ellipse at center, transparent 40%, rgba(44, 36, 22, 0.35) 100%);
}

/* Brass Corners */
.brass-corners {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.corner {
    position: absolute;
    width: 24px;
    height: 24px;
    transition: width 0.2s ease, height 0.2s ease;
}

.corner::before,
.corner::after {
    content: '';
    position: absolute;
    background-color: var(--brass);
}

.corner-tl {
    top: 8px;
    left: 8px;
}
.corner-tl::before {
    top: 0;
    left: 0;
    width: 24px;
    height: 1px;
    transition: width 0.2s ease;
}
.corner-tl::after {
    top: 0;
    left: 0;
    width: 1px;
    height: 24px;
    transition: height 0.2s ease;
}

.corner-tr {
    top: 8px;
    right: 8px;
}
.corner-tr::before {
    top: 0;
    right: 0;
    width: 24px;
    height: 1px;
    transition: width 0.2s ease;
}
.corner-tr::after {
    top: 0;
    right: 0;
    width: 1px;
    height: 24px;
    transition: height 0.2s ease;
}

.corner-br {
    bottom: 8px;
    right: 8px;
}
.corner-br::before {
    bottom: 0;
    right: 0;
    width: 24px;
    height: 1px;
    transition: width 0.2s ease;
}
.corner-br::after {
    bottom: 0;
    right: 0;
    width: 1px;
    height: 24px;
    transition: height 0.2s ease;
}

.corner-bl {
    bottom: 8px;
    left: 8px;
}
.corner-bl::before {
    bottom: 0;
    left: 0;
    width: 24px;
    height: 1px;
    transition: width 0.2s ease;
}
.corner-bl::after {
    bottom: 0;
    left: 0;
    width: 1px;
    height: 24px;
    transition: height 0.2s ease;
}

.archive-card:hover .corner-tl::before,
.archive-card:hover .corner-tr::before,
.archive-card:hover .corner-br::before,
.archive-card:hover .corner-bl::before {
    width: 32px;
}

.archive-card:hover .corner-tl::after,
.archive-card:hover .corner-tr::after,
.archive-card:hover .corner-br::after,
.archive-card:hover .corner-bl::after {
    height: 32px;
}

.card-content {
    position: relative;
    z-index: 2;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
}

.card-label {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--brass);
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.card-title {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 700;
    color: var(--cream-text);
    margin-bottom: 6px;
}

.card-text {
    font-family: var(--font-annotation);
    font-style: italic;
    font-size: 14px;
    color: rgba(240, 235, 224, 0.8);
    line-height: 1.5;
}

/* ============================================
   Section 5: The Foundation (Footer)
   ============================================ */
.section-foundation {
    position: relative;
    z-index: 2;
    background-color: var(--dark-loam);
    padding: 80px 6% 100px;
    text-align: center;
    margin-top: 80px;
}

.footer-rule {
    width: 100%;
    height: 2px;
    display: block;
    margin-bottom: 60px;
}

.foundation-text {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--cream-text);
    font-weight: 400;
}

/* ============================================
   Shadows between sections
   ============================================ */
.section-ledger .ledger-page,
.section-strata .stratum,
.section-archive .archive-card {
    position: relative;
}

.section-strata {
    box-shadow: 0 -4px 20px rgba(44, 36, 22, 0.1);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .ledger-columns {
        flex-direction: column;
    }

    .ledger-divider {
        width: 100%;
        height: 1px;
        margin: 30px 0;
    }

    .ledger-col {
        padding: 0;
    }

    .ledger-page {
        padding: 50px 30px;
    }

    .margin-annotation {
        display: none;
    }

    .archive-grid {
        grid-template-columns: 1fr;
    }

    .card-landscape {
        grid-column: span 1;
    }

    .card-portrait {
        grid-row: span 1;
        min-height: 280px;
    }

    .stratum-content {
        padding-left: 0;
    }

    .stratum {
        padding: 60px 6%;
    }
}

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

    .section-ledger {
        padding: 0 2%;
    }

    .ledger-page {
        padding: 40px 20px;
    }

    .section-archive {
        padding: 60px 3%;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .letter {
        opacity: 1;
        transform: none;
    }

    .subtitle {
        opacity: 1;
    }

    .scroll-chevron {
        opacity: 0.5;
    }

    .archive-card {
        opacity: 1;
        transform: none;
    }
}
