/* =========================================================================
   JoCo Scanner — stylesheet
   Design direction: the site is framed as a piece of radio equipment.
   Dark "chassis" chrome (header/footer/player bar) houses light, highly
   readable "paper" content panels — echoing a scanner's dark plastic
   housing around its readout. The signature element is the channel bank:
   feeds are numbered CH01/CH02 like physical scanner channels, with amber
   LED-style status dots, carried through into the frequency tables.
   No build step — plain CSS with custom properties. Mobile-first.
   ========================================================================= */

:root {
  /* ---- Color tokens ---- */
  --panel-black: #14181a;       /* chassis: header, footer, player bar */
  --panel-black-raised: #1f2527; /* raised chassis surfaces, cards-on-dark */
  --panel-line: #2c3335;         /* hairlines on dark chassis */
  --paper: #f7f5f0;              /* page background */
  --paper-raised: #ffffff;       /* card background on paper */
  --ink: #1b1f1d;                /* body text */
  --ink-soft: #4b524e;           /* secondary text */
  --steel: #6b7370;              /* muted steel — borders, captions */
  --steel-line: #d8d4c9;         /* hairlines on paper */
  --pine: #2f4b3c;                /* deep pine — headings/links on paper */
  --pine-dark: #223a2d;
  --amber: #ffb000;               /* scanner-LCD amber — accent / live LED */
  --amber-dim: #8a5f00;
  --red-alert: #b3402c;           /* offline / alert state */
  --green-live: #4caf6b;

  /* ---- Type ---- */
  --font-display: 'Space Grotesk', 'Arial Narrow', sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* ---- Layout ---- */
  --content-max: 920px;
  --content-max-wide: 920px;
  --radius: 6px;
  --gap: 1rem;

  color-scheme: light;
}

@media (min-width: 1200px) {
  :root { --content-max: 1040px; --content-max-wide: 1240px; }
}
@media (min-width: 1600px) {
  :root { --content-max: 1100px; --content-max-wide: 1400px; }
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.2; color: var(--pine-dark); margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.7rem); margin-top: 2rem; }
h3 { font-size: 1.15rem; margin-top: 1.5rem; }
p { margin: 0 0 1em; }
a { color: var(--pine); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--amber-dim); }
ul, ol { padding-left: 1.25em; }
hr { border: none; border-top: 1px solid var(--steel-line); margin: 2rem 0; }
code, kbd { font-family: var(--font-mono); background: #eeeade; padding: .1em .35em; border-radius: 3px; font-size: .9em; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 1000;
  background: var(--amber); color: var(--panel-black); padding: .6em 1em;
  font-family: var(--font-mono); font-weight: 700;
}
.skip-link:focus { left: .5rem; top: .5rem; }

.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-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* =========================================================================
   Header / navigation
   ========================================================================= */
.site-header {
  background: var(--panel-black);
  color: #ece7da;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--panel-line);
}
.site-header__bar {
  max-width: var(--content-max-wide);
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: inherit; min-width: 0; }
.brand__logo { height: 34px; width: auto; filter: brightness(0) invert(1); opacity: .95; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; letter-spacing: .01em; color: #fff; }
.brand__tagline { font-size: .72rem; color: #a9b0ab; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-toggle {
  background: none; border: 1px solid var(--panel-line); border-radius: var(--radius);
  width: 42px; height: 38px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; cursor: pointer;
}
.nav-toggle__bar { width: 20px; height: 2px; background: #ece7da; display: block; }

.site-nav {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
  background: var(--panel-black-raised);
}
.site-nav.is-open { max-height: 480px; }
.site-nav ul { list-style: none; margin: 0; padding: .25rem 1rem 1rem; display: flex; flex-direction: column; }
.site-nav a {
  display: block; padding: .65rem .25rem; color: #ece7da; text-decoration: none;
  font-family: var(--font-mono); font-size: .95rem; letter-spacing: .02em;
  border-bottom: 1px solid var(--panel-line);
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--amber); }

@media (min-width: 720px) {
  .nav-toggle { display: none; }
  .site-nav { max-height: none; overflow: visible; background: transparent; }
  .site-nav ul { flex-direction: row; padding: 0 1rem; max-width: var(--content-max-wide); margin: 0 auto; gap: .25rem; flex-wrap: wrap; }
  .site-nav a { border-bottom: 2px solid transparent; padding: .6rem .55rem; }
  .site-nav a:hover, .site-nav a[aria-current="page"] { border-bottom-color: var(--amber); }
}

/* =========================================================================
   Main content shell
   ========================================================================= */
.site-main { max-width: var(--content-max); margin: 0 auto; padding: 1.25rem 1rem 5rem; }
.site-main--wide { max-width: var(--content-max-wide); }
.page-content { background: var(--paper-raised); border: 1px solid var(--steel-line); border-radius: var(--radius); padding: 1.25rem 1.25rem 1.5rem; }

/* Long-form prose (legal, basics, contact) reads better at a capped line
   length even when the surrounding page has room to spare — a 1400px-wide
   paragraph is exhausting to read, a 1400px-wide table or card grid isn't. */
.page-content--prose { max-width: 74ch; }

@media (min-width: 720px) {
  .site-main { padding: 2rem 1.5rem 6rem; }
  .page-content { padding: 2rem 2.25rem 2.5rem; }
}

.eyebrow {
  display: inline-block; font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--amber-dim); background: #fff3d9; border: 1px solid #f0d798;
  padding: .2em .6em; border-radius: 3px; margin-bottom: .6rem;
}

/* =========================================================================
   Hero / Channel bank (signature element)
   ========================================================================= */
.hero {
  background: var(--panel-black);
  color: #ece7da;
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  /* faint topo-line texture referencing the Rogue Valley terrain this
     coverage area sits in */
  content: "";
  position: absolute; inset: 0; opacity: .12; pointer-events: none;
  background-image:
    repeating-radial-gradient(circle at 85% 20%, transparent 0 18px, var(--pine) 18px 19px, transparent 19px 40px);
}
.hero__title { color: #fff; position: relative; }
.hero__lede { color: #b9c0ba; max-width: 46ch; position: relative; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.15rem; position: relative; }
.btn-hero {
  font-family: var(--font-mono); font-weight: 600; font-size: .85rem;
  background: var(--amber); color: var(--panel-black); border: 1px solid var(--amber);
  border-radius: 4px; padding: .65em 1.2em; text-decoration: none;
}
.btn-hero:hover { background: #ffc233; color: var(--panel-black); }
.btn-hero--ghost { background: transparent; color: #ece7da; border-color: #3a4340; }
.btn-hero--ghost:hover { border-color: var(--amber); color: var(--amber); }

/* ---- Home page: main column + sidebar on wide screens ---- */
.home-layout { display: flex; flex-direction: column; gap: 1.5rem; }
.home-main { min-width: 0; }
.home-side { display: flex; flex-direction: column; gap: 1.25rem; }

@media (min-width: 960px) {
  .home-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 2rem; align-items: start; }
  .home-side { position: sticky; top: 5.5rem; }
}
@media (min-width: 1300px) {
  .home-layout { grid-template-columns: minmax(0, 1fr) 380px; gap: 2.75rem; }
}

.onair-card { background: var(--panel-black); border-radius: var(--radius); padding: 1.1rem 1.1rem 1.25rem; color: #ece7da; }
.onair-card__title { font-family: var(--font-display); color: #fff; font-size: 1.05rem; margin: 0 0 .6rem; }
.onair-card__empty { font-size: .84rem; color: #b9c0ba; margin: 0 0 .75rem; line-height: 1.5; }
.onair-card__empty a { color: var(--amber); }
.channel-bank--compact { gap: .4rem; }
.channel-bank--compact .channel { padding: .5rem .6rem; grid-template-columns: auto 1fr auto; }
.channel-bank--compact .channel__num { display: none; }

.channel-bank { list-style: none; margin: 1.25rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; position: relative; }
.channel {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: .65rem;
  background: var(--panel-black-raised);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  padding: .65rem .75rem;
}
.channel__num { font-family: var(--font-mono); font-size: .8rem; color: #8f978f; letter-spacing: .04em; }
.channel__led {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--steel); box-shadow: none;
}
.channel__led--live {
  background: var(--amber);
  box-shadow: 0 0 6px 1px rgba(255, 176, 0, .8);
  animation: led-pulse 2.4s ease-in-out infinite;
}
.channel__led--offline { background: var(--red-alert); }
@media (prefers-reduced-motion: reduce) { .channel__led--live { animation: none; } }
@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
.channel__info { min-width: 0; display: flex; flex-direction: column; }
.channel__name { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel__status { font-size: .78rem; color: #9aa19b; }
.channel__status--offline { color: #e5a291; }
.channel__play {
  font-family: var(--font-mono); font-size: .82rem; font-weight: 600;
  background: var(--amber); color: var(--panel-black); border: none;
  border-radius: 4px; padding: .5em .9em; cursor: pointer; white-space: nowrap;
}
.channel__play:hover { background: #ffc233; }
.channel__play:disabled { background: var(--panel-line); color: #777; cursor: not-allowed; }

@media (max-width: 420px) {
  .channel { grid-template-columns: auto 1fr auto; }
  .channel__num { display: none; }
}

/* =========================================================================
   Cards / quick nav grid
   ========================================================================= */
.card-grid { display: grid; grid-template-columns: 1fr; gap: .85rem; margin: 1.5rem 0; }
@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

.nav-card {
  display: block; text-decoration: none; background: var(--paper-raised);
  border: 1px solid var(--steel-line); border-left: 4px solid var(--pine);
  border-radius: var(--radius); padding: 1rem 1.1rem; color: var(--ink);
}
.nav-card:hover { border-left-color: var(--amber); }
.nav-card__title { display: block; font-family: var(--font-display); font-weight: 700; color: var(--pine-dark); margin-bottom: .2rem; }
.nav-card__desc { font-size: .88rem; color: var(--ink-soft); }

.news-card { background: #fbf6e4; border: 1px solid #edddab; border-radius: var(--radius); padding: 1rem 1.15rem; margin: 1.25rem 0; }
.news-card__date { font-family: var(--font-mono); font-size: .78rem; color: var(--amber-dim); display: block; margin-bottom: .3rem; }

/* =========================================================================
   Tables — desktop table, mobile stacked cards (no JS required)
   ========================================================================= */
.data-table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .95rem; }
.data-table caption { text-align: left; font-size: .85rem; color: var(--ink-soft); margin-bottom: .4rem; }
.data-table th { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.data-table td, .data-table th { padding: .6rem .5rem; text-align: left; }
.data-table tbody tr { border-bottom: 1px solid var(--steel-line); }
.data-table td.mono, .data-table .freq { font-family: var(--font-mono); }

/* Tables authored as Markdown (Static Page Editor) get wrapped in this by
   JocoMarkdown::blockTableComplete() — same .data-table styling above
   applies, this just adds horizontal scroll at tablet widths where a
   wide table might not fully fit before the <640px stacked view takes over. */
.md-table-scroll { overflow-x: auto; margin: 1rem 0; }
.md-table-scroll .data-table { margin: 0; }
@media (max-width: 640px) { .md-table-scroll { overflow-x: visible; } }

/* Generic definition lists / basic lists inside Markdown-authored content */
.page-content dl { margin: 1rem 0; }
.page-content dt { font-weight: 600; color: var(--pine-dark); margin-top: .6rem; }
.page-content dd { margin: 0 0 .4rem; }

/* At tablet widths the table is still in horizontal mode (not yet the
   stacked mobile card layout) but often too narrow for 7 columns.
   Callsign/ID are the least useful at a glance, so they fold away until
   there's room; the mobile card view (below) always shows every field. */
.data-table .col-optional { display: none; }
@media (min-width: 900px) { .data-table .col-optional { display: table-cell; } }

@media (max-width: 640px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--steel-line); border-radius: var(--radius); margin-bottom: .6rem; padding: .4rem .6rem; }
  .data-table td { border: none; padding: .3rem 0; display: flex; justify-content: space-between; gap: 1rem; }
  .data-table td::before { content: attr(data-label); font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--steel); flex-shrink: 0; }
  .data-table td.col-optional { display: flex; }
}

/* incident / frequency "listen" buttons inside tables */
.btn-listen {
  font-family: var(--font-mono); font-size: .78rem; font-weight: 600;
  background: var(--pine); color: #fff; border: none; border-radius: 4px;
  padding: .4em .8em; cursor: pointer;
}
.btn-listen:hover { background: var(--pine-dark); }

.data-table__note-row td { background: #f5f2e8; font-size: .85rem; color: var(--ink-soft); font-style: italic; }
.data-table__note-row td::before { content: none !important; }
@media (max-width: 640px) {
  .data-table__note-row { border: none !important; margin-top: -.6rem !important; margin-bottom: .6rem !important; }
  .data-table__note-row td { display: block !important; padding: .5rem .6rem !important; border-radius: 0 0 var(--radius) var(--radius); }
}

/* =========================================================================
   Collapsible groups (frequencies / glossary) — native <details>, no JS
   ========================================================================= */
.group { border: 1px solid var(--steel-line); border-radius: var(--radius); margin-bottom: .75rem; overflow: hidden; }
.group > summary {
  cursor: pointer; list-style: none; padding: .8rem 1rem; font-family: var(--font-display);
  font-weight: 700; color: var(--pine-dark); background: #f0ede3; display: flex;
  align-items: center; justify-content: space-between;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "+"; font-family: var(--font-mono); font-weight: 400; color: var(--steel); }
.group[open] > summary::after { content: "\2212"; }
.group__body { padding: .25rem 1rem 1rem; }

.glossary-jump { display: flex; flex-wrap: wrap; gap: .3rem; font-family: var(--font-mono); font-size: .85rem; margin: 1rem 0 1.5rem; }
.glossary-jump a { padding: .15em .45em; border: 1px solid var(--steel-line); border-radius: 3px; text-decoration: none; }
.glossary-term { display: grid; grid-template-columns: 7ch 1fr; gap: .75rem; padding: .5rem 0; border-bottom: 1px dotted var(--steel-line); }
.glossary-term dt { font-family: var(--font-mono); font-weight: 700; color: var(--pine-dark); }
.glossary-term dd { margin: 0; }
@media (max-width: 480px) { .glossary-term { grid-template-columns: 1fr; gap: .15rem; } }

.frequency-groups { display: flex; flex-direction: column; gap: .75rem; }
@media (min-width: 1100px) {
  .frequency-groups { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; align-items: start; }
}

.csv-links { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; margin: 0 0 1.25rem; font-size: .85rem; }
.csv-links__label { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--steel); }
.csv-links__link {
  font-family: var(--font-mono); font-size: .8rem; text-decoration: none; color: var(--pine);
  border: 1px solid var(--steel-line); border-radius: 4px; padding: .3em .7em;
}
.csv-links__link:hover { border-color: var(--pine); background: #f0ede3; }

/* =========================================================================
   Alert / callout boxes (legal disclaimers etc.)
   ========================================================================= */
.callout { border-left: 4px solid var(--amber); background: #fff8e6; padding: .9rem 1.1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.25rem 0; font-size: .95rem; }
.callout--muted { border-left-color: var(--steel); background: #f1efe7; color: var(--ink-soft); }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { background: var(--panel-black); color: #9aa19b; margin-top: 3rem; }
.site-footer__inner { max-width: var(--content-max-wide); margin: 0 auto; padding: 1.75rem 1rem 6.5rem; font-size: .85rem; }
.site-footer a { color: #d5cfa9; }
.site-footer__links { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-bottom: .75rem; list-style: none; padding: 0; font-family: var(--font-mono); font-size: .8rem; }

@media (min-width: 720px) { .site-footer__inner { padding-bottom: 5.5rem; } }

/* =========================================================================
   Persistent mini player bar
   ========================================================================= */
.player-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--panel-black-raised); border-top: 1px solid var(--panel-line);
  color: #ece7da;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .75rem;
  padding-bottom: calc(.55rem + env(safe-area-inset-bottom));
}
.player-bar[hidden] { display: none; }
.player-bar__meta { display: flex; align-items: center; gap: .55rem; min-width: 0; flex: 0 1 auto; }
.player-bar__led { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px 1px rgba(255,176,0,.8); animation: led-pulse 2.4s ease-in-out infinite; flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) { .player-bar__led { animation: none; } }
.player-bar__text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.player-bar__label { font-family: var(--font-mono); font-size: .65rem; text-transform: uppercase; letter-spacing: .06em; color: #8f978f; }
.player-bar__name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.player-bar__audio { flex: 1 1 auto; min-width: 0; height: 36px; }
.player-bar__close {
  background: none; border: 1px solid var(--panel-line); color: #ece7da; border-radius: 4px;
  width: 32px; height: 32px; flex-shrink: 0; cursor: pointer; font-size: .95rem;
}

/* Plyr theme tweaks so the audio widget matches the amber/charcoal palette */
.player-bar .plyr { --plyr-color-main: var(--amber); --plyr-audio-controls-background: transparent; --plyr-audio-control-color: #ece7da; }

/* =========================================================================
   Misc utility
   ========================================================================= */
.fatal-error { max-width: 480px; margin: 4rem auto; padding: 2rem; background: var(--paper-raised); border-radius: var(--radius); text-align: center; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }

@media print {
  .site-header, .site-footer, .player-bar, .nav-toggle, .btn-listen, .channel__play { display: none !important; }
  body { background: #fff; }
  .page-content { border: none; padding: 0; }
}
