/* ============================================================================
   Sundog shared UI foundation.

   This file intentionally sits after the page-local stylesheets. The current
   pages still carry inline CSS, but these tokens and component overrides make
   the visual system portable for the coming UI/UX overhaul.

   Organized in five layers (Migration Step 2, landed 2026-05-08):
     1. TOKENS       — :root custom properties (colors, fonts, spacing)
     2. BASE         — universal selectors, html, body
     3. COMPONENTS   — chrome, buttons, cards, footer, controls
     4. PAGES        — hero, sections, page-level layout, grids
     5. EXPERIMENTS  — BoxForge primitives, paper-inspired (deferred) extensions

   Section markers are comment-only (no @layer at-rules) so the load-order
   cascade with inline page <style> blocks is preserved unchanged. To promote
   to formal @layer later, also wrap each page's inline <style> contents in
   `@layer overrides { ... }` and declare `@layer overrides, tokens, base,
   components, pages, experiments;` at the top.
   ============================================================================ */


/* ============================================================================
   1. TOKENS
   ============================================================================ */

:root,
body[data-sundog-theme="halo"] {
  color-scheme: light;

  --sd-ink: #142b3a;
  --sd-ink-strong: #0b1720;
  --sd-ink-soft: #263f4e;
  --sd-sky: #7396a8;
  --sd-ice: #dcebf0;
  --sd-cloud: #f7faf8;
  --sd-paper: #fffaf0;
  --sd-paper-warm: #f1eadc;
  --sd-brass: #d7a928;
  --sd-amber: #f4c430;
  --sd-copper: #b8653b;
  --sd-signal: #67c9a6;
  --sd-violet: #6c6a9f;
  --sd-line: rgba(20, 43, 58, 0.14);
  --sd-line-strong: rgba(20, 43, 58, 0.24);
  --sd-shadow: 0 18px 45px rgba(11, 23, 32, 0.14);
  --sd-shadow-soft: 0 10px 28px rgba(11, 23, 32, 0.10);

  --sd-font-display: Georgia, "Times New Roman", serif;
  --sd-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sd-font-data: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --sd-radius-sm: 4px;
  --sd-radius-md: 8px;
  --sd-page-max: 1120px;
  --sd-space-page: clamp(1.25rem, 4vw, 2.5rem);
  --sd-phase-duration: 260ms;

  /* Paper-inspired theme tokens (deferred — see UI_UX_THEME_FOUNDATION.md) */
  --sd-paper-ruled: #fefdfb;
  --sd-paper-line: rgba(99, 163, 220, 0.15);
  --sd-paper-margin: rgba(255, 99, 99, 0.3);

  --sd-sticky-yellow: #fef9c3;
  --sd-sticky-pink: #fce7f3;
  --sd-sticky-blue: #dbeafe;
  --sd-sticky-green: #dcfce7;

  --sd-tape-base: rgba(255, 255, 255, 0.85);
  --sd-tape-shadow: rgba(0, 0, 0, 0.1);

  --sd-wood-dark: #3e2723;
  --sd-wood-mid: #4e342e;
  --sd-wood-light: #5d4037;

  --sd-manila-base: #f4e4c1;
  --sd-manila-dark: #e8d5b7;
  --sd-manila-border: rgba(139, 90, 43, 0.2);

  /* Backwards-compatible aliases for the current inline page CSS. */
  --primary-dark: var(--sd-ink);
  --primary-mid: var(--sd-sky);
  --accent-gold: var(--sd-amber);
  --bg-light: var(--sd-cloud);
  --text-dark: #263036;
  --text-light: #f8fbfc;
  --muted: #64727b;
  --line: var(--sd-line);
}


/* ============================================================================
   2. BASE
   ============================================================================ */

* {
  text-rendering: geometricPrecision;
}

html {
  background: var(--sd-cloud);
}

body {
  font-family: var(--sd-font-body);
  color: var(--text-dark);
  line-height: 1.6;
  background:
    radial-gradient(circle at 16% 0%, rgba(244, 196, 48, 0.12), transparent 28rem),
    linear-gradient(180deg, #fbfdfb 0%, var(--sd-cloud) 42%, #eef5f3 100%);
}


/* ============================================================================
   3. COMPONENTS
   ============================================================================ */

/* --- Chrome: header, nav, brand, links --------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 23, 32, 0.92);
  border-bottom: 1px solid rgba(244, 196, 48, 0.28);
  box-shadow: 0 8px 26px rgba(11, 23, 32, 0.12);
  backdrop-filter: blur(12px);
}

.site-nav {
  max-width: var(--sd-page-max);
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-brand {
  color: var(--text-light);
  font-family: var(--sd-font-data);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
}

.site-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-links a {
  color: rgba(245, 245, 245, 0.82);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: color var(--sd-phase-duration) ease, border-color var(--sd-phase-duration) ease;
}

.site-links a:hover,
.site-links a[aria-current="page"] {
  color: var(--accent-gold);
  border-color: currentColor;
}

/* --- Typography mixin (eyebrow / tier / step / brand) ------------------ */

.eyebrow,
.tier,
.step-number,
.site-brand {
  font-family: var(--sd-font-data);
}

/* --- Buttons / interactive surfaces ------------------------------------ */

.btn,
.button,
.cta-link,
.app-card,
.benefit-card,
.proof-item,
.research-highlight,
.origin-card {
  border-radius: var(--sd-radius-md);
}

.btn,
.button,
.cta-link {
  position: relative;
  overflow: hidden;
  border-color: rgba(244, 196, 48, 0.44);
  transition:
    transform var(--sd-phase-duration) ease,
    border-color var(--sd-phase-duration) ease,
    background var(--sd-phase-duration) ease,
    box-shadow var(--sd-phase-duration) ease;
}

.btn::before,
.button::before,
.cta-link::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--sd-radius-md) - 2px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(103, 201, 166, 0.12), transparent 42%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--sd-phase-duration) ease;
}

.btn:hover::before,
.button:hover::before,
.cta-link:hover::before {
  opacity: 1;
}

.btn:focus-visible,
.button:focus-visible,
.cta-link:focus-visible,
.site-links a:focus-visible {
  outline: 2px solid var(--sd-signal);
  outline-offset: 3px;
}

.btn-primary,
.button {
  background: linear-gradient(180deg, #f8d35a 0%, var(--sd-brass) 100%);
  color: var(--sd-ink-strong);
  box-shadow: 0 12px 24px rgba(215, 169, 40, 0.18);
}

.btn-secondary {
  background: rgba(11, 23, 32, 0.42);
  border-color: rgba(248, 251, 252, 0.74);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(6px);
}

.btn:hover,
.button:hover,
.cta-link:hover {
  transform: translateY(-2px);
}

/* --- Cards: borders, shadows, paper-line backgrounds, hovers ----------- */

.app-card,
.benefit-card,
.proof-item,
.research-highlight,
.origin-card,
.comparison-container {
  border-color: var(--sd-line);
  box-shadow: var(--sd-shadow-soft);
}

.benefit-card,
.proof-item,
.research-highlight,
.comparison-container,
.origin-card {
  background:
    linear-gradient(transparent 96%, rgba(99, 163, 220, 0.075) 96%),
    linear-gradient(90deg, rgba(255, 99, 99, 0.12) 0 2px, transparent 2px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 250, 240, 0.94)),
    var(--sd-paper-ruled);
  background-size: 100% 1.75rem, 100% 100%, 100% 100%, 100% 100%;
}

.app-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 250, 240, 0.98)),
    var(--sd-paper);
}

.app-card:hover,
.benefit-card:hover,
.origin-card:hover,
.proof-item:hover,
.research-highlight:hover {
  transform: translateY(-4px);
  border-color: rgba(215, 169, 40, 0.58);
  box-shadow: var(--sd-shadow);
}

.app-card,
.benefit-card,
.origin-card,
.proof-item,
.research-highlight,
.comparison-container {
  transition:
    transform var(--sd-phase-duration) ease,
    border-color var(--sd-phase-duration) ease,
    box-shadow var(--sd-phase-duration) ease;
}

.benefit-card,
.proof-item,
.research-highlight {
  padding: 1.75rem;
}

.app-card-content {
  padding: 1.5rem;
}

.app-card-img {
  background:
    linear-gradient(135deg, rgba(11, 23, 32, 0.76), rgba(20, 43, 58, 0.90)),
    repeating-linear-gradient(90deg, rgba(244, 196, 48, 0.18) 0 1px, transparent 1px 18px);
  font-family: var(--sd-font-data);
  letter-spacing: 0.04em;
}

.tier {
  align-self: flex-start;
  background: color-mix(in srgb, var(--sd-sky) 82%, var(--sd-ink));
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.34);
}

.theorem-card {
  border-color: rgba(244, 196, 48, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.035)),
    rgba(11, 23, 32, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* --- Data text --------------------------------------------------------- */

.proof-snippet,
.equation-display {
  font-family: var(--sd-font-data);
}

/* --- Footer + dark CTA section surfaces -------------------------------- */

.cta-section,
footer {
  color: var(--text-light);
  padding: 3rem 2rem;
  text-align: center;
  background:
    linear-gradient(180deg, var(--sd-ink) 0%, var(--sd-ink-strong) 100%);
}

footer a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--sd-phase-duration) ease;
}

footer a:hover {
  text-decoration: underline;
}

/* --- Special surfaces -------------------------------------------------- */

.proof-placeholder {
  border: 1px solid rgba(20, 43, 58, 0.12);
  background:
    linear-gradient(135deg, rgba(20, 43, 58, 0.08), rgba(115, 150, 168, 0.08)),
    repeating-linear-gradient(90deg, rgba(20, 43, 58, 0.05) 0 1px, transparent 1px 18px),
    var(--sd-paper-warm);
  color: var(--sd-ink-soft);
}

/* --- Controls (used by experiment pages: threebody, balance) ---------- */

.controls-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 14rem),
    rgba(11, 23, 32, 0.94);
  border-color: rgba(244, 196, 48, 0.36);
  box-shadow: 0 18px 36px rgba(11, 23, 32, 0.24);
}

.control-group button {
  box-shadow: 0 8px 16px rgba(215, 169, 40, 0.16);
}

.control-group input[type="range"] {
  accent-color: var(--sd-amber);
}

.control-group select,
.controls-panel select {
  background-color: rgba(248, 251, 252, 0.11) !important;
  color: var(--text-light) !important;
  border-color: rgba(244, 196, 48, 0.42) !important;
}

.control-group select option,
.controls-panel select option {
  background-color: var(--sd-ink);
  color: var(--sd-cloud);
}


/* ============================================================================
   4. PAGES
   ============================================================================ */

/* --- Hero ------------------------------------------------------------- */

.hero,
.page-hero {
  isolation: isolate;
  position: relative;
}

.hero {
  min-height: calc(100vh - 58px);
  padding-block: clamp(3rem, 9vh, 5.5rem) clamp(2.25rem, 6vh, 4rem);
  background:
    radial-gradient(circle at 50% 44%, rgba(244, 196, 48, 0.18), transparent 13rem),
    radial-gradient(circle at 24% 50%, rgba(103, 201, 166, 0.18), transparent 18rem),
    radial-gradient(circle at 76% 48%, rgba(108, 106, 159, 0.14), transparent 19rem),
    linear-gradient(145deg, var(--sd-ink-strong) 0%, var(--sd-ink) 58%, #203a47 100%);
}

.hero::after,
.page-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 196, 48, 0.72), transparent);
  opacity: 0.65;
  pointer-events: none;
}

.hero h1,
.page-hero h1,
section h2,
.origin-card h2,
.app-card h2,
.app-card h3,
.cta-link h3 {
  letter-spacing: 0;
}

.hero h1,
.page-hero h1 {
  font-family: var(--sd-font-display);
  font-weight: 700;
}

.hero-content {
  order: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 940px);
}

.hero .value-prop {
  margin-bottom: clamp(1.5rem, 4vh, 2.5rem);
}

.cta-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(10rem, 1fr));
  gap: 1rem;
  width: min(100%, 1000px);
}

.cta-buttons .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.3rem;
  padding: 0.82rem 1.15rem;
  font-size: clamp(0.96rem, 1.25vw, 1.05rem);
  text-align: center;
}

.cta-buttons .btn-primary {
  grid-column: span 2;
}

.hero .equation-display {
  order: 2;
  position: relative;
  inset: auto;
  transform: none;
  z-index: 1;
  width: min(100%, 760px);
  min-height: 3.8rem;
  margin: clamp(1.35rem, 4vh, 2rem) auto 0;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(244, 196, 48, 0.24);
  border-radius: var(--sd-radius-md);
  background: rgba(11, 23, 32, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  font-size: clamp(0.88rem, 1.5vw, 1.08rem);
  line-height: 1.55;
}

.hero-note {
  margin: 0 0 1rem;
  color: var(--sd-amber);
  font-size: 0.95rem;
  font-style: italic;
}

.theorem-band {
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 196, 48, 0.08), transparent 24rem),
    linear-gradient(180deg, var(--sd-ink-strong) 0%, var(--sd-ink) 100%);
}

/* --- Sections: padding, backgrounds, generic h2/p defaults ------------ */

.theorem-section,
.what-section,
.why-section,
.applications-section,
.comparison-section,
.proof-section,
.research-section,
.cta-section {
  max-width: none;
  margin: 0;
  padding: clamp(4.5rem, 8vw, 7rem) var(--sd-space-page);
}

/* Generic section heading + paragraph defaults; page-local rules can still override. */
section h2 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
  color: var(--sd-ink-strong);
  text-align: center;
}

section p {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.what-section,
.applications-section,
.proof-section {
  background:
    radial-gradient(circle at 8% 8%, rgba(244, 196, 48, 0.08), transparent 20rem),
    linear-gradient(180deg, #fbfdfb 0%, var(--sd-cloud) 100%);
}

.why-section,
.comparison-section,
.research-section {
  background:
    linear-gradient(180deg, rgba(220, 235, 240, 0.52), rgba(247, 250, 248, 0.94)),
    var(--sd-cloud);
}

.theorem-section > *,
.what-section > *,
.why-section > *,
.applications-section > *,
.comparison-section > *,
.proof-section > *,
.research-section > *,
.cta-section > * {
  max-width: var(--sd-page-max);
  margin-left: auto;
  margin-right: auto;
}

.what-section .content,
.research-content {
  max-width: 780px;
}

.what-section .content {
  position: relative;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid rgba(20, 43, 58, 0.10);
  border-left: 3px solid rgba(215, 169, 40, 0.72);
  border-radius: var(--sd-radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 250, 240, 0.72)),
    var(--sd-paper);
  box-shadow: var(--sd-shadow-soft);
}

.what-section .content p:last-child,
.research-content p:last-child {
  margin-bottom: 0;
}

/* --- Grids ----------------------------------------------------------- */

.benefits-grid,
.app-grid,
.proof-grid,
.research-highlights,
.cta-grid {
  width: min(100%, var(--sd-page-max));
}

.benefits-grid,
.research-highlights {
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 1.4rem;
}

.app-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.4rem;
}

.proof-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.4rem;
}

/* --- Card layout (page-level layout for cards, not styling) ----------- */

.benefit-card,
.proof-item,
.research-highlight {
  min-height: 100%;
  border: 1px solid var(--sd-line);
}

.benefit-card h3,
.proof-item h4,
.research-highlight h4 {
  color: var(--sd-ink-strong);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.app-card h3 {
  color: var(--sd-ink-strong);
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
}

.app-card p {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.app-card a {
  color: var(--sd-ink-strong);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color var(--sd-phase-duration) ease;
}

.app-card a:hover {
  color: var(--accent-gold);
}

.app-card {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.app-card-img {
  min-height: 12rem;
}

.app-card-content {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.app-card-content a {
  margin-top: auto;
}

/* --- Comparison ------------------------------------------------------ */

.comparison-lead {
  max-width: 620px;
  margin: 0 auto 2rem;
  text-align: center;
}

.comparison-container {
  border: 1px solid var(--sd-line);
}

.comparison-side {
  padding: clamp(1rem, 2vw, 1.35rem);
  border-radius: var(--sd-radius-sm);
  background: rgba(255, 255, 255, 0.38);
}

/* --- Proof placeholder layout ---------------------------------------- */

.proof-placeholder {
  min-height: 14rem;
  padding: 1.25rem;
  text-align: center;
}

/* --- CTA section layout ---------------------------------------------- */

.cta-section {
  position: relative;
  overflow: hidden;
}

.cta-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 196, 48, 0.12), transparent 22rem),
    radial-gradient(circle at 18% 80%, rgba(103, 201, 166, 0.10), transparent 18rem);
  pointer-events: none;
}

.cta-section > * {
  position: relative;
}

.cta-grid {
  gap: 1rem;
}

/* --- Footer extras --------------------------------------------------- */

.footer-links {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.footer-note {
  margin-top: 2rem;
  font-size: 0.85rem;
  opacity: 0.7;
}


/* ============================================================================
   5. EXPERIMENTS
   ============================================================================ */

/* --- BoxForge primitives (upcoming hero graph / phase animation) ----- */

.sd-boxforge-surface {
  position: relative;
  transform-style: preserve-3d;
  perspective: 900px;
}

.sd-phase-button {
  border: 1px solid var(--sd-line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(241, 234, 220, 0.78)),
    var(--sd-paper);
  color: var(--sd-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 8px 18px rgba(11, 23, 32, 0.10);
}

.sd-phase-button:hover,
.sd-phase-button[data-state="active"] {
  border-color: rgba(215, 169, 40, 0.72);
  transform: translateY(-1px) rotateX(2deg);
}

.sd-signal-graph {
  --graph-node: var(--sd-amber);
  --graph-edge: rgba(103, 201, 166, 0.46);
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid rgba(244, 196, 48, 0.20);
  background:
    radial-gradient(circle at 50% 50%, rgba(244, 196, 48, 0.10), transparent 11rem),
    linear-gradient(135deg, rgba(11, 23, 32, 0.96), rgba(20, 43, 58, 0.92));
}

.sd-signal-graph::before {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px solid var(--graph-edge);
  border-radius: 50%;
  transform: rotateX(64deg) rotateZ(-16deg);
  animation: sd-graph-orbit 8s linear infinite;
}

.sd-signal-graph::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: calc(50% - 6px);
  top: calc(50% - 6px);
  border-radius: 50%;
  background: var(--graph-node);
  box-shadow:
    -92px -28px 0 var(--sd-signal),
    96px 18px 0 var(--sd-violet),
    0 0 34px rgba(244, 196, 48, 0.45);
}

@keyframes sd-graph-orbit {
  from { transform: rotateX(64deg) rotateZ(-16deg); }
  to { transform: rotateX(64deg) rotateZ(344deg); }
}

/* --- Paper-inspired components (deferred — see UI_UX_THEME_FOUNDATION.md) */

/* Ruled / lined paper cards */
.sd-paper-card {
  position: relative;
  background:
    linear-gradient(transparent 95%, var(--sd-paper-line) 95%),
    var(--sd-paper-ruled);
  background-size: 100% 1.5rem;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 4px 12px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(20, 43, 58, 0.08);
  border-left: 2px solid var(--sd-paper-margin);
  border-radius: var(--sd-radius-md);
  padding: 1.5rem 1.5rem 1.5rem calc(2rem + 2px);
  transition: box-shadow var(--sd-phase-duration) ease;
}

.sd-paper-card:hover {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.15),
    0 8px 20px rgba(0, 0, 0, 0.12);
}

/* Sticky note sections */
.sd-sticky-note {
  position: relative;
  background: linear-gradient(135deg,
    var(--sd-sticky-yellow) 0%,
    color-mix(in srgb, var(--sd-sticky-yellow) 95%, #000) 100%
  );
  transform: rotate(-2deg);
  transition: transform var(--sd-phase-duration) ease,
              box-shadow var(--sd-phase-duration) ease;
  box-shadow:
    2px 4px 8px rgba(0, 0, 0, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  padding: 1rem 1.25rem;
  margin: 1rem;
}

.sd-sticky-note:hover {
  transform: rotate(-4deg) translateY(-4px);
  box-shadow:
    4px 8px 16px rgba(0, 0, 0, 0.2),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.sd-sticky-note.sd-sticky-pink {
  background: linear-gradient(135deg,
    var(--sd-sticky-pink) 0%,
    color-mix(in srgb, var(--sd-sticky-pink) 95%, #000) 100%
  );
}

.sd-sticky-note.sd-sticky-blue {
  background: linear-gradient(135deg,
    var(--sd-sticky-blue) 0%,
    color-mix(in srgb, var(--sd-sticky-blue) 95%, #000) 100%
  );
}

.sd-sticky-note.sd-sticky-green {
  background: linear-gradient(135deg,
    var(--sd-sticky-green) 0%,
    color-mix(in srgb, var(--sd-sticky-green) 95%, #000) 100%
  );
}

/* Tape overlays */
.sd-tape-overlay {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 120px;
  height: 32px;
  background:
    linear-gradient(135deg,
      rgba(255, 255, 255, 0.88) 0%,
      rgba(255, 255, 255, 0.78) 100%
    );
  box-shadow:
    0 2px 4px var(--sd-tape-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  pointer-events: none;
  opacity: 0.92;
  z-index: 10;
}

.sd-tape-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(255, 255, 255, 0.15) 3px,
      rgba(255, 255, 255, 0.15) 6px
    );
  border-radius: 2px;
  mix-blend-mode: overlay;
}

.sd-tape-overlay.sd-tape-top-left {
  left: 15%;
  transform: translateX(0) rotate(8deg);
}

.sd-tape-overlay.sd-tape-top-right {
  left: 85%;
  transform: translateX(-100%) rotate(-8deg);
}

/* Wooden desk background */
body[data-theme="desk"],
.sd-desk-bg {
  background:
    radial-gradient(circle at 20% 30%, rgba(139, 90, 43, 0.15), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(101, 67, 33, 0.15), transparent 40%),
    repeating-linear-gradient(
      90deg,
      var(--sd-wood-dark) 0px,
      var(--sd-wood-mid) 2px,
      var(--sd-wood-dark) 4px
    ),
    linear-gradient(180deg, var(--sd-wood-mid) 0%, var(--sd-wood-dark) 100%);
  background-blend-mode: multiply, multiply, overlay, normal;
  min-height: 100vh;
}

/* Manila folder / clipboard containers */
.sd-manila-container {
  position: relative;
  background:
    linear-gradient(180deg,
      rgba(255, 255, 255, 0.3) 0%,
      transparent 20%
    ),
    var(--sd-manila-base);
  border: 1px solid var(--sd-manila-border);
  border-radius: var(--sd-radius-md);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 2rem;
  overflow: hidden;
}

.sd-manila-container.with-tab::before {
  content: "";
  position: absolute;
  top: -16px;
  right: 20%;
  width: 120px;
  height: 16px;
  background: linear-gradient(180deg, var(--sd-manila-dark) 0%, var(--sd-manila-base) 100%);
  border: 1px solid var(--sd-manila-border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  z-index: -1;
}

.sd-manila-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.02) 2px,
      rgba(0, 0, 0, 0.02) 4px
    );
  pointer-events: none;
  mix-blend-mode: multiply;
}


/* ============================================================================
   MEDIA QUERIES (cross-cutting; affect multiple layers)
   ============================================================================ */

/* Reduced motion — universal */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* Tablet / narrow desktop */
@media (max-width: 768px) {
  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.85rem 1.5rem;
  }

  .site-links {
    justify-content: flex-start;
    gap: 0.85rem;
  }

  .hero {
    min-height: calc(100vh - 96px);
    padding-block: 2.25rem;
  }

  .cta-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 42rem);
  }

  .cta-buttons .btn {
    min-height: 3rem;
  }

  .hero .equation-display {
    min-height: 4.6rem;
    font-size: 0.86rem;
  }

  .theorem-section,
  .what-section,
  .why-section,
  .applications-section,
  .comparison-section,
  .proof-section,
  .research-section,
  .cta-section {
    padding-block: 4rem;
  }

  .benefits-grid,
  .app-grid,
  .proof-grid,
  .research-highlights {
    grid-template-columns: 1fr;
  }

  .benefit-card,
  .proof-item,
  .research-highlight {
    padding: 1.5rem;
  }
}

/* Phone */
@media (max-width: 520px) {
  .cta-buttons {
    grid-template-columns: 1fr;
    width: min(100%, 24rem);
  }

  .cta-buttons .btn-primary {
    grid-column: span 1;
  }
}

/* Reduced motion — paper-effect overrides (experiments layer) */
@media (prefers-reduced-motion: reduce) {
  .sd-sticky-note {
    transform: rotate(0deg);
  }

  .sd-sticky-note:hover {
    transform: rotate(0deg) translateY(-2px);
  }

  .sd-tape-overlay,
  .sd-tape-overlay.sd-tape-top-left,
  .sd-tape-overlay.sd-tape-top-right {
    transform: none;
  }
}
