/*
 * Blupoli visual foundation.
 *
 * This is the canonical cross-app layer for theme colors, typography, spacing,
 * radii and common reading/card surfaces. Product-specific styles may build on
 * these tokens, but should not redefine the visual language per section.
 */

:root {
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --content-max: 1180px;
  --reading-max: 780px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --type-caption: 0.75rem;
  --type-small: 0.875rem;
  --type-body: 1rem;
  --type-body-lg: 1.075rem;
  --type-lead: clamp(1.05rem, 1.8vw, 1.2rem);
  --type-card-title: 1.25rem;
  --type-section: clamp(2rem, 4.5vw, 4rem);
  --type-display: clamp(2.8rem, 6.5vw, 5.8rem);

  --radius-sm: 12px;
  --radius-md: 22px;
  --radius-lg: 30px;
  --radius-pill: 999px;
}

html[data-theme="dark"],
html:not([data-theme]) {
  color-scheme: dark;
  --bg: #08111f;
  --bg-deep: #050b14;
  --surface: rgba(15, 28, 47, 0.82);
  --surface2: #101d30;
  --surface-strong: #101d30;
  --surface-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f7f9fc;
  --text-secondary: #c5cede;
  --text-subtle: #91a0b5;
  --muted: #a9b5c7;
  --blue: #72d7ff;
  --accent: #7587ff;
  --accent2: #72d7ff;
  --indigo: #7587ff;
  --violet: #a177ff;
  --mint: #6fe6c0;
  --ok: #6fe6c0;
  --danger: #fb8ca0;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 16px 42px rgba(0, 0, 0, 0.16);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8fc;
  --bg-deep: #edf2f8;
  --surface: rgba(255, 255, 255, 0.90);
  --surface2: #f7f9fc;
  --surface-strong: #ffffff;
  --surface-soft: rgba(18, 37, 63, 0.05);
  --line: rgba(25, 42, 70, 0.12);
  --line-strong: rgba(25, 42, 70, 0.20);
  --text: #122033;
  --text-secondary: #33455d;
  --text-subtle: #68788d;
  --muted: #5f6f84;
  /* Accents used as text need a darker light-theme value for accessible contrast. */
  --blue: #176d8b;
  --accent: #575fca;
  --accent2: #176d8b;
  --indigo: #575fca;
  --violet: #7047b7;
  --mint: #176f59;
  --ok: #176f59;
  --danger: #b53e57;
  --shadow: 0 24px 70px rgba(56, 74, 108, 0.14);
  --shadow-soft: 0 16px 42px rgba(56, 74, 108, 0.10);
}

html {
  background: var(--bg-deep);
}

body {
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--type-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html[data-theme="dark"] body,
html:not([data-theme]) body {
  background:
    radial-gradient(circle at 75% 4%, rgba(117, 135, 255, 0.13), transparent 30rem),
    radial-gradient(circle at 8% 32%, rgba(114, 215, 255, 0.08), transparent 28rem),
    linear-gradient(180deg, #08111f 0%, #091321 52%, #060d18 100%);
}

html[data-theme="light"] body {
  background:
    radial-gradient(circle at 75% 4%, rgba(117, 135, 255, 0.14), transparent 30rem),
    radial-gradient(circle at 8% 32%, rgba(114, 215, 255, 0.12), transparent 28rem),
    linear-gradient(180deg, #f8fbff 0%, #f3f6fb 52%, #edf2f8 100%);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text);
  font-family: var(--font-sans);
  text-wrap: balance;
}

p,
li,
dd,
figcaption,
small {
  text-wrap: pretty;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--blue) 72%, transparent);
  outline-offset: 3px;
}

/* Shared semantic text hierarchy. */
.hero-lead,
.section-heading > p:last-child,
.editorial-hero > p:not(.section-kicker),
.editorial-card p,
.editorial-log-grid p,
.editorial-now-grid p,
.game-card p,
.game-heading p,
.rules-card ol,
.post-card p,
.public-card p,
.public-feed p,
.article-related small {
  color: var(--muted);
}

.eyebrow,
.category,
.section-kicker,
.kicker,
.series-label,
.editorial-card-meta span,
.editorial-card-cta,
.editorial-other {
  color: var(--blue);
}

/* One card/surface language across the public site and Puzzles. */
.visual-card,
.product-card,
.roadmap-card,
.editorial-card,
.editorial-log-grid article,
.editorial-now-grid article,
.game-card,
.metric-card,
.activity-row,
.post-card,
.public-card,
.play-card,
.rules-card,
.article-related a {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.visual-card:hover,
.product-card:hover,
.roadmap-card:hover,
.editorial-card:hover,
.game-card:hover,
.activity-row:hover,
.post-card:hover,
.public-card:hover,
.article-related a:hover {
  border-color: var(--line-strong);
}

/* Consistent editorial typography. */
.editorial-hero h1,
.blog-hero h1,
.article-head h1 {
  font-size: var(--type-display);
  line-height: 0.98;
  letter-spacing: -0.055em;
  font-weight: 800;
}

.section-heading h2,
.manifesto h2,
.editorial-section-head > p,
.stats-section > h2,
.public-feed h2 {
  letter-spacing: -0.04em;
}

.editorial-card h2,
.product-card h3,
.post-card h3,
.public-card h3 {
  font-size: var(--type-card-title);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

/* Reading surface: this is the critical bridge from the legacy Puzzles CSS. */
.article-page {
  width: min(calc(100% - 40px), 980px);
  color: var(--text);
}

.article-head {
  border-bottom-color: var(--line);
}

.article-lead {
  color: var(--muted);
  font-size: var(--type-lead);
}

.article-meta {
  color: var(--text-subtle);
  font-size: var(--type-small);
}

.article-body {
  max-width: var(--reading-max);
}

.article-body h2 {
  color: var(--text);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.12;
}

.article-body h3 {
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.25;
}

.article-body p {
  color: var(--text-secondary);
  font-size: var(--type-body-lg);
  line-height: 1.82;
}

.article-body > p:first-child {
  color: var(--text);
  font-size: 1.15rem;
}

.article-body a {
  color: var(--blue);
  text-decoration-color: color-mix(in srgb, var(--blue) 48%, transparent);
}

.article-body strong,
.article-body b {
  color: var(--text);
}

.article-callout,
.article-figure,
.editorial-visual,
.puzzle-diagram,
.article-flow-step,
.article-stat,
.article-checklist li,
.article-next {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: none;
}

.article-callout span,
.article-figure figcaption,
.article-flow-step span,
.article-stat span,
.article-checklist li,
.article-next span,
.visual-node span {
  color: var(--muted);
}

.article-quote {
  color: var(--text);
  border-left-color: var(--accent);
}

.article-divider,
.article-footer {
  border-color: var(--line);
}

.editorial-visual {
  background:
    radial-gradient(circle at 85% 15%, color-mix(in srgb, var(--blue) 12%, transparent), transparent 35%),
    var(--surface-strong);
}

.visual-node {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
}

.visual-node.accent {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--accent) 13%, var(--surface-strong)),
    color-mix(in srgb, var(--blue) 9%, var(--surface-strong)));
}

/* Common controls use the same dimensions and hierarchy everywhere. */
.button,
.tool-button,
.theme-toggle,
.editorial-switch a,
.editorial-categories a {
  font-family: var(--font-sans);
  font-weight: 750;
}

.status,
.live-pill,
.roadmap-status,
.pill {
  border-color: var(--line);
  color: var(--text-subtle);
  background: var(--surface-soft);
}

html[data-theme="light"] .status-live,
html[data-theme="light"] .live-pill,
html[data-theme="light"] .roadmap-status.active {
  color: var(--mint);
  border-color: color-mix(in srgb, var(--mint) 25%, var(--line));
  background: color-mix(in srgb, var(--mint) 9%, transparent);
}

@media (max-width: 620px) {
  .article-page {
    width: min(calc(100% - 24px), 980px);
  }

  .article-body p {
    font-size: 1rem;
    line-height: 1.76;
  }
}
