/* ── Collection page ── */
.col-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 32px 40px 24px;
  gap: 16px;
}
.col-page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 36px;
  font-weight: 300;
  margin-bottom: 4px;
}
.col-page-sub { font-size: 13px; color: var(--muted); }
.col-loading  { padding: 60px; text-align: center; color: var(--muted); font-size: 14px; }

/* ── Collection grid ── */
.col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 0 40px 60px;
}

/* ── Collection card ── */
.col-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
}
.col-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.col-card-illustration {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  object-position: center 20%;
  display: block;
  background: var(--tag-bg);
}
.col-card-illustration-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tag-bg);
  color: var(--muted);
  font-size: 32px;
}
.col-card-body { padding: 14px 16px; }
.col-card-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-card-meta { font-size: 12px; color: var(--muted); }

/* Badge total cards */
.col-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

/* Bouton supprimer sur la card */
.col-card-delete {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  backdrop-filter: blur(4px);
}
.col-card:hover .col-card-delete { opacity: 1; }

/* ── Color bar ── */
.col-card-colors {
  display: flex;
  height: 4px;
  border-radius: 0 0 2px 2px;
  overflow: hidden;
}
.col-card-color-bar { flex: 1; }

/* ── Modals ── */
.col-modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

/* Color picker */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.color-swatch:hover   { transform: scale(1.15); }
.color-swatch.active  { border-color: var(--accent); transform: scale(1.15); }

/* ── Detail layout ── */
.detail-layout {
  display: flex;
  gap: 0;
  flex: 1;
  min-height: 0;
}
.detail-main {
  flex: 1;
  padding: 32px 32px 60px;
  overflow-y: auto;
  min-width: 0;
}
.detail-header { margin-bottom: 24px; }

/* ── Detail toolbar (filters + count) ── */
.detail-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.detail-toolbar .filters-wrap {
  opacity: 1;
  pointer-events: all;
  transform: none;
  transition: none;
}

/* Stats panel */
.detail-stats {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 32px 24px;
  overflow-y: auto;
}
.stats-section  { margin-bottom: 20px; }
.stats-label    { font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stats-value    { font-family: 'Cormorant Garamond', serif; font-size: 28px; font-weight: 400; color: var(--text); }
.stats-divider  { height: 1px; background: var(--border); margin: 20px 0; }
.stats-bars     { display: flex; flex-direction: column; gap: 8px; }

.stat-bar-row   { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.stat-bar-label { width: 72px; flex-shrink: 0; color: var(--muted); text-transform: capitalize; }
.stat-bar-track { flex: 1; height: 6px; background: var(--tag-bg); border-radius: 3px; overflow: hidden; }
.stat-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    background-image: linear-gradient(rgba(255,255,255,0.1), transparent);
}
.stat-bar-count { width: 28px; text-align: right; color: var(--text); font-weight: 500; }

/* Mana colors for bars */
.bar-W { background: var(--ms-mana-w, #fdfbce); }
.bar-U { background: var(--ms-mana-u, #bcdaf7); }
.bar-B { background: var(--ms-mana-b, #a7999e); }
.bar-R { background: var(--ms-mana-r, #f19b79); }
.bar-G { background: var(--ms-mana-g, #9fcba6); }
.bar-C { background: var(--ms-mana-c, #d0c6bb); }
.bar-common   { background: #aaa; }
.bar-uncommon { background: #8ab0d4; }
.bar-rare     { background: #c8a830; }
.bar-mythic   { background: #d4784a; }

/* Bar colors for card types */
.bar-Creature     { background: #5d8aa8; } /* Bleu acier */
.bar-Instant      { background: #a2c4c9; } /* Cyan pastel */
.bar-Sorcery      { background: #7b68ee; } /* Violet */
.bar-Enchantment  { background: #ec9abe; } /* Rose */
.bar-Artifact     { background: #967155; } /* Marron bronze */
.bar-Planeswalker { background: #f08080; } /* Corail */
.bar-Land         { background: #3cb371; } /* Vert moyen */
.bar-Battle       { background: #d2b48c; } /* Tan / Sable */
.bar-Legendary    { background: #ff6347; } /* Tomate */

/* Special types */
.bar-Tribal       { background: #9370db; }
.bar-Token        { background: #c0c0c0; }
.bar-Unknown      { background: #555555; }

/* Optional extensions types (Optionnel) */
.bar-Plane, .bar-Phenomenon, .bar-Vanguard, 
.bar-Scheme, .bar-Conspiracy { 
    background: #4682b4; 
}

/* ── Card in detail grid ── */
.detail-card-wrap {
  position: relative;
  cursor: pointer;
  gap: 6px;
}
.detail-card-wrap:hover img { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.18); }
.detail-card-wrap img {
  width: 100%;
  height: auto;
  aspect-ratio: 3/4;
  border-radius: 6px;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.2s ease;
  background-color: var(--tag-bg);
}
.detail-card-controls {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.7);
  border-radius: 14px;
  padding: 2px 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}
.detail-card-wrap:hover .detail-card-controls { opacity: 1; }
.ctrl-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s;
}
.ctrl-btn:hover { background: rgba(255,255,255,0.2); }
.ctrl-qty {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}
.ctrl-delete {
  color: #ff6b6b;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 6px;
  margin-left: 2px;
}
.detail-card-info { padding: 0 2px; }
.detail-card-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* Grille dense pour la vue détail */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding: 0;
}

/* ── Add to collection modal ── */
.add-col-modal {
  flex-direction: column;
  max-width: 420px;
  width: 90vw;
  padding: 32px;
  position: relative;
  border-radius: 16px;
  max-height: 85vh;
  overflow-y: auto;
}
.add-col-card-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.add-col-card-preview img {
  width: 56px;
  border-radius: 5px;
  box-shadow: var(--shadow);
}
.add-col-card-name   { font-family: 'Cormorant Garamond', serif; font-size: 18px; font-weight: 600; }
.add-col-card-type   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.add-col-section     { font-size: 10px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.add-col-list        { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.add-col-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
}
.add-col-item:hover  { border-color: var(--accent); background: var(--tag-bg); }
.add-col-dot         { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.add-col-item-name   { flex: 1; font-size: 14px; font-weight: 500; }
.add-col-item-count  { font-size: 12px; color: var(--muted); }
.add-col-divider     { height: 1px; background: var(--border); margin: 4px 0 16px; }
.add-col-new {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 4px;
  transition: color var(--transition);
}
.add-col-new:hover { color: var(--text); }

/* ── Card preview (hover) ── */
.card-preview {
  position: fixed;
  pointer-events: none;
  z-index: 999;
  display: none;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.card-preview img    { width: 240px; display: block; }
.card-preview.visible { display: block; }

/* ── Card modal ── */
.modal-img {
  flex-shrink: 0;
  width: 300px;
  background: var(--tag-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 12px;
}
.modal-img img { width: 100%; border-radius: 10px; box-shadow: var(--shadow); }
.modal-info    { flex: 1; padding: 32px 28px; overflow-y: auto; position: relative; }
.modal-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 4px;
}
.modal-type    { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.modal-tags    { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.modal-divider { height: 1px; background: var(--border); margin: 20px 0; }
.modal-section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 18px;
}
.modal-oracle {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--tag-bg);
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--border);
}
.modal-prices { display: flex; gap: 12px; margin-top: 6px; }
.price-item   { display: flex; flex-direction: column; gap: 2px; }
.price-label  { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.price-value  { font-size: 15px; font-weight: 500; color: var(--text); }

/* ── Tags ── */
.tag {
  padding: 4px 10px;
  background: var(--tag-bg);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
}
.tag.rarity-common   { border-color: #aaa; }
.tag.rarity-uncommon { border-color: #8ab0d4; color: #8ab0d4; }
.tag.rarity-rare     { border-color: #c8a830; color: #c8a830; }
.tag.rarity-mythic   { border-color: #d4784a; color: #d4784a; }
.tag-mana { display: flex; align-items: center; gap: 2px; padding: 4px 8px; }

/* ── Oracle formatting ── */
.oracle-line { margin: 0; line-height: 1.7; }
.oracle-line + .oracle-line { padding-top: 4px; border-top: 1px solid var(--border); }
.oracle-reminder { font-style: italic; color: var(--muted); font-size: 0.92em; }
.oracle-saga,
.oracle-planeswalker { display: flex; align-items: flex-start; gap: 10px; }
.oracle-saga-icons   { display: flex; gap: 3px; flex-shrink: 0; padding-top: 2px; }
.oracle-saga-icons .ms,
.oracle-pw-icon .ms  { font-size: 1.4em; }
.oracle-pw-icon      { flex-shrink: 0; padding-top: 2px; }
.oracle-saga-text,
.oracle-pw-text      { flex: 1; line-height: 1.6; }

/* ── Filters ── */
.filters-wrap {
  width: 100%;
  max-width: 640px;
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity var(--transition), transform var(--transition);
  position: relative;
  z-index: 300;
}
.filters-wrap.visible { opacity: 1; pointer-events: all; transform: translateY(0); }

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 5px;
}
.filter-btn:hover  { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.filter-dropdown { position: relative; display: flex; align-items: center; }
.filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 220px;
  display: none;
}
.filter-panel.open { display: block; }
.filter-panel-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.filter-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
#colorPanel .filter-options { grid-template-columns: repeat(2, 1fr); }
#typePanel  .filter-options { grid-template-columns: repeat(2, 1fr); }

.filter-option {
  padding: 7px 8px;
  justify-content: center;
  text-align: center;
  min-width: 0;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-option:hover    { border-color: var(--accent); }
.filter-option.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Mana color filters */
.mana-W { background: var(--ms-mana-w, #fdfbce); border-color: color-mix(in srgb, var(--ms-mana-w, #fdfbce) 60%, #999); color: #6a5a10; }
.mana-U { background: var(--ms-mana-u, #bcdaf7); border-color: color-mix(in srgb, var(--ms-mana-u, #bcdaf7) 60%, #555); color: #1a3f6a; }
.mana-B { background: var(--ms-mana-b, #a7999e); border-color: color-mix(in srgb, var(--ms-mana-b, #a7999e) 60%, #222); color: #fff; }
.mana-R { background: var(--ms-mana-r, #f19b79); border-color: color-mix(in srgb, var(--ms-mana-r, #f19b79) 60%, #933); color: #6a1a0a; }
.mana-G { background: var(--ms-mana-g, #9fcba6); border-color: color-mix(in srgb, var(--ms-mana-g, #9fcba6) 60%, #363); color: #1a4a22; }
.mana-C { background: var(--ms-mana-c, #d0c6bb); border-color: color-mix(in srgb, var(--ms-mana-c, #d0c6bb) 60%, #888); color: #4a4540; }


/* Badge foil sur la miniature */
.foil-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, #ffd700, #ff69b4, #00bfff, #ffd700);
  background-size: 300% 300%;
  animation: foil-badge-shift 2s linear infinite;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  letter-spacing: 0.05em;
  pointer-events: none;
  z-index: 2;
}
 
@keyframes foil-shimmer {
  0%   { background-position: 0%   0%;   }
  50%  { background-position: 100% 100%; }
  100% { background-position: 0%   0%;   }
}
 
@keyframes foil-badge-shift {
  0%   { background-position: 0%   50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0%   50%; }
}

/* Foil toggle dans le détail de collection (sur la carte) */
.ctrl-foil {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 6px;
  margin-left: 2px;
  transition: color 0.15s;
}
.ctrl-foil.active {
  background: linear-gradient(135deg, #ffd700, #ff69b4, #00bfff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Effet Foil pour le Modal */
#modalImgFoil {
    position: relative;
    overflow: visible;
    perspective: 1000px;
    --foil-x: 50%;
    --foil-y: 50%;
}

#modalImg {
  transition: none;
  will-change: transform;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  z-index: 1;
}

#modalImgFoil.foil::after {
  content: "";
  position: absolute;
  /* On agrandit un peu l'overlay pour éviter les bords nets lors du pivot */
  top: -5%; left: -5%; right: -5%; bottom: -5%;
  pointer-events: none;
  z-index: 3;
  border-radius: 10px;
  opacity: 0.5;
  mix-blend-mode: color-dodge;
  
  /* Le dégradé suit maintenant la variable --foil-x */
  background: 
    radial-gradient(circle at var(--foil-x) var(--foil-y), rgba(255, 255, 255, 0.7) 0%, transparent 50%),
    linear-gradient(110deg, 
      transparent 10%, 
      rgba(255, 0, 255, 0.3) 30%, 
      rgba(0, 255, 255, 0.3) 50%, 
      rgba(255, 255, 0, 0.3) 70%, 
      transparent 90%
  );
  
  background-size: 200% 200%;
  animation: foil-shimmer 10s linear infinite;
  transition: opacity 0.3s;
}

@keyframes foil-shimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.search-wrap input {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  min-width: 200px;
}

.search-wrap input:focus {
  border-color: var(--accent);
}

/* Back to top button */
#backToTop {
    display: none; /* Caché par défaut */
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
    border: none;
    outline: none;
    background-color: var(--accent, #c8972a);
    color: white;
    cursor: pointer;
    border-radius: 50%; /* Bouton rond */
    width: 50px;
    height: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, opacity 0.3s;
}

#backToTop:hover {
    transform: translateY(-5px);
    background-color: var(--accent-hover, #a67c21);
}

#backToTop.show {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Compare select ── */
.compare-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.compare-select:focus { border-color: var(--accent); }
 
.compare-vs {
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 300;
  color: var(--muted);
  margin: 4px 0 16px;
}
 