/* ============================================================
   BuybackStocks — Shared Stylesheet
   Brand tokens + base typography + reusable components
   ============================================================ */

:root {
  /* Color palette */
  --bbs-navy: #0A2540;
  --bbs-navy-90: #143559;
  --bbs-navy-80: #1E4470;
  --bbs-gold: #C9A227;
  --bbs-gold-soft: #E4C566;
  --bbs-green: #1F6F4A;
  --bbs-green-soft: #E8F4ED;
  --bbs-text: #1A2A3A;
  --bbs-muted: #5A6772;
  --bbs-light: #B7C0CC;
  --bbs-bg-tint: #F5F7FA;
  --bbs-bg-cream: #FAF8F2;
  --bbs-border: #E0E5EB;
  --bbs-white: #FFFFFF;
  --bbs-red-soft: #C13B3B;

  /* Typography */
  --bbs-font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --bbs-font-body: 'Inter', 'Helvetica Neue', Arial, sans-serif;

  /* Spacing scale */
  --bbs-s-1: 4px;
  --bbs-s-2: 8px;
  --bbs-s-3: 12px;
  --bbs-s-4: 16px;
  --bbs-s-5: 24px;
  --bbs-s-6: 32px;
  --bbs-s-7: 48px;
  --bbs-s-8: 64px;
  --bbs-s-9: 96px;

  /* Layout */
  --bbs-container: 1180px;
  --bbs-radius-sm: 4px;
  --bbs-radius-md: 8px;
  --bbs-radius-lg: 14px;

  /* Shadows */
  --bbs-shadow-sm: 0 1px 3px rgba(10,37,64,0.08);
  --bbs-shadow-md: 0 4px 12px rgba(10,37,64,0.10);
  --bbs-shadow-lg: 0 16px 40px rgba(10,37,64,0.14);
}

/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--bbs-font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--bbs-text);
  background: var(--bbs-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--bbs-navy); text-decoration: none; transition: color 150ms ease; }
a:hover { color: var(--bbs-gold); }
hr { border: 0; height: 1px; background: var(--bbs-border); margin: var(--bbs-s-7) 0; }

/* ===== Typography ===== */
h1, h2, h3, h4 {
  font-family: var(--bbs-font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--bbs-navy);
  margin: 0 0 var(--bbs-s-4);
}
h1 { font-size: clamp(40px, 6vw, 64px); letter-spacing: -0.02em; }
h2 { font-size: clamp(28px, 3.6vw, 42px); margin-top: var(--bbs-s-8); }
h3 { font-size: clamp(22px, 2.6vw, 30px); margin-top: var(--bbs-s-6); }
h4 { font-size: 20px; font-family: var(--bbs-font-body); font-weight: 600; }
p { margin: 0 0 var(--bbs-s-4); }
strong { font-weight: 600; color: var(--bbs-navy); }
.lead { font-size: 19px; color: var(--bbs-text); line-height: 1.6; }

.eyebrow {
  display: inline-block;
  font-family: var(--bbs-font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--bbs-gold);
  margin-bottom: var(--bbs-s-3);
}

/* ===== Layout ===== */
.container { max-width: var(--bbs-container); margin: 0 auto; padding: 0 var(--bbs-s-5); }
.section { padding: var(--bbs-s-9) 0; }
.section.tight { padding: var(--bbs-s-7) 0; }
.section.dark { background: var(--bbs-navy); color: var(--bbs-white); }
.section.dark h1, .section.dark h2, .section.dark h3 { color: var(--bbs-white); }
.section.tint { background: var(--bbs-bg-tint); }

/* ===== Header ===== */
.site-header {
  background: var(--bbs-white);
  border-bottom: 1px solid var(--bbs-border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--bbs-s-4) var(--bbs-s-5);
  max-width: var(--bbs-container);
  margin: 0 auto;
}
.site-header__logo img { height: 44px; width: auto; }
.site-header__nav { display: flex; gap: var(--bbs-s-6); align-items: center; }
.site-header__nav a {
  font-weight: 500;
  font-size: 15px;
  color: var(--bbs-text);
}
.site-header__nav a.cta {
  background: var(--bbs-gold);
  color: var(--bbs-navy);
  padding: 10px 20px;
  border-radius: var(--bbs-radius-sm);
  font-weight: 600;
}
.site-header__nav a.cta:hover { background: var(--bbs-gold-soft); color: var(--bbs-navy); }

/* ===== Hero ===== */
.hero {
  position: relative;
  background: var(--bbs-navy);
  color: var(--bbs-white);
  padding: var(--bbs-s-9) 0;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 6px;
  background: var(--bbs-gold);
}
.hero__inner { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--bbs-s-8); align-items: center; }
@media (max-width: 900px) { .hero__inner { grid-template-columns: 1fr; } }
.hero h1 { color: var(--bbs-white); }
.hero h1 em { color: var(--bbs-gold); font-style: normal; }
.hero p { color: var(--bbs-light); font-size: 19px; max-width: 540px; }
.hero .form { margin-top: var(--bbs-s-6); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: var(--bbs-radius-sm);
  font-family: var(--bbs-font-body);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.3px;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  transition: all 150ms ease;
}
.btn-primary { background: var(--bbs-gold); color: var(--bbs-navy); }
.btn-primary:hover { background: var(--bbs-gold-soft); color: var(--bbs-navy); }
.btn-secondary { background: transparent; color: var(--bbs-white); border: 1.5px solid var(--bbs-light); }
.btn-secondary:hover { background: var(--bbs-white); color: var(--bbs-navy); border-color: var(--bbs-white); }
.btn-navy { background: var(--bbs-navy); color: var(--bbs-white); }
.btn-navy:hover { background: var(--bbs-navy-90); color: var(--bbs-white); }

/* ===== Forms ===== */
.opt-in {
  display: flex;
  gap: var(--bbs-s-3);
  max-width: 480px;
  margin-top: var(--bbs-s-5);
}
.opt-in input[type="email"] {
  flex: 1;
  padding: 14px 18px;
  border: 1.5px solid var(--bbs-light);
  border-radius: var(--bbs-radius-sm);
  font-family: var(--bbs-font-body);
  font-size: 16px;
  background: var(--bbs-white);
  color: var(--bbs-text);
}
.opt-in input[type="email"]:focus {
  outline: none;
  border-color: var(--bbs-gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}
.opt-in .btn { white-space: nowrap; }
.opt-in__legal {
  font-size: 12px;
  color: var(--bbs-light);
  margin-top: var(--bbs-s-3);
  max-width: 480px;
  line-height: 1.5;
}

/* ===== Stat Cards ===== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--bbs-s-5); margin-top: var(--bbs-s-7); }
@media (max-width: 700px) { .stat-grid { grid-template-columns: 1fr; } }
.stat {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(201,162,39,0.3);
  border-radius: var(--bbs-radius-md);
  padding: var(--bbs-s-5);
}
.stat__label { font-size: 12px; font-weight: 600; letter-spacing: 2px; color: var(--bbs-gold); text-transform: uppercase; }
.stat__value { font-family: var(--bbs-font-display); font-size: 38px; font-weight: 700; color: var(--bbs-white); margin: 6px 0 0; }
.stat__sub { font-size: 13px; color: var(--bbs-light); }

/* ===== Tables (the buyback listicle) ===== */
.buyback-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bbs-white);
  border-radius: var(--bbs-radius-md);
  overflow: hidden;
  box-shadow: var(--bbs-shadow-sm);
  font-feature-settings: 'tnum';
}
.buyback-table thead {
  background: var(--bbs-navy);
  color: var(--bbs-white);
}
.buyback-table th, .buyback-table td { padding: 16px 18px; text-align: left; }
.buyback-table th { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.buyback-table tbody tr { border-bottom: 1px solid var(--bbs-border); }
.buyback-table tbody tr:last-child { border-bottom: 0; }
.buyback-table tbody tr:nth-child(even) { background: var(--bbs-bg-tint); }
.buyback-table .ticker { color: var(--bbs-gold); font-weight: 600; font-family: var(--bbs-font-body); }
.buyback-table .num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--bbs-navy); }
.buyback-table .pct { color: var(--bbs-green); font-weight: 600; }
.buyback-table .rank {
  width: 36px;
  text-align: center;
  font-family: var(--bbs-font-display);
  font-weight: 700;
  color: var(--bbs-muted);
}

/* ===== Buyback "card" rows for the listicle ===== */
.buyback-entry {
  background: var(--bbs-white);
  border: 1px solid var(--bbs-border);
  border-radius: var(--bbs-radius-md);
  padding: var(--bbs-s-6);
  margin-bottom: var(--bbs-s-5);
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: var(--bbs-s-5);
  box-shadow: var(--bbs-shadow-sm);
}
.buyback-entry__rank {
  font-family: var(--bbs-font-display);
  font-size: 56px;
  font-weight: 700;
  color: var(--bbs-gold);
  line-height: 1;
}
.buyback-entry__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--bbs-s-3);
  margin-bottom: var(--bbs-s-2);
}
.buyback-entry__name { font-family: var(--bbs-font-display); font-size: 26px; font-weight: 700; color: var(--bbs-navy); }
.buyback-entry__ticker {
  font-family: var(--bbs-font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--bbs-gold);
  background: rgba(201,162,39,0.10);
  padding: 4px 10px;
  border-radius: var(--bbs-radius-sm);
}
.buyback-entry__meta {
  display: flex;
  gap: var(--bbs-s-5);
  margin-bottom: var(--bbs-s-3);
  font-size: 14px;
  flex-wrap: wrap;
}
.buyback-entry__meta div { color: var(--bbs-muted); }
.buyback-entry__meta strong { color: var(--bbs-navy); font-family: var(--bbs-font-body); }
.buyback-entry__commentary { color: var(--bbs-text); font-size: 15px; line-height: 1.65; }

/* ===== Inline mid-article opt-in ===== */
.inline-opt {
  background: linear-gradient(135deg, var(--bbs-navy) 0%, var(--bbs-navy-90) 100%);
  color: var(--bbs-white);
  border-radius: var(--bbs-radius-lg);
  padding: var(--bbs-s-7);
  margin: var(--bbs-s-7) 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.inline-opt::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--bbs-gold);
}
.inline-opt h3 { color: var(--bbs-white); margin-bottom: var(--bbs-s-3); }
.inline-opt p { color: var(--bbs-light); max-width: 540px; margin: 0 auto var(--bbs-s-5); }
.inline-opt .opt-in { margin: 0 auto; }
.inline-opt .opt-in__legal { color: var(--bbs-light); margin-left: auto; margin-right: auto; }

/* ===== Footer ===== */
.site-footer {
  background: var(--bbs-navy);
  color: var(--bbs-light);
  padding: var(--bbs-s-8) 0 var(--bbs-s-5);
  font-size: 14px;
}
.site-footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: var(--bbs-s-6); }
@media (max-width: 800px) { .site-footer__grid { grid-template-columns: 1fr 1fr; } }
.site-footer h4 { color: var(--bbs-white); font-family: var(--bbs-font-body); font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: var(--bbs-s-4); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: var(--bbs-s-2); }
.site-footer a { color: var(--bbs-light); }
.site-footer a:hover { color: var(--bbs-gold); }
.site-footer__brand img { height: 40px; margin-bottom: var(--bbs-s-3); }
.site-footer__brand p { color: var(--bbs-light); font-size: 13px; line-height: 1.6; max-width: 320px; }
.site-footer__bottom {
  border-top: 1px solid rgba(255,255,255,0.10);
  margin-top: var(--bbs-s-7);
  padding-top: var(--bbs-s-5);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--bbs-s-3);
  font-size: 12px;
  color: var(--bbs-light);
}
.site-footer__disclaimer {
  margin-top: var(--bbs-s-5);
  padding: var(--bbs-s-4);
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--bbs-gold);
  font-size: 12px;
  color: var(--bbs-light);
  line-height: 1.7;
  border-radius: var(--bbs-radius-sm);
}

/* ============================================================
   GLOBAL: prevent horizontal overflow on any viewport
   Fixes "page scrolls left when scrolling down" on mobile.
   `overflow-x: clip` is the modern correct fix (doesn't break
   sticky/fixed positioning the way `overflow-x: hidden` does).
   ============================================================ */
html { overflow-x: clip; }
body { overflow-x: clip; max-width: 100vw; }
@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}

/* Min-width: 0 fix for flex/grid children that won't shrink below content width */
.hero__inner > *,
.site-footer__grid > *,
.buyback-entry > div,
.stat-grid > *,
.article-meta > *,
.opt-in > * { min-width: 0; }

img, video, picture, svg { max-width: 100%; }

/* ============================================================
   MOBILE OPTIMIZATIONS (≤ 768px)
   Tighten padding, fix nav overflow, stack opt-in form, larger
   touch targets, reduce font sizes on small viewports.
   ============================================================ */
@media (max-width: 768px) {
  /* Header — hide nav links on mobile, keep only logo + CTA */
  .site-header__inner { padding: 12px 16px; }
  .site-header__logo img,
  .site-header__logo picture img { height: 36px; width: auto; }
  .site-header__nav a:not(.cta) { display: none; }
  .site-header__nav { gap: 12px; }
  .site-header__nav a.cta { padding: 10px 16px; font-size: 14px; min-height: 44px; display: inline-flex; align-items: center; }

  /* Tighten section padding */
  .section { padding: 56px 0; }
  .section.tight { padding: 40px 0; }
  .hero { padding: 56px 0 64px; }
  .container { padding: 0 16px; }

  /* Hero — stack vertically, smaller H1 */
  .hero__inner { gap: 32px; grid-template-columns: 1fr; }
  .hero h1 { font-size: 34px; line-height: 1.15; letter-spacing: -0.5px; word-spacing: -1px; }
  .hero p { font-size: 17px; }

  /* Tame letter-spacing on uppercase text to prevent overflow */
  .eyebrow {
    letter-spacing: 1.5px;
    font-size: 11px;
    word-spacing: -1px;
    line-height: 1.4;
  }
  .stat__label,
  .bbs-stat-label { letter-spacing: 1.2px; font-size: 11px; }

  /* Opt-in form — stack input + button */
  .opt-in { flex-direction: column; gap: 10px; }
  .opt-in input[type="email"] { width: 100%; padding: 14px 16px; font-size: 16px; /* 16px prevents iOS auto-zoom */ }
  .opt-in .btn { width: 100%; padding: 14px 20px; min-height: 48px; }
  .opt-in__legal { font-size: 12px; }

  /* Stat cards — full width single column. !important to override homepage inline style. */
  .stat-grid {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    grid-template-columns: 1fr !important;
  }
  .stat { padding: 18px 20px; }
  .stat__value { font-size: 30px; }
  .stat__sub { font-size: 12px; }

  /* Why-section three-column → single */
  .section h2 { font-size: 28px; margin-top: 32px; }
  .lead { font-size: 17px; }

  /* Featured listicle card — stack image below text */
  .featured-card,
  [class*="featured"] { gap: 24px !important; }

  /* Inline opt-in callout */
  .inline-opt { padding: 32px 20px; border-radius: 10px; }
  .inline-opt h3 { font-size: 24px; }

  /* Listicle article body */
  .article-body { padding: 40px 16px; }
  .article-meta { gap: 12px; font-size: 13px; }

  /* TOC — single column on mobile */
  .toc ol { columns: 1; }

  /* Buyback entry cards — collapse rank column, smaller padding, wrap head items */
  .buyback-entry { grid-template-columns: 56px 1fr; gap: 16px; padding: 20px 16px; }
  .buyback-entry__rank { font-size: 40px; }
  .buyback-entry__name { font-size: 22px; line-height: 1.2; }
  .buyback-entry__head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .buyback-entry__ticker { font-size: 12px; }
  .buyback-entry__meta { gap: 6px 14px; font-size: 13px; }
  .buyback-entry__meta > div { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
  .buyback-entry__commentary { font-size: 14px; }

  /* Article meta — wrap with smaller gap on mobile */
  .article-meta { gap: 6px 12px; font-size: 12px; flex-wrap: wrap; }

  /* Article body padding */
  .article-body { padding: 32px 16px; }

  /* H1 on listicle */
  .article-body > h1,
  article > h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.5px; }

  /* H2s tighter on mobile */
  h2 { font-size: 24px; line-height: 1.2; margin-top: 32px; }

  /* Footer — single column above tablet breakpoint */
  .site-footer__grid { grid-template-columns: 1fr; gap: 32px; }
  .site-footer__brand img { height: 36px; }
  .site-footer__bottom { flex-direction: column; align-items: flex-start; }

  /* Touch targets — minimum 44px tap area */
  a, button, .btn { min-height: 44px; }
  .site-footer a, .site-header__nav a:not(.cta) { min-height: auto; }
}

/* ============================================================
   EXTRA SMALL (≤ 380px) — iPhone SE and similar
   ============================================================ */
@media (max-width: 380px) {
  .container { padding: 0 14px; }
  .hero h1 { font-size: 30px; }
  .site-header__logo img,
  .site-header__logo picture img { height: 32px; }
  .site-header__nav a.cta { padding: 8px 14px; font-size: 13px; }
  .stat__value { font-size: 26px; }
  .buyback-entry { grid-template-columns: 44px 1fr; gap: 10px; padding: 16px 12px; }
  .buyback-entry__rank { font-size: 32px; }
  .buyback-entry__name { font-size: 20px; }
  .buyback-entry__meta { font-size: 12px; }
  .buyback-entry__commentary { font-size: 13px; }
  .article-body { padding: 28px 12px; }
  .article-body > h1,
  article > h1 { font-size: 28px; }
  h2 { font-size: 22px; }
  .eyebrow { font-size: 10px; letter-spacing: 1px; }
  .inline-opt { padding: 24px 16px; }
  .inline-opt h3 { font-size: 20px; }
}
