/* Shared foundation for the website and the app: tokens, themes, type, buttons, forms.
   Design language: docs/DESIGN.md (editorial, white canvas, ink primary, signature surface cards). */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/static/fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/static/fonts/inter-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* surfaces and text (light) */
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-strong: #e0e2e6;
  --ink: #181d26;
  --body: #333840;
  --muted: #41454d;
  --subtle: #5f6670;
  --hairline: #dddddd;
  --border-strong: #9297a0;
  --primary: #181d26;
  --primary-active: #0d1218;
  --on-primary: #ffffff;
  --link: #1b61c9;
  --link-active: #1a3866;
  --focus: #458fff;
  --success: #006400;
  --success-bg: #eaf5ea;
  --danger: #aa2d00;
  --danger-bg: #fdf0ea;
  --info: #254fad;
  --info-bg: #edf3fd;
  --skel: #eef0f3;
  --skel-hi: #f8f9fb;
  --scrim: rgba(24, 29, 38, 0.5);
  --shadow-btn: 0 1px 2px rgba(24, 29, 38, 0.22), 0 4px 12px rgba(27, 97, 201, 0.12);
  --shadow-pop: 0 12px 40px rgba(24, 29, 38, 0.16), 0 2px 8px rgba(24, 29, 38, 0.08);
  --card-line: var(--hairline);

  /* signature surfaces (identical in both themes: they are the "voltage") */
  --coral: #aa2d00;
  --forest: #0a2e0e;
  --navy: #181d26;
  --cream: #f5e9d4;
  --peach: #fcab79;
  --mint: #a8d8c4;
  --yellow: #f4d35e;
  --mustard: #d9a441;
  --tile-ink: #181d26;
  --navy-surface: #181d26;

  /* type */
  --font: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  /* shape and spacing (4px grid) */
  --r-xs: 2px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-full: 9999px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 96px;

  /* motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --d-fast: 160ms;
  --d-med: 280ms;
  --d-slow: 420ms;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1319;
    --bg-soft: #161b23;
    --bg-strong: #222935;
    --ink: #f3f5f8;
    --body: #cdd2da;
    --muted: #aab0ba;
    --subtle: #8d95a1;
    --hairline: #2a313c;
    --border-strong: #4d5563;
    --primary: #f3f5f8;
    --primary-active: #d9dee6;
    --on-primary: #181d26;
    --link: #7db0f7;
    --link-active: #a9cbfa;
    --focus: #7db0f7;
    --success: #6fd488;
    --success-bg: #12261a;
    --danger: #ff9f80;
    --danger-bg: #2c1913;
    --info: #9cc0f7;
    --info-bg: #14233b;
    --skel: #1b212b;
    --skel-hi: #242c38;
    --scrim: rgba(3, 5, 8, 0.66);
    --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
    --card-line: #2a313c;
    --navy-surface: #1c2330;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f1319;
  --bg-soft: #161b23;
  --bg-strong: #222935;
  --ink: #f3f5f8;
  --body: #cdd2da;
  --muted: #aab0ba;
  --subtle: #8d95a1;
  --hairline: #2a313c;
  --border-strong: #4d5563;
  --primary: #f3f5f8;
  --primary-active: #d9dee6;
  --on-primary: #181d26;
  --link: #7db0f7;
  --link-active: #a9cbfa;
  --focus: #7db0f7;
  --success: #6fd488;
  --success-bg: #12261a;
  --danger: #ff9f80;
  --danger-bg: #2c1913;
  --info: #9cc0f7;
  --info-bg: #14233b;
  --skel: #1b212b;
  --skel-hi: #242c38;
  --scrim: rgba(3, 5, 8, 0.66);
  --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --card-line: #2a313c;
  --navy-surface: #1c2330;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font: 400 14px/1.5 var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  overflow-x: hidden;
}
h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
}
h1,
h2,
h3,
h4 {
  color: var(--ink);
  font-weight: 400;
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}
a {
  color: var(--link);
  text-decoration: none;
}
a:active {
  color: var(--link-active);
}
/* Text links get a sliding underline. Anything that is a button, row or tile opts out via its own background. */
a:where(:not(.btn):not(.brand):not(.row-link):not(.nav-item):not(.tab-item):not(.sub-app):not(.skip-link)) {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  padding-bottom: 1px;
  transition: background-size var(--d-med) var(--ease), color var(--d-fast) var(--ease);
}
a:where(:not(.btn):not(.brand):not(.row-link):not(.nav-item):not(.tab-item):not(.sub-app):not(.skip-link)):hover {
  background-size: 100% 1px;
}
img,
svg {
  display: block;
  max-width: 100%;
}
b,
strong {
  font-weight: 500;
  color: var(--ink);
}
code,
kbd,
pre {
  font-family: var(--mono);
  font-size: 0.92em;
}
code {
  background: var(--bg-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  overflow-wrap: anywhere;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
::selection {
  background: color-mix(in srgb, var(--focus) 30%, transparent);
  color: var(--ink);
}
html {
  scrollbar-color: color-mix(in srgb, var(--border-strong) 70%, transparent) transparent;
  caret-color: var(--ink);
}
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}

/* type scale (docs/DESIGN.md), modest weights only */
.t-display-xl { font-size: clamp(36px, 5vw, 48px); font-weight: 500; line-height: 1.1; }
.t-display-lg { font-size: clamp(34px, 5.2vw, 40px); font-weight: 400; line-height: 1.2; }
.t-display-md { font-size: clamp(26px, 3.6vw, 32px); font-weight: 400; line-height: 1.2; }
.t-title-lg { font-size: 24px; font-weight: 400; line-height: 1.35; letter-spacing: 0.12px; }
.t-title-md { font-size: 20px; font-weight: 400; line-height: 1.5; }
.t-title-sm { font-size: 18px; font-weight: 500; line-height: 1.4; }
.t-label { font-size: 16px; font-weight: 500; line-height: 1.4; }
.t-caption { font-size: 14px; font-weight: 500; line-height: 1.35; letter-spacing: 0.16px; }
.t-small { font-size: 13px; line-height: 1.45; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.eyebrow { font-size: 12px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--subtle); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --btn-bg: var(--bg);
  --btn-fg: var(--ink);
  --btn-bd: var(--hairline);
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-lg);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 500 16px/1.4 var(--font);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: transform var(--d-fast) var(--ease), background-color var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease), opacity var(--d-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
a.btn:hover {
  text-decoration: none;
}
.btn:hover {
  border-color: var(--border-strong);
}
.btn:active {
  transform: scale(0.97);
  transition-duration: 80ms;
}
.btn .icon { transition: transform var(--d-med) var(--ease); }
.btn:hover .icon-arrow, .btn:hover .icon-go { transform: translateX(3px); }
.btn:hover .icon-spin { transform: rotate(60deg); }
.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--on-primary);
  --btn-bd: var(--primary);
  box-shadow: var(--shadow-btn);
}
.btn-primary:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 86%, var(--bg));
}
.btn-primary:active {
  background: var(--primary-active);
}
.btn-on-dark {
  --btn-bg: #ffffff;
  --btn-fg: #181d26;
  --btn-bd: #ffffff;
}
.btn-on-dark:hover {
  border-color: #ffffff;
  background: #f1f3f6;
}
.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
}
.btn-ghost:hover {
  background: var(--bg-soft);
  border-color: transparent;
}
.btn-danger {
  --btn-bg: var(--bg);
  --btn-fg: var(--danger);
  --btn-bd: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}
.btn-danger-solid {
  --btn-bg: var(--coral);
  --btn-fg: #fff;
  --btn-bd: var(--coral);
}
.btn-danger-solid:hover {
  background: #8f2600;
  border-color: #8f2600;
}
.btn-sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--r-md);
  gap: 6px;
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-icon {
  min-height: 40px;
  width: 40px;
  padding: 0;
  border-radius: 9999px;
}
@media (pointer: coarse) {
  .btn-sm { min-height: 44px; }
  .btn-icon { min-height: 44px; width: 44px; }
}
.btn .spinner {
  position: absolute;
}
.btn[aria-busy='true'] > :not(.spinner) {
  opacity: 0;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 700ms linear infinite;
  display: inline-block;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.link-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--link);
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > label,
.field-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input,
.select,
.textarea {
  appearance: none;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  font: 400 16px/1.4 var(--font);
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease), background-color var(--d-fast) var(--ease);
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder { color: var(--subtle); }
.input:hover,
.select:hover,
.textarea:hover { border-color: var(--border-strong); }
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 28%, transparent);
}
.input[aria-invalid='true'] { border-color: var(--danger); }
.input.has-end { padding-right: 52px; }
.input-wrap.has-icon .input { padding-left: 44px; }
.input-icon { position: absolute; left: 14px; top: 0; bottom: 0; display: grid; place-items: center; color: var(--subtle); pointer-events: none; transition: color var(--d-fast) var(--ease); }
.input-wrap.has-icon:focus-within .input-icon { color: var(--ink); }
.input-end {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
}
.field-hint { font-size: 13px; color: var(--muted); line-height: 1.45; }
.field-error { font-size: 13px; color: var(--danger); line-height: 1.45; display: flex; gap: 6px; align-items: flex-start; }
.field-ok { font-size: 13px; color: var(--success); line-height: 1.45; display: flex; gap: 6px; align-items: center; }

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.alert.error { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }
.alert.success { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 40%, transparent); color: var(--success); }
.alert.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info); }
.alert b, .alert strong { color: inherit; }
.alert .icon { margin-top: 1px; }

/* logo */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; flex: none; transition: transform var(--d-med) var(--ease); }
.brand:hover svg { transform: rotate(-6deg) scale(1.06); }
.logomark-bg { fill: var(--ink); }
.logomark-fg { fill: none; stroke: var(--bg); stroke-width: 2.2; stroke-linecap: round; }
.logomark-dot { fill: var(--peach); }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
