/* CrestIron — design system tokens & base styles */

:root {
  /* surfaces */
  --bg: #07090f;
  --bg-elevated: #0a0d14;
  --surface-0: #0d1117;
  --surface-1: #14191f;
  --surface-2: #1c2129;
  --surface-hover: #181d24;

  /* borders */
  --border-subtle: #161c26;
  --border: #232b39;
  --border-strong: #2e3a4c;

  /* text */
  --text-primary: #e8edf5;
  --text-secondary: #8b95a8;
  --text-muted: #5b6478;
  --text-dim: #404a5c;

  /* accent */
  --accent: #4a7fff;
  --accent-hover: #6090ff;
  --accent-dim: rgba(74, 127, 255, 0.12);
  --accent-border: rgba(74, 127, 255, 0.35);

  /* semantic */
  --warn: #d4a040;
  --warn-dim: rgba(212, 160, 64, 0.12);
  --risk: #d96370;
  --risk-dim: rgba(217, 99, 112, 0.12);
  --ok: #5fb086;
  --ok-dim: rgba(95, 176, 134, 0.12);

  /* type */
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", "Menlo", monospace;

  /* layout */
  --maxw: 1280px;
  --pad-x: 32px;
  --nav-h: 64px;

  /* radii */
  --r-1: 3px;
  --r-2: 6px;
  --r-3: 10px;

  /* focus */
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; overflow-x: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

::selection { background: var(--accent-dim); color: var(--text-primary); }

/* focus rings — strong, visible (508/WCAG) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-1);
}

/* 508 / a11y mode overrides */
body.a11y-508 {
  --text-secondary: #b8c2d4;
  --text-muted: #8993a8;
  --border: #3a4458;
  --border-strong: #4a5468;
  font-size: 17px;
}
body.a11y-508 * {
  transition: none !important;
  animation-duration: 0.01ms !important;
}
body.a11y-508 :focus-visible {
  outline: 3px solid #ffd84d;
  outline-offset: 3px;
}

/* layout primitives */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad-x); }
.wrap-wide { max-width: 1440px; margin: 0 auto; padding: 0 var(--pad-x); }

/* section spacing */
.section { padding: 96px 0; border-top: 1px solid var(--border-subtle); }
.section-tight { padding: 64px 0; border-top: 1px solid var(--border-subtle); }
.section:first-child, .section-tight:first-child { border-top: 0; }

/* type helpers */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.eyebrow-accent { color: var(--accent); }

.h-display {
  font-size: clamp(44px, 6.2vw, 76px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-weight: 400;
  margin: 0;
}
.h-display em {
  font-style: normal;
  color: var(--text-secondary);
}

.h1 {
  font-size: clamp(36px, 4.5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.022em;
  font-weight: 400;
  margin: 0;
}
.h2 {
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.018em;
  font-weight: 400;
  margin: 0;
}
.h3 {
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.012em;
  font-weight: 500;
  margin: 0;
}
.h4 {
  font-size: 17px;
  line-height: 1.3;
  font-weight: 500;
  margin: 0;
}

.lead {
  font-size: 18px;
  line-height: 1.55;
  color: var(--text-secondary);
  letter-spacing: -0.005em;
  max-width: 60ch;
}
.body { font-size: 15px; line-height: 1.6; color: var(--text-secondary); }
.body-sm { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.01em; }
.mono-sm { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: var(--r-2);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--surface-0);
}
.btn-secondary:hover { border-color: var(--text-muted); background: var(--surface-1); }
.btn-ghost { color: var(--text-secondary); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-1); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 13px 20px; font-size: 15px; }

/* card */
.card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
}
.card-flat {
  background: var(--surface-0);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2);
}
.card-hover {
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.card-hover:hover { border-color: var(--border-strong); background: var(--surface-1); }

/* pill / chip */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--surface-0);
  line-height: 1;
}
.pill-accent { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }
.pill-warn { color: var(--warn); border-color: rgba(212,160,64,0.35); background: var(--warn-dim); }
.pill-risk { color: var(--risk); border-color: rgba(217,99,112,0.35); background: var(--risk-dim); }
.pill-ok { color: var(--ok); border-color: rgba(95,176,134,0.35); background: var(--ok-dim); }
.pill-dim { color: var(--text-muted); }

/* status dot */
.dot { display:inline-block; width:6px; height:6px; border-radius:50%; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-dim); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-dim); }
.dot-risk { background: var(--risk); box-shadow: 0 0 0 3px var(--risk-dim); }
.dot-dim { background: var(--text-dim); }

/* divider */
.div-h { border: 0; border-top: 1px solid var(--border-subtle); margin: 24px 0; }
.div-v { width: 1px; background: var(--border-subtle); align-self: stretch; }

/* form */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  color: var(--text-primary);
  font: inherit;
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  background: var(--surface-1);
}
.field textarea { min-height: 100px; resize: vertical; }

/* grid */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* flex helpers */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.center { justify-content: center; align-items: center; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }

/* hairline grid background (used on hero) */
.gridlines {
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: 0 0;
}

/* skip-link for 508 */
.skip-link {
  position: absolute;
  left: -10000px;
  top: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--r-2);
  z-index: 9999;
  font-weight: 500;
}
.skip-link:focus { left: 16px; }

/* page enter */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page-enter { animation: fadeUp 320ms cubic-bezier(0.2, 0.6, 0.2, 1); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1.4s linear infinite; }

/* progress bar */
.bar { height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; position: relative; }
.bar > div { height: 100%; background: var(--accent); transition: width 400ms cubic-bezier(0.2, 0.6, 0.2, 1); }
.bar-warn > div { background: var(--warn); }
.bar-risk > div { background: var(--risk); }
.bar-ok > div { background: var(--ok); }

/* sub-nav */
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border-subtle); padding: 0 var(--pad-x); }
.subnav button {
  background: transparent; border: 0; color: var(--text-muted);
  padding: 14px 16px; font-size: 13px; font-weight: 500; letter-spacing: -0.005em;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 120ms;
}
.subnav button:hover { color: var(--text-primary); }
.subnav button.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* code-ish block */
.codeblock {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2);
  padding: 16px 20px;
  color: var(--text-secondary);
  overflow-x: auto;
}

/* table */
.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th, .t td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.t th {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  background: var(--bg-elevated);
}
.t tbody tr:hover { background: var(--surface-0); }
.t td.mono-cell { font-family: var(--font-mono); color: var(--text-secondary); }

/* responsive foundations */
img, svg, video, canvas { max-width: 100%; }
img { height: auto; }

.subnav {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.subnav button { white-space: nowrap; flex: 0 0 auto; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.t { min-width: 680px; }

@media (max-width: 900px) {
  :root { --pad-x: 24px; }
  .section { padding: 72px 0; }
  .section-tight { padding: 48px 0; }
  .grid { gap: 20px; }
}

@media (max-width: 760px) {
  :root { --pad-x: 20px; --nav-h: 60px; }
  html, body { font-size: 14px; }
  .h-display { font-size: clamp(34px, 11vw, 48px); line-height: 1.06; }
  .h1 { font-size: clamp(30px, 9vw, 40px); }
  .h2 { font-size: clamp(25px, 7vw, 34px); }
  .h3 { font-size: 20px; }
  .lead { font-size: 16px; line-height: 1.58; }
  .section { padding: 56px 0; }
  .section-tight { padding: 40px 0; }
  .row { flex-wrap: wrap; }
  .btn-lg { padding: 12px 16px; }
  .cta-grid, .cta-grid-2 { padding: 32px 24px !important; gap: 24px !important; }
  .ol-hero, .rg-hero { gap: 32px !important; }
  .ol-hero > .card, .rg-hero > .card { flex-direction: column; align-items: flex-start !important; }
  .ps-grid { padding: 20px !important; gap: 20px !important; }
  .contact-grid > .card { padding: 24px !important; }
}

@media (max-width: 520px) {
  :root { --pad-x: 16px; --nav-h: 56px; }
  .wrap, .wrap-wide { padding-left: var(--pad-x); padding-right: var(--pad-x); }
  .section { padding: 44px 0; }
  .section-tight { padding: 32px 0; }
  .btn { width: 100%; justify-content: center; white-space: normal; }
  .pill { white-space: normal; line-height: 1.25; }
  .subnav { padding-left: var(--pad-x); padding-right: var(--pad-x); }
  .subnav button { padding: 12px 10px; }
  .codeblock { padding: 14px; font-size: 11px; }
  .t th, .t td { padding: 10px 12px; }
}
.card:has(.t) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
