/* =============================================
   judge.quest - Inflated 3D Courtroom Adventure
   ============================================= */

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

:root {
    /* Palette from DESIGN.md */
    --bg-light: #e2e0ec;
    --bg-deep: #2d2b3d;
    --inflated-1: #c8bff5;    /* soft periwinkle */
    --inflated-2: #f5d0e0;    /* blush pink */
    --inflated-3: #bfe5d6;    /* mint foam */
    --text-primary: #1a1825;  /* near-black indigo */
    --text-on-dark: #d8d5e8;  /* pale lavender */
    --shadow-color: rgba(149, 144, 176, 0.3);  /* #9590b0 at 30% */
    --specular: rgba(255, 255, 255, 0.4);
    --white: #ffffff;

    /* Typography */
    --font-headline: 'Libre Baskerville', Georgia, serif;
    --font-body: 'Outfit', 'Segoe UI', sans-serif;
    --font-label: 'Syne Mono', 'Courier New', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-light);
    overflow-x: hidden;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* --- Scroll Progress Bar --- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 1000;
    background: transparent;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--inflated-1), var(--inflated-2), var(--inflated-3));
    border-radius: 0 4px 4px 0;
    transition: width 0.1s linear;
}

/* --- Chapter Navigation Dots --- */
.chapter-nav {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 999;
}

.nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--shadow-color);
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 2px 2px 6px rgba(149, 144, 176, 0.2);
}

.nav-dot.active {
    background: var(--inflated-1);
    transform: scale(1.4);
    box-shadow: 0 0 12px rgba(200, 191, 245, 0.5);
}

.nav-dot:hover {
    background: var(--inflated-2);
    transform: scale(1.3);
}

/* --- Hero Section --- */
.section-hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--bg-light);
}

.hero-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

/* --- Inflated 3D Gavel --- */
.gavel-container {
    position: relative;
    width: 280px;
    height: 240px;
    opacity: 0;
    transform: scale(0.85);
}

.gavel-container.animate-in {
    animation: gavelBounceIn 800ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes gavelBounceIn {
    0% { opacity: 0; transform: scale(0.85); }
    60% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1.0); }
}

.gavel {
    position: relative;
    width: 100%;
    height: 100%;
}

.gavel-head {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0;
}

.gavel-head-core {
    width: 140px;
    height: 70px;
    border-radius: 18px;
    background: radial-gradient(ellipse at 35% 30%, var(--specular), var(--inflated-1) 40%, #a99de0 100%);
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.4),
        8px 16px 40px rgba(149, 144, 176, 0.25),
        inset 0 -4px 12px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 2;
}

.gavel-head-face {
    width: 50px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 35% 30%, var(--specular), var(--inflated-1) 45%, #9b8fd6 100%);
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.4),
        6px 12px 30px rgba(149, 144, 176, 0.2),
        inset 0 -3px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 3;
}

.gavel-head-left {
    margin-right: -12px;
}

.gavel-head-right {
    margin-left: -12px;
}

.gavel-handle {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 110px;
    border-radius: 14px;
    background: radial-gradient(ellipse at 35% 20%, var(--specular), var(--inflated-2) 50%, #d4a8be 100%);
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.35),
        6px 12px 30px rgba(149, 144, 176, 0.2),
        inset 0 -3px 8px rgba(0, 0, 0, 0.05);
    z-index: 1;
}

.gavel-shadow {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 160px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(149, 144, 176, 0.3), transparent 70%);
}

/* --- Domain Title --- */
.domain-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(30px, 5.5vw, 72px);
    letter-spacing: 0.08em;
    color: var(--text-primary);
    min-height: 1.2em;
    overflow: hidden;
}

.domain-title .cursor {
    display: inline-block;
    width: 3px;
    height: 0.85em;
    background: var(--inflated-1);
    margin-left: 2px;
    animation: cursorBlink 0.6s ease-in-out infinite alternate;
    vertical-align: baseline;
}

@keyframes cursorBlink {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Scroll Indicator --- */
.scroll-indicator {
    opacity: 0;
    animation: fadeInDelay 0.6s ease forwards 2s;
}

@keyframes fadeInDelay {
    to { opacity: 1; }
}

.scroll-arrow {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(ellipse at 35% 30%, var(--specular), var(--inflated-3) 60%);
    box-shadow:
        2px 3px 8px rgba(149, 144, 176, 0.3),
        inset 0 -2px 6px rgba(0, 0, 0, 0.04);
    position: relative;
    animation: bounceScroll 2s ease-in-out infinite;
}

.scroll-arrow::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-right: 2.5px solid var(--text-primary);
    border-bottom: 2.5px solid var(--text-primary);
    transform: translate(-50%, -60%) rotate(45deg);
    opacity: 0.6;
}

@keyframes bounceScroll {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(12px); }
}

/* --- Chapter Sections --- */
.section-chapter {
    min-height: 150vh;
    position: relative;
    padding: 10vh 5vw;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.section-verdict {
    min-height: 100vh;
    padding-bottom: 20vh;
}

/* --- Chapter Labels --- */
.chapter-label {
    text-align: center;
    margin-bottom: 8vh;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

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

.chapter-number {
    font-family: var(--font-label);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--inflated-1);
    display: inline-block;
    position: relative;
}

.chapter-number.glitch {
    animation: glitchEffect 200ms linear;
}

@keyframes glitchEffect {
    0% { transform: translateX(0); text-shadow: none; }
    20% { transform: translateX(-2px); text-shadow: -2px 0 cyan, 2px 0 magenta; }
    40% { transform: translateX(2px); text-shadow: 2px 0 cyan, -2px 0 magenta; }
    60% { transform: translateX(-1px); text-shadow: -1px 0 cyan, 1px 0 magenta; }
    80% { transform: translateX(1px); text-shadow: 1px 0 cyan, -1px 0 magenta; }
    100% { transform: translateX(0); text-shadow: none; }
}

.chapter-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(30px, 5.5vw, 72px);
    margin-top: 8px;
    transition: color 0.4s ease;
}

/* --- Speech Bubbles (Chapter 1) --- */
.chapter-content {
    max-width: 700px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 60px;
}

.speech-bubble {
    background: radial-gradient(ellipse at 30% 20%, var(--specular), #f0eef7 30%, var(--bg-light) 100%);
    border-radius: 24px;
    padding: 36px 40px;
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.25),
        8px 16px 40px rgba(149, 144, 176, 0.15),
        inset 0 -4px 12px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

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

.speech-bubble p {
    font-family: var(--font-body);
    font-size: clamp(16px, 1.7vw, 20px);
    font-weight: 400;
    line-height: 1.7;
    color: var(--text-primary);
}

.bubble-1 {
    background: radial-gradient(ellipse at 25% 20%, var(--specular), #ece9f8 35%, var(--bg-light) 100%);
    align-self: flex-start;
}

.bubble-2 {
    background: radial-gradient(ellipse at 70% 25%, var(--specular), #f7eef4 35%, #f0ecf6 100%);
    align-self: flex-end;
}

.bubble-3 {
    background: radial-gradient(ellipse at 30% 30%, var(--specular), #e8f2ed 35%, #eceaf4 100%);
    align-self: center;
}

/* --- Evidence Blobs (Chapter 2) --- */
.evidence-field {
    max-width: 900px;
    gap: 50px;
}

.evidence-blob {
    padding: 32px 36px;
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.3),
        8px 16px 40px rgba(149, 144, 176, 0.18),
        inset 0 -4px 12px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.evidence-blob.visible {
    opacity: 1;
    transform: translateX(0) !important;
}

.blob-left {
    transform: translateX(-80px);
    align-self: flex-start;
}

.blob-right {
    transform: translateX(80px);
    align-self: flex-end;
}

.blob-1 {
    border-radius: 30% 70% 50% 60% / 60% 40% 70% 30%;
    background: radial-gradient(ellipse at 30% 25%, var(--specular), var(--inflated-1) 50%, #b3a8e8 100%);
    max-width: 420px;
}

.blob-2 {
    border-radius: 60% 40% 70% 30% / 30% 70% 40% 60%;
    background: radial-gradient(ellipse at 65% 25%, var(--specular), var(--inflated-2) 50%, #e0b5c8 100%);
    max-width: 400px;
}

.blob-3 {
    border-radius: 50% 60% 30% 70% / 70% 30% 60% 40%;
    background: radial-gradient(ellipse at 35% 30%, var(--specular), var(--inflated-3) 50%, #a3d1be 100%);
    max-width: 440px;
}

.blob-4 {
    border-radius: 70% 30% 60% 40% / 40% 60% 30% 70%;
    background: radial-gradient(ellipse at 55% 20%, var(--specular), var(--inflated-1) 45%, #bab0f0 100%);
    max-width: 390px;
}

.blob-5 {
    border-radius: 40% 60% 70% 30% / 50% 50% 40% 60%;
    background: radial-gradient(ellipse at 40% 30%, var(--specular), var(--inflated-2) 50%, #d9a5bc 100%);
    max-width: 430px;
}

.blob-label {
    font-family: var(--font-label);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 12px;
    opacity: 0.7;
}

.evidence-blob p {
    font-family: var(--font-body);
    font-size: clamp(16px, 1.7vw, 20px);
    font-weight: 400;
    line-height: 1.7;
    color: var(--text-primary);
}

/* --- Verdict Section (Chapter 3) --- */
.section-verdict {
    background: transparent;
}

.verdict-content {
    align-items: center;
    gap: 80px;
}

/* --- Scales of Justice --- */
.scales-container {
    width: 100%;
    max-width: 500px;
    height: 340px;
    position: relative;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.scales {
    position: relative;
    width: 100%;
    height: 100%;
}

.scales-fulcrum {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 100px solid transparent;
    position: relative;
}

.scales-fulcrum {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 120px;
    background: radial-gradient(ellipse at 35% 20%, var(--specular), var(--inflated-1) 50%, #a99de0 100%);
    clip-path: polygon(30% 0%, 70% 0%, 85% 100%, 15% 100%);
    box-shadow: 4px 8px 20px rgba(149, 144, 176, 0.3);
    border-radius: 8px;
}

.scales-beam {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 380px;
    height: 16px;
    border-radius: 12px;
    background: radial-gradient(ellipse at 35% 25%, var(--specular), var(--inflated-1) 55%, #a99de0 100%);
    box-shadow:
        2px 4px 10px rgba(149, 144, 176, 0.35),
        inset 0 -3px 6px rgba(0, 0, 0, 0.05);
    transform-origin: center center;
    transition: transform 0.3s ease;
    z-index: 2;
}

.scales-chain-left,
.scales-chain-right {
    position: absolute;
    top: 52px;
    width: 3px;
    height: 60px;
    background: linear-gradient(to bottom, var(--inflated-1), #a99de0);
    border-radius: 2px;
    z-index: 1;
}

.scales-chain-left {
    left: calc(50% - 175px);
}

.scales-chain-right {
    right: calc(50% - 175px);
}

.scales-pan {
    position: absolute;
    top: 110px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.35),
        8px 16px 40px rgba(149, 144, 176, 0.2),
        inset 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.scales-pan-left {
    left: calc(50% - 230px);
    background: radial-gradient(ellipse at 35% 25%, var(--specular), var(--inflated-2) 50%, #d4a8be 100%);
}

.scales-pan-right {
    right: calc(50% - 230px);
    background: radial-gradient(ellipse at 60% 25%, var(--specular), var(--inflated-3) 50%, #a3d1be 100%);
}

.pan-label {
    font-family: var(--font-label);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-primary);
    opacity: 0.8;
}

/* --- Verdict Statement --- */
.verdict-statement {
    max-width: 600px;
    text-align: center;
    background: radial-gradient(ellipse at 30% 20%, var(--specular), rgba(200, 191, 245, 0.25) 40%, transparent 80%);
    border-radius: 24px;
    padding: 40px 44px;
    box-shadow:
        2px 4px 8px rgba(149, 144, 176, 0.2),
        inset 0 -4px 12px rgba(0, 0, 0, 0.04);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

.verdict-statement p {
    font-family: var(--font-body);
    font-size: clamp(16px, 1.7vw, 20px);
    font-weight: 400;
    line-height: 1.8;
}

/* --- Dark background transition for Chapter 3 --- */
body.dark-mode .section-verdict .chapter-title {
    color: var(--text-on-dark);
}

body.dark-mode .section-verdict .chapter-number {
    color: var(--inflated-2);
}

body.dark-mode .verdict-statement {
    background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.08), rgba(200, 191, 245, 0.12) 40%, transparent 80%);
}

body.dark-mode .verdict-statement p {
    color: var(--text-on-dark);
}

body.dark-mode .scales-fulcrum {
    box-shadow: 4px 8px 20px rgba(0, 0, 0, 0.4);
}

body.dark-mode .pan-label {
    color: var(--text-on-dark);
}

body.dark-mode .nav-dot {
    background: rgba(200, 191, 245, 0.3);
}

body.dark-mode .nav-dot.active {
    background: var(--inflated-2);
}

body.dark-mode .blob-label {
    color: var(--text-on-dark);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .section-chapter {
        padding: 8vh 6vw;
    }

    .chapter-content {
        gap: 40px;
    }

    .evidence-field {
        gap: 36px;
    }

    .evidence-blob {
        max-width: 100% !important;
        align-self: center !important;
    }

    .blob-left {
        transform: translateX(-40px);
    }

    .blob-right {
        transform: translateX(40px);
    }

    .speech-bubble {
        padding: 28px 28px;
    }

    .scales-beam {
        width: 260px;
    }

    .scales-chain-left {
        left: calc(50% - 118px);
    }

    .scales-chain-right {
        right: calc(50% - 118px);
    }

    .scales-pan {
        width: 80px;
        height: 80px;
    }

    .scales-pan-left {
        left: calc(50% - 160px);
    }

    .scales-pan-right {
        right: calc(50% - 160px);
    }

    .chapter-nav {
        right: 12px;
    }

    .gavel-container {
        width: 200px;
        height: 180px;
    }

    .gavel-head-core {
        width: 100px;
        height: 50px;
    }

    .gavel-head-face {
        width: 36px;
        height: 44px;
    }

    .gavel-handle {
        width: 16px;
        height: 80px;
    }

    .scales-container {
        height: 260px;
    }
}

@media (max-width: 480px) {
    .chapter-nav {
        display: none;
    }

    .evidence-blob {
        padding: 24px 24px;
    }

    .verdict-statement {
        padding: 28px 24px;
    }

    .scales-beam {
        width: 200px;
    }

    .scales-chain-left {
        left: calc(50% - 88px);
    }

    .scales-chain-right {
        right: calc(50% - 88px);
    }

    .scales-pan-left {
        left: calc(50% - 128px);
    }

    .scales-pan-right {
        right: calc(50% - 128px);
    }

    .scales-pan {
        width: 65px;
        height: 65px;
    }

    .pan-label {
        font-size: 10px;
    }
}
