/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
  background: #FAFAF7;
  color: #1a1a2e;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== TOKENS ===== */
:root {
  --amber: #F59E0B;
  --indigo: #4F46E5;
  --emerald: #10B981;
  --off-white: #FAFAF7;
  --surface: #FFFFFF;
  --border: #E5E3DC;
  --muted: #6B7280;
  --text: #1a1a2e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.07);
  --radius: 10px;
  --radius-lg: 16px;
  --max-w: 1100px;
  --sidebar-w: 220px;
  --gap: 1.5rem;
}

/* ===== LAYOUT WRAP ===== */
.site-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ===== SKIP LINK ===== */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 9999;
  background: var(--indigo);
  color: #fff;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* ===== HEADER ===== */
.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--amber);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: .75rem;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--indigo);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { color: var(--amber); }
.brand-mark { border-radius: 4px; flex-shrink: 0; }

/* ===== NAV (details/summary pattern) ===== */
.nav-details {
  flex: 1;
  min-width: 0;
}

.nav-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  list-style: none;
  padding: .5rem .75rem;
  min-height: 44px;
  min-width: 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--off-white);
  user-select: none;
  white-space: nowrap;
}
.nav-toggle::-webkit-details-marker { display: none; }
.nav-toggle::marker { display: none; }

.hamburger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 18px;
  height: 14px;
  flex-shrink: 0;
}
.hamburger::before,
.hamburger::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.hamburger {
  position: relative;
}
.hamburger::before { position: absolute; top: 0; }
.hamburger::after  { position: absolute; bottom: 0; }

.nav-menu {
  position: absolute;
  top: 62px;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  box-shadow: var(--shadow-md);
  list-style: none;
  z-index: 99;
  padding: .5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.nav-menu li { list-style: none; }
.nav-menu a {
  display: block;
  padding: .65rem .75rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  font-size: .9rem;
  border-radius: var(--radius);
  border-left: 3px solid transparent;
}
.nav-menu a:hover,
.nav-menu a[aria-current="page"] {
  background: #F0EFFF;
  border-left-color: var(--indigo);
  color: var(--indigo);
}

/* ===== HEADER CTAs ===== */
.header-ctas {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .4rem .8rem;
  min-height: 44px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.cta-signup {
  background: linear-gradient(135deg, var(--amber) 0%, #F97316 100%);
  color: #fff;
  border: 2px solid transparent;
}
.cta-signup:hover { opacity: .9; }
.cta-login {
  background: transparent;
  color: var(--indigo);
  border: 2px solid var(--indigo);
}
.cta-login:hover { background: #F0EFFF; }

/* ===== CONTENT LAYOUT (sidebar left + content right) ===== */
.content-layout {
  display: flex;
  flex-direction: row;
  gap: var(--gap);
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

/* SIDEBAR LEFT */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  order: -1;
}
.sidebar-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  position: sticky;
  top: 72px;
}
.sidebar-inner h2,
.sidebar-inner h3 {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: .6rem;
  margin-top: 1rem;
}
.sidebar-inner h2:first-child { margin-top: 0; }
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-list li { margin: 0; }
.toc-list a {
  display: block;
  padding: .4rem .5rem;
  min-height: 36px;
  display: flex;
  align-items: center;
  font-size: .82rem;
  color: var(--indigo);
  text-decoration: underline;
  border-radius: 6px;
  word-break: break-word;
}
.toc-list a:hover { background: #F0EFFF; }

/* MAIN CONTENT */
.content-main {
  flex: 1;
  min-width: 0;
}

/* ===== BODY SECTION ===== */
.body-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

/* ===== PROSE ===== */
.prose {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  max-width: 68ch;
}
.prose h2 { font-size: 1.3rem; margin: 1.6rem 0 .6rem; color: var(--indigo); }
.prose h3 { font-size: 1.1rem; margin: 1.2rem 0 .4rem; }
.prose p { margin-bottom: 1rem; }
.prose ul, .prose ol { margin: .75rem 0 1rem 1.5rem; }
.prose li { margin-bottom: .4rem; }
.prose a { color: var(--indigo); text-decoration: underline; }
.prose a:hover { color: var(--emerald); }
.prose strong { font-weight: 700; }
.prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: .9rem; }
.prose th { background: var(--indigo); color: #fff; padding: .6rem .75rem; text-align: left; }
.prose td { padding: .55rem .75rem; border-bottom: 1px solid var(--border); }
.prose tr:nth-child(even) td { background: #F5F5F5; }
.prose blockquote { border-left: 4px solid var(--amber); padding: .75rem 1rem; background: #FFF8E7; margin: 1rem 0; border-radius: 0 var(--radius) var(--radius) 0; }

/* Prevent content overflow */
.prose img, .prose table { max-width: 100%; overflow-x: auto; display: block; }
.prose pre, .prose code { overflow-x: auto; max-width: 100%; white-space: pre-wrap; word-break: break-all; }

/* ===== HERO SECTIONS ===== */
.hero-section,
.review-hero,
.compare-hero,
.ranking-hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4F46E5 100%);
  color: #fff;
  padding: 2.5rem 1rem 2rem;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.inner-hero {
  background: linear-gradient(120deg, #F59E0B 0%, #F97316 100%);
  color: #fff;
  padding: 2rem 1rem 1.5rem;
  position: relative;
  overflow: hidden;
  width: 100%;
}

.page-hero { }

.hero-text {
  position: relative;
  z-index: 2;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1rem;
}

.hero-text h1 {
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: .6rem;
}

.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .8;
  margin-bottom: .4rem;
}

.hero-desc {
  font-size: .95rem;
  opacity: .85;
  margin-top: .5rem;
  max-width: 60ch;
}

/* ===== BYLINE ===== */
.byline {
  font-size: .82rem;
  opacity: .85;
  margin-bottom: .5rem;
}
.byline time { font-style: italic; }

/* ===== HERO FIGURE / DECO ===== */
.hero-deco,
.inner-deco,
.rank-badge,
.review-deco,
.compare-vs {
  position: absolute;
  right: -20px;
  top: -20px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  opacity: .1;
  background: var(--amber);
  z-index: 1;
}
.rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .15;
  font-size: 4rem;
  font-weight: 900;
  color: var(--amber);
  background: transparent;
}
.compare-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .2;
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -.02em;
  background: transparent;
  color: #fff;
}

.hero-figure { position: absolute; inset: 0; overflow: hidden; z-index: 1; }
.hero-figure .hero-img { width: 100%; height: 100%; object-fit: cover; opacity: .25; }
.inner-figure { display: none; }
.content-figure { display: none; }
.prose-figure { margin-bottom: 1rem; border-radius: var(--radius); overflow: hidden; }
.prose-figure img { width: 100%; display: block; }

/* ===== HOME SPECIFIC ===== */
.main-home .hero-section { padding-bottom: 2.5rem; }
.main-home .hero-text { display: flex; flex-direction: column; }

/* ===== CHILD CARDS (dl > dt > a + dd) ===== */
.child-cards {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.child-cards h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--indigo);
  margin-bottom: 1rem;
}
.card-dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.card-dl dt {
  font-weight: 700;
  margin-bottom: .15rem;
}
.card-dl dt a {
  color: var(--indigo);
  text-decoration: underline;
  font-size: .95rem;
  display: block;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.card-dl dd {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .75rem;
  padding-left: 0;
  line-height: 1.45;
}

/* ===== RANKING SPECIFIC ===== */
.rank-list {
  list-style: none;
  padding: 0;
  counter-reset: none;
}
.rank-list li {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem 0;
  font-size: .82rem;
  border-bottom: 1px solid var(--border);
}
.rank-pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--indigo);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ranking-prose table { font-size: .88rem; }

/* ===== COMPARE SPECIFIC ===== */
.compare-tip,
.inline-note,
.review-callout {
  background: #FFFBEB;
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .88rem;
  margin-bottom: 1.25rem;
}

/* ===== AUTHOR SECTION ===== */
.author-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.author-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--indigo);
  margin-bottom: .75rem;
}
.author-name { font-size: 1rem; margin-bottom: .3rem; }
.author-creds {
  font-size: .82rem;
  color: var(--emerald);
  font-weight: 600;
  margin-bottom: .5rem;
}
.author-bio { font-size: .9rem; color: var(--muted); line-height: 1.6; }

/* ===== FOOTER ===== */
.site-footer {
  background: #1e1b4b;
  color: #d1d5db;
  margin-top: auto;
  width: 100%;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.footer-col {
  flex: 1 1 180px;
  min-width: 0;
}
.footer-col dt.footer-heading {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--amber);
  margin-bottom: .6rem;
}
.footer-col dd {
  font-size: .8rem;
  line-height: 1.5;
  margin-bottom: .35rem;
  word-break: break-word;
}
.footer-col dd a {
  color: #d1d5db;
  text-decoration: underline;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.footer-col dd a:hover { color: var(--amber); }
.footer-rg {
  color: var(--emerald);
  font-size: .78rem !important;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: .5rem;
}

/* ===== HEADING DECORATION (h2 > span) ===== */
h2 > span, h3 > span {
  display: inline;
}

/* ===== RESPONSIVE ===== */

/* Tablet */
@media (max-width: 900px) {
  :root { --sidebar-w: 180px; }
  .content-layout { padding: 1rem .75rem; }
  .body-section { padding: 1.25rem; }
}

/* Mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }

  .content-layout {
    flex-direction: column;
    padding: .75rem;
    gap: .75rem;
  }

  .sidebar {
    width: 100%;
    order: 1;
  }
  .sidebar-inner {
    position: static;
  }
  .content-main { order: 0; }

  .header-inner {
    padding: 0 .5rem;
    gap: .4rem;
    height: 56px;
  }

  .brand {
    font-size: .85rem;
  }

  .cta {
    font-size: .7rem;
    padding: .35rem .55rem;
    min-height: 40px;
  }

  .nav-toggle {
    font-size: .78rem;
    padding: .35rem .55rem;
    min-height: 40px;
  }

  .nav-menu {
    top: 58px;
    left: 0;
    right: 0;
    padding: .5rem;
  }

  .hero-text h1 { font-size: 1.25rem; }
  .body-section { padding: 1rem; }

  .footer-inner {
    flex-direction: column;
    gap: 1.25rem;
  }
  .footer-col { flex: none; width: 100%; }

  .card-dl {
    grid-template-columns: 1fr;
  }

  /* Prevent horizontal overflow from tables */
  .prose { overflow-x: hidden; }
  .prose table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .prose pre { display: block; overflow-x: auto; max-width: 100%; }
}

@media (max-width: 480px) {
  .hero-section,
  .review-hero,
  .compare-hero,
  .ranking-hero,
  .inner-hero {
    padding: 1.5rem .75rem 1.25rem;
  }

  .header-ctas { gap: .3rem; }
  .cta { padding: .3rem .45rem; font-size: .68rem; }
}

/* ===== UTILITY ===== */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Ensure nothing overflows viewport */
img, video, iframe, embed, object { max-width: 100%; height: auto; }
table { max-width: 100%; }

a[data-cta],button[aria-controls]{min-height:44px;min-width:44px;box-sizing:border-box}main p a{text-decoration:underline}.tbl-scroll{overflow-x:auto;max-width:100%}