:root {
  /* Colours taken from the app icon */
  --navy: #081e32;
  --navy-2: #0e2a45;
  --navy-3: #16385a;
  --teal: #13a5b8;
  --ice: #aff8f1;
  --sun: #fdaf74;
  --red: #ff7a6b;
  --text: #e9fbf9;
  --muted: #8fb3c4;
  --line: rgba(175, 248, 241, 0.12);
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--navy);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  max-width: 720px;
  margin-inline: auto;
}

a { color: var(--ice); }
.muted { color: var(--muted); }

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}
.logo { border-radius: 10px; flex: none; }
.titles { flex: 1; min-width: 0; }
h1 { font-size: 1.25rem; margin: 0; line-height: 1.2; }
.titles p { margin: 2px 0 0; font-size: 0.85rem; }

.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--navy-2);
  color: var(--ice);
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.tabs:empty, .tabs.single { display: none; }
.tabs a {
  flex: none; text-decoration: none; color: var(--text);
  padding: 6px 14px; border-radius: 999px; background: var(--navy-2); border: 1px solid var(--line);
  font-size: 0.9rem;
}
.tabs a[aria-current="page"] { background: var(--teal); border-color: var(--teal); color: var(--navy); font-weight: 600; }

h2 { font-size: 1.05rem; margin: 20px 0 10px; }
h3.sub { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; margin-top: 20px; }
.section-head h2 { margin: 0; }

.error {
  background: rgba(255, 122, 107, 0.12); border: 1px solid rgba(255, 122, 107, 0.4);
  color: #ffd2cc; padding: 10px 12px; border-radius: 12px; font-size: 0.9rem;
}

/* Current conditions */
.now-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* An odd last card spans the full row */
.now-grid .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.card {
  background: var(--navy-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; min-width: 0;
}
.card .place { font-weight: 600; }
.card .elev { color: var(--muted); font-size: 0.8rem; }
.card .speed { display: flex; align-items: baseline; gap: 4px; margin-top: 10px; }
.card .speed b { font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.card .speed span { color: var(--muted); font-size: 0.9rem; }
.card .gust { margin-top: 4px; font-size: 0.95rem; }
.card .gust b { font-variant-numeric: tabular-nums; }
.card .dir { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.9rem; }
.card .temp { margin-top: 6px; font-size: 0.9rem; color: var(--muted); }
.chip {
  display: inline-block; margin-top: 10px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; color: var(--navy);
}
.skeleton { min-height: 190px; opacity: 0.5; }

.arrow {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--navy-3); display: grid; place-items: center;
}
.arrow svg { width: 18px; height: 18px; color: var(--ice); }
.arrow.sm { width: 22px; height: 22px; background: transparent; }
.arrow.sm svg { width: 15px; height: 15px; }

/* Wind levels by gust speed */
.calm { background: var(--teal); }
.breezy { background: var(--ice); }
.windy { background: var(--sun); }
.strong { background: var(--red); }

/* Segmented control */
.segmented { display: inline-flex; background: var(--navy-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.85rem;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; min-height: 32px; white-space: nowrap;
}
.segmented button[aria-selected="true"] { background: var(--teal); color: var(--navy); font-weight: 600; }

/* Hourly strip */
.hourly {
  display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity;
  padding-bottom: 8px; margin-inline: -16px; padding-inline: 16px;
  scrollbar-width: thin;
}
.hour {
  flex: none; width: 56px; scroll-snap-align: start;
  background: var(--navy-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-variant-numeric: tabular-nums;
}
.hour .t { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.hour .bars { height: 70px; width: 18px; position: relative; display: flex; align-items: flex-end; }
.hour .bar-g { position: absolute; bottom: 0; left: 0; right: 0; border-radius: 4px; opacity: 0.45; }
.hour .bar-s { position: absolute; bottom: 0; left: 4px; right: 4px; border-radius: 3px; }
.hour .s { font-weight: 700; font-size: 0.95rem; }
.hour .g { font-size: 0.75rem; color: var(--muted); }
.hour.day-start { border-left: 2px solid var(--teal); }

/* Daily list */
.daily { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.day {
  display: grid; grid-template-columns: 3.4rem 1fr auto; align-items: center; gap: 10px;
  background: var(--navy-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font-variant-numeric: tabular-nums;
}
.day .name { font-weight: 600; }
.day .name small { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; }
.day .wind { display: flex; align-items: center; gap: 8px; min-width: 0; }
.day .wind .nums { white-space: nowrap; }
.day .wind .nums b { font-size: 1.05rem; }
.day .wind .nums span { color: var(--muted); font-size: 0.85rem; }
.day .meter { flex: 1; height: 6px; background: var(--navy-3); border-radius: 3px; overflow: hidden; min-width: 30px; }
.day .meter i { display: block; height: 100%; border-radius: 3px; }
.day .extra { text-align: right; font-size: 0.85rem; white-space: nowrap; }
.day .extra .snow { color: var(--ice); display: block; font-size: 0.8rem; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 18px; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

footer { font-size: 0.8rem; padding: 18px 0 24px; }

@media (max-width: 400px) {
  .segmented button { padding: 6px 9px; font-size: 0.8rem; }
}
@media (max-width: 340px) {
  .now-grid { grid-template-columns: 1fr; }
}

/* ---------- View switch ---------- */
.view-bar { display: flex; padding: 2px 0 4px; }
.view-bar .segmented { width: 100%; }
.view-bar .segmented button { flex: 1; font-size: 0.95rem; min-height: 36px; }
[hidden] { display: none !important; }

/* ---------- Map ---------- */
.map-view { margin-top: 10px; }
.map {
  height: min(68vh, 560px);
  min-height: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--navy-2);
}
.map-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.icon-btn.small { width: 40px; height: 40px; }
.map-controls input[type="range"] { flex: 1; accent-color: var(--teal); height: 32px; min-width: 0; }
.map-hour-label { min-width: 5.2rem; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.small { font-size: 0.8rem; margin: 8px 0 0; }
.legend-map { margin-top: 10px; }
#map-legend .legend-map + .legend-map { margin-top: 6px; }

/* Wind markers: the marker's anchor is the arrow's centre */
.wm-wrap { background: none; border: 0; }
.wm { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; }
.wm-num, .wm-label { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); }
.wm-arrow { display: block; filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.7)); }
.wm-arrow path { stroke: var(--navy); stroke-width: 1.2; stroke-linejoin: round; }
.wm-arrow.lv-calm path { fill: var(--teal); }
.wm-arrow.lv-breezy path { fill: var(--ice); }
.wm-arrow.lv-windy path { fill: var(--sun); }
.wm-arrow.lv-strong path { fill: var(--red); }
.wm-num {
  margin-top: 1px; font: 700 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--navy); background: rgba(255, 255, 255, 0.8); padding: 1px 4px; border-radius: 6px;
}
.wm-label {
  margin-top: 2px; white-space: nowrap; font: 12px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: rgba(8, 30, 50, 0.88); padding: 3px 7px; border-radius: 8px;
  border: 1px solid rgba(175, 248, 241, 0.3);
}
.wm-label small { color: var(--muted); font-size: 11px; }
.wm.named .wm-arrow { filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9)); }
.leaflet-container { font: inherit; background: #dfe9ef; }

/* Cartoon base map: soft, bright and flat */
.cartoon-tiles { filter: grayscale(1) contrast(0.7) brightness(1.18); opacity: 0.45; }

/* Lift labels: a round badge with the lift number, full names when zoomed in */
.lift-wrap { background: none; border: 0; }
.lift-tag {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font: 800 10px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff; background: var(--navy); border: 1.5px solid #fff; border-radius: 999px;
  padding: 2px 4px; min-width: 18px; text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.lift-tag.gondola { background: #d9442f; }
.lift-tag .full { display: none; font-weight: 700; }
.z-hi .lift-tag .short { display: none; }
.z-hi .lift-tag .full { display: inline; }
.run-tip { font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

/* Your location */
.me-wrap { background: none; border: 0; }
.me { position: absolute; transform: translate(-50%, -50%); width: 18px; height: 18px; }
.me i { position: absolute; inset: 0; border-radius: 50%; background: #2f86e0; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); }
.me::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; background: rgba(47, 134, 224, 0.35);
  animation: me-pulse 1.8s ease-out infinite;
}
@keyframes me-pulse { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .me::before { animation: none; opacity: 0.4; } }
.locate-ctl a { display: grid !important; place-items: center; color: var(--navy); }
.locate-ctl a.on { color: #2f86e0; }
.loc-note {
  background: rgba(47, 134, 224, 0.14); border: 1px solid rgba(47, 134, 224, 0.45); color: var(--text);
  padding: 8px 12px; border-radius: 12px;
}

/* Map key swatches */
.swatch { display: inline-block; width: 18px; height: 4px; border-radius: 2px; }
.swatch.lift { background: #e9fbf9; height: 5px; box-shadow: 0 0 0 1px var(--navy); }
.swatch.gondola { background: #d9442f; height: 5px; }
.swatch.run-easy { background: #3fbf6a; }
.swatch.run-int { background: #2f86e0; }
.swatch.run-adv { background: #e9fbf9; }
.swatch.run-exp { background: repeating-linear-gradient(90deg, #e9fbf9 0 5px, transparent 5px 8px); }
.leaflet-control-attribution { font-size: 10px; }
