/* ---------------------------------------------------------------------------
   Card Tier List — an extension of "The Eclipse Table" theme (styles.css).
   Every color below is either a shared token or a documented one-off blend
   within the same warm-gold/cool-lilac family; no new hues are introduced.

   Signature device: the "eclipse ramp." Instead of the usual red-orange-
   green tier-list ladder, each tier row's left rail reuses the landing
   hero's corona motif — a gold glow that is brightest at S and fades to
   near-black shadow at F, so scrolling the page re-plays an eclipse from
   corona to totality. Tier *letters* stay high-contrast ink/gold regardless
   (the ramp lives in the decorative rail + glow, never in body text), so
   the signature never costs legibility.
   --------------------------------------------------------------------------- */

:root {
  /* Rarity accents: gold(rare) and the app's existing "ember" top-tier
     accent (RATING_TIER_COLORS[0] in app.js) for mythic are direct reuses.
     --rarity-uncommon is the one net-new value here — MTG's real-world
     silver rarity frame, tuned into the same cool lilac-grey family as
     --muted/--line so it reads as "this system's silver," not a foreign hue. */
  --rarity-common: var(--muted);
  --rarity-uncommon: #c7c2d6;
  --rarity-rare: var(--gold);
  --rarity-mythic: #ff7a42;

  /* Eclipse ramp: six-step luminance/saturation falloff built only from
     existing tokens (gold-soft -> gold -> gold-deep -> muted -> line-soft
     -> bg-deep), plus a matching glow intensity per step. */
  --tier-s-color: var(--gold-soft);
  --tier-s-glow: 0 0 22px rgba(232, 200, 126, 0.55), 0 0 46px rgba(217, 171, 74, 0.25);
  --tier-a-color: var(--gold);
  --tier-a-glow: 0 0 14px rgba(217, 171, 74, 0.4);
  --tier-b-color: var(--gold-deep);
  --tier-b-glow: 0 0 8px rgba(143, 108, 30, 0.35);
  --tier-c-color: var(--muted);
  --tier-c-glow: none;
  --tier-d-color: var(--line-soft);
  --tier-d-glow: none;
  --tier-f-color: var(--bg-deep);
  --tier-f-glow: none;
}

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

.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  background: var(--gold);
  color: #241a06;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}
.skip-link:focus { transform: translateY(0); }

body { padding-bottom: 40px; }

#main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px 0;
}

/* ---- Topbar tweaks ------------------------------------------------------- */

/* Primary nav in the tier-list header, matching the launch page's top row.
   Non-page items (How it works / Why it's different / Methodology / Give
   Feedback) link to the landing page, where those sections/modals live. */
.tier-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: 28px;
  font-size: 0.98rem;
  font-weight: 600;
}
.tier-nav a { color: var(--ink); text-decoration: none; transition: color 140ms ease; white-space: nowrap; }
.tier-nav a:hover { color: var(--gold); }
.tier-nav a.is-active { color: var(--gold); }
@media (max-width: 900px) { .tier-nav { display: none; } }

.tier-topbar-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* "Start drafting" CTA, matching the landing/guides button (landing.css isn't
   loaded here, so the button styles are scoped locally). */
.tier-topbar-controls .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
  border-radius: 9px;
  padding: 8px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 160ms ease, border-color 140ms ease, background 140ms ease;
}
.tier-topbar-controls .btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: #241a06;
  box-shadow: 0 0 0 1px rgba(217, 171, 74, 0.4), 0 8px 24px -10px rgba(217, 171, 74, 0.7);
}
.tier-topbar-controls .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--gold), 0 12px 30px -10px rgba(217, 171, 74, 0.85);
}
.tier-topbar-controls .btn .arrow { transition: transform 140ms ease; }
.tier-topbar-controls .btn:hover .arrow { transform: translateX(3px); }

/* On narrow screens the set-select + count fill the row, so the CTA wraps to
   its own full-width line rather than overflowing off-screen. */
@media (max-width: 520px) {
  .tier-topbar-controls .btn { flex: 1 0 100%; justify-content: center; }
}

.tier-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.tier-count b { color: var(--ink); font-weight: 600; }

.tier-hint {
  margin: 12px 0 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.tier-page-title {
  margin: 16px 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--ink);
}

/* Crawlable per-set links. The set switcher is a JS-driven <select>, which no
   crawler can follow, so these are the inbound links that let /tiers?set=CODE
   get indexed. They double as a one-tap set switch for everyone else. */
.tier-set-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}
.tier-set-links a {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}
.tier-set-links a:hover { border-color: var(--gold); color: var(--ink); }
.tier-set-links a[aria-current="page"] {
  border-color: var(--gold);
  color: var(--gold-soft);
  background: rgba(217, 171, 74, 0.1);
}

/* ---- Filter bar ------------------------------------------------------------ */

/* Data-confidence banner: shown above the board for draft-only / preview sets. */
.tier-data-note {
  margin: 16px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(217, 171, 74, 0.4);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  background: rgba(217, 171, 74, 0.1);
  color: var(--gold-soft);
  font-size: 0.85rem;
  line-height: 1.4;
}
.tier-data-note[hidden] { display: none; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-search { flex: 1 1 220px; min-width: 180px; }

.filter-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.filter-input,
.filter-select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-family: inherit;
  height: 36px;
}

.filter-input:focus-visible,
.filter-select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.filter-input::placeholder { color: var(--muted); }

/* ---- Search autocomplete (Google-style suggestion dropdown) -------------- */

.search-combo { position: relative; }

.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55);
  max-height: 336px;
  overflow-y: auto;
}
.search-suggest[hidden] { display: none; }

.search-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--ink);
}
.search-suggest-item:hover,
.search-suggest-item.is-active {
  background: var(--panel-2);
}

.ss-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ss-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.ss-tier-pill {
  display: inline-block;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.ss-rating { min-width: 2.4em; text-align: right; }

/* Momentary gold flash on the card a suggestion selection scrolls to. */
.tier-card.search-highlight {
  box-shadow: 0 0 0 3px var(--gold), 0 10px 24px rgba(0, 0, 0, 0.55);
  z-index: 3;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* Base chip: shared by color / rarity / cmc / type toggles. */
.chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 8px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.chip:hover { border-color: var(--gold); }

.chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.chip[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: #171126;
}

/* Color chips: a small mana-colored dot inside a neutral pill, so the
   swatch itself carries the color rather than tinting the whole chip
   (keeps five WUBRG chips from turning the filter bar into a rainbow). */
.chip-color { width: 40px; padding: 0; }
.chip-color .chip-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(236, 231, 219, 0.35);
}
/* W/U/B/R/G and colorless render the vendored Scryfall pip SVG (its own circle). */
.chip-color .chip-pip { width: 18px; height: 18px; display: block; }
/* Multicolor has no single pip symbol, so it keeps a gold swatch. */
.chip-color[data-c="M"] .chip-swatch {
  background: linear-gradient(135deg, #e8c87e, #d9ab4a);
  border-color: var(--gold-deep);
}
.chip-color[aria-pressed="true"] { background: var(--panel-2); border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.chip-color[aria-pressed="true"] .chip-swatch { box-shadow: 0 0 8px rgba(217, 171, 74, 0.6); }
.chip-color[aria-pressed="true"] .chip-pip { filter: drop-shadow(0 0 4px rgba(217, 171, 74, 0.85)); }

.chip-rarity .chip-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.chip-rarity[data-r="common"] .chip-swatch { background: var(--rarity-common); }
.chip-rarity[data-r="uncommon"] .chip-swatch { background: var(--rarity-uncommon); }
.chip-rarity[data-r="rare"] .chip-swatch { background: var(--rarity-rare); }
.chip-rarity[data-r="mythic"] .chip-swatch { background: var(--rarity-mythic); }

.chip-cmc { width: 34px; padding: 0; }

/* Touch devices need a ≥44px tap target. Grow the chips on coarse pointers
   only, so the desktop filter bar stays compact. */
@media (pointer: coarse) {
  .chip { height: 44px; min-width: 44px; }
  .chip-color { width: 44px; }
  .chip-cmc { width: 44px; }
  .tier-set-links a { padding: 11px 14px; }
}

.filter-reset {
  align-self: flex-end;
  height: 36px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-reset:hover { border-color: var(--gold); color: var(--ink); }

/* ---- Tier board ------------------------------------------------------------ */

.tier-board {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel);
}

.tier-row {
  display: flex;
  border-bottom: 1px solid var(--line);
}
.tier-row:last-child { border-bottom: none; }

.tier-rail {
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
}

.tier-letter {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
}

.tier-n {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
}

/* Eclipse-ramp rail: a colored halo behind the letter, brightest at S,
   fading to shadow at F. Encodes rank the way the landing hero's corona
   encodes "signature score," instead of a generic stoplight gradient. */
.tier-row[data-tier="S"] .tier-rail { box-shadow: inset -3px 0 0 var(--tier-s-color); }
.tier-row[data-tier="S"] .tier-letter { color: var(--tier-s-color); text-shadow: var(--tier-s-glow); }
.tier-row[data-tier="A"] .tier-rail { box-shadow: inset -3px 0 0 var(--tier-a-color); }
.tier-row[data-tier="A"] .tier-letter { color: var(--tier-a-color); text-shadow: var(--tier-a-glow); }
.tier-row[data-tier="B"] .tier-rail { box-shadow: inset -3px 0 0 var(--tier-b-color); }
.tier-row[data-tier="B"] .tier-letter { color: var(--tier-b-color); text-shadow: var(--tier-b-glow); }
.tier-row[data-tier="C"] .tier-rail { box-shadow: inset -2px 0 0 var(--tier-c-color); }
.tier-row[data-tier="C"] .tier-letter { color: var(--ink); }
.tier-row[data-tier="D"] .tier-rail { box-shadow: inset -2px 0 0 var(--tier-d-color); }
.tier-row[data-tier="D"] .tier-letter { color: var(--ink); opacity: 0.82; }
.tier-row[data-tier="F"] .tier-rail { box-shadow: inset -1px 0 0 var(--line); }
.tier-row[data-tier="F"] .tier-letter { color: var(--ink); opacity: 0.62; }

.tier-cards {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  padding: 12px;
}

/* Server-rendered card names, replaced by card art as soon as tierlist.js runs.
   Only ever seen by crawlers and no-JS visitors. */
.tier-card-name {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.5;
}

.tier-row.is-empty .tier-cards::after {
  content: "No cards match the current filters.";
  color: var(--muted);
  font-size: 0.8rem;
  padding: 8px 2px;
}

.tier-card {
  flex: none;
  width: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-deep);
  padding: 0;
  cursor: pointer;
  display: block;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  text-decoration: none;
  /* Hundreds of cards stay in the DOM for instant CSS filtering; skip layout/paint
     for off-screen rows. contain-intrinsic-size reserves the card's footprint so
     scrollbars and filtering don't jump. */
  content-visibility: auto;
  contain-intrinsic-size: 106px 76px;
  /* Rapid tap-to-preview flow: no 300ms delay, no grey tap flash. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tier-card:hover,
.tier-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--gold-deep);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.tier-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.tier-card.no-link { cursor: default; }
.tier-card.no-link:hover,
.tier-card.no-link:focus-visible {
  border-color: var(--line);
  box-shadow: none;
  transform: none;
}

.tier-card-img {
  width: 100%;
  display: block;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  background: var(--panel-2);
}

.tier-card.card-hidden { display: none; }

/* Clickable rail: the letter column zooms its tier in/out on click. */
.tier-rail { cursor: pointer; user-select: none; transition: background 120ms ease; }
.tier-rail:hover { background: var(--panel-2); }
.tier-rail::after {
  content: "Zoom";
  font-family: var(--font-mono);
  font-size: 0.56rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 120ms ease;
}
.tier-rail:hover::after { opacity: 0.85; }

/* Zoomed tier: enlarge this row's cards so the art reads at a glance. */
.tier-row.tier-zoomed .tier-cards { gap: 12px; padding: 16px; }
.tier-row.tier-zoomed .tier-card { width: 150px; }
.tier-row.tier-zoomed .tier-rail { background: var(--panel-2); }
.tier-row.tier-zoomed .tier-rail::after { content: "Close"; opacity: 0.85; }

/* Both hover popovers are non-interactive: the hover is tied strictly to
   hovering a card, so leaving a card for empty background always dismisses. */
.tier-scorecard { pointer-events: none; }

/* Touch: shown under the scorecard stats after a first tap. */
.sc-tap-hint {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Hover card-image zoom popover (paired with the stats scorecard). */
.tier-card-zoom {
  position: fixed;
  z-index: 10000;
  width: 240px;
  pointer-events: none;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--gold-deep);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.62);
  background: var(--bg-deep);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 110ms ease, transform 110ms ease;
}
.tier-card-zoom.visible { opacity: 1; transform: scale(1); }
.tier-card-zoom img { width: 100%; display: block; aspect-ratio: 5 / 7; object-fit: cover; }

.tier-status {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 30px 0;
}

/* CC BY 4.0 attribution for the 17Lands-derived ratings on this page. */
.tier-attribution {
  text-align: center;
  color: var(--muted);
  font-size: 0.74rem;
  margin: 18px 0 8px;
}
.tier-attribution a { color: var(--muted); }
.tier-attribution a:hover { color: var(--ink); }

/* ---- Hover scorecard (tier-specific extras only; shell is .scorecard) ---- */

.tier-scorecard .sc-tier-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  margin-left: 8px;
  vertical-align: middle;
}

/* These five metrics span different units (percentages, a signed delta, an
   average pick number, a raw sample count) so a comparable-width bar per
   .sc-bar would be misleading; a plain label/value list reads more honestly. */
.tier-metric-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tier-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
}
.tier-metric-label { color: var(--muted); }
.tier-metric-val { font-family: var(--font-mono); color: var(--ink); font-weight: 600; }

/* ---- Responsive ------------------------------------------------------------ */

@media (max-width: 720px) {
  .tier-topbar-controls { width: 100%; margin-left: 0; justify-content: space-between; flex-wrap: wrap; }
  .filter-bar { gap: 12px; padding: 12px; }
  .filter-search { flex: 1 1 100%; }

  .tier-row { flex-direction: column; }
  .tier-rail {
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .tier-row[data-tier="S"] .tier-rail { box-shadow: inset 0 -3px 0 var(--tier-s-color); }
  .tier-row[data-tier="A"] .tier-rail { box-shadow: inset 0 -3px 0 var(--tier-a-color); }
  .tier-row[data-tier="B"] .tier-rail { box-shadow: inset 0 -3px 0 var(--tier-b-color); }
  .tier-row[data-tier="C"] .tier-rail { box-shadow: inset 0 -2px 0 var(--tier-c-color); }
  .tier-row[data-tier="D"] .tier-rail { box-shadow: inset 0 -2px 0 var(--tier-d-color); }
  .tier-row[data-tier="F"] .tier-rail { box-shadow: inset 0 -1px 0 var(--line); }
  .tier-letter { font-size: 1.5rem; }
  .tier-card { width: 58px; }
}
