/* ============================================
   APCOT 2028 — Shared design system
   ============================================ */

:root {
  /* Palette (default: deep navy) — overridden by Tweaks */
  --bg: #06132b;
  --bg-elev: #0b2545;
  --bg-elev-2: #11315c;
  --fg: #eef4ff;
  --fg-muted: #8aa2c8;
  --fg-dim: #5a6f93;
  --line: #1a3358;
  --line-strong: #2d4f80;
  --accent: #4ca7ff;
  --accent-warm: #ff9a55;
  --accent-soft: rgba(76, 167, 255, 0.14);

  /* Type */
  --font-display: "Newsreader", ui-serif, Georgia, serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Density */
  --space-unit: 8px;
  --section-py: 120px;
  --container-px: 48px;
  --container-max: 1320px;

  /* Motif (accent shape) */
  --motif: "dots"; /* dots | chip | none */
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(76,167,255,0.10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.55;
  color: var(--fg);
}

/* ---------- Typography ---------- */
.serif { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.01em; }
.mono  { font-family: var(--font-mono); }
.label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-wrap: balance;
}
h1 { font-size: clamp(48px, 7vw, 104px); }
h2 { font-size: clamp(36px, 4.6vw, 64px); }
h3 { font-size: clamp(24px, 2.4vw, 32px); letter-spacing: -0.015em; }
h4 { font-size: 20px; letter-spacing: -0.01em; }
p  { margin: 0; text-wrap: pretty; }

a { color: inherit; text-decoration: none; }
a.link {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
  transition: border-color .2s ease;
}
a.link:hover { border-color: var(--accent); }

/* ---------- Layout ---------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: var(--container-px);
  padding-right: var(--container-px);
}
section { padding: var(--section-py) 0; position: relative; }
.section-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 48px;
  align-items: baseline;
  margin-bottom: 72px;
}
.section-head .marker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
}
.section-head .title { max-width: 900px; }
.section-head .title h2 { margin-bottom: 16px; }
.section-head .title p { color: var(--fg-muted); font-size: 18px; max-width: 720px; }

@media (max-width: 800px) {
  .section-head { grid-template-columns: 1fr; gap: 16px; margin-bottom: 48px; }
  :root { --section-py: 80px; --container-px: 24px; }
}

/* ---------- Header / Nav ---------- */
.top {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  display: flex; align-items: center; gap: 32px;
  height: 68px;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: var(--container-px);
  padding-right: var(--container-px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark { width: 28px; height: 28px; }
.brand .wordmark {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.18em;
  color: var(--fg);
}
.brand .wordmark .y { color: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--fg-muted);
  transition: color .2s, background .2s;
}
.nav a:hover { color: var(--fg); background: var(--bg-elev); }
.nav a.active { color: var(--fg); background: var(--bg-elev); }
.nav .cta {
  margin-left: 12px;
  font-size: 12px;
  background: var(--accent);
  color: #06132b;
  padding: 10px 16px;
  font-weight: 600;
}
.nav .cta:hover { background: color-mix(in oklab, var(--accent) 85%, white); color: #06132b; }

.scroll-progress {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-warm));
  width: 0%; transition: width 0.05s linear;
}

/* Mobile nav */
.menu-btn { display: none; background: none; border: 0; color: var(--fg); cursor: pointer; }
@media (max-width: 960px) {
  .nav { display: none; }
  .menu-btn { display: block; margin-left: auto; }
  .nav.open {
    display: flex; flex-direction: column; align-items: stretch;
    position: absolute; top: 68px; left: 0; right: 0;
    background: var(--bg-elev); padding: 16px;
    border-bottom: 1px solid var(--line);
  }
  .nav.open a { padding: 14px; border-radius: 8px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .2s, color .2s, border-color .2s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #06132b; font-weight: 600; }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 85%, white); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--fg); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 32px;
  transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--line-strong); }

/* ---------- Footer ---------- */
.foot {
  border-top: 1px solid var(--line);
  padding: 80px 0 40px;
  margin-top: 80px;
  background:
    linear-gradient(to bottom, transparent, rgba(11,37,69,0.4));
}
.foot-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 64px;
}
.foot-grid h5 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}
.foot-grid ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.foot-grid a { color: var(--fg-muted); font-size: 15px; }
.foot-grid a:hover { color: var(--fg); }
.foot-bottom {
  border-top: 1px solid var(--line);
  padding-top: 24px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fg-dim);
}
@media (max-width: 800px) {
  .foot-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .foot-bottom { flex-direction: column; gap: 12px; }
}

/* ---------- Motif: dot grid background ---------- */
.dotgrid {
  background-image: radial-gradient(rgba(76,167,255,0.18) 1px, transparent 1px);
  background-size: 28px 28px;
}
.chip-rule {
  height: 1px; background: var(--line); position: relative;
}
.chip-rule::before, .chip-rule::after {
  content: ""; position: absolute; top: -3px; width: 7px; height: 7px;
  background: var(--accent);
}
.chip-rule::before { left: 0; }
.chip-rule::after  { right: 0; }

/* ---------- Utility ---------- */
.muted { color: var(--fg-muted); }
.dim   { color: var(--fg-dim); }
.stack > * + * { margin-top: 16px; }
.hide-mobile { }
@media (max-width: 800px) { .hide-mobile { display: none; } }
.fade-in { opacity: 0; transform: translateY(12px); transition: opacity .8s ease, transform .8s ease; }
.fade-in.show { opacity: 1; transform: none; }

/* ---------- Density modes ---------- */
html[data-density="airy"] {
  --section-py: 160px;
  --container-px: 64px;
}
html[data-density="compact"] {
  --section-py: 80px;
  --container-px: 32px;
}

/* ---------- Accent shape: chip motif ---------- */
html[data-motif="none"] .motif-bg { background-image: none !important; }
html[data-motif="chip"] .motif-bg {
  background-image:
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    linear-gradient(0deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.5;
}

/* ---------- Color palettes ---------- */
html[data-palette="navy"] {
  --bg: #06132b; --bg-elev: #0b2545; --bg-elev-2: #11315c;
  --fg: #eef4ff; --fg-muted: #8aa2c8; --fg-dim: #5a6f93;
  --line: #1a3358; --line-strong: #2d4f80;
  --accent: #4ca7ff; --accent-warm: #ff9a55;
}
html[data-palette="forest"] {
  --bg: #06180f; --bg-elev: #0d2a1c; --bg-elev-2: #134029;
  --fg: #ecf6ef; --fg-muted: #8ab59d; --fg-dim: #527765;
  --line: #1f3a2b; --line-strong: #355a44;
  --accent: #59d18d; --accent-warm: #f0b35e;
}
html[data-palette="ember"] {
  --bg: #150806; --bg-elev: #2a1310; --bg-elev-2: #3d1c17;
  --fg: #f7ece6; --fg-muted: #c9a695; --fg-dim: #8c6c5e;
  --line: #3a201a; --line-strong: #5a3128;
  --accent: #ff7849; --accent-warm: #ffc857;
}
html[data-palette="paper"] {
  --bg: #f6f4ef; --bg-elev: #ffffff; --bg-elev-2: #ebe7df;
  --fg: #11151c; --fg-muted: #4f5a6b; --fg-dim: #8590a3;
  --line: #d9d4c8; --line-strong: #b9b2a1;
  --accent: #2a6fdb; --accent-warm: #c2410c;
}
html[data-palette="paper"] body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(42,111,219,0.07), transparent 60%),
    var(--bg);
}
html[data-palette="paper"] .nav .cta { color: white; }
html[data-palette="paper"] .btn-primary { color: white; }
html[data-palette="paper"] .dotgrid {
  background-image: radial-gradient(rgba(17,21,28,0.16) 1px, transparent 1px);
}

/* Font pairings */
html[data-fontpair="plex"] {
  --font-display: "Newsreader", ui-serif, Georgia, serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}
html[data-fontpair="grotesk"] {
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
html[data-fontpair="editorial"] {
  --font-display: "Cormorant Garamond", ui-serif, Georgia, serif;
  --font-body: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
html[data-fontpair="grot-serif"] {
  --font-display: "DM Serif Display", ui-serif, Georgia, serif;
  --font-body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
}

/* Selection */
::selection { background: var(--accent); color: var(--bg); }

/* ---------- Decorative overlays — hide on narrow screens ---------- */
@media (max-width: 900px) {
  .label-strip,
  .crosshair { display: none !important; }
}

/* ---------- Page hero — mobile (section.page-hero beats per-page .page-hero specificity) ---------- */
@media (max-width: 800px) {
  section.page-hero { padding: 40px 0 22px; }
  section.page-hero h1 { font-size: clamp(26px, 7vw, 48px) !important; margin: 12px 0 16px !important; }
  section.page-hero .lead { font-size: 14px !important; line-height: 1.5; }
  .crumb { font-size: 10px; }
  section { padding: var(--section-py, 56px) 0; }
  .section-head { margin-bottom: 28px; }
  .section-head h2 { font-size: clamp(20px, 5vw, 32px); }
  .section-head p { font-size: 13px; }
}

/* ---------- Extra-small screens (≤480px) ---------- */
@media (max-width: 480px) {
  :root { --container-px: 16px; --section-py: 48px; }
  .foot-grid { grid-template-columns: 1fr; gap: 24px; }
  .foot-bottom { font-size: 10px; }
  .btn { padding: 10px 14px; font-size: 11px; }
  h3 { font-size: clamp(17px, 4.5vw, 24px); }
}
