/* Orbixa News — hand-written stylesheet, no build step

   Design system: 8px spacing scale, ~1.25 type scale (body 18px), 2
   elevation levels, and a palette consolidated to navy/red/3 grays/white
   plus a small named set of semantic status colors (success/warning/info)
   needed for scannable badges — those aren't "ad-hoc", they're a distinct
   system doing a different job (state, not brand) and every one of them is
   a variable, never a bare hex value in a component rule below. */

:root {
  /* --- Core palette --- */
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-surface: #f9fafb;
  --color-navy: #0b2545;
  --color-navy-dark: #081b34;
  --color-red: #c8102e;
  --color-red-dark: #a30d26;
  --color-accent-pink: #ff6b81; /* brand mark accent on dark backgrounds only */

  /* --- Semantic status colors (badges, alerts) — a separate system from
     the brand palette above; each state needs a distinct hue to stay
     scannable at a glance (pass/warn/fail/info can't share navy+red). --- */
  --color-success-bg: #ecfdf5;
  --color-success-text: #065f46;
  --color-success-border: #a7f3d0;
  --color-warning-bg: #fffbeb;
  --color-warning-text: #92400e;
  --color-warning-border: #fde68a;
  --color-danger-bg: #fef2f2;
  --color-danger-text: #991b1b;
  --color-danger-border: #fecaca;
  --color-info-bg: #eef2ff;
  --color-info-text: #3730a3;
  --color-info-border: #c7d2fe;

  /* --- Category chip accents (color-coded per section, cards + article
     header). Unlisted/future category slugs fall back to --color-red. --- */
  --chip-cambodia: #b45309;
  --chip-world: #1d4ed8;
  --chip-business: #047857;
  --chip-tech: #7c3aed;

  /* --- Spacing scale (8px base, 4px half-step) --- */
  --space-1: 0.25rem;  /* 4px  */
  --space-2: 0.5rem;   /* 8px  */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2rem;     /* 32px */
  --space-7: 3rem;     /* 48px */
  --space-8: 4rem;     /* 64px */

  /* --- Type scale (~1.25 ratio, rounded to clean pixel values) --- */
  --text-2xs: 0.68rem;    /* ~11px — micro-labels only (nav group labels, badges) */
  --text-xs: 0.8125rem;   /* 13px — meta, badges, fine print */
  --text-sm: 0.9375rem;   /* 15px — secondary text, captions */
  --text-base: 1.125rem;  /* 18px — body copy */
  --text-md: 1.25rem;     /* 20px — lead paragraphs, card titles */
  --text-lg: 1.5rem;      /* 24px — h3 / section headers */
  --text-xl: 1.875rem;    /* 30px — h2 */
  --text-2xl: 2.375rem;   /* 38px — h1 / hero title */
  --text-3xl: 2.75rem;    /* 44px — large hero, desktop only */

  --leading-tight: 1.2;
  --leading-normal: 1.6;  /* en / zh body */
  --leading-loose: 1.8;   /* km body — taller glyphs, longer words */

  /* --- Radii --- */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  /* --- Elevation: 2 levels only --- */
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);

  --transition-fast: 150ms ease;

  --font-en: 'Inter', sans-serif;
  --font-km: 'Noto Sans Khmer', sans-serif;
  --font-zh: 'Noto Sans SC', sans-serif;
  --max-width: 1200px;
  --header-height: 68px;
  --header-height-shrunk: 56px;
}

/* Dark mode — theme-init.js sets [data-theme] on <html> from localStorage
   (or prefers-color-scheme when nothing is stored) before first paint, so
   there's no flash of the wrong theme. The media-query block below is a
   pure-CSS fallback for the rare case JS hasn't run yet. The "-dark" accent
   variants stay the brighter/hover variant in both themes; on a dark
   background that means lighter than the base accent, not darker. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0f1115;
    --color-text: #e8eaed;
    --color-muted: #9aa1ad;
    --color-border: #2d323c;
    --color-surface: #171a21;
    --color-navy: #4d7fd6;
    --color-navy-dark: #6f9bea;
    --color-red: #ef4460;
    --color-red-dark: #ff6b81;

    --color-success-bg: #0d2818;
    --color-success-text: #4ade80;
    --color-success-border: #1f5c3a;
    --color-warning-bg: #2b2008;
    --color-warning-text: #fbbf24;
    --color-warning-border: #5c4a15;
    --color-danger-bg: #2b0f10;
    --color-danger-text: #f87171;
    --color-danger-border: #5c1f22;
    --color-info-bg: #1a1f3d;
    --color-info-text: #a5b4fc;
    --color-info-border: #383f7a;

    --chip-cambodia: #f0b429;
    --chip-world: #6d94ff;
    --chip-business: #34d399;
    --chip-tech: #b794f6;

    --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --color-bg: #0f1115;
  --color-text: #e8eaed;
  --color-muted: #9aa1ad;
  --color-border: #2d323c;
  --color-surface: #171a21;
  --color-navy: #4d7fd6;
  --color-navy-dark: #6f9bea;
  --color-red: #ef4460;
  --color-red-dark: #ff6b81;

  --color-success-bg: #0d2818;
  --color-success-text: #4ade80;
  --color-success-border: #1f5c3a;
  --color-warning-bg: #2b2008;
  --color-warning-text: #fbbf24;
  --color-warning-border: #5c4a15;
  --color-danger-bg: #2b0f10;
  --color-danger-text: #f87171;
  --color-danger-border: #5c1f22;
  --color-info-bg: #1a1f3d;
  --color-info-text: #a5b4fc;
  --color-info-border: #383f7a;

  --chip-cambodia: #f0b429;
  --chip-world: #6d94ff;
  --chip-business: #34d399;
  --chip-tech: #b794f6;

  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-en);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

html[lang="km"] body {
  font-family: var(--font-km);
  line-height: var(--leading-loose);
  line-break: strict;
  word-break: normal;
  overflow-wrap: break-word;
}

/* --leading-tight (1.2) is fine for Latin/Chinese headlines, but Khmer's
   stacked subscript consonants and vowel marks need more vertical room per
   line than that — at 1.2 a wrapped multi-line Khmer headline (the card
   title clamps to 3 lines) risks lines visually crowding or clipping each
   other. Loosened for Khmer specifically rather than raising the shared
   token, which would make Latin/Chinese headlines look loose. */
html[lang="km"] .hero__title,
html[lang="km"] .lead-story__title,
html[lang="km"] .secondary-story__title,
html[lang="km"] .article-card__title,
html[lang="km"] .article-header__title {
  line-height: 1.4;
}

html[lang="zh-Hans"] body {
  font-family: var(--font-zh);
  line-height: var(--leading-normal);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Visible focus ring on every interactive element, keyboard nav only
   (mouse/touch clicks don't trigger :focus-visible). One consistent
   treatment instead of relying on inconsistent browser defaults. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-red);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--color-navy);
  color: #fff;
}

::marker {
  color: var(--color-red);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Shared card look — border, radius, background, resting elevation, and a
   hover lift are the same everywhere a "card" appears (article cards, stat
   cards, panels). Layout (grid columns, internal spacing) stays specific
   to each usage via its own class alongside this one. */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}

.card--interactive {
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}

.card--interactive:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

/* Breaking news banner */

.breaking-banner {
  background: var(--color-red);
}

.breaking-banner__inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
}

.breaking-banner__label {
  flex-shrink: 0;
  background: #fff;
  color: var(--color-red);
  font-weight: 800;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem var(--space-3);
  border-radius: var(--radius-sm);
}

.breaking-banner a {
  color: #fff;
  font-weight: 600;
}

.breaking-banner a:hover {
  text-decoration: underline;
}

/* Header — sticky, shrinks on scroll via .is-scrolled (toggled by
   initStickyHeader() in app.js). Height is animated with a transition on
   the padding, not a hard jump, so it doesn't read as layout shift. */

.site-header {
  background: var(--color-bg);
  border-bottom: 3px solid var(--color-navy);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow var(--transition-fast);
}

.site-header.is-scrolled {
  box-shadow: var(--shadow-2);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  gap: var(--space-4);
  transition: padding var(--transition-fast);
}

.site-header.is-scrolled .site-header__bar {
  padding: var(--space-2) 0;
}

.site-logo {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-navy);
  letter-spacing: -0.02em;
  transition: font-size var(--transition-fast);
  white-space: nowrap; /* the brand never stacks onto two lines */
  flex-shrink: 0;
}

.site-header.is-scrolled .site-logo {
  font-size: var(--text-md);
}

.site-logo span {
  color: var(--color-red);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.site-nav__links {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav__links a {
  font-weight: 600;
  color: var(--color-navy);
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap; /* nav labels never wrap mid-item ("Gold & Markets") */
}

.site-nav__links a:hover,
.site-nav__links a.is-active {
  border-bottom-color: var(--color-red);
  text-decoration: none;
}

/* "More ▾" dropdown: keeps the desktop nav to one clean row no matter how
   many categories exist. On mobile the drawer flattens it (see media query). */
.nav-more {
  position: relative;
}

.nav-more__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-1) 0;
  font: inherit;
  font-weight: 600;
  color: var(--color-navy);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition-fast);
}

.nav-more__toggle:hover,
.nav-more__toggle.is-active {
  border-bottom-color: var(--color-red);
}

.nav-more__chevron {
  transition: transform var(--transition-fast);
}

.nav-more.is-open .nav-more__chevron {
  transform: rotate(180deg);
}

.nav-more__menu {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  margin: 0;
  padding: var(--space-2);
  list-style: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  z-index: 60;
}

.nav-more.is-open .nav-more__menu {
  display: block;
}

.nav-more__menu a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border-bottom: none;
}

.nav-more__menu a:hover,
.nav-more__menu a.is-active {
  background: var(--color-surface);
  border-bottom: none;
}

/* Language switcher: compact segmented control, one active pill inside a
   shared track — not three separate free-floating buttons. */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  flex-shrink: 0; /* never squeezed — squeezing stacked 中文 vertically */
}

.lang-switcher a {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.3rem var(--space-3);
  border-radius: var(--radius-full);
  color: var(--color-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  text-align: center;
  width: 3.25rem; /* fixed, not min — a floor still let ខ្មែរ/中文 render
                     wider than EN since their content exceeds the floor;
                     a fixed width is what actually makes segments equal. */
}

.lang-switcher a:hover:not(.is-active) {
  color: var(--color-navy);
  text-decoration: none;
}

.lang-switcher a.is-active {
  background: var(--color-navy);
  color: #fff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-navy);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 100ms ease;
}

.theme-toggle:active,
.search-form button:active {
  transform: scale(0.92);
}

.theme-toggle__icon--dark {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__icon--light {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__icon--dark {
  display: inline;
}

/* Search: collapsed to a single icon button on desktop; clicking expands the
   input (app.js data-search-toggle). Full-width input in the mobile drawer.
   The input overlays (position: absolute) instead of pushing sibling nav
   items — an inline flex-expand has no guaranteed room to grow into once
   enough categories exist that .site-nav__links fills the row, and silently
   flex-shrinks to a few unusable pixels instead of erroring. Overlaying
   means the expand always has the full 180px regardless of how many nav
   items exist on either side. */
.search-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  position: relative;
}

.search-form input {
  position: absolute;
  top: 50%;
  right: 44px; /* clears the 36px button + var(--space-2) gap */
  transform: translateY(-50%);
  padding: 0.4rem var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  opacity: 0;
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-2);
  pointer-events: none; /* closed input is width:0 but stay inert, not just invisible */
  transition: width var(--transition-fast), opacity var(--transition-fast);
}

.search-form.is-open input {
  width: 180px;
  padding: 0.4rem var(--space-3);
  border-width: 1px;
  opacity: 1;
  pointer-events: auto;
}

.search-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  color: var(--color-navy);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 100ms ease;
}

.search-form button:hover,
.search-form.is-open button {
  background: var(--color-red);
  border-color: var(--color-red);
  color: #fff;
}

/* Mobile menu: fixed touch target, meets the >=44px minimum on its own
   without needing extra CSS since the icon + padding already clears it. */
.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-navy);
}

.nav-backdrop {
  display: none;
}

/* Layout */

.page {
  padding: var(--space-6) 0 var(--space-7);
}

.layout-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}

/* Hero (legacy single-hero pattern — still used by category/tag/search
   pages; the home page now uses .lead-grid instead, see below) */

.hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
  min-height: 320px;
  background: linear-gradient(135deg, var(--color-navy), var(--color-navy-dark));
  color: #fff;
  display: flex;
  align-items: flex-end;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.hero__body {
  position: relative;
  padding: var(--space-6);
}

.hero__eyebrow {
  display: inline-block;
  background: var(--color-red);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.hero__title {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin: 0 0 var(--space-2);
  line-height: var(--leading-tight);
}

.hero__excerpt {
  font-size: var(--text-md);
  opacity: 0.9;
  max-width: 700px;
}

/* Lead grid — home page hierarchy: one dominant lead story, 2 secondary
   stories, then the uniform card grid picks up from there. */

.lead-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.lead-story {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 420px;
  background: linear-gradient(135deg, var(--color-navy), var(--color-navy-dark));
  color: #fff;
  display: flex;
  align-items: flex-end;
}

.lead-story img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lead-story::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.15) 55%, transparent 100%);
}

.lead-story__body {
  position: relative;
  z-index: 1;
  padding: var(--space-6);
}

.lead-story__title {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin: 0 0 var(--space-2);
  line-height: var(--leading-tight);
}

.lead-story__excerpt {
  font-size: var(--text-md);
  opacity: 0.92;
  max-width: 640px;
}

.secondary-stories {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.secondary-story {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
}

.secondary-story__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.secondary-story__title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-navy);
  line-height: var(--leading-tight);
  margin: 0;
}

.secondary-story__title a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .lead-grid {
    grid-template-columns: 1fr;
  }

  .lead-story {
    min-height: 280px;
  }
}

/* Cards */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

/* .card + .card--interactive (see design-system section) provide the
   border/radius/shadow/hover-lift — this only adds what's specific to an
   article card: clipping the image to the card's rounded corners. */
.article-card {
  overflow: hidden;
}

.article-card__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--color-surface);
}

.article-card__body {
  padding: var(--space-4);
}

/* Category chips are color-coded per category (via data-category on the
   element) so readers can tell sections apart at a glance without reading
   the label. Unknown/future category slugs fall back to the brand red. */
.article-card__category {
  color: var(--color-red);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.article-card__category[data-category="cambodia"] { color: var(--chip-cambodia); }
.article-card__category[data-category="world"] { color: var(--chip-world); }
.article-card__category[data-category="business"] { color: var(--chip-business); }
.article-card__category[data-category="tech"] { color: var(--chip-tech); }

.article-card__title {
  font-size: var(--text-md);
  font-weight: 700;
  margin: 0.4rem 0;
  color: var(--color-navy);
  line-height: var(--leading-tight);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card__title a:hover {
  text-decoration: underline;
}

.article-card__excerpt {
  color: var(--color-muted);
  font-size: var(--text-sm);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card__meta {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* Sidebar */

.sidebar-box {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.sidebar-box h3 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--color-navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--color-red);
  padding-bottom: var(--space-2);
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sidebar-list li {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
}

.sidebar-list .rank {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-red);
  min-width: 1.5rem;
}

.sidebar-list a {
  font-weight: 600;
  color: var(--color-navy);
}

.sidebar-list a:hover {
  text-decoration: underline;
}

/* Category list */

.category-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.category-pill {
  padding: 0.35rem var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-navy);
  transition: border-color var(--transition-fast);
}

.category-pill:hover {
  border-color: var(--color-navy);
  text-decoration: none;
}

/* Article page */

/* Reusable filled pill chip — more visual weight than .article-card__category
   (a lighter text-only treatment for dense grids); same color-per-category
   mapping via data-category so the two stay visually related. */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-red);
  color: #fff;
}

.chip[data-category="cambodia"] { background: var(--chip-cambodia); }
.chip[data-category="world"] { background: var(--chip-world); }
.chip[data-category="business"] { background: var(--chip-business); }
.chip[data-category="tech"] { background: var(--chip-tech); }

.article-header {
  margin-bottom: var(--space-5);
}

.article-header__title {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--color-navy);
  line-height: var(--leading-tight);
  margin: var(--space-3) 0;
}

.article-header__byline {
  margin: 0 0 var(--space-3);
}

.article-header__meta {
  color: var(--color-muted);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.article-header__meta .dot::before {
  content: '\00b7';
  margin-right: var(--space-2);
  opacity: 0.6;
}

.byline-link {
  color: var(--color-muted);
  text-decoration: underline;
  text-decoration-color: var(--color-border);
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}

.byline-link:hover {
  color: var(--color-navy);
}

.article-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 520px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
}

/* ~68ch keeps a comfortable line length regardless of the base font size
   changing — matters more than a fixed px value once Khmer's larger line
   height is in the mix. */
.article-body {
  font-size: var(--text-base);
  max-width: 68ch;
}

.article-body p {
  margin: 0 0 var(--space-4);
}

.article-body h2,
.article-body h3 {
  color: var(--color-navy);
  margin-top: var(--space-6);
}

.article-body img {
  border-radius: var(--radius-sm);
  margin: var(--space-5) 0;
}

.article-body figure {
  margin: var(--space-5) 0;
}

.article-body figure img {
  margin: 0 0 var(--space-2);
}

.article-body figcaption {
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-align: center;
}

.article-body blockquote {
  border-left: 4px solid var(--color-red);
  margin: var(--space-5) 0;
  padding: var(--space-1) var(--space-5);
  color: var(--color-muted);
  font-style: italic;
}

.article-tags {
  margin-top: var(--space-6);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.article-source {
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.article-source a {
  font-weight: 700;
  color: var(--color-navy);
}

/* Comments */

.comments-section {
  margin-top: var(--space-7);
  max-width: 68ch;
  /* Clears the sticky header when landing on a #comments link (shared or
     bookmarked) so the section title isn't hidden underneath it. */
  scroll-margin-top: 96px;
}

.comments-section__title {
  color: var(--color-navy);
  margin-bottom: var(--space-5);
}

.comment-list {
  margin-bottom: var(--space-6);
}

.comment {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.comment--reply {
  border-bottom: none;
  padding-bottom: 0;
}

.comment__meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: 0.35rem;
}

.comment__meta strong {
  color: var(--color-navy);
  font-size: var(--text-sm);
}

.comment__date {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.comment__body {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  white-space: pre-wrap;
}

.comment__reply-toggle {
  font-size: var(--text-xs);
}

.comment__replies {
  margin-top: var(--space-4);
  margin-left: var(--space-5);
  padding-left: var(--space-4);
  border-left: 2px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.comment-reply-form {
  margin-top: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

.comment-reply-form__label {
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin: 0 0 var(--space-3);
}

.comment-form-wrap {
  padding: var(--space-5);
  background: var(--color-surface);
  border-radius: var(--radius-md);
}

.comment-form-wrap h3 {
  margin: 0 0 var(--space-1);
  color: var(--color-navy);
  font-size: var(--text-md);
}

/* Honeypot: hidden from real visitors, present for bots that fill every field. */
.comment-form__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Search */

.search-page-form {
  display: flex;
  gap: var(--space-2);
  max-width: 500px;
  margin-bottom: var(--space-6);
}

.search-page-form input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  background: var(--color-bg);
  color: var(--color-text);
}

.search-page-form button {
  padding: var(--space-3) var(--space-5);
  background: var(--color-navy);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
}

/* Pagination — numbered pills */

.pagination {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-6);
  flex-wrap: wrap;
  align-items: center;
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.pagination a:hover {
  border-color: var(--color-navy);
  color: var(--color-navy);
  text-decoration: none;
}

.pagination .active {
  background: var(--color-navy);
  color: #fff;
  border-color: var(--color-navy);
}

.pagination span[aria-disabled] {
  opacity: 0.4;
}

/* Empty state */

.empty-state {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-muted);
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--color-border);
}

.empty-state__title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.search-results-for {
  color: var(--color-muted);
  margin-bottom: var(--space-5);
}

/* Footer */

.site-footer {
  background: var(--color-navy);
  color: rgba(255, 255, 255, 0.85);
  margin-top: var(--space-7);
  padding: var(--space-7) 0 var(--space-5);
}

.site-footer a {
  color: #fff;
}

/* 4 columns: About/brand, Categories, Newsletter, Social — stacks down at
   narrower widths (see responsive section). */
.site-footer__grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1.3fr 0.8fr;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.site-footer__col h4 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
  margin: 0 0 var(--space-4);
}

.site-footer__brand {
  font-size: var(--text-lg);
  font-weight: 800;
  color: #fff;
  margin-bottom: var(--space-3);
}

.site-footer__brand span {
  color: var(--color-accent-pink);
}

.site-footer__col p {
  font-size: var(--text-sm);
  opacity: 0.75;
  margin: 0;
  max-width: 32ch;
}

.site-footer__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--text-sm);
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer__links a {
  opacity: 0.75;
  transition: opacity var(--transition-fast);
}

.site-footer__links a:hover {
  opacity: 1;
}

.site-footer__newsletter-text {
  font-size: var(--text-sm);
  opacity: 0.75;
  margin: 0 0 var(--space-3);
}

/* One visually attached input+button unit, not two separate controls. */
.newsletter-form {
  display: flex;
  max-width: 320px;
}

.newsletter-form .form-input {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
  min-width: 0;
  flex: 1;
}

.newsletter-form .form-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.newsletter-form .form-input:focus-visible {
  box-shadow: none;
  border-color: rgba(255, 255, 255, 0.6);
}

.newsletter-form button {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--color-red);
  color: #fff;
  border: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.newsletter-form button:hover {
  background: var(--color-red-dark);
}

.newsletter-form__honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.site-footer__social {
  display: flex;
  gap: var(--space-2);
}

.site-footer__social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  transition: background var(--transition-fast);
}

.site-footer__social a:hover {
  background: rgba(255, 255, 255, 0.2);
  text-decoration: none;
}

.site-footer__social svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.site-footer__bottom {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  opacity: 0.75;
}

.newsletter-landing {
  max-width: 480px;
  padding: var(--space-6) 0;
}

/* Responsive */

@media (max-width: 900px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero img {
    height: 260px;
  }

  .hero__title {
    font-size: var(--text-xl);
  }

  .site-footer__grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* Mobile nav: a fixed slide-in drawer (not an inline expand) — see
     initMobileMenu() in app.js for the backdrop/Escape/scroll-lock logic. */
  .site-nav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(320px, 85vw);
    background: var(--color-bg);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--space-6) var(--space-5);
    transform: translateX(100%);
    transition: transform 250ms ease;
    z-index: 100;
    overflow-y: auto;
    box-shadow: var(--shadow-2);
  }

  .site-nav.is-open {
    transform: translateX(0);
  }

  .site-nav__links {
    flex-direction: column;
    gap: 0;
    width: 100%;
  }

  .site-nav__links li {
    width: 100%;
  }

  /* >=44px touch target per the a11y requirement. */
  .site-nav__links a {
    display: flex;
    align-items: center;
    min-height: 44px;
    width: 100%;
    border-bottom: 1px solid var(--color-border);
  }

  .search-form {
    width: 100%;
    margin: var(--space-4) 0;
  }

  /* In the drawer the search input is always expanded — no icon-collapse.
     Back to normal flow: the desktop overlay positioning doesn't apply here. */
  .search-form input,
  .search-form.is-open input {
    position: static;
    transform: none;
    flex: 1;
    width: auto;
    padding: 0.4rem var(--space-3);
    border-width: 1px;
    opacity: 1;
    box-shadow: none;
    pointer-events: auto;
  }

  /* Flatten the "More" dropdown into the drawer's normal link list. */
  .nav-more__toggle {
    display: none;
  }

  .nav-more__menu {
    display: block;
    position: static;
    transform: none;
    min-width: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .nav-more__menu a {
    display: flex;
    align-items: center;
    min-height: 44px;
    width: 100%;
    padding: var(--space-1) 0;
    border-radius: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .lang-switcher {
    align-self: flex-start;
    margin-top: var(--space-4);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
  }

  .nav-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .article-header__title {
    font-size: var(--text-xl);
  }

  .lead-story__title {
    font-size: var(--text-xl);
  }

  .site-footer__grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Forms (shared: auth + admin)
   ========================================================================== */

.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-navy);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus-visible {
  outline: none;
  border-color: var(--color-navy);
  box-shadow: 0 0 0 3px rgba(11, 37, 69, 0.1);
}

textarea.form-input {
  resize: vertical;
}

.form-textarea-code {
  font-family: 'Courier New', monospace;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.form-error {
  color: var(--color-danger-text);
  font-size: var(--text-xs);
  margin: 0.35rem 0 0;
}

.form-hint {
  color: var(--color-muted);
  font-size: var(--text-xs);
  margin: 0.35rem 0 0;
}

.form-check label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: normal;
}

.form-current-image {
  max-width: 200px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.form-inline {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.btn {
  display: inline-block;
  /* Vertical padding matches .form-input's (var(--space-3)) so a button
     sitting next to a text input in the same form — Contact, comment reply,
     login — renders the same height as the input, not visibly shorter. */
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: var(--text-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 100ms ease;
}

/* Without this, a disabled .btn (e.g. review queue's bulk-publish button
   before anything is checked) looked identical to an enabled one — nothing
   told the user it wasn't clickable yet. */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Subtle press feedback — a faster, snappier duration than the 150ms hover
   transitions above so the button visibly "gives" the instant you click. */
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-navy);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-navy-dark);
  text-decoration: none;
}

.btn-secondary {
  background: var(--color-bg);
  color: var(--color-navy);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-navy);
  text-decoration: none;
}

.btn-danger {
  background: var(--color-bg);
  color: var(--color-red);
  border-color: var(--color-red);
}

.btn-danger:hover {
  background: var(--color-red);
  color: #fff;
  text-decoration: none;
}

.btn-sm {
  padding: 0.35rem var(--space-3);
  font-size: var(--text-xs);
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-navy);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.link-button--danger {
  color: var(--color-red);
}

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}

.alert-error {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border: 1px solid var(--color-danger-border);
}

.alert-error ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* ==========================================================================
   Auth pages
   ========================================================================== */

.auth-body {
  background: var(--color-surface);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-en);
  margin: 0;
  padding: var(--space-6) var(--space-4);
}

.auth-box {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-2);
}

.auth-box__brand {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-navy);
  margin-bottom: var(--space-5);
  text-align: center;
}

.auth-box__brand span {
  color: var(--color-red);
}

.auth-hint {
  color: var(--color-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.auth-link {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* ==========================================================================
   Admin shell
   ========================================================================== */

.admin-body {
  margin: 0;
  background: var(--color-surface);
  font-family: var(--font-en);
  color: var(--color-text);
}

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--color-navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-sidebar__brand {
  font-size: var(--text-md);
  font-weight: 800;
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-sidebar__brand span {
  color: var(--color-accent-pink);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  padding: var(--space-3) var(--space-3);
  gap: var(--space-1);
  flex: 1;
  overflow-y: auto;
}

.admin-nav__group-label {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: var(--text-2xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.4);
}

.admin-nav__group:first-child .admin-nav__group-label {
  padding-top: var(--space-2);
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.6rem var(--space-3);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.75);
  font-weight: 600;
  font-size: var(--text-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.admin-nav__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
}

.admin-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  color: #fff;
}

.admin-nav a.is-active {
  background: var(--color-red);
  color: #fff;
}

.nav-badge {
  display: inline-block;
  background: var(--color-red);
  color: #fff;
  font-size: var(--text-2xs);
  font-weight: 800;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.admin-nav a.is-active .nav-badge {
  background: #fff;
  color: var(--color-red);
}

.admin-sidebar__footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: var(--text-xs);
}

.admin-sidebar__footer a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: rgba(255, 255, 255, 0.75);
}

.admin-main {
  flex: 1;
  min-width: 0;
}

.admin-topbar {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-topbar__title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-navy);
  margin: 0;
}

.admin-topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-content {
  padding: var(--space-6);
}

/* Stat cards */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-card__value-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.stat-card__value {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-navy);
}

.stat-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: var(--text-xs);
  font-weight: 700;
}

.stat-card__trend svg {
  width: 13px;
  height: 13px;
}

.stat-card__trend--up {
  color: var(--color-success-text);
}

.stat-card__trend--down {
  color: var(--color-danger-text);
}

.stat-card__trend--flat {
  color: var(--color-muted);
}

.stat-card__label {
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Dashboard "Manage" grid — one card per admin section, linking straight
   to it. auto-fill/minmax rather than a fixed column count since the list
   of sections (and therefore how many fit per row) can grow over time. */
.quick-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}

.quick-link-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--color-text);
}

.quick-link-card:hover {
  text-decoration: none;
}

.quick-link-card__icon {
  width: 24px;
  height: 24px;
  color: var(--color-navy);
  stroke: currentColor;
}

.quick-link-card__label {
  font-weight: 700;
}

.quick-link-card__count {
  align-self: flex-end;
  margin-top: auto;
  padding: 0.15rem var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quick-link-card__count--urgent {
  background: var(--color-red);
  color: #fff;
}

/* Admin panel / table */

.admin-panel {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.admin-panel__title {
  margin: 0 0 var(--space-1);
  color: var(--color-navy);
  font-size: var(--text-md);
}

.admin-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.admin-panel__header h2 {
  margin: 0;
  font-size: var(--text-md);
  color: var(--color-navy);
}

.filter-form {
  display: flex;
  gap: var(--space-2);
}

.filter-form select {
  padding: 0.4rem var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.admin-table th {
  text-align: left;
  padding: 0.6rem var(--space-3);
  border-bottom: 2px solid var(--color-border);
  color: var(--color-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table td {
  padding: 0.7rem var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

/* Zebra rows and a consistent density knob — .admin-table--compact for
   denser listings (subscribers, tokens) where rows are simple and many. */
.admin-table tbody tr:nth-child(even) {
  background: var(--color-surface);
}

.admin-table--compact th,
.admin-table--compact td {
  padding: var(--space-2) var(--space-3);
}

.admin-table th.num,
.admin-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-table__actions {
  display: flex;
  gap: var(--space-3);
}

.badge {
  display: inline-block;
  padding: 0.15rem var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-surface);
  color: var(--color-navy);
  border: 1px solid var(--color-border);
}

.badge--present,
.badge--published,
.badge--quality-pass {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-color: var(--color-success-border);
}

.badge--missing,
.badge--quality-fail {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-color: var(--color-danger-border);
}

.badge--draft,
.badge--quality-warn {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border-color: var(--color-warning-border);
}

.badge--scheduled {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  border-color: var(--color-info-border);
}

.empty-hint {
  color: var(--color-muted);
  padding: var(--space-6) 0;
  text-align: center;
}

.token-reveal {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-3);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  word-break: break-all;
}

/* Review queue */

.bulk-actions-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.bulk-actions-bar__count {
  font-size: var(--text-sm);
  color: var(--color-muted);
  font-weight: 600;
}

.bulk-actions-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.review-group-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.review-group-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-6);
}

.review-group-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.review-select {
  width: 16px;
  height: 16px;
  accent-color: var(--color-navy);
}

/* The quality badge is the single most important scan signal in the whole
   queue, so it gets a dedicated slot ahead of the lang badges rather than
   blending into the same row. */
.review-group-card__quality {
  flex-shrink: 0;
}

.review-group-card__langs {
  display: flex;
  gap: 0.4rem;
}

.quality-notes {
  margin: var(--space-2) 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.quality-notes p {
  margin: 0 0 0.35rem;
}

.quality-notes ul {
  margin: 0 0 0.35rem;
  padding-left: 1.25rem;
}

.review-group-card h3 {
  margin: 0 0 0.35rem;
}

.review-group-card h3 a {
  color: var(--color-navy);
}

.review-group-card__meta {
  color: var(--color-muted);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-4);
}

.review-group-card__actions {
  display: flex;
  gap: var(--space-3);
}

.review-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  /* Leaves room to breathe above the sticky publish bar. */
  padding-bottom: var(--space-6);
}

.review-column {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  min-width: 0;
  overflow: hidden;
}

/* Sticks to the top of the viewport as the page scrolls (the admin topbar
   isn't sticky, only the sidebar is, so this reaches top:0 once it scrolls
   past). Each column's content flows naturally now instead of being capped
   in its own scroll box, which is what makes a page-level sticky header
   meaningful. */
.review-column__header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.review-column__body-wrap {
  padding: var(--space-4);
}

.review-column__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

.review-column__video {
  display: block;
  width: auto;
  max-width: 100%;
  height: 240px;
  margin: 0 auto var(--space-3);
  border-radius: var(--radius-sm);
  background: #000;
}

.review-column h3 {
  color: var(--color-navy);
  font-size: var(--text-base);
  margin: 0 0 var(--space-2);
}

.review-column__excerpt {
  color: var(--color-muted);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-3);
}

.review-column__body {
  font-size: var(--text-sm);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
}

.review-column__meta {
  font-size: var(--text-xs);
  color: var(--color-muted);
  line-height: 1.7;
}

/* Publish bar: pinned to the bottom of the viewport so the primary action
   is always reachable without scrolling back up past 3 full article
   bodies. The negative side/bottom margins cancel .admin-content's own
   padding so the bar reaches the edges of the content area. */
.review-publish-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-2);
  padding: var(--space-4) var(--space-6);
  margin: 0 calc(var(--space-6) * -1) calc(var(--space-6) * -1);
}

/* Article editor */

.article-form {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
  align-items: start;
}

.article-form__main,
.article-form__sidebar {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

.editor-toolbar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.editor-toolbar button {
  padding: 0.35rem var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 700;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.editor-toolbar button:hover {
  border-color: var(--color-navy);
}

@media (max-width: 1000px) {
  .article-form {
    grid-template-columns: 1fr;
  }

  .review-columns {
    grid-template-columns: 1fr;
  }

  .review-column__header {
    position: static;
  }

  .admin-sidebar {
    width: 72px;
  }

  .admin-sidebar__brand,
  .admin-nav__group-label,
  .admin-sidebar__footer {
    display: none;
  }

  .admin-nav a {
    position: relative;
    justify-content: center;
  }

  /* Visually hidden rather than display:none — display:none also removes
     the label from the accessibility tree, which would leave each
     icon-only nav link with no accessible name for screen reader users. */
  .admin-nav a span:not(.nav-badge) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Repositioned as a small corner dot on the icon instead of hidden —
     the pending-count signal still needs to survive icon-only mode. */
  .nav-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    margin-left: 0;
  }

  .admin-content {
    padding: var(--space-5);
  }

  /* .admin-table has no wrapping scroll container in any of the ~9
     templates that use it (articles, subscribers, tokens, comments,
     social, categories, pages, messages, review index) — width:100% only
     bounds it when the content already fits. Below this breakpoint a
     realistic table (5+ columns of title/category/views/date/actions)
     doesn't fit a phone width, so make the table itself the scroll
     container rather than letting it silently overflow the page. */
  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .review-publish-bar {
    margin: 0 calc(var(--space-5) * -1) calc(var(--space-5) * -1);
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Social posting --- */
.review-publish-form {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}

.checkbox-inline input {
  accent-color: var(--color-navy);
}

.schedule-input {
  width: auto !important;
  display: inline-block;
  padding: 0.3rem var(--space-2);
  font-size: var(--text-xs);
}

/* Error pages */

.error-page {
  max-width: 480px;
  margin: var(--space-8) auto;
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.error-page__code {
  font-size: 4rem;
  font-weight: 800;
  color: var(--color-red);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.error-page__title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-navy);
  margin: 0 0 var(--space-3);
}

.error-page__body {
  color: var(--color-muted);
  margin: 0 0 var(--space-6);
}

/* Analytics */

.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.chart-wrap {
  position: relative;
  height: 280px;
}

.analytics-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
}

.funnel-platform {
  margin-bottom: var(--space-4);
}

.funnel-platform:last-child {
  margin-bottom: 0;
}

.funnel-platform__name {
  font-weight: 700;
  color: var(--color-navy);
  text-transform: capitalize;
  margin-bottom: 0.4rem;
  font-size: var(--text-sm);
}

.funnel-bar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--text-xs);
  margin-bottom: 0.3rem;
}

.funnel-bar-row .label {
  width: 60px;
  color: var(--color-muted);
  flex-shrink: 0;
}

.funnel-bar-row .count {
  width: 30px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 700;
}

@media (max-width: 1000px) {
  .analytics-grid,
  .analytics-two-col {
    grid-template-columns: 1fr;
  }
}

/* Print — article pages get read on paper more than you'd expect for a
   news site. Chrome/nav/footer/comments add nothing on a printed page;
   the byline/date/source stay since they're part of the article's record. */
@media print {
  .site-header,
  .site-footer,
  .breaking-banner,
  .nav-backdrop,
  .comments-section {
    display: none !important;
  }

  body {
    /* Explicit fallback, not just inherited from the screen font-family —
       web fonts don't always finish loading in time for a print render, and
       the browser default for print is traditionally serif. */
    font-family: sans-serif;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
  }

  .article-header__title {
    color: #000;
  }

  .article-body {
    font-size: 12pt;
    line-height: 1.5;
  }

  .article-cover {
    max-width: 100%;
    aspect-ratio: auto;
  }

  .layout-grid {
    display: block;
  }
}

/* AI Settings page (/admin/settings) */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.settings-tabs a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  margin-bottom: -1px;
  font-weight: 600;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.settings-tabs a:hover {
  color: var(--color-navy);
  text-decoration: none;
}

.settings-tabs a.is-active {
  color: var(--color-navy);
  border-bottom-color: var(--color-red);
}

.settings-tabs__lock-icon {
  width: 13px;
  height: 13px;
  opacity: 0.6;
}

.settings-form {
  max-width: 640px;
}

.settings-pause {
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.settings-pause__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-md);
  cursor: pointer;
}

.settings-pause__label input {
  width: 20px;
  height: 20px;
}

.settings-inline-fields {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.settings-inline-fields .form-input {
  flex: 1;
}

.settings-inline-fields + .settings-inline-fields {
  margin-top: var(--space-2);
}

.settings-inline-fields--wrap {
  flex-wrap: wrap;
  align-items: flex-start;
}

.settings-inline-fields--wrap .form-group {
  flex: 1;
  min-width: 200px;
}

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.checkbox-item:hover {
  border-color: var(--color-navy);
}

.checkbox-item--disabled {
  cursor: default;
  opacity: 0.6;
}

.checkbox-item--disabled:hover {
  border-color: var(--color-border);
}

.settings-quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.settings-quota-grid__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.settings-quota-grid__item .form-input {
  width: 70px;
}

.settings-locked-banner {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-navy);
  border-radius: var(--radius-md);
  max-width: 640px;
}

.settings-locked-banner svg {
  flex-shrink: 0;
  color: var(--color-navy);
  margin-top: 2px;
}

.settings-locked-banner p {
  margin: var(--space-1) 0 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.connection-block {
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.connection-block:last-of-type {
  border-bottom: none;
}

.connection-block h3 {
  margin: 0;
  color: var(--color-navy);
}

.connection-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.u-hidden-form {
  display: none;
}

.connection-block .checkbox-item {
  margin-bottom: var(--space-4);
}

.settings-audit {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}

.settings-audit__title {
  color: var(--color-navy);
  margin-bottom: var(--space-4);
}

.settings-audit__value {
  font-family: monospace;
  font-size: var(--text-xs);
  max-width: 220px;
  overflow-wrap: break-word;
}

@media (max-width: 640px) {
  .settings-inline-fields {
    flex-wrap: wrap;
  }
}

/* Dashboard bot status chip — links through to AI Settings, since that's
   where every one of these states gets changed (unpause, adjust hours,
   raise the budget). */
.bot-status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-5);
  border-radius: var(--radius-full);
  border: 1px solid;
  font-weight: 700;
  font-size: var(--text-sm);
  transition: opacity var(--transition-fast);
}

.bot-status-chip:hover {
  opacity: 0.85;
  text-decoration: none;
}

.bot-status-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.bot-status-chip--active {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border-color: var(--color-success-border);
}

.bot-status-chip--paused {
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border-color: var(--color-warning-border);
}

.bot-status-chip--outside-hours {
  background: var(--color-info-bg);
  color: var(--color-info-text);
  border-color: var(--color-info-border);
}

.bot-status-chip--budget-hit {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
  border-color: var(--color-danger-border);
}
