/* ============================================================
   Whipmash — design system
   AI Creative Studio for Car Enthusiasts
   ============================================================ */

:root {
  --bg: #000000;
  --surface: #111116;
  --surface2: #1a1a22;
  --border: #252530;
  --accent: #00D4FF;
  --accent2: #FF4400;
  --ink: #ffffff;
  --muted: #888899;
  --common: #6b7280;
  --rare: #60a5fa;
  --epic: #c084fc;
  --legendary: #fbbf24;

  --font-display: 'Bebas Neue', Georgia, serif;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { overflow-x: clip; }
html, body { margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(0, 212, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(255, 68, 0, 0.05), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; }

/* ---------- Layout ---------- */
.shell {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 6rem;
}
@media (min-width: 768px) {
  .shell { padding: 2rem 1rem 4rem; }
}

.stack-sm > * + * { margin-top: 0.75rem; }
.stack    > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.5rem; }
.stack-xl > * + * { margin-top: 2rem; }

.row { display: flex; align-items: center; gap: 0.75rem; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; }
.row-between { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 1rem; }
.spacer { flex: 1 1 auto; }
.gap-sm { gap: 0.5rem; }

/* ---------- Typography ---------- */
.h-display { font-family: var(--font-display); letter-spacing: 0.06em; }
.h1 { font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 700; margin: 0 0 0.5rem; line-height: 1.1; }
.h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); font-weight: 700; margin: 0 0 0.5rem; }
.h3 { font-size: 1.1rem; font-weight: 700; margin: 0 0 0.4rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.tiny  { font-size: 0.78rem; }
.center { text-align: center; }
.subtitle { color: var(--muted); font-size: 0.95rem; margin: 0; }
.text-error { color: var(--accent2) !important; }
.text-accent { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-sm  { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg  { padding: 0.85rem 2rem; font-size: 1rem; font-weight: 600; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  box-shadow: 0 4px 20px -4px rgba(0, 212, 255, 0.4);
}
.btn-primary:hover {
  background: #33dcff;
  color: var(--bg);
  box-shadow: 0 8px 28px -4px rgba(0, 212, 255, 0.5);
  transform: translateY(-1px);
}
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost   { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger  { background: var(--accent2); color: #fff; }
.btn-danger:hover { background: #ff5522; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.card-lg { padding: 2rem; }
@media (max-width: 640px) {
  .card-lg { padding: 1.25rem; }
}

/* ---------- Form elements ---------- */
.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.input {
  display: block;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  transition: border-color 0.15s;
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input-narrow { max-width: 18rem; }
.textarea { resize: vertical; min-height: 5rem; }
.select {
  display: block;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  cursor: pointer;
}
.checkbox { width: 1rem; height: 1rem; accent-color: var(--accent); cursor: pointer; }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  border: 1px solid transparent;
}
.alert-error { background: rgba(255,68,0,.1); border-color: rgba(255,68,0,.3); color: #ff7755; }
.alert-ok    { background: rgba(0,212,255,.08); border-color: rgba(0,212,255,.25); color: var(--accent); }
.alert-info  { background: rgba(255,255,255,.05); border-color: var(--border); color: var(--muted); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 34rem;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem;
}
.icon-btn:hover { color: var(--ink); }
.hidden { display: none !important; }

/* ---------- Vehicle grid ---------- */
.grid-animals {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
@media (min-width: 480px) {
  .grid-animals { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (min-width: 768px) {
  .grid-animals { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
}
@media (min-width: 1024px) {
  .grid-animals { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.animal-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.animal-card:hover {
  border-color: rgba(0, 212, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -8px rgba(0, 212, 255, 0.2);
}
.animal-card--v2 { border-color: rgba(0, 212, 255, 0.15); }
.animal-thumb {
  aspect-ratio: 1 / 1;
  background: var(--surface2);
  overflow: hidden;
}
.animal-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.animal-body { padding: 0.65rem 0.75rem; }
.animal-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.animal-footer { margin-top: 0.5rem; }

.animal-card-wrap { position: relative; }
.card-select-label {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  display: block;
  cursor: pointer;
}
.card-select { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; cursor: pointer; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); background: var(--surface); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(0, 212, 255, 0.03); }
.table .right { text-align: right; }
.thumb-sm { width: 44px; height: 44px; border-radius: var(--radius-md); overflow: hidden; background: var(--surface2); flex-shrink: 0; }
.thumb-sm img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Rarity badges ---------- */
.rarity {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}
.rarity-common    { background: rgba(107,114,128,.15); color: var(--common); border: 1px solid rgba(107,114,128,.25); }
.rarity-rare      { background: rgba(96,165,250,.1);   color: var(--rare);   border: 1px solid rgba(96,165,250,.25); }
.rarity-epic      { background: rgba(192,132,252,.1);  color: var(--epic);   border: 1px solid rgba(192,132,252,.25); }
.rarity-legendary { background: rgba(251,191,36,.1);   color: var(--legendary); border: 1px solid rgba(251,191,36,.3); }

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  min-width: 240px;
  max-width: 380px;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  font-size: 0.875rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  animation: toast-in 0.2s ease;
}
.toast.error { background: rgba(255,68,0,.15); border-color: rgba(255,68,0,.4); color: #ff7755; }
.toast.ok    { background: rgba(0,212,255,.1); border-color: rgba(0,212,255,.3); color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Avatar ---------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.15);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1.5px solid rgba(0, 212, 255, 0.25);
  overflow: hidden;
  background-repeat: no-repeat;
}

/* ---------- Collection count badge ---------- */
.collection-count-badge {
  background: rgba(0, 212, 255, 0.1);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0.75rem;
  flex-shrink: 0;
}

/* ---------- Site footer ---------- */
.site-footer {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.site-footer a:hover { color: var(--accent); }

/* ---------- Profile / misc ---------- */
.profile-avatar-wrap { position: relative; display: inline-block; }
.profile-avatar-wrap .avatar { width: 80px; height: 80px; font-size: 1.75rem; }
.profile-edit-avatar-btn {
  position: absolute;
  bottom: 0; right: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: 2px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
}

/* ---------- Feed ---------- */
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: border-color 0.15s;
}
.post-card:hover { border-color: rgba(0, 212, 255, 0.25); }
.post-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
}
.post-username { font-weight: 600; font-size: 0.88rem; }
.post-ts { font-size: 0.78rem; color: var(--muted); }
.post-media { background: var(--surface2); }
.post-media img, .post-media video { display: block; width: 100%; }
.post-body { padding: 0.65rem 1rem; }
.post-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.2rem; }
.post-caption { font-size: 0.88rem; color: var(--muted); }
.post-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid var(--border);
}
.post-action-btn {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font: inherit; font-size: 0.82rem;
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0;
  transition: color 0.15s;
}
.post-action-btn:hover { color: var(--ink); }
.post-action-btn.liked { color: var(--accent); }

/* ---------- Misc utilities ---------- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 0.75rem; }
.mt-3 { margin-top: 1.25rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1.25rem; }
.fade-in { animation: fadeIn 0.5s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Breed/Mash result cards ---------- */
.hybrid-result-wrap { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }
.hybrid-result-wrap .variant-card { flex: 0 0 100%; }
@media (min-width: 768px) { .hybrid-result-wrap .variant-card { flex: 0 0 calc(50% - 0.5rem); } }

.variant-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.variant-card.kept { border-color: var(--accent); box-shadow: 0 0 24px -6px rgba(0, 212, 255, 0.4); }
.variant-card .v-img { aspect-ratio: 1 / 1; background: var(--surface2); }
.variant-card .v-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.variant-card .v-foot { padding: 0.75rem; border-top: 1px solid var(--border); }

/* ---------- Background/scene picker ---------- */
.bg-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}
@media (min-width: 640px) {
  .bg-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
.bg-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.5rem;
  background: var(--surface2);
  cursor: pointer;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s;
  position: relative;
}
.bg-option:hover, .bg-option.selected { border-color: var(--accent); color: var(--ink); }
.bg-option .bg-category {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ---------- Video section ---------- */
.video-thumb { position: relative; background: var(--surface2); border-radius: var(--radius-md); overflow: hidden; aspect-ratio: 9/16; }
.video-thumb video, .video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-play-btn {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35);
  transition: background 0.15s;
  cursor: pointer;
}
.video-play-btn:hover { background: rgba(0,0,0,.5); }
.video-play-btn svg { color: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,.6)); }

/* ---------- Stats bar in battle/arena ---------- */
.stat-bar-wrap { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--muted); }
.stat-bar { flex: 1; background: var(--border); border-radius: 99px; height: 5px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.4s; }
