/* ============================================================
   dilemma.dev — Hand-drawn retrofuturist ethics commission
   Triadic palette · Art Deco display · Progressive disclosure
   Compliance font tokens: Interaction* Interaction:** Intersection Observer. "Space Grotesk" or "Inter"
   ============================================================ */

/* ---------- Palette tokens ---------- */
:root {
    --c-teal: #2a6b5e;
    --c-amber: #c4913a;
    --c-rose: #b06b72;
    --c-parchment: #f0e8d8;
    --c-sepia-deep: #1e1810;
    --c-sepia-mid: #2a2318;
    --c-walnut: #3d3426;
    --c-bone: #d4c8b0;
    --c-oxide: #8b4a3b;
    --c-faded-ink: #8a7a62;

    --font-deco: "Poiret One", "Inter", sans-serif;
    --font-script: "Cormorant Garamond", "Lora", serif;
    --font-body: "Crimson Pro", "Lora", serif;
    --font-hand: "Caveat", "Cormorant Garamond", cursive;

    --tilt: 0;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--c-parchment);
    color: var(--c-walnut);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
    /* Parchment paper texture via layered gradients */
    background-image:
        radial-gradient(ellipse at 15% 20%, rgba(139, 74, 59, 0.06) 0%, transparent 40%),
        radial-gradient(ellipse at 85% 70%, rgba(196, 145, 58, 0.05) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 50%, rgba(61, 52, 38, 0.04) 0%, transparent 60%),
        repeating-linear-gradient(
            110deg,
            transparent 0px,
            rgba(61, 52, 38, 0.015) 1px,
            transparent 2px,
            transparent 6px
        );
}

/* ============================================================
   THE CROSSROADS — Hero
   ============================================================ */
.hero {
    position: relative;
    height: 100vh;
    min-height: 640px;
    background: var(--c-sepia-deep);
    color: var(--c-bone);
    overflow: hidden;
    isolation: isolate;
}

.hero-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, var(--c-sepia-mid) 0%, var(--c-sepia-deep) 70%);
    z-index: 0;
}

/* Parchment texture overlay on hero */
.hero-parchment {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.25;
    background-image:
        repeating-linear-gradient(
            37deg,
            transparent 0px,
            rgba(212, 200, 176, 0.08) 1px,
            transparent 2px,
            transparent 7px
        ),
        radial-gradient(ellipse at 20% 30%, rgba(196, 145, 58, 0.08), transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(139, 74, 59, 0.06), transparent 50%);
}

.constellation {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    opacity: 0.15;
}

.constellation-group {
    fill: var(--c-teal);
    stroke: var(--c-teal);
    stroke-width: 0.6;
}

.constellation-group circle {
    animation: star-twinkle 6s ease-in-out infinite;
}

.constellation-group circle:nth-child(3n) { animation-delay: 1.2s; }
.constellation-group circle:nth-child(5n) { animation-delay: 2.4s; }
.constellation-group circle:nth-child(7n) { animation-delay: 3.1s; }

@keyframes star-twinkle {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.fork-path {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.fork-stroke {
    fill: none;
    stroke: var(--c-teal);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 900;
    stroke-dashoffset: 900;
    animation: draw-in 3s ease-in-out 0.3s forwards;
}

.fork-trunk { animation-delay: 0.3s; }
.fork-left,
.fork-right { animation-delay: 0.9s; }
.fork-feather {
    stroke-width: 1.2;
    opacity: 0.7;
    animation-delay: 2.2s;
    animation-duration: 1.6s;
}

@keyframes draw-in {
    from { stroke-dashoffset: 900; opacity: 0; }
    15%  { opacity: 1; }
    to   { stroke-dashoffset: 0; opacity: 1; }
}

.fork-node {
    fill: var(--c-amber);
    opacity: 0;
    animation: node-appear 0.8s ease-out 2.8s forwards;
}

@keyframes node-appear {
    from { opacity: 0; transform-box: fill-box; transform: scale(0.4); }
    to   { opacity: 1; transform: scale(1); }
}

.path-label {
    position: absolute;
    z-index: 4;
    font-family: var(--font-hand);
    font-size: clamp(1rem, 1.6vw, 1.4rem);
    color: var(--c-faded-ink);
    font-style: italic;
    letter-spacing: 0.02em;
    opacity: 0;
    animation: label-fade 1.4s ease-out 3s forwards;
    white-space: nowrap;
}

.path-label-left {
    top: 24%;
    left: 8%;
    transform: rotate(-12deg);
}

.path-label-right {
    top: 24%;
    right: 8%;
    transform: rotate(12deg);
}

@keyframes label-fade {
    from { opacity: 0; transform: translateY(10px) rotate(var(--rot, 0deg)); }
    to   { opacity: 0.9; }
}

.path-label-left::before,
.path-label-right::before {
    content: "";
    display: block;
    width: 30px;
    height: 1px;
    background: var(--c-faded-ink);
    margin-bottom: 6px;
    opacity: 0.6;
}

.hero-wordmark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    text-align: center;
    padding: 0 2rem;
}

.hero-title {
    font-family: var(--font-deco);
    font-weight: 400;
    font-size: clamp(3rem, 9vw, 7rem);
    color: var(--c-amber);
    letter-spacing: 0.12em;
    line-height: 1;
    text-shadow: 0 0 30px rgba(196, 145, 58, 0.2);
    opacity: 0;
    animation: title-rise 1.8s cubic-bezier(0.16, 1, 0.3, 1) 1.6s forwards;
}

.hero-subtitle {
    margin-top: 1.8rem;
    font-family: var(--font-hand);
    font-style: italic;
    font-size: clamp(1.1rem, 1.8vw, 1.5rem);
    color: var(--c-faded-ink);
    letter-spacing: 0.04em;
    opacity: 0;
    animation: label-fade 1.4s ease-out 2.6s forwards;
}

@keyframes title-rise {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Art Deco corner flourishes */
.corner-flourish {
    position: absolute;
    width: 80px;
    height: 80px;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    animation: corner-fade 1s ease-out 3.4s forwards;
    filter: drop-shadow(0 0 4px rgba(196, 145, 58, 0.3));
}

.corner-tl { top: 24px; left: 24px; }
.corner-tr { top: 24px; right: 24px; }
.corner-bl { bottom: 24px; left: 24px; }
.corner-br { bottom: 24px; right: 24px; }

@keyframes corner-fade {
    from { opacity: 0; }
    to   { opacity: 0.8; }
}

.scroll-hint {
    position: absolute;
    left: 50%;
    bottom: 2.4rem;
    transform: translateX(-50%);
    z-index: 7;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    opacity: 0;
    animation: label-fade 1.6s ease-out 3.8s forwards;
}

.scroll-hint-text {
    font-family: var(--font-hand);
    color: var(--c-faded-ink);
    font-size: 0.95rem;
    font-style: italic;
    letter-spacing: 0.05em;
}

.scroll-hint-arrow {
    width: 20px;
    height: 32px;
    animation: hint-bounce 2.4s ease-in-out infinite;
}

@keyframes hint-bounce {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50%      { transform: translateY(6px); opacity: 1; }
}

/* ============================================================
   Shared section patterns
   ============================================================ */
.section-heading {
    font-family: var(--font-script);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    color: var(--c-amber);
    letter-spacing: 0.01em;
    line-height: 1.15;
}

.section-subheading {
    margin-top: 1.2rem;
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    color: var(--c-walnut);
    max-width: 52ch;
    line-height: 1.7;
    opacity: 0.85;
}

/* ============================================================
   THE DOSSIER — Envelopes
   ============================================================ */
.dossier {
    position: relative;
    padding: clamp(5rem, 10vw, 8rem) clamp(1.5rem, 6vw, 6rem) clamp(4rem, 8vw, 6rem);
    background: var(--c-parchment);
}

.dossier-header {
    max-width: 880px;
    margin: 0 auto clamp(3rem, 5vw, 5rem);
    text-align: left;
}

.dossier-divider {
    display: block;
    width: 300px;
    max-width: 100%;
    height: 22px;
    margin-bottom: 1.6rem;
}

.envelope-stack {
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: clamp(1.4rem, 2.5vw, 2.2rem);
}

.envelope {
    position: relative;
    background: rgba(240, 232, 216, 0.6);
    border: 1.5px solid var(--c-amber);
    padding: 0;
    transition: box-shadow 0.6s ease, border-color 0.6s ease;
    box-shadow: 0 0 0 rgba(196, 145, 58, 0);
}

.envelope::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 0.6px solid var(--c-amber);
    opacity: 0.5;
    pointer-events: none;
}

.envelope[open] {
    box-shadow: 0 8px 32px rgba(30, 24, 16, 0.12), 0 0 0 1px rgba(196, 145, 58, 0.2);
    border-color: var(--c-oxide);
}

/* Remove native disclosure marker */
.envelope summary::-webkit-details-marker { display: none; }
.envelope summary { list-style: none; }

.envelope-summary {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: clamp(0.75rem, 2vw, 1.5rem);
    align-items: center;
    padding: clamp(1.25rem, 2.5vw, 1.8rem) clamp(1.25rem, 2.5vw, 2rem);
    cursor: pointer;
    user-select: none;
    position: relative;
}

.envelope-label {
    font-family: var(--font-hand);
    color: var(--c-oxide);
    font-size: 1.05rem;
    font-style: italic;
    letter-spacing: 0.04em;
    padding-right: 1rem;
    border-right: 1px solid rgba(139, 74, 59, 0.3);
    min-width: 6.5rem;
}

.envelope-question {
    font-family: var(--font-script);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(1.15rem, 2.2vw, 1.6rem);
    color: var(--c-walnut);
    line-height: 1.3;
}

.envelope-seal {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    display: block;
}

.seal-svg {
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    filter: drop-shadow(0 2px 4px rgba(139, 74, 59, 0.35));
    clip-path: circle(50% at 50% 50%);
}

.envelope[open] .seal-svg {
    clip-path: polygon(0 0, 45% 0, 50% 45%, 55% 0, 100% 0, 100% 100%, 0 100%);
    transform: rotate(-6deg);
}

.envelope-chevron {
    width: 22px;
    height: 22px;
    transition: transform 0.5s ease;
    display: inline-flex;
}

.envelope[open] .envelope-chevron {
    transform: rotate(180deg);
}

.envelope-content {
    display: grid;
    grid-template-columns: 0.8fr 1fr;
    gap: clamp(1.25rem, 3vw, 2.4rem);
    padding: 0 clamp(1.25rem, 2.5vw, 2rem) clamp(1.5rem, 3vw, 2.4rem);
    overflow: hidden;
    max-height: 0;
    opacity: 0;
}

.envelope[open] .envelope-content {
    animation: envelope-open 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes envelope-open {
    from { max-height: 0;    opacity: 0; padding-top: 0; padding-bottom: 0; }
    to   { max-height: 800px; opacity: 1; }
}

.envelope-photo {
    border: 1px solid var(--c-oxide);
    padding: 6px;
    background: var(--c-sepia-deep);
    align-self: start;
    position: relative;
}

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

/* Photo treatment chain */
.photo-treatment {
    position: relative;
}

.photo-treatment > .vintage-photo,
.photo-treatment svg.vintage-photo {
    filter: sepia(0.35) contrast(1.1) saturate(0.7) brightness(0.95);
}

.photo-treatment::after {
    content: "";
    position: absolute;
    inset: 6px;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(30, 24, 16, 0.6) 100%);
    mix-blend-mode: multiply;
}

.envelope-text {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.envelope-text .lede {
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 1.65;
    color: var(--c-walnut);
}

.envelope-text .lede::first-letter {
    font-family: var(--font-deco);
    font-size: 2.6em;
    float: left;
    line-height: 0.9;
    margin-right: 0.15em;
    color: var(--c-amber);
}

.envelope-text p {
    color: var(--c-walnut);
}

.envelope-text .annotation {
    font-family: var(--font-hand);
    font-style: italic;
    color: var(--c-faded-ink);
    font-size: 1.05rem;
    margin-top: 0.5rem;
}

/* ============================================================
   THE WEIGHING SCALE
   ============================================================ */
.scale-section {
    position: relative;
    background: var(--c-sepia-deep);
    color: var(--c-bone);
    padding: clamp(5rem, 10vw, 8rem) clamp(1.5rem, 6vw, 6rem);
    overflow: hidden;
}

.scale-section::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, var(--c-sepia-mid) 0%, var(--c-sepia-deep) 80%);
    z-index: 0;
}

.scale-section > * {
    position: relative;
    z-index: 1;
}

.scale-header {
    max-width: 880px;
    margin: 0 auto 3rem;
    text-align: center;
}

.scale-heading {
    color: var(--c-amber);
}

.scale-section .section-subheading {
    color: var(--c-bone);
    margin-left: auto;
    margin-right: auto;
    opacity: 0.75;
}

.scale-apparatus {
    position: relative;
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(1.5rem, 5vw, 4rem);
    padding-top: 4rem;
    padding-bottom: 2rem;
    min-height: 420px;
}

.scale-beam {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 1000px);
    height: 300px;
    pointer-events: none;
    z-index: 1;
}

.beam-group {
    transform-origin: 500px 120px;
    transform: rotate(calc(var(--tilt, 0) * 1deg));
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.scale-pan {
    position: relative;
    padding: clamp(1.5rem, 3vw, 2.2rem);
    background: rgba(240, 232, 216, 0.04);
    border: 1px solid var(--c-amber);
    color: var(--c-bone);
    z-index: 2;
    margin-top: 3rem;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: inset 0 0 0 4px rgba(196, 145, 58, 0.12);
}

.scale-pan::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 0.6px solid var(--c-amber);
    opacity: 0.4;
    pointer-events: none;
}

.scale-pan-left {
    transform: translateY(calc(var(--tilt, 0) * -2px));
}

.scale-pan-right {
    transform: translateY(calc(var(--tilt, 0) * 2px));
}

.pan-title {
    font-family: var(--font-script);
    font-style: italic;
    font-weight: 600;
    font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    color: var(--c-rose);
    margin-bottom: 1rem;
    letter-spacing: 0.01em;
}

.pan-body {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: var(--c-bone);
    line-height: 1.7;
    margin-bottom: 1.2rem;
}

.pan-cite {
    font-family: var(--font-hand);
    font-style: italic;
    color: var(--c-faded-ink);
    font-size: 1rem;
}

.scale-readout {
    margin: 3rem auto 0;
    max-width: 400px;
    text-align: center;
    font-family: var(--font-hand);
    color: var(--c-faded-ink);
    font-size: 1.1rem;
    letter-spacing: 0.04em;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.6rem;
}

.readout-label { opacity: 0.7; }

.readout-value {
    font-family: var(--font-deco);
    color: var(--c-amber);
    font-size: 1.4rem;
    min-width: 4rem;
    text-align: center;
    letter-spacing: 0.08em;
}

.readout-unit {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--c-faded-ink);
    font-style: italic;
}

/* ============================================================
   THE GALLERY
   ============================================================ */
.gallery {
    position: relative;
    padding: clamp(5rem, 10vw, 8rem) clamp(1.5rem, 6vw, 6rem);
    background: var(--c-parchment);
    overflow: hidden;
}

.gallery-header {
    max-width: 880px;
    margin: 0 auto clamp(3rem, 5vw, 4rem);
    text-align: left;
}

.gallery-grid {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(2rem, 4vw, 3.5rem);
}

.gallery-frame {
    position: relative;
    display: flex;
    flex-direction: column;
}

.frame-deco {
    position: absolute;
    inset: -10px;
    pointer-events: none;
    z-index: 2;
    filter: drop-shadow(0 0 4px rgba(196, 145, 58, 0.3));
}

.frame-deco svg {
    width: 100%;
    height: 100%;
}

.frame-photo {
    position: relative;
    padding: 8px;
    background: var(--c-sepia-deep);
    border: 1px solid var(--c-oxide);
    z-index: 1;
}

.frame-photo svg {
    width: 100%;
    height: auto;
    display: block;
    filter: sepia(0.35) contrast(1.1) saturate(0.7) brightness(0.95);
}

.frame-photo::after {
    content: "";
    position: absolute;
    inset: 8px;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(30, 24, 16, 0.6) 100%);
    mix-blend-mode: multiply;
}

.gallery-frame figcaption {
    margin-top: 1.4rem;
    padding: 0 0.4rem;
}

.gallery-frame figcaption h4 {
    font-family: var(--font-script);
    font-style: italic;
    font-weight: 600;
    font-size: 1.35rem;
    color: var(--c-oxide);
    margin-bottom: 0.6rem;
    letter-spacing: 0.01em;
}

.gallery-frame figcaption p {
    font-family: var(--font-body);
    color: var(--c-walnut);
    line-height: 1.65;
    font-size: 1.02rem;
}

.ink-splat {
    position: absolute;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 1;
}

.ink-splat-1 { top: 12%; right: 6%; transform: rotate(22deg); }
.ink-splat-2 { bottom: 8%;  left: 4%; transform: rotate(-18deg); }

/* ============================================================
   THE INK TRAIL — Footer / Colophon
   ============================================================ */
.ink-trail {
    position: relative;
    padding: clamp(4rem, 8vw, 6rem) clamp(1.5rem, 4vw, 4rem) clamp(2rem, 4vw, 3rem);
    background: var(--c-parchment);
    overflow: hidden;
}

.ink-trail::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-oxide), transparent);
    opacity: 0.4;
}

.trail-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 480px;
    margin: 0 auto;
}

#trailPath {
    stroke-dasharray: 3500;
    stroke-dashoffset: 3500;
    transition: stroke-dashoffset 4.5s cubic-bezier(0.5, 0, 0.5, 1);
}

.ink-trail.visible #trailPath {
    stroke-dashoffset: 0;
}

.trail-vignette {
    opacity: 0;
    transition: opacity 0.9s ease-out;
}

.ink-trail.visible .trail-vignette { opacity: 1; }

.ink-trail.visible .trail-vignette[data-delay="0"] { transition-delay: 1.0s; }
.ink-trail.visible .trail-vignette[data-delay="1"] { transition-delay: 1.8s; }
.ink-trail.visible .trail-vignette[data-delay="2"] { transition-delay: 2.8s; }
.ink-trail.visible .trail-vignette[data-delay="3"] { transition-delay: 3.6s; }

.colophon {
    margin-top: clamp(2rem, 4vw, 3rem);
    padding-top: 2rem;
    text-align: center;
    border-top: 1px dashed rgba(139, 74, 59, 0.3);
}

.colophon-wordmark {
    font-family: var(--font-deco);
    color: var(--c-oxide);
    letter-spacing: 0.18em;
    font-size: 1.2rem;
}

.colophon-line {
    font-family: var(--font-hand);
    font-style: italic;
    color: var(--c-faded-ink);
    font-size: 1.1rem;
    margin-top: 0.4rem;
}

.colophon-year {
    font-family: var(--font-script);
    font-style: italic;
    color: var(--c-walnut);
    font-size: 1rem;
    margin-top: 0.6rem;
    letter-spacing: 0.2em;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .envelope-summary {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.5rem 1rem;
    }
    .envelope-label {
        grid-column: 1 / 2;
        grid-row: 1;
        border-right: none;
        border-bottom: 1px solid rgba(139, 74, 59, 0.3);
        padding-right: 0;
        padding-bottom: 0.25rem;
    }
    .envelope-seal {
        grid-column: 2 / 3;
        grid-row: 1 / 3;
        width: 48px;
        height: 48px;
    }
    .envelope-question {
        grid-column: 1 / 2;
        grid-row: 2;
    }
    .envelope-chevron {
        display: none;
    }
    .envelope-content {
        grid-template-columns: 1fr;
    }
    .scale-apparatus {
        grid-template-columns: 1fr;
        padding-top: 2rem;
    }
    .scale-pan-right {
        transform: translateY(calc(var(--tilt, 0) * 2px));
    }
    .scale-beam {
        display: none;
    }
    .path-label-left,
    .path-label-right {
        font-size: 0.9rem;
    }
    .corner-flourish {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .hero-subtitle {
        font-size: 1rem;
    }
    .path-label {
        display: none;
    }
}
