/* exfoliation-kjb-spa — shell-only styles. The per-view body styles
   continue to come from exfoliation.css + forecast_*.css. */

/* Reserve scrollbar gutter so a vertical scrollbar appearing on a tall
   view (history/almanac) doesn't shrink the viewport — that's what
   caused the shell-header (justify-content: space-between) to shift
   visibly when switching from a no-scroll view to a scrolling one. */
html { scrollbar-gutter: stable; }

/* Body font reset. css/gauges-ss.css ships an unscoped
   `body { font-family: Verdana }` rule that wins the cascade in the
   shell (loaded after exfoliation.css). spa.css is loaded last, so
   re-pinning the font here restores exfoliation.css's intended
   'Open Sans' for every view regardless of which iframe-era
   stylesheet load order applied. */
body {
  font-family: 'Open Sans', arial, sans-serif;
  font-size: 10pt;
}

.spa-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid #ccc;
}

.spa-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spa-nav a {
  padding: 4px 10px;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 4px;
}

.spa-nav a:hover { background: #f0f0f0; }
.spa-nav a.is-active {
  background: #eef3ff;
  border-color: #b8c8ee;
  font-weight: 600;
}

main#view {
  /* Match the standalone exfoliation pages' default body margin (8px)
     so views render with the same usable horizontal width they had
     pre-SPA. Top padding gives breathing room from the shell-header
     border-bottom — without it, views whose first row is a
     navigation_controls strip (forecast tabs, history Day/Week/Month/
     Year) sit flush against the divider. */
  padding: 14px 8px 0 4px;
  min-height: 60vh;
}

/* Break margin-collapse so iconic/table panes (which open with a
   <p class='forecast_select'>) don't drag the floated nav_controls
   tabs an additional ~16px down — keeps the gap consistent across
   all four panes. */
[data-view="forecast"] #content > .fc_pane { padding-top: 1px; }

.spa-loading { color: #888; font-style: italic; }
.spa-error   { color: #b22; }

.spa-footer {
  border-top: 1px solid #ccc;
  padding: 8px 16px;
  font-size: 80%;
  color: #666;
}

/* Per-page styles lifted from the original index.html.tmpl <head> block.
   The SPA fragment doesn't have its own <head>, so these have to live in
   the shell-loaded stylesheet to keep the three-column block layout and
   the chart-link color coding working. */

main#view::after { content: ""; display: block; clear: both; }

.block {
  float: left;
  padding-right: 50px;
}

.heatindex { color: #aa4444; }
.windchill { color: #4444aa; }
.temphi    { color: #aa4444; }
.templo    { color: #4444aa; }

.precip-img { width: 32px; }
.obvis-img  { width: 32px; }
.pop-img    { width: 8px; }

.table_heading {
  font-size: 80%;
  color: #888;
  border-bottom: 1px solid #ccc;
  padding-top: 20px;
}

.radar {
  border: none;
  width: 480px;
  padding: 2px;
}

.zambretti        { font-size: 80%; }
.forecast_summary { width: 100%; }

/* Pin the main metric table's outer width AND lock column widths
   to the header row, so the layout is stable independent of cell
   content. `table-layout: fixed` makes the browser size columns from
   the first row only — both Current and Live emit an identical header
   row (empty / "ACTUAL" colspan=2 / "HI/LO" / empty / "FORECAST"), so
   columns end up byte-for-byte equal regardless of what later rows
   contain (Cheetah values vs empty rtgd-* spans vs JS-populated). */
.block table.metrics {
  width: 460px;
  table-layout: fixed;
}

/* Mobile: unfloat the three .block columns (metrics, forecast, radar)
   so they stack vertically, and drop the metric table's hard 460px
   width so the table fits inside an iPhone-class viewport (~390px). */
@media (max-width: 480px) {
  .block {
    float: none;
    padding-right: 0;
    width: 100%;
  }
  .block table.metrics {
    width: 100%;
    table-layout: fixed;
  }
  /* On mobile we keep the explicit name-column width from desktop
     (100px) so labels like 'Particulates PM2.5' still fit on one
     line; remaining cells share the rest equally. */
  .block table.metrics tr:first-child td:first-child {
    width: 80px;
  }
  .radar {
    width: 100%;
    height: auto;
  }
}
/* table-layout: fixed reads column widths from the first row only,
   then locks them. Both Current and Live emit an identical header
   row, so this distributes columns identically across views. Pinning
   the first (name) column wider lets long labels — "Solar Radiation",
   "Particulates PM2.5", "Cloud Base" — stay on a single line. */
.block table.metrics tr:first-child td:first-child { width: 100px; }
.block table.metrics .metric_name {
  white-space: nowrap;
}
/* almanac + history want auto-sized metric tables; restore them */
[data-view="almanac"] .block table.metrics,
[data-view="history"] .block table.metrics {
  width: auto;
}


/* Per-view styles lifted from each template's inline <style> block.
   Class names that overlap between views (.metrics, .block) are scoped
   via the [data-view=...] attribute set on each fragment's outer
   <section>; the rest are unique enough to live unscoped. */

/* /live metric_name cells contain an icon (hidden on desktop) + text
   (hidden on phone). At ≤600px the icon replaces the text — frees up
   the metric_name column width so the HI/LO column can fit a 3-digit
   "avg" without wrapping. Hover/long-press the icon to see the full
   word (via the <img title="…"> attribute). */
[data-view="live"] .metric_name .m-icon { display: none; }
[data-view="live"] .metric_name .m-text { display: inline; }
/* Desktop: metric_name text labels top-align with the first line of
   their row's value content (matches the original exfoliation layout).
   Phone: icons get centered inside the cell — handled below in the
   @media block. Padding-right gives breathing room between the
   right-aligned labels and the ACTUAL column to their right. */
[data-view="live"] .metric_name { vertical-align: top; padding-right: 12px; }
/* Header row's grey underline: the original `.table_heading` rule only
   paints border-bottom on cells WITH the class, leaving the empty
   <td></td> in col 1 + the units col without a line — the underline
   shows up as two disconnected bars. Apply to every cell in the first
   row so it extends edge-to-edge. Use the direct-child combinator
   throughout so this rule does NOT bleed into the nested table inside
   the wind ACTUAL cell (whose own first <tr> would otherwise inherit
   the underline, drawing a stray grey line under the wind meter). */
[data-view="live"] .block > table.metrics > tbody > tr:first-child > td {
  border-bottom: 1px solid #ccc;
}
/* Reclaim a bit of the un-scoped 100px label column at desktop.
   Selenium-measured widest single-line label is "Temperature" at
   80px; 90px gives a 10px buffer for font-rendering variance and
   leaves room for the right-aligned text without crowding. The
   freed 10px go to the HI/LO column so 'gust' and 'avg' fit on
   one line. */
[data-view="live"] .block table.metrics tr:first-child td:first-child { width: 90px; }
/* FORECAST cell uses .metric_value { vertical-align: middle } from
   exfoliation.css. For taller rows (multi-line HI/LO content), the
   short forecast value floats in mid-air. Pin all metric_value cells
   in /live to top so short content lines up with the first row of
   taller neighbors. */
[data-view="live"] td.metric_value { vertical-align: top; }
/* Wind row's FORECAST cell uses the same template treatment as the
   forecast section's `.col-wind` (vertical-align: middle, text-align:
   center, background:url(icons/<dir>.png) at 48px). Keep the icon
   inside the row's natural height — don't force `height: 48px` (it
   inflates the row past its content's needs, creating empty space
   below the wind cluster). min-width pin only. */
[data-view="live"] td.col-wind-live { min-width: 60px; }
/* Wind row: the nested 3-col table inside the metric_large ACTUAL
   cell inherits font-size: 200% from .metric_large. Override AT THE
   CELL level so each child cell has its own sane scale + line-height
   — no percentage-of-percentage games. Compass cluster (cell 2)
   needs tight 9pt with line-height matching for the N/0 stack to
   look paired; arrow cell (cell 3) needs medium 12pt so the glyph
   is visible alongside the big "2" without inflating the row. */
[data-view="live"] td.metric_large > table > tbody > tr > td:nth-child(2) {
  font-size: 9pt;
  line-height: 1.1;
  vertical-align: middle;
}
[data-view="live"] td.metric_large > table > tbody > tr > td:nth-child(3) {
  font-size: 12pt;
  line-height: 1;
  vertical-align: middle;
}
/* Override the exfoliation-default `font-weight: bold` (700) on the
   metric values for /live — measured Arial 400 at 9.82% dark-pixel
   density vs Arial 700's 11.70% (16% lighter), and Arial is what
   the system actually loads since no webfont is bundled. */
[data-view="live"] .metric_value,
[data-view="live"] .metric_large { font-weight: 400; }
/* Widen the HI/LO column at desktop so 'gust' and 'avg' values can sit
   on one line ("9.0 gust 3.0 avg" needs ~95px). Steal the width from
   the FORECAST column, which is single-line (5%/85, "6-10", etc.). */
[data-view="live"] .block table.metrics tr:first-child td:nth-child(3) { width: 100px; }
[data-view="live"] .block table.metrics tr:first-child td:nth-child(5) { width: 55px; }
@media (max-width: 600px) {
  [data-view="live"] .metric_name .m-icon {
    display: inline-block;
    vertical-align: middle;
    width: 1.5em;
    height: 1.5em;
  }
  [data-view="live"] .metric_name .m-text { display: none; }
  /* Pin the metric_name column at phone to just-wider-than-the-icon
     (table-layout: fixed reads column widths from the FIRST row, so
     the override targets the first row's first cell). */
  [data-view="live"] .block table.metrics tr:first-child td:first-child { width: 2.5em; }
  /* Center icons vertically inside the cell, and give them some
     breathing room from the adjacent value column. */
  [data-view="live"] .metric_name { vertical-align: middle; padding-right: 6px; }
  .phone-only { display: inline; }
}

/* forecast */
.fc_pane          { display: none; }
.forecast_select  { padding-top: 15px; padding-bottom: 10px; }
.forecast_table   { display: none; }
.forecast_iconic  { display: none; }
/* keep the generic .temp class from being clobbered by the iconic /
   vertical variants */
.iconic-horizontal .temp { float: left; }
.iconic-vertical   .temp { float: left; }
.temp                    { float: none; }

/* history */
[data-view="history"] .metrics {
  width: auto;
  padding-top: 20px;
}
[data-view="history"] .navigation_controls { float: right; }
[data-view="history"] .selectors {
  text-align: right;
  padding-top: 20px;
}
/* Force two graphs per row at any viewport — the upstream relied on
   natural inline flow, which stacks one-per-row whenever the viewport
   isn't ≥ 2 × image-natural-width (i.e. anything narrower than ~1430px).
   Flex with a 50%-each img cap pins two per row and lets each scale
   down at narrower viewports without breaking the grid. */
.data_graphs {
  display: flex;
  flex-wrap: wrap;
  column-gap: 1%;
  row-gap: 8px;
}
.data_graphs img {
  width: 49.5%;
  height: auto;
  padding-top: 2em;
}
@media (max-width: 800px) {
  .data_graphs img { width: 100%; }
}

/* almanac */
[data-view="almanac"] .metrics {
  width: auto;
  padding-right: 20px;
  float: left;
}
.metric_title { padding-top: 3em; }

/* station */
[data-view="station"] #controls {
  font-size: 90%;
  float: right;
  padding-right: 50px;
}
[data-view="station"] #controls tr { vertical-align: top; }
[data-view="station"] .block { padding-bottom: 50px; }

/* links */
.feeds_column      { float: left; padding-right: 3em; }
.feeds_column img  { border: none; width: 140px; padding: 2px; }
@media (max-width: 600px) {
  .feeds_column img { width: 100%; }
}
