/* ==========================================
   courthouse.app - Styles
   ========================================== */

/* --- CSS Custom Properties (Palette) --- */
:root {
    --judicial-navy: #0D1B2A;
    --chamber-navy: #162D44;
    --antique-cream: #F5F0E8;
    --tarnished-brass: #8B7355;
    --seal-vermillion: #8B3A3A;
    --marble-warm: #E8E2D6;
    --courtroom-shadow: #1A3350;
    --depth-navy: #0F1E30;

    --font-headline: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, serif;
    --font-mono: 'DM Mono', 'Courier New', monospace;

    --scroll-progress: 0;
}

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

html {
    scroll-behavior: smooth;
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.15rem);
}

body {
    background-color: var(--judicial-navy);
    color: var(--antique-cream);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Fixed Background Floor Pattern Layer --- */
.floor-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.03;
    background-image:
        linear-gradient(0deg, var(--depth-navy) 1px, transparent 1px),
        linear-gradient(90deg, var(--depth-navy) 1px, transparent 1px),
        linear-gradient(45deg, var(--depth-navy) 1px, transparent 1px),
        linear-gradient(-45deg, var(--depth-navy) 1px, transparent 1px);
    background-size: 80px 80px, 80px 80px, 113px 113px, 113px 113px;
}

/* --- Vertical Rule of Law (Scroll Progress) --- */
.rule-of-law {
    position: fixed;
    left: 14vw;
    top: 0;
    bottom: 0;
    width: 1px;
    z-index: 100;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(139, 115, 85, 0.4) 10%,
        rgba(139, 115, 85, 0.4) 90%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity 0.6s ease;
}

.rule-of-law.visible {
    opacity: 1;
}

.rule-of-law::after {
    content: '';
    position: absolute;
    left: 0;
    width: 1px;
    height: 15vh;
    background: var(--tarnished-brass);
    top: calc(var(--scroll-progress) * 1% - 7.5vh);
    box-shadow: 0 0 6px rgba(139, 115, 85, 0.3);
    mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        var(--tarnished-brass) 20%,
        var(--tarnished-brass) 80%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to bottom,
        transparent 0%,
        white 20%,
        white 80%,
        transparent 100%
    );
}

/* ==========================================
   OPENING VIEWPORT: Caption Page
   ========================================== */
.opening-viewport {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--judicial-navy);
    z-index: 1;
    overflow: hidden;
}

.opening-frame {
    position: relative;
    width: calc(100% - 6vw);
    height: calc(100% - 6vw);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0px solid var(--chamber-navy);
}

/* Frame draw animation */
.opening-frame.animate {
    animation: frameDrawTop 400ms 800ms ease-out forwards,
               frameDrawRight 400ms 1200ms ease-out forwards,
               frameDrawBottom 400ms 1600ms ease-out forwards,
               frameDrawLeft 400ms 2000ms ease-out forwards;
}

@keyframes frameDrawTop {
    from { border-top-width: 0px; }
    to { border-top-width: 3px; border-top-color: var(--chamber-navy); }
}

@keyframes frameDrawRight {
    from { border-right-width: 0px; }
    to { border-right-width: 3px; border-right-color: var(--chamber-navy); }
}

@keyframes frameDrawBottom {
    from { border-bottom-width: 0px; }
    to { border-bottom-width: 3px; border-bottom-color: var(--chamber-navy); }
}

@keyframes frameDrawLeft {
    from { border-left-width: 0px; }
    to { border-left-width: 3px; border-left-color: var(--chamber-navy); }
}

/* Embossed Seal Watermark */
.seal-watermark {
    position: absolute;
    width: 50vw;
    height: 50vw;
    max-width: 500px;
    max-height: 500px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
    z-index: 0;
}

.seal-watermark.visible {
    opacity: 0.02;
}

.seal-watermark.hover {
    opacity: 0.08;
}

.seal-svg {
    width: 100%;
    height: 100%;
}

/* Opening Content */
.opening-content {
    position: relative;
    z-index: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.logotype {
    font-family: var(--font-headline);
    font-weight: 600;
    font-size: clamp(2.5rem, 5vw, 5rem);
    color: var(--antique-cream);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
}

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

.horizontal-rule {
    width: 0%;
    height: 1px;
    background-color: var(--tarnished-brass);
    margin: 1.5rem 0;
    transition: width 0.6s ease-in-out;
}

.horizontal-rule.visible {
    width: 40%;
}

.tagline {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--tarnished-brass);
    letter-spacing: 0.3em;
    overflow: hidden;
    white-space: nowrap;
}

.tagline .char {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.1s ease;
}

.tagline .char.visible {
    opacity: 1;
}

/* ==========================================
   SECTION DIVIDERS
   ========================================== */
.section-divider {
    position: relative;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--judicial-navy);
    z-index: 1;
}

.divider-svg {
    width: 300px;
    max-width: 60%;
    height: auto;
}

.divider-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.8s ease-in-out;
}

.divider-path.drawn {
    stroke-dashoffset: 0;
}

/* ==========================================
   CONTENT SECTIONS
   ========================================== */
.content-section {
    position: relative;
    min-height: 80vh;
    padding: 8rem 5vw 8rem 15vw;
    max-width: 100%;
    background-color: var(--judicial-navy);
    z-index: 1;
    overflow: hidden;
}

/* Geometric Floor Band */
.floor-band {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200px;
    pointer-events: none;
    z-index: 0;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
}

.floor-svg {
    width: 100%;
    height: 100%;
}

/* Section Headings - Rotated vertical spine text */
.section-heading {
    position: absolute;
    left: 5vw;
    top: 50%;
    transform: rotate(-90deg) translateX(-50%);
    transform-origin: left center;
    font-family: var(--font-headline);
    font-weight: 500;
    font-size: clamp(1.75rem, 4vw, 3.5rem);
    font-variant: small-caps;
    letter-spacing: 0.2em;
    color: var(--antique-cream);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 2;
}

.section-heading.visible {
    opacity: 1;
}

/* Section Body */
.section-body {
    position: relative;
    max-width: 680px;
    z-index: 2;
}

.section-body p {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    color: var(--antique-cream);
    margin-bottom: 1.5em;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.section-body p.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ==========================================
   COLUMN FRAGMENTS
   ========================================== */
.column-fragment {
    position: absolute;
    z-index: 1;
    pointer-events: none;
}

.fragment-capital {
    left: 1vw;
    top: 20%;
    width: 80px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.fragment-capital.visible {
    opacity: 1;
}

.fragment-shaft {
    right: 2vw;
    top: 10%;
    width: 60px;
    height: 300px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.fragment-shaft.visible {
    opacity: 1;
}

.fragment-base {
    left: 2vw;
    bottom: 0;
    width: 100px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.fragment-base.visible {
    opacity: 1;
}

.fragment-capital-right {
    right: 1vw;
    top: 15%;
    width: 80px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.fragment-capital-right.visible {
    opacity: 1;
}

/* Path draw animation for architectural fragments */
.arch-path {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    transition: stroke-dashoffset 1.2s ease-in-out;
}

.arch-path.drawn {
    stroke-dashoffset: 0;
}

/* ==========================================
   FILING STAMPS
   ========================================== */
.filing-stamp {
    position: absolute;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--tarnished-brass);
    opacity: 0;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.2s ease;
    will-change: transform;
}

.filing-stamp.visible {
    opacity: 0.3;
}

.stamp-1 {
    right: 4vw;
    top: 15%;
    transform: rotate(-2deg);
}

.stamp-2 {
    left: 3vw;
    top: 30%;
    transform: rotate(1.5deg);
}

.stamp-3 {
    right: 5vw;
    bottom: 20%;
    transform: rotate(3deg);
}

.stamp-4 {
    right: 3vw;
    top: 25%;
    transform: rotate(-1deg);
}

.stamp-5 {
    left: 2vw;
    top: 20%;
    transform: rotate(2deg);
}

.stamp-6 {
    right: 4vw;
    bottom: 15%;
    transform: rotate(-2.5deg);
}

/* ==========================================
   CLOSING VIEWPORT: Disposition
   ========================================== */
.closing-viewport {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--marble-warm);
    z-index: 1;
}

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

.adjourned {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.5em;
    color: var(--judicial-navy);
    transition: color 0.3s ease;
    cursor: default;
}

.adjourned:hover {
    color: var(--seal-vermillion);
}

.gavel-icon {
    color: var(--tarnished-brass);
    transition: transform 0.3s ease, color 0.3s ease;
    cursor: default;
}

.gavel-icon:hover {
    transform: rotate(15deg);
    color: var(--seal-vermillion);
}

/* ==========================================
   LINK / HOVER INTERACTIONS
   ========================================== */
a {
    color: var(--tarnished-brass);
    text-decoration: none;
    position: relative;
    display: inline-block;
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--tarnished-brass);
    transition: width 0.3s ease;
}

a:hover::after {
    width: 100%;
}

/* ==========================================
   REDUCED MOTION
   ========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .logotype,
    .section-heading,
    .section-body p,
    .filing-stamp,
    .column-fragment,
    .seal-watermark,
    .horizontal-rule,
    .divider-path,
    .arch-path {
        opacity: 1 !important;
        transform: none !important;
        stroke-dashoffset: 0 !important;
    }

    .rule-of-law {
        opacity: 1 !important;
    }

    .tagline .char {
        opacity: 1 !important;
    }
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 900px) {
    .content-section {
        padding: 6rem 5vw 6rem 5vw;
    }

    .section-heading {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        transform-origin: initial;
        margin-bottom: 2rem;
    }

    .column-fragment {
        display: none;
    }

    .filing-stamp {
        display: none;
    }

    .rule-of-law {
        display: none;
    }
}

@media (max-width: 600px) {
    .opening-frame {
        width: calc(100% - 4vw);
        height: calc(100% - 4vw);
    }

    .logotype {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
    }

    .tagline {
        font-size: 0.7rem;
        letter-spacing: 0.15em;
    }

    .section-body {
        max-width: 100%;
    }
}
