/* ══════════════════════════════════════════════════════════════════════════
   TRAILASAUR — Dinopedia styles.css (Discoveries theme)
   Goal: keep Dinopedia structure (Core 7 strip + grid), swap theme to Discoveries.
   Requires: ../_shared/theme.css (fonts, base utilities). This file overrides tokens.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Discoveries Theme Tokens (override) ─────────────────────────────────── */
:root {
  --bg-main:        #11130E;
  --bg-card:        #1A1C15;
  --bg-card-hover:  #22251D;

  --accentMain:     #379392;
  --accentGold:     #D8B67F;

  --textWhite:      rgba(255,255,255,0.90);
  --textMuted:      rgba(255,255,255,0.55);
  --textDim:        rgba(255,255,255,0.30);

  --borderDim:      rgba(255,255,255,0.08);
  --borderHighlight:#379392;

  /* Optional: keep consistent “hero rhythm” if you ever add a hero here */
  --hero-height: 420px;
}

/* Match Media/Discoveries layout primitives exactly */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }

body {
  background-color: var(--bg-main);
  color: var(--textWhite);
}

/* ── Shared utilities (match Discoveries) ────────────────────────────────── */
.container-max { max-width: 1200px; width: 100%; margin-left: auto; margin-right: auto; }
.accent-bar    { width: 40px; height: 4px; background: var(--accentMain); margin-bottom: 8px; }

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

/* ── Nav (CANONICAL) ────────────────────────────────────────────────────── */
.navlink {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--textMuted);
  transition: color 140ms ease;
  text-decoration: none;
}
.navlink:hover   { color: var(--textWhite); }
.navlink--active { color: var(--textWhite); }

/* -------------------------------------------------------------------------
   Controls Header (CANONICAL)
   - Row 1: Search (left) + Sort (right)
   - Row 2: Filters span combined width and wrap inside it
   - Sort height matches search height
   ---------------------------------------------------------------------- */
.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 14px;
  row-gap: 12px;
  align-items: start;

  border: 1px solid var(--borderDim);
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px;
}

/* Search sits in col 1, row 1 */
.controls__left {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Sort sits in col 2, row 1 */
.controls__right {
  grid-column: 2;
  grid-row: 1;

  display: flex;
  align-items: stretch;
  gap: 10px;
}

/* Inputs / selects (unified typography + sizing) */
.control-input,
.control-select {
  border: 1px solid rgba(255,255,255,0.15);
  background: var(--bg-main);
  color: var(--textWhite);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: all 140ms ease;

  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Search takes full width of left column */
.control-input { width: 100%; }
.control-input::placeholder {
  color: var(--textMuted);
  text-transform: none;
  letter-spacing: 0.02em;
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
}

/* Focus behavior (match Discoveries) */
.control-input:focus,
.control-select:focus {
  border-color: var(--accentMain);
  background-color: var(--bg-card-hover);
  box-shadow: 0 0 15px rgba(55,147,146,0.15);
}

/* Sort: same height as search bar */
.control-select {
  min-width: 220px;
  width: 220px;

  height: 40px;
  padding: 0 14px;
  line-height: 40px;

  white-space: nowrap;
}

/* Filters span BOTH columns (combined width), row 2 */
.chip-row {
  grid-column: 1 / -1;
  grid-row: 2;

  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 100%;
}

/* Chips (CANONICAL) */
.chip {
  border: 1px solid var(--borderDim);
  background: var(--bg-main);
  color: var(--textMuted);
  border-radius: 8px;
  padding: 9px 12px;

  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;

  transition: all 140ms ease;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  color: var(--textWhite);
  border-color: rgba(255,255,255,0.20);
}
.chip--active,
.chip[aria-selected="true"] {
  background: rgba(55,147,146,0.15);
  border-color: var(--accentMain);
  color: var(--textWhite);
}

/* Meta row (CANONICAL) */
.meta-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-top: 12px;
}
.meta-row__left,
.meta-row__right { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

.meta-text {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--textMuted);
}

/* Mobile: stack sort under search, filters under that */
@media (max-width: 720px) {
  .controls { grid-template-columns: 1fr; }
  .controls__right {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-end;
  }
  .chip-row {
    grid-column: 1;
    grid-row: 3;
  }
  .control-select { width: 100%; min-width: 0; }
}

/* ── Badges (Discoveries base, Dinopedia variants) ───────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid var(--borderDim);
  white-space: nowrap;
  flex-shrink: 0;
}
.badge--sm { font-size: 9px; padding: 3px 7px; letter-spacing: 0.12em; }

/* Dinopedia badge types */
.badge--clade {
  background: transparent;
  border-color: var(--borderDim);
  color: var(--textMuted);
  opacity: 0.9;
}
.badge--ma {
  background: rgba(255,255,255,0.03);
  border-color: var(--borderDim);
  color: var(--textMuted);
}

/* ── Diet badges (Dinopedia) ────────────────────────────────────────────── */
/* Default (fallback) */
.badge--diet {
  background: rgba(255,255,255,0.03);
  border-color: var(--borderDim);
  color: var(--textMuted);
}

/* Herbivore = green */
.badge--diet-herbivore {
  background: rgba(93,156,89,0.12);
  border-color: rgba(93,156,89,0.55);
  color: #A5D6A7;
}

/* Carnivore = red */
.badge--diet-carnivore {
  background: rgba(231,76,60,0.12);
  border-color: rgba(231,76,60,0.55);
  color: #FF8A80;
}

/* Piscivore = blue */
.badge--diet-piscivore {
  background: rgba(52,152,219,0.12);
  border-color: rgba(52,152,219,0.55);
  color: #90CAF9;
}

.badge--tag {
  background: rgba(255,255,255,0.03);
  border-color: var(--borderDim);
  color: var(--textMuted);
}
.badge--core7 {
  background: rgba(55,147,146,0.12);
  border-color: rgba(55,147,146,0.55);
  color: var(--accentMain);
}

/* ── Core 7 strip (keep structure, recolor) ─────────────────────────────── */
.strip {
  border: 1px solid var(--borderDim);
  border-radius: 12px;
  background: var(--bg-card);
  overflow: hidden;
}

.strip__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--borderDim);
}

.strip__label {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--accentMain);
  font-weight: 700;
}

.strip__note {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  color: var(--textMuted);
}

.strip__row {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.strip__row::-webkit-scrollbar { display: none; }

.strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-right: 1px solid var(--borderDim);
  text-decoration: none;
  transition: background 140ms ease;
  white-space: nowrap;
  flex-shrink: 0;
  gap: 3px;
}
.strip-item:last-child { border-right: none; }
.strip-item:hover { background: var(--bg-card-hover); }

.strip-item__name {
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 12px;
  color: var(--textWhite);
  letter-spacing: -0.01em;
}

.strip-item__clade {
  font-family: "Roboto Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--textMuted);
}

/* ── GRID (keep Dinopedia structure) ─────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── Cards (Discoveries feel, Dinopedia structure) ───────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--borderDim);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
  position: relative;
}

/* Clade-colored top bar */
.card::before {
  content: "";
  display: block;
  height: 3px;
  width: 100%;
  background: var(--clade-color, var(--accentMain));
  flex-shrink: 0;
}

.card:hover {
  border-color: var(--accentMain);
  background: var(--bg-card-hover);
  box-shadow: 0 6px 24px rgba(0,0,0,0.28);
  transform: translateY(-3px);
}

/* Image area */
.card__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0A0B08;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--borderDim);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.card__img-placeholder {
  font-family: "Roboto Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--textMuted);
  opacity: 0.45;
}

/* Body */
.card__body {
  display: flex;
  flex-direction: column;
  padding: 14px 16px 12px;
  flex: 1;
}

.card__badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.card__title {
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 16px;
  color: var(--textWhite);
  letter-spacing: -0.01em;
  margin-bottom: 2px;
  line-height: 1.2;
}

.card__sciname {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  color: var(--textMuted);
  font-style: italic;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.card__desc {
  font-size: 13px;
  color: var(--textMuted);
  line-height: 1.55;
  margin-bottom: 12px;
  flex: 1;
}

/* Trailasaur connection strip */
.card__mascot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(216, 182, 127, 0.20);
  border-bottom: 1px solid rgba(216, 182, 127, 0.20);
  background: rgba(216, 182, 127, 0.05);
  border-radius: 6px;
  padding: 9px 10px;
  margin-bottom: 12px;
}

.card__mascot-label {
  font-family: "Roboto Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--accentGold);
  opacity: 0.75;
}

.card__mascot-name {
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 13px;
  color: #FFE0B2;
  letter-spacing: -0.01em;
}

.card__mascot-tagline {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--textMuted);
  line-height: 1.4;
}

/* Links footer */
.card__links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--borderDim);
}

/* Link style (match Discoveries) */
.link {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accentMain);
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 120ms ease;
}
.link:hover { opacity: 0.75; }
.link--muted { color: var(--textMuted); }
.link--muted:hover { color: var(--textWhite); opacity: 1; }

/* ── Load more (match Discoveries) ───────────────────────────────────────── */
.load-more {
  border: 1px solid var(--borderDim);
  background: var(--bg-card);
  color: var(--textWhite);
  border-radius: 8px;
  padding: 11px 24px;
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
}
.load-more:hover:not(:disabled) {
  border-color: var(--accentMain);
  background: var(--bg-card-hover);
}
.load-more:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

/* ── Detail page support (keep your existing structure) ───────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  /* Prevent grid children from overflowing their track */
  min-width: 0;
  width: 100%;
}

@media (min-width: 900px) {
  .detail-grid { grid-template-columns: 1fr 320px; }
}

.tax-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--borderDim);
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
}
.tax-row:last-child { border-bottom: none; }

.tax-label {
  color: var(--textMuted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
  flex-shrink: 0;
}

.tax-value {
  color: var(--textWhite);
  text-align: right;
  word-break: break-word;
}

.mascot-block {
  border: 1px solid rgba(216, 182, 127, 0.35);
  background: rgba(216, 182, 127, 0.06);
  border-radius: 10px;
  padding: 20px 22px;
  margin: 28px 0;
}

.mascot-block__eyebrow {
  font-family: "Roboto Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accentGold);
  opacity: 0.85;
}

.mascot-block__name {
  font-family: "Montserrat", sans-serif;
  font-weight: 900;
  font-size: 22px;
  color: #FFE0B2;
  letter-spacing: -0.02em;
  margin: 0;
}

.mascot-block__tagline {
  font-family: "Roboto Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(255, 224, 178, 0.75);
  font-style: italic;
  margin: 0;
}

.mascot-block__role {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.70);
  line-height: 1.55;
  margin: 6px 0 0;
}

.mascot-block__footer {
  border-top: 1px solid rgba(216, 182, 127, 0.15);
  padding-top: 10px;
}

.cross-panel {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--borderDim);
}
.cross-panel:last-child { border-bottom: none; }

.cross-panel__heading {
  font-family: "Roboto Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--accentMain);
  margin-bottom: 12px;
}

.cross-panel__items { display: flex; flex-direction: column; gap: 10px; }

.cross-card {
  border: 1px solid var(--borderDim);
  background: var(--bg-main);
  border-radius: 8px;
  padding: 12px 14px;
  transition: border-color 140ms ease, background 140ms ease;
}
.cross-card:hover {
  border-color: var(--accentMain);
  background: var(--bg-card-hover);
}

.cross-card__title {
  display: block;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--textWhite);
  margin-bottom: 4px;
  text-decoration: none;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}
.cross-card__title:hover { color: var(--accentMain); }

.cross-card__excerpt {
  font-size: 12px;
  color: var(--textMuted);
  line-height: 1.5;
  margin: 0;
}
/* -------------------------------------------------------------------------
   Detail page wrappers — replaces misused .controls class
   ---------------------------------------------------------------------- */
.detail-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--borderDim);
  border-radius: 12px;
  padding: 20px;
  /* Critical: grid children need min-width:0 or they ignore the track width */
  min-width: 0;
  overflow: hidden;
  /* Ensure all text wraps rather than escaping the card */
  word-break: break-word;
  overflow-wrap: break-word;
}
@media (min-width: 640px) {
  .detail-card { padding: 28px; }
}
@media (min-width: 1024px) {
  .detail-card { padding: 36px; }
}

.detail-card--sidebar {
  padding: 28px;
  align-self: start;
}

/* detail-card mobile padding handled by min-width cascade above */
