/* =========================================================================
   EVO Design System — Components
   Depends on tokens.css. Ship both together.
   ========================================================================= */

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

/* ---------- Background atmosphere (opt-in via .evo-ambient) ---------- */
.evo-ambient { position: relative; }
.evo-ambient::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: var(--bg-halo-1), var(--bg-halo-2);
}
.evo-ambient::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 800; margin: 0; letter-spacing: -0.02em; line-height: var(--lh-tight); }
.h1 { font-size: var(--fs-display); }
.h2 { font-size: var(--fs-h2); }
.h3 { font-size: var(--fs-h3); letter-spacing: -0.01em; }
.eyebrow { font-family: var(--font-mono); font-size: var(--fs-micro); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.glow-text { text-shadow: var(--glow-primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 500; font-size: 16px;
  height: 48px; padding: 0 20px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  line-height: 1; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              opacity var(--dur-base) var(--ease-out),
              background var(--dur-base) var(--ease-out),
              color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.btn:active { transform: scale(0.98); }
.btn[disabled], .btn.is-disabled { opacity: 0.4; pointer-events: none; }
.btn.sm { height: 40px; font-size: 15px; padding: 0 16px; border-radius: 8px; }
.btn.lg { height: 60px; font-size: 17px; padding: 0 24px; border-radius: 12px; }
.btn.block { width: 100%; }

.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-primary:hover, .btn-primary.is-hover { opacity: 0.92; box-shadow: var(--glow-btn); }
.btn-primary.is-active { transform: scale(0.98); }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn-outline:hover, .btn-outline.is-hover { border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary-border); }

.btn-ghost { background: transparent; color: var(--text); border-color: transparent; }
.btn-ghost:hover, .btn-ghost.is-hover { background: var(--primary-fill); color: var(--primary); }

.btn-tg { background: var(--primary-fill); color: var(--primary); border-color: var(--primary-border); }
.btn-tg:hover, .btn-tg.is-hover { background: var(--primary-fill-2); box-shadow: var(--glow-card); }

.btn-destructive { background: var(--destructive); color: #fff; border-color: var(--destructive); }
.btn-destructive:hover { opacity: 0.92; box-shadow: 0 0 20px rgba(232,88,88,0.4); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 15px; color: var(--muted); font-weight: 500; }
.input, .textarea, .select {
  height: 56px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); font-family: var(--font-body); font-size: 17px;
  padding: 0 16px; outline: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.textarea { height: auto; padding: 14px 16px; resize: vertical; min-height: 120px; }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:focus, .textarea:focus, .select:focus, .input.is-focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-fill-2);
}
.input.is-error, .textarea.is-error {
  border-color: var(--destructive);
  box-shadow: 0 0 0 3px var(--destructive-fill);
}
.input:disabled, .input.is-disabled { opacity: 0.45; cursor: not-allowed; }
.field .help { font-size: 13px; color: var(--muted); }
.field .err  { font-size: 13px; color: var(--destructive); }
.input-group { position: relative; }
.input-group .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-group .input { padding-left: 44px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card .card-title { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.card.hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-card);
  border-color: var(--primary-border);
}
.card.featured { border-color: var(--primary-border-2); position: relative; overflow: hidden; }
.card.featured::before {
  content: ""; position: absolute; inset: -40% -20% auto auto;
  width: 260px; height: 260px;
  background: radial-gradient(closest-side, var(--primary-fill-2), transparent 70%);
  pointer-events: none;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 500; font-size: 13px;
  padding: 5px 11px; border-radius: var(--radius-pill);
  letter-spacing: 0.01em; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge-info      { background: var(--info-fill);       color: var(--info);        border-color: var(--info-border); }
.badge-success   { background: var(--success-fill);    color: var(--success);     border-color: var(--success-border); }
.badge-warning   { background: var(--warning-fill);    color: var(--warning);     border-color: var(--warning-border); }
.badge-error     { background: var(--destructive-fill);color: var(--destructive); border-color: var(--destructive-border); }
.badge-primary   { background: var(--primary-fill);    color: var(--primary);     border-color: var(--primary-border); }

/* ---------- Pill / chip ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px;
}

/* ---------- Layout helpers ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; } .grid.cols-2 { grid-template-columns: 1fr; } }

.row   { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hr    { height: 1px; background: var(--border); border: none; margin: 24px 0; }
.kbd   { font-family: var(--font-mono); font-size: 12px; background: var(--bg-2); border: 1px solid var(--border); padding: 2px 6px; border-radius: 5px; color: var(--muted); }
.dot   { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 8px var(--primary); }

/* ---------- Site header ---------- */
.site-header {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: var(--z-nav);
}
.site-header .left { display: flex; align-items: center; gap: 28px; }
.site-header nav { display: flex; gap: 18px; }
.site-header nav a { color: var(--muted); font-size: 15px; font-weight: 500; transition: color var(--dur-fast); }
.site-header nav a:hover, .site-header nav a.active { color: var(--text); }
.site-header .right { display: flex; align-items: center; gap: 10px; }

/* ---------- Brand lockup ---------- */
.evo-lockup { display: flex; align-items: center; gap: 10px; }
.evo-lockup .brand-name { font-family: var(--font-head); font-weight: 800; letter-spacing: 0.14em; font-size: 18px; }
.evo-lockup .brand-name span { color: var(--primary); }
.evo-lockup .brand-tag { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: 0.18em; }

/* ---------- Tab bar (mobile) ---------- */
.tabbar {
  display: flex; justify-content: space-around; align-items: center;
  height: 64px; padding: 0 8px;
  background: var(--card); border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.08em;
  padding: 8px 10px; border-radius: 10px;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.tabbar a.active { color: var(--primary); }
.tabbar a:hover { background: var(--primary-fill); }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex; padding: 4px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 10px;
}
.segmented button {
  background: transparent; border: none; color: var(--muted);
  font-family: var(--font-body); font-weight: 500; font-size: 14px;
  padding: 8px 14px; border-radius: 7px; cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.segmented button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.2); }

/* ---------- List row (data list) ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  transition: background var(--dur-fast);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--card-2); }
.list-row .title { color: var(--text); font-weight: 500; }
.list-row .sub { color: var(--muted); font-size: 13px; }
.list-row .right { margin-left: auto; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }

/* ---------- Avatar ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-fill); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 14px;
  border: 1px solid var(--primary-border);
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

/* ---------- Toast ---------- */
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: inline-flex; gap: 12px; align-items: flex-start;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  max-width: 420px;
}
.toast .title { font-weight: 600; margin-bottom: 2px; }
.toast .body { color: var(--muted); font-size: 14px; }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--destructive); }
.toast.toast-warning { border-left-color: var(--warning); }

/* ---------- Skeleton ---------- */
.skel {
  display: block; background: linear-gradient(90deg, var(--card-2) 25%, var(--card) 37%, var(--card-2) 63%);
  background-size: 400% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}
@keyframes skel-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Modal / sheet ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
  width: min(480px, 92vw); max-height: 86vh; overflow: auto;
  box-shadow: 0 40px 80px rgba(0,0,0,0.5);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 24px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--muted);
}
.empty .icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 14px; background: var(--primary-fill); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--primary-border);
}

/* ---------- Micro-animations (motion vocabulary) ---------- */
/* Vocabulary: lift -2px · glow 20px · press scale(0.98) · rise fade-up · shine sweep */

@keyframes evo-rise-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes evo-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes evo-glow-breath {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-fill); }
  50%      { box-shadow: 0 0 32px 4px var(--primary-fill-2); }
}
@keyframes evo-pulse-dot {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%      { transform: scale(1.4); opacity: 0.6; }
}
@keyframes evo-shine-sweep {
  0%   { transform: translateX(-120%) skewX(-18deg); opacity: 0; }
  40%  { opacity: 1; }
  100% { transform: translateX(220%)  skewX(-18deg); opacity: 0; }
}
@keyframes evo-ring-expand {
  0%   { transform: scale(0.85); opacity: 0.55; }
  100% { transform: scale(1.6);  opacity: 0;    }
}
@keyframes evo-caret-blink { 50% { opacity: 0; } }

/* Staggered rise-in — apply to siblings */
.rise-in       { opacity: 0; animation: evo-rise-up var(--dur-slow) var(--ease-out) forwards; }
.rise-in.d-1   { animation-delay: 80ms;  }
.rise-in.d-2   { animation-delay: 160ms; }
.rise-in.d-3   { animation-delay: 240ms; }
.rise-in.d-4   { animation-delay: 320ms; }
.rise-in.d-5   { animation-delay: 400ms; }
.rise-in.d-6   { animation-delay: 480ms; }

/* Breathing halo — for CTA buttons / hero marks */
.glow-breath   { animation: evo-glow-breath 3.2s var(--ease-out) infinite; }

/* Shine sweep — wrapper must be position:relative; overflow:hidden */
.shine         { position: relative; overflow: hidden; }
.shine::after  {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 40%, color-mix(in oklab, var(--primary) 35%, transparent) 50%, transparent 60%);
  transform: translateX(-120%) skewX(-18deg);
  pointer-events: none;
}
.shine:hover::after { animation: evo-shine-sweep 900ms var(--ease-out); }

/* Underline grow — for anchor links */
.underline-grow { position: relative; }
.underline-grow::after {
  content: ""; position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 1px;
  background: var(--primary);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-base) var(--ease-out);
}
.underline-grow:hover::after { transform: scaleX(1); }

/* Pulsing status dot */
.dot.pulse::before,
.pulse-dot {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  animation: evo-pulse-dot 1.8s var(--ease-out) infinite;
}

/* Magnetic card (lift + glow on hover) — alias of .card.hoverable, generic */
.lift {
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}
.lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-card);
  border-color: var(--primary-border);
}

/* Respect user's reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .rise-in { opacity: 1; }
}

/* ---------- Theme toggle button ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 6px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  cursor: pointer; user-select: none;
  transition: border-color var(--dur-fast);
}
.theme-toggle:hover { border-color: var(--primary-border); }
.theme-toggle .tt-opt {
  padding: 4px 10px; border-radius: 999px;
  transition: all var(--dur-fast);
}
.theme-toggle .tt-opt.active {
  background: var(--primary-fill); color: var(--primary);
}
