/* ==========================================================================
   OverToBot — Global styles
   Fonts, design tokens (dark default + light), reset, typography, layout.
   ========================================================================== */

/* ---------- Self-hosted variable fonts (SIL OFL, see /assets/fonts) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-tight-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
}

/* ---------- Design tokens: premium dark (default) ---------- */
:root {
  color-scheme: dark;

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

  --bg: #060a13;
  --bg-2: #0a101d;
  --bg-3: #0e1626;
  --surface: rgba(148, 176, 214, 0.035);
  --surface-2: rgba(148, 176, 214, 0.06);
  --surface-solid: #0c1322;
  --glass: rgba(10, 16, 29, 0.66);
  --border: rgba(148, 170, 205, 0.12);
  --border-strong: rgba(148, 170, 205, 0.24);

  --text: #eef2f8;
  --text-2: #a9b4c6;
  --text-3: #7a879c;

  --accent: #4cc3ff;
  --accent-2: #2ee6d6;
  --accent-3: #5b7cff;
  --accent-soft: rgba(76, 195, 255, 0.12);
  --accent-line: rgba(76, 195, 255, 0.38);
  --on-accent: #03111c;
  --gradient-accent: linear-gradient(120deg, #5b8cff 0%, #4cc3ff 45%, #2ee6d6 100%);
  --gradient-text: linear-gradient(100deg, #ffffff 10%, #a8dcff 55%, #7ff0e6 100%);

  --success: #3ddc97;
  --danger: #ff7a7a;
  --warning: #ffc861;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 0 1px rgba(76, 195, 255, 0.25), 0 20px 60px -24px rgba(76, 195, 255, 0.35);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --container: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --section-y: clamp(72px, 10vw, 128px);
  --header-h: 76px;
  --header-h-compact: 62px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 240ms;

  --grid-line: rgba(148, 170, 205, 0.055);
  --focus: #7fd6ff;
}

/* ---------- Light theme (optional, remembered via ThemeController) ---------- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f8fb;
  --bg-2: #eef2f7;
  --bg-3: #e6ecf4;
  --surface: rgba(255, 255, 255, 0.8);
  --surface-2: #ffffff;
  --surface-solid: #ffffff;
  --glass: rgba(246, 248, 251, 0.8);
  --border: rgba(15, 30, 60, 0.1);
  --border-strong: rgba(15, 30, 60, 0.2);

  --text: #0a1220;
  --text-2: #445066;
  --text-3: #5f6b80;

  --accent: #0860b8;
  --accent-2: #0a8f86;
  --accent-3: #3452e0;
  --accent-soft: rgba(10, 111, 209, 0.08);
  --accent-line: rgba(10, 111, 209, 0.35);
  --on-accent: #ffffff;
  --gradient-accent: linear-gradient(120deg, #3452e0 0%, #0a6fd1 50%, #0a8f86 100%);
  --gradient-text: linear-gradient(100deg, #0a1220 10%, #0a4f9a 60%, #0a7a72 100%);

  --success: #0f8a5a;
  --danger: #c43131;
  --warning: #7a4d00;

  --shadow-1: 0 1px 2px rgba(15, 30, 60, 0.06);
  --shadow-2: 0 18px 50px -24px rgba(15, 30, 60, 0.25);
  --shadow-glow: 0 0 0 1px rgba(10, 111, 209, 0.2), 0 20px 50px -28px rgba(10, 111, 209, 0.35);

  --grid-line: rgba(15, 30, 60, 0.05);
  --focus: #0860b8;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:where(ul, ol)[role="list"] { list-style: none; margin: 0; padding: 0; }
:where(h1, h2, h3, h4, p, figure, blockquote, dl, dd) { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 0; }

::selection { background: rgba(76, 195, 255, 0.3); color: var(--text); }

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

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--text);
  text-wrap: balance;
}

.display {
  font-size: clamp(2.6rem, 6.4vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 600;
}

h1, .h1 { font-size: clamp(2.3rem, 5vw, 4rem); letter-spacing: -0.035em; }
h2, .h2 { font-size: clamp(1.9rem, 3.6vw, 3rem); letter-spacing: -0.03em; }
h3, .h3 { font-size: clamp(1.15rem, 1.6vw, 1.35rem); line-height: 1.3; letter-spacing: -0.015em; }
h4, .h4 { font-size: 1.05rem; line-height: 1.35; }

p { text-wrap: pretty; }

.lead {
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
  line-height: 1.6;
  color: var(--text-2);
  max-width: 62ch;
}

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.mono { font-family: var(--font-mono); }

.text-gradient {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.8;
}

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--narrow { max-width: calc(820px + var(--gutter) * 2); }
.narrow { max-width: 860px; margin-inline: auto; }
.section--flush { padding-top: clamp(32px, 4vw, 56px) !important; }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }
.section--alt { background: var(--bg-2); border-block: 1px solid var(--border); }
.section + .section:not(.section--alt) { padding-top: calc(var(--section-y) * 0.6); }

.stack > * + * { margin-top: var(--stack, 1.25rem); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--cluster, 12px); align-items: center; }

.grid { display: grid; gap: var(--grid-gap, 20px); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
}
.split--top { align-items: start; }

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

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: 12px; }

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  display: inline-block;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Background texture: faint engineering grid, masked to fade out */
.bg-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 30%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 30%, #000 30%, transparent 75%);
}

/* ---------- Reveal-on-scroll (only when JS is running) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
.js [data-reveal].is-visible { opacity: 1; transform: none; }
/* Safety net: if the app script never starts, reveal content anyway */
.js:not([data-app-ready]) [data-reveal] { animation: reveal-fallback 600ms var(--ease) 2500ms forwards; }
@keyframes reveal-fallback { to { opacity: 1; transform: none; } }

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