/* =====================================================================
   Abhay Model of Excellence — public site stylesheet
   Editorial direction: deep navy + warm cream + muted gold,
   inspired by the print book's redesigned interior.
   ===================================================================== */

:root {
  /* Palette */
  --navy:        #122844;
  --navy-deep:   #0a1a30;
  --gold:        #b89255;
  --gold-soft:   #d4b87b;
  --cream:       #faf6ef;
  --cream-warm:  #f3ecdf;
  --paper:       #ffffff;
  --ink:         #1a1a1a;
  --ink-soft:    #3a3a3a;
  --muted:       #6b6b6b;
  --rule:        #e3dccb;

  /* Type */
  --display: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --body:    'Manrope', system-ui, -apple-system, sans-serif;

  /* Layout */
  --container: 72rem;
  --narrow:    44rem;
  --radius:    4px;
  --shadow-sm: 0 1px 2px rgba(10,26,48,.05);
  --shadow-md: 0 6px 20px rgba(10,26,48,.08);
  --shadow-lg: 0 20px 50px rgba(10,26,48,.15);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Global responsive media safety net — every image, by default, can't
   exceed its container width. Individual rules below may further refine
   behaviour, but they should always either inherit or re-state this. */
img, svg, video, iframe { max-width: 100%; height: auto; }

/* ---------- Skip link --------- */
.skip-link {
  position: absolute; left: -9999px; top: 0; padding: .6rem 1rem;
  background: var(--navy); color: #fff; z-index: 1000;
}
.skip-link:focus { left: 8px; top: 8px; outline: 2px solid var(--gold); }

/* ---------- Containers --------- */
.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }
.container.narrow { max-width: var(--narrow); }
.text-center { text-align: center; }

/* ---------- Type --------- */
h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  color: var(--navy);
  line-height: 1.15;
  margin: 0 0 .6em;
  letter-spacing: -.005em;
}
h1 { font-size: clamp(2.2rem, 4.5vw, 3.5rem); font-weight: 500; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.05rem; font-family: var(--body); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--navy-deep); }

p { margin: 0 0 1em; }
a { color: var(--navy); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--gold-soft); }
a:hover { color: var(--gold); text-decoration-color: var(--gold); }

.eyebrow {
  font-family: var(--body);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--gold);
  margin: 0 0 1rem;
}
.lede { font-family: var(--display); font-size: 1.35rem; font-style: italic; color: var(--ink-soft); line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint  { font-size: .85rem; color: var(--muted); display: inline-block; margin-left: .25rem; }
.req   { color: #c1554a; }

/* ---------- Header --------- */
.site-header {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, .92);
}
.header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem;
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--navy); }
.brand:hover { color: var(--navy); }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  font-family: var(--display); font-size: 1.4rem; font-weight: 600;
  background: var(--navy); color: var(--gold);
  border: 1px solid var(--navy-deep);
  border-radius: 2px;
  letter-spacing: -.02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-family: var(--display); font-size: 1.15rem; font-weight: 600; }
.brand-sub { font-size: .72rem; color: var(--muted); letter-spacing: .05em; }

.primary-nav { display: flex; gap: 1.5rem; align-items: center; }
.primary-nav a {
  text-decoration: none;
  font-size: .92rem; font-weight: 500;
  color: var(--ink-soft);
  padding: .35rem 0; position: relative;
}
.primary-nav a:hover, .primary-nav a.active { color: var(--navy); }
.primary-nav a.active::after {
  content: ""; position: absolute; bottom: -.55rem; left: 0; right: 0;
  height: 2px; background: var(--gold);
}

.nav-toggle { display: none; background: none; border: 0; width: 2.5rem; height: 2.5rem; cursor: pointer; }
.nav-toggle span { display: block; width: 1.4rem; height: 2px; background: var(--navy); margin: .3rem auto; transition: transform .25s, opacity .25s; }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .primary-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    flex-direction: column; gap: 0; padding: 0;
    transform: scaleY(0); transform-origin: top; transition: transform .25s ease;
    box-shadow: var(--shadow-md);
  }
  .primary-nav a {
    width: 100%; padding: 1rem 1.25rem; border-top: 1px solid var(--rule);
  }
  .primary-nav a.active::after { display: none; }
  body.nav-open .primary-nav { transform: scaleY(1); }
  body.nav-open .nav-toggle span:nth-child(1) { transform: translateY(.5rem) rotate(45deg); }
  body.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-.5rem) rotate(-45deg); }
}

/* ---------- Hero --------- */
.hero {
  padding: 4rem 0 5rem;
  background:
    radial-gradient(ellipse at 80% 0%, rgba(184,146,85,.10), transparent 50%),
    linear-gradient(180deg, var(--cream) 0%, var(--cream-warm) 100%);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(18,40,68,.025) 1px, transparent 1px);
  background-size: 60px 100%;
  pointer-events: none;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 4rem; align-items: center;
}
.hero-text h1 {
  font-size: clamp(2.4rem, 5vw, 4rem);
  margin-bottom: .5rem;
}
.hero-text .lede { margin: 0 0 2rem; font-size: 1.3rem; max-width: 32ch; }
.hero-text .author { font-family: var(--display); font-size: 1.05rem; color: var(--ink-soft); margin: 0 0 2rem; }
.hero-text .author strong { color: var(--navy); }

.hero-cta { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.hero-meta { font-size: .85rem; color: var(--muted); display: flex; gap: .5rem; flex-wrap: wrap; }

.hero-cover img {
  width: 100%; max-width: 380px; height: auto;
  box-shadow: var(--shadow-lg);
  border-radius: 2px;
  transform: rotate(-1deg);
  transition: transform .3s ease;
}
.hero-cover { text-align: center; }
.hero-cover img:hover { transform: rotate(0); }

@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; text-align: left; }
  .hero-cover img { transform: none; max-width: 240px; }
}

/* ---------- Buttons --------- */
.btn {
  display: inline-block; padding: .7rem 1.5rem;
  font-family: var(--body); font-size: .92rem; font-weight: 600;
  letter-spacing: .03em;
  border: 1px solid var(--navy);
  background: var(--navy); color: #fff;
  cursor: pointer; text-decoration: none;
  border-radius: 2px;
  transition: all .2s ease;
}
.btn:hover { background: var(--navy-deep); color: var(--gold); border-color: var(--navy-deep); }
.btn-primary { background: var(--navy); color: var(--cream); }
.btn-ghost   { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: var(--navy); color: var(--gold); }
.btn-sm { padding: .4rem 1rem; font-size: .82rem; }

/* ---------- Sections --------- */
.about-band {
  padding: 4rem 0;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.about-band p {
  font-family: var(--display);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 50rem;
  margin: 0 auto;
  text-align: center;
}

.contents-preview { padding: 5rem 0; }
.contents-preview h2 { text-align: center; margin-bottom: 3rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.card {
  display: block; padding: 1.75rem;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none; color: inherit;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--gold-soft); }
.card-label { font-size: .72rem; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; color: var(--gold); margin: 0 0 .75rem; }
.card h3 { margin: 0 0 .5rem; font-size: 1.45rem; }
.card p { color: var(--ink-soft); margin-bottom: 1.25rem; }
.card-link { font-size: .9rem; font-weight: 600; color: var(--navy); }

/* ---------- Generic page section --------- */
.page-section { padding: 4rem 0 5rem; }

/* ---------- TOC --------- */
.toc-group { margin: 2.5rem 0; }
.toc-group-title {
  font-size: .8rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold); font-family: var(--body);
  padding-bottom: .5rem; border-bottom: 2px solid var(--gold-soft); margin-bottom: 1rem;
}
.toc-list { list-style: none; counter-reset: tocnum; margin: 0; padding: 0; }
.toc-list li { border-bottom: 1px dotted var(--rule); }
.toc-list a {
  display: grid; grid-template-columns: 120px 1fr auto;
  gap: 1.5rem; align-items: baseline;
  padding: 1rem 0; text-decoration: none; color: var(--ink);
  transition: padding .2s ease;
}
.toc-list a:hover { padding-left: .5rem; background: linear-gradient(to right, rgba(184,146,85,.08), transparent); }
.toc-label { font-family: var(--display); font-style: italic; color: var(--gold); font-size: 1rem; }
.toc-title { font-size: 1.1rem; }
.toc-meta  { font-size: .8rem; color: var(--muted); }
@media (max-width: 540px) {
  .toc-list a { grid-template-columns: 1fr; gap: .15rem; }
  .toc-meta { font-size: .75rem; }
}

/* ---------- Chapter --------- */
.chapter { padding: 3.5rem 0 4rem; background: var(--paper); }
.chapter-header { text-align: center; margin-bottom: 3rem; }
.chapter-header h1 { font-size: clamp(2rem, 4vw, 3.2rem); margin-bottom: .5rem; }
.chapter-header .lede { margin: .5rem auto 1rem; max-width: 40ch; }
.chapter-meta { font-size: .85rem; color: var(--muted); display: flex; gap: .5rem; justify-content: center; }

.chapter-body {
  font-size: 1.08rem;
  line-height: 1.8;
}
.chapter-body p {
  margin: 0 0 1.4em;
  text-align: justify;
  hyphens: auto;
}
.chapter-body > p:first-of-type::first-letter {
  font-family: var(--display);
  font-weight: 600;
  font-size: 3.6em;
  float: left;
  line-height: .85;
  padding: .15em .12em 0 0;
  color: var(--navy);
}
.chapter-body > p:first-of-type::first-line {
  font-variant: small-caps;
  letter-spacing: .04em;
}
.chapter-body h2 {
  margin-top: 2.5rem;
  font-size: 1.7rem;
  font-family: var(--display);
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -.005em;
}
.chapter-body h3 {
  margin-top: 2.25rem;
  margin-bottom: .65rem;
  font-size: 1.15rem;
  font-family: var(--body);
  font-weight: 700;
  color: var(--navy-deep);
  letter-spacing: 0;
  text-transform: none;
}
/* Strip the <strong> inside h3 since the h3 itself is already bold */
.chapter-body h3 strong { font-weight: inherit; }
.chapter-body blockquote {
  font-family: var(--display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink-soft);
  line-height: 1.45;
  border-left: 3px solid var(--gold);
  padding: .25rem 0 .25rem 1.5rem;
  margin: 1.75rem 0;
}
.chapter-body blockquote p { margin: 0; text-align: left; }
.chapter-body ul, .chapter-body ol { padding-left: 1.5rem; margin: 0 0 1.4em; }
.chapter-body li { margin: .35rem 0; }

/* Pager */
.chapter-pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  margin-top: 3.5rem; padding-top: 2rem; border-top: 1px solid var(--rule);
}
.pager-link {
  display: block; padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  background: var(--cream);
  border-radius: var(--radius);
  text-decoration: none; color: inherit;
  transition: all .2s ease;
}
.pager-link:hover { border-color: var(--gold-soft); background: var(--cream-warm); }
.pager-link.next { text-align: right; }
.pager-dir { display: block; font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.pager-title { display: block; font-family: var(--display); font-size: 1.05rem; color: var(--navy); margin-top: .25rem; }
@media (max-width: 560px) {
  .chapter-pager { grid-template-columns: 1fr; }
  .pager-link.next { text-align: left; }
}

/* ---------- Comments --------- */
.comments-section {
  padding: 4rem 0;
  background: var(--cream-warm);
  border-top: 1px solid var(--rule);
}
.comments-section h2 { margin-bottom: .25rem; }
.comments-section > .container > p.muted { margin-bottom: 2rem; }

.comments { list-style: none; padding: 0; margin: 0 0 3rem; }
.comment {
  padding: 1.25rem 1.5rem;
  background: var(--paper);
  border-left: 3px solid var(--gold-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.comment-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: .5rem; gap: 1rem; flex-wrap: wrap;
}
.comment-author { font-family: var(--display); font-weight: 600; color: var(--navy); font-size: 1.1rem; }
.comment time { color: var(--muted); font-size: .82rem; }
.comment-body { color: var(--ink-soft); }
.comment-context { margin: .75rem 0 0; font-size: .85rem; color: var(--muted); }

.empty-note {
  background: var(--paper);
  border: 1px dashed var(--rule);
  padding: 1.5rem; border-radius: var(--radius);
  color: var(--muted); text-align: center;
  font-style: italic;
}

/* Comment form */
.comment-form { background: var(--paper); padding: 1.5rem 1.75rem 2rem; border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-row { margin-bottom: 1.25rem; }
.form-row label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; color: var(--navy-deep); }
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row textarea {
  width: 100%; padding: .65rem .8rem;
  font-family: var(--body); font-size: 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--cream);
  transition: border-color .15s, box-shadow .15s;
}
.form-row textarea { resize: vertical; line-height: 1.5; }
.form-row input:focus, .form-row textarea:focus {
  outline: 0; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,146,85,.18); background: var(--paper);
}
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Flash messages */
.flash {
  padding: .85rem 1.1rem; margin-bottom: 1rem;
  border-radius: var(--radius);
  border-left: 4px solid;
}
.flash-success { background: #eaf4ec; border-color: #2d8a3e; color: #1e5a2a; }
.flash-error   { background: #fbe9e7; border-color: #c1554a; color: #8a261c; }

/* ---------- Footer --------- */
.site-footer {
  background: var(--navy);
  color: rgba(255, 255, 255, .8);
  padding: 3.5rem 0 1.5rem;
  margin-top: 4rem;
}
.site-footer h4 { color: var(--gold); font-family: var(--body); font-size: .8rem; }
.site-footer p, .site-footer a { color: rgba(255, 255, 255, .75); }
.site-footer a { text-decoration-color: var(--gold-soft); }
.site-footer a:hover { color: var(--gold); }
.site-footer .muted { color: rgba(255, 255, 255, .55); }
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2.5rem;
}
.footer-grid .nolist { list-style: none; padding: 0; margin: 0; }
.footer-grid .nolist li { margin: .3rem 0; }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid rgba(255, 255, 255, .1);
  margin-top: 2.5rem; padding-top: 1.5rem;
}
@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .footer-bottom { flex-direction: column; gap: .5rem; }
}

/* ---------- Prose (about page) --------- */
.prose p { margin: 0 0 1.2em; font-size: 1.05rem; line-height: 1.75; }

/* ====================================================================
   Content protection (deterrent layer).
   Active when <body class="cp-on"> is set from PHP, based on the
   `content_protection` site setting.
   ==================================================================== */

/* 1. Disable native text selection on chapter content. Form inputs,
      the admin panel, and the WYSIWYG editor still allow selection
      because cp-on is only applied to the public site's body, and
      these rules scope to chapters / static prose. */
.cp-on .chapter-body,
.cp-on .prose,
.cp-on .lede,
.cp-on .hero-text,
.cp-on .toc-list,
.cp-on .comments {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;   /* iOS long-press menu */
  -webkit-tap-highlight-color: transparent;
}

/* Form fields & the comment textarea must remain selectable */
.cp-on input,
.cp-on textarea,
.cp-on [contenteditable="true"] {
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* 2. Stop images from being draggable to the desktop / file manager */
.cp-on img { -webkit-user-drag: none; user-drag: none; pointer-events: none; }
/* …but keep tribute & chart figures hover-clickable for the lightbox-y feel */
.cp-on .card img, .cp-on .hero-cover img { pointer-events: auto; }

/* 3. Blank the page when someone hits Print / Save-as-PDF.
      This catches users who bypass the JS shortcut blocker via the
      browser's File menu. */
@media print {
  .cp-on body * { visibility: hidden !important; }
  .cp-on::before {
    content: "Printing of this content is disabled.\AVisit the site online to read.";
    white-space: pre;
    visibility: visible;
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    font: 600 1.2rem/1.6 'Manrope', sans-serif;
    color: #122844;
    text-align: center;
    padding: 2rem;
  }
}

/* 4. Subtle, repeating watermark across chapter content carrying the
      reader's IP and date. Each visit produces a slightly different
      pattern, making leaked screenshots traceable.
      The actual text content is set via the `data-watermark` attribute
      on .chapter-body from PHP, then drawn via ::before. */
.cp-on .chapter-body {
  position: relative;
}
.cp-on .chapter-body[data-watermark]::before {
  content: attr(data-watermark);
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  display: block;
  white-space: pre;
  font: 500 .85rem/2.5 'Manrope', sans-serif;
  color: rgba(18, 40, 68, 0.05);
  letter-spacing: .15em;
  text-transform: uppercase;
  background: repeating-linear-gradient(
    -25deg,
    transparent 0,
    transparent 7rem,
    rgba(18, 40, 68, 0.012) 7rem,
    rgba(18, 40, 68, 0.012) 14rem
  );
  overflow: hidden;
}
/* Make sure chapter content sits above the watermark */
.cp-on .chapter-body > * { position: relative; z-index: 2; }

/* ---------- Figures & images in chapters --------- */
.book-figure {
  margin: 2.5rem auto;
  text-align: center;
  /* Break out of the narrow column for visual breathing room */
  max-width: 100%;
  /* Belt-and-braces: if any descendant tries to be wider than the figure
     (e.g. an editor-pasted <img> with inline width="1200"), clip it instead
     of letting it push the whole page sideways on mobile. */
  overflow: hidden;
}
.book-figure img {
  display: block;
  margin: 0 auto;
  width: auto;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  background: var(--cream-warm);
}
.book-figure figcaption {
  margin-top: .85rem;
  font-family: var(--display);
  font-style: italic;
  font-size: .95rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 60ch;
  margin-left: auto;
  margin-right: auto;
}

/* ----------------------------------------------------------------------
   Mobile-overflow hard backstop for chapter images.

   The Personal Chapter (and any other chapter whose body is pasted from
   the WYSIWYG editor) can contain <img> tags with inline width / height
   attributes or inline `style="width: 1200px"` baked in. Inline styles
   beat class-level CSS on specificity, which is why the page was going
   out of bounds on phones even though .book-figure img already declared
   max-width: 100%.

   The two !important rules below are intentional: they're the only thing
   that reliably overrides inline sizing on user-generated chapter HTML.
   --------------------------------------------------------------------- */
.chapter-body img {
  max-width: 100% !important;
  height: auto !important;
}

/* Personal Chapter — cap tall portrait photos so they don't dominate the
   viewport on big screens. Re-states width: auto so the max-height +
   max-width combination doesn't trigger the iOS Safari quirk where an
   image renders at intrinsic pixel width. */
.chapter-body .book-figure img {
  width: auto;
  max-height: 80vh;
  object-fit: contain;
}

/* The model diagram: cap at 580px on wide screens, fill the column
   on mobile. */
.chapter-body .book-figure img[src*="abhay-model-diagram"] {
  width: 100%;
  max-width: 580px;
  max-height: none;
  height: auto;
}

/* Tables, code blocks, and any other wide block-level content inside a
   chapter must also stay inside the column on mobile. */
.chapter-body table,
.chapter-body pre,
.chapter-body iframe,
.chapter-body video {
  max-width: 100%;
}
.chapter-body pre { overflow-x: auto; }
/* Long unbreakable strings (URLs, hashes) — wrap instead of overflowing. */
.chapter-body { overflow-wrap: break-word; word-wrap: break-word; }

/* ---------- Chart grid (Exhibit VI) --------- */
/* Wide-body sections (Exhibit VI charts, Personal Chapter) get more room */
.chapter-body.wide-body { max-width: 60rem; }
.chapter-body.wide-body p { text-align: left; max-width: 44rem; margin-left: auto; margin-right: auto; }
.chapter-body.wide-body > p:first-of-type::first-letter { float: none; font-size: inherit; padding: 0; color: inherit; }
.chapter-body.wide-body > p:first-of-type::first-line { font-variant: normal; letter-spacing: normal; }
.chapter-body.wide-body h3 { text-align: center; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem 2.5rem;
  margin: 2.5rem 0 3rem;
}
.chart-card {
  margin: 0;
  text-align: center;
  background: var(--paper);
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
}
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.chart-card img {
  width: 100%;
  height: auto;
  background: var(--paper);
}
.chart-card figcaption {
  margin-top: .75rem;
  font-size: .85rem;
  color: var(--ink-soft);
  font-style: normal;
  font-family: var(--body);
  line-height: 1.4;
}
.chart-card figcaption strong {
  display: block;
  font-family: var(--display);
  font-size: 1.05rem;
  color: var(--navy);
  margin-bottom: .15rem;
  font-weight: 600;
}
.chart-card .muted { font-size: .8rem; }

@media (max-width: 720px) {
  .chart-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .chart-card { padding: 1rem .75rem; }
}

/* ---------- Data tables (e.g. BRPSE Performance Projections) --------- */
.data-table-wrap {
  margin: 2.5rem 0;
  max-width: 100%;
}
.table-caption {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--navy);
  text-align: center;
  margin-bottom: .85rem;
  letter-spacing: .01em;
}
.data-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--paper);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--body);
  font-size: .95rem;
}
.data-table thead {
  background: var(--navy);
  color: var(--cream);
}
.data-table thead th {
  padding: .75rem 1rem;
  text-align: center;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-right: 1px solid rgba(255, 255, 255, .12);
}
.data-table thead th:first-child { text-align: left; }
.data-table thead th:last-child { border-right: 0; }
.data-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--navy);
  font-family: var(--body);
  padding: .7rem 1rem;
  background: var(--cream-warm);
  border-right: 1px solid var(--rule);
}
.data-table tbody td {
  padding: .7rem 1rem;
  text-align: center;
  border-right: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.data-table tbody td:last-child,
.data-table tbody th:last-child { border-right: 0; }
.data-table tbody tr { border-top: 1px solid var(--rule); }
.data-table tbody td.neg { color: #c1554a; font-weight: 500; }

/* Variant: 2-column key/value table (no header row, first col is label) */
.data-table-2col tbody th {
  width: 35%;
  vertical-align: top;
}
.data-table-2col tbody td {
  text-align: left;
  vertical-align: top;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Variant: 3-column with letter column (SMARTER) */
.data-table-3col .col-letter { width: 90px; }
.data-table-3col .col-meaning { width: 180px; }
.data-table-3col tbody th.letter {
  text-align: center;
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--gold);
  background: var(--navy);
  width: 90px;
  letter-spacing: 0;
}
.data-table-3col tbody td.meaning {
  font-weight: 600;
  color: var(--navy);
  background: var(--cream-warm);
  text-align: left;
  font-size: 1rem;
}
.data-table-3col tbody td:last-child {
  text-align: left;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  font-size: .92rem;
  line-height: 1.55;
}

/* Variant: comparison table (two equal columns, no row labels) */
.compare-table tbody td {
  text-align: left;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  width: 50%;
  vertical-align: top;
}
.compare-table tbody tr td:first-child {
  background: var(--cream-warm);
  border-right: 1px solid var(--rule);
}

/* ---------- SWOT grid --------- */
.swot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.swot-cell {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  background: var(--paper);
  border-top: 4px solid;
  box-shadow: var(--shadow-sm);
}
.swot-cell h4 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 .75rem;
  letter-spacing: .03em;
  text-transform: none;
}
.swot-cell ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: .92rem;
  line-height: 1.55;
}
.swot-cell li { margin: .25rem 0; }
.swot-s { border-top-color: #2d8a3e; }
.swot-s h4 { color: #1e5a2a; }
.swot-w { border-top-color: #c1554a; }
.swot-w h4 { color: #8a261c; }
.swot-o { border-top-color: var(--gold); }
.swot-o h4 { color: #8a6118; }
.swot-t { border-top-color: var(--navy); }
.swot-t h4 { color: var(--navy-deep); }

@media (max-width: 600px) {
  .swot-grid { grid-template-columns: 1fr; }
  .data-table { font-size: .85rem; }
  .data-table thead th, .data-table tbody th, .data-table tbody td { padding: .5rem .6rem; }
}

/* =====================================================================
   Reader authentication — login / register / verify / resend pages
   ===================================================================== */

.auth-page { padding: 4rem 0 5rem; }

.auth-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 2.5rem 2.5rem 2rem;
  box-shadow: var(--shadow-md);
  max-width: 30rem;
  margin: 0 auto;
}
.auth-card h1 { margin: 0 0 .35rem; font-size: 2rem; }
.auth-card .lede { font-size: 1.05rem; margin: 0 0 1.75rem; }
.auth-card .lede a { font-weight: 600; }
.auth-form .form-row { margin-bottom: 1.1rem; }
.auth-form button[type="submit"] { width: 100%; padding: .8rem 1.25rem; font-size: 1rem; }

@media (max-width: 540px) {
  .auth-card { padding: 1.75rem 1.5rem 1.5rem; }
}

/* Header nav extras — divider, greeting, register CTA, sign-out ghost */
.nav-divider {
  width: 1px; height: 1.25rem; background: var(--rule); margin: 0 .25rem;
  display: inline-block;
}
.nav-greeting {
  font-size: .88rem; color: var(--muted); font-weight: 500;
  padding: .35rem 0;
}
.primary-nav a.nav-cta {
  background: var(--navy); color: var(--cream);
  padding: .4rem .85rem; border-radius: 2px;
  text-decoration: none;
}
.primary-nav a.nav-cta:hover { background: var(--navy-deep); color: var(--gold); }
.primary-nav a.nav-cta::after { display: none !important; }
.primary-nav a.nav-cta-ghost {
  font-size: .88rem; color: var(--muted);
}
@media (max-width: 760px) {
  .nav-divider { display: none; }
}

/* =====================================================================
   Locked sections — teaser + paywall card + locked-row in TOC
   ===================================================================== */

.toc-note {
  background: var(--cream-warm);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--gold);
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin: 1.5rem 0 2rem;
  font-size: .95rem;
}
.toc-note a { font-weight: 600; }
.toc-locked .lock-icon {
  margin-left: .5rem;
  font-size: .9rem;
  filter: grayscale(.4);
  opacity: .7;
}
.toc-locked a:hover .lock-icon { opacity: 1; filter: none; }

/* Chapter teaser styling — fade out the bottom of the visible content
   so the reader senses there's more behind the paywall. */
.chapter-body.is-locked {
  position: relative;
}
.chapter-body.is-locked > p:first-of-type {
  /* Soft fade on the teaser paragraph */
  mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 65%, transparent 100%);
  margin-bottom: 0;
}

/* The paywall card itself */
.paywall {
  margin: 2.5rem auto 1rem;
  max-width: 100%;
}
.paywall-inner {
  background: linear-gradient(180deg, var(--cream-warm) 0%, var(--paper) 100%);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.paywall-eyebrow {
  font-family: var(--body);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 .75rem;
}
.paywall-inner h2 {
  margin: 0 0 .65rem;
  font-size: 1.65rem;
}
.paywall-inner > p {
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 32rem;
  margin: 0 auto 1.5rem;
}
.paywall-actions {
  display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.paywall-foot { margin: 0; max-width: 30rem; margin-left: auto; margin-right: auto; }

@media (max-width: 540px) {
  .paywall-inner { padding: 1.5rem 1.25rem 1.25rem; }
  .paywall-inner h2 { font-size: 1.35rem; }
  .paywall-actions .btn { width: 100%; }
}
