/* ============================================
   CORVELL — Styles
   ============================================ */

/* Reset and Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    background-color: #0a0a0a;
    font-family: 'Lora', serif;
    color: #e8d7c3;
    overflow: hidden;
}

/* Smooth fade-in for neighborhood polygons when styles change */
.leaflet-interactive {
    transition: fill-opacity 0.6s ease, stroke-opacity 0.6s ease, stroke-width 0.3s ease;
}

/* ============================================
   MAP & OVERLAY
   ============================================ */

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Leaflet defaults */
.leaflet-container {
    background-color: #0a0a0a;
    font-family: 'Lora', serif;
}

/* Hide default zoom controls */
.leaflet-top.leaflet-left,
.leaflet-top.leaflet-right {
    display: none;
}

/* Attribution styling */
.leaflet-attribution {
    background-color: rgba(10, 10, 10, 0.7) !important;
    color: #8b7355 !important;
    font-size: 10px !important;
}

.leaflet-attribution a {
    color: #d4a574 !important;
}

/* Warm amber overlay (subtle tint) */
#map::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(212, 165, 116, 0.06);
    pointer-events: none;
    z-index: 10;
}

/* Vignette effect */
#map::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    z-index: 9;
}

/* ── Entrance mask — starts fully black, dissolves to reveal the city ── */
.globe-mask {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 8;
    pointer-events: none;
    background: radial-gradient(
        ellipse 80% 75% at 50% 50%,
        rgba(0, 0, 0, 0.7) 0%,
        rgba(0, 0, 0, 0.85) 40%,
        rgba(0, 0, 0, 0.95) 65%,
        #0a0a0a 85%
    );
    opacity: 1;
    transition: opacity 2s ease-out;
}

.globe-mask.dissolve {
    opacity: 0;
}

/* Warm rim glow — appears as the mask dissolves, like light leaking in */
.globe-rim {
    position: fixed;
    top: 50%; left: 50%;
    width: 100vw;
    height: 100vh;
    transform: translate(-50%, -50%);
    border-radius: 40%;
    box-shadow: inset 0 0 150px rgba(212, 165, 116, 0.06),
                inset 0 0 60px rgba(212, 165, 116, 0.03);
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease-in 0.3s;
}

.globe-rim.dissolve {
    opacity: 1;
}

/* Rim fades out after a few seconds */
.globe-rim.fade-out {
    opacity: 0;
    transition: opacity 1.5s ease-out;
}

.globe-rim.dissolve {
    opacity: 0;
}

/* Radial glow that pulses during arrival */
.entrance-glow {
    position: fixed;
    top: 50%; left: 50%;
    width: 100vw; height: 100vh;
    transform: translate(-50%, -50%) scale(0.2);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 165, 116, 0.12) 0%, rgba(212, 165, 116, 0.06) 40%, transparent 70%);
    z-index: 55;
    pointer-events: none;
    opacity: 0;
}

.entrance-glow.active {
    animation: glowPulseEntrance 2.5s ease-out forwards;
}

@keyframes glowPulseEntrance {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
    25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
    50%  { opacity: 0.6; transform: translate(-50%, -50%) scale(1.8); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(3); }
}

/* Scanline sweep — a thin horizontal light that sweeps down during zoom */
.entrance-scanline {
    position: fixed;
    top: -2px; left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(212, 165, 116, 0.4) 30%, rgba(212, 165, 116, 0.6) 50%, rgba(212, 165, 116, 0.4) 70%, transparent 100%);
    z-index: 56;
    pointer-events: none;
    opacity: 0;
}

.entrance-scanline.active {
    animation: scanSweep 1.8s ease-in-out forwards;
}

@keyframes scanSweep {
    0%   { top: -2px; opacity: 0; }
    10%  { opacity: 0.8; }
    90%  { opacity: 0.5; }
    100% { top: 100%; opacity: 0; }
}

/* ============================================
   PARTICLE CANVAS
   ============================================ */

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

/* ============================================
   BRANDING (Top-Left)
   ============================================ */

.branding {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 1000;
    cursor: default;
}

.branding-title {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 400;
    color: #d4a574;
    letter-spacing: 3px;
    opacity: 0;
    transform: translateY(8px);
    /* Entrance animation triggered by JS adding .entrance-ready */
}

.branding-title.loaded {
    transition: opacity 0.3s ease;
}

.branding:hover .branding-title.loaded {
    opacity: 1;
}

.branding-tagline {
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    font-style: italic;
    color: #d4a574;
    opacity: 0;
    margin-top: 8px;
    transform: translateY(6px);
    /* Entrance animation triggered by JS adding .entrance-ready */
}

.branding-tagline.loaded {
    transition: opacity 0.3s ease;
}

.branding:hover .branding-tagline.loaded {
    opacity: 0.6;
}

.branding-title.entrance-ready {
    animation: brandingIn 1.2s ease forwards;
}

.branding-tagline.entrance-ready {
    animation: brandingIn 1s ease forwards;
    animation-delay: 0.4s;
}

.counter.entrance-ready {
    animation: counterIn 1s ease forwards;
    animation-delay: 0.6s;
}

@keyframes brandingIn {
    to {
        opacity: 0.5;
        transform: translateY(0);
    }
}

/* ============================================
   COUNTER (Bottom-Left)
   ============================================ */

.counter {
    position: fixed;
    bottom: 30px;
    left: 30px;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    color: #8b7355;
    z-index: 1000;
    opacity: 0;
    transform: translateY(6px);
    /* Entrance animation triggered by JS */
}

@keyframes counterIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.counter-number {
    color: #d4a574;
    font-weight: 600;
    font-size: 18px;
    line-height: 1;
    margin-bottom: 4px;
}

/* ============================================
   BACK BUTTON (Top-Right)
   ============================================ */

.back-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 1000;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    color: #d4a574;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.back-btn.visible {
    opacity: 0.8;
    pointer-events: auto;
}

.back-btn:hover {
    color: #ffd89b;
}

/* ============================================
   NEIGHBORHOOD LABELS (via Leaflet)
   ============================================ */

.neighborhood-label {
    text-align: center;
    pointer-events: none !important;
    z-index: 100;
    transition: opacity 0.4s ease;
}

.neighborhood-name {
    font-family: 'Crimson Text', serif;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: opacity 0.4s ease;
}

/* Neighborhoods WITH stories: warm amber, prominent */
.neighborhood-label.has-stories .neighborhood-name {
    color: #d4a574;
    opacity: 0.7;
    font-size: 13px;
}

/* Neighborhoods WITHOUT stories: cool slate, equally visible */
.neighborhood-label.no-stories .neighborhood-name {
    color: #8a9baa;
    opacity: 0.7;
    font-size: 12px;
    letter-spacing: 1.5px;
}

.neighborhood-count {
    font-family: 'Crimson Text', serif;
    font-size: 11px;
    color: #8b7355;
    margin-top: 2px;
    transition: opacity 0.4s ease;
}

/* Sub-neighborhood labels — smaller, italic, slightly different feel */
.neighborhood-label.sub-label .neighborhood-name.sub-name {
    font-size: 10px;
    letter-spacing: 1.5px;
    font-style: italic;
    opacity: 0.8;
}

.neighborhood-label.sub-label.has-stories .neighborhood-name.sub-name {
    color: #d4a574;
}

.neighborhood-label.sub-label.no-stories .neighborhood-name.sub-name {
    color: #8a9baa;
}

/* ============================================
   STORY MARKERS (Dots & Rings)
   ============================================ */

/* Story markers — SVG circle markers that stay locked to coordinates during zoom */
.marker-circle {
    cursor: pointer;
    transition: fill-opacity 0.5s ease, stroke-opacity 0.5s ease, r 0.3s ease;
    filter: drop-shadow(0 0 6px rgba(212, 165, 116, 0.8))
            drop-shadow(0 0 12px rgba(212, 165, 116, 0.4));
}

.marker-circle:hover {
    filter: drop-shadow(0 0 10px rgba(212, 165, 116, 1))
            drop-shadow(0 0 20px rgba(212, 165, 116, 0.6));
}

.marker-glow-ring {
    pointer-events: none;
    transition: fill-opacity 0.5s ease, stroke-opacity 0.5s ease;
    animation: svg-pulse 3s ease-in-out infinite;
}

@keyframes svg-pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 0.2;
    }
}

/* ============================================
   TOOLTIP
   ============================================ */

.tooltip {
    position: fixed;
    z-index: 2000;
    background-color: rgba(20, 16, 12, 0.96);
    border: 1px solid rgba(212, 165, 116, 0.25);
    border-radius: 8px;
    padding: 14px 18px;
    max-width: 260px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tooltip.visible {
    opacity: 1;
}

.tooltip-name {
    font-family: 'Playfair Display', serif;
    font-size: 14px;
    color: #d4a574;
    font-weight: 600;
    margin-bottom: 4px;
}

.tooltip-neighborhood {
    font-family: 'Crimson Text', serif;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8b7355;
    margin-bottom: 8px;
}

.tooltip-preview {
    font-family: 'Lora', serif;
    font-size: 12px;
    font-style: italic;
    color: #b8a898;
    line-height: 1.5;
}

/* ============================================
   PREVIEW CARD (Bottom-Center)
   ============================================ */

.preview-card {
    position: fixed;
    bottom: 60px;
    left: 50%;
    width: 520px;
    transform: translateX(-50%) translateY(30px);
    background-color: rgba(22, 18, 14, 0.96);
    border: 1px solid rgba(212, 165, 116, 0.25);
    border-radius: 12px;
    padding: 32px;
    z-index: 1500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.preview-card.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.preview-card-name {
    font-family: 'Playfair Display', serif;
    font-size: 26px;
    color: #d4a574;
    font-weight: 600;
    margin-bottom: 8px;
}

.preview-card-meta {
    font-family: 'Crimson Text', serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #8b7355;
    margin-bottom: 14px;
}

.preview-card-stars {
    color: #d4a574;
    font-size: 16px;
    letter-spacing: 3px;
    margin-bottom: 14px;
}

.preview-card-text {
    font-family: 'Lora', serif;
    font-size: 14px;
    color: #c9b8a8;
    line-height: 1.7;
    margin-bottom: 18px;
}

.preview-card-link {
    display: inline-block;
    font-family: 'Crimson Text', serif;
    font-size: 13px;
    color: #d4a574;
    border-bottom: 1px solid rgba(212, 165, 116, 0.3);
    cursor: pointer;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.preview-card-link:hover {
    color: #ffd89b;
    border-bottom-color: rgba(255, 216, 155, 0.5);
}

/* ============================================
   STORY PANEL OVERLAY
   ============================================ */

.story-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    z-index: 2500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

.story-panel-overlay.visible {
    background-color: rgba(0, 0, 0, 0.4);
    opacity: 1;
    pointer-events: auto;
}

/* ============================================
   STORY PANEL (Right Side)
   ============================================ */

.story-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 440px;
    height: 100%;
    background-color: rgba(22, 18, 14, 0.98);
    border-left: 1px solid rgba(212, 165, 116, 0.15);
    z-index: 3000;
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.story-panel.visible {
    transform: translateX(0);
}

/* Custom scrollbar for story panel */
.story-panel::-webkit-scrollbar {
    width: 5px;
}

.story-panel::-webkit-scrollbar-track {
    background: transparent;
}

.story-panel::-webkit-scrollbar-thumb {
    background-color: rgba(212, 165, 116, 0.4);
    border-radius: 10px;
}

.story-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(212, 165, 116, 0.6);
}

.story-panel-content {
    padding: 60px 32px 40px 32px;
}

.story-panel-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(212, 165, 116, 0.08);
    border: 1px solid rgba(212, 165, 116, 0.15);
    color: #d4a574;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 3001;
}

.story-panel-close:hover {
    background-color: rgba(212, 165, 116, 0.15);
    transform: rotate(90deg);
}

/* Expand button */
.story-panel-expand {
    position: absolute;
    top: 24px;
    right: 70px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(212, 165, 116, 0.08);
    border: 1px solid rgba(212, 165, 116, 0.15);
    color: #d4a574;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 3001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-panel-expand:hover {
    background-color: rgba(212, 165, 116, 0.15);
}

/* ── Full-screen reader mode ── */
.story-panel.fullscreen {
    width: 100%;
    border-left: none;
    background-color: rgba(15, 12, 10, 0.99);
}

.story-panel.fullscreen .story-panel-content {
    max-width: 620px;
    margin: 0 auto;
    padding: 80px 40px 60px 40px;
}

.story-panel.fullscreen .story-panel-name {
    font-size: 42px;
    margin-bottom: 12px;
}

.story-panel.fullscreen .story-panel-meta {
    font-size: 12px;
    letter-spacing: 2px;
}

.story-panel.fullscreen .story-panel-stars {
    font-size: 18px;
    letter-spacing: 4px;
}

.story-panel.fullscreen .story-panel-divider {
    width: 60px;
    margin-bottom: 32px;
}

.story-panel.fullscreen .story-panel-text {
    font-size: 18px;
    line-height: 2;
}

.story-panel.fullscreen .story-paragraph {
    margin-bottom: 28px;
}

.story-panel-name {
    font-family: 'Playfair Display', serif;
    font-size: 32px;
    color: #d4a574;
    margin-bottom: 8px;
    font-weight: 600;
}

.story-panel-meta {
    font-family: 'Crimson Text', serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #8b7355;
}

.story-panel-stars {
    color: #d4a574;
    font-size: 16px;
    letter-spacing: 3px;
    margin: 12px 0 20px 0;
}

.story-panel-divider {
    width: 40px;
    height: 1px;
    background-color: rgba(212, 165, 116, 0.3);
    margin-bottom: 24px;
}

.story-panel-text {
    font-family: 'Lora', serif;
    font-size: 15px;
    color: #c9b8a8;
    line-height: 1.9;
}

.story-paragraph {
    margin-bottom: 20px;
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.story-paragraph:nth-child(1) {
    animation-delay: 0s;
}

.story-paragraph:nth-child(2) {
    animation-delay: 0.1s;
}

.story-paragraph:nth-child(3) {
    animation-delay: 0.2s;
}

.story-paragraph:nth-child(4) {
    animation-delay: 0.3s;
}

.story-paragraph:nth-child(5) {
    animation-delay: 0.4s;
}

.story-paragraph:nth-child(n+6) {
    animation-delay: 0.5s;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.story-drop-cap {
    float: left;
    font-family: 'Playfair Display', serif;
    font-size: 56px;
    line-height: 44px;
    padding-right: 10px;
    color: #d4a574;
    font-weight: 700;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .preview-card {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
        transform: translateX(0) translateY(30px);
        padding: 24px;
    }

    .preview-card.visible {
        transform: translateX(0) translateY(0);
    }

    .preview-card-name {
        font-size: 22px;
    }

    .preview-card-text {
        font-size: 12px;
    }

    .story-panel {
        width: 100%;
    }

    .story-panel-name {
        font-size: 26px;
    }

    .story-panel-content {
        padding: 60px 24px 40px 24px;
    }

    .story-panel-text {
        font-size: 14px;
    }

    .branding-title {
        font-size: 24px;
    }

    .counter {
        font-size: 11px;
    }

    .counter-number {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .branding {
        top: 20px;
        left: 20px;
    }

    .counter {
        bottom: 20px;
        left: 20px;
    }

    .back-btn {
        top: 20px;
        right: 20px;
        font-size: 11px;
    }

    .preview-card {
        bottom: 40px;
    }

    .branding-title {
        font-size: 20px;
        letter-spacing: 2px;
    }
}
