/* design-system/stitch.css — Editorial Intelligence
 *
 * Implements the Stitch design system per design-system/Stitch Design/DESIGN.md.
 * Premium printed industry-report aesthetic: minimalist corporate, Trusted
 * Advisor voice, sharp 0px corners, tonal layering, no shadows.
 *
 * All colour, type, and spacing values consume tokens from tokens.css plus
 * the stitch.* extensions registered there. No raw hex in this file.
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Serif:wght@400;600;700&display=swap");

:root {
  /* Stitch palette — anchored on Deep Navy + Rich Teal + Muted Gold accent. */
  --stitch-primary: #051C2C;
  --stitch-secondary: #156874;
  --stitch-accent-gold: #a17f3b;
  --stitch-surface: #f8fafb;
  --stitch-surface-container-lowest: #ffffff;
  --stitch-surface-container-low: #f2f4f5;
  --stitch-surface-container: #eceeef;
  --stitch-surface-container-high: #e6e8e9;
  --stitch-on-surface: #191c1d;
  --stitch-on-surface-variant: #43474c;
  --stitch-outline: #73777d;
  --stitch-outline-variant: #c3c7cc;
  --stitch-inverse-surface: #2e3132;
  --stitch-inverse-on-surface: #eff1f2;

  /* Spacing system. */
  --stitch-container-max: 1280px;
  --stitch-reading-width: 720px;
  --stitch-section-y: 80px;
  --stitch-gutter: 32px;
  --stitch-edge: 40px;

  /* Typography stack. */
  --stitch-serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --stitch-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ─── Reset (scoped, light) ───────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body.stitch {
  margin: 0;
  font-family: var(--stitch-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--stitch-on-surface);
  background: var(--stitch-surface-container-lowest);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--stitch-secondary);
}

/* ─── Top navigation bar ──────────────────────────────────────────────── */

.stitch-topnav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 50;
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--stitch-gutter);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--stitch-outline-variant);
}

.stitch-topnav__brand {
  font-family: var(--stitch-sans);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--stitch-primary);
}

.stitch-topnav__links {
  display: flex;
  align-items: center;
  gap: 32px;
  font-family: var(--stitch-serif);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.stitch-topnav__link {
  color: var(--stitch-on-surface-variant);
  transition: color 200ms ease;
  position: relative;
  padding: 4px 0;
}

.stitch-topnav__link:hover,
.stitch-topnav__link.is-active {
  color: var(--stitch-primary);
}

.stitch-topnav__link.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--stitch-accent-gold);
}

.stitch-topnav__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--stitch-primary);
  color: #ffffff;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  border: none;
  cursor: pointer;
  transition: background 200ms ease;
}

.stitch-topnav__cta:hover {
  background: var(--stitch-secondary);
  color: #ffffff;
}

@media (max-width: 880px) {
  .stitch-topnav__links {
    display: none;
  }
}

/* ─── Page hero (80vh) ────────────────────────────────────────────────── */

.stitch-hero {
  position: relative;
  width: 100%;
  height: 80vh;
  min-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: 64px;
}

.stitch-hero__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.stitch-hero__overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 28, 44, 0.55);
  mix-blend-mode: multiply;
}

.stitch-hero__inner {
  position: relative;
  z-index: 1;
  max-width: 920px;
  padding: 0 var(--stitch-edge);
  text-align: center;
  color: #ffffff;
}

.stitch-hero__eyebrow {
  font-family: var(--stitch-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 0 16px;
}

.stitch-hero__title {
  font-family: var(--stitch-serif);
  font-size: clamp(40px, 6.5vw, 72px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.25);
}

.stitch-hero__subtitle {
  font-family: var(--stitch-sans);
  font-size: clamp(18px, 1.5vw, 22px);
  font-weight: 400;
  line-height: 1.5;
  margin: 0 0 32px;
  color: rgba(255, 255, 255, 0.92);
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.stitch-hero__cta {
  display: inline-block;
  font-family: var(--stitch-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 14px 32px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #ffffff;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.stitch-hero__cta:hover {
  background: #ffffff;
  color: var(--stitch-primary);
  border-color: #ffffff;
}

/* ─── Sections ────────────────────────────────────────────────────────── */

.stitch-section {
  padding: var(--stitch-section-y) var(--stitch-edge);
  background: var(--stitch-surface-container-lowest);
}

.stitch-section--alt {
  background: var(--stitch-surface-container-low);
}

.stitch-section--inverse {
  background: var(--stitch-primary);
  color: #ffffff;
  border-top: 1px solid var(--stitch-outline-variant);
}

.stitch-section__inner {
  max-width: var(--stitch-reading-width);
  margin: 0 auto;
}

.stitch-section__eyebrow {
  font-family: var(--stitch-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stitch-secondary);
  margin: 0 0 16px;
}

.stitch-section--inverse .stitch-section__eyebrow {
  color: var(--stitch-accent-gold);
}

.stitch-section__title {
  font-family: var(--stitch-serif);
  font-size: 40px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 32px;
  color: var(--stitch-primary);
}

.stitch-section--inverse .stitch-section__title {
  color: #ffffff;
}

.stitch-section__inner p {
  font-family: var(--stitch-sans);
  font-size: 18px;
  line-height: 1.7;
  color: var(--stitch-on-surface-variant);
  margin: 0 0 24px;
}

.stitch-section--inverse .stitch-section__inner p {
  color: rgba(255, 255, 255, 0.85);
}

.stitch-section__inner h3 {
  font-family: var(--stitch-serif);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--stitch-primary);
  margin: 40px 0 16px;
}

.stitch-section--inverse .stitch-section__inner h3 {
  color: #ffffff;
}

.stitch-section__inner ul,
.stitch-section__inner ol {
  font-family: var(--stitch-sans);
  font-size: 18px;
  line-height: 1.7;
  color: var(--stitch-on-surface-variant);
  padding-left: 24px;
  margin: 0 0 24px;
}

.stitch-section--inverse .stitch-section__inner ul,
.stitch-section--inverse .stitch-section__inner ol {
  color: rgba(255, 255, 255, 0.85);
}

.stitch-section__inner ul li,
.stitch-section__inner ol li {
  margin-bottom: 8px;
}

.stitch-section__inner strong {
  color: var(--stitch-primary);
  font-weight: 600;
}

.stitch-section--inverse .stitch-section__inner strong {
  color: #ffffff;
}

.stitch-section__inner blockquote {
  font-family: var(--stitch-serif);
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.4;
  color: var(--stitch-primary);
  margin: 40px 0;
  padding-left: 24px;
  border-left: 3px solid var(--stitch-accent-gold);
}

.stitch-section--inverse .stitch-section__inner blockquote {
  color: #ffffff;
  border-left-color: var(--stitch-accent-gold);
}

.stitch-section__inner blockquote p {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  line-height: inherit;
  margin: 0;
}

/* ─── Inset card (used inside sections, e.g. Three-Tier, Recommendations) ── */

.stitch-card {
  background: var(--stitch-surface-container-lowest);
  border: 1px solid var(--stitch-outline-variant);
  padding: 40px;
  margin: 40px 0 0;
}

.stitch-section--inverse .stitch-card {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.stitch-card h3 {
  margin-top: 0;
}

.stitch-card .stitch-button {
  margin-top: 24px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */

.stitch-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--stitch-sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 14px 32px;
  border: 1px solid var(--stitch-primary);
  background: var(--stitch-primary);
  color: #ffffff;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}

.stitch-button:hover {
  background: var(--stitch-secondary);
  border-color: var(--stitch-secondary);
  color: #ffffff;
}

.stitch-button--ghost {
  background: transparent;
  color: var(--stitch-primary);
}

.stitch-button--ghost:hover {
  background: var(--stitch-primary);
  color: #ffffff;
}

.stitch-section--inverse .stitch-button {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--stitch-primary);
}

.stitch-section--inverse .stitch-button:hover {
  background: var(--stitch-surface-container-low);
  color: var(--stitch-primary);
}

/* ─── Parallax full-bleed transition image ────────────────────────────── */

.parallax-transition {
  position: relative;
  width: 100%;
  height: 60vh;
  min-height: 360px;
  overflow: hidden;
  background-color: var(--stitch-primary);
}

.parallax-transition__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  /* Parallax: image translates at half scroll-speed via background-attachment.
     For <img> we use a CSS scroll-driven transform when supported. */
  will-change: transform;
}

@supports (animation-timeline: scroll()) {
  .parallax-transition__image {
    animation: parallax-translate linear;
    animation-timeline: view();
    animation-range: cover 0% cover 100%;
  }
  @keyframes parallax-translate {
    from { transform: translateY(-12%); }
    to   { transform: translateY( 12%); }
  }
}

.parallax-transition__overlay {
  position: absolute;
  inset: 0;
  /* Round 2 finding 4: lighter image overlay; the stat card carries
     the contrast load via its own translucent panel. */
  background: rgba(5, 28, 44, 0.22);
  z-index: 1;
}

.parallax-transition__content {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--stitch-edge);
  z-index: 2;
  pointer-events: none;
}

/* Stat card alignment — alternates left/right to read as cadence,
   not as a centred slideshow of quotes. */
.parallax-transition--right .parallax-transition__content {
  justify-content: flex-end;
}
.parallax-transition--left .parallax-transition__content {
  justify-content: flex-start;
}

.parallax-stat-card {
  pointer-events: auto;
  max-width: 520px;
  padding: 28px 32px;
  background: rgba(5, 28, 44, 0.58);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #ffffff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.parallax-stat-card__eyebrow {
  margin: 0 0 10px;
  font-family: var(--stitch-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.parallax-stat-card__value {
  margin: 0 0 14px;
  font-family: var(--stitch-serif);
  font-size: clamp(36px, 4.5vw, 56px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #ffffff;
  /* Numbers must not be italicised per Round 2 finding 4. */
  font-style: normal;
}

.parallax-stat-card__label {
  margin: 0 0 16px;
  font-family: var(--stitch-sans);
  font-size: 16px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
}

.parallax-stat-card__chip {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 10px;
  font-family: var(--stitch-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.parallax-stat-card__caveat {
  margin: 0;
  font-family: var(--stitch-sans);
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.78);
}

/* Mobile: card becomes a full-width bottom sheet so it doesn't compete
   with the image for the visual centre. */
@media (max-width: 720px) {
  .parallax-transition__content {
    align-items: flex-end;
    padding: 0;
  }
  .parallax-transition--left .parallax-transition__content,
  .parallax-transition--right .parallax-transition__content {
    justify-content: stretch;
  }
  .parallax-stat-card {
    max-width: none;
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}

/* Respect prefers-reduced-motion: disable the scroll-driven image
   transform so users with vestibular sensitivities aren't pushed into
   parallax animation. */
@media (prefers-reduced-motion: reduce) {
  .parallax-transition__image {
    animation: none !important;
    transform: none !important;
  }
}

/* ─── Footer ──────────────────────────────────────────────────────────── */

.stitch-footer {
  border-top: 1px solid var(--stitch-outline-variant);
  background: var(--stitch-surface-container-lowest);
  padding: 48px var(--stitch-edge);
}

.stitch-footer__inner {
  max-width: var(--stitch-container-max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.stitch-footer__legal {
  font-family: var(--stitch-sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--stitch-primary);
}

.stitch-footer__links {
  display: flex;
  gap: 24px;
  font-family: var(--stitch-sans);
  font-size: 13px;
  color: var(--stitch-on-surface-variant);
}

.stitch-footer__links a {
  color: var(--stitch-on-surface-variant);
  transition: color 200ms ease;
}

.stitch-footer__links a:hover {
  color: var(--stitch-primary);
  text-decoration: underline;
}

/* ─── Responsive refinements ──────────────────────────────────────────── */

@media (max-width: 720px) {
  :root {
    --stitch-section-y: 56px;
    --stitch-edge: 24px;
  }
  .stitch-section__title {
    font-size: 32px;
  }
  .stitch-card {
    padding: 24px;
  }
  .parallax-transition {
    height: 40vh;
    min-height: 280px;
  }
}

/* ─── Source-audit popover (Phase 2A) ─────────────────────────────────
   Surfaces per-counter source URL + page/table + extracted value +
   transformation + last-checked date inline with each provenance chip.
   Native <details> for accessibility (no JS, keyboard-traversable).
   The chip text remains the <summary> so evidence class is visible
   without opening the popover. */

.source-audit-popover {
  display: inline-block;
  position: relative;
  margin-left: 4px;
}

.source-audit-popover summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--stitch-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--stitch-on-surface-variant, #5a6675);
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: background 0.15s ease, color 0.15s ease;
}

.source-audit-popover summary::-webkit-details-marker {
  display: none;
}

.source-audit-popover summary:hover,
.source-audit-popover summary:focus-visible {
  background: rgba(0, 0, 0, 0.1);
  color: var(--stitch-on-surface, #1a1f2c);
  outline: none;
}

.source-audit-popover[open] summary {
  background: var(--stitch-primary, #1a4d6e);
  color: #ffffff;
  border-color: var(--stitch-primary, #1a4d6e);
}

.source-audit-popover__detail {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  margin: 0;
  padding: 14px 16px;
  max-width: min(420px, 90vw);
  width: max-content;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  font-family: var(--stitch-sans);
  font-size: 12px;
  line-height: 1.45;
  color: var(--stitch-on-surface, #1a1f2c);
}

.source-audit-popover__detail dt {
  margin: 8px 0 2px;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stitch-on-surface-variant, #5a6675);
}

.source-audit-popover__detail dt:first-child {
  margin-top: 0;
}

.source-audit-popover__detail dd {
  margin: 0;
  word-break: break-word;
}

.source-audit-popover__detail a {
  color: var(--stitch-primary, #1a4d6e);
  word-break: break-all;
}

/* Mobile: render the popover as a bottom-anchored sheet so it doesn't
   overflow the viewport. */
@media (max-width: 640px) {
  .source-audit-popover__detail {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
    top: auto;
    max-width: 90vw;
  }
}
