/* judge.quest - Dreamy Digital Courtroom */
/* Colors: #1a3a4a, #7fb5c4, #e8d2af, #c9a96e, #f4f0ec, #0f2832, #d4e8ed, #d4a08a, #2a5a6a, #2a4a56 */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'EB Garamond', Georgia, serif;
    background: #0f2832;
    color: #2a4a56;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== BACKGROUND LAYER (z:0) ===== */
.background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(165deg, #1a3a4a 0%, #2a5a6a 35%, #7fb5c4 70%, #e8d2af 100%);
    background-size: 200% 200%;
    animation: gradient-shift 20s ease infinite;
}

@keyframes gradient-shift {
    0% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

.bg-circuits {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 400%;
    opacity: 0.05;
}

.circuit-bg-path {
    fill: none;
    stroke: #7fb5c4;
    stroke-width: 0.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.circuit-node {
    fill: #c9a96e;
    opacity: 0.15;
    animation: node-pulse 8s ease-in-out infinite;
}

.circuit-node:nth-child(even) {
    animation-delay: -4s;
}

.circuit-node:nth-child(3n) {
    animation-delay: -2.5s;
}

@keyframes node-pulse {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.35; }
}

/* ===== MIDGROUND LAYER (z:1) ===== */
.midground-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.mid-shape {
    position: absolute;
    border-radius: 45% 55% 50% 50%;
    background: radial-gradient(ellipse, rgba(127, 181, 196, 0.15) 0%, transparent 70%);
    animation: drift-x 30s ease-in-out infinite, drift-y 25s ease-in-out infinite;
}

.shape-1 {
    width: 400px; height: 350px;
    top: 10%; left: -5%;
    animation-delay: 0s, -3s;
}
.shape-2 {
    width: 300px; height: 280px;
    top: 30%; right: -8%;
    background: radial-gradient(ellipse, rgba(232, 210, 175, 0.08) 0%, transparent 70%);
    animation-delay: -5s, -8s;
    border-radius: 50% 40% 55% 45%;
}
.shape-3 {
    width: 500px; height: 400px;
    top: 50%; left: 10%;
    animation-delay: -10s, -12s;
}
.shape-4 {
    width: 250px; height: 220px;
    top: 70%; right: 5%;
    background: radial-gradient(ellipse, rgba(232, 210, 175, 0.10) 0%, transparent 70%);
    animation-delay: -15s, -7s;
    border-radius: 55% 45% 40% 60%;
}
.shape-5 {
    width: 350px; height: 300px;
    top: 20%; left: 50%;
    animation-delay: -20s, -15s;
    border-radius: 40% 60% 50% 50%;
}
.shape-6 {
    width: 200px; height: 180px;
    top: 85%; left: 25%;
    animation-delay: -8s, -20s;
}
.shape-7 {
    width: 450px; height: 380px;
    top: 5%; right: 15%;
    background: radial-gradient(ellipse, rgba(127, 181, 196, 0.10) 0%, transparent 70%);
    animation-delay: -12s, -5s;
    border-radius: 50% 50% 40% 60%;
}
.shape-8 {
    width: 280px; height: 260px;
    top: 60%; left: 40%;
    background: radial-gradient(ellipse, rgba(232, 210, 175, 0.06) 0%, transparent 70%);
    animation-delay: -18s, -10s;
}

@keyframes drift-x {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(20px); }
}

@keyframes drift-y {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(15px); }
}

/* ===== FLOATING ORBS ===== */
.orbs-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    backdrop-filter: blur(4px);
    animation: float-up linear infinite;
}

.orb-1 { width: 8px; height: 8px; background: rgba(127, 181, 196, 0.20); left: 15%; bottom: -20px; animation-duration: 45s; animation-delay: 0s; }
.orb-2 { width: 14px; height: 14px; background: rgba(232, 210, 175, 0.15); left: 35%; bottom: -20px; animation-duration: 52s; animation-delay: -5s; }
.orb-3 { width: 6px; height: 6px; background: rgba(127, 181, 196, 0.25); left: 55%; bottom: -20px; animation-duration: 40s; animation-delay: -12s; }
.orb-4 { width: 20px; height: 20px; background: rgba(232, 210, 175, 0.10); left: 75%; bottom: -20px; animation-duration: 58s; animation-delay: -20s; }
.orb-5 { width: 10px; height: 10px; background: rgba(127, 181, 196, 0.18); left: 25%; bottom: -20px; animation-duration: 48s; animation-delay: -8s; }
.orb-6 { width: 16px; height: 16px; background: rgba(232, 210, 175, 0.12); left: 65%; bottom: -20px; animation-duration: 55s; animation-delay: -15s; }
.orb-7 { width: 7px; height: 7px; background: rgba(127, 181, 196, 0.22); left: 45%; bottom: -20px; animation-duration: 42s; animation-delay: -25s; }
.orb-8 { width: 24px; height: 24px; background: rgba(127, 181, 196, 0.10); left: 85%; bottom: -20px; animation-duration: 60s; animation-delay: -30s; }
.orb-9 { width: 12px; height: 12px; background: rgba(232, 210, 175, 0.16); left: 10%; bottom: -20px; animation-duration: 50s; animation-delay: -18s; }
.orb-10 { width: 9px; height: 9px; background: rgba(127, 181, 196, 0.20); left: 90%; bottom: -20px; animation-duration: 46s; animation-delay: -35s; }

@keyframes float-up {
    from { transform: translateY(0); }
    to { transform: translateY(-120vh); }
}

/* ===== FOREGROUND LAYER (z:2) ===== */
.foreground-layer {
    position: relative;
    z-index: 3;
}

/* ===== CHAMBER 1: HERO ===== */
.chamber-1 {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 40px 20px;
}

.hero-content {
    text-align: center;
    max-width: 800px;
}

.hero-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(4rem, 10vw, 8rem);
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: -0.03em;
    line-height: 1.08;
    margin-bottom: 32px;
    opacity: 0;
    animation: title-appear 2s ease-out 0.5s forwards;
}

.hero-subtitle {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: rgba(232, 210, 175, 0.88);
    max-width: 560px;
    margin: 0 auto;
    opacity: 0;
    animation: title-appear 2s ease-out 1.2s forwards;
}

@keyframes title-appear {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Gavel Ripple */
.gavel-ripple {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    opacity: 0;
}

.gavel-ripple.active {
    opacity: 1;
}

.ripple-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 1px solid rgba(201, 169, 110, 0.3);
    border-radius: 50%;
    opacity: 0;
}

.gavel-ripple.active .ripple-1 {
    animation: ripple-expand 3s ease-out forwards;
}
.gavel-ripple.active .ripple-2 {
    animation: ripple-expand 3s ease-out 0.4s forwards;
}
.gavel-ripple.active .ripple-3 {
    animation: ripple-expand 3s ease-out 0.8s forwards;
}

@keyframes ripple-expand {
    0% { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(3); opacity: 0; }
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fade-in 1s ease-out 6s forwards;
}

.chevron {
    width: 30px;
    height: 30px;
    border-right: 2px solid rgba(232, 210, 175, 0.6);
    border-bottom: 2px solid rgba(232, 210, 175, 0.6);
    transform: rotate(45deg);
    animation: chevron-pulse 2s ease-in-out infinite;
}

@keyframes chevron-pulse {
    0%, 100% { opacity: 0.4; transform: rotate(45deg) translateY(0); }
    50% { opacity: 1; transform: rotate(45deg) translateY(6px); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== CHAMBER 2: DELIBERATION HALL ===== */
.chamber-2 {
    padding: 80px 20px 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 120px;
}

/* ===== GLASS CARDS ===== */
.glass-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(31, 78, 94, 0.12);
    padding: 48px 40px;
    max-width: 720px;
    width: 100%;
    position: relative;
    overflow: hidden;
    transform: perspective(1200px) rotateY(90deg);
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.23, 1.0, 0.32, 1.0), opacity 0.8s cubic-bezier(0.23, 1.0, 0.32, 1.0);
}

.glass-card.visible {
    transform: perspective(1200px) rotateY(0deg);
    opacity: 1;
}

/* Solid fallback for no backdrop-filter support */
@supports not (backdrop-filter: blur(24px)) {
    .glass-card {
        background: rgba(26, 58, 74, 0.9);
    }
}

.glass-card h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    color: rgba(255, 255, 255, 0.92);
    letter-spacing: -0.02em;
    line-height: 1.08;
    margin-bottom: 24px;
    margin-top: 12px;
}

.glass-card p {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1.05rem, 1.8vw, 1.2rem);
    line-height: 1.72;
    letter-spacing: 0.005em;
    color: rgba(232, 210, 175, 0.88);
}

/* Card Circuit Border */
.card-circuit-border {
    width: 100%;
    height: 4px;
    display: block;
    margin-bottom: 8px;
}

.card-circuit-path {
    fill: none;
    stroke: #c9a96e;
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.25;
}

.card-circuit-node {
    fill: #c9a96e;
    opacity: 0.25;
}

/* ===== CARD-FLIP PAIRS ===== */
.card-flip-pair {
    display: flex;
    align-items: stretch;
    gap: 0;
    max-width: 720px;
    width: 100%;
    position: relative;
}

.pair-card {
    flex: 1;
    max-width: none;
    border-radius: 16px;
}

.pair-left {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.pair-right {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.pair-gap {
    width: 8px;
    min-width: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.gap-circuit {
    width: 40px;
    height: 100%;
    position: absolute;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.gap-circuit-path {
    fill: none;
    stroke: #c9a96e;
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.6;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 0.6s ease;
}

.gap-node {
    fill: #c9a96e;
    opacity: 0;
    transition: opacity 0.6s ease 0.3s;
}

.card-flip-pair:hover .pair-left.visible {
    transform: perspective(1200px) rotateY(12deg);
}

.card-flip-pair:hover .pair-right.visible {
    transform: perspective(1200px) rotateY(-12deg);
}

.card-flip-pair:hover .gap-circuit {
    opacity: 1;
}

.card-flip-pair:hover .gap-circuit-path {
    stroke-dashoffset: 0;
}

.card-flip-pair:hover .gap-node {
    opacity: 0.8;
}

/* ===== CHAMBER 3: DEEP VERDICT ===== */
.chamber-3 {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 80px 20px;
}

.verdict-watermark {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(6rem, 14vw, 12rem);
    color: #c9a96e;
    opacity: 0.08;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    letter-spacing: 0.1em;
    pointer-events: none;
    z-index: 0;
}

.convergence-node {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    z-index: 1;
    pointer-events: none;
}

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

.convergence-circle {
    fill: none;
    stroke: #c9a96e;
    stroke-width: 1;
    opacity: 0.4;
    animation: convergence-pulse 4s ease-in-out infinite;
}

.convergence-trace {
    fill: none;
    stroke: #c9a96e;
    stroke-width: 0.8;
    stroke-linecap: round;
    opacity: 0.25;
}

@keyframes convergence-pulse {
    0%, 100% { opacity: 0.2; stroke-width: 1; }
    50% { opacity: 0.5; stroke-width: 1.5; }
}

.verdict-card {
    position: relative;
    z-index: 2;
    text-align: center;
}

.verdict-card h2 {
    font-size: clamp(2rem, 4vw, 3.2rem);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .card-flip-pair {
        flex-direction: column;
        gap: 16px;
    }

    .pair-left, .pair-right {
        border-radius: 16px;
    }

    .pair-gap {
        width: 100%;
        height: 40px;
        min-width: auto;
    }

    .gap-circuit {
        width: 100%;
        height: 40px;
        position: relative;
    }

    .glass-card {
        padding: 32px 24px;
    }

    .chamber-2 {
        gap: 80px;
    }

    .card-flip-pair:hover .pair-left.visible,
    .card-flip-pair:hover .pair-right.visible {
        transform: perspective(1200px) rotateY(0deg);
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }

    .glass-card {
        padding: 24px 18px;
    }

    .chamber-2 {
        gap: 60px;
        padding: 60px 16px 80px;
    }
}