/* ===========================================
   moral.quest - Goblincore Moral Philosophy
   =========================================== */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: #2E2A24;
    color: #E8DFD0;
    font-family: 'Crimson Text', Helvetica, Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.12rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* --- Scroll Indicator --- */
.scroll-indicator {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #5A7A4A;
    opacity: 0.3;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

/* ===========================================
   HERO SECTION
   =========================================== */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2E2A24;
    overflow: hidden;
}

.hero-noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.08;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 512px 512px;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    transition: opacity 0.1s linear;
}

.hero-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(4rem, 15vw, 14rem);
    color: #E8DFD0;
    letter-spacing: 0.04em;
    line-height: 0.9;
    margin-bottom: 0.15em;
}

.hero-subtitle {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: clamp(1rem, 2.5vw, 2rem);
    color: #C4854A;
    letter-spacing: 0.15em;
    display: block;
}

/* ===========================================
   GROUND LAYERS
   =========================================== */
.ground-layer {
    width: 100%;
    height: 80px;
    position: relative;
    background-color: #5A4A3A;
    opacity: 0.06;
    overflow: hidden;
}

.ground-layer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.18;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

.ground-layer--final {
    height: 120px;
}

/* ===========================================
   QUEST STAGES
   =========================================== */
.quest-stage {
    position: relative;
    min-height: 100vh;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 80px 24px;
    display: flex;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.quest-stage.visible {
    opacity: 1;
    transform: translateY(0);
}

.stage-inner {
    flex: 1;
    max-width: 750px;
}

/* F-Pattern: Headlines full width, context narrower, tension narrowest */
.quest-headline {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    color: #5A7A4A;
    line-height: 1.1;
    margin-bottom: 0.6em;
    width: 100%;
}

.quest-context {
    width: 80%;
    margin-bottom: 2em;
}

.quest-context p {
    margin-bottom: 1.2em;
    color: #E8DFD0;
}

.quest-tension {
    width: 60%;
    padding-left: 2em;
    border-left: 3px solid #6A5A7A;
}

.tension-text {
    color: #D4CCC0;
    font-style: italic;
}

.tension-text em {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    color: #6A5A7A;
}

/* ===========================================
   SPECIMEN CARDS
   =========================================== */
.specimen-card {
    width: 180px;
    min-height: 240px;
    background-color: #D4CCC0;
    position: absolute;
    top: 100px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    transform: scale(0.95);
    opacity: 0.7;
    transition: transform 0.3s ease, opacity 0.3s ease, box-shadow 0.3s ease;
    /* Double-rule border: botanical specimen framing */
    border: 1px solid #5A4A3A;
    outline: 0.5px solid #5A4A3A;
    outline-offset: 4px;
    /* Aged paper vignette */
    background-image: radial-gradient(ellipse at center, transparent 50%, rgba(90,74,58,0.15) 100%);
    background-color: #D4CCC0;
}

.specimen-card.visible {
    transform: scale(1);
    opacity: 1;
}

.specimen-card:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.specimen-card--right {
    right: 24px;
}

.specimen-card--left {
    right: 24px;
    top: 140px;
}

.specimen-illustration {
    width: 120px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.specimen-label {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 0.75rem;
    color: #5A4A3A;
    text-align: center;
    letter-spacing: 0.05em;
    font-style: italic;
    margin-top: 4px;
}

.specimen-concept {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #2E2A24;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    text-align: center;
    margin-top: 2px;
    font-weight: bold;
}

/* ===========================================
   FINAL SECTION
   =========================================== */
.quest-final {
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
}

.final-content {
    text-align: center;
}

.final-text {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 1rem;
    color: #6A5A7A;
    letter-spacing: 0.1em;
    margin-bottom: 2em;
}

.final-mark {
    display: block;
    font-size: 2rem;
    color: #5A7A4A;
    opacity: 0.5;
}

/* ===========================================
   LINKS
   =========================================== */
a {
    color: #6A5A7A;
    text-decoration: none;
    border-bottom: 1px solid rgba(106, 90, 122, 0.3);
    transition: border-color 0.2s ease, color 0.2s ease;
}

a:hover {
    color: #C4854A;
    border-bottom-color: #C4854A;
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 768px) {
    .quest-stage {
        flex-direction: column;
        padding: 60px 20px;
    }

    .quest-context {
        width: 100%;
    }

    .quest-tension {
        width: 90%;
    }

    .specimen-card {
        position: relative;
        top: auto;
        right: auto;
        margin: 2em auto 0;
    }

    .specimen-card--right,
    .specimen-card--left {
        right: auto;
        top: auto;
    }
}

@media (min-width: 769px) {
    .quest-stage {
        padding-right: 220px;
    }

    .quest-stage[data-stage="1"] .specimen-card { top: 80px; }
    .quest-stage[data-stage="2"] .specimen-card { top: 120px; }
    .quest-stage[data-stage="3"] .specimen-card { top: 60px; }
    .quest-stage[data-stage="4"] .specimen-card { top: 150px; }
    .quest-stage[data-stage="5"] .specimen-card { top: 90px; }
}

/* ===========================================
   GRAIN ANIMATION
   =========================================== */
@keyframes grain-shift {
    0% { background-position: 0 0; }
    25% { background-position: 64px 32px; }
    50% { background-position: -32px 64px; }
    75% { background-position: 32px -32px; }
    100% { background-position: 0 0; }
}

body::before {
    animation: grain-shift 3s steps(4) infinite;
}
