/* ─────────────────────────────────────────────────────────
   Niranta — A4 article reading view
   A single sheet of paper centered on a warm "desk" background,
   with a sticky table-of-contents rail to the left on desktop.
   Designed to feel printed, edited, deliberate.
   ───────────────────────────────────────────────────────── */

/* ── DESK ──────────────────────────────────────────────── */
.page-desk {
  background:
    radial-gradient(1400px 700px at 50% -10%, rgba(255,255,255,0.55), transparent 60%),
    linear-gradient(180deg, #EFEDE5 0%, #E5E1D5 100%);
  padding: 28px 32px 80px;
  min-height: calc(100vh - 76px);
}

/* The folded "tab" above the sheet (back link).
   Default: aligned to the left edge of a centered A4 sheet (used by
   quote and other static pages with no rail).
   `.page-tab-rail` modifier offsets to clear the article rail. */
.page-tab {
  max-width: var(--a4-w);
  margin: 0 auto 14px;
  padding-left: 4px;
  text-align: left;
}
.page-tab.page-tab-rail {
  max-width: calc(var(--rail-w) + var(--s-6) + var(--a4-w));
  padding-left: calc(var(--rail-w) + var(--s-6));
}
.page-tab .back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-size: var(--t-eyebrow);
  font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); text-decoration: none;
  background: rgba(255,255,255,0.65);
  padding: 7px 14px; border-radius: 2px 2px 0 0;
  border: 1px solid rgba(0,0,0,0.06); border-bottom: none;
  transition: color .18s, background .18s, transform .18s;
}
.page-tab .back-link:hover {
  color: var(--brand); background: white; transform: translateY(-1px);
}

/* ── PAGE GRID (rail + sheet) ──────────────────────────── */
.page-grid {
  max-width: calc(var(--rail-w) + var(--s-6) + var(--a4-w));
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--rail-w) var(--a4-w);
  gap: var(--s-6);
  align-items: start;
}
/* When the article has no TOC, the rail isn't rendered. Collapse to a
   single A4-width centered column so the sheet fills the available space
   instead of being trapped in the now-empty rail slot. */
.page-grid.page-grid-solo {
  max-width: var(--a4-w);
  grid-template-columns: 1fr;
}
/* Ensure the inline TOC fallback still appears when a no-rail layout
   is used on a wide viewport (currently identical to .a4-toc-inline). */
.page-grid-solo .a4-toc-inline { display: block; }

/* ── LEFT RAIL: TOC + meta (sticky on desktop) ────────── */
.page-rail {
  position: sticky;
  top: 96px;            /* clears the sticky site-header */
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.18) transparent;
}
.page-rail::-webkit-scrollbar { width: 6px; }
.page-rail::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.18); border-radius: 3px;
}

.page-rail-inner {
  padding: 4px 8px 20px 0;
}
.page-rail-label {
  display: block;
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
}

/* TOC list shared by left-rail and inline-fallback */
.ed-toc {
  list-style: none;
  margin: 0; padding: 0;
  font-family: var(--font-display);
}
.ed-toc li {
  counter-increment: toc-item;
  position: relative;
  padding: 6px 0 6px 30px;
  font-size: var(--t-meta); line-height: 1.4;
  border-left: 2px solid transparent;
}
.ed-toc li::before {
  content: counter(toc-item, decimal-leading-zero);
  position: absolute; left: 8px; top: 8px;
  font-family: var(--font-display); font-size: 9px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ed-toc li a {
  color: var(--ink-2); text-decoration: none;
  display: block; transition: color .18s;
}
.ed-toc li:hover { border-left-color: var(--brand-soft); }
.ed-toc li:hover a { color: var(--ink); }
.ed-toc li a.active,
.ed-toc li.active a {
  color: var(--brand); font-weight: 600;
}
.ed-toc li:has(a.active) { border-left-color: var(--brand); }

.page-rail-toc {
  counter-reset: toc-item;
}

.page-rail-divider {
  height: 1px; background: rgba(0,0,0,0.08); margin: 22px 8px;
}
.page-rail-meta {
  padding-left: 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.page-rail-meta > div {
  font-family: var(--font-display); font-size: var(--t-eyebrow);
  color: var(--ink-3); line-height: 1.4;
}
.page-rail-meta strong {
  display: block;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: #aaa;
  margin-bottom: 2px;
}

/* Static page variant (about, philosophical, health, etc.).
   These pages render outside the article .page-grid, so the sheet has to
   constrain its own width and center itself on the desk. */
.a4-sheet.a4-sheet-page {
  width: 100%;
  max-width: var(--a4-w);   /* 794px — A4 width at 96dpi */
  margin: var(--s-4) auto 0;
  min-height: 0;
}

/* ── A4 SHEET ──────────────────────────────────────────── */
.a4-sheet {
  /* A4 width 210mm == 794px at 96dpi. Height grows with content. */
  width: 100%;
  background: #FFFFFF;
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 2px;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.02),
    0 4px 14px rgba(0,0,0,0.06),
    0 24px 56px rgba(0,0,0,0.07);
  padding: 80px 84px 96px;
  /* faint page edge — like a sheet of paper */
  background-image:
    linear-gradient(90deg, rgba(0,0,0,0.015), rgba(0,0,0,0) 6px, rgba(0,0,0,0) calc(100% - 6px), rgba(0,0,0,0.015));
}

/* ── ARTICLE HEADER (inside the sheet) ─────────────────── */
.a4-head {
  /* No rule below the masthead — separation comes from generous whitespace. */
  padding-bottom: 0;
  margin-bottom: var(--s-10);
}
.ed-eyebrow {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 22px;
}
.ed-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 500; line-height: 1.10;
  letter-spacing: -0.022em;
  color: var(--ink);
  margin-bottom: 20px;
}
.ed-title em { font-style: italic; color: var(--brand); }
.ed-subtitle {
  font-family: var(--font-display); font-style: italic;
  font-size: var(--t-h3); line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 26px;
  max-width: 560px;
}
.ed-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-family: var(--font-display); font-size: var(--t-eyebrow);
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-3);
}
.ed-meta .sep {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--ink-3);
}

/* ── INLINE TOC (only shows when left rail is hidden) ──── */
.a4-toc-inline { display: none; }
.a4-toc-inline {
  background: var(--surface-2);
  border-left: 3px solid var(--brand);
  padding: 18px 22px 20px;
  margin: 0 0 36px;
  border-radius: 2px;
  counter-reset: toc-item;
}
.a4-toc-label {
  display: block;
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.a4-toc-list {
  columns: 2; column-gap: 32px;
  font-family: var(--font-display);
}
.a4-toc-list li {
  break-inside: avoid;
  padding: 4px 0 4px 30px;
  font-size: 13px; line-height: 1.4;
  border-left: none;
}
.a4-toc-list li::before { top: 6px; }

/* ── BODY PROSE ────────────────────────────────────────── */
.ed-body-text {
  font-family: var(--font-body);
  font-size: var(--t-body); line-height: 1.78;
  color: var(--ink);
  letter-spacing: 0.001em;
}
.ed-body-text p {
  margin-bottom: 1.1em;     /* normal paragraph rhythm — proportional to body size */
  hyphens: auto;
}

/* Markdown horizontal rules render as invisible spacing — no horizontal
   lines in the blog body. The break still creates a thematic gap, but
   visually we use whitespace, not a rule. */
.ed-body-text hr {
  border: none;
  height: 0;
  margin: var(--s-8) 0;
  background: transparent;
}
/* First-letter accent — inline, no float, no size change.
   Subtle editorial signature: just an amber tint and slightly heavier weight
   on the opening letter of the article. Cannot create wrap or empty-line
   artifacts because it stays inside the line box. */
.ed-body-text > p:first-of-type::first-letter {
  color: var(--brand);
  font-weight: 600;
}
.ed-body-text strong { font-weight: 600; color: var(--ink); }
.ed-body-text em { font-style: italic; }
.ed-body-text a {
  color: var(--ink); text-decoration: none;
  background-image: linear-gradient(transparent 62%, rgba(232,146,43,0.22) 62%);
  transition: background-image .18s;
}
.ed-body-text a:hover {
  background-image: linear-gradient(transparent 62%, rgba(232,146,43,0.45) 62%);
  color: var(--brand-deep);
}

/* Subheadings always lowercase — editorial signature.
   Applies to article body h2/h3, section heads, and quote body subheads.
   Article TITLES (h1, .ed-title) keep their source casing. */
.ed-body-text h2,
.ed-body-text h3,
.ed-section-title,
.quote-body h2,
.quote-body h3 {
  text-transform: lowercase;
}

/* Section heads — the editorial backbone.
   No horizontal rule, no massive gap. The number is the dominant visual
   element; the subheading reads at a body-adjacent size beside it.
   Magazine-style: 02 (large amber) — the title (small, lowercase). */
.ed-body-text h2 {
  font-family: var(--font-display);
  font-size: var(--t-h2); font-weight: 500;
  line-height: 1.22;
  color: var(--ink);
  margin: var(--s-8) 0 var(--s-3);     /* 32px above, 12px below */
  letter-spacing: -0.012em;
}
.ed-section-head {
  display: flex; align-items: baseline; gap: var(--s-4);
  margin: var(--s-8) 0 var(--s-3);     /* matches the standalone h2 rhythm */
}
.ed-section-head > * { margin: 0; }    /* the inner h2 inherits parent spacing only */

.ed-section-num {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 48px;                      /* larger than the title */
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-transform: none;                 /* numerals don't lowercase */
}
.ed-section-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 500;    /* smaller than the number */
  line-height: 1.3;
  letter-spacing: -0.008em;
  color: var(--ink);
  flex: 1 1 auto;
}
.ed-body-text h3 {
  font-family: var(--font-display); font-size: var(--t-h3); font-weight: 600;
  line-height: 1.32; color: var(--ink);
  margin: 36px 0 14px;
  letter-spacing: -0.005em;
}
.ed-body-text h4 {
  font-family: var(--font-display); font-size: var(--t-eyebrow); font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 28px 0 12px;
}

.ed-body-text ul, .ed-body-text ol { margin: 22px 0 22px 24px; }
.ed-body-text ul { list-style: disc; }
.ed-body-text ol { list-style: decimal; }
.ed-body-text li { margin-bottom: 8px; }

.ed-body-text blockquote {
  border-left: 3px solid var(--brand);
  background: linear-gradient(135deg, var(--surface-2), white);
  padding: 18px 26px;
  margin: 30px 0;
  font-style: italic;
  color: var(--ink-2);
  font-size: var(--t-body); line-height: 1.6;
  border-radius: 0 2px 2px 0;
}
.ed-body-text blockquote p:last-child { margin-bottom: 0; }

/* Inline + block code */
.ed-body-text code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  font-size: 0.86em;
  background: var(--surface-code);
  padding: 2px 6px; border-radius: 3px;
  word-break: break-word;
}
.ed-body-text pre,
.ed-body-text .code-block {
  background: var(--surface-code);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 18px 22px;
  margin: 26px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  tab-size: 2;
}
.ed-body-text pre code,
.ed-body-text .code-block pre {
  background: transparent; padding: 0; border: none;
  font-size: 13px;
  color: #1f1f1f;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: block;
}
.code-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}

/* Generic callout (.callout) */
.callout {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--brand);
  background: var(--surface-2);
  padding: 20px 24px; margin: 26px 0;
  border-radius: 2px;
}
.callout > .callout-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px; display: block;
}
.callout p:last-child { margin-bottom: 0; }

.pull-quote {
  font-family: var(--font-display); font-style: italic;
  font-size: 24px; line-height: 1.4;
  color: var(--ink);
  border-left: 3px solid var(--brand);
  padding: 8px 0 8px 26px;
  margin: 32px 0;
}

/* ── EDITORIAL COMPONENTS ──────────────────────────────── */

/* .gate-block — used in the 5-Gate Rule article and similar.
   The number column is 116px so "Gate 1" fits on a single line at 28px.
   The number is top-aligned with the command name, not vertically centered. */
.gate-block {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 4px var(--s-6);
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  background: white;
  padding: var(--s-6) var(--s-7, 28px);
  margin: var(--s-6) 0;
  position: relative;
}
.gate-block::before {
  content: '';
  position: absolute;
  left: calc(116px + var(--s-7, 28px));
  top: var(--s-6);
  bottom: var(--s-6);
  width: 1px;
  background: var(--rule);
}
.gate-number {
  grid-column: 1; grid-row: 1 / span 3;
  align-self: start;            /* top-align with the command name */
  padding-top: 2px;             /* visually center cap-height with mono baseline */
  font-family: var(--font-display);
  font-size: 28px;              /* fits "Gate 1" on one line in 116px */
  font-weight: 500;
  color: var(--brand);
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.gate-name {
  grid-column: 2; grid-row: 1;
  font-family: 'SFMono-Regular', 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 13.5px; font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
  padding-left: var(--s-2);
}
.gate-question {
  grid-column: 2; grid-row: 2;
  font-family: var(--font-display); font-style: italic;
  font-size: var(--t-body); color: var(--ink-2);
  margin-bottom: var(--s-3);
  padding-left: var(--s-2);
}
.gate-block > p,
.gate-block > .gate-body {
  grid-column: 2; grid-row: 3;
  margin-bottom: 0;
  padding-left: var(--s-2);
  font-size: var(--t-tight); line-height: 1.7;
  color: var(--ink);
}

/* .issue-block — flagged problem callouts (severity-style) */
.issue-block {
  border-left: 3px solid #C44;
  background: linear-gradient(90deg, #FDF7F6, white);
  padding: 18px 22px;
  margin: 22px 0;
  border-radius: 0 2px 2px 0;
  border-top: 1px solid rgba(196,68,68,0.12);
  border-right: 1px solid rgba(196,68,68,0.08);
  border-bottom: 1px solid rgba(196,68,68,0.12);
}
.issue-id {
  font-family: var(--font-display);
  font-size: var(--t-eyebrow); font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: #B03A2E;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.issue-id::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: #C44; flex-shrink: 0;
}
.issue-block p { margin-bottom: 14px; font-size: var(--t-tight); line-height: 1.65; }
.issue-block p:last-child { margin-bottom: 0; }
.issue-block .code-block {
  background: white;
  border-color: rgba(196,68,68,0.15);
}

/* ── ARTICLE FOOTER ────────────────────────────────────── */
.a4-foot {
  margin-top: var(--s-12);
  padding-top: 0;
}
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.article-tag {
  font-family: var(--font-display); font-size: var(--t-eyebrow); font-weight: 500;
  color: var(--brand); text-decoration: none;
  padding: 4px 10px; background: var(--brand-soft);
  border-radius: 3px; letter-spacing: 0.04em;
}
.share-strip {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap; padding-bottom: 18px;
}
.share-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
}
.share-btn {
  font-family: var(--font-display); font-size: var(--t-h4); font-weight: 500;
  color: var(--brand); text-decoration: none;
  letter-spacing: 0.02em;
}
.share-btn:hover { text-decoration: underline; }
.a4-byline {
  margin-top: 14px;
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display); font-style: italic;
  font-size: 14px; color: var(--ink-3);
}
.a4-byline .sep {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--ink-3);
}

/* ── RELATED POSTS (below sheet, on the desk) ─────────── */
.a4-related {
  max-width: calc(220px + 24px + 794px);
  margin: 64px auto 0;
  padding-left: 244px;   /* aligns under the sheet */
}
.a4-related-label {
  display: block;
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.20em; text-transform: uppercase;
  color: #6a6a60;
  margin-bottom: 16px;
}
.a4-related-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.a4-related-card {
  display: block; padding: 20px 22px;
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 2px;
  text-decoration: none; color: inherit;
  transition: transform .18s, box-shadow .18s;
}
.a4-related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.07);
}
.a4-related-cat {
  font-family: var(--font-display); font-size: 9px; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 6px;
}
.a4-related-title {
  font-family: var(--font-display); font-size: 15px;
  font-weight: 500; line-height: 1.36;
  color: var(--ink);
}

/* ── RESPONSIVE ────────────────────────────────────────────
   1080px: rail too narrow next to A4 — collapse, show inline TOC.
   880px:  smaller phones — drop the desk frame.
   460px:  fine-tune at very narrow widths.
   ─ */
@media (max-width: 1100px) {
  .page-grid {
    grid-template-columns: 1fr;
    max-width: 794px;
  }
  .page-rail { display: none; }
  .a4-toc-inline { display: block; }
  .page-tab.page-tab-rail {
    /* Article tab loses its rail offset when the rail itself is hidden. */
    padding-left: 4px;
    max-width: var(--a4-w);
  }
  .a4-related { padding-left: 0; max-width: 794px; }
}

@media (max-width: 880px) {
  .page-desk {
    padding: 22px 14px 56px;
    background:
      linear-gradient(180deg, #F0EDE5 0%, #E9E5D8 100%);
  }
  .a4-sheet {
    padding: 44px 28px 56px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  }
  .a4-toc-list { columns: 1; }
  .a4-related-grid { grid-template-columns: 1fr; }
  .ed-title { font-size: clamp(24px, 6vw, 32px); }
  .ed-subtitle { font-size: var(--t-tight); }
  .ed-body-text { font-size: 16.5px; }
  /* First-letter accent stays inline at all viewports — no responsive
     adjustments needed since it lives inside a line box. */
  .ed-body-text h2 { font-size: 22px; margin: var(--s-6) 0 var(--s-2); }
  .ed-section-head { margin: var(--s-6) 0 var(--s-2); gap: var(--s-3); }
  .ed-section-num { font-size: 36px; }
  .ed-section-title { font-size: 18px; }
  .ed-body-text h3 { font-size: var(--t-body); }
  .gate-block {
    grid-template-columns: 1fr;
    padding: 18px 20px;
  }
  .gate-block::before { display: none; }
  .gate-number {
    grid-column: 1; grid-row: auto;
    font-size: 28px; margin-bottom: 4px;
  }
  .gate-name, .gate-question, .gate-block > p {
    grid-column: 1; grid-row: auto; padding-left: 0;
  }
  .issue-block { padding: 14px 18px; }
}

@media (max-width: 460px) {
  .page-desk { padding: 14px 8px 40px; }
  .a4-sheet { padding: 28px 18px 40px; }
  .ed-meta { font-size: 10px; gap: 8px; }
  .ed-body-text { font-size: var(--t-tight); line-height: 1.72; }
}
