/* ============================================================
   Marvel Compass — Stylesheet
   ============================================================ */

/* --- Reset & base ------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f0f1a;
  --bg-card:     #1a1a2e;
  --bg-card-2:   #16213e;
  --border:      #2a2a4a;
  --text:        #e8e8f0;
  --text-muted:  #8888aa;
  --accent:      #e63946;
  --accent-glow: rgba(230, 57, 70, 0.3);
  --gold:        #f4a261;

  --aggression:  #e63946;
  --justice:     #2a9d8f;
  --leadership:  #457b9d;
  --protection:  #f4a261;
  --basic:       #8888aa;

  --radius:  8px;
  --radius-lg: 14px;
  --shadow:  0 2px 12px rgba(0,0,0,0.5);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header ------------------------------------------------ */
.site-header {
  background: var(--bg-card);
  border-bottom: 2px solid var(--accent);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--text);
  text-decoration: none;
}
.site-logo:hover { text-decoration: none; }
.logo-icon { color: var(--accent); font-size: 1.4rem; }

/* --- Language switcher ------------------------------------- */
.lang-nav {
  margin-left: auto;
  display: flex;
  gap: .3rem;
  align-items: center;
}

.lang-switch {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .25rem .5rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.lang-switch:hover { color: var(--text); text-decoration: none; border-color: var(--border); }
.lang-switch--active { color: var(--accent); border-color: var(--accent); pointer-events: none; }

/* --- Main layout ------------------------------------------- */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- Hero section (homepage banner) ----------------------- */
.page-hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}
.page-hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: .5rem;
}
.page-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 540px;
  margin: 0 auto;
}

/* --- Hero grid (homepage) ---------------------------------- */
.hero-grid-section h2 {
  font-size: 1.2rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 1.5rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2rem;
}

.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform .18s, border-color .18s, box-shadow .18s;
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
}
.hero-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px var(--accent-glow);
  text-decoration: none;
}

.hero-card__art {
  width: 100%;
  aspect-ratio: 5/7;
  background: var(--bg-card-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.hero-card__img--placeholder {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text-muted);
}

.hero-card__body {
  padding: .8rem 1rem;
}
.hero-card__name {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .2rem;
}
.hero-card__meta {
  font-size: .78rem;
  color: var(--text-muted);
}

/* --- Hero detail page -------------------------------------- */
.hero-detail__header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.hero-detail__img {
  width: 140px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.hero-detail__info { flex: 1; min-width: 220px; }

.back-link {
  font-size: .85rem;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: .6rem;
}
.back-link:hover { color: var(--text); }

.hero-detail__name {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: .7rem;
}

.hero-detail__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .35rem .8rem;
  font-size: .88rem;
  color: var(--text-muted);
}
.stat strong { color: var(--text); font-size: 1rem; }

/* --- Filters ----------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
}

.filters__label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-right: .3rem;
}

.filter-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .8rem;
  font-size: .88rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888aa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding-right: 2rem;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

.filter-reset {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .9rem;
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.filter-reset:hover { border-color: var(--accent); color: var(--text); }

.filters__count {
  font-size: .82rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* --- Card list --------------------------------------------- */
.card-list { display: flex; flex-direction: column; gap: .75rem; }

.card-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.card-row:hover { border-color: var(--accent); transform: translateX(2px); text-decoration: none; }
.card-row.hidden { display: none; }

.card-row__art {
  width: 52px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-card-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-row__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.card-row__img--placeholder {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-muted);
}

.card-row__main { flex: 1; min-width: 0; }

.card-row__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .3rem;
}

.card-row__name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--gold);
  flex: 1;
  min-width: 120px;
}
.card-row:hover .card-row__name { color: var(--text); }

.card-row__badges { display: flex; flex-wrap: wrap; gap: .3rem; }

.card-row__text {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: .45rem;
  line-height: 1.5;
}

/* --- Frequency bar ----------------------------------------- */
.card-row__freq {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.freq-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
  max-width: 320px;
}
.freq-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 3px;
  transition: width .3s ease;
}

.freq-label {
  white-space: nowrap;
  font-size: .9rem;
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
}
.freq-label__decks {
  font-size: .78rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* --- Badges ------------------------------------------------ */
.badge {
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 20px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge--cost {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge--cost::before { content: "⬡ "; }

/* Type badges */
.badge--type { background: rgba(136,136,170,.18); color: #aaaacc; }
.badge--type-ally     { background: rgba(100,160,220,.18); color: #88bbee; }
.badge--type-event    { background: rgba(230,180, 60,.18); color: #e6c048; }
.badge--type-upgrade  { background: rgba(100,200,100,.18); color: #80cc80; }
.badge--type-support  { background: rgba(160,100,220,.18); color: #bb88ee; }
.badge--type-resource { background: rgba(100,160,160,.18); color: #80bbbb; }

/* Faction/aspect badges */
.badge--faction-aggression { background: rgba(230,57,70,.2);   color: var(--aggression); }
.badge--faction-justice    { background: rgba(42,157,143,.2);  color: var(--justice); }
.badge--faction-leadership { background: rgba(69,123,157,.2);  color: var(--leadership); }
.badge--faction-protection { background: rgba(244,162,97,.2);  color: var(--protection); }
.badge--faction-basic      { background: rgba(136,136,170,.18);color: var(--basic); }

/* --- Footer ------------------------------------------------ */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1.2rem 2rem;
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--gold); }
.site-footer__algo-link { color: var(--text-muted); }
.site-footer__algo-link:hover { color: var(--gold); }
.site-footer__build { font-size: .72rem; opacity: .45; margin-top: .3rem; }

/* --- Algorithm page ---------------------------------------- */
.algo-page { max-width: 720px; }

.algo-page__title {
  font-size: 2rem;
  font-weight: 800;
  margin: .6rem 0 1.5rem;
}

.algo-page__intro {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 2rem;
  padding: 1rem 1.2rem;
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.algo-section {
  margin-bottom: 2rem;
}

.algo-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.algo-section p {
  color: var(--text-muted);
  line-height: 1.7;
}

.algo-formula__label {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .3rem;
}

.algo-formula {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1.2rem;
  margin-bottom: .8rem;
  overflow-x: auto;
}

.algo-formula code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: .95rem;
  color: var(--text);
}

.algo-formula sup { font-size: .7em; vertical-align: super; }

.algo-formula__legend {
  font-size: .82rem;
  color: var(--text-muted);
  font-style: italic;
}

.algo-table {
  border-collapse: collapse;
  width: 100%;
}
.algo-table th, .algo-table td {
  padding: .6rem .9rem;
  text-align: left;
  border: 1px solid var(--border);
  font-size: .9rem;
}
.algo-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 600;
  width: 140px;
}
.algo-table td { color: var(--text-muted); }
.algo-table td strong { color: var(--text); }

.algo-note {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  font-size: .88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* --- Card detail page -------------------------------------- */
.card-detail__header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.card-detail__art {
  flex-shrink: 0;
  width: 160px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-detail__img {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  display: block;
}

.card-detail__img--placeholder {
  width: 160px;
  height: 224px;
  font-size: 4rem;
  font-weight: 800;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-detail__info { flex: 1; min-width: 220px; }

.card-detail__name {
  font-size: 2rem;
  font-weight: 800;
  margin: .4rem 0 .7rem;
}

.card-detail__badges {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .8rem;
}

.card-detail__traits {
  font-size: .82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: .6rem;
}

.card-detail__text {
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: .9rem;
  max-width: 540px;
}

.card-detail__external {
  font-size: .82rem;
  color: var(--text-muted);
}
.card-detail__external:hover { color: var(--gold); }


/* --- Heroes section (card detail page) --------------------- */
.heroes-section { margin-top: 1rem; }

.section-title {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 1.2rem;
}

.hero-usage-list { display: flex; flex-direction: column; gap: .6rem; }

.hero-usage-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.hero-usage-row:hover {
  border-color: var(--accent);
  transform: translateX(2px);
  text-decoration: none;
}

.hero-usage__art {
  width: 52px;
  height: 68px;
  flex-shrink: 0;
  border-radius: 5px;
  overflow: hidden;
  background: var(--bg-card-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-usage__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.hero-usage__img--placeholder {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-muted);
}

.hero-usage__main { flex: 1; min-width: 0; }

.hero-usage__name {
  display: block;
  font-weight: 700;
  font-size: .95rem;
  color: var(--gold);
  margin-bottom: .35rem;
}
.hero-usage-row:hover .hero-usage__name { color: var(--text); }

/* --- Responsive -------------------------------------------- */
@media (max-width: 600px) {
  .hero-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .hero-detail__img { width: 100px; }
  .hero-detail__name { font-size: 1.5rem; }
}
