/* ============================================
   turingtest.club — Design Language Stylesheet
   Chrome-on-paper // Art Deco meets Bletchley Park
   ============================================ */

/* --- Custom Properties (Mirror Inversion Ready) --- */
:root {
    --mercury-silver: #c0c0c8;
    --tarnished-steel: #7a7d85;
    --aged-vellum: #f5ead6;
    --foxing-brown: #a0896c;
    --turing-ink: #1e1e28;
    --verdigris: #4a8c7f;
    --blush-dawn: #d4a5a5;
    --chrome-light: #e8e8ee;
    --paper-mid: #e8dcc6;
    --paper-dark: #d4c8a8;

    --bg-primary: var(--turing-ink);
    --text-primary: var(--aged-vellum);
    --text-secondary: var(--mercury-silver);
    --text-accent: var(--blush-dawn);
    --surface-chrome: var(--mercury-silver);
    --surface-paper: var(--aged-vellum);

    --font-display: 'Poiret One', cursive;
    --font-body: 'Cormorant Garamond', serif;
    --font-mono: 'DM Mono', monospace;

    --chrome-gradient: linear-gradient(170deg, #c0c0c8 0%, #e8e8ee 35%, #7a7d85 70%, #c0c0c8 100%);
    --paper-gradient: radial-gradient(ellipse at 30% 40%, #f5ead6 0%, #e8dcc6 60%, #d4c8a8 100%);

    --content-width: 640px;
    --section-gap: 160px;
}

/* --- Mirror Inversion Mode --- */
body.mirror-inverted {
    --bg-primary: var(--aged-vellum);
    --text-primary: var(--turing-ink);
    --text-secondary: var(--tarnished-steel);
    --text-accent: var(--verdigris);
    --surface-chrome: var(--foxing-brown);
    --surface-paper: var(--mercury-silver);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
    overflow-x: hidden;
    transition: background-color 1.2s ease, color 1.2s ease;
}

/* --- Mercury Thermometer Progress Indicator --- */
#progress-track {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 200px;
    background: linear-gradient(to bottom, rgba(192,192,200,0.1), rgba(192,192,200,0.2));
    border-radius: 2px;
    z-index: 100;
    overflow: visible;
}

#progress-mercury {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #c0c0c8, #e8e8ee);
    border-radius: 2px;
    transition: height 0.1s linear;
    box-shadow: 0 0 6px rgba(192,192,200,0.3);
}

#progress-bulb {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    background: var(--mercury-silver);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(192,192,200,0.4);
}

/* --- Watermark Overlay --- */
#watermark-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#watermark-overlay p {
    font-family: var(--font-body);
    font-size: 4vw;
    color: var(--mercury-silver);
    opacity: 0.03;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    transform: rotate(-30deg);
    white-space: nowrap;
    user-select: none;
}

/* --- THE THRESHOLD --- */
.section-threshold {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.paper-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--paper-gradient);
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

.threshold-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: var(--content-width);
    padding: 0 2rem;
}

.deco-medallion {
    margin: 0 auto 3rem;
    width: 120px;
    height: 120px;
    opacity: 0.5;
}

.enigma-rotor {
    width: 100%;
    height: 100%;
    animation: slowRotate 120s linear infinite;
}

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

.threshold-question {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
    min-height: 1.5em;
    margin-bottom: 2rem;
}

.threshold-question .cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--text-accent);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

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

.threshold-attribution {
    opacity: 0;
    transition: opacity 1.5s ease 0.5s;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.threshold-attribution.visible {
    opacity: 1;
}

.dm-mono {
    font-family: var(--font-mono);
}

/* --- Botanical Illustrations --- */
.botanical {
    position: absolute;
    top: 0;
    height: 100%;
    width: 120px;
    z-index: 1;
    pointer-events: none;
}

.botanical-left {
    left: 5%;
}

.botanical-right {
    right: 5%;
}

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

/* --- Art Deco Dividers --- */
.deco-divider {
    position: relative;
    padding: 40px 0;
    max-width: 800px;
    margin: 0 auto;
    z-index: 2;
}

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

/* --- CORRESPONDENCE Sections (Letters) --- */
.section-letter {
    position: relative;
    padding: var(--section-gap) 2rem;
    z-index: 2;
}

.letter-wrapper {
    max-width: var(--content-width);
    margin: 0 auto;
}

.letter-content {
    position: relative;
    padding: 3rem 2.5rem;
    background: var(--paper-gradient);
    color: var(--turing-ink);
    border-radius: 2px;
    overflow: hidden;
}

.torn-edges {
    clip-path: polygon(
        0% 2%, 3% 0%, 7% 1.5%, 12% 0.5%, 18% 2%, 23% 0%, 28% 1%, 33% 0.5%, 
        38% 2%, 43% 0%, 48% 1.5%, 53% 0%, 58% 2%, 63% 0.5%, 68% 1%, 73% 2%, 
        78% 0%, 83% 1.5%, 88% 0.5%, 93% 2%, 97% 0%, 100% 1.5%,
        100% 97%, 97% 100%, 93% 98.5%, 88% 100%, 83% 98%, 78% 100%, 73% 99%, 
        68% 100%, 63% 98%, 58% 99.5%, 53% 100%, 48% 98%, 43% 100%, 38% 99%, 
        33% 100%, 28% 98.5%, 23% 100%, 18% 99%, 12% 100%, 7% 98.5%, 3% 100%, 0% 98%
    );
}

.foxing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 15% 25%, rgba(160,137,108,0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 60%, rgba(160,137,108,0.1) 0%, transparent 40%),
        radial-gradient(ellipse at 40% 80%, rgba(160,137,108,0.12) 0%, transparent 45%),
        radial-gradient(circle at 85% 15%, rgba(160,137,108,0.08) 0%, transparent 30%);
    pointer-events: none;
    animation: foxingFade 8s ease-in-out infinite alternate;
}

@keyframes foxingFade {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

.letter-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(160,137,108,0.3);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.letter-date {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--tarnished-steel);
    text-transform: uppercase;
}

.letter-timestamp {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--foxing-brown);
    opacity: 0.7;
}

.letter-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.5vw, 2.2rem);
    font-weight: 400;
    color: var(--turing-ink);
    margin-bottom: 1.5rem;
    letter-spacing: 0.03em;
}

.letter-body {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.75;
    color: var(--turing-ink);
    margin-bottom: 1.25rem;
}

.letter-body em {
    font-style: italic;
    color: #2a2a35;
}

.letter-body.aside {
    font-style: italic;
    color: var(--tarnished-steel);
    padding-left: 1.5rem;
    border-left: 2px solid var(--foxing-brown);
    opacity: 0.85;
}

.letter-quote {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--turing-ink);
    padding: 1.5rem 2rem;
    margin: 1.5rem 0;
    border-left: 3px solid var(--verdigris);
    background: rgba(74,140,127,0.05);
}

.chess-bullet {
    font-style: normal;
    margin-right: 0.25rem;
    color: var(--tarnished-steel);
    font-size: 1.1em;
}

.chess-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.chess-list li {
    padding: 0.75rem 0;
    padding-left: 0.5rem;
    border-bottom: 1px solid rgba(160,137,108,0.15);
    font-size: 1rem;
    line-height: 1.65;
}

.chess-list li:last-child {
    border-bottom: none;
}

.chess-list li strong {
    color: var(--turing-ink);
    font-weight: 600;
}

.wax-seal {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
    opacity: 0.8;
}

.seal-svg {
    width: 45px;
    height: 45px;
}

/* --- THE MIRROR Section --- */
.section-mirror {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 2;
}

.mirror-chrome-surface {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--chrome-gradient);
    opacity: 0.06;
    transition: opacity 1.2s ease;
}

.section-mirror.active .mirror-chrome-surface {
    opacity: 0.12;
}

.mirror-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: var(--content-width);
    padding: 0 2rem;
}

.enigma-medallion {
    margin: 0 auto 3rem;
    width: 200px;
    height: 200px;
    opacity: 0.5;
}

.enigma-large {
    width: 100%;
    height: 100%;
    animation: slowRotate 200s linear infinite reverse;
}

.mirror-question {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.08em;
    margin-bottom: 2rem;
    transition: color 1.2s ease;
}

.mirror-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease, color 1.2s ease;
}

.mirror-subtext.visible {
    opacity: 0.6;
    transform: translateY(0);
}

#mirror-result {
    color: var(--verdigris);
    transition: color 1.2s ease;
}

/* --- Ink Bleed Effect (applied via JS) --- */
.ink-bleed {
    text-shadow: 
        0 0 0 transparent,
        0 0 0 transparent;
    transition: text-shadow 1.5s ease;
}

.ink-bleed.active {
    text-shadow: 
        1px 1px 2px rgba(30,30,40,0.15),
        -0.5px 0.5px 1px rgba(30,30,40,0.08);
}

/* --- THE ARCHIVE Section --- */
.section-archive {
    position: relative;
    padding: var(--section-gap) 2rem;
    z-index: 2;
}

.archive-wrapper {
    max-width: var(--content-width);
    margin: 0 auto;
}

.archive-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    text-align: center;
}

.archive-intro {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    margin-bottom: 3rem;
    opacity: 0.6;
}

.archive-item {
    margin-bottom: 3rem;
    padding: 2rem;
    background: rgba(245,234,214,0.04);
    border-left: 2px solid var(--mercury-silver);
    transition: background 0.6s ease, border-color 0.6s ease;
}

.archive-item:hover {
    background: rgba(245,234,214,0.08);
    border-left-color: var(--verdigris);
}

.archive-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    color: var(--tarnished-steel);
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.archive-text {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--text-primary);
}

.archive-text.aside {
    font-style: italic;
    color: var(--text-secondary);
}

/* --- CLOSING Section --- */
.section-closing {
    position: relative;
    padding: var(--section-gap) 2rem;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.closing-content {
    text-align: center;
    max-width: var(--content-width);
}

.closing-medallion {
    margin-bottom: 2rem;
    width: 80px;
    height: 80px;
    opacity: 0.4;
}

.closing-seal {
    width: 100%;
    height: 100%;
}

.closing-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
    opacity: 0.5;
    margin-bottom: 2rem;
    line-height: 2;
}

.closing-question {
    font-family: var(--font-display);
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--text-accent);
    letter-spacing: 0.05em;
    font-weight: 400;
}

/* --- Chrome Shimmer Effect --- */
.chrome-shimmer {
    background-size: 200% 200%;
    animation: chromeShift 8s ease infinite;
}

@keyframes chromeShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Paper Fold Transition --- */
.paper-fold {
    transform: perspective(1000px) rotateX(0deg);
    transform-origin: top center;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s ease;
    opacity: 1;
}

.paper-fold.folded {
    transform: perspective(1000px) rotateX(-5deg);
    opacity: 0.7;
}

/* --- Scroll-triggered fade-in --- */
.fade-in-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Grid paper underlay (rotates on scroll) --- */
.section-letter::before {
    content: '';
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-image: 
        linear-gradient(rgba(192,192,200,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(192,192,200,0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 0;
    transition: transform 0.1s linear;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    :root {
        --section-gap: 100px;
        --content-width: 100%;
    }

    .botanical {
        display: none;
    }

    #progress-track {
        right: 12px;
        height: 150px;
    }

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

    .letter-header {
        flex-direction: column;
    }

    .enigma-medallion {
        width: 140px;
        height: 140px;
    }

    .deco-divider {
        padding: 20px 1rem;
    }
}

@media (max-width: 480px) {
    .threshold-question {
        font-size: 1.6rem;
    }

    .mirror-question {
        font-size: 2rem;
    }

    .letter-content {
        padding: 1.5rem 1rem;
    }

    .archive-item {
        padding: 1.5rem 1rem;
    }
}