/* =========================================================
   VELA — COMPONENT STYLES
   ========================================================= */

/* ---------- Layout primitives ---------- */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--space-6);
}
.container-narrow { max-width: var(--container-md); }
.container-wide   { max-width: var(--container-2xl); }

.stack > * + * { margin-top: var(--stack, var(--space-4)); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.grid { display: grid; gap: var(--space-6); }

/* ---------- Brand strip / site chrome ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--header-h);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
}
.site-header .container { display: flex; align-items: center; gap: var(--space-6); width: 100%; }
.brand-lockup { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--fg); }
.brand-lockup img { height: 28px; width: auto; }
.brand-name {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.site-nav { display: flex; align-items: center; gap: var(--space-1); margin-left: var(--space-4); }
.nav-link {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.nav-link:hover { color: var(--fg); background: var(--bg-muted); }
.nav-link.is-active { color: var(--fg); background: var(--bg-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 var(--space-4);
  height: 40px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  color: var(--fg);
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-ring); }

.btn-primary {
  background: var(--brand);
  color: var(--brand-fg);
  border-color: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }

.btn-accent {
  background: linear-gradient(180deg, var(--vela-teal-400) 0%, var(--vela-teal-500) 100%);
  color: #03333A;
  border-color: var(--vela-teal-500);
  box-shadow: var(--shadow-glow);
}
.btn-accent:hover { filter: brightness(1.05); }

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--bg-muted); border-color: var(--fg-subtle); }

.btn-ghost { color: var(--fg); background: transparent; }
.btn-ghost:hover { background: var(--bg-muted); }

.btn-link {
  color: var(--fg-accent);
  padding: 0;
  height: auto;
  background: none;
  border: none;
  text-decoration: none;
  font-weight: var(--weight-semibold);
}
.btn-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(0.95); }

.btn-sm { height: 32px; font-size: var(--text-xs); padding: 0 var(--space-3); border-radius: var(--r-sm); }
.btn-lg { height: 48px; font-size: var(--text-md); padding: 0 var(--space-6); border-radius: var(--r-md); }
.btn-xl { height: 56px; font-size: var(--text-md); padding: 0 var(--space-8); border-radius: var(--r-lg); }

.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-lg { width: 48px; }

/* ---------- Form controls ---------- */
.input, .select, .textarea {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.textarea { height: auto; padding: var(--space-3); min-height: 96px; resize: vertical; line-height: var(--leading-normal); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--fg-subtle); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-subtle); }
.input[disabled] { background: var(--bg-muted); cursor: not-allowed; color: var(--fg-subtle); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--fg);
  letter-spacing: -0.005em;
}
.field-hint { font-size: var(--text-xs); color: var(--fg-subtle); }
.field-error { font-size: var(--text-xs); color: var(--danger); font-weight: var(--weight-medium); }
.field.is-invalid .input { border-color: var(--danger); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 3px rgba(217, 74, 66, 0.25); }

.checkbox, .radio {
  appearance: none;
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all var(--dur-fast) var(--ease-out);
  flex-shrink: 0;
}
.radio { border-radius: var(--r-full); }
.checkbox:checked, .radio:checked { background: var(--brand); border-color: var(--brand); }
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.radio:checked::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: #fff;
  border-radius: 50%;
}
.checkbox:focus-visible, .radio:focus-visible { box-shadow: var(--shadow-ring); outline: none; }

/* Toggle */
.toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 36px; height: 20px;
  border-radius: var(--r-full);
  background: var(--vela-gray-300);
  position: relative;
  cursor: pointer;
  transition: background var(--dur-normal) var(--ease-out);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-normal) var(--ease-spring);
}
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(16px); }

/* Input with addon */
.input-group { display: flex; align-items: center; position: relative; }
.input-group .input { padding-left: 36px; }
.input-group .icon-leading {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--fg-subtle); pointer-events: none;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}
.card-raised { box-shadow: var(--shadow-md); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}
.card-title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  color: var(--fg);
}
.card-subtitle { color: var(--fg-muted); font-size: var(--text-sm); margin-top: 2px; }

/* ---------- Badge / Tag ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--r-full);
  line-height: 1.5;
  letter-spacing: -0.005em;
}
.badge-brand   { background: var(--brand-muted); color: var(--fg-brand); }
.badge-accent  { background: var(--accent-muted); color: var(--accent-contrast); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn    { background: var(--warn-bg); color: var(--vela-warn-700); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--bg-muted); color: var(--fg-muted); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--fg-muted); }

.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ---------- Alert ---------- */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--r-md);
  border: 1px solid;
  align-items: flex-start;
}
.alert-icon { flex-shrink: 0; font-size: 18px; line-height: 1; }
.alert-title { font-weight: var(--weight-semibold); color: var(--fg); font-size: var(--text-sm); }
.alert-body { color: var(--fg-muted); font-size: var(--text-sm); margin-top: 2px; }

.alert-info    { background: var(--info-bg); border-color: var(--info-border); }
.alert-info    .alert-icon { color: var(--info); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); }
.alert-success .alert-icon { color: var(--success); }
.alert-warn    { background: var(--warn-bg); border-color: var(--warn-border); }
.alert-warn    .alert-icon { color: var(--vela-warn-700); }
.alert-danger  { background: var(--danger-bg); border-color: var(--danger-border); }
.alert-danger  .alert-icon { color: var(--danger); }

/* ---------- Code ---------- */
code, pre, kbd, samp { font-family: var(--font-mono); }
.code-inline {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  color: var(--fg);
}
.code-block {
  background: var(--vela-navy-950);
  color: #E6EAF4;
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  overflow-x: auto;
  border: 1px solid var(--vela-navy-800);
  position: relative;
}
.code-block .tok-kw { color: #F4A7A3; }
.code-block .tok-fn { color: #FFD37A; }
.code-block .tok-str { color: #95DBE0; }
.code-block .tok-num { color: #7ED4A8; }
.code-block .tok-com { color: #727B93; font-style: italic; }
.code-block .tok-op  { color: #A9B2C7; }
.code-block .tok-var { color: #C6ECEF; }

.kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  color: var(--fg-muted);
  line-height: 1;
  display: inline-block;
}

/* ---------- Table ---------- */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}
.table th, .table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table th {
  font-weight: var(--weight-semibold);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  background: var(--bg-muted);
  position: sticky; top: 0;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-muted); }
.table tr.is-selected td { background: var(--accent-muted); }

/* ---------- Avatar ---------- */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--accent-contrast);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 40px; height: 40px; font-size: var(--text-sm); }
.avatar-xl { width: 56px; height: 56px; font-size: var(--text-md); }

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; border: 2px solid var(--surface); }

/* ---------- Separator ---------- */
.sep { border: none; height: 1px; background: var(--border); margin: var(--space-8) 0; }

/* ---------- Section primitives ---------- */
.section { padding: var(--space-20) 0; }
.section-sm { padding: var(--space-12) 0; }
.section-lg { padding: var(--space-24) 0; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--fg-accent);
  font-family: var(--font-sans);
}
.eyebrow::before {
  content: '';
  width: 24px; height: 1px; background: currentColor;
  display: inline-block;
}

/* ---------- Utilities ---------- */
.text-muted { color: var(--fg-muted); }
.text-subtle { color: var(--fg-subtle); }
.text-brand { color: var(--fg-brand); }
.text-accent { color: var(--fg-accent); }
.text-center { text-align: center; }
.text-display { font-family: var(--font-display); font-optical-sizing: auto; letter-spacing: var(--tracking-tight); line-height: var(--leading-tight); }
.italic { font-style: italic; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--fg-muted);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-muted); color: var(--fg); }

/* ---------- Tweak panel ---------- */
.tweak-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: var(--z-modal);
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-xl);
  display: none;
}
.tweak-panel.is-open { display: block; }
.tweak-panel h4 { font-family: var(--font-display); font-style: italic; font-size: 1.25rem; color: var(--fg); margin-bottom: var(--space-3); }
.tweak-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; font-size: var(--text-sm); color: var(--fg-muted); }
.tweak-swatches { display: flex; gap: 6px; }
.tweak-swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; }
.tweak-swatch.is-active { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg); }

/* ---------- Sail mark (CSS-only wordmark fallback) ---------- */
.sail-mark {
  display: inline-block;
  width: 28px;
  height: 32px;
  position: relative;
}

/* ---------- Hero gradient utilities ---------- */
.bg-navy-deep {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(64, 182, 189, 0.25), transparent 60%),
    radial-gradient(800px 400px at 0% 100%, rgba(64, 182, 189, 0.15), transparent 60%),
    linear-gradient(180deg, var(--vela-navy-900) 0%, var(--vela-navy-950) 100%);
  color: var(--vela-sand-50);
}
.bg-sand-wave {
  background:
    radial-gradient(800px 400px at 100% 0%, rgba(64, 182, 189, 0.10), transparent 60%),
    radial-gradient(600px 400px at 0% 100%, rgba(36, 53, 85, 0.05), transparent 60%),
    var(--vela-sand-50);
}
