/*
 * StratCon Solutions — design system tokens
 * Loaded as `inter-font` (historical name retained; now carries the full token system).
 * Fonts are loaded via <link> in layouts/landing.html.erb + application.html.erb + admin.html.erb.
 *
 * Palette: OKLCH, perceptually uniform. Warm-neutral near-whites, warm inks, StratCon-blue accent.
 * Type: Source Serif 4 (display), Inter Tight (body/UI), JetBrains Mono (numeric/code).
 * See .impeccable.md for the full rationale.
 *
 * Tokens are mirrored in stratcon-web/assets/stratcon.css and config/tailwind.config.js
 * — keep all three in sync.
 */

:root {
  /* ————————————————————————————————————————— surfaces */
  --surface-0: oklch(0.985 0.003 78);     /* page background — warm-neutral paper */
  --surface-1: oklch(0.97  0.004 78);     /* raised panel / card */
  --surface-2: oklch(0.945 0.006 78);     /* sunken / muted / code */
  --surface-inv: oklch(0.18 0.012 60);    /* inverted panels (rare) */

  /* ————————————————————————————————————————— ink (text) */
  --ink-900: oklch(0.185 0.012 60);       /* headlines, primary */
  --ink-700: oklch(0.35  0.010 60);       /* body */
  --ink-500: oklch(0.52  0.008 60);       /* secondary / meta */
  --ink-300: oklch(0.74  0.006 60);       /* tertiary / disabled */

  /* ————————————————————————————————————————— lines (hairlines only) */
  --line:         oklch(0.89 0.008 60);
  --line-strong:  oklch(0.78 0.008 60);

  /* ————————————————————————————————————————— accent (StratCon blue, from the wordmark #2f6df0) */
  --accent:       oklch(0.55 0.18 262);
  --accent-hover: oklch(0.50 0.19 262);
  --accent-ink:   oklch(0.39 0.15 262);   /* for accent text on surface */
  --accent-soft:  oklch(0.955 0.02 258);  /* accent-tinted surface */
  --accent-line:  oklch(0.87 0.05 258);   /* accent-tinted hairline */

  /* ————————————————————————————————————————— semantic */
  --ok:       oklch(0.50 0.08 150);
  --ok-soft:  oklch(0.96 0.02 150);
  --warn:     oklch(0.62 0.13 80);
  --warn-soft:oklch(0.96 0.035 80);
  --bad:      oklch(0.50 0.16 28);
  --bad-soft: oklch(0.96 0.03 28);

  /* ————————————————————————————————————————— spacing (4pt base) */
  --space-xs:  0.25rem;   /*  4 */
  --space-sm:  0.5rem;    /*  8 */
  --space-md:  0.75rem;   /* 12 */
  --space-lg:  1rem;      /* 16 */
  --space-xl:  1.5rem;    /* 24 */
  --space-2xl: 2rem;      /* 32 */
  --space-3xl: 3rem;      /* 48 */
  --space-4xl: 4rem;      /* 64 */
  --space-5xl: 6rem;      /* 96 */
  --space-6xl: 8rem;      /* 128 */

  /* ————————————————————————————————————————— radius (restrained) */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 9999px;

  /* ————————————————————————————————————————— motion */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo:  cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-base: 220ms;
  --dur-slow: 360ms;

  /* ————————————————————————————————————————— type */
  --font-display: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-body:    "Inter Tight", system-ui, -apple-system, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ————————————————————————————————————————— base */
html {
  background: var(--surface-0);
  color: var(--ink-700);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11"; /* Inter Tight stylistic sets */
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--surface-0);
  color: var(--ink-700);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

/* Headings: Source Serif 4, display optical size at > 2rem. */
h1, h2, h3, h4, h5, h6,
.serif {
  font-family: var(--font-display);
  font-weight: 420;                           /* variable weight, editorial restraint */
  font-variation-settings: "opsz" 36;         /* use display optical size by default */
  color: var(--ink-900);
  letter-spacing: -0.018em;
  line-height: 1.08;
}

h1 { font-size: clamp(2.5rem, 2rem + 3vw, 4.5rem); line-height: 1.02; letter-spacing: -0.025em; }
h2 { font-size: clamp(1.875rem, 1.5rem + 1.5vw, 3rem); }
h3 { font-size: clamp(1.375rem, 1.2rem + 0.6vw, 1.75rem); line-height: 1.15; }
h4 { font-size: 1.125rem; line-height: 1.25; letter-spacing: -0.01em; }

/* Small headings use text optical size — more legible at small sizes */
h4, h5, h6 {
  font-variation-settings: "opsz" 10;
}

/* Eyebrows / small-caps labels */
.eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-500);
}

/* Tabular numerics — use on any number-heavy surface */
.num, .tnum {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  letter-spacing: -0.01em;
}

/* Links default: subtle underline, accent on hover */
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out-quart);
}

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

/* ————————————————————————————————————————— selection */
::selection {
  background: var(--accent-soft);
  color: var(--ink-900);
}

/* ————————————————————————————————————————— native form reset (minimal) */
input, textarea, select, button {
  font-family: inherit;
  color: inherit;
}

button { cursor: pointer; }

/* ————————————————————————————————————————— utility classes
   Small, reusable, not worth Tailwinding. */

.hairline-t { border-top: 1px solid var(--line); }
.hairline-b { border-bottom: 1px solid var(--line); }
.hairline-l { border-left: 1px solid var(--line); }
.hairline-r { border-right: 1px solid var(--line); }
.hairline   { border: 1px solid var(--line); }

/* Staggered entry — used sparingly on hero */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rise       { animation: rise-in 520ms var(--ease-out-quart) both; }
.rise-1     { animation-delay: 0ms; }
.rise-2     { animation-delay: 40ms; }
.rise-3     { animation-delay: 80ms; }
.rise-4     { animation-delay: 120ms; }
.rise-5     { animation-delay: 160ms; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ————————————————————————————————————————— form controls (global)
   A single input style across the app. Overridden per-surface where needed. */

.field {
  display: block;
  width: 100%;
  background: var(--surface-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: 0.9375rem;
  color: var(--ink-900);
  line-height: 1.4;
  transition: border-color var(--dur-fast) var(--ease-out-quart),
              background var(--dur-fast) var(--ease-out-quart);
}

.field:hover { border-color: var(--line-strong); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--ink-300); }

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
  margin-bottom: 0.375rem;
}

.field-help { font-size: 0.8125rem; color: var(--ink-500); margin-top: 0.375rem; }
.field-error { font-size: 0.8125rem; color: var(--bad); margin-top: 0.375rem; }

/* ————————————————————————————————————————— button system
   Two tiers: primary (accent), secondary (ink outline).
   A third, .btn-ghost, for tertiary actions. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1;
  padding: 0.7rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out-quart),
              color var(--dur-fast) var(--ease-out-quart),
              border-color var(--dur-fast) var(--ease-out-quart);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--surface-0);
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--ink-900);
  border-color: var(--line-strong);
}
.btn-secondary:hover { border-color: var(--ink-900); }

.btn-ghost {
  background: transparent;
  color: var(--ink-700);
  border-color: transparent;
  padding: 0.5rem 0.75rem;
}
.btn-ghost:hover { color: var(--ink-900); background: var(--surface-1); }

.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: var(--bad);
}
.btn-danger:hover { background: var(--bad); color: var(--surface-0); }

.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.9rem 1.4rem; font-size: 1rem; }

/* ————————————————————————————————————————— badge (status pills) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-0);
  color: var(--ink-700);
}
.badge-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--ink-500); }
.badge--ok    { border-color: color-mix(in oklch, var(--ok) 35%, var(--line)); color: var(--ok); }
.badge--ok    .badge-dot { background: var(--ok); }
.badge--warn  { border-color: color-mix(in oklch, var(--warn) 35%, var(--line)); color: var(--warn); }
.badge--warn  .badge-dot { background: var(--warn); }
.badge--bad   { border-color: color-mix(in oklch, var(--bad) 35%, var(--line)); color: var(--bad); }
.badge--bad   .badge-dot { background: var(--bad); }
.badge--accent{ border-color: var(--accent-line); color: var(--accent-ink); background: var(--accent-soft); }
.badge--accent .badge-dot { background: var(--accent); }

/* ————————————————————————————————————————— card
   Used sparingly. Cards = truly detachable units. */
.card {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.card-muted {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

/* ————————————————————————————————————————— table
   Real <table> elements. Hairlines. tabular nums. */
.table-data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table-data thead th {
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-500);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line-strong);
}
.table-data tbody td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-900);
  vertical-align: middle;
}
.table-data tbody tr:last-child td { border-bottom: none; }
.table-data .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.table-data .right { text-align: right; }

/* Alerts / notices — full border, no side-stripe */
.notice {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  background: var(--surface-1);
  color: var(--ink-900);
  font-size: 0.9375rem;
}
.notice--ok   { background: var(--ok-soft);   border-color: color-mix(in oklch, var(--ok) 25%, var(--line)); }
.notice--warn { background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 25%, var(--line)); }
.notice--bad  { background: var(--bad-soft);  border-color: color-mix(in oklch, var(--bad) 25%, var(--line)); }
.notice--accent { background: var(--accent-soft); border-color: var(--accent-line); }

/* Prose helper — constrained body copy */
.prose-tight {
  max-width: 65ch;
  line-height: 1.6;
  color: var(--ink-700);
}
.prose-tight p + p { margin-top: 1em; }
