/* ===================================================
   courthouse.app — Styles
   Candy-bright Scandinavian civic design
   Bento-box layout with water-bubble motifs
   =================================================== */

/* --- CSS Variables / Design Tokens --- */
:root {
    --warm-milk: #faf8f5;
    --bubble-bath: #f0eef8;
    --coral: #ff6b6b;
    --violet: #a78bfa;
    --aqua: #67e8f9;
    --gold: #fbbf24;
    --green: #6ee7b7;
    --deep-plum: #2d2b3d;
    --muted-lavender: #7b7896;
    --night-court: #3b3868;
    --body-text: #4a4862;
    --cell-radius: 16px;
    --gutter: 24px;
    --cell-gap: 12px;
    --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    color: var(--body-text);
    background: var(--warm-milk);
    overflow-x: hidden;
}

/* --- Navigation --- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: rgba(250, 248, 245, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gutter);
    z-index: 1000;
}

.nav-wordmark {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--deep-plum);
    letter-spacing: -0.02em;
}

.nav-pills {
    display: flex;
    gap: 8px;
}

.nav-pill {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 20px;
    transition: all 0.4s var(--spring);
    color: var(--deep-plum);
}

.pill-coral { background: rgba(255, 107, 107, 0.2); }
.pill-aqua { background: rgba(103, 232, 249, 0.2); }
.pill-violet { background: rgba(167, 139, 250, 0.2); }
.pill-green { background: rgba(110, 231, 183, 0.2); }

.nav-pill:hover {
    transform: translateY(-2px) scale(1.05);
}

.pill-coral:hover { background: var(--coral); color: #fff; }
.pill-aqua:hover { background: var(--aqua); color: var(--deep-plum); }
.pill-violet:hover { background: var(--violet); color: #fff; }
.pill-green:hover { background: var(--green); color: var(--deep-plum); }

/* --- Ambient Bubbles (Background) --- */
.ambient-bubbles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* --- Bento Tray Base --- */
.bento-tray {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: var(--gutter);
    padding-top: calc(48px + var(--gutter));
    display: flex;
    align-items: center;
    justify-content: center;
}

.bento-grid {
    width: 100%;
    max-width: 1200px;
    display: grid;
    gap: var(--cell-gap);
}

/* --- Bento Cell Base --- */
.bento-cell {
    border-radius: var(--cell-radius);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--spring);
    opacity: 0;
    transform: scale(0.8);
}

.bento-cell.visible {
    opacity: 1;
    transform: scale(1);
}

.bento-cell:hover {
    transform: scale(1.02);
    z-index: 2;
}

.bento-cell.visible:hover {
    transform: scale(1.02);
}

/* --- Cell Color Variants --- */
.hero-cell {
    background: var(--coral);
}

.cell-violet {
    background: var(--violet);
}

.cell-light {
    background: var(--bubble-bath);
}

.cell-aqua {
    background: var(--aqua);
}

.cell-aqua-light {
    background: var(--aqua);
    transition: all 0.4s var(--spring);
}

.cell-gold {
    background: var(--gold);
    transition: all 0.4s var(--spring);
}

.cell-dark {
    background: var(--night-court);
}

.cell-green {
    background: var(--green);
}

.cell-coral {
    background: var(--coral);
}

.cell-violet-word {
    background: var(--violet);
}

.cell-coral-light {
    background: rgba(255, 107, 107, 0.15);
}

.cell-violet-light {
    background: rgba(167, 139, 250, 0.15);
}

.cell-green-light {
    background: rgba(110, 231, 183, 0.15);
}

.cell-gold-light {
    background: rgba(251, 191, 36, 0.15);
}

.cell-dark-light {
    background: rgba(59, 56, 104, 0.1);
}

/* Hover lightening for filing cells */
.filing-cell:hover.cell-aqua-light {
    background: rgba(103, 232, 249, 0.7);
}

.filing-cell:hover.cell-gold {
    background: rgba(251, 191, 36, 0.7);
}

/* ===================================================
   TRAY 1 — The Lobby
   =================================================== */
.tray1-grid {
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(3, 1fr);
    min-height: calc(100vh - 48px - 2 * var(--gutter));
    grid-template-areas:
        "hero hero hero hero hero hero hero hero side1 side1 side1 side1"
        "hero hero hero hero hero hero hero hero side2 side2 side2 side2"
        "hero hero hero hero hero hero hero hero side3 side3 side3 side3";
}

.hero-cell {
    grid-area: hero;
    padding: 3rem;
}

.side-cell:nth-child(2) {
    grid-area: side1;
}

.side-cell:nth-child(3) {
    grid-area: side2;
}

.side-cell:nth-child(4) {
    grid-area: side3;
}

.hero-title {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 7vw, 6rem);
    color: #faf8f5;
    letter-spacing: -0.02em;
    line-height: 1.1;
    text-align: center;
}

.hero-subtitle {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: 1.2rem;
    color: #faf8f5;
    margin-top: 0.5rem;
    text-align: center;
    opacity: 0.9;
}

/* Scale of Justice (Tray 1 side cell) */
.scale-of-justice {
    width: 80%;
    max-width: 120px;
}

.scale-svg {
    width: 100%;
    height: auto;
}

.scale-beam {
    transform-origin: 60px 20px;
    animation: tiltScale 8s ease-in-out infinite;
}

.scale-bowl-left, .scale-bowl-right {
    animation: tiltScale 8s ease-in-out infinite;
}

@keyframes tiltScale {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-3deg); }
    30% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
    60% { transform: rotate(3deg); }
    80% { transform: rotate(0deg); }
}

/* Cell labels and big text */
.cell-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-lavender);
    margin-bottom: 4px;
}

.cell-big-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.8rem;
    color: var(--deep-plum);
    letter-spacing: -0.02em;
}

/* Gavel */
.gavel-icon {
    width: 60%;
    max-width: 80px;
}

.gavel-svg {
    width: 100%;
    height: auto;
    animation: gavelBounce 2s var(--spring) infinite;
}

@keyframes gavelBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-8px) rotate(-5deg); }
}

/* ===================================================
   TRAY SPACERS
   =================================================== */
.tray-spacer {
    position: relative;
    height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 1;
}

.floating-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.1));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: floatUp linear infinite;
}

.floating-bubble::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(255,107,107,0.05), rgba(167,139,250,0.05), rgba(103,232,249,0.05), rgba(110,231,183,0.05), rgba(255,107,107,0.05));
    animation: sheenRotate 6s linear infinite;
}

@keyframes floatUp {
    0% { transform: translateY(100%) translateX(0); opacity: 0; }
    10% { opacity: 0.7; }
    90% { opacity: 0.7; }
    100% { transform: translateY(-100vh) translateX(30px); opacity: 0; }
}

@keyframes sheenRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Individual bubble sizes and positions */
.fb-1 { width: 120px; height: 120px; left: 10%; animation-duration: 12s; animation-delay: 0s; }
.fb-2 { width: 80px; height: 80px; left: 30%; animation-duration: 10s; animation-delay: 2s; }
.fb-3 { width: 160px; height: 160px; left: 55%; animation-duration: 14s; animation-delay: 1s; }
.fb-4 { width: 60px; height: 60px; left: 75%; animation-duration: 9s; animation-delay: 3s; }
.fb-5 { width: 100px; height: 100px; left: 90%; animation-duration: 11s; animation-delay: 0.5s; }
.fb-6 { width: 80px; height: 80px; left: 5%; animation-duration: 10s; animation-delay: 1s; }
.fb-7 { width: 140px; height: 140px; left: 80%; animation-duration: 13s; animation-delay: 0s; }
.fb-8 { width: 60px; height: 60px; left: 25%; animation-duration: 9s; animation-delay: 2.5s; }
.fb-9 { width: 100px; height: 100px; left: 65%; animation-duration: 11s; animation-delay: 1.5s; }
.fb-10 { width: 90px; height: 90px; left: 45%; animation-duration: 12s; animation-delay: 3s; }
.fb-11 { width: 100px; height: 100px; left: 15%; animation-duration: 11s; animation-delay: 0s; }
.fb-12 { width: 140px; height: 140px; left: 50%; animation-duration: 13s; animation-delay: 1s; }
.fb-13 { width: 70px; height: 70px; left: 80%; animation-duration: 9s; animation-delay: 2s; }

/* Quote Bubble */
.quote-bubble {
    position: relative;
    z-index: 2;
    background: rgba(167, 139, 250, 0.08);
    border-radius: 50%;
    width: clamp(200px, 40vw, 360px);
    height: clamp(200px, 40vw, 360px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(167, 139, 250, 0.15);
}

.quote-text {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    font-style: italic;
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: var(--deep-plum);
    text-align: center;
    line-height: 1.6;
}

/* ===================================================
   TRAY 2 — The Filing Office (9-cell grid)
   =================================================== */
.tray2-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    min-height: calc(100vh - 48px - 2 * var(--gutter));
}

.filing-cell {
    padding: 1.5rem;
    cursor: pointer;
    min-height: 160px;
}

.doc-word {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    color: var(--deep-plum);
    text-align: center;
    transition: text-shadow 0.4s var(--spring);
}

.filing-cell:hover .doc-word {
    text-shadow: 2px 2px 8px rgba(45, 43, 61, 0.15);
}

/* --- Bubble Clusters --- */
.bubble-cluster {
    position: absolute;
    display: flex;
    gap: 3px;
}

.cluster-hero {
    top: 1.5rem;
    right: 1.5rem;
}

.cluster-corner {
    top: 10px;
    right: 10px;
    transition: all 0.4s var(--spring);
}

.filing-cell:hover .cluster-corner {
    gap: 8px;
    top: 6px;
    right: 6px;
}

.filing-cell:hover .cluster-corner .bubble {
    transform: scale(1.5);
}

.bubble {
    display: block;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.85), rgba(255,255,255,0.2));
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: transform 0.4s var(--spring);
}

.bubble-xs { width: 12px; height: 12px; }
.bubble-sm { width: 20px; height: 20px; }
.bubble-md { width: 32px; height: 32px; }
.bubble-lg { width: 48px; height: 48px; }

/* ===================================================
   TRAY 3 — The Courtroom
   =================================================== */
.tray3-grid {
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto auto;
    min-height: calc(100vh - 48px - 2 * var(--gutter));
    grid-template-areas:
        "stage stage stage stage stage stage stage stage stage stage stage stage"
        "w1 w1 w1 w1 w2 w2 w2 w2 w3 w3 w3 w3";
}

.stage-cell {
    grid-area: stage;
    min-height: 60vh;
    padding: 2rem;
}

.courtroom-scene {
    width: 100%;
    max-width: 500px;
}

.courtroom-scale-svg {
    width: 100%;
    height: auto;
}

.courtroom-beam {
    transform-origin: 200px 100px;
    animation: beamTilt 8s ease-in-out infinite;
}

@keyframes beamTilt {
    0%, 100% { transform: rotate(0deg); }
    15% { transform: rotate(-3deg); }
    25% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
    60% { transform: rotate(3deg); }
    85% { transform: rotate(0deg); }
}

/* Rising bubbles in courtroom SVG */
.rising-bubble {
    animation: riseBubble 3s ease-in-out infinite;
}

.rb-1 { animation-delay: 0s; }
.rb-2 { animation-delay: 0.8s; }
.rb-3 { animation-delay: 1.6s; }
.rb-4 { animation-delay: 0.3s; }
.rb-5 { animation-delay: 1.1s; }
.rb-6 { animation-delay: 1.9s; }

@keyframes riseBubble {
    0% { opacity: 0; transform: translateY(0); }
    30% { opacity: 0.4; }
    70% { opacity: 0.2; }
    100% { opacity: 0; transform: translateY(-30px); }
}

.word-cell:nth-child(2) { grid-area: w1; }
.word-cell:nth-child(3) { grid-area: w2; }
.word-cell:nth-child(4) { grid-area: w3; }

.word-cell {
    padding: 2rem;
    min-height: 120px;
}

.word-big {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: -0.02em;
    color: var(--deep-plum);
}

.cell-green .word-big { color: var(--deep-plum); }
.cell-coral .word-big { color: #faf8f5; }
.cell-violet-word .word-big { color: #faf8f5; }

/* ===================================================
   TRAY 4 — The Gallery
   =================================================== */
.tray4-grid {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto;
    min-height: calc(100vh - 48px - 2 * var(--gutter));
}

.gallery-cell {
    padding: 2rem;
    min-height: 200px;
    cursor: pointer;
    position: relative;
}

/* Pop Bubbles (Gallery) */
.pop-bubbles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

.pop-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(255,255,255,0.25));
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    pointer-events: all;
    transition: transform 0.3s var(--spring), opacity 0.2s ease;
}

.pop-bubble::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(255,107,107,0.08), rgba(167,139,250,0.08), rgba(103,232,249,0.08), rgba(110,231,183,0.08), rgba(255,107,107,0.08));
    animation: sheenRotate 4s linear infinite;
}

.pop-bubble.popped {
    transform: scale(1.5) !important;
    opacity: 0 !important;
    pointer-events: none;
    transition: transform 0.2s ease-out, opacity 0.15s ease-out 0.05s;
}

/* Reveal Content (Gallery) */
.reveal-content {
    opacity: 0;
    transition: opacity 0.6s ease;
    text-align: center;
    z-index: 1;
}

.reveal-content.revealed {
    opacity: 1;
}

.reveal-text {
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--body-text);
    line-height: 1.65;
    margin-top: 8px;
}

.gallery-cell .cell-label {
    color: var(--body-text);
    font-size: 13px;
}

/* ===================================================
   FINAL SECTION
   =================================================== */
.final-section {
    position: relative;
    z-index: 1;
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem var(--gutter);
    text-align: center;
}

.final-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    color: var(--deep-plum);
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 2rem;
}

.final-bubble {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.85), rgba(255,255,255,0.15));
    border: 2px solid rgba(255, 255, 255, 0.4);
    cursor: pointer;
    position: relative;
    transition: transform 0.4s var(--spring);
    box-shadow: 0 8px 32px rgba(59, 56, 104, 0.1);
}

.final-bubble:hover {
    transform: scale(1.08);
}

.final-bubble-sheen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
        rgba(255, 107, 107, 0.12),
        rgba(167, 139, 250, 0.12),
        rgba(103, 232, 249, 0.12),
        rgba(110, 231, 183, 0.12),
        rgba(251, 191, 36, 0.12),
        rgba(255, 107, 107, 0.12)
    );
    animation: sheenRotate 6s linear infinite;
}

/* Celebration Bubbles */
.celebration-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.celebration-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.15));
    animation: celebrateBubble 2s var(--spring) forwards;
}

@keyframes celebrateBubble {
    0% { transform: scale(0); opacity: 1; }
    50% { opacity: 0.8; }
    100% { transform: scale(1) translateY(-100px); opacity: 0; }
}

/* ===================================================
   SCROLL-TRIGGERED MICRO BUBBLES
   =================================================== */
.micro-bubble {
    position: fixed;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8), rgba(255,255,255,0.15));
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 100;
    animation: microRise 1.5s var(--spring) forwards;
}

@keyframes microRise {
    0% { transform: translateY(0) scale(0.5); opacity: 0.8; }
    100% { transform: translateY(-120px) scale(1); opacity: 0; }
}

/* ===================================================
   RESPONSIVE
   =================================================== */
@media (max-width: 900px) {
    .tray1-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        grid-template-areas:
            "hero"
            "side1"
            "side2"
            "side3";
    }

    .hero-cell {
        min-height: 50vh;
    }

    .side-cell {
        min-height: 120px;
    }

    .tray2-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tray3-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        grid-template-areas:
            "stage"
            "w1"
            "w2"
            "w3";
    }

    .stage-cell {
        min-height: 40vh;
    }

    .tray4-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-pills {
        display: none;
    }
}

@media (max-width: 600px) {
    .tray2-grid {
        grid-template-columns: 1fr;
    }

    .tray4-grid {
        grid-template-columns: 1fr;
    }

    .quote-bubble {
        width: 80vw;
        height: 80vw;
    }
}
