/* EventMap responsive desktop overlay layout.
   The map remains full-viewport; the timeline and event panel float above it. */
:root {
  --em-sidebar-width: 356px;
  --em-timeline-height: 202px;
  --em-glass: rgba(7, 19, 34, .78);
  --em-glass-border: rgba(151, 194, 228, .22);
}
* { box-sizing: border-box; }
html, body { width:100%; height:100%; min-height:100%; margin:0; overflow:hidden; }
.modal-backdrop[hidden], .map-options[hidden], .map-error[hidden] { display:none !important; }
body { background:#071422; }
.app {
  position:fixed; inset:0; width:100%; height:100dvh; min-height:0;
  display:block; overflow:hidden; background:#071422;
}
.topbar {
  position:absolute; z-index:20; top:0; left:0; right:0;
  height:58px; min-height:58px; padding:0 20px;
  display:flex; align-items:center; gap:16px;
  background:rgba(5, 16, 30, .78);
  border-bottom:1px solid rgba(130,180,220,.16);
  backdrop-filter:blur(16px); -webkit-backdrop-filter:blur(16px);
}
.brand { flex:0 0 auto; z-index:2; }
.brand-sub { display:inline-block; }
.header-center { display:none !important; }
.header-actions { margin-left:auto; z-index:2; display:flex; gap:8px; }
.header-icon { width:38px; height:38px; flex:none; }
.desktop-search-wrap {
  position:absolute; left:50%; top:9px; transform:translateX(-50%);
  width:min(500px, 43vw); z-index:24;
}
.desktop-search {
  width:100%; height:40px; display:flex; align-items:center; gap:10px;
  padding:0 7px 0 14px; border:1px solid rgba(115,170,214,.35);
  border-radius:13px; background:rgba(12, 29, 48, .94);
  box-shadow:0 8px 26px rgba(0,0,0,.25);
}
.desktop-search > svg { width:19px; height:19px; flex:none; fill:none; stroke:#a9c2d8; stroke-width:2; }
.desktop-search input {
  flex:1; min-width:0; height:100%; border:0; outline:0; background:transparent;
  color:#f4f9ff; font:500 13px Inter,system-ui,sans-serif;
}
.desktop-search input::placeholder { color:#8ea7bd; }
#search-open {
  width:29px; height:29px; flex:none; display:grid; place-items:center;
  border:0; border-radius:9px; background:#153c5c; color:#bfe8ff; cursor:pointer;
}
#search-open svg { width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; }
.search-results-floating {
  position:absolute; top:calc(100% + 8px); left:0; right:0; z-index:30;
  max-height:min(58vh, 440px); overflow:auto; padding:6px;
  border:1px solid rgba(117,167,205,.34); border-radius:14px;
  background:rgba(7, 20, 36, .97); box-shadow:0 18px 50px rgba(0,0,0,.45);
  backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px);
}
.search-results-floating[hidden] { display:none !important; }
.workspace { position:absolute; inset:0; display:block; min-height:0; }
.map-column { position:absolute; inset:0; display:block; min-width:0; min-height:0; }
.map-wrap { position:absolute; inset:0; min-height:0; overflow:hidden; }
#map { position:absolute; inset:0; width:100%; height:100%; }
.maplibregl-control-container .maplibregl-ctrl-bottom-right { bottom:8px; right:8px; }
.maplibregl-ctrl-attrib { font-size:9px !important; opacity:.72; }
.map-control-stack {
  position:absolute; z-index:4; top:74px; left:16px;
  display:flex; flex-direction:column; padding:4px;
  border:1px solid rgba(255,255,255,.75); border-radius:13px;
  background:rgba(250,252,255,.94); box-shadow:0 8px 25px rgba(0,0,0,.28);
}
.map-style-picker {
  position:absolute; z-index:4; left:16px; bottom:calc(var(--em-timeline-height) + 28px);
  display:flex; gap:5px; padding:5px; border-radius:13px;
  background:rgba(249,252,255,.96); border:1px solid rgba(255,255,255,.72);
  box-shadow:0 8px 24px rgba(0,0,0,.28);
}
.map-options-toggle {
  position:absolute; z-index:5; right:calc(var(--em-sidebar-width) + 28px);
  bottom:calc(var(--em-timeline-height) + 27px);
  border:1px solid rgba(255,255,255,.68); border-radius:11px;
  background:rgba(250,252,255,.96); color:#344a60;
  box-shadow:0 8px 24px rgba(0,0,0,.28);
}
.map-options {
  position:absolute; z-index:8; right:calc(var(--em-sidebar-width) + 28px);
  bottom:calc(var(--em-timeline-height) + 76px);
  width:min(300px, calc(100vw - var(--em-sidebar-width) - 60px));
  max-height:min(58vh, 520px); overflow:auto;
  border:1px solid rgba(133,179,215,.35); border-radius:15px;
  background:rgba(7,20,36,.94); color:#eaf4ff;
  box-shadow:0 18px 48px rgba(0,0,0,.4);
  backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px);
}
.map-options label { color:#e0edf8; }
.options-title { color:#f2f8ff; border-color:rgba(255,255,255,.12); }
.options-title button { color:#c5d6e6; }
.map-bottom-note { display:none !important; }
.map-error { z-index:12; }
.timeline {
  position:absolute; z-index:6; left:220px;
  right:calc(var(--em-sidebar-width) + 30px); bottom:14px;
  width:auto; height:var(--em-timeline-height); min-height:160px;
  max-height:45vh; flex:none; overflow:hidden;
  padding:13px 16px 12px;
  border:1px solid var(--em-glass-border); border-radius:17px;
  background:rgba(6, 19, 34, .76);
  box-shadow:0 12px 36px rgba(0,0,0,.27);
  backdrop-filter:blur(17px); -webkit-backdrop-filter:blur(17px);
}
.timeline-heading { align-items:center; }
.timeline-dates { flex:none; }
.timeline-footnote { margin-top:8px; }
.solar-timeline { padding-top:9px; margin-top:8px; }
.sidebar {
  position:absolute; z-index:7; top:72px; right:14px; bottom:14px;
  width:var(--em-sidebar-width); min-width:270px; max-width:calc(100vw - 28px);
  display:flex; flex-direction:column; min-height:0;
  border:1px solid var(--em-glass-border); border-radius:18px;
  background:rgba(7, 19, 34, .78);
  box-shadow:0 12px 36px rgba(0,0,0,.25);
  backdrop-filter:blur(17px); -webkit-backdrop-filter:blur(17px);
}
.sidebar-head { padding-top:19px; }
.sidebar-bottom { background:transparent; border-color:rgba(255,255,255,.1); }
.sidebar-close { display:none; }
.event-list { min-height:0; }
.panel-resize-grip {
  position:absolute; z-index:10; left:-4px; top:12px; bottom:12px; width:9px;
  cursor:ew-resize; touch-action:none; border-radius:9px;
}
.panel-resize-grip:hover { background:rgba(74,183,255,.28); }
.timeline-resize-grip {
  position:absolute; z-index:10; top:-3px; left:16px; right:16px; height:8px;
  cursor:ns-resize; touch-action:none; border-radius:8px;
}
.timeline-resize-grip:hover { background:rgba(74,183,255,.28); }
body.em-is-resizing { user-select:none; cursor:grabbing; }
body.em-resize-x { cursor:ew-resize; }
body.em-resize-y { cursor:ns-resize; }
.toast { z-index:40; }
@media (max-width:1100px) {
  :root { --em-sidebar-width:310px; --em-timeline-height:194px; }
  .topbar { padding-inline:14px; }
  .brand-sub { display:none; }
  .timeline { left:205px; right:calc(var(--em-sidebar-width) + 25px); }
  .sidebar-head { padding-inline:17px; }
  .filters { padding-inline:15px; }
  .event-row { gap:9px; }
  .event-image { width:62px; height:62px; }
}
@media (max-width:760px) {
  :root { --em-sidebar-width:0px; --em-timeline-height:0px; }
  .topbar { height:54px; min-height:54px; padding:0 9px; gap:7px; }
  .brand-name { font-size:16px; }
  .brand-logo { width:29px; height:29px; }
  .brand-sub { display:none; }
  .header-actions { gap:5px; }
  .header-icon { width:33px; height:33px; }
  .desktop-search-wrap {
    left:136px; right:91px; top:9px; width:auto; transform:none;
  }
  .desktop-search { height:36px; border-radius:11px; gap:6px; padding-left:9px; }
  .desktop-search input { font-size:12px; }
  .desktop-search input::placeholder { color:#91a9bf; }
  #search-open { width:27px; height:27px; }
  .workspace, .map-column, .map-wrap { position:absolute; inset:0; }
  .timeline { display:none !important; }
  .sidebar {
    display:none; position:fixed; z-index:35; top:62px; right:8px; bottom:8px; left:8px;
    width:auto; min-width:0; max-width:none; border-radius:16px;
    background:rgba(6,18,33,.95);
  }
  .sidebar.mobile-open { display:flex; }
  .sidebar-close { display:block; position:absolute; right:13px; top:14px; z-index:2; }
  .sidebar-head { padding:18px 17px 13px; }
  .filters { padding:0 14px 13px; }
  .map-control-stack { top:64px; left:8px; padding:3px; border-radius:10px; }
  .map-control { width:30px; height:30px; font-size:20px; }
  .map-control svg { width:16px; height:16px; }
  .map-controls-sep { margin:3px 5px; }
  .map-style-picker { left:8px; bottom:10px; padding:3px; gap:1px; }
  .style-card { min-width:44px; padding:3px; font-size:9px; }
  .style-thumb { width:34px; height:21px; }
  .map-options-toggle { right:8px; bottom:10px; padding:8px 9px; font-size:11px; }
  .map-options {
    right:8px; bottom:57px; width:min(300px,calc(100vw - 16px));
    max-height:65vh;
  }
  .panel-resize-grip, .timeline-resize-grip { display:none; }
  .search-results-floating { max-height:58vh; }
  .maplibregl-ctrl-bottom-right { display:none; }
}
@media (max-width:390px) {
  .brand-name { font-size:14px; }
  .desktop-search-wrap { left:122px; right:82px; }
  .desktop-search input { font-size:11px; }
  .desktop-search input::placeholder { content:"Search..."; }
  .header-icon { width:30px; height:30px; }
}
@media (prefers-reduced-motion:reduce) {
  .desktop-search, .sidebar, .timeline { transition:none !important; }
}

/* Mobile search island: the desktop search stays in the top bar; mobile gets
   only the floating circular button at the previously marked lower-right spot. */
.mobile-search-island { display:none; }
.mobile-search-panel[hidden],
.mobile-search-results[hidden] { display:none !important; }
.modal-backdrop { z-index:60; }
.modal-backdrop[hidden] { display:none !important; }
.help-modal video {
  display:block;
  width:100%;
  height:auto;
  max-height:min(48vh, 340px);
  border-radius:12px;
  background:#02070d;
  object-fit:contain;
}
body.modal-active { overflow:hidden; }

@media (max-width:760px) {
  .desktop-search-wrap { display:none !important; }

  .mobile-search-island {
    display:block;
    position:fixed;
    z-index:34;
    right:18px;
    bottom:calc(env(safe-area-inset-bottom, 0px) + 58px);
    pointer-events:none;
  }
  .mobile-search-fab {
    pointer-events:auto;
    display:grid;
    place-items:center;
    width:56px;
    height:56px;
    padding:0;
    border:1px solid rgba(119,202,255,.65);
    border-radius:50%;
    color:#f4fbff;
    background:linear-gradient(145deg,rgba(16,54,82,.97),rgba(5,21,39,.96));
    box-shadow:0 8px 26px rgba(0,0,0,.42),0 0 0 5px rgba(45,161,231,.12),inset 0 1px 0 rgba(255,255,255,.14);
    backdrop-filter:blur(16px);
    -webkit-backdrop-filter:blur(16px);
    cursor:pointer;
    transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  }
  .mobile-search-fab:active { transform:scale(.94); }
  .mobile-search-fab[aria-expanded="true"] {
    border-color:#8bd7ff;
    box-shadow:0 8px 28px rgba(0,0,0,.46),0 0 0 6px rgba(45,161,231,.18);
  }
  .mobile-search-fab svg {
    width:24px;
    height:24px;
    fill:none;
    stroke:currentColor;
    stroke-width:2;
    stroke-linecap:round;
    stroke-linejoin:round;
  }
  .mobile-search-panel {
    pointer-events:auto;
    position:absolute;
    right:0;
    bottom:calc(100% + 12px);
    width:min(340px,calc(100vw - 32px));
    max-height:min(58vh,500px);
    overflow:hidden;
    padding:10px;
    border:1px solid rgba(119,177,218,.35);
    border-radius:17px;
    background:rgba(5,19,34,.96);
    box-shadow:0 18px 48px rgba(0,0,0,.48);
    backdrop-filter:blur(20px);
    -webkit-backdrop-filter:blur(20px);
  }
  .mobile-search-entry {
    display:flex;
    align-items:center;
    gap:9px;
    min-height:44px;
    padding:0 8px 0 12px;
    border:1px solid rgba(121,177,218,.42);
    border-radius:11px;
    background:rgba(19,43,65,.92);
  }
  .mobile-search-entry > svg {
    width:18px;
    height:18px;
    flex:none;
    fill:none;
    stroke:#a9c9e3;
    stroke-width:2;
  }
  .mobile-search-entry input {
    width:100%;
    min-width:0;
    height:42px;
    border:0;
    outline:0;
    background:transparent;
    color:#f3f8ff;
    font:500 13px Inter,system-ui,sans-serif;
  }
  .mobile-search-entry input::placeholder { color:#8ea7bd; }
  .mobile-search-entry button {
    width:29px;
    height:29px;
    flex:none;
    border:0;
    border-radius:8px;
    background:#17689d;
    color:white;
    font-size:17px;
  }
  .mobile-search-results {
    display:flex;
    flex-direction:column;
    max-height:min(40vh,340px);
    overflow:auto;
    margin-top:7px;
    padding:2px;
  }
  .mobile-search-results .search-result { padding:10px 8px; }
  .mobile-search-hint {
    margin:8px 3px 1px;
    color:#8199b1;
    font-size:10px;
    line-height:1.4;
  }
  .modal-backdrop { z-index:60; }
}
@media (prefers-reduced-motion:reduce) {
  .mobile-search-fab { transition:none; }
}
