/* ============================================
   courthouse.stream — Cinematic Noir Jurisprudence
   ============================================ */

:root {
    /* Color Palette */
    --deep-background: #0B0D0F;    /* Courtroom Midnight */
    --panel-dark: #1A1D22;          /* Mahogany Shadow */
    --wood-accent: #8C7353;         /* Courtroom Oak */
    --parchment: #E8DCC8;           /* Verdict Cream */
    --warm-stone: #C4B8A0;          /* Limestone */
    --aged-brass: #A89878;          /* Gavel Brass */
    --deep-crimson: #6B1D1D;        /* Seal Wax */
    --tinted-fog: #2A2D35;          /* Courtroom Haze */

    /* Scroll Progress */
    --scroll-progress: 0;
    --section-index: 1;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-background);
    color: var(--warm-stone);
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
   ============================================ */

h1 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(2.2rem, 5.5vw, 5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.05;
    color: var(--parchment);
}

h2 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2.6rem);
    color: var(--aged-brass);
    line-height: 1.15;
    margin-bottom: 1.5em;
}

p {
    max-width: 38em;
    margin-bottom: 1.5em;
    color: var(--warm-stone);
}

/* ============================================
   Film Grain Overlay
   ============================================ */

#grain-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    will-change: background-position;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-size: 256px 256px;
    animation: grainShift 0.15s steps(3) infinite;
    mix-blend-mode: overlay;
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-2px, 1px); }
    66% { transform: translate(1px, -1px); }
    100% { transform: translate(-1px, 2px); }
}

/* ============================================
   Broadcast Overlay (Fixed Foreground)
   ============================================ */

#broadcast-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 900;
}

/* LIVE Indicator */
#live-indicator {
    position: absolute;
    top: 28px;
    left: 28px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

#live-indicator.visible {
    opacity: 1;
}

.live-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--deep-crimson);
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 0.4; box-shadow: 0 0 6px rgba(107, 29, 29, 0.3); }
    50% { opacity: 1; box-shadow: 0 0 12px rgba(107, 29, 29, 0.6); }
}

.live-text {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--deep-crimson);
}

/* Timecode */
#timecode {
    position: absolute;
    top: 30px;
    right: 28px;
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wood-accent);
    opacity: 0;
    transition: opacity 0.6s ease;
}

#timecode.visible {
    opacity: 0.5;
}

/* Docket Ticker */
#docket-ticker {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 36px;
    background: linear-gradient(to bottom, transparent, rgba(26, 29, 34, 0.7));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.8s ease;
}

#docket-ticker.visible {
    opacity: 1;
}

.ticker-mask {
    width: 100%;
    overflow: hidden;
    mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

.ticker-content {
    display: flex;
    white-space: nowrap;
    animation: tickerScroll 120s linear infinite;
}

.ticker-content span {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wood-accent);
    opacity: 0.5;
    padding-right: 2rem;
    flex-shrink: 0;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Progress Indicator */
#progress-indicator {
    position: absolute;
    bottom: 56px;
    right: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.progress-ring {
    width: 48px;
    height: 48px;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--tinted-fog);
    stroke-width: 2;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--wood-accent);
    stroke-width: 2;
    stroke-dasharray: 125.66;
    stroke-dashoffset: 125.66;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
}

#section-numeral {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    color: var(--wood-accent);
    opacity: 0.7;
}

/* ============================================
   Film Gate Transition Bar
   ============================================ */

#film-gate-bar {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--wood-accent);
    transform: translateX(-100%);
    z-index: 800;
    pointer-events: none;
    opacity: 0;
}

#film-gate-bar.sweeping {
    opacity: 1;
    animation: filmGateSweep 800ms ease-in-out forwards;
}

@keyframes filmGateSweep {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================
   Broadcast Sections
   ============================================ */

.broadcast-section {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    overflow: hidden;
}

/* Background paneling effect (alternating subtle shades) */
.broadcast-section:nth-child(odd of .broadcast-section) {
    background: linear-gradient(
        180deg,
        var(--deep-background) 0%,
        rgba(26, 29, 34, 0.3) 50%,
        var(--deep-background) 100%
    );
}

.broadcast-section:nth-child(even of .broadcast-section) {
    background: linear-gradient(
        180deg,
        var(--deep-background) 0%,
        rgba(26, 29, 34, 0.15) 50%,
        var(--deep-background) 100%
    );
}

/* Chiaroscuro Spotlight */
.section-spotlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(
        ellipse 50% 60% at 50% 40%,
        rgba(232, 220, 200, 0.06) 0%,
        transparent 70%
    );
    transition: background-position 0.5s ease;
}

/* Section Content */
.section-content {
    position: relative;
    z-index: 10;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1.2s cubic-bezier(0.25, 0.1, 0.25, 1.0),
                transform 1.2s cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

.section-content.in-view {
    opacity: 1;
    transform: translateY(0) translateX(0);
}

.section-content--wide {
    width: min(83.333%, 1200px);
    text-align: center;
}

.section-content--wide p {
    margin-left: auto;
    margin-right: auto;
}

.section-content--narrow {
    width: min(41.666%, 600px);
}

.section-content--left {
    margin-right: auto;
    margin-left: 8.333%;
    text-align: left;
    transform: translateX(-60px);
}

.section-content--left.in-view {
    transform: translateX(0);
}

.section-content--right {
    margin-left: auto;
    margin-right: 8.333%;
    text-align: left;
    transform: translateX(60px);
}

.section-content--right.in-view {
    transform: translateX(0);
}

/* ============================================
   Hero Section (#section-1)
   ============================================ */

.hero-title {
    margin-bottom: 0.3em;
}

.hero-title-accent {
    display: block;
    color: var(--aged-brass);
    font-weight: 400;
    font-size: 0.55em;
    letter-spacing: 0.15em;
}

.hero-subtitle {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-style: italic;
    font-weight: 300;
    font-size: clamp(1rem, 1.6vw, 1.3rem);
    color: var(--aged-brass);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease 0.4s, transform 1.2s ease 0.4s;
    max-width: 38em;
    margin-left: auto;
    margin-right: auto;
}

.section-content.in-view .hero-subtitle {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   Testimony Blocks
   ============================================ */

.testimony-block {
    position: relative;
    padding: 1em 0;
}

.testimony-quote-open,
.testimony-quote-close {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: 8rem;
    line-height: 1;
    color: var(--wood-accent);
    opacity: 0;
    position: absolute;
    pointer-events: none;
    transition: opacity 1.2s ease;
}

.in-view .testimony-quote-open,
.in-view .testimony-quote-close {
    opacity: 0.15;
}

.testimony-quote-open {
    top: -0.35em;
    left: -0.15em;
}

.testimony-quote-close {
    bottom: 0;
    right: 0;
}

.testimony-block p {
    position: relative;
    z-index: 2;
    font-style: italic;
    font-weight: 300;
}

/* ============================================
   Gavel SVG Divider
   ============================================ */

.gavel-divider,
.final-gavel {
    margin: 2.5em auto;
    text-align: center;
    transform: rotate(-12deg);
    opacity: 0.7;
}

.gavel-svg {
    width: 160px;
    height: 64px;
}

.gavel-path {
    fill: none;
    stroke: var(--wood-accent);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease-out;
}

.in-view .gavel-path {
    stroke-dashoffset: 0;
}

/* ============================================
   Bokeh Circles
   ============================================ */

.bokeh-circle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(20px);
    background: radial-gradient(
        circle,
        rgba(232, 220, 200, 0.08) 0%,
        rgba(232, 220, 200, 0.02) 50%,
        transparent 70%
    );
}

.bokeh-1 {
    width: 180px;
    height: 180px;
    top: 15%;
    right: 10%;
    opacity: 0.05;
    animation: bokehDrift1 30s ease-in-out infinite alternate;
}

.bokeh-2 {
    width: 100px;
    height: 100px;
    bottom: 20%;
    left: 15%;
    opacity: 0.04;
    animation: bokehDrift2 25s ease-in-out infinite alternate;
}

.bokeh-3 {
    width: 140px;
    height: 140px;
    top: 25%;
    left: 60%;
    opacity: 0.06;
    animation: bokehDrift1 35s ease-in-out infinite alternate;
}

.bokeh-4 {
    width: 60px;
    height: 60px;
    bottom: 30%;
    right: 20%;
    opacity: 0.04;
    animation: bokehDrift2 28s ease-in-out infinite alternate;
}

.bokeh-5 {
    width: 200px;
    height: 200px;
    top: 10%;
    left: 5%;
    opacity: 0.03;
    animation: bokehDrift1 40s ease-in-out infinite alternate;
}

.bokeh-6 {
    width: 120px;
    height: 120px;
    top: 40%;
    right: 15%;
    opacity: 0.06;
    animation: bokehDrift2 32s ease-in-out infinite alternate;
}

.bokeh-7 {
    width: 80px;
    height: 80px;
    bottom: 15%;
    left: 25%;
    opacity: 0.04;
    animation: bokehDrift1 22s ease-in-out infinite alternate;
}

.bokeh-8 {
    width: 160px;
    height: 160px;
    top: 20%;
    right: 25%;
    opacity: 0.05;
    animation: bokehDrift2 36s ease-in-out infinite alternate;
}

@keyframes bokehDrift1 {
    0% { transform: translateY(0); }
    100% { transform: translateY(-40px); }
}

@keyframes bokehDrift2 {
    0% { transform: translateY(0); }
    100% { transform: translateY(30px); }
}

/* ============================================
   Closing Statement
   ============================================ */

.closing-statement {
    font-family: 'DM Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wood-accent);
    opacity: 0.5;
    margin-top: 2em;
    text-align: center;
}

/* ============================================
   Wood Paneling Background Columns
   ============================================ */

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    background: repeating-linear-gradient(
        to right,
        transparent 0%,
        transparent calc(100% / 12),
        rgba(26, 29, 34, 0.08) calc(100% / 12),
        rgba(26, 29, 34, 0.08) calc(200% / 12)
    );
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 768px) {
    .broadcast-section {
        padding: 60px 24px;
    }

    .section-content--narrow {
        width: min(90%, 600px);
    }

    .section-content--left {
        margin-left: 5%;
    }

    .section-content--right {
        margin-right: 5%;
    }

    .testimony-quote-open,
    .testimony-quote-close {
        font-size: 5rem;
    }

    #live-indicator {
        top: 16px;
        left: 16px;
    }

    #timecode {
        top: 18px;
        right: 16px;
    }

    #progress-indicator {
        bottom: 48px;
        right: 16px;
    }
}

@media (max-width: 480px) {
    .section-content--wide {
        width: 95%;
    }

    .section-content--narrow {
        width: 95%;
    }

    .section-content--left,
    .section-content--right {
        margin-left: auto;
        margin-right: auto;
    }

    h1 {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }
}
