/* ==========================================================================
   Apiro — base: tokens, reset, typography, layout, header, footer, buttons
   Palette sampled from the Apiro logo: cyan → azure → royal blue → violet → magenta
   ========================================================================== */

:root {
  --font-display: "Sora", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Brand (from the logo) */
  --cyan: #00e0ff;
  --sky: #0a9dff;
  --blue: #2458f5;
  --royal: #1238e0;
  --violet: #6a1ef2;
  --purple: #9b2cf8;
  --magenta: #e845e0;
  --grad-brand: linear-gradient(120deg, #00d8ff 0%, #1f6bff 34%, #6a1ef2 68%, #f04fe0 100%);
  --grad-button: linear-gradient(120deg, #2458f5 0%, #6a1ef2 100%);
  --grad-text: linear-gradient(95deg, #0a8dff 0%, #3b4cff 38%, #8a2bf2 72%, #d63bd0 100%);

  /* Surfaces & ink — light */
  --bg: #ffffff;
  --bg-soft: #f6f7fc;
  --bg-tint: #eef1fa;
  --surface: #ffffff;
  --surface-2: #f8f9fe;
  --border: #e4e8f2;
  --border-strong: #cdd4e4;
  --ink: #0a0e1a;
  --ink-2: #3b4358;
  --ink-3: #646c86;
  --link: #2451e6;
  --focus: #3b6bff;
  --header-bg: rgba(255, 255, 255, 0.78);
  --glow-a: rgba(0, 216, 255, 0.16);
  --glow-b: rgba(106, 30, 242, 0.12);
  --shadow-sm: 0 1px 2px rgba(10, 14, 26, 0.06);
  --shadow-md: 0 8px 28px -10px rgba(18, 30, 80, 0.2);
  --shadow-lg: 0 28px 70px -24px rgba(30, 40, 120, 0.3);

  /* Code (dark in both themes) */
  --code-bg: #0b1022;
  --code-bar: #0f1630;
  --code-border: #1b2340;
  --code-ink: #d9e0f7;

  /* Risk verdicts & severities */
  --ok: #04704f;
  --ok-bg: #dcf6ea;
  --warn: #8a5300;
  --warn-bg: #fff0c7;
  --high: #ad3d0c;
  --high-bg: #ffe6d4;
  --crit: #c1134b;
  --crit-bg: #ffe2eb;
  --ok-solid: #12b886;
  --warn-solid: #f5b11e;
  --high-solid: #ff7a3d;
  --crit-solid: #f0386b;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --container: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 68px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070a14;
    --bg-soft: #0b1020;
    --bg-tint: #10162b;
    --surface: #0e1427;
    --surface-2: #121931;
    --border: #1d2542;
    --border-strong: #2c3659;
    --ink: #edf1ff;
    --ink-2: #b3bcd8;
    --ink-3: #8a93b2;
    --link: #86abff;
    --focus: #86abff;
    --header-bg: rgba(7, 10, 20, 0.72);
    --glow-a: rgba(0, 216, 255, 0.12);
    --glow-b: rgba(140, 60, 255, 0.16);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 80px -28px rgba(0, 0, 0, 0.8);
    --grad-text: linear-gradient(95deg, #22d3ff 0%, #5b8cff 38%, #a95cff 72%, #f062e0 100%);
    --code-bg: #0a0f1f;
    --code-bar: #0e1429;
    --code-border: #1d2542;
    --ok: #3ddba4;
    --ok-bg: rgba(61, 219, 164, 0.12);
    --warn: #ffc94d;
    --warn-bg: rgba(255, 201, 77, 0.12);
    --high: #ff9a62;
    --high-bg: rgba(255, 154, 98, 0.13);
    --crit: #ff6b93;
    --crit-bg: rgba(255, 107, 147, 0.14);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #070a14;
  --bg-soft: #0b1020;
  --bg-tint: #10162b;
  --surface: #0e1427;
  --surface-2: #121931;
  --border: #1d2542;
  --border-strong: #2c3659;
  --ink: #edf1ff;
  --ink-2: #b3bcd8;
  --ink-3: #8a93b2;
  --link: #86abff;
  --focus: #86abff;
  --header-bg: rgba(7, 10, 20, 0.72);
  --glow-a: rgba(0, 216, 255, 0.12);
  --glow-b: rgba(140, 60, 255, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 30px 80px -28px rgba(0, 0, 0, 0.8);
  --grad-text: linear-gradient(95deg, #22d3ff 0%, #5b8cff 38%, #a95cff 72%, #f062e0 100%);
  --code-bg: #0a0f1f;
  --code-bar: #0e1429;
  --code-border: #1d2542;
  --ok: #3ddba4;
  --ok-bg: rgba(61, 219, 164, 0.12);
  --warn: #ffc94d;
  --warn-bg: rgba(255, 201, 77, 0.12);
  --high: #ff9a62;
  --high-bg: rgba(255, 154, 98, 0.13);
  --crit: #ff6b93;
  --crit-bg: rgba(255, 107, 147, 0.14);
  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 20px); }
body, h1, h2, h3, h4, h5, p, ul, ol, figure, blockquote, dl, dd, pre { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 700;
  text-wrap: balance;
}
h1 { font-size: clamp(2.3rem, 5.6vw, 4.25rem); letter-spacing: -0.035em; }
h2 { font-size: clamp(1.8rem, 3.6vw, 2.75rem); }
h3 { font-size: clamp(1.15rem, 1.6vw, 1.35rem); letter-spacing: -0.015em; line-height: 1.3; }
h4 { font-size: 1rem; letter-spacing: -0.01em; line-height: 1.35; }
p { text-wrap: pretty; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 600; color: var(--ink); }

code, kbd, samp { font-family: var(--font-mono); font-size: 0.88em; }
:not(pre) > code {
  padding: 0.12em 0.4em;
  border-radius: 6px;
  background: var(--bg-tint);
  border: 1px solid var(--border);
  color: var(--ink);
  white-space: nowrap;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-brand);
}
.lead { font-size: clamp(1.05rem, 1.5vw, 1.2rem); color: var(--ink-2); line-height: 1.65; }
.muted { color: var(--ink-3); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

.gradient-text {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.container-narrow { max-width: 860px; }
.section { padding-block: clamp(64px, 9vw, 120px); position: relative; }
.section-soft { background: var(--bg-soft); border-block: 1px solid var(--border); }
.section-head { max-width: 760px; margin-bottom: clamp(36px, 5vw, 56px); }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head.center .eyebrow { justify-content: center; }
.section-head h2 { margin-top: 14px; }
.section-head .lead { margin-top: 16px; }
.stack > * + * { margin-top: 1rem; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 46px;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  min-height: var(--btn-h);
  padding: 0 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 0.95rem; font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-sm { --btn-h: 38px; padding: 0 1rem; font-size: 0.875rem; }
.btn-lg { --btn-h: 54px; padding: 0 1.6rem; font-size: 1rem; }
.btn-primary {
  color: #fff;
  background: var(--grad-button);
  box-shadow: 0 8px 22px -10px rgba(60, 50, 240, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover { box-shadow: 0 12px 28px -10px rgba(60, 50, 240, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.22); transform: translateY(-1px); }
.btn-secondary { color: var(--ink); background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--ink-3); }
.btn-ghost { color: var(--ink-2); background: transparent; }
.btn-ghost:hover { color: var(--ink); background: var(--bg-tint); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.link-arrow {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-weight: 600; text-decoration: none; color: var(--link);
}
.link-arrow::after { content: "→"; transition: transform 0.2s ease; }
.link-arrow:hover::after { transform: translateX(3px); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--border); }
.header-inner { height: 100%; display: flex; align-items: center; gap: 28px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.brand-mark { width: 36px; height: 30px; }
.brand-wordmark { width: 86px; height: 18px; color: var(--ink); }

.site-nav { display: flex; align-items: center; gap: 28px; margin-left: auto; }
.site-nav ul { display: flex; align-items: center; gap: 4px; list-style: none; padding: 0; margin: 0; }
.site-nav a:not(.btn) {
  display: block; padding: 8px 12px; border-radius: 999px;
  color: var(--ink-2); font-size: 0.925rem; font-weight: 500; text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.site-nav a:not(.btn):hover { color: var(--ink); background: var(--bg-tint); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--bg-tint); }
.nav-cta { display: none; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.nav-toggle { display: none; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 940px) {
  .nav-toggle { display: inline-grid; }
  .header-cta { display: none; }
  .header-actions { margin-left: auto; }
  .site-nav {
    position: absolute; inset: var(--header-h) 0 auto 0;
    display: none; flex-direction: column; align-items: stretch; gap: 12px;
    margin: 0; padding: 12px var(--gutter) 22px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  .site-nav.is-open { display: flex; }
  .site-nav ul { flex-direction: column; align-items: stretch; }
  .site-nav a:not(.btn) { padding: 12px 10px; font-size: 1rem; border-radius: var(--radius-sm); }
  .nav-cta { display: inline-flex; }
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding-block: 56px 32px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 40px; }
.footer-brand p { margin-top: 14px; max-width: 34ch; color: var(--ink-2); font-size: 0.95rem; }
.footer-col h2 {
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
}
.footer-col ul { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.footer-col a { color: var(--ink-2); text-decoration: none; font-size: 0.95rem; }
.footer-col a:hover { color: var(--ink); text-decoration: underline; }
.footer-base {
  margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px;
  color: var(--ink-3); font-size: 0.85rem;
}
@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

/* ---------- Motion ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
/* If main.js never runs, don't leave content invisible */
.js:not(.reveal-ready) .reveal { animation: reveal-fallback 0.01s 2s forwards; }
@keyframes reveal-fallback { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}
