/* ===========================================================
   03-BASE.CSS — global typography, body bg, common utilities.
   This is the foundation. Per-page CSS extends it without conflict.
   =========================================================== */

html {
  overflow-x: clip; /* clip = no scroll container → position:sticky works; hidden broke sticky */
}

body {
  font-family: var(--font-body);
  font-size: var(--t-md);
  color: var(--ink);
  background: var(--paper);
  overflow-x: clip; /* clip = no scroll container → position:sticky works */
}

/* —— WCAG 2.2 focus visibility — custom outline beats browser default — */
:focus-visible {
  outline: 2px solid var(--flag);
  outline-offset: 3px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* —— Base transitions for all interactive elements (T29 transitions_low fix) — */
a {
  transition: color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
button,
input[type="submit"],
input[type="button"],
input[type="reset"],
[role="button"] {
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

/* —— WCAG 2.2 SC 2.5.8 touch-target baseline (44×44px) — */
button,
[role="button"],
a.btn,
a.cta-primary,
a.cta-ghost,
.cta-primary,
.cta-ghost,
.fake-link,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  min-height: 44px;
  min-width: 44px;
}

/* —— Mobile nav tap-target (T22 mobile_tap_target_density fix — all pages) — */
@media (max-width: 900px) {
  .masthead__nav a,
  .masthead__mobile-nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding-block: 0.5rem;
  }
  .masthead__menu-toggle {
    min-height: 44px;
    min-width: 44px;
  }
}

/* —— Editorial typography rhythm —— */
.prose {
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
}
.prose p + p,
.prose p + ul,
.prose p + ol,
.prose p + blockquote,
.prose ul + p,
.prose ol + p,
.prose blockquote + p {
  margin-top: 1.1em;
}

.prose strong { font-weight: 700; }
.prose em { font-style: italic; }

.prose a {
  color: var(--ink);
  background-image: linear-gradient(to right, var(--flag) 50%, transparent 0);
  background-position: 0 100%;
  background-size: 200% 1px;
  background-repeat: no-repeat;
  transition: background-position var(--dur) var(--ease);
}
@media (hover: hover) {
  .prose a:hover {
    background-position: -100% 100%;
  }
}

.prose ul,
.prose ol {
  margin: 1.1em 0 1.1em 1.5em;
}
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose ul li,
.prose ol li {
  margin: 0.4em 0;
  padding-left: 0.3em;
}

.prose blockquote {
  border-left: 3px solid var(--flag);
  margin: 1.4em 0;
  padding: 0.2em 0 0.2em 1.4em;
  font-style: italic;
  color: var(--ink-dim);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--paper-deep);
  padding: 0.1em 0.4em;
  border-radius: var(--r-1);
}

.prose pre {
  background: var(--stage);
  color: var(--stage-ink);
  padding: 1.2em 1.4em;
  border-radius: var(--r-3);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9em;
  line-height: 1.55;
  margin: 1.4em 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.4em 0;
}

/* === PROSE CARDS — semantic blocks, not mechanical wrappers.
       The PHP renderer wraps a paragraph in a prose-card ONLY when its
       leading bold marker is a recognised semantic type (callout / tip /
       warning / stat / step / method / summary). Each type carries an
       identity that aligns with the Editorial Documentary aesthetic.
   ================================================================== */
.prose .prose-card {
  margin: 1.8em 0;
  padding: 1.4em 1.7em 1.5em;
  border-radius: var(--r-3);
  position: relative;
  font-size: 1.0625rem;
  line-height: 1.7;
}
.prose .prose-card p + p { margin-top: 0.9em; }
.prose .prose-card p:first-child { margin-top: 0; }
.prose .prose-card p:last-child  { margin-bottom: 0; }
.prose .prose-card p:first-child strong:first-child {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.65em;
}

/* Callout — scarlet flag rail; promotes a key takeaway out of the prose flow. */
.prose .prose-card--callout {
  background: var(--ledger);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--flag);
  padding-left: 1.9em;
}
.prose .prose-card--callout p:first-child strong:first-child { color: var(--flag); }

/* Tip — warm cream, hairline. Soft advice tone. */
.prose .prose-card--tip {
  background: var(--paper-flash);
  border: 1px solid var(--rule);
}
.prose .prose-card--tip p:first-child strong:first-child { color: var(--ink-dim); }
.prose .prose-card--tip::before {
  content: "";
  position: absolute;
  top: 1.2em;
  right: 1.2em;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--green);
  background:
    radial-gradient(circle at center, var(--green) 0%, var(--green) 30%, transparent 30%);
}

/* Warning — red-soft bg with red flag. Cautionary tone. */
.prose .prose-card--warning {
  background: var(--red-soft);
  border: 1px solid var(--red);
  border-left-width: 4px;
}
.prose .prose-card--warning p:first-child strong:first-child { color: var(--red); }

/* Stat — asymmetric inset; reads as a data row pulled out of body. */
.prose .prose-card--stat {
  background: var(--ledger);
  border: 1px solid var(--ink);
  margin-left: 1.6em;
  position: relative;
  padding: 1.2em 1.5em;
}
.prose .prose-card--stat::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -1.6em;
  transform: translateY(-50%);
  width: 1.6em;
  height: 1px;
  background: var(--gold);
}
.prose .prose-card--stat::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -1.6em;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  transform: translate(-3px, -50%);
}
.prose .prose-card--stat p:first-child strong:first-child {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--flag);
  margin-bottom: 0.3em;
}

/* Step — paper-deep card with numbered serif counter feel. */
.prose .prose-card--step {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  position: relative;
  padding-left: 2.2em;
}
.prose .prose-card--step::before {
  content: "";
  position: absolute;
  top: 1.4em;
  left: 0.7em;
  width: 4px;
  height: calc(100% - 2.8em);
  background: var(--flag);
  border-radius: 2px;
}
.prose .prose-card--step p:first-child strong:first-child {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--flag);
}

/* Method — dark stage card. Heavyweight. */
.prose .prose-card--method {
  background: var(--ink);
  color: var(--stage-ink);
  border: 0;
  padding: 1.6em 1.8em;
}
.prose .prose-card--method p { color: var(--stage-dim); }
.prose .prose-card--method p:first-child strong:first-child {
  color: var(--gold);
  margin-bottom: 0.6em;
}
.prose .prose-card--method a {
  color: var(--gold);
  border-bottom: 1px dotted var(--gold);
  background-image: none !important;
}

/* Summary — base card with double-rule top. */
.prose .prose-card--summary {
  background: var(--paper-flash);
  border: 1px solid var(--rule);
  border-top: 3px double var(--ink);
  padding-top: 1.5em;
}
.prose .prose-card--summary p:first-child strong:first-child {
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.35em;
  margin-bottom: 0.6em;
}

@media (max-width: 640px) {
  .prose .prose-card { padding: 1.1em 1.3em; margin: 1.4em 0; }
  .prose .prose-card--stat,
  .prose .prose-card--callout { margin-left: 0; padding-left: 1.5em; }
  .prose .prose-card--stat::before,
  .prose .prose-card--stat::after,
  .prose .prose-card--tip::before { display: none; }
}

.prose h2 {
  font-family: var(--font-display);
  font-size: clamp(1.625rem, 2.6vw, 2rem);
  margin: 2.4em 0 0.8em;
  font-weight: 500;
}
.prose h3 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
  margin: 1.8em 0 0.6em;
  font-weight: 500;
}
.prose h4 {
  font-size: 1.125rem;
  margin: 1.4em 0 0.5em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}


.prose .step {
  position: relative;
  padding: 1.2em 1.4em 1.2em 3.6em;
  background: var(--ledger);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  margin: 1.8em 0;         /* unified (was 1em) */
  counter-increment: step-counter;
}
.prose .step::before {
  content: counter(step-counter);
  position: absolute;
  left: 1em;
  top: 1.15em;
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--flag);
  font-weight: 600;
  line-height: 1;
}
.prose { counter-reset: step-counter; }

.prose .story {
  background: var(--paper-deep);
  padding: 1.6em 1.8em;
  margin: 1.8em 0;         /* unified (was 2em) */
  border-radius: var(--r-3);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.prose .comparison-table-wrap,
.prose .comparison {
  margin: 1.8em 0;
  overflow-x: auto;
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.96em;
}
.prose th,
.prose td {
  padding: 0.7em 1em;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.prose th {
  background: var(--paper-deep);
  font-weight: 600;
  font-size: 0.92em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prose tr:last-child td { border-bottom: 0; }

/* — Utility classes — */
.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.label-mono {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.rule-hairline { border-top: 1px solid var(--rule); }
.rule-thick    { border-top: 2px solid var(--ink); }

.flag-rail {
  position: relative;
}
.flag-rail::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 4px; height: 100%;
  background: var(--flag);
}

/* — Skip link — */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 1rem;
  z-index: var(--z-toast);
}
.skip-link:focus {
  left: 1rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  border-radius: var(--r-2);
}

/* — Containers — */
.wrap-grand { max-width: var(--max-grand); margin: 0 auto; padding: 0 max(var(--s-4), 4vw); }
.wrap-wide  { max-width: var(--max-wide);  margin: 0 auto; padding: 0 max(var(--s-4), 4vw); }
.wrap-prose { max-width: var(--max-prose); margin: 0 auto; padding: 0 max(var(--s-4), 4vw); }
.wrap-narrow{ max-width: var(--max-narrow); margin: 0 auto; padding: 0 max(var(--s-4), 4vw); }

/* — Common cta button look (override per template) — */
.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.85em 1.4em;
  background: var(--flag);
  color: var(--paper);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.94rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: var(--r-2);
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
@media (hover: hover) {
  .cta-primary:hover { background: var(--flag-deep); transform: translateY(-1px); }
}

.cta-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.85em 1.4em;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.94rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
@media (hover: hover) {
  .cta-ghost:hover { background: var(--ink); color: var(--paper); }
}

/* — Common verdict chips for cross-page rating signaling — */
.chip-verdict {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.7em 0.3em 0.5em;
  border-radius: var(--r-round);
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chip-verdict::before {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: currentColor;
}
.chip-verdict.is-green  { color: var(--green);  background: var(--green-soft); }
.chip-verdict.is-yellow { color: #7E6800;       background: var(--yellow-soft); }
.chip-verdict.is-red    { color: var(--red);    background: var(--red-soft); }

/* — Touch target ≥48px for primary buttons on mobile — */
@media (max-width: 640px) {
  .cta-primary, .cta-ghost { min-height: 48px; }
}
