/* dual viewer */

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

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: system-ui, sans-serif;
}

/* ---------------------------------------------------------------------------
   Map panes — side by side, full viewport
--------------------------------------------------------------------------- */
#mapLeft, #mapRight {
    position: fixed;
    top: 0; bottom: 0;
    width: 50%;
}
#mapLeft  { left: 0; border-right: 1px solid rgba(255,255,255,0.3); }
#mapRight { right: 0; }

#mapLeft  .ol-viewport,
#mapRight .ol-viewport { cursor: none !important; }

#timeControls,
#toolbarBR,
#aboutPanel { cursor: auto; }

/* ---------------------------------------------------------------------------
   Date badges
--------------------------------------------------------------------------- */
.date-badge {
    position: fixed;
    top: 0.75rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
    padding: 0.25rem 0.8rem;
    border-radius: 8px;
    pointer-events: none;
    z-index: 100;
    transform: translateX(-50%);
}
.badge-left  { left: 25%; }
.badge-right { left: 75%; }

/* ---------------------------------------------------------------------------
   Shared glass button
--------------------------------------------------------------------------- */
.map-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    border-radius: 8px;
    border: 1px solid rgb(0 0 0 / 12%);
    color: #18181b;
    background: rgb(244 244 245 / 85%);
    backdrop-filter: blur(8px) saturate(140%);
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%), 0 1px 2px rgb(0 0 0 / 10%);
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.map-btn:hover  { background: rgb(228 228 231 / 92%); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%), 0 2px 6px rgb(0 0 0 / 12%); }
.map-btn:focus-visible { outline: 2px solid #0072B2; outline-offset: 2px; box-shadow: none; }
.overlay-btn { font-size: 0.72rem; font-weight: 600; width: auto; padding: 0 0.6rem; min-width: 44px; }
.overlay-btn[aria-pressed="true"] { background: #0072B2; color: #fff; border-color: #0072B2; box-shadow: none; }

/* ---------------------------------------------------------------------------
   Time controls — bottom of left pane
--------------------------------------------------------------------------- */
#timeControls {
    position: fixed;
    bottom: 0.75rem;
    left: 0.75rem;
    width: calc(50% - 1.5rem);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    z-index: 200;
}

#periodSelect {
    display: none;
    height: 44px;
    padding: 0 0.6rem;
    border-radius: 8px;
    border: 1px solid rgb(0 0 0 / 20%);
    background: rgb(244 244 245 / 92%);
    backdrop-filter: blur(8px);
    font-size: 0.85rem;
    font-weight: 600;
    color: #18181b;
    width: calc(100vw - 1.5rem);
    cursor: pointer;
}
#periodSelect:focus {
    outline: 2px solid #0072B2;
    outline-offset: 1px;
}

.period-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgb(0 0 0 / 12%);
    color: #18181b;
    background: rgb(244 244 245 / 85%);
    backdrop-filter: blur(8px) saturate(140%);
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%), 0 1px 2px rgb(0 0 0 / 10%);
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.period-btn:hover {
    background: rgb(228 228 231 / 92%);
}
.period-btn[aria-pressed="true"] {
    background: #0072B2;
    color: #fff;
    border-color: #0072B2;
    box-shadow: none;
}
.period-btn:focus-visible {
    outline: 2px solid #0072B2;
    outline-offset: 2px;
    box-shadow: none;
}

/* ---------------------------------------------------------------------------
   Bottom-right toolbar
--------------------------------------------------------------------------- */
#toolbarBR {
    position: fixed;
    bottom: 0.75rem;
    right: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    z-index: 200;
}

#toolbarRow {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.4rem;
}

#searchBox {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.4rem;
}

#searchInput {
    width: 160px;
    height: 44px;
    padding: 0 0.6rem;
    border-radius: 8px;
    border: 1px solid rgb(0 0 0 / 20%);
    background: rgb(244 244 245 / 92%);
    backdrop-filter: blur(8px);
    font-size: 0.85rem;
    color: #18181b;
    transition: width 0.2s ease;
}
#searchInput:focus {
    outline: 2px solid #0072B2;
    outline-offset: 1px;
}

#searchResults {
    position: absolute;
    bottom: calc(100% + 0.4rem);
    right: 0;
    min-width: 100%;
    list-style: none;
    background: rgb(244 244 245 / 96%);
    backdrop-filter: blur(8px);
    border: 1px solid rgb(0 0 0 / 12%);
    border-radius: 8px;
    max-height: 220px;
    overflow-y: auto;
    white-space: nowrap;
}
#searchResults li {
    padding: 0.45rem 0.7rem;
    font-size: 0.82rem;
    cursor: pointer;
    border-bottom: 1px solid rgb(0 0 0 / 6%);
    color: #18181b;
}
#searchResults li:last-child { border-bottom: none; }
#searchResults li:hover { background: rgb(0 114 178 / 12%); }

/* ---------------------------------------------------------------------------
   About panel
--------------------------------------------------------------------------- */
#aboutPanel {
    position: fixed;
    bottom: calc(0.75rem + 44px + 0.8rem);
    right: 0.75rem;
    width: 300px;
    background: rgb(244 244 245 / 96%);
    backdrop-filter: blur(12px);
    border: 1px solid rgb(0 0 0 / 12%);
    border-radius: 12px;
    padding: 1rem;
    z-index: 300;
    font-size: 0.82rem;
    color: #18181b;
}
#aboutPanel h2 { font-size: 0.95rem; margin-bottom: 0.5rem; }
#aboutPanel p, #aboutPanel ul { margin-bottom: 0.4rem; }
#aboutPanel ul { padding-left: 1.2rem; }
#aboutPanel a { color: #0072B2; }
.about-close { position: absolute; top: 0.5rem; right: 0.5rem; width: 32px; height: 32px; font-size: 0.8rem; }


/* ---------------------------------------------------------------------------
   Spinners
--------------------------------------------------------------------------- */
.map-spinner {
    position: fixed;
    top: 50%;
    width: 32px; height: 32px;
    margin-top: -16px;
    margin-left: -16px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 350;
    animation: spin 0.7s linear infinite;
}
#spinLeft  { left: 25%; }
#spinRight { left: 75%; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------------
   Crosshair
--------------------------------------------------------------------------- */
.crosshair {
    position: fixed;
    width: 32px; height: 32px;
    margin-left: -16px; margin-top: -16px;
    border-radius: 50%;
    border: 2.5px solid #0072B2;
    box-shadow: 0 0 0 2px #fff;
    pointer-events: none;
    z-index: 400;
    display: none;
}
.crosshair::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 5px; height: 5px;
    margin-left: -2.5px; margin-top: -2.5px;
    border-radius: 50%;
    background: #0072B2;
    box-shadow: 0 0 0 1.5px #fff;
}
.crosshair.mirror {
    opacity: 0.45;
    border-style: dashed;
}
.crosshair.mirror::after { display: none; }

/* ---------------------------------------------------------------------------
   Drop pin
--------------------------------------------------------------------------- */
.map-pin {
    width: 18px;
    height: 24px;
    margin-left: -9px;
    pointer-events: none;
}
.map-pin::before {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: #D55E00;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
}
.pin-tooltip {
    background: rgb(244 244 245 / 96%);
    backdrop-filter: blur(8px);
    border: 1px solid rgb(0 0 0 / 12%);
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    color: #18181b;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgb(0 0 0 / 15%);
    pointer-events: none;
    max-width: 240px;
    white-space: normal;
}

.map-pin::after {
    content: '';
    display: block;
    width: 4px;
    height: 6px;
    background: rgb(0 0 0 / 25%);
    border-radius: 50%;
    margin: 1px auto 0;
    filter: blur(1px);
}

/* ---------------------------------------------------------------------------
   Scale line
--------------------------------------------------------------------------- */
.ol-scale-line { background: rgba(0,0,0,0.45); border-radius: 4px; }
.ol-scale-line-inner { color: #fff; border-color: #fff; font-size: 0.75rem; }

/* ---------------------------------------------------------------------------
   Visually hidden (a11y)
--------------------------------------------------------------------------- */
.vh {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ---------------------------------------------------------------------------
   Portrait: stack maps
--------------------------------------------------------------------------- */
@media (orientation: portrait) {
    #mapLeft  { width: 100%; height: 50%; top: 0; bottom: auto; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.3); }
    #mapRight { width: 100%; height: 50%; top: 50%; right: 0; }

    .badge-left  { left: 50%; top: 0.75rem; }
    .badge-right { left: 50%; top: calc(50% + 0.75rem); }

    #spinLeft  { left: 50%; top: 25%; }
    #spinRight { left: 50%; top: 75%; }

    #timeControls {
        width: calc(100% - 1.5rem);
        bottom: calc(50% + 0.5rem);
    }

    .period-btn { display: none; }
    #periodSelect { display: block; }

    #aboutPanel { width: min(300px, calc(100vw - 1.5rem)); }
}

/* ---------------------------------------------------------------------------
   Landscape mobile: compact
--------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 500px) {
    .date-badge { font-size: 1rem; padding: 0.15rem 0.5rem; }
    #timeControls { bottom: 0.5rem; }
    #searchBox    { bottom: 0.5rem; }
    #aboutPanel   { bottom: calc(0.5rem + 44px + 0.8rem); }
}

/* ---------------------------------------------------------------------------
   Print
--------------------------------------------------------------------------- */
@media print {
    #timeControls, #toolbarBR, #aboutPanel,
    #spinLeft, #spinRight,
    #chLeft, #chRight { display: none !important; }

    #mapLeft, #mapRight {
        position: absolute;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* landscape print: side by side */
    #mapLeft  { top: 0; bottom: 0; left: 0;   width: 50%; }
    #mapRight { top: 0; bottom: 0; left: 50%;  width: 50%; }

    .date-badge { position: absolute; z-index: 100; }
    .badge-left  { left: 25%; transform: translateX(-50%); }
    .badge-right { left: 75%; transform: translateX(-50%); }

    .ol-viewport { cursor: default !important; }
}

@media print and (orientation: portrait) {
    #mapLeft  { top: 0;   left: 0; width: 100%; height: 50%; bottom: auto; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.3); }
    #mapRight { top: 50%; left: 0; width: 100%; height: 50%; }

    .badge-left  { left: 50%; top: 0.75rem; }
    .badge-right { left: 50%; top: calc(50% + 0.75rem); }
}
