/* ============================================================
   EDH Manabase Analyser — Stylesheet
   ============================================================

   Token architecture — two layers:

   Layer 1 — Primitive tokens
   Raw values. Define the full palette. Never used directly
   in component styles.

   Layer 2 — Semantic tokens
   Intent-based aliases. All component styles reference
   these only. To retheme, remap semantics.
   ============================================================ */

:root {

  /* ----------------------------------------------------------
     PRIMITIVE TOKENS
     ---------------------------------------------------------- */

  --color-brand-300: #cfd9ce;
  --color-brand-500: #9bad99;
  --color-brand-700: #384838;

  --color-neutral-950: #080e07;
  --color-neutral-900: #151f14;
  --color-neutral-850: #242c21;
  --color-neutral-700: #495c4a;
  --color-neutral-200: #e3e9e2;
  --color-neutral-100: #f8fbf9;

  --color-green-500:  #4caf7a;
  --color-green-900:  #2a4a2a;
  --color-amber-500:  #d4942a;
  --color-gold-500:   #e9cf5b;
  --color-red-500:    #c94c4c;

  --color-mana-W: #d4cfc4;
  --color-mana-U: #4a7fc1;
  --color-mana-B: #8a6fa8;
  --color-mana-R: #c94c4c;
  --color-mana-G: #4caf7a;
  --color-mana-C: #7a7668;

  /* ----------------------------------------------------------
     SEMANTIC TOKENS
     ---------------------------------------------------------- */

  --brand:       var(--color-brand-500);
  --brand-light: var(--color-brand-300);
  --brand-dark:  var(--color-brand-700);

  --bg-deep:  var(--color-neutral-950);
  --bg-card:  var(--color-neutral-900);
  --bg-panel: var(--color-neutral-850);

  --border:       var(--color-neutral-700);
  --border-brand: var(--color-brand-500);

  --text:       var(--color-neutral-100);
  --text-muted: var(--color-neutral-200);
  --text-dim:   var(--color-brand-500);

  --green: var(--color-green-500);
  --gold:  var(--color-gold-500);
  --amber: var(--color-amber-500);
  --red:   var(--color-red-500);

  --white-mana:     var(--color-mana-W);
  --blue-mana:      var(--color-mana-U);
  --black-mana:     var(--color-mana-B);
  --red-mana:       var(--color-mana-R);
  --green-mana:     var(--color-mana-G);
  --colorless-mana: var(--color-mana-C);

  /* Typography — fonts */
  --font-display: 'Geist', sans-serif;
  --font-body:    'Geist', sans-serif;
  --font-mono:    'Geist Mono', monospace;

  /* Typography — major third scale (1.25 ratio, base 16px) */
  --text-xs:   0.64rem;
  --text-sm:   0.8rem;
  --text-base: 1rem;
  --text-h6:   1.25rem;
  --text-h5:   1.563rem;
  --text-h4:   1.953rem;
  --text-h3:   2.441rem;
  --text-h2:   3.052rem;
  --text-h1:   3.815rem;

  /* Spacing — 8pt scale */
  --space-0:  0;
  --space-1:  1px;
  --space-2:  2px;
  --space-4:  4px;
  --space-8:  8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --space-40: 40px;
  --space-48: 48px;
  --space-64: 64px;
  --space-80: 80px;
  --space-96: 96px;

  /* Radius */
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-lg:   8px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:         0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:         0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:         0 8px 32px rgba(0,0,0,0.5);
  --shadow-brand:      0 0 0 1px var(--color-brand-700);
  --shadow-brand-glow: 0 0 16px rgba(155,173,153,0.15);

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(.45,.3,.53,1);
  --transition-base: 0.2s cubic-bezier(.45,.3,.53,1);
  --transition-slow: 0.8s cubic-bezier(.45,.3,.53,1);
}


/* ============================================================
   RESET & BASE
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(201,168,76,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(74,127,193,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(76,175,122,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}


/* ============================================================
   LAYOUT
   ============================================================ */

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--space-24);
  position: relative;
  z-index: 1;
}


/* ============================================================
   UTILITY — Hidden state
   ============================================================ */

.hidden { display: none !important; }


/* ============================================================
   HEADER
   ============================================================ */

header {
  padding: var(--space-48) 0 var(--space-32);
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-48);
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-12);
}

.header-eyebrow {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4em;
  color: var(--brand);
  text-transform: uppercase;
  text-align: left;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(var(--text-h3), 5vw, var(--text-h1));
  font-weight: 900;
  color: var(--brand-light);
  letter-spacing: 0.05em;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow: 0 0 60px rgba(201,168,76,0.2);
  text-align: left;
}

h1 span {
  display: block;
  font-weight: 400;
  font-size: 0.55em;
  color: var(--text-muted);
  letter-spacing: 0.2em;
  margin-top: var(--space-8);
}


/* ============================================================
   INPUT SECTION
   ============================================================ */

.input-section {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-24);
  margin-bottom: var(--space-40);
  align-items: stretch;
}

@media (max-width: 700px) {
  .input-section { grid-template-columns: 1fr; }
}

.input-group {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: var(--space-12);
}

.input-group label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.25em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: var(--space-8);
}

textarea {
  width: 100%;
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  padding: var(--space-16);
  resize: vertical;
  min-height: 220px;
  transition: border-color var(--transition-base);
}

textarea:focus {
  outline: none;
  border-color: var(--brand-dark);
}

textarea::placeholder { color: var(--text-dim); }

/* Text input wrap (flex column when visible) */
.text-input-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}


/* ============================================================
   COMMANDER CARD PICKER
   ============================================================ */

.commander-card-picker {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: border-color var(--transition-base);
}

.commander-card-picker:focus-within {
  border-color: var(--brand);
}

.commander-search-state {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.commander-card-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-12);
  padding: var(--space-24);
  color: var(--text-dim);
}

.card-placeholder-icon {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.commander-placeholder-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
}

.commander-search-field {
  padding: var(--space-12);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
}

.commander-search-field input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px var(--space-12);
  transition: border-color var(--transition-base);
}

.commander-search-field input:focus {
  outline: none;
  border-color: var(--brand);
}

.commander-search-field input::placeholder { color: var(--text-dim); }

.commander-selected-state {
  position: relative;
  width: 100%;
  height: 100%;
}

.commander-card-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.commander-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 33%;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
}

.commander-card-name { display: none; }

.commander-change-btn {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  color: rgba(255,255,255,0.8);
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-base);
}

.commander-change-btn:hover {
  background: rgba(0,0,0,0.85);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}


/* ============================================================
   AUTOCOMPLETE DROPDOWN
   ============================================================ */

.autocomplete-wrap { position: relative; }

.autocomplete-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-brand);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-card);
  color: var(--text);
}


/* ============================================================
   FORMAT NOTE & BUTTONS
   ============================================================ */

.format-note {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px var(--space-16);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.format-note strong {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.format-note code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--brand);
}

.btn-analyse {
  width: 100%;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  border: none;
  border-radius: var(--radius-md);
  color: var(--bg-deep);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  padding: var(--space-16);
  cursor: pointer;
  transition: all var(--transition-base);
  text-transform: uppercase;
}

.btn-analyse:hover {
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(201,168,76,0.3);
}

.btn-analyse:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-reset {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 10px var(--space-20);
  cursor: pointer;
  transition: all var(--transition-base);
  text-transform: uppercase;
  display: block;
  margin: 0 auto 60px;
}

.btn-reset:hover {
  border-color: var(--brand-dark);
  color: var(--brand);
}


/* ============================================================
   FEEDBACK — Loading, Error, Warning
   ============================================================ */

.loading {
  display: none;
  text-align: center;
  padding: 60px 0;
}

.loading.active { display: block; }

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 12px rgba(155,173,153,0.2);
  margin: 0 auto var(--space-16);
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading p {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.error-msg {
  display: none;
  background: rgba(201,76,76,0.1);
  border: 1px solid rgba(201,76,76,0.3);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--red);
  font-size: 14px;
  margin-bottom: var(--space-24);
}

.error-msg.active { display: block; }

.warning-msg {
  display: none;
  background: rgba(212,148,42,0.1);
  border: 1px solid rgba(212,148,42,0.3);
  border-radius: var(--radius-md);
  padding: var(--space-12) var(--space-16);
  color: var(--amber);
  font-size: 13px;
  margin-bottom: var(--space-16);
}

.warning-msg.active { display: block; }


/* ============================================================
   RESULTS
   ============================================================ */

#results { display: none; }
#results.active { display: block; animation: fadeUp 0.4s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ============================================================
   SCORE HERO
   ============================================================ */

.score-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-32);
  align-items: center;
  background: var(--bg-panel);
  border: 1px solid var(--color-brand-700);
  border-radius: var(--radius-lg);
  padding: var(--space-32);
  margin-bottom: var(--space-32);
  box-shadow: var(--shadow-lg), var(--shadow-brand-glow);
}

@media (max-width: 600px) {
  .score-hero { grid-template-columns: 1fr; text-align: center; }
}

.score-ring {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.score-ring svg { transform: rotate(-90deg); }

.score-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 6;
}

.score-ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease, stroke var(--transition-base);
}

.score-number {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-number strong {
  font-family: var(--font-display);
  font-size: var(--text-h4);
  font-weight: 900;
  line-height: 1;
}

.score-number span {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.score-details h2 {
  font-family: var(--font-display);
  font-size: clamp(var(--text-h3), 4vw, var(--text-h2));
  font-weight: 600;
  color: var(--brand-light);
  margin-bottom: 6px;
}

.score-grade {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-bottom: var(--space-12);
}

.score-summary {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 520px;
}


/* ============================================================
   DECK STATS BAR
   ============================================================ */

.deck-stats {
  display: flex;
  gap: var(--space-24);
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-20) var(--space-24);
  margin-bottom: var(--space-24);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stat-label {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.stat-value.highlight { color: var(--brand-light); }

.stat-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

.stat-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
}


/* ============================================================
   SECTION TITLES
   ============================================================ */

.section-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: var(--space-20);
  padding-bottom: var(--space-12);
  border-bottom: 1px solid var(--border);
}

/* Modifier: no bottom border/spacing (used in manabase header) */
.section-title--flush {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* Modifier: extra top margin (used before category grid) */
.section-title--spaced {
  margin-top: var(--space-8);
}


/* ============================================================
   MANA CURVE
   ============================================================ */

.curve-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-24);
  margin-bottom: var(--space-24);
}

.curve-bars {
  display: flex;
  align-items: flex-end;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
}

.curve-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  flex: 1;
}

.curve-bar {
  width: 100%;
  background: linear-gradient(to top, var(--brand-dark), var(--brand));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: height 0.6s ease;
  min-height: 2px;
}

.curve-bar.land-bar {
  background: linear-gradient(to top, var(--color-green-900), var(--green));
}

.curve-label {
  font-family: var(--font-display);
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.curve-count {
  font-size: 12px;
  color: var(--text-muted);
}


/* ============================================================
   COLOUR PIPS & LAND BREAKDOWN
   ============================================================ */

.colour-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-24);
  margin-bottom: var(--space-24);
}

.colour-pips {
  display: flex;
  gap: var(--space-12);
  flex-wrap: wrap;
  margin-bottom: var(--space-20);
}

.pip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.pip-symbol {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  border: 2px solid rgba(255,255,255,0.1);
}

.pip-label {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.pip-count {
  font-size: 12px;
  color: var(--text-muted);
}

.pip-W { background: rgba(212,207,196,0.15); color: var(--white-mana); }
.pip-U { background: rgba(74,127,193,0.15);  color: var(--blue-mana); }
.pip-B { background: rgba(138,111,168,0.15); color: var(--black-mana); }
.pip-R { background: rgba(201,76,76,0.15);   color: var(--red-mana); }
.pip-G { background: rgba(76,175,122,0.15);  color: var(--green-mana); }
.pip-C { background: rgba(122,118,104,0.15); color: var(--colorless-mana); }

.land-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-12);
  margin-top: var(--space-16);
}

.land-type-item {
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  padding: var(--space-12) 14px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.land-type-name {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.land-type-count {
  font-size: var(--text-h5);
  font-weight: 600;
  color: var(--text);
}

.land-type-pct {
  font-size: 12px;
  color: var(--text-muted);
}


/* ============================================================
   MULLIGAN PROBABILITY
   ============================================================ */

.mulligan-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-24);
  margin-bottom: var(--space-24);
}

.mulligan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-16);
}

.mulligan-stat {
  text-align: center;
  padding: var(--space-16);
  background: var(--bg-panel);
  border-radius: var(--radius-md);
}

.mulligan-stat .value {
  font-family: var(--font-display);
  font-size: var(--text-h5);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.mulligan-stat .label {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.mulligan-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: var(--space-12);
  font-style: italic;
}


/* ============================================================
   CATEGORY CARDS
   ============================================================ */

.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-16);
  margin-bottom: var(--space-32);
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-20);
  transition: border-color var(--transition-base);
}

.category-card:hover { border-color: var(--color-brand-500); box-shadow: var(--shadow-brand-glow); }

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.category-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--brand);
  text-transform: uppercase;
  display: flex;
  align-items: center;
}

.category-score {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.score-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 14px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width var(--transition-slow);
}

.traffic-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  margin-right: var(--space-8);
  flex-shrink: 0;
  margin-top: var(--space-4);
}

.category-feedback {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 0;
}

/* Status utilities */
.status-green { color: var(--green); }
.status-amber { color: var(--amber); }
.status-red   { color: var(--red); }

.bar-green { background: var(--green); }
.bar-amber { background: var(--amber); }
.bar-red   { background: var(--red); }

.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red); }


/* ============================================================
   INFOTIPS
   ============================================================ */

.infotip-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 10px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  font-family: var(--font-display);
  margin-left: 6px;
  vertical-align: middle;
}

.infotip-btn:hover {
  border-color: var(--brand-dark);
  color: var(--brand);
}

.infotip-panel {
  display: none;
  margin-top: var(--space-12);
  padding: var(--space-12) 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-brand);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

.infotip-panel.open {
  display: block;
  animation: fadeUp 0.2s ease;
}

.infotip-panel strong {
  display: block;
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.infotip-panel .formula {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-top: var(--space-8);
  color: var(--text);
  display: block;
  line-height: 1.6;
}


/* ============================================================
   RECOMMENDATIONS
   ============================================================ */

.recommendations {
  background: var(--bg-panel);
  border: 1px solid var(--border-brand);
  border-radius: var(--radius-lg);
  padding: var(--space-24);
  margin-bottom: var(--space-40);
}

.rec-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rec-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: var(--space-12) 14px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  transition: background var(--transition-fast);
}

.rec-item.priority-high   { border-left-color: var(--red);   background: rgba(201,76,76,0.04); }
.rec-item.priority-medium { border-left-color: var(--amber); background: rgba(212,148,42,0.04); }
.rec-item.priority-low    { border-left-color: var(--green); background: rgba(76,175,122,0.04); }

.rec-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.rec-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.rec-text strong {
  color: var(--text);
  font-weight: 600;
}


/* ============================================================
   URL INPUT & TOGGLE
   ============================================================ */

.url-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.url-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 12px 14px;
  transition: border-color var(--transition-base);
}

.url-input:focus {
  outline: none;
  border-color: var(--brand-dark);
}

.url-input::placeholder { color: var(--text-dim); }

.url-input-row .btn-analyse {
  width: auto;
  padding: 12px 20px;
  white-space: nowrap;
}

.paste-toggle {
  display: inline-block;
  margin-top: 8px;
  color: var(--brand);
  font-size: 12px;
  text-decoration: none;
  opacity: 0.8;
  transition: opacity var(--transition-fast);
}

.paste-toggle:hover { opacity: 1; }


/* ============================================================
   MANABASE VISUALISER
   ============================================================ */

.manabase-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-16);
  margin-bottom: var(--space-24);
}

.manabase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-20);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.manabase-count {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-panel);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: -2px;
  margin-bottom: 5px;
}

/* Groups */
.manabase-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.mb-group {
  /*styling*/
}

.mb-group:last-child { margin-bottom: var(--space-8); }

.mb-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
}

.mb-group-name {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.mb-group-count {
  font-family: var(--font-display);
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-panel);
  padding: 2px 8px;
  border-radius: 20px;
}

/* Card rows */
.mb-card-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mb-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.mb-card-row:hover { background: var(--bg-panel); }

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

.mb-card-name {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.mb-card-row:hover .mb-card-name { color: var(--text); }

.mdfc-badge {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--brand);
  background: rgba(155,173,153,0.15);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

.mb-card-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: var(--space-12);
}

.mb-qty {
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--text-dim);
  min-width: 16px;
  text-align: center;
}

.mb-qty-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all var(--transition-fast);
}

.mb-qty-btn:hover {
  border-color: var(--brand);
  color: var(--text);
}

.mb-remove-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.mb-card-row:hover .mb-remove-btn { opacity: 1; }
.mb-remove-btn:hover { color: var(--red); }

/* Add land search bar */
.manabase-add {
  margin-top: var(--space-16);
  padding-top: var(--space-16);
  border-top: 1px solid var(--border);
}

.manabase-search-input {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 14px;
  transition: border-color var(--transition-base);
}

.manabase-search-input:focus {
  outline: none;
  border-color: var(--brand);
}

.manabase-search-input::placeholder { color: var(--text-dim); }

/* Manabase autocomplete opens downward */
.manabase-add .autocomplete-dropdown {
  bottom: auto;
  top: 100%;
  border-top: none;
  border-bottom: 1px solid var(--border-brand);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}


/* ============================================================
   CARD PREVIEW (desktop hover)
   ============================================================ */

.card-preview-float {
  display: none;
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.6));
}

.card-preview-float img {
  width: 200px;
  border-radius: 8px;
  display: block;
}


/* ============================================================
   CARD MODAL (mobile tap)
   ============================================================ */

.card-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.card-modal-overlay.open {
  display: flex;
  animation: fadeUp 0.2s ease;
}

.card-modal {
  position: relative;
  padding: var(--space-16);
}

.card-modal img {
  width: min(80vw, 300px);
  border-radius: 12px;
  display: block;
}

.card-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}


/* ============================================================
   MOBILE — stacked card rows
   ============================================================ */

@media (max-width: 767px) {
  .mb-card-row {
    cursor: pointer;
  }

  .mb-card-name {
    font-size: 13px;
  }

  .mb-remove-btn {
    opacity: 1;
  }

  .card-preview-float { display: none !important; }
}


/* ============================================================
   STATE 1 — LANDING
   ============================================================ */

.state-landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  margin-bottom: var(--space-40);
}

.landing-input-wrap {
  width: 100%;
  max-width: 640px;
}

.landing-label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.25em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.landing-footer {
  margin-top: var(--space-12);
  text-align: center;
}


/* ============================================================
   STATE 2 — TEXT INPUT (two-column)
   ============================================================ */

.state-text-input .input-section {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-24);
  margin-bottom: var(--space-40);
  align-items: stretch;
}

@media (max-width: 700px) {
  .state-text-input .input-section { grid-template-columns: 1fr; }
}


/* ============================================================
   STATE 3 — POST-ANALYSIS LAYOUT
   ============================================================ */

.state-analysis {
  margin-bottom: var(--space-32);
}

.analysis-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-24);
  align-items: start;
}

@media (max-width: 700px) {
  .analysis-layout { grid-template-columns: 1fr; }
}

.analysis-commander {
  flex-shrink: 0;
}

.analysis-commander label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.25em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: var(--space-8);
}

.analysis-commander-card {
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.analysis-commander-selected {
  position: relative;
  width: 100%;
  height: 100%;
}

.analysis-commander-selected .commander-card-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.analysis-commander-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: var(--space-16);
  text-align: center;
}

.analysis-manabase {
  min-width: 0; /* prevent overflow in grid */
  height: 100%;
}

.analysis-manabase-title {
  display: flex;
  flex-direction: row;
  gap: var(--space-8);
}

.analysis-manabase label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.25em;
  color: var(--brand);
  text-transform: uppercase;
  margin-bottom: var(--space-8);
}

.analysis-manabase .manabase-section {
  margin-bottom: 0;
}


/* ============================================================
   MANABASE — ACCORDION GROUPS
   ============================================================ */

.mb-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-bottom: var(--space-4);
}

.mb-group-header.open {
  background: var(--bg-panel);
}

.mb-group-header:hover { background: var(--bg-panel); }

.mb-group-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.mb-accordion-icon {
  width: 12px;
  height: 12px;
  color: var(--text-dim);
  transition: transform var(--transition-base);
  flex-shrink: 0;
}

.mb-group-header.open .mb-accordion-icon {
  transform: rotate(180deg);
}

/* Card list hidden by default, shown when accordion open */
.mb-card-list {
  display: none;
  padding: 0 var(--space-4);
  margin-bottom: var(--space-8);
}

.mb-card-list.open {
  display: block;
  border: solid 1px var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
}
