/* Fyniks X News — dark macOS (MacBookPro) theme over the dynamic shader
   background. The #field canvas paints the animated cloud field behind
   everything (see public/field.js); a CSS gradient stands in when WebGL2 is
   unavailable. Everything above it is translucent rounded glass — floating
   toolbar, cards, footer — with content legibility first: glass panels keep
   enough opacity to hold contrast over the moving field. CSS only, no JS
   styling. */

:root {
  --bg: #16171b;
  --bg-deep: #0f1013;
  --glass: rgba(13, 15, 20, 0.55);
  --glass-strong: rgba(13, 15, 20, 0.72);
  --surface: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.085);
  --border: rgba(255, 255, 255, 0.10);
  --border-bright: rgba(255, 255, 255, 0.20);
  --text: #f2f3f6;
  --text-dim: #a7abb6;
  --text-faint: #7c8290;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --gold: #ffd60a;
  --radius-xl: 22px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  --blur: blur(26px) saturate(170%);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  /* fallback field: static clouds if WebGL2 is unavailable */
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(10, 132, 255, 0.14), transparent 60%),
    radial-gradient(900px 420px at -10% 12%, rgba(110, 80, 200, 0.10), transparent 55%),
    linear-gradient(180deg, var(--bg-deep), var(--bg) 30%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------- dynamic background layers */
#field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* film grain over the field (data: URL, allowed by img-src data:) */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.05em 0.4em;
}

/* ------------------------------------------- floating glass toolbar */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  max-width: 1180px;
  margin: 12px auto 0;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.topbar-inner {
  padding: 12px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #bf5af2);
  box-shadow: 0 0 12px rgba(10, 132, 255, 0.7);
}

.nav { display: flex; gap: 6px; }
.nav a {
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 550;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.subject-strip {
  padding: 0 18px 12px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.strip-chip {
  flex: none;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  transition: all 0.15s ease;
}
.strip-chip:hover {
  color: var(--text);
  border-color: var(--border-bright);
  text-decoration: none;
}
.strip-chip.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* --------------------------------------------------------------- main */
.wrap {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.hero { padding: 34px 0 26px; position: relative; }
.hero-slim { padding: 22px 0 10px; }

/* soft scrim keeps hero type legible over the moving field */
.hero::before {
  content: "";
  position: absolute;
  inset: -6vh -12vw;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(15, 16, 19, 0.55) 0%, rgba(15, 16, 19, 0.32) 55%, rgba(15, 16, 19, 0) 100%);
  filter: blur(8px);
  pointer-events: none;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 750;
}

.lede {
  margin: 0;
  max-width: 62ch;
  color: var(--text-dim);
  font-size: 17px;
}

.hero-meta {
  margin: 12px 0 0;
  color: var(--text-faint);
  font-size: 13.5px;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
  max-width: 900px;
}

/* ------------------------------------------------------------- blocks */
.block { margin: 30px 0 8px; }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.block-head h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.more { font-size: 13.5px; font-weight: 550; white-space: nowrap; }
.count-label { color: var(--text-faint); font-size: 13px; }
.subject-group { margin: 26px 0 6px; }

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
}

.group-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ------------------------------------------------ glass story cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 16px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-bright);
  background: var(--glass-strong);
}

.card-top { display: flex; align-items: flex-start; gap: 10px; }

.rank {
  flex: none;
  min-width: 34px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(255, 214, 10, 0.12);
  border: 1px solid rgba(255, 214, 10, 0.25);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 2px;
}

.card-title {
  margin: 0;
  font-size: 16.5px;
  line-height: 1.32;
  letter-spacing: -0.012em;
  font-weight: 650;
}
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); text-decoration: none; }

.synopsis {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.chip {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}
a.chip:hover { color: var(--text); border-color: var(--border-bright); text-decoration: none; }
.chip-subject { color: var(--accent); background: var(--accent-soft); border-color: rgba(10, 132, 255, 0.3); }
.chip .count { color: var(--text-faint); margin-left: 4px; }

.date { color: var(--text-faint); font-size: 12px; margin-left: auto; }

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

.ext {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  transition: all 0.15s ease;
}
.ext:hover { color: var(--accent); border-color: rgba(10, 132, 255, 0.4); text-decoration: none; }
.ext-also { opacity: 0.85; }

.empty { color: var(--text-faint); }

/* --------------------------------------- auto-refresh toggle (glass) */
.refresh-ctl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.refresh-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 12px 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.refresh-switch:hover { border-color: var(--border-bright); background: var(--surface-hover); }
.refresh-switch:hover .refresh-text { color: var(--text); }

.refresh-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.refresh-track {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.refresh-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease;
}

.refresh-input:checked + .refresh-track {
  background: var(--accent);
  border-color: var(--accent);
}
.refresh-input:checked + .refresh-track .refresh-knob { transform: translateX(14px); }
.refresh-input:focus-visible + .refresh-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.refresh-input:disabled + .refresh-track { opacity: 0.5; }

.refresh-text {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-dim);
  white-space: nowrap;
  transition: color 0.15s ease;
}

.refresh-status {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ------------------------------------------------ glass footer bar */
.footer {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto 16px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 18px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.footer p { margin: 4px 0; }
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--accent); }
.footer strong { color: var(--text-dim); font-weight: 600; }

/* --------------------------------------------------------- responsive */
@media (max-width: 640px) {
  .topbar { top: 8px; margin: 8px 8px 0; }
  .topbar-inner { padding: 12px 16px 8px; flex-wrap: wrap; }
  .subject-strip { padding: 0 16px 10px; }
  .wrap { padding: 20px 16px 48px; }
  .grid { grid-template-columns: 1fr; }
  .nav a { padding: 6px 10px; }
  .date { margin-left: 0; }
  .refresh-status { display: none; }
  .footer { margin: 0 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .nav a, .strip-chip, .ext, .refresh-track, .refresh-knob, .refresh-text { transition: none; }
  .card:hover { transform: none; }
}
