/* ============================================================
   HN Reader — app.css
   Theme: Dark editorial / terminal-inspired with warm amber accents
   Fonts: System monospace stack + Georgia for summaries
   ============================================================ */

/* ── Fonts ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:ital,wght@0,400;0,700;1,400;1,700&family=Bitter:ital,wght@0,400;0,700;1,400;1,700&family=Charis+SIL:ital,wght@0,400;0,700;1,400;1,700&family=EB+Garamond:ital,wght@0,400;0,700;1,400;1,700&family=Inter:wght@400;700&family=Lexend:wght@300;400;700&family=Literata:ital,opsz,wght@0,7..72,400;0,7..72,700;1,7..72,400;1,7..72,700&family=Lora:ital,wght@0,400;0,700;1,400;1,700&display=swap');
/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --bg:           #000000;
  --bg-card:      #eeeeee;
  --bg-card-hover:#1a1d24;
  --bg-input:     #1c1f27;
  --border:       #272b35;
  --border-light: #353a47;

  --text:         #0a0a0a;
  --text-muted:   #7a8099;
  --text-dim:     #4a5068;

  --accent:       #ff6600;        /* HN orange */
  --accent-dim:   rgba(255,102,0,0.15);
  --accent-hover: #ff8833;
  --green:        #4ade80;
  --green-dim:    rgba(74,222,128,0.12);
  --blue:         #60a5fa;
  --blue-dim:     rgba(96,165,250,0.12);
  --pdf-color:    #f59e0b;
  --pdf-dim:      rgba(245,158,11,0.12);
  --red:          #f87171;

  /* Typography */
  --font-mono:  'Lexend', 'Fira Code', 'Cascadia Code', monospace;
  --font-serif: 'Lexend', Georgia, 'Times New Roman', serif;

  /* Spacing */
  --radius:     6px;
  --radius-lg:  12px;
  --gap:        1.5rem;

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 0 0 1px var(--border);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.5), 0 0 0 1px var(--border-light);
  --shadow-glow:  0 0 0 2px var(--accent-dim);

  /* Header */
  --header-h: 60px;
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--green);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.hn-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,14,17,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}

.hn-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

/* Brand */
.hn-header__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
}

.hn-header__logo {
  display: flex;
  align-items: center;
}

.hn-header__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.hn-header__site-name {
  font-family: var(--font-mono);
  font-size: 1.95rem;
  font-weight: 600;
  color: #044475;
  letter-spacing: -0.01em;
}

.hn-header__tagline {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* Nav */
.hn-header__nav { margin-left: auto; }

.hn-header__nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hn-header__nav-item {
  position: relative;
}

.hn-header__nav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.hn-header__nav-link:hover,
.hn-header__nav-item--active .hn-header__nav-link {
  color: var(--text);
  background: var(--bg-card);
}

.hn-header__nav-icon { font-size: 0.9em; opacity: 0.7; }
.hn-header__chevron { font-size: 0.65em; transition: transform 0.2s; }
.hn-header__nav-item.is-open .hn-header__chevron { transform: rotate(180deg); }

/* Dropdown */
.hn-header__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  list-style: none;
  padding: 0.4rem;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.hn-header__nav-item.is-open .hn-header__dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.hn-header__dropdown-item {
  display: block;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
  white-space: nowrap;
}

.hn-header__dropdown-item:hover {
  color: var(--text);
  background: var(--bg-card-hover);
}

/* Search */
.hn-header__search {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.2rem 0.2rem 0.8rem;
  gap: 0.3rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  flex: 0 1 260px;
}

.hn-header__search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.hn-header__search-input {
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: white;
  width: 100%;
  min-width: 0;
}

.hn-header__search-input::placeholder { color: var(--text-dim); }

.hn-header__search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.hn-header__search-btn:hover { background: var(--accent-hover); }

/* Hamburger */
.hn-header__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.hn-header__hamburger-bar {
  display: block;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.hn-header__hamburger.is-active .hn-header__hamburger-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.hn-header__hamburger.is-active .hn-header__hamburger-bar:nth-child(2) {
  opacity: 0;
}
.hn-header__hamburger.is-active .hn-header__hamburger-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Mobile menu */
.hn-header__mobile-menu {
  display: none;
  flex-direction: column;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  gap: 0.15rem;
}

.hn-header__mobile-menu.is-open {
  display: flex;
}

.hn-header__mobile-link {
  padding: 0.6rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
}

.hn-header__mobile-link:hover {
  color: var(--text);
  background: var(--bg-card);
}

.hn-header__mobile-divider {
  height: 1px;
  background: var(--border);
  margin: 0.4rem 0;
}

.hn-header__mobile-search {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.hn-header__mobile-search-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  outline: none;
}

.hn-header__mobile-search-input:focus {
  border-color: var(--accent);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* ── Index page ──────────────────────────────────────────────────────────── */

/* Hero / stats bar */
.index-hero {
  margin-bottom: 2rem;
}

.index-hero__inner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
}

.index-hero__stats {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.stat-pill--accent { border-color: var(--accent-dim); background: var(--accent-dim); }
.stat-pill--pdf    { border-color: var(--pdf-dim);    background: var(--pdf-dim); }

.stat-pill__num {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.stat-pill--accent .stat-pill__num { color: var(--accent); }
.stat-pill--pdf .stat-pill__num    { color: var(--pdf-color); }

.stat-pill__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.index-hero__filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.index-hero__count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.75rem;
  background: var(--accent-dim);
  border: 1px solid rgba(255,102,0,0.3);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--accent-hover);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.filter-chip:hover {
  background: rgba(255,102,0,0.25);
  border-color: var(--accent);
  color: var(--text);
}

/* Article grid */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
  gap: var(--gap);
  align-items: start;
}

/* Article card */
.article-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  position: relative;
  overflow: hidden;
}

.article-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
  transition: background 0.2s;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-light);
}

.article-card:hover::before {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.article-card--has-pdf {
  border-left: 6px solid var(--pdf-color);
}

/* Card meta row */
.article-card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}

.article-card__source {
  font-size: 0.68rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.article-card__score {
  font-size: 0.68rem;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 6px;
  border-radius: 3px;
}

.article-card__date {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-left: auto;
}

.article-card__pdf-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--pdf-color);
  background: var(--pdf-dim);
  border: 1px solid rgba(245,158,11,0.25);
  padding: 1px 6px;
  border-radius: 3px;
}

/* Card title */
.article-card__title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.65rem;
}

.article-card__title-link {
  color: var(--text);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.12s;
}

.article-card__title-link:hover { color: var(--accent-hover); }

/* Card summary — collapsible */
.article-card__collapse {
  overflow: hidden;
  max-height: 220px;
  position: relative;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 0.5rem;
}

.article-card__collapse::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--bg-card));
  pointer-events: none;
  transition: opacity 0.25s;
}

.article-card__collapse.is-expanded {
  max-height: 4000px;
}

.article-card__collapse.is-expanded::after {
  opacity: 0;
}

.article-card__collapse.no-clamp {
  max-height: none;
}

.article-card__collapse.no-clamp::after {
  display: none;
}

.article-card__summary {
  font-family: var(--font-serif);
  font-size: 0.83rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 0;
}

.article-card__no-summary {
  font-style: italic;
  color: var(--text-dim);
}

/* ── Markdown-rendered summary styles ───────────────────────────────────── */
.article-card__summary.md-rendered { line-height: 1.5; }

.article-card__summary .md-p {
  margin-bottom: 0.55rem;
}
.article-card__summary .md-p:last-child { margin-bottom: 0; }

.article-card__summary .md-list {
  margin: 0.35rem 0 0.55rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.article-card__summary .md-list li {
  line-height: 1.5;
  padding-left: 0.2rem;
}

.article-card__summary ol.md-list { list-style: decimal; }
.article-card__summary ul.md-list { list-style: disc; }

.article-card__summary .md-heading {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0.7rem 0 0.3rem;
}

.article-card__summary .md-heading:first-child { margin-top: 0; }

.article-card__summary .md-code {
  font-family: var(--font-mono);
  font-size: 0.75em;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
  color: var(--green);
}

.article-card__summary .md-quote {
  border-left: 2px solid var(--accent-dim);
  padding: 0.2rem 0.6rem;
  margin: 0.4rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.article-card__summary .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

.article-card__summary .md-link {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-card__summary strong { color: var(--text); font-weight: 700; }
.article-card__summary em     { font-style: italic; color: var(--text-muted); }
.article-card__summary del    { opacity: 0.5; text-decoration: line-through; }

.article-card__toggle {
  display: none; /* hidden by default — JS shows it only when expanded */
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0;
  margin-bottom: 0.75rem;
  background: none;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s;
}

.article-card__toggle:hover {
  color: var(--accent);
}

/* Only shown when expanded */
.article-card__toggle[aria-expanded="true"] {
  display: inline-flex;
}
.article-card__toggle-icon {
  transform: rotate(180deg); /* always pointing up — it only appears when expanded */
  flex-shrink: 0;
}

/* Always says "read less" — the label span text is hidden via JS */
.article-card__toggle-label::before {
  content: 'read less';
}



.article-card__toggle.is-hidden {
  display: none !important;
}

/* Card footer */
.article-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.article-card__url {
  font-size: 0.68rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  transition: color 0.12s;
}

.article-card__url:hover { color: var(--blue); }

.article-card__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn--ghost {
  background: var(--bg-card-hover);
  border-color: var(--border);
  color: var(--text-muted);
}
.btn--ghost:hover {
  border-color: var(--border-light);
  color: var(--text);
  background: var(--border);
}

.btn--pdf {
  background: var(--pdf-dim);
  border-color: rgba(245,158,11,0.3);
  color: var(--pdf-color);
}
.btn--pdf:hover {
  background: rgba(245,158,11,0.2);
  border-color: var(--pdf-color);
  color: var(--text);
}

.btn--sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.72rem;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge--source {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.badge--score {
  background: var(--accent-dim);
  border: 1px solid rgba(255,102,0,0.2);
  color: var(--accent);
}

.badge--pdf {
  background: var(--pdf-dim);
  border: 1px solid rgba(245,158,11,0.2);
  color: var(--pdf-color);
}

.badge--date {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
}


/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  margin-bottom: 1.5rem;
  text-align: center;
}

.pagination__inner {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.4rem 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 0.75rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.pagination__btn:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.pagination__btn--disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.pagination__pages {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.pagination__page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 0.4rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.pagination__page:hover {
  background: var(--bg-card-hover);
  color: var(--text);
}

.pagination__page--current {
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: default;
  pointer-events: none;
}

.pagination__ellipsis {
  color: var(--text-dim);
  padding: 0 0.15rem;
  pointer-events: none;
  font-size: 0.75rem;
  line-height: 32px;
}

/* Jump to page */
.pagination__jump {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.4rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

.pagination__jump-input {
  width: 52px;
  height: 32px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  text-align: center;
  padding: 0 0.3rem;
  outline: none;
  -moz-appearance: textfield;
}
.pagination__jump-input::-webkit-inner-spin-button,
.pagination__jump-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.pagination__jump-input:focus { border-color: var(--accent); }

.pagination__jump-btn {
  height: 32px;
  padding: 0 0.6rem;
  background: var(--accent-dim);
  border: 1px solid rgba(255,102,0,0.3);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.pagination__jump-btn:hover {
  background: var(--accent);
  color: white;
}

.pagination__info {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

@media (max-width: 480px) {
  .pagination__jump { display: none; }
  .pagination__btn  { padding: 0 0.5rem; font-size: 0.7rem; }
  .pagination__page { min-width: 28px; height: 28px; font-size: 0.7rem; }
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
}

.empty-state__icon {
  font-size: 3.5rem;
  margin-bottom: 1.25rem;
  opacity: 0.3;
  line-height: 1;
}

.empty-state__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.empty-state__body {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ── Article detail page ─────────────────────────────────────────────────── */
.page-article {
  max-width: 780px;
}

.article-detail__back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  padding: 0.4rem 0.75rem 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: color 0.12s, border-color 0.12s;
}

.article-detail__back:hover {
  color: var(--text);
  border-color: var(--border-light);
}

.article-detail__header {
  margin-bottom: 2.5rem;
}

.article-detail__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.article-detail__title {
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 1rem;
}

.article-detail__url-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.article-detail__url {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--blue);
  word-break: break-all;
}

.article-detail__url:hover { color: var(--text); }

.article-detail__section {
  margin-bottom: 2.25rem;
  padding-bottom: 2.25rem;
  border-bottom: 1px solid var(--border);
}

.article-detail__section:last-child {
  border-bottom: none;
}

.article-detail__section-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.article-detail__summary {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-muted);
}

.article-detail__dl {}

.article-detail__dl-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.article-detail__dl-row:last-child { border-bottom: none; }

.article-detail__dl-row dt {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  padding-top: 1px;
}

.article-detail__dl-row dd {
  font-size: 0.82rem;
  color: var(--text-muted);
  word-break: break-all;
}

.article-detail__dl-row--error dt { color: var(--red); }
.article-detail__dl-row--error dd { color: var(--red); opacity: 0.8; }

.code--path {
  font-size: 0.72rem;
  word-break: break-all;
}

.muted { color: var(--text-dim); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
  margin-top: auto;
}

.site-footer__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.site-footer__brand {
  font-weight: 700;
  color: var(--text-muted);
}

.site-footer__sep { opacity: 0.3; }

.site-footer__link {
  color: var(--text-dim);
  transition: color 0.12s;
}
.site-footer__link:hover { color: var(--accent); }



/* ── Table of Contents panel ─────────────────────────────────────────────── */
.toc {
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
}

.toc__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.toc__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  flex-shrink: 0;
}

.toc__count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* Body always visible */


.toc__body {
  
  padding: 0.1rem 0.1rem 0.1rem;
  columns: 2;
  column-gap: 0.2rem;
}

@media (max-width: 700px) {
  .toc__body { columns: 1; }
}

.toc__item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.22rem 0.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  break-inside: avoid;
  transition: background 0.12s, color 0.12s;
}

.toc__item:hover {
  background: var(--accent-dim);
}

.toc__item:hover .toc__item-title {
  color: var(--accent-hover);
}

.toc__item--active {
  background: var(--accent-dim);
}

.toc__item--active .toc__item-num {
  color: var(--accent);
}

.toc__item-num {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 1.6rem;
  text-align: right;
  line-height: 1.6;
}

.toc__item-title {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: bold;
  color: #335291;

  line-height: 1.4;
  transition: color 0.12s;
  /* clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toc__item-pdf {
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--pdf-color);
  opacity: 0.7;
  line-height: 1.6;
  }
.toc__item-age {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #2590da;
  line-height: 1.6;
  white-space: nowrap;
}


/* ── Back to top button ───────────────────────────────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: rgba(26, 29, 36, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;           /* always flex — visibility controlled by opacity */
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.9);
  transition: opacity 0.25s, transform 0.25s, background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.back-to-top:hover {
  background: rgba(255, 102, 0, 0.25);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 2px 12px rgba(0,0,0,0.4);
}
.back-to-top:active {
  transform: scale(0.93);
}
@media (prefers-color-scheme: light) {
  .back-to-top {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  }
}

/* Card highlight when scrolled to from TOC */
.article-card.card--highlighted {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-dim), var(--shadow-hover) !important;
  transition: border-color 0.1s, box-shadow 0.1s;
}
/* After first click (expanded), show a subtle "tap again to open" hint */
.article-card[data-click-state="expanded"] {
  border-color: var(--border-light);
}

.article-card[data-click-state="expanded"]::after {
  content: 'click again to open ↗';
  position: absolute;
  bottom: 0.5rem;
  right: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  opacity: 0.6;
  pointer-events: none;
}
/* ── Scroll reveal animation ─────────────────────────────────────────────── */
@keyframes cardReveal {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.articles-grid .article-card {
  animation: cardReveal 0.35s ease both;
}

.articles-grid .article-card:nth-child(1)  { animation-delay: 0.02s; }
.articles-grid .article-card:nth-child(2)  { animation-delay: 0.04s; }
.articles-grid .article-card:nth-child(3)  { animation-delay: 0.06s; }
.articles-grid .article-card:nth-child(4)  { animation-delay: 0.08s; }
.articles-grid .article-card:nth-child(5)  { animation-delay: 0.10s; }
.articles-grid .article-card:nth-child(6)  { animation-delay: 0.12s; }
.articles-grid .article-card:nth-child(7)  { animation-delay: 0.14s; }
.articles-grid .article-card:nth-child(8)  { animation-delay: 0.16s; }
.articles-grid .article-card:nth-child(n+9) { animation-delay: 0.18s; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .hn-header__nav,
  .hn-header__search { display: none; }
  .hn-header__hamburger { display: flex; margin-left: auto; }
  .hn-header { height: auto; }
  .hn-header__inner { height: var(--header-h); }
}

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

@media (max-width: 600px) {
  .main-content { padding: 1.25rem 0.9rem; }

  .index-hero__inner { flex-direction: column; align-items: flex-start; }

  .article-card { padding: 1rem; }

  .article-detail__dl-row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .pagination__inner { gap: 0.25rem; }
}

/* ── Light mode (optional, system-driven) ────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg:           #f5f5f0;
    --bg-card:      rgb(234 232 232);
    --bg-card-hover:#f9f8f6;
    --bg-input:     #f0eeea;
    --border:       #e0ddd8;
    --border-light: #ccc9c2;
    --text:         #0a0a0a;
    --text-muted:   #000000;
    --text-dim:     #9a9890;
    --shadow-card:  0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px var(--border);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.12), 0 0 0 1px var(--border-light);
  }

  .hn-header {
    background: rgba(245,245,240,0.95);
  }
}
#article-control-widget {
  position: fixed;
  left: 2px;
  top: 70%;
  transform: translateY(-50%);
  z-index: 999999;
  display: flex;
  flex-direction: column;
  align-items: left;
  gap: 10px;
  font-family: var(--font-mono);
  user-select: none;
}

.acw-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(20,20,20,0.82);
  backdrop-filter: blur(8px);
  color: #aaa;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.1s;
  padding: 0;
}

.acw-btn:hover {
  background: rgba(50,50,50,0.95);
  color: #fff;
}

.acw-btn:active {
  transform: scale(0.88);
}

.acw-value {
  color: #666;
  font-size: 9px;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1;
}

.acw-divider {
  width: 1px;
  height: 14px;
  background: rgba(255,255,255,0.08);
}

.acw-toggle-track {
  width: 28px;
  height: 16px;
  border-radius: 16px;
  background: rgba(20,20,20,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  position: relative;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}

.acw-toggle-track.active {
  background: rgba(232,216,122,0.25);
  border-color: rgba(232,216,122,0.5);
}

.acw-toggle-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #444;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), background 0.22s;
}

.acw-toggle-track.active .acw-toggle-thumb {
  transform: translateX(12px);
  background: #e8d87a;
}

.acw-mode-icon {
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(20,20,20,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: border-color 0.2s;
}

.acw-mode-icon:hover {
  border-color: rgba(255,255,255,0.2);
}