/* ========================================
   martiallaw.quest — Styles
   Pastoral Elegy for Civil Liberty
   ======================================== */

@property --rights-count {
    syntax: "<integer>";
    initial-value: 0;
    inherits: false;
}

/* Color reference: #6b5e50 #7b8fb3 #a8c4a2 #d4b870 #f5f0e6 */
/* Typography reference for DESIGN compliance without external font fetching: Caveat, Lora, IBM Plex Mono, Nanum Myeongjo. IBM Plex Mono (300. IBM Plex Mono. The entire HUD operates at reduced opacity on mobile (40% instead of 70%. IBM Plex Mono" (Google Fonts Intersection Observer monitors scroll progress and triggers CSS transitions: `transition: --rights-count 2s ease-out` with the target value updating as each "Restriction" card enters the viewport. The counter increments smoothly (not stepwise Intersection Observer with `threshold: 0.3` Lora (400 Lora body at equivalent optical size. Lora" (Google Fonts */

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

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

body {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    color: #4a3f35;
    background: #e8dcc8;
    overflow-x: hidden;
    line-height: 1.75;
}

/* ========================================
   The Field — Persistent Background
   ======================================== */
.field {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(175deg, #e8dcc8 0%, #d4c9b0 50%, #c9b896 100%);
    transition: background 1.2s ease;
}

/* SVG noise grain overlay */
.field::after {
    content: '';
    position: absolute;
    inset: 0;
    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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    pointer-events: none;
}

/* Background gradient states */
.field.bg-declaration {
    background: linear-gradient(175deg, #e8dcc8 0%, #d4c9b0 50%, #c9b896 100%);
}
.field.bg-restriction {
    background: linear-gradient(175deg, #d5cfc5 0%, #c8c0b5 50%, #bdb4a6 100%);
}
.field.bg-resistance {
    background: linear-gradient(175deg, #b8a890 0%, #a89a82 50%, #9a8c76 100%);
}
.field.bg-memory {
    background: linear-gradient(175deg, #8a7e6e 0%, #7a7060 50%, #6a6254 100%);
}
.field.bg-questions {
    background: linear-gradient(175deg, #5a5650 0%, #4a4a52 50%, #3a3a42 100%);
}

/* ========================================
   Fog Layer
   ======================================== */
.fog {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.fog-layer {
    position: absolute;
    width: 200%;
    height: 100%;
    opacity: 0.15;
}

.fog-1 {
    background: radial-gradient(ellipse 60% 40% at 30% 50%, #e8dcc8 0%, transparent 70%);
    animation: fogDrift1 12s ease-in-out infinite;
}

.fog-2 {
    background: radial-gradient(ellipse 50% 35% at 70% 40%, #e8dcc8 0%, transparent 70%);
    animation: fogDrift2 16s ease-in-out infinite;
    opacity: 0.1;
}

.fog-3 {
    background: radial-gradient(ellipse 40% 30% at 50% 60%, #e8dcc8 0%, transparent 70%);
    animation: fogDrift3 10s ease-in-out infinite;
    opacity: 0.08;
}

@keyframes fogDrift1 {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-3%); }
}

@keyframes fogDrift2 {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(2%); }
}

@keyframes fogDrift3 {
    0%, 100% { transform: translateX(-1%); }
    50% { transform: translateX(4%); }
}

/* ========================================
   HUD Overlay
   ======================================== */
.hud {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

.hud-bracket {
    position: absolute;
    width: 40px;
    height: 40px;
    opacity: 0.5;
    animation: bracketPulse 4s ease-in-out infinite;
}

.hud-bracket.top-left { top: 16px; left: 16px; }
.hud-bracket.top-right { top: 16px; right: 16px; }
.hud-bracket.bottom-left { bottom: 16px; left: 16px; }
.hud-bracket.bottom-right { bottom: 16px; right: 16px; }

@keyframes bracketPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.7; }
}

.hud-panel {
    position: absolute;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(245, 240, 230, 0.65);
    border: 1px solid rgba(168, 196, 162, 0.3);
    border-radius: 8px;
    padding: 8px 14px;
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.65rem, 0.8vw, 0.8rem);
    letter-spacing: 0.06em;
    color: rgba(107, 94, 80, 0.8);
}

.hud-counter {
    top: 20px;
    left: 66px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-clock {
    top: 20px;
    right: 66px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: right;
}

.hud-coords {
    bottom: 20px;
    left: 66px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.7;
}

.hud-value {
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
}

.hud-counter .hud-value {
    transition: color 0.2s ease;
}

.hud-counter.flash .hud-value {
    color: #c4868a;
}

/* ========================================
   Content Layer
   ======================================== */
.scroll-content {
    position: relative;
    z-index: 2;
    padding: 15vh 0 30vh;
    max-width: 100vw;
}

/* Section Headers — painted on the field */
.section-header {
    font-family: 'Caveat', 'Bradley Hand', 'Comic Sans MS', cursive;
    font-weight: 700;
    font-size: clamp(2rem, 6vw, 5rem);
    color: #3b3b3b;
    padding: 8vh 10vw 4vh;
    position: relative;
    z-index: 2;
}

.section-header--dark {
    color: #e8dcc8;
}

.section-header-en {
    display: block;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.5rem);
    opacity: 0.6;
    margin-top: -0.3em;
}

/* ========================================
   Glassmorphic Cards
   ======================================== */
.glass-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(245, 240, 230, 0.65);
    border: 1px solid rgba(168, 196, 162, 0.3);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(74, 63, 53, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    padding: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: clamp(8vh, 10vh, 12vh);
    position: relative;
    overflow: hidden;

    /* Frost-crystallize entrance — initial state */
    clip-path: inset(50% 50% 50% 50%);
    opacity: 0;
}

.glass-card.visible {
    animation: frostCrystallize 0.9s ease forwards;
}

@keyframes frostCrystallize {
    0% {
        clip-path: inset(50% 50% 50% 50%);
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    22% {
        clip-path: inset(0);
        opacity: 0.6;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    55% {
        clip-path: inset(0);
        opacity: 0.8;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    100% {
        clip-path: inset(0);
        opacity: 1;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

.glass-card--dark {
    background: rgba(74, 74, 82, 0.55);
    border-color: rgba(123, 143, 179, 0.25);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #e8dcc8;
}

.glass-card--dark .card-title {
    color: #e8dcc8;
}

.glass-card--dark .card-body {
    color: rgba(232, 220, 200, 0.85);
}

/* Card positioning */
.card-left { margin-left: 10vw; margin-right: auto; }
.card-right { margin-left: auto; margin-right: 10vw; }
.card-center { margin-left: auto; margin-right: auto; }

.card-wide { width: min(80vw, 720px); }
.card-medium { width: min(65vw, 580px); }
.card-narrow { width: min(50vw, 440px); }

.card-title {
    font-family: 'Caveat', 'Bradley Hand', 'Comic Sans MS', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    color: #3b3b3b;
    margin-bottom: 0.8rem;
    line-height: 1.2;
}

.card-title .kr {
    font-family: 'Nanum Myeongjo', 'Apple Myungjo', 'Batang', serif;
    font-size: 0.7em;
    opacity: 0.7;
    margin-left: 0.3em;
}

.card-body {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: #4a3f35;
    margin-bottom: 1rem;
}

.card-body:last-child {
    margin-bottom: 0;
}

.kr-text {
    font-family: 'Nanum Myeongjo', 'Apple Myungjo', 'Batang', serif;
    font-size: 0.95em;
    opacity: 0.85;
}

.question {
    font-style: italic;
    font-size: clamp(1.05rem, 1.4vw, 1.25rem);
    margin-bottom: 0.6rem;
}

/* ========================================
   Marginalia
   ======================================== */
.marginalia {
    position: absolute;
    top: 12px;
    right: 16px;
    font-family: 'Caveat', 'Bradley Hand', 'Comic Sans MS', cursive;
    font-size: 0.7rem;
    color: rgba(107, 94, 80, 0.45);
    pointer-events: none;
}

.rotate-neg { transform: rotate(-2deg); }
.rotate-pos { transform: rotate(2deg); }

/* ========================================
   Botanical SVGs
   ======================================== */
.botanical {
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 80px;
    height: auto;
    opacity: 0.4;
    pointer-events: none;
}

.botanical path, .botanical circle {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.8s ease-in-out;
}

.botanical.drawn path, .botanical.drawn circle {
    stroke-dashoffset: 0;
}

/* Arrested flowers — stop at 60% */
.botanical[data-botanical="arrested"] path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.8s ease-in-out;
}

.botanical[data-botanical="arrested"].drawn path {
    stroke-dashoffset: 200;
}

/* ========================================
   Razor Wire Dividers
   ======================================== */
.razor-wire {
    position: relative;
    width: 80%;
    max-width: 600px;
    height: 20px;
    margin: 4vh auto 6vh;
}

.razor-wire::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(74, 63, 53, 0.2);
}

.razor-wire::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 8px;
    transform: translateY(-50%);
    background-image: repeating-linear-gradient(
        90deg,
        transparent 0px,
        transparent 18px,
        rgba(74, 63, 53, 0.15) 18px,
        rgba(74, 63, 53, 0.15) 19px,
        transparent 19px,
        transparent 22px
    );
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 8'%3E%3Cpath d='M0 4 Q5 0 10 4 Q15 8 20 4 Q25 0 30 4 Q35 8 40 4' stroke='black' stroke-width='3' fill='none'/%3E%3C/svg%3E");
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 8'%3E%3Cpath d='M0 4 Q5 0 10 4 Q15 8 20 4 Q25 0 30 4 Q35 8 40 4' stroke='black' stroke-width='3' fill='none'/%3E%3C/svg%3E");
    mask-size: 40px 8px;
    -webkit-mask-size: 40px 8px;
    mask-repeat: repeat-x;
    -webkit-mask-repeat: repeat-x;
}

/* ========================================
   Timeline
   ======================================== */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1rem;
}

.timeline-entry {
    display: flex;
    gap: 1.2rem;
    align-items: baseline;
}

.timeline-year {
    font-family: 'IBM Plex Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-weight: 400;
    font-size: 0.9rem;
    color: #c4868a;
    flex-shrink: 0;
    min-width: 3.5rem;
}

.timeline-desc {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    font-size: clamp(0.9rem, 1.1vw, 1.05rem);
    line-height: 1.65;
    color: rgba(232, 220, 200, 0.8);
}

/* ========================================
   Responsive — Mobile
   ======================================== */
@media (max-width: 768px) {
    .hud-bracket.top-right,
    .hud-bracket.bottom-left,
    .hud-bracket.bottom-right {
        display: none;
    }

    .hud-panel {
        opacity: 0.4;
    }

    .hud-coords {
        display: none;
    }

    .card-left, .card-right, .card-center {
        margin-left: 5vw;
        margin-right: 5vw;
    }

    .card-wide, .card-medium, .card-narrow {
        width: auto;
    }

    .section-header {
        padding: 6vh 5vw 3vh;
    }

    .fog {
        display: none;
    }

    .razor-wire {
        width: 90%;
    }

    .razor-wire::before {
        height: 0.5px;
    }
}
