/* Clause5 Shared CSS — Molten Trace Design System
 * Source of truth: landing/design-tokens.md
 * Covers: tokens, reset, base typography, layout, arc-line, sparks, keyframes,
 * accessibility (reduced-motion, touch targets), mobile, print.
 *
 * Pages link this BEFORE their page-specific <style> block.
 * Page-specific CSS (calculator forms, result cards) stays inline.
 * Component CSS (FAQ, related-links) loaded separately via /components/*.css.
 * This file also covers: tables, CTA buttons, field-notes, trust asides, snippets, footer.
 */

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scrollbar-gutter: stable; }

/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg: #08080A; --surface: #111115; --surface-deep: #0C0C10;
  --arc: #FFB627; --arc-hot: #FF8C00;
  --arc-glow: rgba(255,182,39,0.15); --arc-glow-strong: rgba(255,182,39,0.3);
  --arc-glow-subtle: rgba(255,182,39,0.10);
  --text: #F0EDE8; --text-muted: #D0D0D4; --text-dim: #B0B0B6;
  --border: #2A2A2E; --border-subtle: #1A1A1E; --success: #34D399; --radius: 6px;
}

/* ── Base ────────────────────────────────────────────────────────────── */
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { background: var(--bg); color: var(--text); font-family: 'Barlow', sans-serif; font-weight: 400; line-height: 1.6; min-height: 100vh; min-height: 100dvh; overflow-x: clip; position: relative; }
body::before { content: ''; position: fixed; inset: 0; opacity: 0.03; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); background-repeat: repeat; background-size: 256px; pointer-events: none; z-index: 1; }
body::after { content: ''; position: fixed; top: 30%; left: 50%; transform: translate(-50%,-50%); width: 900px; height: 600px; background: radial-gradient(ellipse, var(--arc-glow-subtle) 0%, transparent 70%); pointer-events: none; z-index: 0; }

/* ── Layout ──────────────────────────────────────────────────────────── */
.page { position: relative; z-index: 2; max-width: 760px; margin: 0 auto; padding: 0 24px; }

/* ── Breadcrumb ──────────────────────────────────────────────────────── */
.breadcrumb { margin-top: 24px; font-size: 0.95rem; color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.04em; opacity: 0; animation: fadeIn 0.8s ease 0.1s forwards; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color 0.3s; }
.breadcrumb a:hover { color: var(--arc); }
.breadcrumb span { color: var(--text-dim); margin: 0 6px; }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero { padding: 48px 0 32px; opacity: 0; animation: slideUp 0.8s ease 0.15s forwards; }
.hero__label { font-family: 'Syne', sans-serif; font-size: 0.82rem; font-weight: 700; color: var(--arc); letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 16px; }
h1 { font-family: 'Syne', sans-serif; font-weight: 800; font-size: clamp(1.8rem,4.5vw,2.6rem); line-height: 1.3; letter-spacing: -0.02em; margin-bottom: 16px; }
.hero__sub { color: var(--text-muted); font-size: 1rem; line-height: 1.7; max-width: 580px; }

/* ── Arc Line + Sparks ───────────────────────────────────────────────── */
.arc-line { position: relative; height: 2px; margin: 32px 0; background: linear-gradient(90deg, transparent 0%, var(--arc) 30%, var(--arc-hot) 50%, var(--arc) 70%, transparent 100%); opacity: 0; animation: arcIgnite 1.2s ease 0.4s forwards; overflow: visible; }
.arc-line::before { content: ''; position: absolute; inset: -8px 0; background: linear-gradient(90deg, transparent 0%, var(--arc-glow) 30%, rgba(255,140,0,0.2) 50%, var(--arc-glow) 70%, transparent 100%); filter: blur(8px); animation: arcPulse 3s ease-in-out infinite; }
.arc-line::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 6px; height: 6px; border-radius: 50%; background: var(--text); box-shadow: 0 0 12px var(--arc), 0 0 24px var(--arc-hot), 0 0 48px var(--arc-glow-strong); animation: arcCenter 3s ease-in-out infinite; }
.sparks { position: absolute; left: 50%; top: 0; width: 200px; transform: translateX(-50%); pointer-events: none; }
.spark { position: absolute; width: 2px; height: 2px; background: var(--arc); border-radius: 50%; opacity: 0; animation: sparkFloat var(--duration) ease-out var(--delay) infinite; }

/* ── Sections ────────────────────────────────────────────────────────── */
.section { padding: 48px 0; opacity: 0; transition: opacity 0.5s ease; }
.section.visible { opacity: 1; }
.section + .section { border-top: 1px solid var(--border-subtle); }
.section + [id="flux-widget"] { margin-top: -32px; }
.section__label { font-family: 'Syne', sans-serif; font-size: 0.82rem; font-weight: 700; color: var(--arc); letter-spacing: 0.2em; text-transform: uppercase; margin-bottom: 20px; }

/* ── Typography ──────────────────────────────────────────────────────── */
h2 { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.4rem; letter-spacing: -0.01em; margin-bottom: 20px; }
p { color: var(--text-muted); line-height: 1.75; margin-bottom: 16px; }
p:last-child { margin-bottom: 0; }
strong { color: var(--text); font-weight: 600; }
a { color: var(--arc); text-decoration: none; }
a:hover { color: var(--arc-hot); }

/* ── Trust Line ──────────────────────────────────────────────────────── */
.trust-line { text-align: center; font-size: 0.85rem; color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; padding: 24px 0 8px; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; margin: 20px 0 24px; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.compare-table th { text-align: left; padding: 10px 12px; background: var(--surface); color: var(--arc); font-family: 'IBM Plex Mono', monospace; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; border-bottom: 1px solid var(--border); }
.compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); color: var(--text-muted); }
.compare-table a { color: var(--arc); text-decoration: none; }
.compare-table a:hover { color: var(--arc-hot); }

/* ── CTA Buttons ─────────────────────────────────────────────────────── */
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 32px 0; }
.cta-btn { display: inline-block; padding: 12px 24px; background: var(--arc); color: #08080A; border-radius: var(--radius); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.95rem; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; transition: transform 0.2s, box-shadow 0.2s; }
.cta-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--arc-glow); }

/* ── Calculator → Content back-link section (Tier 3 of CTA injection) ─ */
.calc-related-reading { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border-subtle); }
.calc-related-reading h2 { font-family: 'Syne', sans-serif; font-size: 0.875rem; font-weight: 700; color: var(--arc); letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 20px; }
.calc-related-reading ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.calc-related-reading li { font-size: 0.95rem; line-height: 1.5; color: var(--text-dim); }
.calc-related-reading li a { color: var(--text); text-decoration: none; font-weight: 600; transition: color 0.2s; }
.calc-related-reading li a:hover { color: var(--arc); }
@media (max-width: 640px) {
  .calc-related-reading { margin-top: 40px; padding-top: 24px; }
  .calc-related-reading li { font-size: 0.9rem; }
}

/* ── Field Notes ─────────────────────────────────────────────────────── */
.field-note { margin: 24px 0; padding: 16px 20px; border-left: 3px solid var(--arc); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.field-note p { margin-bottom: 0; font-size: 1rem; }

/* ── Expert Quote ────────────────────────────────────────────────────── */
.expert-quote { margin: 32px 0; padding: 20px 24px; border-left: 3px solid var(--arc); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.expert-quote p { font-style: italic; font-size: 1.05rem; line-height: 1.7; color: var(--text); margin: 0 0 8px; }
.expert-quote cite { display: block; font-size: 0.85rem; color: var(--text-dim); font-style: normal; }

/* ── Snippet ─────────────────────────────────────────────────────────── */
.snippet { color: var(--text); font-size: 1.05rem; line-height: 1.7; margin-bottom: 20px; }

/* ── Trust Aside ─────────────────────────────────────────────────────── */
aside.trust { margin: 40px 0 0; padding: 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius); text-align: center; }
aside.trust p { font-size: 0.85rem; color: var(--text-dim); font-family: 'IBM Plex Mono', monospace; margin: 0; }
aside.trust p + p { margin-top: 6px; }

/* ── Footer ──────────────────────────────────────────────────────────── */
footer { padding: 40px 24px; border-top: 1px solid var(--border-subtle); font-size: 0.875rem; color: var(--text-dim); max-width: 960px; margin: 0 auto; }
footer a { color: var(--text-muted); text-decoration: none; transition: color 0.3s; }
footer a:hover { color: var(--arc); }
.footer-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 24px; margin-bottom: 24px; }
.footer-grid h4 { font-family: 'Syne', sans-serif; font-size: 0.875rem; font-weight: 700; color: var(--arc); letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 12px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 6px; }
.footer-grid li a { font-size: 0.875rem; }
.footer-cta { text-align: center; padding: 16px 0; border-top: 1px solid var(--border-subtle); margin-bottom: 16px; }
.footer-cta a { color: var(--arc); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.9rem; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 0.875rem; }
.footer-langs { text-align: center; font-size: 0.875rem; letter-spacing: 0.1em; margin-top: 16px; }
.footer-langs a { margin: 0 4px; opacity: 0.6; }
.footer-langs a:hover { opacity: 1; }
.footer-langs a.active { opacity: 1; font-weight: 600; }
@media (max-width: 768px) { .footer-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; gap: 20px; } .footer-bottom { flex-direction: column; text-align: center; } }

/* ── Keyframes ───────────────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes sparkFloat { 0% { opacity: 0.9; transform: translate(var(--x), 0) scale(1); } 100% { opacity: 0; transform: translate(calc(var(--x) + var(--drift)), -60px) scale(0); } }
@keyframes arcIgnite { 0% { opacity: 0; transform: scaleX(0); } 60% { opacity: 1; transform: scaleX(1.02); } 100% { opacity: 1; transform: scaleX(1); } }
@keyframes arcPulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes arcCenter { 0%, 100% { box-shadow: 0 0 12px var(--arc), 0 0 24px var(--arc-hot), 0 0 48px var(--arc-glow-strong); } 50% { box-shadow: 0 0 16px var(--arc), 0 0 32px var(--arc-hot), 0 0 64px rgba(255,182,39,0.4); } }

/* ── Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page { padding-inline: 1.25rem; }
  .hero { padding: 32px 0 20px !important; }
  .section { padding: 24px 0 !important; }
  .section + [id="flux-widget"] { margin-top: -16px; }
  h2 { margin-bottom: 12px !important; }
  .cta-row { flex-direction: column; }
}

/* ── Calculator Reset ───────────────────────────────────────────────── */
.calc-reset { display: block; width: 100%; background: transparent; border: 1px solid var(--border); color: var(--text-muted); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1rem; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; padding: 14px; min-height: 48px; border-radius: var(--radius, 6px); transition: border-color 0.2s, color 0.2s; margin-top: 8px; }
.calc-reset:hover { border-color: var(--arc); color: var(--arc); }

/* ── Result Card Divider ────────────────────────────────────────────── */
.result-card__divider { height: 1px; background: var(--border-subtle); margin: 16px 0; }
.result-card__disclaimer { font-size: 0.82rem; color: var(--text-dim); margin-top: 12px; }

/* ── Share Buttons ──────────────────────────────────────────────────── */
.share-buttons { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.share-buttons button, .share-buttons a { padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center; font-size: 0.85rem; font-family: 'IBM Plex Mono', monospace; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; color: var(--text-muted); cursor: pointer; text-decoration: none; transition: border-color 0.2s; }
.share-buttons button:hover, .share-buttons a:hover { border-color: var(--arc); color: var(--text); }
@media (max-width: 600px) { .share-buttons { flex-direction: column; } .share-buttons button, .share-buttons a { width: 100%; justify-content: center; } }

/* ── Accessibility ───────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--arc); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  nav, .breadcrumb, .hero, .arc-line, .section { opacity: 1 !important; transform: none !important; }
}

/* ── Flux Chips (hover + disabled) ────────────────────────────────────
   Inline styles on symbol pages override normal specificity,
   so hover uses !important to ensure arc highlight always works. */
.flux-chip { transition: border-color 0.15s, color 0.15s; }
.flux-chip:hover:not(:disabled) { border-color: var(--arc) !important; color: var(--arc) !important; }
.flux-chip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Print ───────────────────────────────────────────────────────────── */
@media print {
  /* NUCLEAR: force ALL text black, kill ALL animations, force ALL visible.
     This beats any inline <style> specificity because * + !important wins. */
  * { color: #000 !important; animation: none !important; opacity: 1 !important; transition: none !important; }
  *::before, *::after { animation: none !important; opacity: 1 !important; }

  /* White background, strip decorative layers */
  body { background: #fff !important; }
  body::before, body::after { display: none !important; }
  *, *::before, *::after { background: transparent !important; box-shadow: none !important; text-shadow: none !important; }
  body, .page, main, .faq-section, .faq-item, .faq-answer, .qa-block { background: #fff !important; }
  .page { max-width: 100%; padding: 0 !important; }

  /* Restore text hierarchy (secondary text lighter than black) */
  .hero__label, .section__label, .diagram-block__label, .breadcrumb, cite { color: #555 !important; }
  .hero__sub { color: #333 !important; }

  /* HIDE: all interactive/non-print elements (comprehensive list) */
  #c5-nav, nav, #flux-widget, [id="flux-widget"],
  .flux-widget-header, .flux-chip, .flux-card, .flux-input-row, .flux-qa-input,
  .share-bar, .btn-share, .share-row,
  .flux-machine-offer, .flux-machine-result, .flux-email-card,
  .c5-cta, #c5CtaMount, .cta-row, .cta-btn,
  .sparks, .arc-line, .share-buttons, .unit-toggle,
  .no-print, footer, script,
  body > div.page > div.arc-line { display: none !important; visibility: hidden !important; height: 0 !important; overflow: hidden !important; }

  /* Code citations — visible with border on white */
  code { background: #eee !important; color: #000 !important; border: 1px solid #999 !important; padding: 1px 4px !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Field notes / expert quotes — solid black border */
  .field-note, .expert-quote, blockquote.field-note, blockquote.expert-quote {
    border-left: 3px solid #000 !important; padding-left: 16px !important;
    background: #f9f9f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  /* Tables — borders visible */
  table, .compare-table, .ref-table, .var-table { border-collapse: collapse !important; }
  th, td { border: 1px solid #ccc !important; padding: 4px 8px !important; color: #000 !important; }
  .result-card { border: 1px solid #ccc !important; background: #fff !important; break-inside: avoid; }

  /* PAGE BREAKS — prevent content cutoff */
  h1, h2, h3, h4, h5, h6, dt, strong, .section__label, .diagram-block__label,
  .hero__label, caption, thead { page-break-after: avoid; break-after: avoid; }
  .faq-item, .qa-block, table, blockquote, .field-note, .expert-quote,
  .related-links, .diagram-block, .result-card, .sym-cell,
  img, svg, figure, .compare-table, .var-table-wrap, .process-selector,
  .finish-grid, .finish-card, .ref-table tr, .contour-grid,
  .contour-card, dt + dd, li { page-break-inside: avoid; break-inside: avoid; }
  /* Widows/orphans — minimum lines before/after page break */
  p, li, dd { orphans: 3; widows: 3; }
  /* Don't orphan headings — keep with next content */
  h2 + p, h2 + div, h2 + table, h2 + ul, h3 + p, h3 + div,
  h4 + p, h4 + div, dt + dd, strong + p, .section__label + h2 {
    page-break-before: avoid; break-before: avoid;
  }

  /* Links — show URL for reference */
  a { color: #000 !important; text-decoration: underline !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.7em; color: #666 !important; }
  /* Don't expand internal links */
  a[href^="/"]::after { content: none; }

  /* SVG symbols — black strokes on white paper */
  svg, svg * { stroke: #000 !important; }
  svg [fill]:not([fill="none"]) { fill: #000 !important; }
  svg [fill="none"] { fill: none !important; }
  svg text { fill: #000 !important; stroke: none !important; }

  /* Print source attribution */
  .trust, aside.trust { display: block !important; border-top: 1px solid #ccc; margin-top: 24px; padding-top: 12px; }
  .trust p { color: #666 !important; font-size: 0.85em !important; }
}

/* Authority edition badge — calculator pages */
.edition-badge { font-family: 'IBM Plex Mono', monospace; font-size: 0.85rem; color: var(--text-dim); letter-spacing: 0.04em; margin-top: 8px; }

/* ── RTL (Arabic) ────────────────────────────────────────────────────── */
[dir=rtl] { direction: rtl; text-align: right; }
[dir=rtl] .breadcrumb { direction: rtl; }
[dir=rtl] .c5-tools-nav { direction: rtl; }
[dir=rtl] .result-card { text-align: right; }
[dir=rtl] .result-card__temp { direction: ltr; unicode-bidi: embed; }
[dir=rtl] .related-links a { direction: rtl; }
[dir=rtl] .compare-table { direction: rtl; }
[dir=rtl] .compare-table td, [dir=rtl] .compare-table th { text-align: right; }
[dir=rtl] .faq-item__q, [dir=rtl] .faq-item__a, [dir=rtl] .faq-list { text-align: right; }
[dir=rtl] .section { text-align: right; }
[dir=rtl] .hero { text-align: right; }
[dir=rtl] .nav-links { margin-left: 0; margin-right: auto; }

/* GEO blockquotes — attributed D1.1/A2.4 quotes for AI citation (+42.8% visibility per Princeton GEO study) */
.geo-quote { border-left: 3px solid var(--accent, #f97316); margin: 24px 0; padding: 16px 20px; background: rgba(249,115,22,0.06); border-radius: 0 8px 8px 0; font-style: italic; color: var(--text-muted); }
.geo-quote p { margin: 0; line-height: 1.7; }
