/* ============================================
   martiallaw.quest - Styles
   Palette: Aurora Gradient on Aged Parchment
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --aged-parchment: #F5F0E8;
    --smoked-cream: #EDE6D8;
    --midnight-teal: #0D3B44;
    --spectral-viridian: #2E8B6E;
    --boreal-mauve: #7B5EA7;
    --glacial-breath: #4AAFB2;
    --seal-vermillion: #C84B31;
    --faded-iron: #7A7568;

    /* Typography sizes */
    --hero-size: clamp(3rem, 8vw, 7rem);
    --heading-size: clamp(1.8rem, 4vw, 3.5rem);
    --body-size: clamp(1.05rem, 1.8vw, 1.25rem);
    --annotation-size: clamp(0.85rem, 1.4vw, 1.1rem);

    /* Spacing */
    --section-gap: min(20vh, 200px);
    --content-max: 640px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Neuton', serif;
    font-weight: 200;
    font-size: var(--body-size);
    line-height: 1.85;
    color: var(--midnight-teal);
    background-color: var(--aged-parchment);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Paper texture overlay via pseudo-element with CSS noise */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* SVG filter definitions - hidden */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Poiret One', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

p {
    max-width: 58ch;
}

a {
    color: var(--spectral-viridian);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--glacial-breath);
}

/* --- Layout Grid --- */
.section-content {
    display: grid;
    grid-template-columns: 1fr minmax(300px, var(--content-max)) 1fr;
    padding: 0 1rem;
}

.section-content > * {
    grid-column: 2;
}

/* --- Reveal Animation (applied by JS) --- */
.reveal-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease, transform 600ms ease;
}

.reveal-section.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   SECTION 1: Opening Void / Hero
   ============================================ */
#opening-void {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
}

.void-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.horizon-line {
    width: min(80vw, 600px);
    height: auto;
    opacity: 0;
}

.horizon-line.animate {
    opacity: 1;
}

.horizon-line line {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1500ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.horizon-line.animate line {
    stroke-dashoffset: 0;
}

.hero-title {
    font-size: var(--hero-size);
    color: var(--midnight-teal);
    letter-spacing: 0.15em;
    text-align: center;
    opacity: 0;
    transition: opacity 1200ms ease;
}

.hero-title.visible {
    opacity: 1;
}

.whisper-line {
    padding-top: 15vh;
    display: flex;
    justify-content: center;
}

.whisper-text {
    font-family: 'Neuton', serif;
    font-weight: 200;
    font-size: var(--body-size);
    color: var(--faded-iron);
    text-align: center;
    max-width: 58ch;
    opacity: 0;
    transition: opacity 1000ms ease;
}

.whisper-text.visible {
    opacity: 1;
}

/* ============================================
   SECTION 2: Definition Panel
   ============================================ */
#definition-panel {
    margin-top: var(--section-gap);
    margin-bottom: var(--section-gap);
}

.definition-frame {
    position: relative;
    padding: 3rem 2.5rem;
    max-width: var(--content-max);
    margin: 0 auto;
}

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

.frame-border rect {
    stroke-dasharray: 2220;
    stroke-dashoffset: 2220;
    transition: stroke-dashoffset 2500ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.definition-frame.animate .frame-border rect {
    stroke-dashoffset: 0;
}

.definition-content {
    opacity: 0;
    transition: opacity 500ms ease 2600ms;
}

.definition-frame.animate .definition-content {
    opacity: 1;
}

.section-heading {
    font-size: var(--heading-size);
    margin-bottom: 1.5rem;
    color: var(--midnight-teal);
}

#definition-panel .section-heading {
    position: relative;
    display: inline-block;
}

#definition-panel .section-heading::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 60%;
    height: 2px;
    background: var(--boreal-mauve);
    opacity: 0.5;
}

.definition-content p {
    margin-bottom: 2.5em;
    color: var(--midnight-teal);
}

.annotation-note {
    font-family: 'Caveat', cursive;
    font-size: var(--annotation-size);
    color: var(--faded-iron);
    font-style: normal;
    line-height: 1.6;
}

/* ============================================
   Section Dividers - Barbed Wire
   ============================================ */
.section-divider {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    margin: 2rem 0;
}

.barbed-wire {
    width: min(80vw, 500px);
    height: auto;
}

/* ============================================
   SECTION 3: Timeline
   ============================================ */
#timeline-section {
    margin-top: var(--section-gap);
    margin-bottom: var(--section-gap);
}

#timeline-section .section-heading {
    text-align: center;
    margin-bottom: 1rem;
}

.section-intro {
    text-align: center;
    color: var(--faded-iron);
    font-family: 'Caveat', cursive;
    font-size: var(--annotation-size);
    margin-bottom: 4rem;
    max-width: 58ch;
    margin-left: auto;
    margin-right: auto;
}

.timeline-grid {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 4px 1fr;
    gap: 0;
}

.timeline-spine-wrapper {
    grid-column: 2;
    grid-row: 1 / -1;
    display: flex;
    justify-content: center;
}

.timeline-spine {
    width: 4px;
    height: 100%;
}

.timeline-spine line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: stroke-dashoffset 3000ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.timeline-spine.animate line {
    stroke-dashoffset: 0;
}

/* Timeline Entries */
.timeline-entry {
    display: flex;
    align-items: center;
    padding: 2rem 0;
}

.entry-left {
    grid-column: 1;
    justify-content: flex-end;
    flex-direction: row;
}

.entry-right {
    grid-column: 3;
    justify-content: flex-start;
    flex-direction: row;
}

.timeline-connector {
    width: 60px;
    flex-shrink: 0;
}

.timeline-connector svg {
    width: 100%;
    height: 4px;
}

/* --- Card Flip --- */
.timeline-card {
    width: 280px;
    height: 360px;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.timeline-card .card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transition: transform 0.7s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.card-front {
    background-color: var(--aged-parchment);
    border: 1.5px solid var(--midnight-teal);
    transform: rotateY(0deg);
}

.card-back {
    background-color: var(--smoked-cream);
    border: 1.5px solid var(--midnight-teal);
    transform: rotateY(180deg);
    text-align: left;
    align-items: flex-start;
    justify-content: flex-start;
    overflow-y: auto;
}

.timeline-card.flipped .card-front {
    transform: rotateY(180deg);
}

.timeline-card.flipped .card-back {
    transform: rotateY(0deg);
}

/* Aurora edge glow during flip */
.timeline-card.flipping {
    box-shadow:
        0 0 30px rgba(46, 139, 110, 0.4),
        0 0 60px rgba(74, 175, 178, 0.2),
        0 0 90px rgba(123, 94, 167, 0.1);
    border-radius: 8px;
}

/* Gentle pulse for un-flipped cards */
.timeline-card:not(.flipped) {
    animation: gentle-pulse 4s ease-in-out infinite;
}

.timeline-card.flipped {
    animation: none;
}

@keyframes gentle-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Card content */
.card-illustration {
    width: 100%;
    height: auto;
    max-height: 280px;
}

.card-date {
    font-family: 'Caveat', cursive;
    font-size: var(--annotation-size);
    color: var(--faded-iron);
    display: block;
    margin-bottom: 0.8rem;
}

.card-title {
    font-family: 'Poiret One', sans-serif;
    font-size: 1.3rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--midnight-teal);
    margin-bottom: 1rem;
}

.card-text {
    font-family: 'Neuton', serif;
    font-weight: 400;
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--midnight-teal);
}

/* ============================================
   SECTION 4: Voices
   ============================================ */
#voices-section {
    margin-top: var(--section-gap);
    margin-bottom: var(--section-gap);
}

#voices-section .section-heading {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
}

#voices-section .section-heading::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 2px;
    background: var(--boreal-mauve);
    opacity: 0.4;
}

.voices-container {
    display: flex;
    flex-direction: column;
    gap: 6rem;
    max-width: var(--content-max);
    margin: 0 auto;
}

.voice-block {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.voice-quote-wrapper {
    display: flex;
    gap: 1.2rem;
    align-items: stretch;
}

.voice-line {
    width: 3px;
    flex-shrink: 0;
    height: auto;
    align-self: stretch;
}

.voice-quote {
    font-family: 'Neuton', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--midnight-teal);
    max-width: 58ch;
}

.voice-attribution {
    font-family: 'Caveat', cursive;
    font-size: var(--annotation-size);
    color: var(--faded-iron);
    font-style: normal;
    padding-left: 1.5rem;
}

/* ============================================
   Paper Cranes Scatter
   ============================================ */
.crane-scatter {
    position: relative;
    height: 30vh;
    min-height: 200px;
    margin: 4rem 0;
}

.scatter-crane {
    position: absolute;
    width: 50px;
    height: auto;
    opacity: 0.25;
}

.crane-1 {
    top: 20%;
    left: 15%;
    transform: rotate(-15deg);
}

.crane-2 {
    top: 50%;
    right: 20%;
    transform: rotate(25deg) scale(0.8);
}

.crane-3 {
    bottom: 15%;
    left: 45%;
    transform: rotate(-5deg) scale(1.1);
}

/* ============================================
   SECTION 5: Closing Void
   ============================================ */
#closing-void {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    padding: 4rem 2rem;
}

.closing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.closing-question-mark {
    width: 80px;
    height: auto;
}

.closing-question-mark path,
.closing-question-mark circle {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2500ms cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

#closing-void.revealed .closing-question-mark path,
#closing-void.revealed .closing-question-mark circle {
    stroke-dashoffset: 0;
}

.closing-whisper {
    font-family: 'Neuton', serif;
    font-weight: 200;
    font-size: var(--body-size);
    color: var(--faded-iron);
    text-align: center;
    max-width: 58ch;
    opacity: 0;
    transition: opacity 1200ms ease 2000ms;
}

#closing-void.revealed .closing-whisper {
    opacity: 1;
}

/* ============================================
   Compass Rose Navigation
   ============================================ */
.compass-nav {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
}

.compass-trigger {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.compass-nav:hover .compass-trigger,
.compass-nav.active .compass-trigger {
    opacity: 1;
}

.compass-rose {
    width: 40px;
    height: 40px;
    transition: transform 0.3s ease;
}

.compass-nav.active .compass-rose {
    transform: rotate(45deg);
}

.compass-nav.active .compass-rose circle:last-child {
    fill: var(--boreal-mauve);
}

.compass-menu {
    position: absolute;
    top: 50px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--aged-parchment);
    border: 1px solid var(--midnight-teal);
    border-radius: 4px;
    padding: 1rem 1.5rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(13, 59, 68, 0.1);
}

.compass-nav.active .compass-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.compass-link {
    font-family: 'Caveat', cursive;
    font-size: 1.1rem;
    color: var(--midnight-teal);
    white-space: nowrap;
    padding: 0.2rem 0;
    transition: color 0.2s ease;
}

.compass-link:hover {
    color: var(--boreal-mauve);
}

/* ============================================
   Aurora Shimmer Keyframes
   ============================================ */
@keyframes aurora-shimmer {
    0% {
        box-shadow:
            0 0 30px rgba(46, 139, 110, 0.4),
            0 0 60px rgba(74, 175, 178, 0.2),
            0 0 90px rgba(123, 94, 167, 0.1);
    }
    33% {
        box-shadow:
            0 0 30px rgba(74, 175, 178, 0.4),
            0 0 60px rgba(123, 94, 167, 0.2),
            0 0 90px rgba(46, 139, 110, 0.1);
    }
    66% {
        box-shadow:
            0 0 30px rgba(123, 94, 167, 0.4),
            0 0 60px rgba(46, 139, 110, 0.2),
            0 0 90px rgba(74, 175, 178, 0.1);
    }
    100% {
        box-shadow:
            0 0 30px rgba(46, 139, 110, 0.4),
            0 0 60px rgba(74, 175, 178, 0.2),
            0 0 90px rgba(123, 94, 167, 0.1);
    }
}

/* ============================================
   Responsive: Mobile < 768px
   ============================================ */
@media (max-width: 768px) {
    :root {
        --section-gap: min(10vh, 100px);
    }

    .section-content {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    .section-content > * {
        grid-column: 1;
    }

    /* Timeline: single column */
    .timeline-grid {
        grid-template-columns: 4px 1fr;
        max-width: 100%;
        padding: 0 1rem;
    }

    .timeline-spine-wrapper {
        grid-column: 1;
        grid-row: 1 / -1;
    }

    .timeline-entry {
        grid-column: 2;
        padding: 1.5rem 0 1.5rem 1rem;
        flex-direction: row;
        justify-content: flex-start;
    }

    .entry-left {
        grid-column: 2;
    }

    .entry-right {
        grid-column: 2;
    }

    .timeline-connector {
        display: none;
    }

    .timeline-card {
        width: calc(100vw - 64px);
        max-width: 360px;
        height: 380px;
    }

    /* Definition */
    .definition-frame {
        padding: 2rem 1.5rem;
    }

    /* Voices */
    .voices-container {
        gap: 4rem;
        padding: 0 1rem;
    }

    /* Cranes */
    .crane-scatter {
        height: 15vh;
        min-height: 100px;
    }

    .scatter-crane {
        width: 35px;
    }

    /* Compass becomes bottom hamburger */
    .compass-nav {
        top: auto;
        bottom: 1rem;
        right: 1rem;
    }

    .compass-trigger {
        opacity: 0.6;
        background: var(--aged-parchment);
        border-radius: 50%;
        padding: 8px;
        border: 1px solid var(--midnight-teal);
    }

    .compass-menu {
        top: auto;
        bottom: 50px;
        right: 0;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .reveal-section {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .timeline-card .card-face {
        transition-duration: 0.01ms;
    }

    .timeline-card:not(.flipped) {
        animation: none;
    }

    .horizon-line line,
    .frame-border rect,
    .timeline-spine line,
    .closing-question-mark path,
    .closing-question-mark circle {
        stroke-dashoffset: 0;
        transition: none;
    }

    .hero-title,
    .whisper-text,
    .definition-content,
    .closing-whisper {
        opacity: 1;
        transition: none;
    }
}
