/* Deck list ---------------------------------------------------------- */

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

.deck-list-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
}

.deck-list-card-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.deck-list-legends {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.deck-list-legend-thumb {
  width: 40px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.deck-list-legend-empty {
  width: 40px;
  height: 56px;
  border-radius: 4px;
  border: 1px dashed var(--border);
}

.deck-list-card-meta {
  font-size: 12px;
  color: var(--text-dim);
}

/* Deck detail ---------------------------------------------------------- */

#deck-detail h2 {
  margin: 4px 0 8px;
  font-size: 18px;
}

.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-link-chip {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--cyan) !important;
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 12px;
}

.deck-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.deck-status.invalid { border-left-color: var(--red); }

.deck-status-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.deck-status-sub { font-size: 13px; margin-top: 2px; }

.deck-status-badge {
  padding: 5px 12px;
  border: 1px solid var(--green);
  color: var(--green);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.deck-status.invalid .deck-status-badge { border-color: var(--red); color: var(--red); }

.deck-section { margin-bottom: 22px; }

.deck-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.count-badge {
  font-size: 11px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  text-transform: none;
  letter-spacing: 0;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

/* Same "height: 0 + inline padding-bottom" trick as the app's
   .view-deck-tile - see TILE_RAISE_PX in decks.js. */
.deck-tile {
  position: relative;
  height: 0;
}

.deck-tile-layer {
  position: absolute;
  left: 0;
  width: 100%;
  aspect-ratio: 63 / 88;
  object-fit: cover;
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.deck-tile-empty {
  aspect-ratio: 63 / 88;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 11px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.deck-description {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.deck-description:empty { display: none; }

.deck-description details { border: 1px solid var(--border); border-left: 3px solid var(--cyan); border-radius: 6px; margin: 0 0 8px; background: rgba(255, 255, 255, 0.02); }
.deck-description details:last-child { margin-bottom: 0; }
.deck-description details.dd-combo { border-left-color: var(--purple, #b866ff); }
.deck-description details.dd-side { border-left-color: var(--yellow); }
.deck-description summary { cursor: pointer; padding: 7px 12px; font-weight: 700; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--yellow); list-style: none; display: flex; gap: 8px; user-select: none; }
.deck-description summary::-webkit-details-marker { display: none; }
.deck-description summary::before { content: '\25B8'; color: var(--cyan); transition: transform 0.15s; }
.deck-description details[open] > summary::before { transform: rotate(90deg); }
.deck-description .dd-body { padding: 6px 14px 12px; }
.deck-description .dd-body p { margin: 0; }
.deck-description .dd-body ul { margin: 0; padding-left: 18px; }
.deck-description .dd-body li { margin: 0 0 5px; }
.deck-description .dd-body li:last-child { margin-bottom: 0; }
.deck-description .dd-row { display: grid; grid-template-columns: 88px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.deck-description .dd-row:first-child { border-top: none; padding-top: 2px; }
.deck-description .dd-label { color: var(--cyan); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding-top: 2px; }
@media (max-width: 560px) { .deck-description .dd-row { grid-template-columns: 1fr; gap: 2px; } }
.deck-description .dd-legacy { margin-bottom: 8px; }
.card-tag { color: var(--cyan); border-bottom: 1px dashed var(--cyan); cursor: help; }
@media (min-width: 561px) { .card-tag { white-space: nowrap; } }
.card-tag:hover { color: var(--yellow); border-color: var(--yellow); }
.card-tag-pop { position: fixed; z-index: 80; pointer-events: none; }
.card-tag-pop img { width: min(300px, 38vw, calc((100vh - 20px) * 63 / 88)); aspect-ratio: 63 / 88; object-fit: cover; background: var(--bg-card, #111); border-radius: 10px; border: 2px solid var(--yellow); box-shadow: 0 8px 30px #000c; display: block; }

/* Eddie Cost Curve --------------------------------------------------- */

.ram-curve {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  margin-bottom: 20px;
}

.ram-curve-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

.ram-curve-bar {
  width: 100%;
  background: var(--cyan);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ram-curve-bar-count {
  font-size: 10px;
  font-weight: 800;
  color: #0a0a0f;
  margin-top: 3px;
}

.ram-curve-label {
  font-size: 9px;
  color: var(--text-dim);
}

/* Donuts -------------------------------------------------------------- */

.donut-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-bottom: 20px;
}

.donut-block {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 8px;
}

.donut-block h4 {
  margin: 0 0 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  text-align: center;
}

.donut {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
  flex-shrink: 0;
}

.donut-hole {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.donut-pct { font-size: 16px; font-weight: 800; line-height: 1; }
.donut-sublabel { font-size: 9px; font-weight: 700; margin-top: 2px; }
.donut-count { font-size: 9px; color: var(--text-dim); }

.donut-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 8px;
}

.donut-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 8px;
}

.donut-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Swap plans + sideboard */
.deck-plans { margin-bottom: 16px; }
.plan-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-chip { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px; font-weight: 700; }
.plan-chip.active { border-color: var(--yellow); color: var(--yellow); }
.plan-chip-n { color: var(--cyan); margin-left: 4px; }
.plan-summary { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; }
.plan-out { color: var(--red); }
.plan-in { color: var(--green); }
.deck-tile .swap-badges { position: absolute; top: 4px; left: 4px; z-index: 30; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.swap-badge-in, .swap-badge-out { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px; color: #000; }
.swap-badge-in { background: var(--green); }
.swap-badge-out { background: var(--red); }

/* Redesign (list hero/grid, wide two-column detail) ------------------- */
  /* ---- Layout: the page container comes from style.css (fluid, wide) ---- */
  .clip { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px)); }

  /* ---- Toolbar ---------------------------------------------------------- */
  .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
  .toolbar .grow { flex: 1; min-width: min(100%, 200px); position: relative; }
  .search { width: 100%; background: var(--bg-panel); border: 1px solid var(--border); color: var(--text);
    padding: 9px 38px 9px 12px; border-radius: 6px; font-size: 14px; }
  .search:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
  .kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--text-dim);
    border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; pointer-events: none; }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; }
  .sort { width: auto; min-width: 190px; background-color: var(--bg-panel); border: 1px solid var(--border); color: var(--text); padding: 9px 34px 9px 12px; border-radius: 6px; }
  @media (max-width: 520px) { .sort { width: 100%; } }
  .live { color: var(--text-dim); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-left: auto; white-space: nowrap; }
  .live b { color: var(--yellow); }

  /* ---- Shared bits ------------------------------------------------------ */
  .legend-fan { display: flex; justify-content: center; align-items: flex-end; padding-top: 6px; }
  .legend-fan img { width: 31%; max-width: 130px; aspect-ratio: 63/88; object-fit: cover; border-radius: 6px;
    border: 1px solid rgba(255,255,255,.18); box-shadow: 0 8px 22px rgba(0,0,0,.6); transition: transform .2s; background: var(--bg-card); }
  .legend-fan img:nth-child(1) { transform: rotate(-7deg) translateX(10px); }
  .legend-fan img:nth-child(2) { transform: translateY(-8px); z-index: 1; }
  .legend-fan img:nth-child(3) { transform: rotate(7deg) translateX(-10px); }
  .hoverable:hover .legend-fan img:nth-child(1) { transform: rotate(-11deg) translateX(4px); }
  .hoverable:hover .legend-fan img:nth-child(3) { transform: rotate(11deg) translateX(-4px); }

  .stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); background: rgba(0,0,0,.25); white-space: nowrap; }
  .pill b { color: var(--text); }
  .pill.ok { border-color: rgba(77,255,136,.45); color: var(--green); }
  .pill.warn { border-color: rgba(245,228,0,.45); color: var(--yellow); }
  .dots { display: inline-flex; gap: 4px; align-items: center; }
  .dot { width: 11px; height: 11px; border-radius: 50%; }

  .curve { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
  .curve i { flex: 1; min-width: 6px; background: var(--cyan); opacity: .75; border-radius: 2px 2px 0 0; }
  .curve-wrap { width: 100%; max-width: 260px; }
  .curve-labels { display: flex; gap: 3px; font-size: 9px; color: var(--text-dim); margin-top: 2px; }
  .curve-labels span { flex: 1; text-align: center; }

  .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
  .btn { background: transparent; border: 1px solid var(--border); color: var(--text-dim); font-size: 11px; padding: 6px 10px;
    border-radius: 4px; cursor: pointer; letter-spacing: .05em; text-transform: uppercase; }
  .btn:hover { border-color: var(--cyan); color: var(--cyan); }
  .btn.on { border-color: var(--yellow); color: var(--yellow); }
  .btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

  /* ---- Featured banner -------------------------------------------------- */
  .featured { position: relative; display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: 28px; align-items: center;
    padding: 24px; margin-bottom: 26px; cursor: pointer; border: 1px solid var(--border); border-left: 4px solid var(--accent1);
    background: linear-gradient(120deg, color-mix(in srgb, var(--accent1) 22%, var(--bg-card)) 0%, var(--bg-card) 55%);
    transition: border-color .15s; }
  .featured:hover { border-color: var(--yellow); }
  .featured .tag { position: absolute; top: 0; right: 0; background: var(--yellow); color: #0a0a0f; font-size: 11px;
    font-weight: 800; letter-spacing: .12em; padding: 4px 14px 4px 18px; clip-path: polygon(10px 0,100% 0,100% 100%,0 100%); }
  .featured h2 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 34px); letter-spacing: .02em; text-transform: uppercase; }
  .featured .blurb { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 0 0 16px; max-width: 70ch;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

  /* ---- Grid of deck cards ---------------------------------------------- */
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: clamp(12px, 1.6vw, 20px); }
  .deck { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-top: 3px solid var(--accent1);
    padding: 16px 16px 14px; cursor: pointer; transition: border-color .15s, transform .15s; overflow: hidden; }
  .deck::before { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--accent1) 20%, transparent), transparent 70%); }
  .deck { transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
  .deck:hover { border-color: var(--yellow); transform: translateY(-4px); box-shadow: 0 16px 34px rgba(0, 0, 0, .55), 0 0 0 1px rgba(245, 228, 0, .2); }
  .deck > * { position: relative; }
  .deck h3 { margin: 0 0 4px; font-size: 16px; text-transform: uppercase; letter-spacing: .03em; }
  .deck .sub { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; display: flex; justify-content: space-between; gap: 8px; }
  .deck .legend-fan { margin: 6px 0 14px; }
  .deck .legend-fan img { max-width: 100px; }
  .deck .excerpt { font-size: 12px; color: var(--text-dim); line-height: 1.45; margin: 12px 0 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
  .row-between { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }

  .empty { padding: 40px 14px; text-align: center; border: 1px dashed var(--border); color: var(--text-dim); }
  .skeleton { height: 330px; border: 1px solid var(--border); background: linear-gradient(100deg, var(--bg-card) 30%, #20202b 50%, var(--bg-card) 70%);
    background-size: 200% 100%; animation: sk 1.2s linear infinite; }
  @keyframes sk { to { background-position: -200% 0; } }

  /* ---- Detail view: wide two-column layout ------------------------------ */
  #deck-detail { --accent1: var(--yellow); }
  .detail-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 18px 20px; margin-bottom: 20px;
    border: 1px solid var(--border); border-left: 4px solid var(--accent1);
    background: linear-gradient(120deg, color-mix(in srgb, var(--accent1) 20%, var(--bg-card)) 0%, var(--bg-card) 60%); }
  .detail-hero h2 { margin: 0; font-size: clamp(22px, 3vw, 32px); text-transform: uppercase; letter-spacing: .02em; }
  .detail-hero .grow { flex: 1; min-width: min(100%, 240px); }
  .detail-hero .actions { margin-top: 10px; }
  .detail-hero .detail-links { margin: 12px 0 0; }
  .detail-layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
  .detail-side { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 4px; }
  .detail-side .tile-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .detail-side .donut-row { flex-direction: column; flex-wrap: nowrap; }
  .detail-side .donut-block { width: 100%; flex: none; }
  .detail-main .tile-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  #deck-detail .deck-section { margin-bottom: 26px; }
  #deck-detail .deck-status { margin-bottom: 16px; }

  @media (max-width: 900px) {
    .detail-layout { grid-template-columns: 1fr; }
    .detail-side { position: static; }
    .detail-side .donut-row { flex-direction: row; flex-wrap: wrap; }
    .detail-side .donut-block { flex: 1; min-width: 140px; width: auto; }
    .detail-side .tile-grid { max-width: 420px; }
  }
  @media (max-width: 760px) {
    .featured { grid-template-columns: 1fr; padding: 18px; gap: 14px; }
    .live { margin-left: 0; width: 100%; }
    .toolbar .chips { order: 3; }
    .grid { grid-template-columns: 1fr; }
    .detail-main .tile-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
  }

/* Tags, groups ------------------------------------------------------- */
.tag-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 0; }
.tag-chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); background: rgba(0,0,0,.25); white-space: nowrap; text-decoration: none; }
.tag-chip.cat-archetype { color: var(--cyan); border-color: rgba(29,225,225,.45); }
.tag-chip.cat-creator { color: #ff7b7b; border-color: rgba(255,123,123,.45); }
.tag-chip.cat-misc { color: var(--purple); border-color: rgba(184,102,255,.45); }
.tag-chip.cat-color { font-weight: 800; letter-spacing: .08em; }
a.tag-chip:hover { border-color: currentColor; }
button.tag-chip { cursor: pointer; font-family: inherit; }
button.tag-chip:hover { filter: brightness(1.3); }
button.tag-chip.active { background: rgba(255,255,255,.14); box-shadow: 0 0 0 1px currentColor inset; color: var(--text); }
.tag-filters { display: flex; flex-direction: column; gap: 6px; margin: -6px 0 16px; }
.tag-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-filter-row > b { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); min-width: 72px; }
.grp { margin-bottom: 18px; }
.grp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 6px 10px; border: 1px solid var(--border); border-left: 3px solid var(--yellow); border-radius: 6px; background: var(--bg-card); }
.grp.focus .grp-head { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow) inset; }
.grp.collapsed .grp-head { margin-bottom: 0; }
.grp-toggle { flex: 1; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; cursor: pointer; padding: 4px 0; }
.grp-toggle:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.grp-toggle .count { color: var(--text-dim); font-weight: 400; letter-spacing: 0; text-transform: none; font-size: 12px; margin-left: 8px; }
.tag-guide { margin-bottom: 18px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); }
.tag-guide summary { cursor: pointer; padding: 10px 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 12px; }
.tag-guide dl { margin: 0; padding: 0 14px 12px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
@media (max-width: 560px) { .tag-guide dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .tag-guide dd { margin-bottom: 8px; } }
.tag-guide dt { margin: 0; }
.tag-guide dd { margin: 0; color: var(--text-dim); }
.tag-guide h4 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--yellow); }
