/* ============================================================
   Wild Hybrids — design system (hand-rewritten from
   the Tailwind config used in the original Next.js codebase).
   No utility framework; every class is a named component.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&family=Inter:wght@400;500;600;700&family=Playfair+Display:ital,wght@1,700&family=Trade+Winds&family=Grechen+Fuemen&display=swap');

:root {
  --bg: #14110d;
  --surface: #1d1914;
  --surface2: #251f17;
  --border: #332b20;
  --accent: #d4a942;
  --accent2: #b8923a;
  --ink: #f1e8d5;
  --muted: #a89b80;
  --common: #8a7d65;
  --rare: #c8924c;
  --epic: #e8b942;
  --legendary: #fbd784;

  --font-display: 'Merriweather', 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 { 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(212, 169, 66, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(184, 146, 58, 0.08), 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: 0 1rem 0; }
}

.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; }

/* ---------- Top nav ---------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(10px);
  background: rgba(20, 17, 13, 0.78);
  border-bottom: 1px solid var(--border);
}
.topnav-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1rem 0.75rem 10px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: -0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .brand { margin-left: calc((72rem - 100vw) / 2); }
}
.brand img { width: 60px; height: auto; padding: 0; }
@media (max-width: 480px) {
  .brand img { width: 45px; }
}
.brand:hover { color: var(--accent); }
.brand-title {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0 -0.4rem;
  line-height: 1;
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: -0.02em;
}
.brand-title .epic {
  font-family: 'Playfair Display', serif;
  font-size: 2.6rem;
  font-weight: 700;
  font-style: italic;
  color: var(--accent);
  text-shadow: 0 2px 8px rgba(212,169,66,0.3);
}
.brand-title .hybrids {
  font-size: 1.4rem;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.nav-links {
  display: none;
  gap: 0.25rem;
}
@media (min-width: 768px) {
  .nav-links { display: flex; }
}
.nav-link {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--ink); background: rgba(212, 169, 66, 0.06); }
.nav-link.active { color: var(--accent); }
.nav-link-icon { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 0.6rem; }

.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
  cursor: pointer;
}
@media (min-width: 768px) { .nav-toggle { display: none; } }
@media (max-width: 767px) {
  .topnav-inner > a[href="/profile.php"],
  .topnav-inner > .btn { display: none; }
}
.nav-mobile {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 0.5rem 1rem;
}
.nav-mobile.open { display: block; }
.nav-mobile .nav-link { display: block; padding: 0.75rem 0.5rem; }

/* ---------- 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.95rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  background: none;
  color: var(--ink);
  user-select: none;
  text-align: center;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  border-color: rgba(212, 169, 66, 0.4);
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.4);
}
.btn-primary:hover:not(:disabled) {
  background: var(--legendary);
  color: var(--bg);
  box-shadow: 0 8px 20px -4px rgba(212, 169, 66, 0.3);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: rgba(212, 169, 66, 0.6);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.4rem 0.7rem;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); }

.btn-danger {
  background: transparent;
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.7);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}
.input, .select, .textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0.625rem 0.9rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 169, 66, 0.18);
}
.textarea { min-height: 80px; resize: vertical; }
.input-narrow { max-width: 12rem; }
.field-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.field-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) {
  .field-grid-2 { grid-template-columns: 1fr 1fr; }
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

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

/* ---------- Headings ---------- */
h1 {
  font-family: 'Grechen Fuemen', Georgia, serif;
  text-transform: uppercase;
}

h2, h3, h4, h5, h6 {
  font-family: 'Trade Winds', Georgia, serif;
}

.h-display {
  font-family: 'Trade Winds', Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 0;
}
.h1 { font-size: 1.875rem; line-height: 1.35; font-family: 'Grechen Fuemen', Georgia, serif; }
.h2 { font-size: 1.5rem; line-height: 1.35; font-family: 'Trade Winds', Georgia, serif; }
.h3 { font-size: 1.15rem; line-height: 1.35; font-family: 'Trade Winds', Georgia, serif; }
@media (min-width: 768px) {
  .h1 { font-size: 2.5rem; }
  .h2 { font-size: 1.875rem; }
}

.subtitle { font-size: 0.9rem; color: var(--muted); margin-top: 0.35rem; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.center { text-align: center; }

.gold-underline {
  background-image: linear-gradient(transparent 70%, rgba(212, 169, 66, 0.35) 70%);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  padding: 0 0.1em;
}

/* ---------- Animal grid + cards ---------- */
.grid-animals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (min-width: 640px) {
  .grid-animals { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .grid-animals { grid-template-columns: repeat(4, 1fr); }
}

.animal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.2s;
}
.animal-card:hover {
  border-color: rgba(212, 169, 66, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
}
.animal-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface2);
  overflow: hidden;
}
.animal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.animal-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.animal-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.2;
}
.animal-species { font-size: 0.7rem; font-style: italic; color: var(--muted); }
.animal-footer { margin-top: auto; padding-top: 0.5rem; }

/* ---------- Badges (rarity) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 1px solid transparent;
}
.rarity-common     { background: rgba(138, 125, 101, 0.10); color: var(--common);    border-color: rgba(138, 125, 101, 0.30); }
.rarity-rare       { background: rgba(200, 146, 76, 0.10);  color: var(--rare);      border-color: rgba(200, 146, 76, 0.30); }
.rarity-epic       { background: rgba(232, 185, 66, 0.10);  color: var(--epic);      border-color: rgba(232, 185, 66, 0.40); }
.rarity-legendary  {
  background: rgba(251, 215, 132, 0.10);
  color: var(--legendary);
  border-color: rgba(251, 215, 132, 0.40);
  text-shadow: 0 0 12px rgba(251, 215, 132, 0.45);
}
.rarity-aggressive { background: rgba(220, 80, 60, 0.10);   color: #f87171;          border-color: rgba(220, 80, 60, 0.35); }
.rarity-exotic     {
  background: rgba(139, 92, 246, 0.10);
  color: #c4b5fd;
  border-color: rgba(139, 92, 246, 0.35);
  text-shadow: 0 0 10px rgba(139, 92, 246, 0.35);
}

/* ---------- Tables ---------- */
.table-wrap {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table thead {
  background: var(--surface2);
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.table th, .table td { padding: 0.75rem; vertical-align: middle; }
.table tr + tr td { border-top: 1px solid var(--border); }
.table .right { text-align: right; }
.thumb-sm {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface2);
}
.thumb-sm img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.alert-error  { background: rgba(248, 113, 113, 0.10); color: #fca5a5; border-color: rgba(248, 113, 113, 0.40); }
.alert-ok     { background: rgba(212, 169, 66, 0.10);  color: var(--accent); border-color: rgba(212, 169, 66, 0.40); }
.alert-info   { background: rgba(168, 155, 128, 0.10); color: var(--ink); border-color: var(--border); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 17, 13, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
@media (min-width: 768px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  width: 100%;
  max-width: 42rem;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeIn 0.25s ease-out;
}
@media (min-width: 768px) { .modal { border-radius: var(--radius-xl); } }
.modal-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
}
.modal-head h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; margin: 0; }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-foot {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
}
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-md);
}
.icon-btn:hover { color: var(--ink); background: var(--surface2); }

/* ---------- Hero (landing) ---------- */
.hero {
  display: grid;
  gap: 2rem;
  padding: 2rem 0 3rem;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
}
.hero p {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 38rem;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s ease-out;
  pointer-events: auto;
}
.toast.error { border-color: rgba(248, 113, 113, 0.5); color: #fca5a5; }
.toast.ok    { border-color: rgba(212, 169, 66, 0.5); color: var(--accent); }

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.9s linear infinite; }
.fade-in { animation: fadeIn 0.3s ease-out; }

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface2);
  border-radius: var(--radius-md);
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  background-size: 200% 100%;
  animation: shimmer 2.5s linear infinite;
}

/* ---------- Utility helpers (small set) ---------- */
.hidden { display: none !important; }
.tiny { font-size: 0.75rem; }
.small { font-size: 0.85rem; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.gap-sm { gap: 0.5rem; }
.gap    { gap: 0.75rem; }
.gap-lg { gap: 1.25rem; }
.text-error  { color: #fca5a5; }

/* ---------- Feed 3-column layout (sidebars + main) ---------- */
.feed-page .shell { max-width: none !important; width: 100%; padding-left: .25rem; padding-right: .25rem; padding-bottom: 0; }

.feed-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (min-width: 1200px) {
  .feed-layout { grid-template-columns: 1fr 820px 1fr; gap: 0.5rem; 
  min-height: 100vh;}
}

.feed-sidebar { display: none; }
@media (min-width: 1200px) {
  .feed-sidebar {
    display: block;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .feed-sidebar::-webkit-scrollbar {
    width: 0 !important;
  }
}

.feed-sidebar .card { padding: 0.875rem; }

@media (min-width: 1200px) {
  .feed-layout > div {
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .feed-layout > div::-webkit-scrollbar {
    width: 0 !important;
  }
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.sidebar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.sidebar-thumb {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border);
  transition: border-color 0.15s, transform 0.15s;
  display: block;
}
.sidebar-thumb:hover {
  border-color: rgba(212, 169, 66, 0.5);
  transform: scale(1.04);
}
.sidebar-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* ---------- Feed post media ---------- */
.post-media-img {
  display: block;
  max-width: 360px;
  width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius-md);
}
.post-media-vid {
  display: block;
  max-width: 360px;
  width: 100%;
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  border-radius: var(--radius-md);
  background: var(--surface2);
  object-fit: contain;
}

/* ---------- Compact stat bars (library cards, breed variants) ---------- */
.stat-mini {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 0.4rem;
}
.stat-mini-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--muted);
  line-height: 1;
}
.stat-mini-label { width: 24px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-mini-track { flex: 1; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.stat-mini-fill  { height: 100%; border-radius: 2px; background: var(--accent); }
.stat-mini-val   { width: 24px; text-align: right; flex-shrink: 0; }

/* ---------- Full stat block (collection-detail, user profile) ---------- */
.stat-block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1.25rem;
}
.stat-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.stat-row-label { width: 60px; color: var(--muted); flex-shrink: 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-row-track { flex: 1; height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.stat-row-fill  { height: 100%; border-radius: 3px; background: var(--accent); }
.stat-row-val   { width: 28px; text-align: right; flex-shrink: 0; font-weight: 600; color: var(--ink); font-size: 0.82rem; }

/* ---------- Sidebar guide links ---------- */
.sidebar-guides { display: flex; flex-direction: column; gap: 4px; margin-top: 0.5rem; }
.sidebar-guide-link {
  display: flex; align-items: center; gap: 6px;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.sidebar-guide-link:hover { color: var(--accent); background: rgba(212,169,66,0.07); }
