/* ═══════════════════════════════════════════════
   DESIGN TOKENS — dark (default) and light
═══════════════════════════════════════════════ */
:root,
[data-theme="dark"] {
  --bg:        #0b1120;
  --deep:      #070c17;
  --panel:     #131f35;
  --border:    #1c2e4a;
  --accent:    #00e5ff;
  --accent2:   #ff3d57;
  --gold:      #ffd166;
  --text:      #d0ddf5;
  --muted:     #6b7e9e;
  --heading:   #eef3ff;
  --scanline:  rgba(0,229,255,0.010);
  --shadow:    0 2px 20px rgba(0,0,0,0.55);
  --tag-bg:    rgba(0,229,255,0.12);
  --stat-bg:   #0f1c30;
}

[data-theme="light"] {
  --bg:        #f0f4fb;
  --deep:      #ffffff;
  --panel:     #f8fafd;
  --border:    #dde3ef;
  --accent:    #0070c0;
  --accent2:   #d42040;
  --gold:      #966800;
  --text:      #1e2838;
  --muted:     #556480;
  --heading:   #0a1020;
  --scanline:  transparent;
  --shadow:    0 1px 10px rgba(0,0,0,0.08);
  --tag-bg:    rgba(0,112,192,0.09);
  --stat-bg:   #edf0f7;
}

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

:root { --content-width: 800px; }

html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Transitions enabled only after JS fires — prevents flash-of-wrong-theme on load */
body.theme-ready {
  transition: background 0.4s, color 0.4s;
}
body.theme-ready * {
  transition-property: background, color, border-color, box-shadow;
  transition-duration: 0.4s;
  transition-timing-function: ease;
}
/* Keep interactive elements snappy — override the blanket transition above */
body.theme-ready .refresh-btn,
body.theme-ready .toggle-track,
body.theme-ready .toggle-thumb {
  transition-duration: 0.2s;
}

/* Scanline overlay — off on mobile for performance */
@media (min-width: 768px) {
  body::after {
    content: '';
    position: fixed; inset: 0;
    pointer-events: none; z-index: 9000;
    background: repeating-linear-gradient(
      0deg,
      transparent, transparent 2px,
      var(--scanline) 2px, var(--scanline) 4px
    );
  }
}

img { max-width: 100%; height: auto; display: block; }
a   { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ═══════════════════════════════════════════════
   THEME TOGGLE (reused inside the burger menu)
═══════════════════════════════════════════════ */
.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none; flex-shrink: 0;
  min-height: 38px;
  -webkit-tap-highlight-color: transparent;
}
.toggle-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: #7a8aaa; letter-spacing: 0.12em; text-transform: uppercase;
  width: 34px; text-align: right;
}

.toggle-track {
  position: relative; width: 46px; height: 24px;
  background: #1c2538; border: 1px solid #2a3650;
  border-radius: 12px; flex-shrink: 0;
}
[data-theme="light"] .toggle-track { background: #b8d0f0; border-color: #7aa8d8; }

.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #4a5878;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; line-height: 1;
  transition: transform 0.35s cubic-bezier(.4,0,.2,1), background 0.3s;
}
[data-theme="light"] .toggle-thumb { transform: translateX(22px); background: var(--accent); }

/* ═══════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════ */
header {
  background: var(--deep);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow);
  padding: 10px 32px 10px;
  position: relative; /* burger-menu positions from here, not from burger-wrap */
}
.header-inner {
  max-width: var(--content-width); margin: 0 auto;
  display: flex; flex-wrap: nowrap;
  align-items: center; gap: 12px;
}
@media (max-width: 600px) {
  header { padding: 8px 14px; }
}

.header-titleblock { flex: 1 1 auto; min-width: 0; overflow: hidden; }

/* ── BURGER MENU BUTTON ── */
.burger-wrap { flex-shrink: 0; } /* no position:relative — header is the stacking parent */
.burger-btn {
  width: 36px; height: 36px;
  background: transparent; border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; padding: 0; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.burger-btn:hover { border-color: var(--accent); }
.burger-btn span {
  display: block; width: 16px; height: 2px; background: var(--text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.burger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn.open span:nth-child(2) { opacity: 0; }
.burger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── BURGER MENU PANEL ──
   Positioned from <header> (its nearest positioned ancestor),
   so it always drops below the full header bar on every screen size. */
.burger-menu {
  position: absolute;
  top: calc(100% + 2px); /* just below the header border */
  left: 32px;            /* aligns with the header's left padding */
  width: 300px; max-width: calc(100vw - 32px);
  max-height: 80vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  z-index: 500;
  visibility: hidden; opacity: 0; transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
@media (max-width: 600px) {
  .burger-menu { left: 14px; width: calc(100vw - 28px); max-width: 340px; }
}
.burger-menu.open { visibility: visible; opacity: 1; transform: translateY(0); pointer-events: auto; }
.burger-menu .sidebar-widget {
  margin: 0; box-shadow: none; border-left: none; border-right: none; border-top: none;
  border-bottom: 1px solid var(--border);
}
.burger-menu .sidebar-widget:last-of-type { border-bottom: none; }
.burger-theme-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 14px;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.logo-badge {
  display: inline-block; background: var(--accent); color: #0a0a0a;
  font-family: 'IBM Plex Mono', monospace; font-size: 9px; font-weight: 600;
  letter-spacing: 0.18em; padding: 2px 8px; text-transform: uppercase; margin-bottom: 4px;
}
[data-theme="light"] .logo-badge { color: #fff; }

h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(22px, 4vw, 36px);
  letter-spacing: 0.04em; color: var(--heading); line-height: 0.95;
}
h1 span { color: var(--accent); }

.tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(9px, 1.6vw, 10px);
  color: var(--muted); letter-spacing: 0.1em; margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 600px) { .tagline { white-space: normal; font-size: 9px; } }

.header-right {
  text-align: right; display: flex; flex-direction: column;
  align-items: flex-end; gap: 6px; flex-shrink: 0;
}
@media (max-width: 600px) {
  .header-right { flex-direction: row; align-items: center; gap: 6px; }
  .next-refresh  { display: none; } /* hidden on mobile — saves horizontal space */
}

.next-refresh {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--muted); white-space: nowrap;
}
.next-refresh span { color: var(--accent); font-weight: 600; }

.refresh-btn {
  background: transparent; border: 1px solid var(--accent); color: var(--accent);
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.1em;
  padding: 8px 16px; text-transform: uppercase;
  min-height: 36px; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.refresh-btn:hover:not(:disabled) { background: var(--accent); color: #0a0a0a; }
[data-theme="light"] .refresh-btn:hover:not(:disabled) { color: #fff; }
.refresh-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* On mobile: icon-only for the REFRESH button only — nav link buttons keep their text */
@media (max-width: 600px) {
  .refresh-btn { padding: 0; width: 36px; height: 36px; font-size: 16px; letter-spacing: 0; }
  .refresh-btn.icon-only .btn-text { display: none; }
}

/* ── PROGRESS BAR ── */
.progress-track { background: var(--border); height: 2px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  will-change: width;
  transition: width 1s linear !important;
}

/* ═══════════════════════════════════════════════
   MAIN LAYOUT — single centered feed column
═══════════════════════════════════════════════ */
.main-wrap {
  max-width: var(--content-width); margin: 0 auto; padding: 24px 16px;
}
@media (max-width: 600px) {
  .main-wrap { padding: 16px; }
}

/* ═══════════════════════════════════════════════
   FEED COLUMN
═══════════════════════════════════════════════ */
.feed-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.feed-title {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  letter-spacing: 0.15em; color: var(--accent); text-transform: uppercase;
  font-weight: normal; margin: 0;
}
.story-count { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--muted); }

/* ── STORY CARD ── */
.story-card {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--story-accent, var(--accent));
  padding: 22px 28px; margin-bottom: 12px; box-shadow: var(--shadow);
  animation: fadeUp 0.4s ease both; opacity: 0;
}
@media (max-width: 480px) {
  .story-card { padding: 18px 16px; }
}
@media (hover: hover) {
  .story-card:hover {
    border-left-color: var(--gold); transform: translateX(3px);
    transition: transform 0.15s, border-left-color 0.15s;
  }
}
.story-card.updated { border-left-color: var(--accent2); }

@keyframes fadeUp {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .story-card { animation: none; opacity: 1; } }

.story-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.source-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  background: var(--tag-bg); color: var(--accent);
  padding: 2px 8px; letter-spacing: 0.08em; text-transform: uppercase; flex-shrink: 0;
}
.updated-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  background: rgba(212,32,64,0.1); color: var(--accent2);
  padding: 2px 8px; letter-spacing: 0.08em; text-transform: uppercase;
}
.story-time {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--muted); white-space: nowrap;
}
.story-pub-date {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--accent); margin-left: auto; white-space: nowrap; letter-spacing: 0.04em;
}

.story-title { font-size: clamp(15px,3.5vw,17px); font-weight: 600; color: var(--heading); margin-bottom: 4px; margin-top: 0; line-height: 1.3; }
.story-title a { color: inherit; text-decoration: none; }
.story-title a:hover { color: var(--accent); }
.story-tags { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: var(--muted); border: 1px solid var(--border); padding: 2px 7px; letter-spacing: 0.06em;
}

/* ── LOADING / ERROR states ── */
.state-center { text-align: center; padding: 56px 20px; font-family: 'IBM Plex Mono', monospace; }
.spin { font-size: 28px; display: block; margin-bottom: 14px; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.state-heading { color: var(--accent); font-size: 12px; letter-spacing: 0.12em; }
.state-sub { color: var(--muted); font-size: 10px; margin-top: 6px; line-height: 1.6; }

.error-box {
  background: rgba(255,61,87,0.07); border: 1px solid rgba(255,61,87,0.25);
  padding: 22px; text-align: center; font-family: 'IBM Plex Mono', monospace;
}
.error-box .err-head { color: var(--accent2); font-size: 12px; margin-bottom: 8px; }
.error-box .err-body { color: var(--muted); font-size: 11px; line-height: 1.7; }

/* ── INFINITE SCROLL SENTINEL ── */
.feed-sentinel {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  text-align: center; padding: 22px 12px; min-height: 24px;
}
.feed-sentinel .spin { display: inline-block; font-size: 14px; margin: 0 6px 0 0; vertical-align: middle; }
.feed-sentinel.feed-more { color: var(--accent); }
.feed-sentinel.feed-end  { color: var(--muted); opacity: 0.7; }
.feed-end-line {
  display: inline-block; border-top: 1px solid var(--border);
  padding-top: 14px; padding-left: 6px; padding-right: 6px;
}

/* ═══════════════════════════════════════════════
   SKELETON PLACEHOLDER CARDS
   Shown instantly (no network wait) while the
   first batch of real stories is fetched, so the
   feed never shows a blocking "loading screen".
═══════════════════════════════════════════════ */
.skeleton-card {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  padding: 22px 28px; margin-bottom: 12px;
}
.skeleton-line {
  height: 10px; border-radius: 2px; margin-bottom: 10px;
  background: var(--stat-bg);
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w90 { width: 90%; }
.skeleton-line.w40 { width: 40%; margin-bottom: 0; }
.skeleton-line {
  background-image: linear-gradient(90deg, var(--stat-bg) 25%, var(--border) 37%, var(--stat-bg) 63%);
  background-size: 400% 100%;
  animation: skeletonShine 1.4s ease-in-out infinite;
}
@keyframes skeletonShine {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-line { animation: none; }
}

/* ═══════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════ */
.sidebar-widget { background: var(--panel); border: 1px solid var(--border); margin-bottom: 20px; overflow: hidden; box-shadow: var(--shadow); }
.widget-title { background: var(--stat-bg); padding: 9px 14px; font-family: 'IBM Plex Mono', monospace; font-size: 9px; letter-spacing: 0.15em; color: var(--muted); text-transform: uppercase; font-weight: normal; margin: 0; }
.widget-body { padding: 14px; }
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); font-family: 'IBM Plex Mono', monospace; font-size: 11px; }
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--muted); }
.stat-val { color: var(--accent); font-weight: 600; }
.about-text { font-size: 12px; line-height: 1.7; color: var(--text); }
.about-text strong { color: var(--heading); }
.about-text a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted currentColor; }
.about-text a:hover { text-decoration: none; border-bottom-style: solid; }
.burger-nav { display: flex; flex-direction: column; gap: 2px; }
.burger-nav-link {
  display: block; padding: 9px 4px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.08em;
  color: var(--text); text-decoration: none; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.burger-nav-link:last-child { border-bottom: none; }
.burger-nav-link:hover { color: var(--accent); }

/* ─── DATE RANGE FILTER ─── */
.date-filter-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px;
}
.date-filter-label {
  display: flex; flex-direction: column; gap: 4px;
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase;
  flex: 1; min-width: 110px;
}
.date-filter-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  padding: 6px 8px; color-scheme: dark;
}
[data-theme="light"] .date-filter-input { color-scheme: light; }
.date-filter-input:focus { outline: none; border-color: var(--accent); }
.date-filter-clear {
  display: none; margin-top: 8px; width: 100%;
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase;
  cursor: pointer; background: none; border: 1px solid var(--border); padding: 5px 8px;
}
.date-filter-clear:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════════
   FILTER BUTTONS
═══════════════════════════════════════════════ */
.filter-group { margin-bottom: 14px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-group-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase;
  margin-bottom: 8px;
}
.filter-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-btn {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.06em; padding: 5px 10px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  min-height: 32px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active {
  background: var(--tag-bg); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

/* ═══════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════ */
footer {
  border-top: 1px solid var(--border);
  margin-top: 8px; padding: 18px 32px 52px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  color: var(--muted); letter-spacing: 0.08em; flex-wrap: wrap; gap: 8px;
  max-width: 1464px; margin-left: auto; margin-right: auto;
}
@media (max-width: 600px) {
  footer { padding: 14px 16px 52px; flex-direction: column; text-align: center; gap: 5px; }
}
.footer-nav {
  display: flex; justify-content: center; gap: 18px; flex-wrap: wrap;
  max-width: var(--content-width); margin: 24px auto 0; padding: 0 16px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.08em;
}
.footer-nav a { color: var(--muted); text-decoration: none; text-transform: uppercase; }
.footer-nav a:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════
   STATUS BAR — fixed at bottom of viewport
═══════════════════════════════════════════════ */
.status-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(10,10,10,0.97);
  border-top: 1px solid var(--border);
  padding: 5px 20px;
  padding-bottom: max(5px, env(safe-area-inset-bottom));
  display: flex; gap: 0; overflow: hidden;
  font-family: 'IBM Plex Mono', monospace; font-size: 9px;
  color: var(--muted); letter-spacing: 0.07em; z-index: 200;
}
[data-theme="light"] .status-bar { background: rgba(240,244,251,0.97); }
.status-item {
  padding: 0 12px; border-right: 1px solid var(--border);
  white-space: nowrap; display: flex; align-items: center; gap: 4px;
}
.status-item:last-child { border-right: none; }
.status-item span { color: var(--accent); }
@media (max-width: 640px) { .status-item:nth-child(n+3) { display: none; } }
@media (max-width: 380px) { .status-item:nth-child(n+2) { display: none; } }
