/* ═══════════════════════════════════════════════════════════════
   DECK BUILDER
   ═══════════════════════════════════════════════════════════════ */

/* ── Page tabs ── */
.deck-page-tabs {
  display: flex;
  gap: 0;
  padding: 20px 32px 0;
  max-width: 1200px;
  margin: 0 auto;
  border-bottom: 1px solid var(--border-color);
}
.deck-page-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 24px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.deck-page-tab:hover { color: var(--text-primary); }
.deck-page-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}
.deck-page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ── My Decks shelf ── */
.deck-shelf-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 24px;
  gap: 10px;
}
.deck-shelf-actions {
  display: flex;
  gap: 10px;
}
.deck-shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 0;
}

/* ── Deck Tiles (My Decks shelf) ── */
.deck-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  height: 200px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.deck-tile:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
.deck-tile-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 30%;
  z-index: 0;
}
.deck-tile-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.15);
}
.deck-tile-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 50%, transparent 100%);
  z-index: 1;
}
.deck-tile-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  z-index: 2;
}
.deck-tile-format {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(4px);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.deck-tile-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  line-height: 1.2;
  margin-bottom: 4px;
}
.deck-tile-meta {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
}
.deck-tile-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  border: none;
  color: rgba(255,255,255,0.6);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.deck-tile:hover .deck-tile-delete {
  opacity: 1;
}
.deck-tile-delete:hover {
  color: #f87171;
  background: rgba(0,0,0,0.7);
}

/* ── Deck Editor layout (2-panel: left sidebar + right visual board) ── */
.deck-editor-layout {
  display: flex;
  height: calc(100vh - 60px);
  overflow: hidden;
}
.deck-visual {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: visible;
  background: var(--bg-primary, #0a0a0f);
  position: relative;
}
.deck-visual-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
}
.deck-visual-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.deck-visual-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
}
/* Fan view — solitaire columns */
.deck-visual-canvas.fan-view {
  display: flex;
  gap: 16px;
  padding: 24px 24px 40px;
  overflow: auto;
  align-items: flex-start;
}

.deck-solitaire-col {
  flex-shrink: 0;
  min-width: 180px;
}
.deck-solitaire-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding-left: 2px;
}
.deck-solitaire-stack {
  position: relative;
  width: 180px;
}

/* Deck visual cards */
.deck-visual-card {
  position: relative;
  width: 180px;
  border-radius: 4.5% / 3.2%;
  overflow: visible;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  will-change: transform;
}
.deck-visual-card:hover {
  transform: translateY(-12px) scale(1.25);
  z-index: 9999 !important;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.deck-visual-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4.5% / 3.2%;
  pointer-events: none;
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}
/* Deck visual card placeholder */
.deck-visual-card-placeholder {
  width: 180px;
  height: 252px;
  background: var(--surface-2);
  border: 1px dashed var(--border-color);
  border-radius: 4.5% / 3.2%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 8px;
}

/* Commander display */
.deck-commander-display {
  flex-shrink: 0;
  margin-right: 24px;
  padding-right: 24px;
  border-right: 1px solid var(--border-color);
}
.deck-commander-card {
  width: 220px !important;
}
.deck-commander-card img {
  width: 100%;
  height: auto;
  border-radius: 4.5% / 3.2%;
}

/* Sideboard separator */
.deck-solitaire-sideboard {
  margin-left: 12px;
  padding-left: 24px;
  border-left: 2px dashed var(--border-color);
}
.deck-solitaire-sideboard .deck-solitaire-label {
  color: var(--accent-primary);
}

/* Stats aside — right side of editor */
.deck-stats-aside {
  width: 260px;
  flex-shrink: 0;
  border-left: 1px solid var(--border-color);
  background: var(--surface);
  overflow-y: auto;
  padding: 16px;
}

.deck-sidebar {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border-color);
}
.deck-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
}

/* ── Deck list toolbar ── */
.deck-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-shrink: 0;
}
.deck-list-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.deck-list-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  outline: none;
  border-bottom: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  cursor: text;
}
.deck-list-name:focus { border-bottom-color: var(--accent); }
.deck-format-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  flex-shrink: 0;
}
.deck-list-actions { display: flex; gap: 4px; }
.deck-tool-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}
.deck-tool-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.deck-tool-btn--danger:hover { color: #f87171; border-color: #f87171; }
.deck-tool-btn svg { width: 14px; height: 14px; }

/* ── Buy toolbar ── */
.deck-buy-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.deck-buy-count { font-size: 0.8rem; color: var(--text-secondary); }

/* ── Card groups ── */
#deckCardGroups { overflow-y: auto; flex: 1; padding-bottom: 20px; }
.deck-group { padding: 0 0 4px; }
.deck-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 4px;
}
.deck-group:first-child .deck-group-header { border-top: none; margin-top: 0; }
.deck-group-count {
  background: var(--surface-2);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 0.65rem;
}
.deck-row {
  display: flex;
  align-items: center;
  padding: 5px 14px;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.deck-row:hover { background: var(--surface-2); }
.deck-row-check {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.deck-row-qty {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.deck-row-name {
  font-size: 0.8rem;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-row-price {
  font-size: 0.72rem;
  color: #2dd4bf;
  flex-shrink: 0;
}
.deck-row-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.1s;
}
.deck-row:hover .deck-row-controls { opacity: 1; }
.deck-row-btn {
  background: var(--surface-3);
  border: none;
  color: var(--text-secondary);
  border-radius: 4px;
  width: 18px;
  height: 18px;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}
.deck-row-btn:hover { background: var(--accent); color: #fff; }
.deck-row-buy {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  flex-shrink: 0;
}
.deck-row:hover .deck-row-buy { opacity: 1; }
.deck-row-buy:hover { color: var(--accent); }
.deck-row-buy svg { width: 12px; height: 12px; }

/* Card hover preview */
.deck-card-preview {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  width: 200px;
  border-radius: 4.5% / 3.2%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  display: none;
}
.deck-card-preview img { width: 100%; border-radius: 4.5% / 3.2%; display: block; }

/* ── Search panel ── */
.deck-search-panel {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.deck-search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}
.deck-search-input:focus { border-color: var(--accent); }
.deck-search-results {
  margin-top: 8px;
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.deck-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}
.deck-search-row:hover { background: var(--surface-2); }
.deck-search-thumb {
  width: 32px;
  height: 44px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--surface-3);
}
.deck-search-info { flex: 1; min-width: 0; }
.deck-search-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-search-sub { font-size: 0.72rem; color: var(--text-secondary); }
.deck-search-owned {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  background: rgba(45,212,191,0.15);
  color: #2dd4bf;
  flex-shrink: 0;
}
.deck-search-add-sb {
  font-size: 0.68rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: none;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.deck-search-add-sb:hover { border-color: var(--accent); color: var(--accent); }

/* ── Stats panel ── */
.deck-stats-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.deck-stat-block { margin-bottom: 18px; }
.deck-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.deck-validity { display: flex; flex-direction: column; gap: 6px; }
.deck-validity-ok {
  font-size: 0.82rem;
  color: #4ade80;
  font-weight: 600;
}
.deck-validity-warn {
  font-size: 0.78rem;
  color: #facc15;
  padding: 6px 10px;
  background: rgba(250,204,21,0.08);
  border-radius: 6px;
  border-left: 3px solid #facc15;
}
.deck-count-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.deck-count-text { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.deck-count-progress {
  flex: 1;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.deck-count-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}
.deck-mana-curve {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
}
.deck-mana-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  height: 100%;
  justify-content: flex-end;
}
.deck-mana-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}
.deck-mana-count {
  font-size: 0.6rem;
  color: var(--text-primary);
  font-weight: 600;
  min-height: 14px;
}
.deck-mana-label {
  font-size: 0.6rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.deck-color-pips {
  display: flex;
  gap: 8px;
  align-items: center;
}
.deck-color-pip {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 900;
}
