/* Freshies Cast, in the Rocky Mountain Journal theme (rockymountainjournal.com, 11-17).
   Token names are historical: rime = page background, spruce = text, granite = secondary
   text, frost = dividers, control = selected buttons, accent = links.
   The only saturated colour on the map is data: pass markers and the blue odds ramp,
   which stay as they are (blue reads as snow; one hue light to dark). */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(type/inter-400.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url(type/inter-600.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url(type/inter-700.woff2) format("woff2"); }
@font-face { font-family: "Libre Baskerville"; font-weight: 700; font-display: swap; src: url(type/libre-baskerville-700.woff2) format("woff2"); }

:root {
  --rime: #f4f4f2;
  --snow: #ffffff;
  --spruce: #1a1a1a;
  --granite: #6b7280;
  --frost: #d9d9d5;
  --track: #e6e6e2;
  --control: #2c3340;
  --accent: #2a4a1a;
  --focus: #2a4a1a;
  --warn-bg: #fff4d6;
  --warn-ink: #5c4300;

  --sans: "Inter", system-ui, sans-serif;
  --cond: "Inter", system-ui, sans-serif; /* numbers: Inter too (RMJ theme) */
  --display: "Libre Baskerville", Georgia, "Times New Roman", serif;

  --gutter: 16px;
  --radius-control: 6px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--rime); color: var(--spruce); }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px var(--gutter) 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Masthead ------------------------------------------------------------------ */
.masthead { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.masthead > * { grid-column: 1 / -1; }
.masthead > .brand { grid-column: 1; grid-row: 1; }
.masthead > h1 { grid-column: 1; grid-row: 2; align-self: end; }
/* Snowflake badge: top right, beside the brand and title, in the odds ramp's blue. */
.masthead > .badge {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  width: clamp(64px, 15vw, 104px);
  height: auto;
  display: block;
}
/* RMJ eyebrow: Libre Baskerville, uppercase, 0.02em tracking (client theme). */
.brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--granite);
}
h1 {
  margin: 2px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.75rem, 5.5vw, 2.5rem);
  line-height: 1.1;
}
.proto { margin: 6px 0 0; max-width: 68ch; font-size: 0.95rem; line-height: 1.35; }
/* Embedded (?embed=1): the host page carries the title, intro and the not-an-official-
   forecast caveat (RMJ, 11-18), so the embed starts at the issued line and any warnings. */
.embed .masthead > .brand,
.embed .masthead > h1,
.embed .masthead > .badge,
.embed .masthead > .proto { display: none; }
.embed .masthead > .stamp { margin-top: 0; }
.stamp { margin: 4px 0 0; color: var(--granite); font-size: 0.95rem; }
.demo-flag {
  margin: 8px 0 0;
  padding: 6px 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border-left: 4px solid #d4a017;
  font-weight: 600;
  font-size: 0.95rem;
}

/* Controls ------------------------------------------------------------------ */
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: end; }
.seg { border: 0; margin: 0; padding: 0; min-width: 0; }
.seg legend { font-size: 0.875rem; font-weight: 600; color: var(--granite); padding: 0 0 4px; }
.seg-buttons { display: flex; background: var(--snow); border: 1px solid var(--frost); border-radius: var(--radius-control); padding: 3px; }
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--control); color: var(--snow); }
.seg button[aria-pressed="true"] .glyph-none path { stroke: var(--snow); }
.seg-pass { flex: 1 1 340px; max-width: 560px; }
.seg-pass .seg-buttons > button { flex: 1 1 0; justify-content: center; padding: 0 8px; }

/* Timeline: play button + 4-stop range. Tick labels sit under the thumb centres. */
.seg-time { flex: 1 1 320px; max-width: 520px; }
.seg-time legend { font-weight: 600; }
#step-readout { color: var(--spruce); }
.timeline { display: flex; align-items: flex-start; gap: 10px; }
.seg .play {
  flex: none;
  padding: 0;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--control);
  border-radius: 50%;
  background: var(--snow);
  color: var(--control);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.seg .play[aria-pressed="true"] { background: var(--control); color: var(--snow); }
.track { --thumb: 22px; position: relative; flex: 1; min-width: 0; }
.step-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 30px; margin: 7px 0 0; background: transparent; cursor: pointer; }
.step-range::-webkit-slider-runnable-track { height: 6px; background: var(--frost); border-radius: 3px; }
.step-range::-moz-range-track { height: 6px; background: var(--frost); border-radius: 3px; }
.step-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: -8px;
  border-radius: 50%;
  background: var(--control);
  border: 3px solid var(--snow);
  box-shadow: 0 0 0 1px var(--control);
}
.step-range::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: var(--control);
  border: 3px solid var(--snow);
  box-shadow: 0 0 0 1px var(--control);
}
.ticks { position: relative; height: 34px; }
/* .seg .tick beats the generic .seg button rule. Labels hang from their stop: the first
   starts at it, the last ends at it, the middle ones sit proportionally between. */
.seg .tick {
  position: absolute;
  top: 0;
  left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--pos));
  transform: translateX(calc(-100% * var(--pos)));
  min-height: 0;
  padding: 0 2px;
  border-radius: 3px;
  background: none;
  color: var(--spruce);
  display: grid;
  justify-items: center;
  gap: 0;
  line-height: 1.15;
  font-weight: 400;
}
.seg .tick[aria-pressed="true"] { background: none; color: var(--spruce); }
.tick-h { font-weight: 600; font-size: 0.85rem; padding-bottom: 3px; }
.tick-t { font-size: 0.75rem; color: var(--granite); }
.tick[aria-pressed="true"] .tick-h { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }

/* Stage: map + board -------------------------------------------------------- */
.stage { display: grid; gap: 14px; grid-template-columns: 1fr; }
.map-wrap { position: relative; }
.map {
  height: clamp(340px, 95vw, 560px);
  border-radius: var(--radius-control);
  overflow: hidden;
  border: 1px solid var(--frost);
  background: #dde5ea;
}
.ramp {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 4px;
  padding: 6px 8px 4px;
  font-size: 0.75rem;
  color: var(--spruce);
  pointer-events: none;
}
.ramp-title { font-weight: 600; margin-bottom: 3px; }
.ramp-bar { display: flex; height: 10px; width: 160px; }
.ramp-bar span { flex: 1; }
.ramp-ticks { display: flex; justify-content: space-between; width: 168px; margin-left: -4px; color: var(--granite); }

.board h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.2;
}
.board-note { margin: 2px 0 8px; color: var(--granite); font-size: 0.9rem; }
.board-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--spruce); }
/* Column labels: same grid as .row so the hour labels sit over the trend bars. */
.board-head {
  display: grid;
  grid-template-columns: 18px 1fr auto auto;
  column-gap: 10px;
  align-items: end;
  padding: 0 2px 4px;
  color: var(--granite);
  font-size: 0.78rem;
}
.board-head .h-name { grid-column: 2; }
.board-head .h-trend { grid-column: 3; display: grid; justify-items: center; line-height: 1.1; }
.board-head .h-trend > span { font-size: 0.7rem; }
.board-head .trend-head { display: block; overflow: visible; } /* end labels overhang the bars */
/* Same width as the odds figures below (1.75rem condensed, min 3.2ch). */
.board-head .h-odds {
  grid-column: 4;
  font-family: var(--cond);
  font-size: 1.75rem;
  line-height: 1;
  min-width: 3.2ch;
  text-align: right;
}
.board-head .h-odds > span { font-family: inherit; font-size: 0.45em; font-weight: 600; }

/* The board is the signature element: a lift-board column of resorts, each odds bar
   painted with the same ramp colour the map uses at that resort. */
.row {
  appearance: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--frost);
  background: transparent;
  padding: 9px 2px 10px;
  display: grid;
  grid-template-columns: 18px 1fr auto auto;
  grid-template-rows: auto 8px;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: rgba(255, 255, 255, 0.6); }
.row[aria-current="true"] { background: var(--snow); }
.row .glyph { grid-row: 1; grid-column: 1; }
.row .trend { grid-row: 1; grid-column: 3; align-self: end; }
.row .odds { grid-row: 1; grid-column: 4; }
.row .name { grid-row: 1; grid-column: 2; font-weight: 600; font-size: 1.02rem; line-height: 1.15; }
.row .state { font-weight: 400; color: var(--granite); margin-left: 6px; font-size: 0.85rem; }
.row .odds {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  min-width: 3.2ch;
  text-align: right;
}
.row .odds small { font-size: 0.55em; font-weight: 600; margin-left: 1px; color: var(--granite); }
.row .odds.na { color: var(--granite); font-weight: 600; }
.row .bar { grid-column: 2 / 5; grid-row: 2; height: 8px; background: var(--track); border-radius: 0 4px 4px 0; overflow: hidden; }
.row .bar span { display: block; height: 100%; border-radius: 0 4px 4px 0; }

.more {
  margin-top: 10px;
  width: 100%;
  min-height: 44px;
  background: var(--snow);
  border: 1px solid var(--frost);
  border-radius: var(--radius-control);
  font-weight: 600;
  cursor: pointer;
}

.foot { display: grid; gap: 8px; }
.about { border-top: 1px solid var(--frost); border-bottom: 1px solid var(--frost); }
.about summary { min-height: 44px; display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.about-body { padding: 0 0 12px; max-width: 68ch; font-size: 0.95rem; }
.about-body h3 { margin: 10px 0 2px; font-size: 1rem; }
.about-body p, .about-body ul { margin: 0 0 6px; }
.about-body ul { padding-left: 1.2em; }
.about-body a { color: var(--accent); }
.credits { margin: 0; color: var(--granite); font-size: 0.8rem; }

/* Popup -------------------------------------------------------------------- */
.maplibregl-popup-content { font-family: var(--sans); padding: 12px 14px; border-radius: var(--radius-control); }
.pop h3 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.15rem; line-height: 1.2; }
.pop .where { margin: 2px 0 8px; color: var(--granite); font-size: 0.85rem; }
.pop .steps { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.pop .steps th, .pop .steps td { padding: 2px 6px; text-align: right; }
.pop .steps th:first-child { text-align: left; padding-left: 4px; }
.pop .steps thead th { font-size: 0.78rem; font-weight: 600; color: var(--granite); border-bottom: 1px solid var(--frost); }
.pop .steps thead th.cur { color: var(--spruce); }
.pop .steps tbody th { font-weight: 400; color: var(--granite); }
.pop .steps td { font-family: var(--cond); font-weight: 600; font-size: 1.05rem; color: var(--granite); }
.pop .steps td.cur { color: var(--spruce); font-weight: 700; }
.pop .steps tr.now { background: var(--rime); }
.pop .steps tr.now th { color: var(--spruce); font-weight: 600; }
.pop .note { margin: 8px 0 0; font-size: 0.78rem; color: var(--granite); max-width: 30ch; }

/* Wide screens: board left, map right ---------------------------------------- */
@media (min-width: 900px) {
  .stage { grid-template-columns: minmax(300px, 360px) 1fr; align-items: start; }
  .board { order: -1; max-height: 640px; overflow-y: auto; padding-right: 4px; }
  .map { height: 640px; }
  .more { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
