/*
File: index.css
*/

:root {
    --bg-color: #f4f7f6;
    --panel-bg: #ffffff;
    --border-color: #dddddd;
    --text-color: #333333;
    --hover-bg: #eef2f5;
    --banner-bg: #0078d7;
    --topic-accent: #0078d7;
    --curtain-footer-tint: color-mix(in srgb, var(--topic-accent) 74%, #000 26%);
    --banner-gap: 16px;
    --banner-side-gap: 16px;
}

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

body {
    margin: 0; padding: 0; font-family: 'PeydaFaNumWeb', Tahoma, sans-serif !important;
    display: flex; flex-direction: column; height: 100vh; height: var(--vvh, 100dvh);
    background-color: var(--bg-color); color: var(--text-color); overflow: hidden;
}

/* Requirement 1: Map lives behind the banner natively */
#main-content { 
    display: flex; 
    flex-grow: 1; 
    overflow: hidden; 
    position: relative;
    margin-top: 0; /* Ensures map container takes full screen height, rendering behind floating banner */
}

#top-banner { 
    position: absolute; 
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    height: 75px; 
    flex-shrink: 0; 
    background: transparent; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 25px; 
    color: #ffffff; 
    z-index: 2000; 
    box-shadow: none; 
    transition: top 0.9s cubic-bezier(0.22, 1, 0.36, 1), left 0.9s cubic-bezier(0.22, 1, 0.36, 1), right 0.9s cubic-bezier(0.22, 1, 0.36, 1), width 0.9s cubic-bezier(0.22, 1, 0.36, 1), border-radius 0.9s cubic-bezier(0.22, 1, 0.36, 1), background 0.6s ease; 
    border-radius: 0; 
}

#top-banner::before {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    background: var(--banner-bg); z-index: -1;
    box-shadow: none; transition: background 0.6s ease, box-shadow 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

html.atlas-view #top-banner {
    top: var(--banner-gap);
    left: var(--banner-side-gap);
    right: var(--banner-side-gap);
    width: calc(100% - 2 * var(--banner-side-gap));
    border-radius: 12px;
}

html.atlas-view #top-banner::before {
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}

#entry-view-curtain {
    position: absolute; top: 0; left: 0; width: 100%; height: 100vh; height: var(--vvh, 100dvh);
    background: var(--banner-bg); z-index: 1500;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    backface-visibility: hidden;
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
    overflow: hidden;
    padding: 0; border-radius: 0;
    --fade-stop: var(--topic-accent, #0078d7);
    --curtain-banner-h: 75px;
}

.perspective-grid {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    perspective: 2000px;
    border-radius: inherit;
}

.perspective-grid-plane {
    --grid-size: 28;
    position: absolute;
    width: 80rem;
    aspect-ratio: 1 / 1;
    left: 50%;
    top: 50%;
    display: grid;
    grid-template-columns: repeat(28, 1fr);
    grid-template-rows: repeat(28, 1fr);
    transform-origin: center center;
    transform: translate(-50%, -50%) rotateX(30deg) rotateY(-5deg) rotateZ(20deg) scale(2);
    pointer-events: auto;
}

.perspective-grid-tile {
    min-width: 1px;
    min-height: 1px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: transparent;
    transition: background-color 0.35s ease;
}

.perspective-grid-tile:hover {
    background-color: rgba(255, 255, 255, 0.32);
    transition-duration: 0s;
}

.perspective-grid-fade {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(circle, transparent 25%, var(--fade-stop) 80%);
}

html.atlas-view #entry-view-curtain,
#entry-view-curtain.curtain-up { 
    transform: translate3d(0, -100%, 0);
    pointer-events: none;
    /* This timing is used when the curtain comes back down. */
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    transition-duration: 0.9s;
}

.entry-scroll {
    position: absolute;
    top: var(--curtain-banner-h, 75px);
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    margin-top: 0;
    color: #ffffff;
    pointer-events: auto;
    overflow: hidden;
    overscroll-behavior: none;
}
.entry-hero {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px 40px;
    box-sizing: border-box;
    pointer-events: none;
    text-align: center;
}
.entry-header-texts { text-align: center; margin-bottom: 28px; }
.entry-main-title { font-size: 2.2rem; font-weight: 800; color: #ffffff; margin: 0; }

.entry-search-container { position: relative; width: 100%; max-width: 600px; margin-bottom: 0; pointer-events: auto; }
.entry-search-box { display: flex; align-items: center; background: #fff; border: 2px solid #0078d7; border-radius: 10px; padding: 5px 15px; box-shadow: 0 8px 20px rgba(0,120,215,0.15); }
.entry-search-box .search-icon { width: 24px; height: 24px; color: #0078d7; margin-left: 10px; }
.entry-search-box input { flex-grow: 1; border: none; outline: none; padding: 12px 0; font-size: 1.1rem; font-family: inherit; background: transparent; }

.entry-suggestions { position: absolute; top: 100%; left: 0; right: 0; background: #fff; color: #1e293b; border-radius: 8px; margin-top: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); max-height: 250px; overflow-y: auto; z-index: 10; list-style: none; padding: 0; display: none; border: 1px solid var(--border-color); }
.entry-suggestions li { padding: 12px 20px; cursor: pointer; border-bottom: 1px solid #eee; transition: background 0.2s; font-size: 1rem; color: #1e293b; line-height: 1.7; text-align: right; white-space: normal; overflow-wrap: break-word; }
.entry-suggestions li strong { color: #0078d7; font-weight: 800; }
.entry-suggestions li:last-child { border-bottom: none; }
.entry-suggestions li:hover { background: #f0f7ff; }

.entry-scroll-cue {
    margin-top: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.88);
    font-size: 0.85rem;
    font-weight: 700;
    pointer-events: none;
}
.entry-scroll-cue i {
    width: 12px;
    height: 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    animation: entry-cue-bounce 1.4s ease-in-out infinite;
}
@keyframes entry-cue-bounce {
    0%, 100% { transform: rotate(45deg) translate(0, 0); opacity: 0.35; }
    50% { transform: rotate(45deg) translate(4px, 4px); opacity: 1; }
}

.entry-section {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 88px 24px;
    box-sizing: border-box;
    width: 100%;
    pointer-events: none;
    position: relative;
    z-index: 1;
}
#section-race {
    background: color-mix(in srgb, var(--topic-accent) 34%, rgba(8, 16, 28, 0.78));
    min-height: 100%;
    height: 100%;
    padding: 64px 24px 36px;
    display: flex;
    align-items: stretch;
    justify-content: center;
}
.race-section-inner {
    width: min(747px, 100%);
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
#section-race .entry-section-title {
    margin: 0;
    font-size: clamp(1.25rem, 2.4vw, 1.85rem);
}
.race-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    flex: 0 0 auto;
}
.race-head-copy { min-width: 0; flex: 1 1 auto; }
.race-year {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 0 0 auto;
    color: #ffffff;
    line-height: 1;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}
.race-year-label {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    opacity: 0.8;
    margin-bottom: 2px;
}
.race-year-num {
    font-size: clamp(2.6rem, 7vw, 4.4rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    direction: ltr;
}
.race-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.race-list {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.race-row {
    position: absolute;
    inset-inline: 0;
    top: 0;
    display: grid;
    grid-template-columns: minmax(6.2rem, 8.6rem) minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    will-change: transform, opacity;
}
.race-name {
    font-size: clamp(0.68rem, 1.15vw, 0.86rem);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
    color: rgba(255, 255, 255, 0.94);
}
.race-track {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 100%;
}
.race-grow {
    display: flex;
    align-items: center;
    width: 0;
    min-width: 0;
    max-width: 100%;
    height: 100%;
}
.race-bar {
    flex: 1 1 auto;
    height: 58%;
    min-height: 7px;
    max-height: 18px;
    min-width: 2px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.race-val {
    flex: 0 0 auto;
    margin-inline-start: 8px;
    font-size: clamp(0.68rem, 1.1vw, 0.84rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.92);
    direction: ltr;
}
#section-yearly-report { background-color: rgba(11, 39, 68, 0.58); }
#about { background-color: rgba(29, 78, 137, 0.58); }
#section-overview { background-color: rgba(15, 111, 104, 0.58); }
#section-explorer { background-color: rgba(44, 36, 112, 0.58); }
#section-atlas { background-color: rgba(28, 107, 60, 0.58); }
.entry-section-inner {
    width: min(960px, 100%);
}
#section-race .race-section-inner {
    width: min(747px, 100%);
}
.entry-section-split {
    display: flex;
    align-items: center;
    gap: 48px;
}
.entry-kicker {
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.75);
}
.entry-section-title {
    margin: 0 0 16px;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    font-weight: 800;
    line-height: 1.3;
    color: #ffffff;
}
.entry-section-text {
    margin: 0 0 22px;
    font-size: 1.05rem;
    line-height: 1.9;
    color: rgba(255,255,255,0.92);
    text-align: justify;
}
#about .entry-section-text { margin-bottom: 18px; }
#section-overview .entry-section-text { margin-bottom: 18px; }
.about-story-link {
    pointer-events: auto;
    position: relative;
    z-index: 2;
}
.entry-section-text code {
    font-size: 0.82em;
    background: rgba(0,0,0,0.18);
    padding: 1px 6px;
    border-radius: 6px;
}
.entry-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 22px;
    border: none;
    border-radius: 12px;
    background: #ffffff;
    color: #0f172a;
    font-family: inherit;
    font-size: inherit;
    font-weight: 800;
    text-decoration: none;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
    pointer-events: auto;
    cursor: pointer;
}
.entry-cta:hover { filter: brightness(0.96); }
.entry-cta:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    filter: none;
}
.entry-report-cover,
.entry-preview {
    flex: 0 0 auto;
    width: min(280px, 42vw);
}
.entry-preview-wide {
    width: min(520px, 54vw);
}
.entry-report-cover img,
.entry-preview img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.28);
}
.entry-section-copy { flex: 1 1 auto; min-width: 0; }

.entry-reveal {
    opacity: 0;
    transform: translate3d(0, 42px, 0);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: opacity, transform;
}
.entry-reveal.is-inview {
    opacity: 1;
    transform: none;
}
.entry-reveal.is-leave {
    opacity: 0;
    transform: translate3d(0, -28px, 0);
}

.entry-footnote {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -96px;
    padding: 132px 24px 48px;
    box-sizing: border-box;
    pointer-events: none;
    position: relative;
    z-index: 2;
    background: none;
    border: 0;
    overflow: visible;
}
.entry-footnote-edge {
    position: absolute;
    left: 0;
    width: 100%;
    top: 0;
    height: 96px;
    color: var(--curtain-footer-tint);
    pointer-events: none;
    z-index: 0;
    display: block;
}
.entry-footnote::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 72px;
    bottom: 0;
    background: var(--curtain-footer-tint);
    pointer-events: none;
    z-index: 0;
}
.entry-footnote-inner {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.entry-footnote-title {
    margin: 0 0 10px;
    font-size: 1.15rem;
    font-weight: 800;
}
.entry-contact p,
.entry-contact a {
    margin: 0 0 6px;
    color: rgba(255,255,255,0.92);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1.7;
}
.entry-contact-org { font-weight: 800; font-size: 1.05rem; }
.entry-contact,
.entry-social { pointer-events: auto; }
.entry-social { display: flex; gap: 12px; }
.entry-social a {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.16);
    color: #ffffff;
}
.entry-social a:hover { background: rgba(255,255,255,0.28); }
.entry-footnote-logo {
    height: 85px;
    width: auto;
    object-fit: contain;
    flex: 0 0 auto;
}

.entry-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px; width: 100%; margin-bottom: 60px; }
.entry-info-box { background: #fff; border-radius: 12px; padding: 25px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid var(--border-color); display: flex; flex-direction: column; }
.entry-info-box h3 { margin-top: 0; color: #1e293b; font-size: 1.1rem; margin-bottom: 15px; border-bottom: 2px solid #e2e8f0; padding-bottom: 10px; font-weight: 800; }
.entry-info-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.95rem; color: #475569; }
.entry-info-row strong { color: #0f172a; }
.entry-info-text { font-size: 0.95rem; color: #475569; line-height: 1.7; text-align: justify; margin: 0; }

.entry-start-btn { background: #0078d7; color: #fff; border: none; padding: 15px 50px; font-size: 1.2rem; font-weight: bold; font-family: inherit; border-radius: 10px; cursor: pointer; box-shadow: 0 8px 20px rgba(0,120,215,0.3); transition: transform 0.2s, box-shadow 0.2s; position: absolute; bottom: 20px; left: 0; }
.entry-start-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 25px rgba(0,120,215,0.4); }

@media(max-width: 768px) {
    .entry-start-btn { position: static; margin-top: 20px; align-self: center; }
    .entry-main-title { font-size: 1.6rem; }
    .entry-section-split { flex-direction: column; gap: 24px; }
    .entry-report-cover { width: min(220px, 70vw); }
    .entry-preview,
    .entry-preview-wide { width: min(100%, 520px); }
    .entry-section { min-height: auto; padding: 64px 18px; }
    #section-race {
        min-height: var(--vvh, 100vh);
        height: auto;
        padding: 56px 16px 28px;
    }
    .race-stage { min-height: 68vh; }
    .race-name { white-space: nowrap; }
    .entry-footnote { margin-top: -72px; padding-top: 110px; }
    .entry-footnote-edge { height: 72px; }
    .entry-footnote::before { top: 54px; }
    .entry-footnote-inner { flex-wrap: wrap; justify-content: space-between; }
}

.lazy-bg { background-size: cover; background-position: center; background-repeat: no-repeat; }
.bg-placeholder { background-color: #f3f4f6; }

.leaflet-tile-pane {
    transition: opacity 2.2s ease, filter 2.2s ease;
    filter: none; opacity: 0.30;
}
body.immersive-mode .leaflet-tile-pane { opacity: 0.35 !important; filter: grayscale(80%) contrast(0.9); }
path.leaflet-interactive { transform-box: fill-box; transform-origin: center center; transition: transform 2.2s cubic-bezier(0.25, 1, 0.5, 1), opacity 2.2s ease, fill-opacity 2.2s ease !important; }
path.leaflet-interactive,
path.leaflet-interactive:focus,
path.leaflet-interactive:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
}

body.immersive-mode path.hidden-province { opacity: 1 !important; fill-opacity: 0.1 !important; stroke: #888888 !important; stroke-width: 1.2px !important; stroke-opacity: 0.65 !important; pointer-events: none; }
body.immersive-mode path.detached-province { filter: drop-shadow(0 20px 30px rgba(0,0,0,0.5)) !important; stroke: #ffffff !important; stroke-width: 2.5px !important; cursor: pointer; }

.fade-out { opacity: 0 !important; visibility: hidden; pointer-events: none !important; }

.fade-out-collapse {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

#left-popup-panel, #map-legend, #right-panel { transition: all 0.5s ease; }

.leaflet-control-zoom { display: none !important; }

/* Requirement 5: Move back button UP onto the banner */
#btn-back-entry {
    position: absolute;
    top: 60%;
    transform: translateY(-50%);
    left: 24px;
    z-index: 2200;
}

#btn-back-entry:hover { background: rgba(255, 255, 255, 0.3) !important; }

@media (max-width: 640px) {
    #btn-back-entry { top: 60%; }
}

#right-panel { 
    display: none; 
    position: absolute;
    /* Sit below the floating banner (75px) and hanging nav buttons (~38px) */
    top: calc(var(--banner-gap) + 75px + 46px); 
    right: 0; 
    bottom: 0;
    width: 400px; 
    background: transparent; 
    z-index: 1000; 
    flex-direction: column; 
    gap: 10px; 
    pointer-events: none;
}

#right-panel.show-panel { 
    display: flex; 
    animation: fadeSlideIn 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) forwards; 
}

.right-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-left: 15px solid var(--topic-accent, #0078d7);
    border-radius: 16px;
    padding: 15px;
    box-shadow: -4px 4px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 320px;
    pointer-events: auto;
}

.right-card-top { flex-shrink: 0; margin-top: 0; text-align: center; padding-bottom: 0; }
.right-card-bottom { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 20px; margin-bottom: 130px; }

.panel-title { font-size: 0.8rem; margin-top: 0; margin-bottom: 15px; text-align: center; border-bottom: 1px solid var(--border-color); padding-bottom: 10px; width: 100%; font-weight: 700; color: var(--text-color); }
.instruction { font-size: 0.90rem; color: #666; text-align: center; margin-top: 30px; line-height: 1.5; }
.index-kicker { margin-top: 0; font-size: 0.75rem; color: #666; font-weight: bold; }
.index-description-text { font-size: 0.70rem; line-height: 1.7; color: #444; text-align: justify; margin: 10px 0; padding: 10px; background: #f8fbff; border-radius: 8px; border: 1px solid #e0efff; }
.prov-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.prov-head-row h3 { margin: 0; color: #333; font-size: 0.75rem; font-weight: bold; }
.prov-pop-pill {
    display: inline-flex;
    align-items: center;
    background: #f4f7f6;
    border: 1px solid #c1d5e0;
    padding: 4px 10px;
    border-radius: 15px;
    color: #0078d7;
    font-size: 0.75rem;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.prov-pop-pill svg { width: 14px; height: 14px; margin-left: 4px; fill: #0078d7; }
.prov-change-up { color: #059669; font-weight: bold; }
.prov-change-down { color: #dc2626; font-weight: bold; }
.prov-change-flat { color: #4b5563; font-weight: bold; }

@keyframes fadeSlideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

#center-column { display: flex; flex-direction: column; flex-grow: 1; position: relative; }
#map { flex-grow: 1; background: #e8f4fc; transition: background 2.2s; }
body.immersive-mode #map { background: #dce5ec; }

.leaflet-bottom.leaflet-right { margin-bottom: 25px !important; margin-right: 25px !important; z-index: 1001; }

/* Requirement 8: Move Map title behind icons */
.leaflet-control-attribution { z-index: 0 !important; pointer-events: none; }

#floating-group-container { position: absolute; top: calc(20px + 1px + var(--banner-gap)); right: 20px; bottom: 20px; width: 440px; display: none; flex-direction: column; gap: 15px; z-index: 2000; opacity: 0; transition: opacity 0.8s ease; pointer-events: none; }
#floating-group-container.show-float { opacity: 1; pointer-events: auto; }

#btn-exit-focus {
    margin-bottom: 5px;
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.8rem;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.floating-box { background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(8px); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.2); padding: 15px; border: 1px solid var(--border-color); }
#floating-charts-box { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; height: 100%; }
#group-charts-container, #group-table-container { flex-grow: 1; overflow-y: auto; padding-right: 5px; }

.chart-switcher { display: flex; background: #f0f4f8; padding: 4px; border-radius: 8px; margin-bottom: 12px; flex-shrink: 0; }
.switcher-btn { flex: 1; padding: 8px; text-align: center; font-size: 0.8rem; font-weight: bold; background: transparent; border: none; border-radius: 6px; cursor: pointer; color: #555; transition: all 0.2s; font-family: inherit; }
.switcher-btn.active { background: #0078d7; color: #fff; box-shadow: 0 2px 6px rgba(0,120,215,0.3); }

.prov-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.prov-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.prov-card-title { font-weight: bold; font-size: 0.95rem; color: #1e293b; }
.prov-card-meta { font-size: 0.75rem; color: #64748b; }
.prov-chart-wrap { width: 100%; height: 130px; position: relative; }

#left-popup-panel { position: absolute; left: 0; top: calc(var(--banner-gap) + 75px + 46px); bottom: 200px; width: 280px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(5px); border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); display: none; flex-direction: column; padding: 15px 10px; z-index: 1000; border: 1px solid var(--border-color); border-right: 15px solid var(--topic-accent, #0078d7); }
#left-popup-panel h3 { font-size: 0.95rem; text-align: center; margin: 0 0 15px 0; color: #333; }
#left-chart-container { position: relative; flex-grow: 1; margin: 10px 0; }
#left-chart-container::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: #ccc; transform: translateX(-50%); }

.y-tick { position: absolute; left: 50%; transform: translateX(-50%); width: 10px; height: 2px; background: #888; }
.y-tick span { position: absolute; left: 15px; top: -10px; font-size: 0.8rem; font-weight: bold; color: #555; }
#left-chart-markers { position: absolute; inset: 0; }

.topic-marker { position: absolute; transform: translateY(50%); display: flex; align-items: center; gap: 8px; transition: bottom 1.5s cubic-bezier(0.25, 1, 0.5, 1); }
.topic-marker:hover { z-index: 99999 !important; }
.topic-marker.left-side { right: 50%; flex-direction: row-reverse; margin-right: -8px; }
.topic-marker.right-side { left: 50%; flex-direction: row; margin-left: -8px; }
.topic-marker.right-side .topic-marker-content { flex-direction: row-reverse; }

.topic-marker-dot { width: 16px; height: 16px; border-radius: 50%; background: #0078d7; border: 2px solid #fff; box-shadow: 0 0 4px rgba(0,0,0,0.4); flex-shrink: 0; }
.topic-marker-content { display: flex; align-items: center; gap: 6px; background: #fff; padding: 3px 6px; border-radius: 20px; border: 1px solid #ddd; box-shadow: 0 2px 5px rgba(0,0,0,0.1); position: relative; cursor: pointer; }
.topic-marker-content img { width: 29px; height: 29px; border-radius: 50%; object-fit: cover; }
.topic-marker-content span { font-size: 0.85rem; font-weight: bold; color: #333; margin: 0 4px; }
.topic-marker-content::after { content: attr(data-topic-name); position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0, 0, 0, 0.85); color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 0.85rem; font-weight: normal; white-space: nowrap; opacity: 0; visibility: hidden; transition: all 0.3s ease; box-shadow: 0 2px 8px rgba(0,0,0,0.2); pointer-events: none; z-index: 10000; }
.topic-marker.left-side .topic-marker-content::after, .topic-marker.right-side .topic-marker-content::after { left: 110%; right: auto; }
.topic-marker-content:hover::after { opacity: 1; visibility: visible; }

#map-legend {
    position: absolute; bottom: 145px; left: 50%; transform: translateX(-50%);
    padding: 4px 15px 8px 15px;
    z-index: 1000; display: flex; flex-direction: column; align-items: space-between;
}

/* Requirement 9: Center title */
.legend-title { font-size: 0.8rem; font-weight: 800; margin-bottom: 5px; color: #444; text-align: center; width: 100%; }
.legend-scale-wrapper { direction: ltr; width: 60vw; max-width: 600px; }
.legend-scale-bar { display: flex; flex-direction: row; height: 16px; width: 100%; overflow: visible; border: 1px solid #bbb; position: relative; }
.legend-segment { flex-grow: 1; height: 100%; cursor: pointer; transition: transform 0.2s, filter 0.2s; }
.legend-segment:hover { transform: scaleY(1.3); filter: brightness(1.2); }
.legend-labels { display: flex; flex-direction: row; justify-content: space-between; width: 100%; font-size: 0.8rem; font-weight: 700; color: #555; margin-top: 4px; padding: 0 2px; }

/* Requirement 10: Change line to circular score marker */
#score-pointer { 
    display: none; 
    position: absolute; 
    top: 50%; 
    transform: translate(-50%, -50%); 
    width: 26px; 
    height: 26px; 
    background: #fff; 
    border: 2px solid #222; 
    z-index: 10; 
    transition: left 0.4s ease-out; 
    border-radius: 50%; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.4); 
    align-items: center; 
    justify-content: center; 
}
#pointer-label { 
    position: static; 
    transform: none; 
    margin-top: 0; 
    background: transparent; 
    color: #222; 
    font-size: 11px; 
    padding: 0; 
    border-radius: 0; 
    font-weight: bold; 
}

#bottom-panel {
    position: absolute;
    height: 150px;
    left: 20px;
    right: 20px;
    bottom: 0;
    border-radius: 14px 14px 0 0;
    display: flex; 
    flex-direction: row; 
    align-items: flex-end; 
    padding: 0 15px 0 15px; 
    background: transparent;
    box-shadow: none;
    z-index: 1100; 
    transition: all 0.8s ease; 
}

.index-list { 
    list-style: none; padding: 0; margin: 0; display: flex; flex-direction: row; 
    overflow-x: auto; overflow-y: hidden; flex-grow: 1; align-items: flex-end; 
    height: 100%; justify-content: center; gap: 10px; 
}
.index-list::-webkit-scrollbar { height: 8px; }
.index-list::-webkit-scrollbar-track { background: transparent; }
.index-list::-webkit-scrollbar-thumb { background: #bbb; border-radius: 10px; }

.index-item { 
    width: 110px; height: 120px; flex-shrink: 0; border-radius: 14px 14px 0 0; 
    cursor: pointer; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); 
    background-color: #ffffff; display: flex; flex-direction: column; 
    align-items: center; justify-content: center; padding: 12px; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); border: 3px solid transparent; 
    border-bottom: none; position: relative; overflow: hidden; gap: 12px; 
    transform-origin: bottom center; 
}

.index-item .index-item-img {
    width: 40px; height: 40px; border-radius: 8px; background-size: contain; 
    background-repeat: no-repeat; background-position: center; flex-shrink: 0; 
    transition: transform 0.3s ease; 
}

.index-item .index-item-text { font-weight: 700; text-align: center; font-size: 0.70rem; color: #333333; line-height: 1.3; z-index: 2; }
.index-item:hover { transform: scale(1.02); box-shadow: 0 8px 18px rgba(0,0,0,0.2); }
.index-item:hover .index-item-img { transform: scale(1.1); }
.index-item.active { height: 88%; border-color: #0078d7; transform: scale(1.03); box-shadow: 0 0 15px rgba(0,120,215,0.5); border-top: 10px solid var(--topic-accent, #0078d7); }

.heat-table { width: 100%; border-collapse: collapse; margin-bottom: 0; font-size: 0.75rem; text-align: center; }
.heat-table th { background: #f0f0f0; padding: 8px 4px; color: #333; border: 1px solid #ddd; font-weight: bold; position: sticky; top: 0; z-index: 2; }
.heat-table td { padding: 8px 4px; border: 1px solid #eee; font-weight: bold; }
.heat-table .heat-prov-col { width: 25%; }
.heat-cell { color: #222; }

.leaflet-tooltip.custom-tooltip { background-color: rgba(255, 255, 255, 0.95); border: 1px solid #ccc; color: #333; border-radius: 6px; font-family: 'PeydaFaNumWeb', Tahoma, sans-serif !important; font-size: 14px; text-align: center; line-height: 1.6;}

#map-panel-dock { display: none; }

@media (max-width: 767px) {
    .entry-main-title { font-size: 1.25rem; padding: 0 8px; }
    .entry-search-container { max-width: 100%; }

    #bottom-panel {
        height: 104px;
        left: 6px;
        right: 6px;
        padding: 0 6px env(safe-area-inset-bottom);
        z-index: 1200;
    }
    .index-list {
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        gap: 6px;
    }
    .index-item {
        width: 72px;
        height: 84px;
        padding: 8px 6px;
        gap: 6px;
    }
    .index-item .index-item-img { width: 26px; height: 26px; }
    .index-item .index-item-text { font-size: 0.6rem; }

    #map-panel-dock {
        display: flex;
        position: absolute;
        left: 8px;
        right: 8px;
        bottom: calc(104px + env(safe-area-inset-bottom, 0px));
        z-index: 1220;
        gap: 4px;
        padding: 4px;
        background: rgba(255, 255, 255, 0.96);
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        box-sizing: border-box;
    }
    .map-dock-btn {
        flex: 1;
        border: none;
        background: transparent;
        font-family: inherit;
        font-weight: 800;
        font-size: 0.75rem;
        padding: 8px 4px;
        border-radius: 8px;
        color: #374151;
        cursor: pointer;
    }
    .map-dock-btn.is-active {
        background: var(--topic-accent, #0078d7);
        color: #ffffff;
    }

    #map-legend {
        bottom: calc(152px + env(safe-area-inset-bottom, 0px));
        left: 50%;
        width: calc(100% - 20px);
        padding: 2px 8px 4px;
        z-index: 1100;
        box-sizing: border-box;
    }
    .legend-scale-wrapper { width: 100%; max-width: none; }
    .legend-scale-bar { height: 12px; }
    .legend-title { font-size: 0.7rem; margin-bottom: 2px; }

    #right-panel,
    #right-panel.show-panel {
        display: none;
    }
    body.map-sheet-details #right-panel.show-panel {
        display: flex;
        left: 8px;
        right: 8px;
        width: auto;
        top: auto;
        bottom: calc(152px + env(safe-area-inset-bottom, 0px));
        max-height: min(42vh, 320px);
        gap: 8px;
        align-items: stretch;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 1180;
    }
    .right-card {
        width: 100%;
        max-width: none;
        padding: 10px 12px;
        border-radius: 12px;
        border-left-width: 8px;
        box-sizing: border-box;
    }
    .right-card-top { flex: 0 0 auto; }
    .right-card-bottom {
        margin-bottom: 0;
        padding-bottom: 8px;
        min-height: 0;
        flex: 1 1 auto;
    }
    .panel-title { font-size: 0.75rem; margin-bottom: 8px; padding-bottom: 6px; }
    .index-description-text { font-size: 0.65rem; margin: 6px 0; padding: 8px; }
    #chart-wrapper,
    #trend-wrapper {
        height: 100px !important;
        margin-bottom: 4px !important;
    }

    #left-popup-panel {
        display: none !important;
    }
    body.map-sheet-topics #left-popup-panel {
        display: flex !important;
        left: 8px;
        right: 8px;
        width: auto;
        top: auto;
        bottom: calc(152px + env(safe-area-inset-bottom, 0px));
        height: auto;
        max-height: min(50vh, 380px);
        padding: 10px 12px;
        border-right-width: 8px;
        border-radius: 12px;
        z-index: 1180;
        box-sizing: border-box;
        overflow: hidden;
        flex-direction: column;
    }
    body.map-sheet-topics #left-popup-panel h3 {
        font-size: 0.85rem;
        margin: 0 0 8px;
        flex-shrink: 0;
    }
    body.map-sheet-topics #left-chart-container {
        position: relative;
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        margin: 0;
    }
    body.map-sheet-topics #left-chart-container::before,
    body.map-sheet-topics .y-tick {
        display: none;
    }
    body.map-sheet-topics #left-chart-markers {
        position: relative;
        inset: auto;
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 100%;
    }
    body.map-sheet-topics .topic-marker,
    body.map-sheet-topics .topic-marker.left-side,
    body.map-sheet-topics .topic-marker.right-side {
        position: static !important;
        transform: none !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        margin: 0 !important;
        width: 100%;
        justify-content: flex-start;
        flex-direction: row;
    }
    body.map-sheet-topics .topic-marker-content {
        flex: 1;
    }
    body.map-sheet-topics .topic-marker-content span { font-size: 0.8rem; }
    body.map-sheet-topics .topic-marker-content img { width: 22px; height: 22px; }
    body.map-sheet-topics .topic-marker-content::after { display: none; }

    #floating-group-container,
    #floating-group-container.show-float {
        display: none !important;
    }
    body.map-sheet-groups #floating-group-container {
        display: flex !important;
        left: 8px;
        right: 8px;
        width: auto;
        top: auto;
        bottom: calc(152px + env(safe-area-inset-bottom, 0px));
        max-height: min(50vh, 400px);
        z-index: 1190;
    }
    .floating-box { padding: 10px; }
    .switcher-btn { font-size: 0.7rem; padding: 6px 4px; }
    .prov-chart-wrap { height: 100px; }
}

