/* -----------------------------------------------------------------------
   Solar Conditions — W5MMW
   ----------------------------------------------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@400;600&display=swap');

/* Dark theme — charcoal + red (default) */
:root {
  --bg:          #1c1c1c;
  --bg-block:    #272727;
  --bg-cond:     #1c1c1c;
  --border:      #3e3e3e;
  --border-cond: #333333;
  --text:        #e2e2e2;
  --text-muted:  #8a8a8a;
  --text-head:   #ff7070;
  --text-th:     #c09898;
  --value:       #ff7070;
  --link:        #ff7070;

  --good-bg:     #0e2e0e;
  --good-fg:     #4ec94e;
  --good-border: #1e6a1e;
  --fair-bg:     #2e2200;
  --fair-fg:     #d4a820;
  --fair-border: #6a5000;
  --bad-bg:      #350a0a;
  --bad-fg:      #e05050;
  --bad-border:  #7a1818;

  --chart-tick:   #a08080;
  --chart-grid:   #3e3e3e;
  --chart-legend: #e2e2e2;

  --btn-bg:       #361616;
  --btn-fg:       #e09090;
  --btn-border:   #6a2a2a;
  --btn-hover:    #451c1c;

  --inactive-bg:     #202020;
  --inactive-fg:     #909090;
  --inactive-border: #2c2c2c;
}

/* Light theme — based on example.css palette */
[data-theme="light"] {
  --bg:          #fcfefd;
  --bg-block:    #ffffff;
  --bg-cond:     #f8faf9;
  --border:      #d8d8d8;
  --border-cond: #e4eae6;
  --text:        #141c17;
  --text-muted:  #51534d;
  --text-head:   #a00000;
  --text-th:     #51534d;
  --value:       #1a426a;
  --link:        #a00000;

  --good-bg:     #e8f5e8;
  --good-fg:     #1c8a1c;
  --good-border: #a0d0a0;
  --fair-bg:     #fffbe0;
  --fair-fg:     #7a5800;
  --fair-border: #dec400;
  --bad-bg:      #fde8e8;
  --bad-fg:      #dd5456;
  --bad-border:  #f0a8a8;

  --chart-tick:   #51534d;
  --chart-grid:   #d8d8d8;
  --chart-legend: #141c17;

  --btn-bg:       #f5e8e8;
  --btn-fg:       #a00000;
  --btn-border:   #cc8888;
  --btn-hover:    #eddede;

  --inactive-bg:     #f0f0f0;
  --inactive-fg:     #666666;
  --inactive-border: #dcdcdc;
}

/* -----------------------------------------------------------------------
   Skip link (keyboard navigation)
   ----------------------------------------------------------------------- */

#skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 200;
  padding: 8px 16px;
  background: var(--bg-block);
  color: var(--text-head);
  border: 2px solid var(--text-head);
  font-weight: 600;
  text-decoration: none;
}

#skip-link:focus {
  top: 0;
}

/* Screen-reader-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -----------------------------------------------------------------------
   Focus rings (keyboard navigation)
   ----------------------------------------------------------------------- */

:focus-visible {
  outline: 3px solid var(--text-head);
  outline-offset: 2px;
}

/* -----------------------------------------------------------------------
   Smooth theme transitions
   ----------------------------------------------------------------------- */

body, .block, .cond, #chart_wrapper, footer,
#bandstable th, #bandstable td,
h1, h2, a {
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* -----------------------------------------------------------------------
   Reset & base
   ----------------------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow Semi Condensed', 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.5;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* -----------------------------------------------------------------------
   Theme toggle button (fixed top-right)
   ----------------------------------------------------------------------- */

#theme-toggle {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 100;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 0.82em;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.15s;
}

#theme-toggle:hover {
  background: var(--btn-hover);
}

/* -----------------------------------------------------------------------
   Page header
   ----------------------------------------------------------------------- */

h1 {
  text-align: center;
  margin: 0;
  padding: 24px 70px 24px 20px; /* right padding clears the toggle button */
  background: var(--bg-block);
  color: var(--text-head);
  font-size: 2.2em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border);
}

h2 {
  color: var(--text-head);
  font-size: 1.15em;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* -----------------------------------------------------------------------
   Layout
   ----------------------------------------------------------------------- */

#wrapper {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
}

#wrapper-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "bands        primaryconds"
    "chart_wrap   chart_wrap"
    "stats        stats"
    "vhf          vhf";
  gap: 20px;
}

/* -----------------------------------------------------------------------
   Blocks
   ----------------------------------------------------------------------- */

.block {
  background: var(--bg-block);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

#bands        { grid-area: bands; }
#primaryconds { grid-area: primaryconds; }
#vhf-section  { grid-area: vhf; }

#chart_wrapper {
  grid-area: chart_wrap;
  background: var(--bg-block);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

#stats { grid-area: stats; }

/* -----------------------------------------------------------------------
   Band conditions table
   ----------------------------------------------------------------------- */

#bandstable {
  width: 100%;
  border-collapse: collapse;
}

#bandstable th {
  padding: 8px 12px;
  text-align: center;
  color: var(--text-th);
  font-weight: normal;
}

/* Border only on column header row, not on body row-header cells */
#bandstable thead th {
  border-bottom: 1px solid var(--border);
}

/* Stack SVG icon above the column label text without a <br> */
#bandstable thead th .subrow {
  display: block;
}

#bandstable th:first-child {
  text-align: left;
}

#bandstable td {
  padding: 8px 12px 0;
  text-align: center;
}

#bandstable tr.thead-spacer td {
  padding: 0;
  height: 8px;
  border: none;
}

#bandstable td:first-child {
  text-align: left;
}

/* Bold, slightly larger band labels in the data rows */
#bandstable tbody tr:not(.subrow) th {
  font-weight: 600;
  font-size: 1.25em;
  color: var(--text);
}

#bandstable tr.subrow td {
  padding: 1px 12px 8px;
  color: var(--text-muted);
  font-size: 0.95em;
  border-bottom: 1px solid var(--border);
}

/* Status badges */
.status {
  display: inline-block;
  font-weight: bold;
  border-radius: 4px;
  padding: 5px 14px;
  min-width: 82px;
  text-align: center;
  font-size: 1.25em;
}

.status.good {
  background: var(--good-bg);
  color: var(--good-fg);
  border: 1px solid var(--good-border);
}

.status.fair {
  background: var(--fair-bg);
  color: var(--fair-fg);
  border: 1px solid var(--fair-border);
}

.status.bad {
  background: var(--bad-bg);
  color: var(--bad-fg);
  border: 1px solid var(--bad-border);
}

.status.inactive {
  background: var(--inactive-bg);
  color: var(--inactive-fg);
  border: 1px solid var(--inactive-border);
}

/* -----------------------------------------------------------------------
   Condition cards
   ----------------------------------------------------------------------- */

.cond {
  background: var(--bg-cond);
  border: 1px solid var(--border-cond);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.cond:last-child {
  margin-bottom: 0;
}

.cond.inactive {
  background: var(--inactive-bg);
  border-color: var(--inactive-border);
}

.cond.inactive dt,
.cond.inactive .cond_value,
.cond.inactive .subrow {
  color: var(--inactive-fg);
}

.cond_row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cond_value {
  font-size: 1.35em;
  font-weight: bold;
  color: var(--value);
  margin-left: 12px;
  white-space: nowrap;
}

.subrow {
  color: var(--text-muted);
  font-size: 0.86em;
  margin-top: 4px;
}

/* -----------------------------------------------------------------------
   Stats grid
   ----------------------------------------------------------------------- */

#stats-inner,
#vhf-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* -----------------------------------------------------------------------
   Chart
   ----------------------------------------------------------------------- */

#solardata_chart {
  width: 100% !important;
  max-height: 400px;
}

/* -----------------------------------------------------------------------
   Footer
   ----------------------------------------------------------------------- */

#footer, footer#footer {
  text-align: center;
  padding: 16px 20px;
  margin-top: 4px;
  background: var(--bg-block);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.88em;
  line-height: 1.8;
}

/* -----------------------------------------------------------------------
   Reduced motion
   ----------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  body, .block, .cond, #chart_wrapper, #footer,
  #bandstable th, #bandstable td,
  h1, h2, a {
    transition: none !important;
  }
}

/* -----------------------------------------------------------------------
   Definition list resets for condition cards
   ----------------------------------------------------------------------- */

dl.cond { margin: 0; }
dt { display: inline; margin: 0; }
dd { display: inline; margin: 0; }

/* -----------------------------------------------------------------------
   Responsive: single column on small screens
   ----------------------------------------------------------------------- */

@media (max-width: 640px) {
  #wrapper-inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "bands"
      "primaryconds"
      "chart_wrap"
      "stats"
      "vhf";
  }
}
