/* ========================================
   witch-trial.com - Styles
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
    --abyss-black: #0a0808;
    --parchment-bone: #e8dcc4;
    --witch-flame: #b8621b;
    --dried-blood: #6b2020;
    --tallow-smoke: #8a7e6d;
    --iron-gall: #2a1f15;
    --verdigris-stain: #3d6b5e;
    --paper-spot-1: #d4c4a0;
    --paper-spot-2: #b8a882;
    --paper-spot-3: #c9b896;

    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --font-handwriting: 'Caveat', cursive;
    --font-body: 'Source Serif 4', 'Georgia', serif;

    --verdict-scale: 1;
}

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

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

body {
    background-color: var(--abyss-black);
    color: var(--parchment-bone);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Accusation Margin Strip --- */
.margin-strip {
    position: fixed;
    top: 0;
    left: 0;
    width: 120px;
    height: 100vh;
    background-color: rgba(10, 8, 8, 0.92);
    border-right: 1px solid var(--iron-gall);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.accusation-text {
    font-family: var(--font-handwriting);
    font-size: clamp(0.9rem, 2vw, 1.4rem);
    color: var(--tallow-smoke);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    text-align: center;
    padding: 1rem 0;
    opacity: 0;
    transition: opacity 0.8s ease;
    max-height: 80vh;
    white-space: nowrap;
}

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

/* --- Candle Indicator --- */
#candle-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 160px;
    z-index: 100;
    pointer-events: none;
}

#candle-svg {
    width: 100%;
    height: 100%;
}

#candle-flame {
    animation: flicker 0.15s infinite alternate;
    transform-origin: center bottom;
}

@keyframes flicker {
    0% { transform: scaleX(1) scaleY(1) translateX(0); }
    25% { transform: scaleX(0.92) scaleY(1.04) translateX(-0.5px); }
    50% { transform: scaleX(1.05) scaleY(0.96) translateX(0.5px); }
    75% { transform: scaleX(0.95) scaleY(1.02) translateX(-0.3px); }
    100% { transform: scaleX(1.03) scaleY(0.98) translateX(0.4px); }
}

.smoke-hidden {
    opacity: 0;
    transition: opacity 1s ease;
}

.smoke-visible {
    opacity: 1;
}

#candle-smoke path {
    animation: smoke-rise 3s ease-out infinite;
}

@keyframes smoke-rise {
    0% { stroke-dashoffset: 30; opacity: 0.5; }
    100% { stroke-dashoffset: 0; opacity: 0; }
}

/* --- Chambers (general) --- */
.chamber {
    min-height: 100vh;
    position: relative;
    padding-left: 120px;
}

.chamber-title {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--parchment-bone);
    opacity: 0.15;
    position: absolute;
    top: 2rem;
    right: 2rem;
    pointer-events: none;
}

/* ========================================
   Chamber I: The Accusation
   ======================================== */
#chamber-accusation {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--abyss-black);
    overflow: hidden;
}

.accusation-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    padding: 2rem;
}

/* Woodcut Eye */
#woodcut-eye {
    width: clamp(200px, 40vw, 500px);
    height: auto;
    margin-bottom: 3rem;
}

#eye-outline,
#eye-iris,
#eye-pupil {
    transition: stroke-dashoffset 3.5s ease-out;
}

#eye-outline.drawn { stroke-dashoffset: 0; }
#eye-iris.drawn { stroke-dashoffset: 0; }
#eye-pupil.drawn { stroke-dashoffset: 0; opacity: 1; }

#eye-hatching.visible { opacity: 0.6; transition: opacity 1s ease; }

/* Eye blink animation */
#eye-upper-lid {
    transition: transform 0.4s ease-in-out;
}

#eye-upper-lid.blink-down {
    transform: translateY(0);
}

#eye-upper-lid.blink-up {
    transform: translateY(-110px);
}

@keyframes blink-cycle {
    0%, 90%, 100% { transform: translateY(-110px); }
    95% { transform: translateY(0px); }
}

.eye-blinking #eye-upper-lid {
    animation: blink-cycle 6s ease-in-out infinite;
}

/* Title */
#site-title {
    font-family: var(--font-display);
    font-size: clamp(4rem, 12vw, 10rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--parchment-bone);
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.title-hidden .title-letter {
    opacity: 0;
}

.title-letter {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.title-letter.revealed {
    opacity: 1;
    animation: tremble 0.12s infinite alternate;
}

@keyframes tremble {
    0% { transform: translate(-1px, -0.5px); }
    25% { transform: translate(1px, 0.5px); }
    50% { transform: translate(-0.5px, 1px); }
    75% { transform: translate(0.5px, -1px); }
    100% { transform: translate(1px, 0.5px); }
}

/* Anno Domini subtitle */
#anno-domini {
    font-family: var(--font-handwriting);
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: var(--tallow-smoke);
    opacity: 0;
    transition: opacity 1s ease;
}

#anno-domini.visible {
    opacity: 1;
}

.anno-hidden {
    opacity: 0;
}

/* ========================================
   Chamber II: The Evidence
   ======================================== */
#chamber-evidence {
    min-height: 100vh;
    padding-top: 5vh;
    padding-bottom: 10vh;
    position: relative;
}

.evidence-cards {
    position: relative;
    padding: 5vh 2rem 5vh 2rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* SVG filter for paper texture */
.document-card {
    position: sticky;
    max-width: 560px;
    padding: 2.5rem;
    margin-bottom: 30vh;
    background-color: var(--paper-spot-3);
    background-image:
        radial-gradient(ellipse at 20% 30%, var(--paper-spot-1) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, var(--paper-spot-2) 0%, transparent 40%),
        radial-gradient(ellipse at 40% 80%, var(--paper-spot-1) 0%, transparent 45%),
        radial-gradient(circle at 80% 20%, var(--paper-spot-3) 0%, transparent 30%);
    color: var(--iron-gall);
    box-shadow: 8px 8px 0 var(--iron-gall);
    clip-path: polygon(2% 0%, 98% 1%, 100% 3%, 99% 97%, 97% 100%, 3% 99%, 0% 96%, 1% 2%);
    opacity: 0;
    z-index: 1;
}

.document-card.card-left {
    margin-right: auto;
    margin-left: 0;
    transform: translateX(-120%) rotate(0deg);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.8s ease;
}

.document-card.card-right {
    margin-left: auto;
    margin-right: 0;
    transform: translateX(120%) rotate(0deg);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.8s ease;
}

.document-card.card-visible.card-left {
    opacity: 1;
    transform: translateX(0) rotate(var(--card-rotation, -2deg));
}

.document-card.card-visible.card-right {
    opacity: 1;
    transform: translateX(0) rotate(var(--card-rotation, 3deg));
}

.card-title {
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: var(--abyss-black);
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.card-body {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.2vw, 1.05rem);
    line-height: 1.75;
    color: var(--iron-gall);
    margin-bottom: 1.5rem;
}

.card-signature {
    font-family: var(--font-handwriting);
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: var(--tallow-smoke);
    display: block;
    text-align: right;
}

/* ========================================
   Chamber III: The Trial
   ======================================== */
#chamber-trial {
    min-height: 100vh;
    overflow: hidden;
}

.trial-split {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.trial-left {
    width: 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.accused-silhouette {
    width: 100%;
    max-width: 300px;
    height: auto;
}

.accused-silhouette path {
    transition: stroke-dashoffset 4s ease-out;
}

.accused-silhouette path.drawn {
    stroke-dashoffset: 0;
}

.figure-hatching {
    transition: opacity 1.5s ease 3.5s;
}

.figure-hatching.visible {
    opacity: 0.5;
}

.trial-divider {
    width: 10px;
    position: relative;
    z-index: 5;
}

.jagged-line {
    width: 100%;
    height: 100%;
}

#jagged-path {
    animation: jagged-morph 8s ease-in-out infinite alternate;
}

@keyframes jagged-morph {
    0% {
        d: path("M5,0 L3,50 L7,100 L2,150 L8,200 L4,250 L6,300 L2,350 L7,400 L3,450 L8,500 L4,550 L6,600 L2,650 L7,700 L3,750 L8,800 L4,850 L6,900 L5,950 L3,1000");
    }
    100% {
        d: path("M5,0 L4,50 L6,100 L3,150 L7,200 L5,250 L7,300 L3,350 L6,400 L4,450 L7,500 L5,550 L7,600 L3,650 L6,700 L4,750 L7,800 L5,850 L7,900 L4,950 L5,1000");
    }
}

.trial-right {
    width: 45%;
    padding: 5vh 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3rem;
}

.charge {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.charge-numeral {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--parchment-bone);
    flex-shrink: 0;
    line-height: 1.3;
}

.charge-text {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.3vw, 1.15rem);
    line-height: 1.75;
    color: var(--parchment-bone);
}

.charge-final .charge-text {
    color: var(--dried-blood);
}

.charge-final .charge-numeral {
    color: var(--dried-blood);
}

/* ========================================
   Chamber IV: The Verdict
   ======================================== */
#chamber-verdict {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--abyss-black);
}

.verdict-column {
    max-width: 480px;
    text-align: center;
    padding: 2rem;
}

.verdict-text {
    font-family: var(--font-body);
    font-size: calc(1.2rem * var(--verdict-scale));
    line-height: 1.75;
    color: var(--parchment-bone);
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.verdict-text.verdict-visible {
    opacity: 1;
    transform: translateY(0);
}

.verdict-guilty-wrapper {
    padding: 4rem 0;
}

#verdict-guilty {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(8rem, 20vw, 16rem);
    color: var(--dried-blood);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    display: block;
    opacity: 0;
    transition: opacity 1s ease;
    animation: none;
}

#verdict-guilty.visible {
    opacity: 1;
    animation: pulse-attention 2s ease-in-out infinite;
}

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

/* ========================================
   Chamber V: The Aftermath
   ======================================== */
#chamber-aftermath {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.aftermath-fragments {
    position: absolute;
    top: 0;
    left: 120px;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.fragment {
    position: absolute;
    font-family: var(--font-display);
    font-style: italic;
    font-weight: 700;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--tallow-smoke);
    opacity: 0.3;
    white-space: nowrap;
}

.fragment:nth-child(odd) {
    animation: drift-1 25s ease-in-out infinite alternate;
}

.fragment:nth-child(even) {
    animation: drift-2 32s ease-in-out infinite alternate;
}

@keyframes drift-1 {
    0% { transform: translate(0, 0) rotate(var(--frag-rotate, 0deg)); }
    25% { transform: translate(15px, -10px) rotate(calc(var(--frag-rotate, 0deg) + 2deg)); }
    50% { transform: translate(-10px, 8px) rotate(calc(var(--frag-rotate, 0deg) - 1deg)); }
    75% { transform: translate(8px, -15px) rotate(calc(var(--frag-rotate, 0deg) + 1.5deg)); }
    100% { transform: translate(-5px, 12px) rotate(calc(var(--frag-rotate, 0deg) - 0.5deg)); }
}

@keyframes drift-2 {
    0% { transform: translate(0, 0) rotate(var(--frag-rotate, 0deg)); }
    33% { transform: translate(-12px, 15px) rotate(calc(var(--frag-rotate, 0deg) - 2deg)); }
    66% { transform: translate(10px, -8px) rotate(calc(var(--frag-rotate, 0deg) + 1deg)); }
    100% { transform: translate(-8px, -12px) rotate(calc(var(--frag-rotate, 0deg) + 2.5deg)); }
}

.aftermath-coda {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 10vh 2rem;
    padding-left: calc(120px + 2rem);
}

.coda-text {
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.3vw, 1.2rem);
    line-height: 1.75;
    color: var(--parchment-bone);
    max-width: 640px;
    text-align: left;
}

.aftermath-void {
    height: 200px;
    background-color: var(--abyss-black);
}

.final-line {
    font-family: var(--font-handwriting);
    font-size: 0.85rem;
    color: var(--parchment-bone);
    opacity: 0.4;
    text-align: center;
    padding: 2rem;
    padding-bottom: 4rem;
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .title-letter.revealed {
        animation: none;
    }

    .eye-blinking #eye-upper-lid {
        animation: none;
    }

    #candle-flame {
        animation: none;
    }

    .fragment {
        animation: none !important;
    }

    #jagged-path {
        animation: none;
    }

    #verdict-guilty.visible {
        animation: none;
    }

    .accusation-text {
        transition: none;
    }

    #candle-smoke path {
        animation: none;
    }
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .margin-strip {
        width: 60px;
    }

    .chamber {
        padding-left: 60px;
    }

    .aftermath-fragments {
        left: 60px;
    }

    .aftermath-coda {
        padding-left: calc(60px + 1rem);
    }

    .trial-split {
        flex-direction: column;
    }

    .trial-left {
        width: 100%;
        min-height: 50vh;
    }

    .trial-divider {
        width: 100%;
        height: 10px;
    }

    .jagged-line {
        transform: rotate(90deg);
    }

    .trial-right {
        width: 100%;
        padding: 3vh 2rem;
    }

    .evidence-cards {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .document-card {
        max-width: 100%;
    }

    #candle-indicator {
        bottom: 10px;
        right: 10px;
        width: 30px;
        height: 120px;
    }

    .accusation-text {
        font-size: 0.8rem;
    }
}
