/* ==========================================================================
   App shell
   --------------------------------------------------------------------------
   Editorial split rather than "map with floating boxes": a fixed left rail
   carrying the ranked answer, the map as the main canvas, and a detail sheet
   that overlaps both with real depth. The rail exists because the user's actual
   question is "where should I climb this week", which a map alone cannot answer
   — the previous version made you hunt the continent for a green dot.
   ========================================================================== */

.shell {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    "brand topbar"
    "rail  map";
  height: 100dvh;
  background: var(--bg-deep);
}

/* ── brand block ───────────────────────────────────────────────────────── */
.brand {
  grid-area: brand;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 var(--space-5);
  background: var(--bg-base);
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.brand__title {
  font-size: var(--text-lg);
  letter-spacing: -0.03em;
}

.brand__title em {
  font-style: normal;
  color: var(--accent);
}

.brand__sub {
  font-size: var(--text-2xs);
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* ── topbar ────────────────────────────────────────────────────────────── */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--bg-base);
  border-bottom: 1px solid var(--line-soft);
  min-width: 0;
}

.topbar__spacer { flex: 1; }

/* ── rail ──────────────────────────────────────────────────────────────── */
.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-base);
  border-right: 1px solid var(--line-soft);
}

.rail__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--line-soft);
}

.rail__filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}

.rail__list {
  flex: 1;
  min-height: 0;
  padding: var(--space-2) var(--space-3) var(--space-6);
}

/* ── map ───────────────────────────────────────────────────────────────── */
.map-region {
  grid-area: map;
  position: relative;
  min-width: 0;
  background: var(--bg-inset);
}

#map {
  position: absolute;
  inset: 0;
}

.map-overlay {
  position: absolute;
  z-index: 900;
  pointer-events: none;
}

.map-overlay > * { pointer-events: auto; }

.map-overlay--bottom-left {
  bottom: var(--space-4);
  left: var(--space-4);
}

.map-overlay--top-right {
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-end;
}

/* ── responsive ───────────────────────────────────────────────────────────
   Below 1100px the rail becomes a bottom sheet the user can pull up, so the map
   keeps the full width on tablets and phones. */
@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) 1fr auto;
    grid-template-areas:
      "brand"
      "map"
      "rail";
  }

  .brand {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    border-right: none;
  }

  .brand__sub { display: none; }

  /* Two rows, not three: search on its own line, then the day scrubber sharing
     a line with the action buttons. The spacer is removed so the buttons sit
     against the scrubber instead of being pushed onto a third row. */
  .topbar {
    position: absolute;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    z-index: 600;
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas:
      "search search search"
      "days   refresh theme";
    gap: var(--space-2);
    align-items: center;
    background: var(--bg-overlay);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line-mid);
    height: auto;
    padding: var(--space-3) var(--space-4);
  }

  .topbar .search { grid-area: search; flex-basis: auto; }
  .topbar .days { grid-area: days; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topbar .days::-webkit-scrollbar { display: none; }
  .topbar #refresh { grid-area: refresh; }
  .topbar #theme-toggle { grid-area: theme; }
  .topbar__spacer { display: none; }

  .rail {
    border-right: none;
    border-top: 1px solid var(--line-mid);
    max-height: 45dvh;
    box-shadow: var(--shadow-float);
  }

  .rail__filters { display: none; }
  .rail[data-expanded="true"] .rail__filters { display: flex; }

  .map-overlay--top-right { top: calc(var(--topbar-height) + 4.5rem); }
}

@media (max-width: 640px) {
  :root { --topbar-height: 3.5rem; }

  .brand__title { font-size: var(--text-md); }
  .rail__head,
  .rail__filters { padding-left: var(--space-4); padding-right: var(--space-4); }
  .rail { max-height: 50dvh; }
  .map-overlay--bottom-left { display: none; }
}

/* NOTE: responsive overrides for .day and .sheet live in components.css, not
   here. Media queries add no specificity, and components.css is loaded after
   this file — so a `.sheet` rule in a media query here loses to the plain
   `.sheet` rule there. Keep component overrides next to the component. */
