/*
File: explorer.css
Purpose: Explorer catalog landing and indicator desk, in the dashboard visual identity.
*/

@property --topic-accent {
    syntax: '<color>';
    inherits: true;
    initial-value: #0078d7;
}

:root {
    --banner-gap: 16px;
    --banner-side-gap: 16px;
    --topic-accent: #0078d7;
    --ex-ink: #1b242e;
    --ex-muted: #5c6570;
    --ex-paper: #f4f5f7;
    --ex-line: rgba(27, 36, 46, 0.12);
    --ex-shadow: 0 10px 24px rgba(27, 36, 46, 0.08);
    --ex-radius: 14px;
    --ex-pill: 999px;
    --ex-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body.explorer-body {
    height: 100%;
    margin: 0;
}

body.explorer-body {
    font-family: 'PeydaFaNumWeb', Tahoma, sans-serif !important;
    background: var(--ex-paper);
    color: var(--ex-ink);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: var(--vvh, 100dvh);
}

.explorer-workspace {
    flex: 1;
    min-height: 0;
    margin-top: calc(75px + var(--banner-gap));
    padding-top: 46px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.hidden { display: none !important; }

.custom-scrollbar::-webkit-scrollbar { width: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(27, 36, 46, 0.18);
    border-radius: 99px;
}

/* ------------------------------------------------------------------ */
/* Landing                                                             */
/* ------------------------------------------------------------------ */

.ex-landing {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    overscroll-behavior: contain;
}

.ex-atmosphere {
    pointer-events: none;
    position: sticky;
    top: 0;
    height: 0;
    z-index: 0;
}
.ex-atmosphere::before,
.ex-atmosphere::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
}
.ex-atmosphere::before {
    z-index: 0;
    opacity: 0.07;
    background-image: repeating-linear-gradient(
        90deg,
        transparent 0 72px,
        rgba(27, 36, 46, 0.55) 72px 73.5px,
        transparent 73.5px 140px,
        rgba(27, 36, 46, 0.28) 140px 141px,
        transparent 141px 214px,
        rgba(27, 36, 46, 0.7) 214px 218px,
        transparent 218px 300px
    );
}
.ex-atmosphere::after {
    z-index: 1;
    opacity: 0.1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 220px 220px;
}

.ex-stage {
    position: relative;
    z-index: 2;
}

.ex-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 28px 24px 18px;
}

.ex-kicker {
    margin: 0 0 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--topic-accent, #0078d7);
    transition: color 0.6s ease;
}

.ex-title {
    margin: 0;
    font-size: clamp(2rem, 5.5vw, 3.4rem);
    font-weight: 600;
    line-height: 1.45;
    color: var(--ex-ink);
}

.ex-lead {
    margin: 14px 0 0;
    max-width: 28rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 2;
    color: var(--ex-muted);
}

.ex-cue {
    margin-top: 28px;
    color: var(--ex-ink);
    opacity: 0.7;
}
.ex-cue i {
    display: block;
    width: 10px;
    height: 10px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
    animation: ex-cue-bounce 1.4s var(--ex-ease) infinite;
}
@keyframes ex-cue-bounce {
    0%, 100% { transform: rotate(45deg) translate(0, 0); opacity: 0.35; }
    50% { transform: rotate(45deg) translate(3px, 3px); opacity: 1; }
}

.ex-bento {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto 56px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ex-topics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 12px;
}

.ex-room {
    min-width: 0;
}

.ex-room-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 2px 2px 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: center;
    cursor: pointer;
    transform-origin: center bottom;
    animation: ex-tile-float 5.2s ease-in-out infinite;
}

.ex-room:nth-child(2n) .ex-room-face { animation-delay: 0.35s; }
.ex-room:nth-child(3n) .ex-room-face { animation-delay: 0.7s; }
.ex-room:nth-child(4n) .ex-room-face { animation-delay: 1.05s; }

@keyframes ex-tile-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.ex-room-visual {
    width: 72%;
    aspect-ratio: 4 / 3;
    border-radius: var(--ex-radius);
    background-color: #e5e7eb;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    outline: 1px solid var(--ex-line);
    outline-offset: -1px;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.55), var(--ex-shadow);
    transition: box-shadow 0.35s var(--ex-ease), outline-color 0.35s ease;
}

.ex-room.is-open .ex-room-face {
    animation: none;
    transform: translateY(-5px) scale(1.03);
}

.ex-room.is-open .ex-room-visual {
    outline-color: var(--topic-accent, #0078d7);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.7), 0 10px 24px rgba(27, 36, 46, 0.12);
}

.ex-room-veil {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(27, 36, 46, 0.28), transparent 55%);
    pointer-events: none;
}

.ex-room-copy {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ex-room-copy h2 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.6;
    color: var(--ex-ink);
    text-align: center;
}

.ex-room-meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ex-muted);
}

.ex-room-pearl {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--topic-accent, #0078d7);
    flex-shrink: 0;
}

.ex-panel {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    border-radius: var(--ex-radius);
    border: 1px solid var(--ex-line);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.9), var(--ex-shadow);
}

.ex-panel-grain {
    pointer-events: none;
    position: absolute;
    inset: 0;
    z-index: 4;
    opacity: 0.07;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px 180px;
}

.ex-index-panel {
    min-height: 0;
}

.ex-panel-body {
    position: relative;
    z-index: 2;
    padding: 12px 16px 14px;
}

.ex-panel-empty {
    min-height: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 8px 0;
}

.ex-panel-empty .ex-kicker { margin: 0; }
.ex-panel-empty p {
    margin: 0;
    color: var(--ex-muted);
    font-size: 0.85rem;
    line-height: 1.6;
}

.ex-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 0 6px;
}

.ex-sheet-head h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.ex-sheet-close {
    width: 30px;
    height: 30px;
    border-radius: var(--ex-pill);
    border: 1px solid var(--ex-line);
    background: rgba(255, 255, 255, 0.8);
    color: var(--ex-ink);
    cursor: pointer;
    display: grid;
    place-items: center;
}

.ex-sheet-close:hover { transform: translateY(-2px); }

.ex-sub {
    padding: 6px 0 4px;
}

.ex-sub + .ex-sub {
    border-top: 1px solid var(--ex-line);
}

.ex-sub-name {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ex-muted);
    margin-bottom: 6px;
}

.ex-inds {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mosaic-ind {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 10px 5px;
    border: 1px solid var(--ex-line);
    border-radius: var(--ex-pill);
    background: rgba(255, 255, 255, 0.86);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ex-ink);
    cursor: pointer;
    text-align: right;
}

.mosaic-ind:hover {
    transform: translateY(-2px);
    background: #fff;
}

.mosaic-ind-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--topic-accent, #0078d7);
    flex-shrink: 0;
}

.ex-bubble-panel {
    min-height: 340px;
    display: flex;
    flex-direction: column;
}

.ex-bubbles {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 240px;
    margin: 12px 16px 0;
}

.ex-bubble-axis {
    position: absolute;
    pointer-events: none;
    background: var(--ex-ink);
    opacity: 0.18;
}
.ex-bubble-axis-x {
    left: 8%;
    right: 8%;
    bottom: 14%;
    height: 2px;
    border-radius: 99px;
}
.ex-bubble-axis-y {
    top: 10%;
    bottom: 14%;
    right: 8%;
    width: 2px;
    border-radius: 99px;
}

.ex-bubble {
    position: absolute;
    border-radius: 50%;
    border: 2.2px solid var(--ex-ink);
    background:
        radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.85) 0 18%, transparent 42%),
        color-mix(in srgb, var(--topic-accent, #0078d7) 52%, #ffffff);
    color: var(--ex-ink);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.25;
    padding: 4px;
    cursor: grab;
    user-select: none;
    box-shadow: 0 8px 18px rgba(27, 36, 46, 0.12);
    animation: ex-bubble-float 4.8s ease-in-out infinite;
    touch-action: none;
}
.ex-bubble:nth-child(2n) { animation-duration: 5.4s; }
.ex-bubble:nth-child(3n) { animation-duration: 4.2s; animation-delay: -1.1s; }
.ex-bubble:active { cursor: grabbing; animation-play-state: paused; }
.ex-bubble:hover {
    z-index: 6;
    transform: scale(1.08);
}

@keyframes ex-bubble-float {
    0%, 100% { translate: 0 0; }
    50% { translate: 0 -10px; }
}

.ex-panel-copy {
    position: relative;
    z-index: 3;
    padding: 16px 22px 20px;
}

.ex-panel-copy h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.ex-panel-copy p {
    margin: 8px 0 14px;
    max-width: 28rem;
    font-size: 0.88rem;
    line-height: 1.9;
    color: var(--ex-muted);
}

.ex-build,
.bubble-build-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 42px;
    padding: 8px 20px 10px;
    border-radius: var(--ex-pill);
    background: var(--topic-accent, #0078d7);
    color: #fff;
    text-decoration: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: var(--ex-shadow);
    border: 1px solid rgba(255, 255, 255, 0.18);
    width: max-content;
    transition: transform 0.3s var(--ex-ease);
}

.ex-build:hover,
.bubble-build-bar:hover {
    transform: translateY(-3px);
}

.ex-stage.is-pending .ex-room,
.ex-stage.is-pending .ex-panel {
    opacity: 0;
}

/* ------------------------------------------------------------------ */
/* Indicator desk                                                      */
/* ------------------------------------------------------------------ */

.ex-dash {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ex-paper);
}

.ex-dash-head {
    flex-shrink: 0;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 8px 0 18px;
}

.ex-dash-head #btn-nav-subtopics {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 16px 7px;
    border-radius: var(--ex-pill);
    border: 1px solid var(--ex-line);
    background: #fff;
    color: var(--ex-ink);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--ex-shadow);
}

.ex-dash-head #btn-nav-subtopics:hover { transform: translateY(-2px); }

.ex-dash-head .ex-kicker {
    margin-top: 18px;
    text-align: right;
}

.ex-dash-head #indicator-title {
    margin: 0 0 10px;
    font-size: clamp(1.4rem, 2.6vw, 2rem);
    font-weight: 600;
    line-height: 1.7;
    color: var(--ex-ink);
}

.ex-dash-head #insight-text {
    margin: 0 0 14px;
    max-width: 46rem;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 2;
    color: var(--ex-muted);
    text-align: justify;
}

.ex-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ex-meta span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 14px 5px;
    border-radius: var(--ex-pill);
    border: 1px solid var(--ex-line);
    background: rgba(255, 255, 255, 0.72);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ex-ink);
}

.ex-dash-body {
    flex: 1;
    min-height: 0;
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto 20px;
    display: flex;
    gap: 28px;
}

.ex-chart-room {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--ex-line);
    border-radius: var(--ex-radius);
    box-shadow: var(--ex-shadow);
    padding: 14px 16px 12px;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.chart-toolbar h3 {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ex-ink);
}

.chart-switcher {
    display: flex;
    border: 1px solid var(--ex-line);
    border-radius: var(--ex-pill);
    padding: 3px;
    background: transparent;
}

.chart-mode-btn {
    height: 32px;
    padding: 0 14px 1px;
    border: 0;
    border-radius: var(--ex-pill);
    background: transparent;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ex-muted);
    cursor: pointer;
}

.chart-mode-btn.active {
    background: var(--topic-accent, #0078d7);
    color: #fff;
}

#canvas-reveal-wrapper {
    position: relative;
    flex: 1;
    min-height: 280px;
}

.chart-pane {
    position: absolute;
    inset: 0;
    display: none;
}

.chart-pane.is-active { display: block; }
.chart-pane canvas { width: 100% !important; height: 100% !important; }

.ex-prov-rail {
    width: 228px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.ex-prov-rail h2 {
    margin: 0 0 12px;
    font-size: 0.88rem;
    font-weight: 600;
}

.ex-prov-search input {
    width: 100%;
    height: 38px;
    padding: 0 14px 1px;
    border-radius: var(--ex-radius);
    border: 1px solid var(--ex-line);
    background: #fff;
    font: inherit;
    font-size: 0.85rem;
    outline: none;
}

.ex-prov-search input:focus {
    border-color: var(--topic-accent, #0078d7);
}

.ex-prov-actions {
    display: flex;
    gap: 6px;
    margin: 10px 0 12px;
}

.ex-prov-actions button {
    flex: 1;
    height: 32px;
    border-radius: var(--ex-pill);
    border: 1px solid var(--ex-line);
    background: #fff;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ex-ink);
    cursor: pointer;
}

.ex-prov-actions button:last-child { color: #b91c1c; }

.ex-prov-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.province-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 4px;
    border-radius: var(--ex-radius);
}

.province-item:hover { background: rgba(27, 36, 46, 0.04); }

.province-item label {
    flex: 1;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--ex-ink);
    cursor: pointer;
}

.province-checkbox {
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.ex-prov-rail.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

@media (max-width: 980px) {
    .ex-dash-body { flex-direction: column; }
    .ex-prov-rail {
        width: 100%;
        max-height: 32vh;
    }
    #canvas-reveal-wrapper { min-height: 240px; }
}

@media (max-width: 720px) {
    .explorer-workspace {
        margin-top: calc(64px + var(--banner-gap));
        padding-top: 8px;
    }
    .ex-bento { width: calc(100% - 24px); }
    .ex-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .ex-hero { padding: 18px 16px 12px; }
    .ex-index-panel, .ex-panel-body { min-height: 0; }
    .ex-panel-empty { min-height: 72px; }
    .ex-bubble-panel { min-height: 300px; }
    .ex-dash-head, .ex-dash-body { width: calc(100% - 24px); }
}

@media (max-width: 900px) {
    .ex-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .ex-cue i,
    .ex-room-face,
    .ex-bubble { animation: none; }
}
