/* ==========================================================================
   Design tokens
   Light theme on :root; dark theme via prefers-color-scheme or data-theme.
   ========================================================================== */
:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #eaefec;
  --ink: #111815;
  --ink-2: #3d4943;
  --ink-3: #66726c;
  --line: #d9e1dc;
  --brand: #0a6b47;
  --brand-strong: #07563a;
  --brand-ink: #ffffff;
  --brand-soft: #e1f0e8;
  --live: #d62839;
  --header-bg: #0c1712;
  --header-ink: #e8efeb;
  --header-ink-2: #9fb0a7;
  --dark-box: #13211a;
  --dark-box-ink: #e8efeb;
  --dark-box-ink-2: #9fb0a7;
  --dark-box-accent: #6adba6;
  --focus: #f2b705;

  --font-body: "Noto Sans", "Segoe UI", Roboto, Arial, sans-serif;
  --font-head: "Roboto Condensed", "Arial Narrow", "Segoe UI", sans-serif;

  --radius: 6px;
  --gap: 24px;
  --wrap: 1240px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f0d;
    --surface: #131a17;
    --surface-2: #1b2420;
    --ink: #e7ede9;
    --ink-2: #b6c2bb;
    --ink-3: #8b9891;
    --line: #26312c;
    --brand: #3fcb8b;
    --brand-strong: #6adba6;
    --brand-ink: #06140d;
    --brand-soft: #173428;
    --live: #ff5a67;
    --header-bg: #070a09;
    --header-ink: #e7ede9;
    --header-ink-2: #8b9891;
    --dark-box: #18231e;
    --dark-box-ink: #e7ede9;
    --dark-box-ink-2: #8b9891;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f0d;
  --surface: #131a17;
  --surface-2: #1b2420;
  --ink: #e7ede9;
  --ink-2: #b6c2bb;
  --ink-3: #8b9891;
  --line: #26312c;
  --brand: #3fcb8b;
  --brand-strong: #6adba6;
  --brand-ink: #06140d;
  --brand-soft: #173428;
  --live: #ff5a67;
  --header-bg: #070a09;
  --header-ink: #e7ede9;
  --header-ink-2: #8b9891;
  --dark-box: #18231e;
  --dark-box-ink: #e7ede9;
  --dark-box-ink-2: #8b9891;
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
h1, h2, h3 { text-wrap: balance; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }
.narrow { max-width: 820px; }
.page { padding-block: 24px 56px; min-height: 60vh; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: var(--radius);
}
.skip-link:focus { top: 8px; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header { background: var(--header-bg); color: var(--header-ink); }
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; flex-wrap: wrap; padding-block: 8px;
}
.logo {
  font-family: var(--font-head); font-weight: 700; font-size: 28px; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--header-ink); line-height: 1;
  display: inline-flex; align-items: center; gap: 10px;
}
.logo::before {
  content: ""; width: 12px; height: 26px; border-radius: 2px;
  background: linear-gradient(var(--brand) 0 50%, var(--live) 50% 100%);
}
.logo:hover { color: var(--header-ink); }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.search-form { display: flex; align-items: center; background: rgb(255 255 255 / 0.08); border-radius: 999px; }
.search-form input {
  width: 200px; background: transparent; border: 0; color: var(--header-ink);
  padding: 8px 4px 8px 16px; font: inherit; font-size: 14px;
}
.search-form input::placeholder { color: var(--header-ink-2); }
.search-form input:focus { outline: none; }
.search-form:focus-within { box-shadow: 0 0 0 2px var(--focus); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 999px;
  border: 0; background: transparent; color: var(--header-ink); cursor: pointer;
}
.icon-btn:hover { background: rgb(255 255 255 / 0.1); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

.lang-switch { display: flex; gap: 2px; font-size: 13px; }
.lang-switch a { padding: 5px 8px; border-radius: 4px; color: var(--header-ink-2); white-space: nowrap; }
.lang-switch a:hover { color: var(--header-ink); background: rgb(255 255 255 / 0.08); }
.lang-switch a[aria-current] { color: var(--header-ink); background: rgb(255 255 255 / 0.12); }
.lang-short { display: none; }

.mainnav { background: var(--surface); border-bottom: 1px solid var(--line); }
.mainnav-inner {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.mainnav-inner::-webkit-scrollbar { display: none; }
.mainnav a {
  padding: 14px 12px 12px; font-weight: 600; font-size: 15px; color: var(--ink-2);
  border-bottom: 3px solid transparent;
}
.mainnav a:hover { color: var(--ink); }
.mainnav a[aria-current] { color: var(--ink); border-bottom-color: var(--brand); }

/* ==========================================================================
   Shared pieces
   ========================================================================== */
.layout {
  display: grid; gap: 32px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 320px;
}
.sidebar { display: grid; gap: 24px; position: sticky; top: 16px; }

.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.meta-cat { color: var(--brand); font-weight: 600; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--brand); background: var(--brand-soft); padding: 2px 8px; border-radius: 999px;
}

.img-fallback {
  display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 10;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, var(--bg) 14px 28px);
  color: var(--ink-3); font-family: var(--font-head); font-size: 18px; text-transform: uppercase; letter-spacing: 0.06em;
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title {
  font-family: var(--font-head); font-weight: 700; font-size: 24px; text-transform: uppercase;
  letter-spacing: 0.02em; margin: 0 0 12px; display: flex; align-items: center; gap: 10px;
}
.section-title::before { content: ""; width: 6px; height: 22px; background: var(--brand); border-radius: 2px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font-size: 14px; font-weight: 600; padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip[aria-current] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600;
}
.btn:hover { background: var(--brand-strong); color: var(--brand-ink); }
.btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

.empty, .result-count { color: var(--ink-3); }
.notice { background: var(--brand-soft); color: var(--ink); padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }

.breadcrumbs { font-size: 14px; color: var(--ink-3); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.breadcrumbs a { color: var(--ink-2); }
.page-title {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(28px, 4vw, 38px);
  line-height: 1.1; margin: 0 0 12px;
}
.page-intro { color: var(--ink-2); max-width: 65ch; margin: 0 0 20px; }

/* ==========================================================================
   Home: top stories
   ========================================================================== */
.top-stories { display: grid; gap: var(--gap); margin-bottom: 36px; }
.lead-story {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
}
.lead-media img, .lead-media .img-fallback { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 16 / 10; }
.lead-body { padding: 28px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.lead-title {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(26px, 3vw, 36px);
  line-height: 1.12; margin: 0;
}
.lead-text { margin: 0; color: var(--ink-2); font-size: 17px; }

.card-grid { display: grid; gap: var(--gap); }
.card-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { display: flex; flex-direction: column; gap: 10px; }
.card-media { border-radius: var(--radius); overflow: hidden; }
.card-media img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; transition: transform 0.3s ease; }
.card:hover .card-media img { transform: scale(1.03); }
.card-body { display: grid; gap: 6px; }
.card-title { font-size: 18px; font-weight: 700; line-height: 1.3; margin: 0; }

/* ==========================================================================
   Feed rows (home, lists, search)
   ========================================================================== */
.rows { display: grid; }
.row {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px;
  padding-block: 18px; border-bottom: 1px solid var(--line);
}
.row:first-child { padding-top: 6px; }
.row-media { border-radius: var(--radius); overflow: hidden; align-self: start; }
.row-media img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.row-body { display: grid; gap: 6px; align-content: start; }
.row-title { font-size: 19px; font-weight: 700; line-height: 1.3; margin: 0; }
.row-lead { margin: 0; color: var(--ink-2); font-size: 15px; }
.more-wrap { display: flex; justify-content: center; padding-top: 24px; }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 24px; font-weight: 600;
}
.pagination a { color: var(--brand); }
.pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pages a, .pages .current, .pages .gap {
  min-width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}
.pages a { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.pages a:hover { border-color: var(--brand); }
.pages .current { background: var(--brand); color: var(--brand-ink); }
.pages .gap { color: var(--ink-3); }

/* ==========================================================================
   Sidebar boxes
   ========================================================================== */
.side-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.box-title {
  font-family: var(--font-head); font-weight: 700; font-size: 19px; text-transform: uppercase;
  letter-spacing: 0.03em; margin: 0 0 8px;
}
.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li { padding-block: 11px; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.side-list li:last-child { border-bottom: 0; }
.side-list a { font-weight: 600; line-height: 1.35; }
.side-list-times li { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }
.side-list-times time { color: var(--brand); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.side-author { font-size: 13px; color: var(--ink-3); }
.box-more { display: inline-block; margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--brand); }

.side-dark { background: var(--dark-box); border-color: var(--dark-box); color: var(--dark-box-ink); }
.side-dark .side-list li { border-color: rgb(255 255 255 / 0.1); }
.side-dark .side-list a:hover { color: var(--dark-box-accent); }
.side-dark .side-author { color: var(--dark-box-ink-2); }
.side-dark .box-more { color: var(--dark-box-accent); }

/* ==========================================================================
   Article
   ========================================================================== */
.article { min-width: 0; }
.article-head { display: grid; gap: 12px; margin-bottom: 22px; }
.article-title {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.08; margin: 0;
}
.article-lead { font-size: 20px; line-height: 1.45; color: var(--ink-2); margin: 0; max-width: 60ch; }
.article-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-3); font-size: 14px; }
.byline { font-weight: 700; color: var(--ink); }
.article-figure { margin: 0 0 24px; }
.article-figure img { width: 100%; border-radius: var(--radius); aspect-ratio: 16 / 10; object-fit: cover; }
.article-figure figcaption { font-size: 14px; color: var(--ink-3); margin-top: 8px; }
.credit { white-space: nowrap; }

.article-body { font-size: 18px; line-height: 1.7; max-width: 68ch; }
.article-body > * { margin-block: 0 1em; }
.article-body h2, .article-body h3 { font-family: var(--font-head); line-height: 1.2; margin-top: 1.4em; }
.article-body a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.article-body blockquote {
  margin-inline: 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--brand);
  font-size: 20px; font-style: italic; color: var(--ink-2);
}
.article-body img { border-radius: var(--radius); }
.article-body iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--radius); }
.article-body table { border-collapse: collapse; width: 100%; font-size: 16px; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 28px 0 20px; }
.share {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-block: 16px; border-block: 1px solid var(--line); margin-bottom: 36px;
}
.share-label { font-weight: 700; margin-right: 4px; }
.share-btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.share-btn:hover { border-color: var(--brand); color: var(--brand); }
.related { margin-top: 8px; }

/* ==========================================================================
   Search, errors
   ========================================================================== */
.search-page-form { display: flex; gap: 8px; margin-bottom: 18px; }
.search-page-form input {
  flex: 1; min-width: 0; font: inherit; padding: 10px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.error-page { text-align: left; }
.error-code {
  font-family: var(--font-head); font-weight: 700; font-size: 96px; line-height: 1;
  color: var(--brand); margin: 12px 0 0;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { background: var(--header-bg); color: var(--header-ink-2); padding-block: 36px 24px; font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-brand p { margin: 8px 0 0; max-width: 40ch; }
.logo-footer { font-size: 22px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; align-content: start; }
.footer-links a { color: var(--header-ink); }
.footer-links a:hover { color: var(--brand-strong); }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 28px; padding-top: 18px; border-top: 1px solid rgb(255 255 255 / 0.1);
}
.age-mark {
  display: inline-block; margin-left: 8px; padding: 0 6px; border: 1px solid currentColor; border-radius: 4px;
  font-size: 12px; font-weight: 700; line-height: 1.5; vertical-align: 1px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
}
@media (max-width: 800px) {
  .lead-story { grid-template-columns: minmax(0, 1fr); }
  .lead-body { padding: 18px 18px 22px; }
  .card-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .card-grid-3 .card { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 14px; }
  .card-grid-3 .card-title { font-size: 16px; }
  .search-form input { width: 150px; }
}
@media (max-width: 600px) {
  .page { padding-top: 16px; }
  .logo { font-size: 23px; }
  .topbar-inner { min-height: 56px; }
  .tools { width: 100%; justify-content: space-between; }
  .search-form { flex: 1; }
  .search-form input { width: 100%; }
  .topbar .lang-full { display: none; }
  .topbar .lang-short { display: inline; }
  .row { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding-block: 14px; }
  .row-title { font-size: 16px; }
  .row-lead { display: none; }
  .card-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .article-body { font-size: 17px; }
  .article-lead { font-size: 18px; }
  .pagination { justify-content: center; }
}
@media (max-width: 420px) {
  .topbar .lang-switch a { padding: 5px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
