/* Dashboard layout: summary tiles first, map next, detail in closed sections,
   and a bar of main screens at the bottom on phones. Loaded after alpine.css. */

/* Thinner scene on Today and place screens so the tiles start on the first screen */
main.dash::before { height: 76px; margin-bottom: 12px; background-position: center 82%; }
@media (min-width: 760px) { main.dash::before { height: 140px; } }

/* ---------- Summary tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 4px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, 1fr); } .tiles .tile.wide { grid-column: span 2; grid-row: span 2; } }
.tile {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-height: 96px; min-width: 0;
  padding: 12px 14px; border-radius: var(--r-sm, 14px); border: 2px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
  box-shadow: 0 5px 0 -1px var(--slab);
}
.tile.wide { grid-column: 1 / -1; cursor: default; }
@media (max-width: 759px) { .tile.span { grid-column: 1 / -1; } }
.tile:focus-visible, .tile-more:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile p { margin: 0; }
.tile-label { font: 800 .74rem/1.25 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tile-value { font: 800 1.75rem/1.1 var(--body); margin-top: 4px !important; overflow-wrap: anywhere; }
.tile-value .unit { font-size: .95rem; margin-left: 3px; }
.tile-value .loading { font-size: 1rem; }
.tile-sub { font-size: .84rem; line-height: 1.3; color: var(--muted); }
/* Something to check (a closure, a red flag crossed): warning color, kept apart from the danger-scale colors */
.tile.alert { border-color: var(--warn); box-shadow: 0 5px 0 -1px color-mix(in srgb, var(--warn) 70%, #000); }
.tile.alert .tile-value::before { content: "▲ "; font-size: .7em; vertical-align: .12em; color: var(--warn); }

.tile-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tile-head .tile-label { flex: 1 1 auto; }
.tile-head .select-row { margin: 0; flex: 1 1 160px; }
.tile-head .select-label { display: none; }
.tile-bands { display: grid; gap: 8px; margin: 10px 0 2px; }
.tile-band { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.tile-band .chip { min-width: 9.5em; text-align: center; }
.tile-more {
  margin-top: 8px; min-height: 48px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--line);
  background: var(--card-2); color: var(--ink); font: 700 .95rem var(--body); cursor: pointer;
}

/* Sections opened from a tile land below the sticky header */
details.fold { scroll-margin-top: 84px; }
@media (min-width: 760px) { details.fold { scroll-margin-top: 150px; } }

/* ---------- Bottom bar (phones) ---------- */
.bottombar { display: none; }
.foot-links a { color: inherit; }
@media (max-width: 759px) {
  header#top .tabs, header#top .near-btn { display: none; }
  .bottombar {
    display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 2px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--shelf); box-shadow: 0 -8px 20px -8px rgba(0, 0, 0, .45);
  }
  .bottombar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 60px; border-radius: 14px; text-decoration: none;
    color: var(--shelf-ink); opacity: .82; font: 800 .74rem/1 var(--body); letter-spacing: .03em;
  }
  .bottombar a.on { opacity: 1; color: var(--ribbon); background: color-mix(in srgb, var(--ribbon) 20%, transparent); }
  .bottombar a:focus-visible { outline: 3px solid var(--ribbon); outline-offset: -3px; }
  .bb-ic { display: grid; place-items: center; height: 26px; }
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
  /* Full-screen map covers the bar */
  body.rmap-lock .bottombar { display: none; }
  details.fold { scroll-margin-top: 76px; }
}
