/* ═══════════════════════════════════════════════════════════════
   Nile Intel — design tokens shared by every page
   One source for colour, type, radius and motion. Pages style their own
   layout with these variables; nothing else should hard-code a colour
   that has to change between light and dark.
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-alt: #F6F7F9;
  --hover-bg: #F8F9FA;
  --skeleton: #EEF0F2;
  --tint: #F0F6FF;               /* soft blue panels (subscribe, callouts) */

  /* Text: every level passes WCAG AA on --bg */
  --text-primary: #0F172A;        /* Nile navy: the brand colour, used for ink and main actions */
  --text-secondary: #4D535C;
  --text-tertiary: #6B717A;
  --on-ink: #FFFFFF;             /* text on a --text-primary background */

  /* Lines */
  --border: #E6E8EB;
  --border-light: #F1F2F4;

  /* Brand: navy (above) is primary, blue marks what's interactive or
     live, red is reserved for severity and breaking news */
  --accent: #1A6FDB;
  --accent-light: #E8F1FD;
  --accent-border: #BFD7F6;

  /* Callouts */
  --warn-bg: #FFFBEB;
  --warn-text: #92400E;
  --warn-border: #FDE68A;
  --ok-bg: #F0FDF4;
  --ok-text: #166534;
  --signal: #DC2626;

  /* Shape and depth */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.04);
  --shadow-hover: 0 8px 28px rgba(0,0,0,0.10), 0 0 1px rgba(0,0,0,0.04);

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Layout */
  --max-width: 1060px;
  --content-width: 760px;
}

/* Appearance: Auto follows the device; readers can pick Light or Dark
   (theme.js sets <html data-theme>). Same palette either way. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1114;
    --surface: #171A1E;
    --surface-alt: #1D2126;
    --hover-bg: #1B1E23;
    --skeleton: #242830;
    --tint: #142033;
    --text-primary: #EEF0F3;
    --text-secondary: #B3B9C2;
    --text-tertiary: #8D949E;
    --on-ink: #0F1114;
    --border: #2B3038;
    --border-light: #22262C;
    --accent: #6AA6F8;
    --accent-light: rgba(106, 166, 248, 0.14);
    --accent-border: rgba(106, 166, 248, 0.35);
    --warn-bg: rgba(245, 158, 11, 0.12);
    --warn-text: #FCD34D;
    --warn-border: rgba(245, 158, 11, 0.35);
    --ok-bg: rgba(34, 197, 94, 0.12);
    --ok-text: #86EFAC;
    --signal: #F87171;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.45);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-hover: 0 8px 28px rgba(0,0,0,0.55);
  }
  :root:not([data-theme="light"]) img:not([src$=".svg"]) { filter: brightness(0.92); }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0F1114;
    --surface: #171A1E;
    --surface-alt: #1D2126;
    --hover-bg: #1B1E23;
    --skeleton: #242830;
    --tint: #142033;
    --text-primary: #EEF0F3;
    --text-secondary: #B3B9C2;
    --text-tertiary: #8D949E;
    --on-ink: #0F1114;
    --border: #2B3038;
    --border-light: #22262C;
    --accent: #6AA6F8;
    --accent-light: rgba(106, 166, 248, 0.14);
    --accent-border: rgba(106, 166, 248, 0.35);
    --warn-bg: rgba(245, 158, 11, 0.12);
    --warn-text: #FCD34D;
    --warn-border: rgba(245, 158, 11, 0.35);
    --ok-bg: rgba(34, 197, 94, 0.12);
    --ok-text: #86EFAC;
    --signal: #F87171;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.45);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
    --shadow-hover: 0 8px 28px rgba(0,0,0,0.55);
}

:root[data-theme="dark"] img:not([src$=".svg"]) { filter: brightness(0.92); }

/* Appearance picker (added to every footer by theme.js) */
.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 12px auto 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.theme-picker-label {
  font: 600 12px/1 var(--font-sans);
  color: var(--text-tertiary);
  padding: 0 8px 0 10px;
}

.theme-picker button {
  font: 600 12px/1 var(--font-sans);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
}

.theme-picker button[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--on-ink);
}

.theme-picker-wrap { display: flex; justify-content: center; width: 100%; }

/* Keyboard users always see where they are */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Clickable cards are focusable too (see app.js) */
[data-story-index]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text-primary);
  color: var(--on-ink);
  font: 600 14px/1 var(--font-sans);
  text-decoration: none;
}

.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── Notifications / install panel (pwa.js) ────────────────── */

.push-panel {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  text-align: left;
}

.card .push-panel { margin: 0; background: none; border: none; padding: 0; }

.push-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.push-status { font: 500 14px/1.45 var(--font-sans); color: var(--text-primary); flex: 1 1 200px; }
.push-note { font: 400 13px/1.5 var(--font-sans); color: var(--text-secondary); margin: 6px 0 0; }
.push-note:first-child { margin-top: 0; }

.push-btn {
  font: 700 14px/1 var(--font-sans);
  min-height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  border: none;
  background: var(--text-primary);
  color: var(--on-ink);
  cursor: pointer;
  white-space: nowrap;
}

.push-btn-secondary { background: none; color: var(--text-primary); border: 1px solid var(--border); }
.push-install { margin-top: 10px; }
.push-btn:disabled { opacity: 0.6; cursor: progress; }

/* ─── Header actions (every page; header.js fills them in) ──── */

.header-actions { display: flex; align-items: center; gap: 8px; }

.header-signin {
  display: inline-flex;
  align-items: center;
  font: 600 14px/1 var(--font-sans);
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 6px;
}

.header-signin:hover { color: var(--text-primary); }
.signin-icon { display: none; width: 22px; height: 22px; }

.header-alerts-btn {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 17px;
  border: none;
  background: var(--text-primary);
  color: var(--on-ink);
  font: 700 13px/1 var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

/* Phones: a person icon instead of the word, so the header holds the
   logo and one action */
@media (max-width: 768px) {
  .header-signin { width: 40px; height: 40px; justify-content: center; padding: 0; color: var(--text-primary); }
  .signin-icon { display: block; }
  .signin-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
}

/* Bottom tab bar on phones: the current tab is marked by colour alone */
@media (max-width: 768px) {
  .header-page-link.active { border-top-color: transparent !important; }
}
