/* =============================================================
   MCM Current Conditions — style.css
   Light theme, WordPress 2024 compatible, no external fonts.
   Tokens copied from the main viewer's style.css so this folder
   stands alone in its own repo.

   Scaling: every size is in rem, and the root font-size is fluid
   (driven by viewport width AND height), so the same layout reads
   on a phone, a laptop, and a lobby TV. Breakpoints below only
   change layout (column count, fill-the-screen), not sizes.
   ============================================================= */

/* --- Tokens -------------------------------------------------- */
:root {
  --bg: #f8f8f7;
  --surface: #ffffff;
  --border: #e0ddd8;
  --border-light: #ece9e4;
  --text-primary: #1a1917;
  --text-secondary: #5a574f;
  --text-muted: #8a877f;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --warm: #c92a2a;               /* feels-like above 0 °C */
  --warm-light: #fff5f5;
  --good: #2f9e44;
  --line-default: #6b9bd1;       /* sparklines (soft blue) */
  --line-solar: #d4a43c;         /* solar radiation sparkline (soft gold) */
  --series-a: #2563eb;           /* single value / first of a group (accent) */
  --series-b: #0c8599;           /* second of a group (viewer palette teal) */
  --series-c: #e8590c;
  --radius: 0.43rem;
  --radius-lg: 0.72rem;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --gap: 0.86rem;
  --axis-w: 2.5rem;              /* sparkline y-axis label gutter */
  --transition-ms: 550ms;
}

/* Fluid root size: 14px on phones/laptops → ~19px at 1080p → ~34px at 4K. */
html {
  font-size: clamp(14px, calc(0.6vmin + 0.45vw + 4px), 40px);
}

/* --- Reset --------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 86rem;
  margin: 0 auto;
  padding: 1.15rem 1.4rem 1.7rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* Opened directly (not in an iframe): fill the screen. */
body:not(.embedded) #app { min-height: 100vh; min-height: 100dvh; }
body:not(.embedded) #stage { flex: 1; display: flex; }
body:not(.embedded) .site-card { flex: 1; display: flex; flex-direction: column; }
body:not(.embedded) .tiles { flex: 1; }
body:not(.embedded) .spark-wrap { max-height: none; }   /* sparklines absorb spare height; minSpan keeps them honest */

/* --- Header -------------------------------------------------- */
#cc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.86rem;
  flex-wrap: wrap;
}

.cc-kicker {
  display: flex;
  align-items: center;
  gap: 0.57rem;
  font-size: 0.79rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.cc-clock-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.57rem;
}

.cc-clock-label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

#cc-clock {
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* "Feels like" line under air temperature */
/* "Feels like" pill under air temperature, in the dashboard's light blue */
.feels-like {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  padding: 0.15rem 0.65rem;
  border: 1px solid rgba(37, 99, 235, 0.3);      /* --accent at 30 % */
  border-radius: 100px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.86rem;
  line-height: 1.4;
  white-space: nowrap;
}
.feels-like strong { font-weight: 600; color: inherit; }
/* Feels-like bands (thresholds in config.js): solid blue when very cold, red above 0 °C. */
.feels-like.is-very-cold {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.feels-like.is-warm {
  background: var(--warm-light);
  border-color: rgba(201, 42, 42, 0.3);           /* --warm at 30 % */
  color: var(--warm);
}

/* Pressure tendency reuses the wind-direction block, a size smaller
   (it sits in a single-width tile). */
.side-stat .wind-cardinal { font-size: 1.35rem; }
.side-stat .wind-arrow { width: 1.9rem; height: 1.9rem; }
.side-stat .wind-deg { white-space: nowrap; }

/* --- Stage + transition ------------------------------------- */
#stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.site-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.6rem 1.6rem;
  min-height: 22rem;
  transition:
    opacity var(--transition-ms) ease,
    transform var(--transition-ms) cubic-bezier(0.22, 0.61, 0.36, 1);
}

.site-card.is-leaving  { opacity: 0; transform: translateX(-3%); }
.site-card.is-entering { opacity: 0; transform: translateX(3%); transition: none; }

/* Tiles cascade in after the card lands */
.site-card.is-shown .tile {
  animation: tile-in 480ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.site-card.is-shown .tile:nth-child(2) { animation-delay: 60ms; }
.site-card.is-shown .tile:nth-child(3) { animation-delay: 120ms; }
.site-card.is-shown .tile:nth-child(4) { animation-delay: 180ms; }
.site-card.is-shown .tile:nth-child(5) { animation-delay: 240ms; }
.site-card.is-shown .tile:nth-child(6) { animation-delay: 300ms; }

@keyframes tile-in {
  from { opacity: 0; transform: translateY(0.7rem); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .site-card,
  .site-card.is-leaving,
  .site-card.is-entering { transform: none; }
  .site-card.is-shown .tile { animation: none; }
}

/* --- Site heading ------------------------------------------- */
.site-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.57rem 1.4rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  margin-bottom: 1.3rem;
  border-bottom: 1px solid var(--border-light);
}

/* Logo + station name/code, side by side. Logo is sized to the two lines. */
.site-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.site-logo {
  height: 4.4rem;
  width: auto;
  flex-shrink: 0;
}

.site-name {
  font-size: 2.4rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.site-meta {
  display: flex;
  align-items: center;
  gap: 0.57rem;
  margin-top: 0.43rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.site-code { font-family: var(--mono); color: var(--text-muted); }

.obs-time {
  text-align: right;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.obs-time strong {
  display: block;
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--text-primary);
}

/* Time-zone suffix on observation times ("UTC+13"): much smaller than the time */
.tz {
  font-size: 0.62em;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* --- Tiles --------------------------------------------------- */
/* Default (tablet → TV): 3 columns, 3 tiles on top and wind, pressure and
   the location map below. (A `wide` tile would span two columns.) */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: row dense;
  gap: var(--gap);
}

.tile.wide { grid-column: span 2; }

/* Wide grouped tile: put the readings side by side. */
.tile.wide .pair { flex-direction: row; gap: 1rem 2.5rem; flex-wrap: wrap; }
.tile.wide .pair-row { flex: 0 1 auto; grid-template-columns: auto auto; justify-content: start; column-gap: 1.2rem; }

.tile {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.tile-label {
  font-size: 0.79rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  line-height: 1.3;
  min-height: 2.6em;            /* two lines, so numbers line up across tiles */
}

.tile-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.4rem;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

.tile-number {
  font-size: 2.9rem;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.tile-unit {
  font-size: 0.86rem;
  font-family: var(--mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.43rem;
  min-height: 1.3rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Wind direction, beside the speed */
.wind-dir {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1.2rem;
  padding-left: 1.2rem;
  border-left: 1px solid var(--border-light);
  align-self: center;
}

.wind-arrow {
  width: 2.4rem;
  height: 2.4rem;
  flex-shrink: 0;
  color: var(--text-primary);
}

.wind-dir-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.wind-cardinal {
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.wind-deg {
  font-size: 0.79rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

.tile.no-value .tile-number,
.pair-row.no-value .tile-number { color: var(--text-muted); }

/* Grouped tile (e.g. shallow + deep O₂) */
.pair { display: flex; flex-direction: column; gap: 0.5rem; }

.pair-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name value" "range range";
  align-items: baseline;
  column-gap: 0.5rem;
}

.pair-name {
  grid-area: name;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.pair-row .tile-value { grid-area: value; justify-content: flex-end; }
.pair-row .tile-number { font-size: 1.9rem; }

.pair-range {
  grid-area: range;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.swatch {
  width: 1.1rem;
  height: 0;
  border-top: max(2px, 0.14rem) solid var(--series-a);
  flex-shrink: 0;
}
.swatch.s-b { border-top-style: dashed; border-top-color: var(--series-b); }
.swatch.s-c { border-top-style: dotted; border-top-color: var(--series-c); }

/* --- Wind-direction arrows on the wind trend line ----------- */
.wind-arrows { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; }
.wind-arrow-mini {
  position: absolute;
  width: 0.95rem;
  height: 0.95rem;
  margin: -0.475rem 0 0 -0.475rem;
  color: #000;
  pointer-events: auto;          /* hover shows the direction */
}
.wind-arrows .wind-arrow-mini .wind-arrow { display: block; width: 100%; height: 100%; color: inherit; }
@media (max-width: 700px) {
  .wind-arrows, .wind-key { display: none; }
}

/* --- Locator map tile --------------------------------------- */
/* The SVG takes the height the row gives it (set by the other tiles), and
   the image fits inside it, so the map never makes its row taller. */
.map-svg {
  flex: 1 1 0;
  min-height: 9rem;
  width: 100%;
  margin-top: 0.43rem;
  display: block;
}

/* Dark dots with a white ring show on both snow and bare ground */
.map-dot circle:not(.hit) {
  fill: rgba(26, 25, 23, 0.85);
  stroke: #fff;
  stroke-width: 1.5px;
}
.map-dot .hit { fill: transparent; }
.map-dot:not(.stale) { cursor: pointer; }
.map-dot:not(.stale):hover circle:not(.hit) { fill: var(--accent-light); stroke: var(--accent); }
.map-dot.stale circle:not(.hit) { fill: rgba(26, 25, 23, 0.35); stroke-dasharray: 2 2; }

.map-here {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 2.5px;
}
.map-here-halo { fill: var(--accent); opacity: 0.3; }

/* --- Sparkline colours --------------------------------------
   Each tile sets --line for its sparkline, fill and end dot: soft blue,
   with soft gold for solar radiation. */
.tile    { --line: var(--line-default); }
.v-solar { --line: var(--line-solar); }

/* --- Sparkline ----------------------------------------------- */
.spark-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 2.6rem;
  max-height: 8rem;             /* when embedded (sized to content) */
  margin-top: 0.43rem;
}

/* Y-axis: tick labels in a left gutter, plot area to the right of it. */
.spark-axis {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc(var(--axis-w) - 0.35rem);
}

.spark-tick {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.66rem;
  line-height: 1;
  color: var(--text-muted);
  white-space: nowrap;
}

.spark-plot {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: var(--axis-w);
}

.spark-grid {
  stroke: var(--border-light);
  stroke-width: 1px;
}

.spark {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.spark-line {
  fill: none;
  stroke: var(--line, var(--series-a));
  stroke-width: max(2px, 0.14rem);
  stroke-linejoin: round;
  stroke-linecap: round;
}
.spark-line.s-b { stroke: var(--series-b); stroke-dasharray: 5 3; }
.spark-line.s-c { stroke: var(--series-c); stroke-dasharray: 1.5 3; }

/* A light tint of the line colour (opacity rather than color-mix(), which
   browsers older than Chrome 111 don't know and would draw as solid black). */
.spark-area { fill: var(--line, var(--series-a)); fill-opacity: 0.09; }

.spark-dot {
  position: absolute;
  width: 0.57rem;
  height: 0.57rem;
  margin: -0.285rem 0 0 -0.285rem;
  border-radius: 50%;
  background: var(--line, var(--series-a));
  box-shadow: 0 0 0 2px var(--surface);
}
.spark-dot.s-b { background: var(--series-b); }
.spark-dot.s-c { background: var(--series-c); }

.spark-caption {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 0.8rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1.5em;            /* keeps tiles level when the range is hidden */
}

/* Historical average: dashed grey line behind the data, with a key */
.spark-ref {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: max(1.5px, 0.1rem);
  stroke-dasharray: 4 3;
  stroke-linecap: round;
  opacity: 0.85;
}

.avg-key {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.swatch.s-avg { border-top: max(2px, 0.14rem) dashed var(--text-muted); }

/* Top of a tile: label / value / sub on the left, extras (records) on the right.
   Wraps the extras underneath when the tile is too narrow for both. */
.tile-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.tile-main {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 auto;
}

/* Record high / low for this date + hour (air temperature): upper right */
.tile-records {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  justify-content: end;
  gap: 0.05rem 0.4rem;
  font-size: 0.79rem;
  color: var(--text-secondary);
  text-align: right;
  flex: 0 0 auto;
}

.tile-records .rec-label {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.rec-year { color: var(--text-muted); font-size: 0.9em; }

/* Min / max values in the range captions */
.range-val {
  font-family: var(--mono);
  font-size: 1.08em;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* --- Messages ----------------------------------------------- */
.cc-message {
  margin: auto;
  padding: 4rem 1rem;
  text-align: center;
  font-size: 1rem;
  color: var(--text-muted);
  font-style: italic;
}

/* --- Footer: site chips + progress -------------------------- */
#cc-footer { display: flex; flex-direction: column; gap: 0.7rem; }

#site-dots { display: flex; flex-wrap: wrap; gap: 0.43rem; }

.site-dot {
  padding: 0.2rem 0.64rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.79rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.site-dot:hover { border-color: var(--accent); color: var(--accent); }

.site-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.site-dot.stale {
  color: var(--text-muted);
  border-style: dashed;
  cursor: default;
  opacity: 0.7;
}
.site-dot.stale:hover { border-color: var(--border); color: var(--text-muted); }

#progress {
  height: 0.2rem;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 2px;
}

/* =============================================================
   Layout breakpoints
   ============================================================= */

/* Large screens / TVs: drop the max-width, use the whole display,
   and give the headline numbers more weight. */
@media (min-width: 1600px) {
  #app { max-width: none; padding: 2.2vh 2.5vw; }
}
@media (min-width: 1600px) and (orientation: landscape) {
  body:not(.embedded) .site-name { font-size: 3rem; }
  body:not(.embedded) .site-logo { height: 5.3rem; }
  body:not(.embedded) .tile-number { font-size: 4.2rem; }
  body:not(.embedded) .pair-row .tile-number { font-size: 2.6rem; }
  body:not(.embedded) .wind-cardinal { font-size: 2.6rem; }
  body:not(.embedded) .wind-arrow { width: 3.2rem; height: 3.2rem; }
  body:not(.embedded) .side-stat .wind-cardinal { font-size: 1.9rem; }
  body:not(.embedded) .side-stat .wind-arrow { width: 2.4rem; height: 2.4rem; }
}

/* Phones: 2 columns, wide tile spans the row (dense flow moves it last),
   sizes nudged. */
@media (max-width: 700px) {
  #app { padding: 0.7rem 0.85rem 1.4rem; }
  .site-card { padding: 1.1rem; min-height: 0; }
  .site-name { font-size: 1.9rem; }
  .site-region { display: none; }    /* just the station name on phones */
  .site-logo { display: none; }      /* logo is the home-screen / tab icon there instead */
  .site-title { gap: 0.75rem; }
  .obs-time { text-align: left; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .tile { padding: 0.8rem 0.85rem 0.6rem; }
  .tile-number { font-size: 2.2rem; }
  /* Wind direction / pressure trend drop onto their own line under the value */
  .wind-dir { flex-basis: 100%; margin: 0.3rem 0 0; padding-left: 0; border-left: 0; }
  .tile-records { justify-content: start; text-align: left; }
  .tile.wide { grid-column: 1 / -1; }
  .tile-label { min-height: 0; }
}

/* Very small phones: single column. */
@media (max-width: 360px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tile.wide .pair { flex-direction: column; }
}

/* Short landscape screens (phone held sideways): compact 3 × 2 grid, so the
   map still fits and nothing is squeezed into a fifth of the width. */
@media (max-height: 500px) and (orientation: landscape) {
  body:not(.embedded) #app { min-height: 0; }
  #app { padding: 0.6rem 0.85rem 1rem; }
  .site-card { min-height: 0; padding: 0.9rem 1rem; }
  .site-head { margin-bottom: 0.8rem; padding-bottom: 0.6rem; }
  .site-name { font-size: 1.6rem; }
  .site-logo, .site-region { display: none; }   /* phone held sideways: same as upright */
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem; }
  .tile { padding: 0.6rem 0.7rem 0.5rem; }
  .tile.wide { grid-column: auto; }
  .tile.wide .pair { flex-direction: column; gap: 0.5rem; }
  .tile-number { font-size: 1.7rem; }
  .pair-row .tile-number { font-size: 1.3rem; }
  .wind-cardinal { font-size: 1.2rem; }
  .wind-arrow { width: 1.6rem; height: 1.6rem; }
  .side-stat { flex-basis: 100%; margin: 0.3rem 0 0; padding-left: 0; border-left: 0; }
  .tile-label { font-size: 0.7rem; }
}
