/* ==========================================================================
   BestTense — 2026 design system
   Tokens, reset, shared shell and UI primitives
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  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;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/inter-latin-ext.woff2") format("woff2");
  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-20C4, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

:root {
  color-scheme: light;

  /* Typography */
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  --text-display: clamp(2.8rem, 6vw, 5rem);
  --text-h1: clamp(2rem, 4vw, 3.2rem);
  --text-h2: clamp(1.35rem, 2.4vw, 1.8rem);
  --text-h3: 1.05rem;
  --text-body: 0.95rem;
  --text-small: 0.83rem;
  --text-caption: 0.72rem;

  /* Color — light */
  --bg: #f6f7fb;
  --bg-deep: #eef0f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f2f4fa;
  --surface-tint: #eef2ff;
  --ink: #141726;
  --ink-soft: #30364a;
  --muted: #667085;
  --muted-strong: #4c556a;
  --line: #e4e7f0;
  --line-strong: #d4d9e8;

  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ink: #ffffff;
  --accent: #6366f1;
  --success: #0f9f6e;
  --success-soft: #e7f8f1;
  --warning: #c47a10;
  --warning-soft: #fff6e5;
  --danger: #d04545;
  --danger-soft: #fff0f0;

  /* Legacy compatibility tokens */
  --accent-dark: #3730a3;
  --accent-soft: #eef2ff;
  --warm: #e9a23b;

  /* Radii */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-2xl: 28px;
  --radius-pill: 999px;

  /* Spacing — 4px grid */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(20, 23, 38, 0.04);
  --shadow-sm: 0 2px 8px rgba(20, 23, 38, 0.05);
  --shadow-md: 0 12px 32px rgba(20, 23, 38, 0.07);
  --shadow-lg: 0 24px 64px rgba(20, 23, 38, 0.1);
  --shadow-xl: 0 40px 120px rgba(20, 23, 38, 0.16);
  --shadow-primary: 0 10px 28px rgba(79, 70, 229, 0.24);

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.08);
  --duration-fast: 160ms;
  --duration-normal: 240ms;
  --duration-slow: 360ms;
  --shadow: var(--shadow-md);
  --radius: var(--radius-xl);
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0c0f18;
  --bg-deep: #090b12;
  --surface: #141826;
  --surface-raised: #191e2f;
  --surface-soft: #1b2032;
  --surface-tint: #1e2340;
  --ink: #f3f5ff;
  --ink-soft: #d8dcf1;
  --muted: #9aa4bd;
  --muted-strong: #b5bdd2;
  --line: #272d42;
  --line-strong: #353d57;

  --primary: #818cf8;
  --primary-strong: #a5b4fc;
  --primary-soft: #23284a;
  --primary-ink: #0b0d18;
  --accent: #a5b4fc;
  --success: #34d399;
  --success-soft: #102e26;
  --warning: #fbbf24;
  --warning-soft: #33260e;
  --danger: #f87171;
  --danger-soft: #35171b;

  --accent-dark: #a5b4fc;
  --accent-soft: #23284a;
  --warm: #fbbf24;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.38);
  --shadow-xl: 0 50px 140px rgba(0, 0, 0, 0.5);
  --shadow-primary: 0 10px 30px rgba(99, 102, 241, 0.18);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -8%, rgba(99, 102, 241, 0.12), transparent 38%),
    radial-gradient(circle at 94% 6%, rgba(168, 85, 247, 0.08), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration-normal) ease, color var(--duration-normal) ease;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 8% -8%, rgba(99, 102, 241, 0.18), transparent 36%),
    radial-gradient(circle at 94% 6%, rgba(168, 85, 247, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
}

::selection {
  background: rgba(99, 102, 241, 0.24);
  color: var(--ink);
}

button,
textarea,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary);
}

img,
svg {
  display: block;
}

h1, h2, h3, h4, h5, h6, p {
  margin-top: 0;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 999;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-ink);
  font-size: var(--text-small);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-140%);
  transition: transform var(--duration-fast) ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

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

.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(79, 70, 229, 0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.65), transparent 72%);
}

html[data-theme="dark"] .page-glow {
  background-image: radial-gradient(rgba(165, 180, 252, 0.1) 1px, transparent 1px);
}

/* --------------------------------------------------------------------------
   Header / navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  transition: border-color var(--duration-normal), background var(--duration-normal);
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 72px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.03rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  flex: 0 0 auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.35), transparent 42%),
    linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-primary);
}

.brand-sub {
  display: block;
  margin-top: -2px;
  color: var(--muted);
  font-size: 0.61rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  box-shadow: var(--shadow-xs);
}

.header-nav a {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    background var(--duration-fast) ease,
    color var(--duration-fast) ease,
    transform var(--duration-fast) ease;
}

.header-nav a:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.header-nav a.active {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.22);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted-strong);
  box-shadow: var(--shadow-xs);
  transition:
    transform var(--duration-fast) var(--ease-spring),
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    box-shadow var(--duration-fast) ease;
}

.theme-toggle:hover {
  transform: translateY(-1px) scale(1.03);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* --------------------------------------------------------------------------
   Typography helpers
   -------------------------------------------------------------------------- */
.eyebrow {
  margin: 0 0 var(--space-3);
  color: var(--primary);
  font-size: var(--text-caption);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-text {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.72;
}

.field-label {
  display: block;
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.primary-button,
.secondary-button,
.text-button {
  -webkit-tap-highlight-color: transparent;
}

.primary-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--primary), #6d5ce7);
  color: var(--primary-ink);
  font-size: 0.88rem;
  font-weight: 750;
  letter-spacing: -0.005em;
  text-decoration: none;
  box-shadow: var(--shadow-primary);
  overflow: hidden;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) ease,
    filter var(--duration-fast) ease;
}

.primary-button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.22) 48%, transparent 72%);
  transform: translateX(-120%);
  transition: transform 520ms var(--ease-out);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(79, 70, 229, 0.3);
  filter: saturate(1.04);
}

.primary-button:hover::after {
  transform: translateX(120%);
}

.primary-button:active {
  transform: translateY(0) scale(0.985);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
  filter: saturate(0.75);
}

.primary-button.small {
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  box-shadow: none;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
  transition:
    transform var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    background var(--duration-fast) ease;
}

.secondary-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 2px;
  font-size: 0.78rem;
  font-weight: 700;
}

.text-button:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 300;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: var(--surface);
  font-size: 0.82rem;
  font-weight: 650;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--duration-normal) ease,
    transform var(--duration-normal) var(--ease-out);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-7);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

.site-footer strong {
  color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   Motion / page entrance
   -------------------------------------------------------------------------- */
@keyframes page-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

main.shell {
  animation: page-in var(--duration-slow) var(--ease-out) both;
}

/* reduced-motion bypassed by product requirement */
@media (max-width: 720px) {
  .shell,
  .site-footer {
    width: min(100% - 28px, 1180px);
  }

  .header-inner {
    min-height: 64px;
    gap: 10px;
  }

  .brand-sub {
    display: none;
  }

  .header-nav a {
    padding: 6px 10px;
    font-size: 0.74rem;
  }
}

@media (max-width: 480px) {
  .brand span:not(.brand-mark):not(.brand-sub) {
    display: none;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }
}

/* --------------------------------------------------------------------------
   Header actions / command palette
   -------------------------------------------------------------------------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.command-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-xs);
  transition: border-color 160ms, color 160ms, box-shadow 160ms;
}

.command-trigger:hover {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.command-trigger svg {
  width: 16px;
  height: 16px;
}

.command-trigger span {
  font-size: 0.72rem;
  font-weight: 650;
}

.command-trigger kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-family: inherit;
  font-size: 0.61rem;
  font-weight: 700;
}

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 13vh 20px 20px;
}

.command-palette[hidden] {
  display: none;
}

.command-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 24, 0.52);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: command-fade 160ms ease both;
}

.command-dialog {
  position: relative;
  width: min(590px, 100%);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  animation: command-in 260ms var(--ease-out) both;
}

.command-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.command-head svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
}

.command-head input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.92rem;
}

.command-head input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.command-head kbd,
.command-footer kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-family: inherit;
  font-size: 0.61rem;
  font-weight: 700;
}

.command-list {
  max-height: min(52vh, 390px);
  overflow-y: auto;
  padding: 7px;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.command-item:hover,
.command-item.active {
  border-color: var(--line);
  background: var(--surface-soft);
}

.command-item-icon {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
}

.command-item-copy {
  min-width: 0;
  display: grid;
  gap: 0;
}

.command-item-copy strong {
  font-size: 0.82rem;
  font-weight: 700;
}

.command-item-copy small {
  color: var(--muted);
  font-size: 0.68rem;
}

.command-item-shortcut {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.63rem;
}

.command-empty {
  padding: 25px 15px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.command-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.63rem;
}

.command-footer span:last-child {
  margin-left: auto;
  color: var(--muted);
}

@keyframes command-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes command-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .command-trigger span {
    display: none;
  }

  .command-trigger {
    width: 40px;
    justify-content: center;
    padding: 0;
  }

  .command-trigger kbd {
    display: none;
  }

  .command-palette {
    padding: 9vh 12px 12px;
  }
}

/* reduced-motion bypassed by product requirement */
body.command-open {
  overflow: hidden;
}

html.scroll-locked,
body.scroll-locked {
  overflow: hidden;
}
