﻿body {
    margin: 0;
    font: 0.9rem/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

#map {
    width: 100%;
    height: 100vh;
}

/* Header overlay */
.map-title {
    background: rgba(24,24,28,0.9);
    color: #e8e8ea;
    border-color: #ffffff12;

    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;

    border: 1px solid #00000014;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.15);
    backdrop-filter: saturate(1.2) blur(6px);

    padding: 8px 14px;
    margin: 0;
    font: 600 clamp(20px, 2.8vw, 28px)/1.2 var system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

    pointer-events: none; /* keep map draggable under the title */
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-fixed {
  position: fixed;
  top: max(0px, env(safe-area-inset-top));      /* avoids iOS notch */
  z-index: 1000;                                  /* stay above content */
  display: inline-block;
  height: 130px;
  width: 110px;
  margin: 10px;
}

.general-info {
  position: fixed;
  top: max(170px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 1000;

  width: 35px;                 /* square */
  height: 35px;
  padding: 0;
  display: grid;               /* center icon */
  place-items: center;

  background: #ffffff;
  color: #111827;              /* icon color */
  border: none;
  border-radius: 8px;          /* make 0 for sharp corners */
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .1);
}
/* Icon size */
.general-info svg { width: 22px; height: 22px; }

aside header {
    background: rgba(24,24,28,0.9);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    font-weight: 600;
    border-bottom: 1px solid white;
}

/* Navigation overlay panel */
.nav-panel {
    background: rgba(24,24,28,0.9); 
    color: #e8e8ea; 
    position: absolute;
    z-index: 11;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.15);
    backdrop-filter: saturate(1.2) blur(6px);
    min-width: 220px;
    max-width: min(86vw, 360px);
    overflow: hidden;
    bottom: 10px;
    right: 10px;
}
#timeForm { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 8px; 
    padding: 8px 10px 10px 10px;
}
#timeForm label { 
    display: grid; 
    gap: 4px; 
}
#timeForm select {
    background: rgba(24,24,28,0.9);
    border-color: #2a2d34;
    color: #e8e8ea;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid;
    font: inherit;
}
#timeForm .btn-primary {
    grid-column: 1 / -1;
    background: #2b5cff;
    color: #fff;
    border: 0;
    border-radius: 6px;
    padding: 3px; /* padding: 6.55px; */
    font: inherit;
    cursor: pointer;
    transition: background .15s ease, transform .02s ease, opacity .15s ease, filter .15s ease;
}
/* Hover/active only when NOT disabled */
#timeForm .btn-primary:not(:disabled):hover { 
    background: #244de0; 
}
#timeForm .btn-primary:not(:disabled):active { 
    transform: translateY(1px); 
}
/* Disabled visual state */
#timeForm .btn-primary:disabled,
#timeForm .btn-primary[disabled],
#timeForm .btn-primary[aria-disabled="true"] {
    background: #3a3f4b;
    border-color: #2a2d34;
    color: #a9afbb;
    cursor: not-allowed;
    opacity: .8;
    transform: none;
    box-shadow: none;
    pointer-events: none; /* ignore hover */
}

/* Legend overlay */
.legend {
    background: rgba(24,24,28,0.9);
    color: #e8e8ea;
    position: absolute;
    z-index: 10;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.15);
    backdrop-filter: saturate(1.2) blur(6px);
    min-width: 260px;
    max-width: min(86vw, 360px);
    overflow: hidden;
    bottom: 10px;
    left: 10px;
}
.legend table {
    border-collapse: collapse;
    width: 100%;
}
.legend th, .legend td {
    padding: 7px 10px;
    border-bottom: 1px solid #0000000d;
}
.legend tbody tr:last-child td {
    border-bottom: 0;
}
.swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #0002;
    display: inline-block;
    margin-right: 8px;
    vertical-align: -2px;
}

/* Layout wrapper ensures popover positions relative to the button */
.info-popover {
    position: relative;
    display: inline-block;
    margin-left: auto; /* pushes it to the right */
    line-height: 0; /* no extra line box height */
}
/* The icon button */
.icon-btn {
    inline-size: 1.25rem;
    block-size: 1.25rem;
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    cursor: pointer;
    border-radius: 50%;
    background: #9aa0a6;
    transition: background .15s ease, color .15s ease;
}
.icon-btn:hover {
    background: white;
}
.icon-btn:focus-visible {
    outline: 2px solid #0b57d0;
    outline-offset: 2px;
}

/* Popover panel */
.pop {
    position: absolute;
    transform: translateY(-8px);
    z-index: 1000;
    min-inline-size: 220px;
    max-inline-size: min(86vw, 360px);
    color: #e8e8ea;
    background: rgba(24,24,28,0.9);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.30);
    backdrop-filter: saturate(1.2) blur(6px);
    padding: 10px 12px;
}
.pop[hidden] {
    display: none !important;
}
.pop[data-placement="bottom"] {
    inset: 100% auto auto 0;
    transform: translateY(8px);
}
.pop-inner {
    display: grid;
    gap: 6px;
}
/* Popover header: mirrors .nav-panel header */
.pop-inner > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 600;
    background: rgba(24,24,28,0.9);
    border-bottom: 1px solid white;
    /* stretch header to pop edges */
    margin: -10px -12px 0px -12px;
    padding: 8px 10px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
/* Body text */
.pop-inner p {
    margin: 0;
    line-height: 1.5;
    color: #e8e8ea;
}
/* Close button */
.pop-close {
    padding: 2px;
    justify-self: end;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: #9aa0a6;
    font-size: 14px;
    border-radius: 4px;
}
.pop-close:hover {
    color: #e8e8ea;
}
.pop-close:focus-visible {
    outline: 2px solid #0b57d0;
    outline-offset: 2px;
}
/* Arrow */
.pop-arrow {
    position: absolute;
    inline-size: 10px;
    block-size: 10px;
    background: #1d1f24;
    transform: rotate(45deg);
}
/* Arrow positions for above/below */
.pop:not([data-placement="bottom"]) .pop-arrow {
    bottom: -6px;
    left: 12px;
}
.pop[data-placement="bottom"] .pop-arrow {
    top: -5px;
    left: 12px;
}

.maplibregl-ctrl-group {
    border-radius: 8px;
}
.maplibregl-ctrl-group button {
    width: 35px;
    height: 35px;
}
.maplibregl-ctrl-group .maplibregl-ctrl-icon {
    background-size: 80% 80%;
}

#info-btn {
    color: black;
}

#legend-body {
    padding: 4px 0px;
    overflow: hidden;
    height: auto; /* expanded */
    transition: height .5s ease;
}
.pop[data-align="end"]:not([data-placement="bottom"]) .pop-arrow {
    left: auto;
    right: 12px;
}
.pop[data-align="end"][data-placement="bottom"] .pop-arrow {
    left: auto;
    right: 12px;
}
#legend-toggle {
    display: grid;
}
/* The toggle button: circular, black background, white chevron */
.legend__toggle {
    border: 0;
    border-radius: 50%;
    background: #9aa0a6;
    color: #000;
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 0;
}
/* Hide/show the body */
#legend-body[hidden] {
    display: none;
}
/* Optional: animated height instead of instant hide.
Wrap body content in a .legend__body-inner if you want smooth collapse. */
.legend__body-anim {
    overflow: clip; /* or hidden */
    transition: block-size .2s ease;
}
.legend--collapsed .legend__body-anim {
    block-size: 0;
}
/* Collapse when the button says expanded=false */
.legend:has(.legend__toggle[aria-expanded="false"]) #legend-body {
    height: 0;
    padding: 0;
}
.legend:has(.legend__toggle[aria-expanded="false"]) .legend__header {
    border: 0;
}
.legend__toggle .chev {
    color: black;
    transition: transform .5s ease;
    transform-origin: 50% 50%;
    transform: rotate(180deg);
}
/* Rotate up when expanded */
.legend__toggle[aria-expanded="true"] .chev {
    transform: rotate(0deg);
}

/* Optional: reduce motion */
@media (prefers-reduced-motion: reduce) {
    .legend__toggle .chev {
        transition: none;
    }
    #legend-body {
        transition: none;
    }
}

/* Phone portrait */
@media (max-width: 640px) {
    body {
        font-size: 1rem;
    }

    .map-title {
        font-size: 1.5rem;
    }

    /* 1) Create a bottom "dock" that spans the full width */
    .bottom-dock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
        display: grid;
        gap: 12px;
        z-index: 1000; /* above the map */
        pointer-events: none; /* let map get touches except on panels */
    }

    /* 2) Make each panel full width and scrollable if tall */
    .bottom-dock > .legend,
    .bottom-dock > .nav-panel {
        pointer-events: auto; /* re-enable interaction for the panels */
        position: static !important; /* cancel absolute corner placement */
        max-width: none !important;
    }

    .logo-fixed {
        height: 80px;
        width: 68px;
    }
}

/* Phone landscape, Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .bottom-dock {
        display: flex;
    }

    .logo-fixed {
        height: 80px;
        width: 68px;
    }
}
