/* Refugio Mountain Retreat — weather app
   Light theme. Palette taken from the Refugio logo: navy wordmark, fern green,
   with a warm sunset accent echoing the retreat photography. */

:root {
  --navy: #1b3a5c;
  --navy-deep: #12283f;
  --green: #3f7d28;
  --green-lt: #58a336;
  --sun: #d9863a;
  --page: #f2f5ef;
  --page-2: #e8eee2;
  --surface: #ffffff;
  --line: #dfe5da;
  --text: #14293f;
  --text-dim: #5d6f7e;
  --text-faint: #8b9aa5;
  --radius: 18px;
  --tabbar-h: 62px;
  --shadow: 0 1px 2px rgba(20, 41, 63, .05), 0 6px 18px rgba(20, 41, 63, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; background: var(--page); }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
  background:
    radial-gradient(120% 60% at 50% 0%, #ffffff 0%, transparent 62%),
    linear-gradient(180deg, var(--page) 0%, var(--page-2) 100%);
  background-attachment: fixed;
}

/* ── Header ─────────────────────────────────────────── */
.topbar {
  position: relative;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 6px;
  text-align: center;
  flex: 0 0 auto;
}
.brand-logo { height: 38px; width: auto; max-width: 74vw; object-fit: contain; }
.brand-mark { display: inline-flex; align-items: center; gap: 7px; }
.brand-mark .fern {
  width: 46px; height: 46px;
  flex: 0 0 auto;
  margin-bottom: -3px;   /* the frond's stem hangs below the wordmark baseline */
}
.brand-word {
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: 34px;
  letter-spacing: .005em;
  color: var(--navy);
  line-height: 1;
}
.brand-sub {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* Refresh sits in the empty corner beside the centred branding, so it costs
   no vertical space. It matters more than it looks: overscroll-behavior
   disables pull-to-refresh, and a home-screen install has no reload button —
   without this there is no way for a guest to force an update. */
.refresh-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--green);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.refresh-btn svg {
  width: 13px; height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.refresh-btn:active { transform: scale(.95); }
.refresh-btn[disabled] { opacity: .65; cursor: default; }
.refresh-btn.is-busy svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-height: 720px) {
  .refresh-btn { top: calc(env(safe-area-inset-top) + 8px); padding: 5px 9px 5px 8px; }
}

/* ── View plumbing ──────────────────────────────────── */
main { flex: 1 1 auto; position: relative; min-height: 0; }
.view { display: none; height: 100%; }
.view.is-active { display: block; }

#view-now {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 20px);
}

/* ── Hero ───────────────────────────────────────────── */
.hero { text-align: center; padding: 8px 0 14px; }
.hero-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.hero-temp { line-height: .92; display: inline-flex; align-items: flex-start; }
.temp-value {
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: clamp(56px, 18vw, 78px);
  letter-spacing: -.02em;
  color: var(--navy);
}
.temp-unit {
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 600;
  font-size: clamp(19px, 6vw, 26px);
  color: var(--text-faint);
  margin-top: .4em;
  margin-left: 3px;
}

/* Today's range, stacked beside the current reading. */
.hero-range {
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
}
.range-row { display: flex; align-items: baseline; gap: 5px; }
.range-arrow { font-size: 11px; line-height: 1; }
.range-arrow.hi { color: var(--sun); }
.range-arrow.lo { color: #5b93c4; }
.range-val {
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  color: var(--navy);
}
.range-at { font-size: 10.5px; color: var(--text-faint); }
.hero-feels { margin-top: 1px; font-size: 14px; color: var(--text-dim); }
.hero-cond {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-lt);
  box-shadow: 0 0 0 4px rgba(88, 163, 54, .16);
  flex: 0 0 auto;
}
.dot.stale { background: var(--sun); box-shadow: 0 0 0 4px rgba(217, 134, 58, .18); }
.dot.err   { background: #c9503f; box-shadow: 0 0 0 4px rgba(201, 80, 63, .16); }

/* ── Metric grid ────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 9px 12px 8px;
  box-shadow: var(--shadow);
}
.card.wide { border-radius: var(--radius); padding: 10px 13px 9px; }
.card.wide { grid-column: 1 / -1; }
.card-label {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  white-space: nowrap;
}
.card-value {
  margin-top: 3px;
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: 23px;
  line-height: 1;
  color: var(--navy);
  white-space: nowrap;
}
.card-value small {
  font-family: Inter, sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  margin-left: 3px;
}
.card-foot {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-dim);
  min-height: 13px;
  white-space: nowrap;
}
.arrow { display: inline-block; color: var(--green); font-size: 13px; }

.totals {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 6px;
}
.totals span {
  display: block;
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: clamp(16px, 4.6vw, 20px);
  color: var(--navy);
  white-space: nowrap;
}
.totals em {
  font-style: normal;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.footnote {
  margin: 10px 2px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.stamp b { font-weight: 600; color: var(--text-dim); }
.stamp i { font-style: normal; margin-left: 5px; }
.updated { flex: 1; text-align: right; }
.linkbtn {
  background: none; border: 0;
  color: var(--green);
  font: inherit; font-weight: 600;
  padding: 2px 0; cursor: pointer;
  flex: 0 0 auto;
}

.notice {
  background: #fdf3e6;
  border: 1px solid #f0d5b0;
  color: #8a5a1e;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 10px;
}
.hidden { display: none !important; }

/* ── Sun and moon row ───────────────────────────────────── */
.card.wide.sky {
  display: grid;
  /* The moon cell carries the longest label ("Waning crescent"), so it gets
     the extra width rather than being clipped. */
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 6px;
  align-items: center;
}
.sky-cell { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sky-cell span {
  display: block;
  font-family: "Saira Condensed", Inter, sans-serif;
  font-weight: 700;
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1.05;
  color: var(--navy);
  white-space: nowrap;
}
.sky-cell em {
  display: block;
  font-style: normal;
  font-size: 9.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.sky-ico {
  width: 22px; height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--sun);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sky-ico .ico-arrow { stroke: var(--sun); }
.moon-svg { stroke: none; }
/* Lit limb warm and bright, shadowed limb cool and muted — otherwise a full
   moon reads as a solid dark blob. */
.moon-dark { fill: #c3ccd2; }
.moon-lit { fill: #efc75e; }
.moon-edge { fill: none; stroke: rgba(27, 58, 92, .22); stroke-width: 1; }

/* ── Radar ──────────────────────────────────────────── */
#view-radar { position: relative; }
#map { position: absolute; inset: 0; background: var(--page-2); }
.leaflet-container { background: var(--page-2); font-family: Inter, sans-serif; }
.leaflet-control-attribution {
  background: rgba(255, 255, 255, .82) !important;
  color: var(--text-faint) !important;
  font-size: 9.5px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }
.leaflet-bar a { background: var(--surface); color: var(--navy); border-color: var(--line); }
.leaflet-bar a:hover { background: #f4f7f1; color: var(--navy-deep); }

/* Deliberately no filter and no will-change here. Both promote the overlay to
   a layer the browser must re-rasterise while the map's zoom animation runs,
   which makes the radar drift behind the basemap on a phone. The bin-edge
   softening is baked into the image instead (SOFTEN_PX in app.js). */
.radar-frame { image-rendering: auto; }

/* Location blue, the convention for "you are here" — and it stays legible
   against the greens of light rain on the radar. */
.station-pin {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, .35), 0 2px 6px rgba(20, 41, 63, .35);
}

.radar-panel {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 500;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px 10px;
  box-shadow: 0 8px 26px rgba(20, 41, 63, .18);
}
.radar-head { display: flex; align-items: center; gap: 12px; }
.playbtn {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.playbtn:active { transform: scale(.94); }
.playbtn svg { width: 22px; height: 22px; fill: currentColor; }
.radar-time { flex: 1 1 auto; line-height: 1.25; min-width: 0; }
.radar-time strong {
  font-family: "Saira Condensed", Inter, sans-serif;
  font-size: 21px;
  color: var(--navy);
  display: block;
}
.radar-time span { font-size: 11.5px; color: var(--text-faint); }
.radar-legend {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: .06em;
}
.legend-bar {
  width: 54px; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #63d16b, #2fa93a, #f2e04a, #ef9a32, #d94040, #b23fa8);
}

.scrub {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  margin: 14px 0 0;
  background: transparent;
}
.scrub::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: #dde3d8; }
.scrub::-moz-range-track { height: 5px; border-radius: 3px; background: #dde3d8; }
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--green);
  box-shadow: 0 1px 4px rgba(20, 41, 63, .3);
}
.scrub::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--green);
}
.scrub-ends {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-faint);
  margin-top: 3px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ── Tab bar ────────────────────────────────────────── */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 900;
}
.tab {
  flex: 1;
  background: none; border: 0;
  color: var(--text-faint);
  font: inherit;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: color .18s ease;
}
.tab svg {
  width: 23px; height: 23px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round;
}
.tab.is-active { color: var(--green); }

/* Short phones (iPhone SE/8 and similar, ~667px tall). Trim just enough to
   keep the Now screen on one screen without scrolling; taller phones keep the
   roomier layout above. */
@media (max-height: 720px) {
  .brand-logo { height: 32px; }
  .brand-sub { display: none; }
  .hero { padding: 4px 0 10px; }
  .temp-value { font-size: clamp(48px, 16vw, 64px); }
  .temp-unit { font-size: clamp(17px, 5vw, 22px); }
  .range-val { font-size: 21px; }
  .range-at { font-size: 10px; }
  .hero-range { gap: 7px; }
  .hero-feels { font-size: 13px; }
  .hero-cond { margin-top: 8px; padding: 5px 12px 5px 10px; font-size: 12.5px; }
  .grid { gap: 7px; }
  .card { padding: 8px 11px 7px; }
  .card-value { font-size: 21px; }
  .card-foot { font-size: 10.5px; }
  .footnote { margin-top: 8px; }
}

@media (min-width: 640px) {
  #view-now { max-width: 560px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .radar-panel { max-width: 560px; margin: 0 auto; }
}
