/* raccha.ai — shared design tokens, nav, footer, and base components.
   Marketing page layout lives in marketing.css. */

:root {
  /* Ground — warm paper, not clinical white */
  --bg: #f8f8f6;
  --bg-alt: #f0efea;
  --surface: #ffffff;
  --surface-2: #f4f3ef;
  --border: #e5e4df;
  --border-bright: #cfcec6;

  /* Text */
  --text: #121214;
  --text-muted: #4a4a50;
  --text-dim: #71717a;

  /* Accent — Continuous.Engineering indigo, slightly desaturated for editorial */
  --accent: #4f46e5;
  --accent-bright: #3730a3;
  --accent-glow: rgba(79, 70, 229, 0.10);

  /* Functional status */
  --live: #166534;
  --live-bg: #dcfce7;
  --live-soft: #f0fdf4;

  --caution: #b45309;
  --caution-bg: #fef3c7;
  --caution-soft: #fffbeb;

  --error: #991b1b;
  --error-bg: #fee2e2;
  --error-soft: #fef2f2;

  /* Heritage hint — only for CE lineage moments */
  --heritage: #9a3412;

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Type scale */
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-hero: clamp(2.75rem, 6vw, 4.5rem);

  /* Spacing (8px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 80px;
  --space-10: 100px;

  /* Layout */
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --container: 1120px;
  --container-dash: 980px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

section[id] { scroll-margin-top: 80px; }

@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;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1 0 auto; }

img, svg { display: block; max-width: 100%; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-bright); text-decoration: underline; }

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

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -60px;
  z-index: 1000;
  background: var(--text);
  color: #fff;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: var(--space-4); }

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

/* Grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.018;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

@media (max-width: 560px) {
  .container { padding: 0 var(--space-4); }
}

/* Navigation */
nav.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 248, 246, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(229, 228, 223, 0.7);
}

nav.topbar .nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  min-height: 68px;
}

nav.topbar .word {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

nav.topbar .word span { color: var(--accent); }

nav.topbar .links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 15px;
  font-weight: 500;
}

nav.topbar .links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, background 0.15s ease;
}

nav.topbar .links a:hover {
  color: var(--text);
  background: var(--surface-2);
}

nav.topbar .links a[aria-current="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-bright);
}

/* Nav dropdown groups */
nav.topbar .nav-group {
  position: relative;
}

nav.topbar .nav-group-title {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  padding-right: calc(var(--space-3) + 14px);
  border-radius: var(--radius-sm);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease;
}

nav.topbar .nav-group-title::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-60%) rotate(45deg);
  transition: transform 0.15s ease;
}

nav.topbar .nav-group-title:hover,
nav.topbar .nav-group-title[aria-expanded="true"] {
  color: var(--text);
  background: var(--surface-2);
}

nav.topbar .nav-group-title[aria-expanded="true"]::after {
  transform: translateY(-40%) rotate(-135deg);
}

nav.topbar .nav-group-links {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  min-width: 200px;
  padding: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
  z-index: 101;
}

nav.topbar .nav-group-links::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 0;
  right: 0;
  height: 9px;
}

nav.topbar .nav-group-title[aria-expanded="true"] + .nav-group-links {
  display: flex;
}

nav.topbar .nav-group-links a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

nav.topbar .menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

nav.topbar .menu-toggle[aria-expanded="true"] {
  background: var(--surface-2);
  border-color: var(--accent);
}

@media (max-width: 767px) {
  nav.topbar .menu-toggle { display: inline-flex; }
  nav.topbar .links {
    display: none;
    position: fixed;
    inset: 68px 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1);
    padding: var(--space-4) var(--space-5) var(--space-6);
    background: rgba(248, 248, 246, 0.98);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    max-height: calc(100vh - 68px);
    overflow-y: auto;
  }
  nav.topbar .links.open { display: flex; }
  nav.topbar .links a {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
  }
  nav.topbar .nav-group-title {
    width: 100%;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
  }
  nav.topbar .nav-group-title::after {
    position: static;
    transform: translateY(-20%) rotate(45deg);
  }
  nav.topbar .nav-group-title[aria-expanded="true"]::after {
    transform: translateY(0) rotate(-135deg);
  }
  nav.topbar .nav-group-links {
    position: static;
    transform: none;
    display: none;
    box-shadow: none;
    border: none;
    background: transparent;
    padding: 0 0 0 var(--space-3);
    min-width: auto;
  }
  nav.topbar .nav-group-title[aria-expanded="true"] + .nav-group-links {
    display: flex;
  }
  nav.topbar .nav-group-links::before { display: none; }
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-7) 0 var(--space-6);
  background: var(--surface);
}

.footer-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1.5fr repeat(5, 1fr);
  align-items: start;
}

.footer-brand .footer-word {
  font-weight: 700;
  color: var(--text);
}

.footer-brand p {
  color: var(--text-dim);
  font-size: 15px;
  margin: var(--space-1) 0 0;
}

.footer-col h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 var(--space-2);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.footer-col a {
  color: var(--text-dim);
  font-size: 15px;
  text-decoration: none;
}

.footer-col a:hover { color: var(--accent); text-decoration: underline; }

@media (max-width: 900px) {
  .footer-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  border: none;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-bright);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-bright);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .btn:hover { transform: none; }
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.card--border-accent:hover { border-color: var(--accent); }

/* Badges */
.badge {
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 6px;
  padding: 3px 8px;
  flex-shrink: 0;
}

.badge--live { color: var(--live); background: var(--live-bg); }
.badge--caution { color: var(--caution); background: var(--caution-bg); }
.badge--error { color: var(--error); background: var(--error-bg); }

/* Section label / title */
.section-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin: 0 0 var(--space-3);
}

.section-title {
  font-size: clamp(1.75rem, 3.2vw, 2.25rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-5);
  letter-spacing: -0.02em;
}

/* Code block */
.code-block {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  background: var(--text);
  color: #f2ead9;
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  overflow-x: auto;
}

/* Form basics */
input, select, textarea, button {
  font: inherit;
}

/* Reduced-motion helper */
@media (prefers-reduced-motion: reduce) {
  .reveal { transition: none !important; opacity: 1 !important; transform: none !important; }
}
