/* ==========================================================================
   Rule Zero · shared components — used by the dashboard AND Play.
   Tokens only (see tokens.css). Old dashboard class names are kept as
   aliases so existing markup keeps working; new code should use the first
   name in each selector list. Game-only pieces live in play/*.css.
   Load order: fonts.css → tokens.css → base.css → components.css → page css.
   ========================================================================== */

/* ── Layout utilities ───────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--sp-2h); }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.divider { height: 1px; background: var(--line); margin: var(--sp-5) 0; }

/* ── Text bits ──────────────────────────────────────────────────────────── */
.eyebrow { text-transform: uppercase; letter-spacing: var(--ls-caps); font-size: var(--fs-10); color: var(--gold); font-weight: var(--fw-bold); }
.subtle-link { font-size: var(--fs-10); }
.text-button { background: none; border: 0; padding: 0; color: var(--muted); font-size: var(--fs-11); }
.text-button:hover { background: none; color: var(--text); }
kbd { font: var(--fw-semibold) var(--fs-10)/1 var(--font-ui); padding: 2px 5px; border-radius: var(--r-1); border: 1px solid var(--white-a22); background: var(--black-a25); color: inherit; letter-spacing: .04em; }

/* ── Badge · chip · status pill ─────────────────────────────────────────── */
.badge { font-size: var(--fs-10); line-height: 1.4; padding: 4px 7px; border-radius: var(--r-1); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.gold { color: var(--gold); border-color: var(--gold-dim); background: var(--gold-a08); }
.badge.green { color: var(--green2); border-color: var(--green-a30); background: var(--green-a08); }
.badge.danger { color: var(--danger); border-color: var(--danger-a30); background: var(--danger-a08); }
.badge.pill, .chip { border-radius: var(--r-pill); }
.chip { display: inline-flex; align-items: center; gap: var(--sp-1h); font-size: var(--fs-11); line-height: 1.2; padding: 3px 9px; border: 1px solid var(--line2); background: var(--black-a25); color: var(--text-hi); white-space: nowrap; }
.chip.gold { color: var(--gold2); border-color: var(--gold-a50); background: var(--gold-a08); }
.chip.danger { color: var(--danger); border-color: var(--danger-a30); background: var(--danger-a08); }
.status, .run-status { display: inline-flex; align-items: center; border: 1px solid var(--green-a30); background: var(--green-a08); color: var(--green2); padding: 4px 8px; border-radius: var(--r-2); font-size: var(--fs-10); text-transform: capitalize; white-space: nowrap; }
.status.live, .run-status.live { color: var(--gold); border-color: var(--gold-dim); background: var(--gold-a08); }
.status.warning, .run-status.warning { color: var(--danger); border-color: var(--danger-a30); background: var(--danger-a08); }
.status-dot { display: inline-block; height: 6px; width: 6px; background: var(--green); border-radius: var(--r-round); margin-right: var(--sp-1h); box-shadow: 0 0 8px var(--green-a30); }

/* ── Mana pips (printed-symbol chips): <span class="pip W">W</span> ─────── */
.mana { display: inline-flex; gap: 3px; align-items: center; }
.pip { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--r-round); height: 17px; min-width: 17px; padding: 0 3px; background: var(--pip-C); color: var(--pip-ink); font-size: var(--fs-10); font-weight: var(--fw-bold); box-shadow: var(--sh-1); letter-spacing: 0; }
.pip.W { background: var(--pip-W); } .pip.U { background: var(--pip-U); } .pip.B { background: var(--pip-B); }
.pip.R { background: var(--pip-R); } .pip.G { background: var(--pip-G); } .pip.C { background: var(--pip-C); }
.pip.lg { height: 24px; min-width: 24px; font-size: var(--fs-13); }
/* .in = inline cost glyph that scales with the surrounding text */
.pip.in { height: 1.45em; min-width: 1.45em; padding: 0; font-size: .78em; margin: 0 1px; vertical-align: -.2em; box-shadow: inset 0 0 0 1px var(--black-a25); }

/* ── Panel · stat · progress · empty ────────────────────────────────────── */
.panel, .progress-panel { padding: 22px 25px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r-3); font-size: var(--fs-12); }
.panel.glass { background: var(--glass); backdrop-filter: blur(10px); border-color: var(--line2); box-shadow: var(--sh-3); }
.stat-inline { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; }
.stat-inline strong { font-size: var(--fs-20); font-weight: var(--fw-medium); color: var(--text); margin-right: 5px; }
.progress, .progress-track { height: 5px; background: var(--panel3); border-radius: var(--r-1); overflow: hidden; margin: 16px 0 11px; }
.progress > div, .progress-track > div { height: 100%; background: var(--gold); transition: width var(--t-4); }
.empty, .empty-results { text-align: center; border: 1px dashed var(--line); border-radius: var(--r-3); padding: 70px 25px; color: var(--muted); }
.loading { display: grid; place-items: center; height: 100vh; font: var(--fs-32) var(--font-display); color: var(--gold); }
.error-state { padding: 50px; font-size: var(--fs-16); line-height: var(--lh-loose); }

/* ── Tabs / navigation underline ────────────────────────────────────────── */
.tabs, .study-tabs { display: flex; gap: 30px; border-bottom: 1px solid var(--line); }
.tabs button, .study-tabs button { border: 0; border-radius: 0; background: none; padding: 15px 1px; color: var(--muted); font-size: var(--fs-14); border-bottom: 2px solid transparent; }
.tabs button:hover, .study-tabs button:hover { background: none; color: var(--text); }
.tabs button.active, .study-tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── App shell: top bar, brand, primary navigation ──────────────────────── */
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid var(--line); background: var(--chrome); gap: var(--sp-5); }
.brand { display: flex; align-items: center; gap: var(--sp-3); color: var(--text); text-decoration: none; font-size: var(--fs-16); font-weight: var(--fw-semibold); letter-spacing: -.5px; }
.brand-symbol { width: 34px; height: 38px; color: var(--gold); }
.brand small { display: block; font-size: var(--fs-10); color: var(--muted); letter-spacing: 2.1px; font-weight: var(--fw-medium); margin-top: var(--sp-1); }
.top-actions { display: flex; align-items: center; gap: var(--sp-2); }
.save-status { font-size: var(--fs-11); color: var(--muted); margin-right: 14px; }
.save-status::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: var(--r-round); background: var(--green); margin-right: 7px; }
.main-nav { display: flex; gap: var(--sp-5); height: 76px; align-items: stretch; min-width: 0; overflow-x: auto; }
.main-nav button, .main-nav a { display: inline-flex; align-items: center; background: none; border: 0; border-radius: 0; color: var(--muted); padding: 0 var(--sp-1); font-size: var(--fs-12); text-decoration: none; border-bottom: 2px solid transparent; flex-shrink: 0; white-space: nowrap; }
.main-nav button:hover, .main-nav a:hover { background: none; color: var(--text); }
.main-nav button.active, .main-nav a.active { color: var(--text); border-bottom-color: var(--gold); }
.main-nav span { margin-left: 5px; background: var(--panel3); border-radius: var(--r-1); padding: 1px 5px; font-size: var(--fs-10); }
.engine-mini { display: flex; align-items: center; gap: var(--sp-2); margin-top: 22px; font-size: var(--fs-11); color: var(--green); }

/* ── Dialog (modal) ─────────────────────────────────────────────────────── */
dialog { border: 1px solid var(--line2); border-radius: var(--r-4); background: var(--panel); color: var(--text); width: min(620px, calc(100vw - 32px)); max-height: 90vh; padding: 27px; box-shadow: var(--sh-4); }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(5px); }
dialog.wide { width: min(960px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { font-size: var(--fs-32); }
.modal-head button { border: 0; background: transparent; font-size: var(--fs-20); padding: 0 5px; }
.modal-body { line-height: var(--lh-loose); color: var(--muted); font-size: var(--fs-12); }
.modal-body p { margin-bottom: 13px; }
.modal-body label { margin-top: 14px; }
.modal-footer { display: flex; justify-content: end; gap: 9px; margin-top: 22px; }
.modal-error { color: var(--danger); line-height: 1.7; font-size: var(--fs-12); margin-top: var(--sp-3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast, #toast { position: fixed; bottom: 23px; left: 50%; transform: translate(-50%, 15px); background: var(--gold2); color: var(--ink); padding: 13px 22px; border-radius: var(--r-2); box-shadow: var(--sh-3); z-index: var(--z-toast); opacity: 0; pointer-events: none; transition: opacity var(--t-3), transform var(--t-3); max-width: 90vw; font-size: var(--fs-12); }
.toast.show, #toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Deck tile: art header + title block (dashboard grid and Play setup) ── */
.deck-tile { padding: 0; text-align: left; overflow: hidden; position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-3); min-width: 0; }
.deck-tile.selected { border-color: var(--gold); box-shadow: var(--ring-soft); }
.deck-art { height: 130px; position: relative; background: linear-gradient(125deg, var(--panel3), var(--felt)); overflow: hidden; }
.deck-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 32%; transition: transform var(--t-4); }
.deck-tile:hover img { transform: scale(1.04); }
.deck-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 30%, color-mix(in srgb, var(--panel) 50%, transparent)); }
.deck-art .mana { position: absolute; bottom: 10px; right: var(--sp-3); z-index: 1; }
.tile-content { padding: 13px 15px 14px; }
.tile-content h3 { font-family: var(--font-display); font-size: var(--fs-24); margin-bottom: 5px; }
.tile-content p { font-size: var(--fs-11); letter-spacing: .3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-content .row { margin-top: 14px; font-size: var(--fs-11); color: var(--muted); }
.tile-content .arrow { margin-left: auto; color: var(--gold); font-size: var(--fs-18); }
.checkmark { position: absolute; right: 11px; top: 10px; border-radius: var(--r-round); width: 20px; height: 20px; background: var(--gold); color: var(--ink); z-index: 1; text-align: center; line-height: 20px; }

/* ── Page frame: container, hero, section heads, deck grid ──────────────── */
.setup { max-width: 1376px; padding: 42px 52px; margin: auto; }
.intro { display: flex; justify-content: space-between; align-items: center; gap: 44px; margin-bottom: 35px; }
.intro .eyebrow { margin-bottom: 16px; }
.intro p { max-width: 450px; line-height: var(--lh-loose); color: var(--muted); font-size: var(--fs-14); margin-top: 18px; }
.intro-note { width: 270px; border-left: 1px solid var(--line); padding-left: 28px; line-height: var(--lh-loose); color: var(--muted); font-size: var(--fs-12); }
.intro-note strong { display: block; color: var(--text); font-size: var(--fs-13); margin-bottom: 7px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 25px 0 15px; }
.section-head h2 { font-family: inherit; font-weight: var(--fw-semibold); font-size: var(--fs-16); }
.section-head span { color: var(--muted); font-size: var(--fs-12); }
.deck-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }

/* ── Responsive: shell, page frame, deck tiles ──────────────────────────── */
@media (max-width: 1120px) {
  .topbar { padding: 0 22px; } .main-nav { gap: var(--sp-3); }
  .setup { padding: 30px; } .intro h1 { font-size: var(--fs-48); } .intro-note { width: 220px; } .deck-art { height: 112px; }
}
@media (max-width: 850px) {
  .topbar { height: auto; min-height: 72px; padding: 13px 20px; flex-wrap: wrap; } .main-nav { height: 48px; } .save-status { display: none; }
  .intro-note { display: none; } .deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .deck-art { height: 155px; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 17px; gap: var(--sp-2); } .brand { font-size: var(--fs-14); } .brand-symbol { width: 27px; } .top-actions { gap: 5px; } .top-actions button { font-size: var(--fs-10); padding: 7px; }
  .main-nav { order: 3; width: 100%; height: 33px; gap: 26px; } .main-nav button, .main-nav a { font-size: var(--fs-11); }
  .setup { padding: 28px 18px; } .intro h1 { font-size: var(--fs-48); } .intro p { font-size: var(--fs-12); }
  .section-head h2 { font-size: var(--fs-14); } .section-head span { font-size: var(--fs-10); }
  .deck-grid { gap: 10px; } .deck-art { height: 110px; } .tile-content { padding: 10px; } .tile-content h3 { font-size: var(--fs-24); } .tile-content p { font-size: var(--fs-10); } .tile-content .row { font-size: var(--fs-10); margin-top: 10px; }
}
