/* news-breaking — editorial UI. Dark-first, light theme via data-theme / prefers-color-scheme. */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #0b1120;
  --bg-elev: #111a2e;
  --bg-card: #141f36;
  --bg-hover: #1a2743;
  --border: #223052;
  --text: #e6ebf5;
  --text-2: #a6b1c8;
  --text-3: #7c88a3;
  --link: #8ab4ff;
  --accent: #ef4444;
  --accent-2: #f59e0b;
  --ok: #34d399;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --max: 1240px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7fb; --bg-elev: #ffffff; --bg-card: #ffffff; --bg-hover: #f0f3fa; --border: #e3e7f0;
    --text: #0f172a; --text-2: #3d4a63; --text-3: #6b7690; --link: #1d4ed8;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f7fb; --bg-elev: #ffffff; --bg-card: #ffffff; --bg-hover: #f0f3fa; --border: #e3e7f0;
  --text: #0f172a; --text-2: #3d4a63; --text-3: #6b7690; --link: #1d4ed8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; font-size: 16px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-elev); border: 1px solid var(--border); padding: 0 0.3em; border-radius: 6px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.container { width: min(100% - 2rem, var(--max)); margin-inline: auto; }
.muted { color: var(--text-2); }
.small { font-size: 0.85rem; }
.ok { color: var(--ok); }
.fail { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 0.5rem 1rem; z-index: 100; }
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- header */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 0; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--text); font-weight: 800; letter-spacing: -0.02em; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-mark svg { display: block; }
.search { flex: 1; max-width: 420px; }
.search input { width: 100%; padding: 0.55rem 0.9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font: inherit; }
.search input:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.country-select select { padding: 0.5rem 0.7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font: inherit; max-width: 180px; }
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #dc2626; }
.btn-danger { color: var(--accent); }
.btn-alert.on { border-color: var(--ok); color: var(--ok); }
.btn-ghost { background: transparent; }
:root[data-theme="light"] .icon-moon, :root:not([data-theme="dark"]) .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun, :root:not([data-theme="dark"]) .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
}
.topnav { display: flex; gap: 0.25rem; overflow-x: auto; padding: 0 0 0.5rem; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--text-2); padding: 0.35rem 0.7rem; border-radius: 999px; white-space: nowrap; font-weight: 600; font-size: 0.92rem; }
.topnav a:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.topnav a.active { background: var(--text); color: var(--bg); }

/* ---------------------------------------------------------------- ticker */
.ticker { background: var(--accent); color: #fff; overflow: hidden; }
.ticker[hidden] { display: none; }
.ticker-row { display: flex; align-items: center; gap: 1rem; padding: 0.4rem 0; }
.ticker-label { font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; flex: none; display: flex; align-items: center; gap: 0.4rem; }
.ticker-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
.ticker-track { display: flex; gap: 2.5rem; white-space: nowrap; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent); }
.ticker-track:hover .ticker-item { animation-play-state: paused; }
.ticker-item { color: #fff; font-weight: 600; animation: marquee 40s linear infinite; }
.ticker-item:hover { text-decoration: underline; }
.ticker-src { opacity: 0.8; font-weight: 400; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes blink { 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .ticker-item { animation: none; } .ticker-label::before { animation: none; } .pulse { animation: none; } }

/* ---------------------------------------------------------------- sections */
main { padding: 1.5rem 0 3rem; }
.section { margin: 0 0 2.25rem; }
.section-head { display: flex; align-items: baseline; gap: 0.8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.section-head h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.section-head h2 a { color: var(--text); }
.section-head .more { margin-left: auto; font-weight: 600; }
.section-breaking .section-head h2 { color: var(--accent); }
.home-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 2rem; }
@media (max-width: 960px) { .home-layout { grid-template-columns: 1fr; } }
.sidebar { border-left: 1px solid var(--border); padding-left: 1.5rem; }
@media (max-width: 960px) { .sidebar { border-left: 0; padding-left: 0; } }

/* ---------------------------------------------------------------- grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; }
.grid-5 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.story { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease; position: relative; }
.story:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--border) 50%, var(--text-3)); }
.story.imp-breaking { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.story.imp-breaking::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); z-index: 1; }
.thumb { display: block; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--bg-elev), var(--bg-hover)); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.story:hover .thumb img { transform: scale(1.03); }
.thumb-fallback { display: grid; place-items: center; height: 100%; font-size: 2.4rem; opacity: 0.55; }
.story-body { padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.story-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.story-title a { color: var(--text); }
.snippet { margin: 0; color: var(--text-2); font-size: 0.93rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.story-foot { margin-top: auto; display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.82rem; padding-top: 0.3rem; }
.story-foot .ext { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-foot .details { color: var(--link); white-space: nowrap; }
.meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--text-3); }
.meta .src { color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem; }
.meta .chip { color: var(--text-2); background: var(--bg-elev); border: 1px solid var(--border); padding: 0 0.5rem; border-radius: 999px; }
.meta .coverage { color: var(--accent-2); font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.68rem; padding: 0.15rem 0.5rem; border-radius: 999px; }
.badge-breaking { background: var(--accent); color: #fff; }
.badge-high { background: color-mix(in srgb, var(--accent-2) 22%, transparent); color: var(--accent-2); }
.badge-medium { background: color-mix(in srgb, var(--link) 18%, transparent); color: var(--link); }
.badge-low { background: var(--bg-elev); color: var(--text-3); border: 1px solid var(--border); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }

/* hero variant */
.story-hero { grid-column: 1 / -1; flex-direction: row; }
.story-hero .thumb { flex: 0 0 52%; aspect-ratio: auto; min-height: 260px; }
.story-hero .story-body { padding: 1.4rem 1.5rem; justify-content: center; }
.story-hero .story-title { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.story-hero .snippet { font-size: 1.02rem; -webkit-line-clamp: 4; }
@media (max-width: 700px) { .story-hero { flex-direction: column; } .story-hero .thumb { flex: none; aspect-ratio: 16 / 9; min-height: 0; } .story-hero .story-title { font-size: 1.3rem; } }

/* row variant */
.rows { display: flex; flex-direction: column; gap: 0.6rem; }
.story-row { flex-direction: row; align-items: stretch; border-radius: 10px; }
.story-row .thumb { flex: 0 0 96px; aspect-ratio: 1; }
.story-row .thumb-fallback { font-size: 1.5rem; }
.story-row .story-body { padding: 0.6rem 0.8rem; gap: 0.3rem; }
.story-row .story-title { font-size: 0.95rem; }
.story-row .story-foot { display: none; }
.story-row .meta { font-size: 0.72rem; }
.story-row .meta .chip { display: none; }

/* ---------------------------------------------------------------- detail */
.detail { max-width: 860px; }
.detail-title { font-size: clamp(1.6rem, 3.5vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; margin: 0.6rem 0 1rem; }
.detail-title a { color: var(--text); }
.detail-image img { border-radius: var(--radius); margin-bottom: 1rem; max-height: 480px; object-fit: cover; width: 100%; }
.lead { font-size: 1.15rem; color: var(--text-2); }
.facts { display: grid; gap: 0.6rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.5rem 0; }
.facts > div { display: grid; grid-template-columns: 9rem 1fr; gap: 0.6rem; align-items: baseline; font-size: 0.95rem; }
@media (max-width: 600px) { .facts > div { grid-template-columns: 1fr; gap: 0.1rem; } }
.related { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.related li { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.related .src { font-weight: 600; margin-right: 0.4rem; }

/* ---------------------------------------------------------------- misc blocks */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-2); background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius); }
.pager { display: flex; justify-content: space-between; margin-top: 1.5rem; }
.prose { max-width: 760px; }
.prose h1 { font-size: 2rem; margin-bottom: 1rem; }
.prose h2 { font-size: 1.3rem; margin: 1.6rem 0 0.5rem; }
.prose li { margin: 0.4rem 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8rem; margin: 1rem 0 1.5rem; }
.stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1rem; }
.stat-n { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-l { color: var(--text-3); font-size: 0.82rem; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin: 0.5rem 0 1.5rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--text-3); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.trust { color: var(--accent-2); letter-spacing: 0.1em; }
.source-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1rem; margin-bottom: 0.8rem; background: var(--bg-card); }
.source-group summary { cursor: pointer; font-weight: 700; padding: 0.4rem 0; }
.source-cat h3 { font-size: 1rem; margin: 0.9rem 0 0.2rem; }
.log { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; font-size: 0.78rem; overflow-x: auto; max-height: 420px; }
h3 { margin: 1.4rem 0 0.4rem; }

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-elev); padding: 2rem 0; color: var(--text-2); font-size: 0.92rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
.footer-grid a { display: block; color: var(--text-2); margin: 0.25rem 0; }
.footer-title { font-weight: 700; color: var(--text); margin-bottom: 0.4rem; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.6); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-card h2 { margin-bottom: 0.3rem; }
.modal fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.9rem; margin: 0.8rem 0; }
.modal legend { font-weight: 700; font-size: 0.9rem; padding: 0 0.3rem; }
.modal label { display: block; padding: 0.2rem 0; font-size: 0.93rem; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 0.5rem; }
.link { background: none; border: 0; color: var(--link); cursor: pointer; font: inherit; font-size: 0.85rem; padding: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.8rem; }

/* ---------------------------------------------------------------- responsive header */
@media (max-width: 760px) {
  .header-row { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .country-select select { max-width: 130px; }
  .brand-name { display: none; }
}
