/* ── The Elm Reader — Shared Stylesheet ─────────────────────────────────────── */

:root {
  --bg:          #0d1117;
  --bg-card:     #161c26;
  --bg-surface:  #1c2333;
  --bg-nav:      #0a0e16;
  --text:        #cdd3de;
  --text-strong: #e2e8f0;
  --text-muted:  #7d8a9e;
  --text-dim:    #4e5a6e;
  --accent:      #c9a85c;
  --accent-h:    #dbbf78;
  --health:      #52a882;
  --legal:       #7b91d4;
  --lifestyle:   #c47b5b;
  --goodnews:    #a8c45a;
  --border:      rgba(255,255,255,0.07);
  --border-mid:  rgba(255,255,255,0.12);
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  --font-body:   Georgia, 'Times New Roman', serif;
  --font-ui:     system-ui, -apple-system, 'Segoe UI', sans-serif;
  --base:        19px;
  --line:        1.9;
  --measure:     68ch;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--base); scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: var(--line);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--accent-h); }
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ── Skip link (ADA) ─────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 1rem;
  background: var(--accent); color: #000;
  padding: 0.5rem 1rem; border-radius: var(--radius);
  font-family: var(--font-ui); font-weight: 700;
  z-index: 1000; text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ── Nav ─────────────────────────────────────────────────────────────────────── */
.site-nav {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 1.5rem;
  display: flex; align-items: center; gap: 2rem;
  height: 64px;
}
.nav-logo {
  font-family: var(--font-ui);
  font-size: 1.2rem; font-weight: 700;
  color: var(--text-strong); text-decoration: none;
  letter-spacing: 0.03em; white-space: nowrap;
}
.nav-logo span { color: var(--accent); }
.nav-links {
  display: flex; gap: 0.25rem;
  list-style: none; margin: 0; padding: 0;
  flex-wrap: wrap;
}
.nav-links a {
  font-family: var(--font-ui); font-size: 0.88rem;
  text-decoration: none; color: var(--text-muted);
  padding: 0.4rem 0.75rem; border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--text-strong);
  background: var(--bg-surface);
}
.nav-links a.cat-health   { --cat: var(--health); }
.nav-links a.cat-legal    { --cat: var(--legal); }
.nav-links a.cat-lifestyle{ --cat: var(--lifestyle); }
.nav-links a.cat-goodnews { --cat: var(--goodnews); }
.nav-links a[class*="cat-"]:hover { color: var(--cat); background: rgba(255,255,255,0.05); }

/* ── Ad slot ─────────────────────────────────────────────────────────────────── */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card);
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius);
  color: var(--text-dim); font-family: var(--font-ui); font-size: 0.75rem;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.ad-leaderboard { width: 100%; height: 90px; margin: 1.5rem 0; }
.ad-rectangle   { width: 300px; height: 250px; }
.ad-inline      { width: 100%; height: 90px; margin: 2rem auto; max-width: 728px; }
@media (max-width: 767px) { .ad-leaderboard, .ad-inline { height: 60px; } }

/* ── Page wrapper ────────────────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1200px; margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}
.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ── Hero ────────────────────────────────────────────────────────────────────── */
.hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 3rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 700px) { .hero { grid-template-columns: 1fr; } }
.hero-img {
  background: var(--bg-surface);
  min-height: 280px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-family: var(--font-ui); font-size: 0.8rem;
}
.hero-img:not(:has(img)) { display: none; }
.hero-body {
  padding: 2.5rem;
  display: flex; flex-direction: column; justify-content: center; gap: 1rem;
}
.hero-body .cat-tag { align-self: flex-start; }
.hero-body h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  color: var(--text-strong); line-height: 1.3;
}
.hero-body p { color: var(--text-muted); font-size: 1rem; }
.hero-body .read-more {
  font-family: var(--font-ui); font-size: 0.9rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.hero-body .read-more:hover { color: var(--accent-h); }

/* ── Category tag ────────────────────────────────────────────────────────────── */
.cat-tag {
  display: inline-block;
  font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 0.25rem 0.65rem; border-radius: 4px;
  text-decoration: none;
}
.cat-tag.health   { background: rgba(82,168,130,0.15);  color: var(--health); }
.cat-tag.legal    { background: rgba(123,145,212,0.15); color: var(--legal); }
.cat-tag.lifestyle{ background: rgba(196,123,91,0.15);  color: var(--lifestyle); }
.cat-tag.good-news{ background: rgba(168,196,90,0.15);  color: var(--goodnews); }

/* ── Section heading ─────────────────────────────────────────────────────────── */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem; margin-bottom: 1.75rem;
}
.section-head h2 {
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted);
}
.section-head a {
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--text-dim); text-decoration: none;
}
.section-head a:hover { color: var(--accent); }

/* ── Article card grid ───────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3.5rem;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--border-mid); transform: translateY(-2px); }
.card-img {
  background: var(--bg-surface);
  height: 160px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-family: var(--font-ui); font-size: 0.75rem;
}
.card-img:not(:has(img)) { display: none; }
.card-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.card-body h3 {
  font-size: 1.05rem; line-height: 1.4;
  color: var(--text-strong);
}
.card-body h3 a { color: inherit; text-decoration: none; }
.card-body h3 a:hover { color: var(--accent); }
.card-body p { font-size: 0.9rem; color: var(--text-muted); flex: 1; }
.card-meta {
  font-family: var(--font-ui); font-size: 0.75rem;
  color: var(--text-dim); margin-top: auto;
  display: flex; gap: 0.75rem;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 2rem; }
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.widget-title {
  font-family: var(--font-ui); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 1rem;
  padding-bottom: 0.6rem; border-bottom: 1px solid var(--border);
}
.sidebar-links { list-style: none; display: flex; flex-direction: column; gap: 0.75rem; }
.sidebar-links li { border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; }
.sidebar-links li:last-child { border-bottom: none; padding-bottom: 0; }
.sidebar-links a { font-size: 0.92rem; color: var(--text); text-decoration: none; line-height: 1.4; }
.sidebar-links a:hover { color: var(--accent); }
.sidebar-links .s-meta {
  font-family: var(--font-ui); font-size: 0.72rem;
  color: var(--text-dim); margin-top: 0.2rem;
}

/* ── Article page ────────────────────────────────────────────────────────────── */
.article-wrap { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.article-grid {
  display: grid; grid-template-columns: 1fr 300px; gap: 3rem; align-items: start;
}
@media (max-width: 900px) { .article-grid { grid-template-columns: 1fr; } }

.breadcrumb {
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--text-dim); margin-bottom: 1.5rem;
  display: flex; gap: 0.4rem; align-items: center;
}
.breadcrumb a { color: var(--text-dim); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text-dim); }

.article-header { margin-bottom: 2rem; }
.article-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--text-strong); line-height: 1.25;
  margin: 0.75rem 0 1rem;
}
.article-header .deck {
  font-size: 1.15rem; color: var(--text-muted);
  line-height: 1.6; margin-bottom: 1.25rem;
}
.article-meta {
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--text-dim); display: flex; gap: 1rem; flex-wrap: wrap;
  padding: 1rem 0; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.article-meta strong { color: var(--text-muted); }

.article-featured-img {
  background: var(--bg-surface);
  border-radius: var(--radius);
  height: 340px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-family: var(--font-ui); font-size: 0.8rem;
  margin: 1.75rem 0;
}
.article-featured-img:not(:has(img)) { display: none; }

.article-body { max-width: var(--measure); }
.article-body h2 {
  font-size: 1.4rem; color: var(--text-strong);
  margin: 2.25rem 0 0.75rem; line-height: 1.3;
}
.article-body h3 {
  font-size: 1.15rem; color: var(--text-strong);
  margin: 1.75rem 0 0.5rem;
}
.article-body p { margin-bottom: 1.4rem; font-size: 1.05rem; }
.article-body ul, .article-body ol {
  margin: 0 0 1.4rem 1.5rem;
}
.article-body li { margin-bottom: 0.5rem; font-size: 1.05rem; }
.article-body strong { color: var(--text-strong); }
.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.75rem 0;
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic; color: var(--text-muted);
}

/* ── Disclaimer notice (inline, on every article) ───────────────────────────── */
.disclaimer-notice {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-left: 3px solid var(--text-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 2rem 0;
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--text-muted); line-height: 1.6;
}
.disclaimer-notice strong { color: var(--text); }

/* ── Tags ────────────────────────────────────────────────────────────────────── */
.article-tags {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 2rem 0; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.tag {
  font-family: var(--font-ui); font-size: 0.78rem;
  background: var(--bg-surface); color: var(--text-muted);
  padding: 0.3rem 0.7rem; border-radius: 20px;
  text-decoration: none; border: 1px solid var(--border);
}
.tag:hover { border-color: var(--accent); color: var(--accent); }

/* ── Related articles ────────────────────────────────────────────────────────── */
.related { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border); }
.related h2 {
  font-family: var(--font-ui); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 1.5rem;
}
.related-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1.25rem;
}

/* ── Static pages (disclaimer, sitemap) ─────────────────────────────────────── */
.static-page { max-width: 800px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
.static-page h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--text-strong); margin-bottom: 0.5rem;
}
.static-page .last-updated {
  font-family: var(--font-ui); font-size: 0.82rem;
  color: var(--text-dim); margin-bottom: 2.5rem;
}
.static-page h2 {
  font-size: 1.2rem; color: var(--text-strong);
  margin: 2.5rem 0 0.75rem;
}
.static-page p { margin-bottom: 1.25rem; font-size: 1rem; }
.static-page ul { margin: 0 0 1.25rem 1.5rem; }
.static-page li { margin-bottom: 0.5rem; }

/* ── Sitemap ─────────────────────────────────────────────────────────────────── */
.sitemap-section { margin-bottom: 2.5rem; }
.sitemap-section h2 {
  font-family: var(--font-ui); font-size: 0.82rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 1rem;
  padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.sitemap-links { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.sitemap-links a { color: var(--text); text-decoration: none; font-size: 0.98rem; }
.sitemap-links a:hover { color: var(--accent); text-decoration: underline; }
.sitemap-links .s-desc {
  font-family: var(--font-ui); font-size: 0.78rem;
  color: var(--text-dim); margin-left: 0.5rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  padding: 3rem 1.5rem 2rem;
  margin-top: 4rem;
}
.footer-inner { max-width: 1200px; margin: 0 auto; }
.footer-top {
  display: grid; grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem; margin-bottom: 2.5rem;
}
@media (max-width: 700px) { .footer-top { grid-template-columns: 1fr; } }
.footer-brand p {
  font-size: 0.88rem; color: var(--text-muted);
  max-width: 38ch; line-height: 1.7; margin-top: 0.75rem;
}
.footer-col h3 {
  font-family: var(--font-ui); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 0.85rem;
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.footer-col a {
  font-size: 0.88rem; color: var(--text-dim);
  text-decoration: none;
}
.footer-col a:hover { color: var(--accent); }
.footer-disclaimer {
  border-top: 1px solid var(--border);
  padding-top: 1.75rem;
  font-family: var(--font-ui); font-size: 0.78rem;
  color: var(--text-dim); line-height: 1.7;
}
.footer-disclaimer strong { color: var(--text-muted); }
.footer-disclaimer a { color: var(--text-dim); }
.footer-bottom {
  margin-top: 1.5rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  font-family: var(--font-ui); font-size: 0.75rem; color: var(--text-dim);
}

/* ── Accessibility helpers ───────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav-inner { gap: 1rem; }
  .hero-body { padding: 1.5rem; }
  .page-wrap { padding: 1.5rem 1rem 3rem; }
  .card-grid { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATION
   Rules for elderly-friendly UX + maximum ad viewability on small screens.
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Larger base font on mobile ───────────────────────────────────────────
   Elderly users benefit from 20px+ body text. Desktop stays at 19px.        */
@media (max-width: 767px) {
  html { font-size: 20px; }
  .article-body p,
  .article-body li  { font-size: 1.05rem; line-height: 2; }
  .article-body h2  { font-size: 1.35rem; }
  .article-header h1 { font-size: 1.65rem; line-height: 1.25; }
  .article-header .deck { font-size: 1.05rem; }
}

/* ── 2. Touch targets — 44px minimum (WCAG 2.5.5) ───────────────────────────
   Every tappable element must be at least 44×44px on mobile.                */
@media (max-width: 767px) {
  .nav-links a {
    padding: 0.65rem 0.75rem;
    min-height: 44px;
    display: inline-flex; align-items: center;
  }
  .card-body h3 a {
    display: block;
    padding: 0.25rem 0;
    min-height: 44px;
  }
  .read-more {
    padding: 0.75rem 0;
    min-height: 44px;
    display: inline-flex; align-items: center;
  }
  .cat-tag {
    padding: 0.5rem 0.85rem;
    min-height: 36px;
    display: inline-flex; align-items: center;
  }
  .footer-col a {
    display: block;
    min-height: 44px;
    display: flex; align-items: center;
  }
}

/* ── 3. Nav: horizontal scroll on small screens ──────────────────────────────
   Keeps all nav items reachable without wrapping onto two lines.             */
@media (max-width: 767px) {
  .site-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-inner { flex-wrap: nowrap; padding-right: 1rem; }
  .nav-links  { flex-wrap: nowrap; }
  .nav-logo   { flex-shrink: 0; }
}

/* ── 4. Hero: stack vertically on mobile ────────────────────────────────────  */
@media (max-width: 767px) {
  .hero { grid-template-columns: 1fr; }
  .hero-img { min-height: 200px; }
}

/* ── 5. Article page: full-width, comfortable padding ───────────────────────  */
@media (max-width: 767px) {
  .article-wrap { padding: 1.25rem 1rem 5rem; }
  .article-featured-img:has(img) { height: 200px; }
  .article-grid { grid-template-columns: 1fr; }
  .breadcrumb { font-size: 0.78rem; flex-wrap: wrap; }
}

/* ── 6. Cards: full-width, larger tap area ───────────────────────────────────  */
@media (max-width: 767px) {
  .card { flex-direction: row; align-items: stretch; min-height: 100px; }
  .card-img:has(img) { width: 110px; min-width: 110px; height: auto; flex-shrink: 0; }
  .card-body { padding: 1rem; }
  .card-body h3 { font-size: 1rem; }
  .related-grid { grid-template-columns: 1fr; }
}

/* ── 7. Footer: simplify on mobile ──────────────────────────────────────────
   Show only the disclaimer + copyright — save vertical space.               */
@media (max-width: 767px) {
  .footer-top { display: none; }
  .site-footer { padding: 1.5rem 1rem 6rem; margin-top: 2rem; }
}

/* ── 8. Ad slots: mobile sizing ─────────────────────────────────────────────
   320×100 (large mobile banner) outperforms 320×50. Use max-width so it
   never overflows a narrow screen.                                           */
@media (max-width: 767px) {
  .ad-leaderboard {
    height: 100px;
    max-width: 100%;
  }
  .ad-inline {
    height: 100px;
    max-width: 100%;
    margin: 1.5rem 0;
  }
  /* Rectangle ads don't show in sidebar (sidebar is hidden on mobile).
     In-article rectangles reflow to full-width banners instead.             */
  .ad-rectangle {
    width: 100%;
    max-width: 320px;
    height: 100px;
    margin: 0 auto;
  }
}

/* ── 9. Sticky bottom ad bar (mobile only) ───────────────────────────────────
   Stays in view as the user scrolls. Highest viewability of any placement.
   Gives 8px clearance from screen edge so it doesn't feel like a trap.
   JS in each page dismisses it after 30 seconds to respect the user.        */
#sticky-ad-bar {
  display: none;
}
@media (max-width: 767px) {
  #sticky-ad-bar {
    display: flex;
    align-items: center; justify-content: center;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--bg-nav);
    border-top: 1px solid var(--border-mid);
    z-index: 50;
    padding: 0 0.5rem;
  }
  #sticky-ad-bar .ad-slot {
    border: none;
    background: transparent;
    height: 50px; width: 320px; max-width: 100%;
    margin: 0;
  }
  #sticky-ad-close {
    position: absolute; right: 6px; top: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.7rem; line-height: 1;
    padding: 3px 6px; border-radius: 4px;
    cursor: pointer; font-family: var(--font-ui);
    min-width: 44px; min-height: 30px;
    display: flex; align-items: center; justify-content: center;
  }
  /* Push page content up so sticky bar never covers the last line of text   */
  body { padding-bottom: 60px; }
}
