/* ===================================================
   Kentucky Derby Bet Calculator — E-Ink / Paper Theme
   Lexend + Source Sans 3 · Parchment ground · Monochrome
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&family=Source+Sans+3:wght@300;400;500;600;700&display=swap');

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

:root {
  --paper: #fdfbf7;
  --paper-2: #f5f5f5;
  --ink: #1a1a1a;
  --ink-muted: #555;
  --ink-faint: #999;
  --border: #d8d4cc;
  --border-light: #e8e4dc;
  --rail-w: 240px;
  --content-max: 780px;
  --gap: 1.5rem;
  --radius-card: 28px;
  --radius-sm: 6px;
  --font-body: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  --font-head: 'Lexend', 'Segoe UI', system-ui, sans-serif;
  --transition: none;
}

/* ── Base ── */
html { scroll-behavior: auto; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}

h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.6rem); margin-top: 2rem; }
h3 { font-size: clamp(1rem, 2vw, 1.25rem); margin-top: 1.5rem; }

p { margin-top: 1rem; }
p:first-child { margin-top: 0; }

a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

ul, ol { padding-left: 1.5rem; margin-top: 1rem; }
li { margin-top: 0.4rem; }

strong { font-weight: 600; }
small { font-size: 0.78rem; font-family: var(--font-head); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); }

table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; font-size: 0.95rem; }
th, td { border: 1px solid var(--border); padding: 0.6rem 0.8rem; text-align: left; }
th { background: var(--paper-2); font-family: var(--font-head); font-weight: 600; }

blockquote {
  border-left: 3px solid var(--ink);
  padding: 0.8rem 1.2rem;
  margin: 1.5rem 0;
  background: var(--paper-2);
  font-style: italic;
}

/* ── Page Shell: Fixed Left Rail + Content Area ── */
.page-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ── Side Rail (nav) ── */
.side-rail {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--rail-w);
  height: 100vh;
  background: var(--paper);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  padding: 0 0 1rem;
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.2rem 1rem 1rem;
  border-bottom: 1px solid var(--border-light);
  min-height: 64px;
}

.brand-logo { width: 32px; height: 32px; object-fit: contain; }

.brand-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  line-height: 1.2;
}

/* Nav details/summary */
.nav-details {
  flex: 1;
  overflow: visible;
}

.nav-toggle {
  display: none; /* hidden on desktop */
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  background: none;
  color: var(--ink);
  border-bottom: 1px solid var(--border-light);
  list-style: none;
  min-height: 44px;
}

.nav-toggle::-webkit-details-marker { display: none; }
.nav-toggle::marker { display: none; }

.toggle-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* On desktop the menu is always visible */
.nav-menu {
  list-style: none;
  padding: 0.75rem 0;
  margin: 0;
}

.nav-menu li { margin: 0; }

.nav-menu a {
  display: block;
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font-head);
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: var(--transition);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.nav-menu a:hover,
.nav-menu a[aria-current="page"] {
  border-left-color: var(--ink);
  background: var(--paper-2);
  font-weight: 500;
}

/* Header CTA group in rail */
.header-cta-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

/* CTA Buttons */
.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1rem;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  transition: var(--transition);
  text-align: center;
}

.cta-signup {
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
}

.cta-signup:hover {
  background: #333;
  color: var(--paper);
  text-decoration: none;
}

.cta-login {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}

.cta-login:hover {
  background: var(--paper-2);
  text-decoration: none;
}

/* ── Content Area (offset by rail width on desktop) ── */
.content-area {
  margin-left: var(--rail-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Hero (Home) ── */
.hero-section {
  min-height: 100vh;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  min-height: 100vh;
}

.hero-media {
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.hero-media img.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-copy {
  padding: 4rem 3rem 4rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: right;
}

.hero-copy--full {
  grid-column: 1 / -1;
  text-align: left;
  padding: 4rem 3rem;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.75rem;
  font-family: var(--font-head);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
  margin-bottom: 1rem;
  align-self: flex-end;
}

.hero-copy--full .hero-eyebrow { align-self: flex-start; }

.hero-copy h1 { margin-bottom: 0.75rem; }

.hero-lead {
  color: var(--ink-muted);
  font-size: 1rem;
  margin-top: 0.75rem;
  margin-bottom: 1.5rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  align-self: flex-end;
  letter-spacing: 0.02em;
}

.hero-copy--full .btn-primary { align-self: flex-start; }
.btn-primary:hover { background: #333; color: var(--paper); text-decoration: none; }

/* ── Inner Hero (non-home pages) ── */
.inner-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  min-height: 300px;
}

.inner-hero.no-media {
  grid-template-columns: 1fr;
  min-height: 160px;
  align-items: center;
  padding: 2.5rem 2.5rem;
}

.inner-hero-media { overflow: hidden; border-right: 1px solid var(--border); }
.inner-hero-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.inner-hero-copy {
  padding: 2.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* ── Feature Banner ── */
.feature-banner {
  background: var(--paper-2);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 2.5rem;
}

.feature-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-family: var(--font-head);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.75rem;
}

.feature-desc { color: var(--ink-muted); margin-top: 0.5rem; }

/* ── FAQ Banner ── */
.faq-banner {
  padding: 2.5rem 2.5rem;
  border-bottom: 1px solid var(--border);
}

.faq-banner small { display: block; margin-bottom: 0.5rem; }

/* ── Main Content Structure: main > section.wrap > div > article ── */
main {
  flex: 1;
  padding: 2rem 2.5rem 3rem;
}

.wrap {
  max-width: calc(var(--content-max) + 260px + var(--gap) * 2);
  margin: 0 auto;
}

.wrap > div {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: var(--gap) 2rem;
  align-items: start;
}

/* ── Sidebar (left of content) ── */
aside.sidebar {
  position: sticky;
  top: 1.5rem;
  padding: 1.25rem;
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sidebar-heading {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.sidebar-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-links li { margin: 0; }

.sidebar-links a {
  display: flex;
  align-items: center;
  padding: 0.45rem 0;
  font-size: 0.875rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  min-height: 44px;
}

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

.sidebar-cta {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-cta small { display: block; margin-bottom: 0.5rem; }

.sidebar-signup {
  width: 100%;
  font-size: 0.82rem;
}

.trust-sidebar {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.trust-sidebar small { display: block; margin-bottom: 0.4rem; }
.trust-link { font-size: 0.875rem; text-decoration: underline; color: var(--ink); }

/* ── Main Article ── */
.main-article {
  min-width: 0;
}

.article-body {
  max-width: var(--content-max);
}

.article-body a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.article-body a:hover { text-decoration-thickness: 2px; }

/* ── Byline ── */
.byline {
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-family: var(--font-head);
  margin-top: 0.75rem;
  margin-bottom: 0;
}

.author-name { font-weight: 500; }

/* ── Stage Badge ── */
.stage-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-family: var(--font-head);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--ink-muted);
  margin-bottom: 0.75rem;
}

/* ── Child-page Cards (Home) ── */
.child-cards {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.child-cards > small { display: block; margin-bottom: 0.5rem; }
.child-cards > h2 { margin-top: 0.25rem; margin-bottom: 1.25rem; }

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card-list li { margin: 0; }

.card-list a {
  display: block;
  padding: 1.25rem 1.5rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  min-height: 80px;
  transition: var(--transition);
}

.card-list a:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--ink-faint);
}

.card-title {
  display: block;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.95rem;
  line-height: 1.3;
  margin-bottom: 0.4rem;
}

.card-list small {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ── Related List (guide bottom) ── */
.article-footer-links {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-footer-links > small { display: block; margin-bottom: 0.4rem; }
.article-footer-links > h2 { margin-top: 0.2rem; margin-bottom: 1rem; }

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-list li {
  margin: 0;
  border-bottom: 1px solid var(--border-light);
  padding: 0.6rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.related-list a {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--ink);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.related-list a:hover { text-decoration: underline; }
.related-list small { font-size: 0.78rem; letter-spacing: 0.02em; text-transform: none; color: var(--ink-muted); }

/* ── Author Profile (about) ── */
.author-profile {
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.author-profile > small { display: block; margin-bottom: 0.4rem; }
.author-profile > h2 { margin-top: 0.25rem; }
.author-credentials { font-size: 0.9rem; margin-top: 0.5rem; color: var(--ink-muted); }
.author-bio { font-size: 1rem; margin-top: 0.75rem; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  background: var(--paper-2);
  font-size: 0.85rem;
}

.footer-rg {
  padding: 1rem 2.5rem;
  border-bottom: 1px solid var(--border-light);
}

.rg-notice {
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-family: var(--font-head);
  font-weight: 400;
  letter-spacing: 0.01em;
  margin: 0;
}

.footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2.5rem;
  border-bottom: 1px solid var(--border-light);
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.footer-brand {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}

.footer-copy {
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.footer-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
}

.footer-right a {
  color: var(--ink-muted);
  font-size: 0.82rem;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.footer-right a:hover { text-decoration: underline; color: var(--ink); }

.footer-disclaimer {
  padding: 0.75rem 2.5rem;
}

.footer-disclaimer p {
  color: var(--ink-faint);
  font-size: 0.75rem;
  line-height: 1.5;
  margin: 0;
}

/* ── Scroll Reveal (pure CSS via @starting-style or just opacity animation) ── */
@media (prefers-reduced-motion: no-preference) {
  .main-article,
  .card-list li,
  .related-list li {
    animation: revealUp 0.4s ease both;
  }

  .card-list li:nth-child(2) { animation-delay: 0.05s; }
  .card-list li:nth-child(3) { animation-delay: 0.1s; }
  .card-list li:nth-child(4) { animation-delay: 0.15s; }
  .card-list li:nth-child(5) { animation-delay: 0.2s; }
  .card-list li:nth-child(6) { animation-delay: 0.25s; }

  @keyframes revealUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .cta-signup:hover,
  .cta-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ── Responsive: Tablet ── */
@media (max-width: 1024px) {
  :root { --rail-w: 200px; }
  .hero-copy { padding: 3rem 2rem; }
  main { padding: 1.5rem 1.5rem 2.5rem; }
  .footer-rg,
  .footer-nav,
  .footer-disclaimer { padding-left: 1.5rem; padding-right: 1.5rem; }
}

/* ── Responsive: Mobile ── */
@media (max-width: 768px) {
  :root { --rail-w: 0px; }

  /* Rail becomes a top header on mobile */
  .side-rail {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 300;
    padding: 0;
    max-height: 120px;
    overflow: visible;
  }

  .rail-brand {
    flex: 1;
    border-bottom: none;
    padding: 0.6rem 0.75rem;
    min-height: 52px;
  }

  .brand-name {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  /* Show the toggle button on mobile */
  .nav-toggle {
    display: flex;
    min-height: 52px;
    width: auto;
    padding: 0.5rem 0.75rem;
    border-bottom: none;
    border-left: 1px solid var(--border-light);
  }

  .toggle-label { display: none; }

  /* Nav details becomes a dropdown on mobile */
  .nav-details {
    order: 10;
    width: 100%;
    flex-basis: 100%;
    border-top: 1px solid var(--border-light);
  }

  /* Menu hidden when details is closed */
  .nav-details:not([open]) .nav-menu {
    display: none;
  }

  .nav-details[open] .nav-menu {
    display: block;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
    max-height: 60vh;
    overflow-y: auto;
  }

  .nav-menu a {
    padding: 0.65rem 1rem;
    min-height: 48px;
  }

  /* CTAs stay visible on one row with brand + toggle */
  .header-cta-group {
    flex-direction: row;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
    border-top: none;
    border-left: 1px solid var(--border-light);
    margin-top: 0;
    min-height: 52px;
    align-items: center;
  }

  .cta {
    font-size: 0.75rem;
    padding: 0.45rem 0.7rem;
    min-height: 44px;
    white-space: nowrap;
  }

  /* Offset content area by mobile header height */
  .content-area {
    margin-left: 0;
    padding-top: 56px;
  }

  /* Hero stacks on mobile */
  .hero-inner {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-media { border-right: none; border-bottom: 1px solid var(--border); max-height: 280px; }

  .hero-copy {
    text-align: left;
    padding: 2rem 1.25rem;
  }

  .hero-eyebrow { align-self: flex-start; }
  .btn-primary { align-self: flex-start; }

  .inner-hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .inner-hero-media { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .inner-hero-copy { padding: 1.5rem 1.25rem; }

  .feature-banner,
  .faq-banner { padding: 1.5rem 1.25rem; }

  /* Sidebar: collapse to top on mobile */
  .wrap > div {
    grid-template-columns: 1fr;
  }

  aside.sidebar {
    position: static;
    order: -1;
    margin-bottom: 1rem;
  }

  main { padding: 1.25rem 1rem 2rem; }

  .footer-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
  }

  .footer-rg,
  .footer-disclaimer { padding: 0.75rem 1rem; }

  .footer-right { gap: 0.5rem 1rem; }

  .footer-right a { min-height: 44px; }

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

  h1 { font-size: 1.5rem; }
}

/* ── Body copy links clearly distinct ── */
.article-body a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--ink-faint);
  text-underline-offset: 3px;
}

.article-body a:hover {
  text-decoration-color: var(--ink);
}

/* ── FAQ specific ── */
.faq-article .article-body details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  padding: 0 1rem;
}

.faq-article .article-body details summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 500;
  padding: 0.75rem 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.faq-article .article-body details[open] summary {
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.5rem;
}

/* ── Heading decoration: small eyebrow before h2 ── */
small + h2,
small + h3 {
  margin-top: 0.3rem;
}

/* ── Ensure no horizontal scroll ── */
img { max-width: 100%; height: auto; display: block; }
.hero-img { width: 100%; }

a[data-cta],button[aria-controls]{min-height:44px;min-width:44px;box-sizing:border-box}main p a{text-decoration:underline}