/* Deck Tile Components - Shared across My Decks and Public Decks */
/* ── Newtype v2 ── dark HUD aesthetic, neon-green accent ── */

/* Colour badges — UNIVERSAL (mobile + desktop). These used to live only inside
   the >=769px block below, so on mobile the badges rendered as empty (uncoloured)
   circles. Hoisted here so the colored word badges show at every width. */
.color-badge {
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 1px 5px;
}
.color-badge.Blue   { background: rgba(0,100,220,0.8);  color: #cce0ff; }
.color-badge.Green  { background: rgba(20,120,60,0.8);  color: #b0ffcc; }
.color-badge.Red    { background: rgba(180,20,20,0.8);  color: #ffc0c0; }
.color-badge.Purple { background: rgba(100,20,160,0.8); color: #e0b0ff; }
.color-badge.White  { background: rgba(150,150,130,0.8); color: #f0f0e8; }
.color-badge.Yellow { background: rgba(180,140,0,0.8);  color: #ffe88a; }
.color-badge.Black  { background: rgba(30,30,30,0.9);   color: #aaa; }
.color-badge.Null   { background: rgba(80,80,80,0.8);   color: #aaa; }

/* ═══════════════════════════════════════════════════════════
   DESKTOP DECK TILE — Newtype v2 (≥ 769px)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 769px) {

/* ─── Grid ─── */
.decks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
}

/* ─── Deck Tile ─── */
.deck-tile {
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.deck-tile::before,
.deck-tile::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.deck-tile::before {
  top: 0; left: 0;
  border-top: 1.5px solid var(--neon);
  border-left: 1.5px solid var(--neon);
  opacity: 0.45;
}

.deck-tile::after {
  bottom: 0; right: 0;
  border-bottom: 1.5px solid var(--neon);
  border-right: 1.5px solid var(--neon);
  opacity: 0.45;
}

.deck-tile:hover {
  border-color: var(--neon);
  box-shadow: 0 0 16px var(--neon-glow);
  transform: translateY(-2px);
}

.deck-tile:hover::before,
.deck-tile:hover::after { opacity: 1; }

/* ─── Cover Art ─── */
.card-cover {
  position: relative;
  height: 180px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}

.card-cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  opacity: 0.85;
  transition: opacity var(--transition-base), transform var(--transition-base);
}

.deck-tile:hover .card-cover-image {
  opacity: 1;
  transform: scale(1.02);
}

.color-gradient-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  z-index: 2;
}

.card-cover-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 20%, rgba(6,8,5,0.92) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--spacing-md);
  z-index: 1;
}

.card-cover-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.card-cover-colors {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

/* Completion% + deck value row, rendered over the cover image just below
   the color badges. Same shape as .tile-meta-row but tightened so the
   row sits cleanly inside the cover's bottom-fade gradient. */
.card-cover-stats {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ─── Color Badges ─── */
.color-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 1px 5px;
}

.color-badge.Blue   { background: rgba(0,100,220,0.8);  color: #cce0ff; }
.color-badge.Green  { background: rgba(20,120,60,0.8);  color: #b0ffcc; }
.color-badge.Red    { background: rgba(180,20,20,0.8);  color: #ffc0c0; }
.color-badge.Purple { background: rgba(100,20,160,0.8); color: #e0b0ff; }
.color-badge.White  { background: rgba(150,150,130,0.8); color: #f0f0e8; }
.color-badge.Yellow { background: rgba(180,140,0,0.8);  color: #ffe88a; }
.color-badge.Black  { background: rgba(30,30,30,0.9);   color: #aaa; }
.color-badge.Null   { background: rgba(80,80,80,0.8);   color: #aaa; }

/* ─── Favorite Button ─── */
.favorite-button {
  position: absolute;
  top: var(--spacing-sm);
  left: var(--spacing-sm);
  width: 28px;
  height: 28px;
  background: rgba(6,8,5,0.78);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 4;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.favorite-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: rgba(216, 245, 225, 0.75);
  stroke-width: 2;
  stroke-linejoin: miter;
  stroke-linecap: square;
  transition: stroke var(--transition-fast), fill var(--transition-fast);
}

.favorite-button:hover {
  border-color: var(--amber);
  box-shadow: 0 0 8px var(--amber-glow);
  background: rgba(255,184,77,0.12);
}
.favorite-button:hover svg { stroke: var(--amber); }
.favorite-button.favorited svg { fill: var(--amber); stroke: var(--amber); }

/* ─── Action Buttons (Edit / Delete) ─── */
.deck-tile-actions {
  position: absolute;
  top: var(--spacing-sm);
  right: var(--spacing-sm);
  display: flex;
  gap: 4px;
  z-index: 4;
}

.deck-tile-action-btn {
  width: 28px;
  height: 28px;
  background: rgba(6,8,5,0.78);
  backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.deck-tile-action-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: rgba(216, 245, 225, 0.75);
  stroke-width: 1.75;
  stroke-linecap: square;
  stroke-linejoin: miter;
  transition: stroke var(--transition-fast);
}

.deck-tile-action-btn.edit-btn:hover {
  border-color: var(--neon);
  box-shadow: 0 0 6px var(--neon-glow);
  background: rgba(46,255,126,0.12);
}

.deck-tile-action-btn.edit-btn:hover svg {
  stroke: var(--neon);
}

.deck-tile-action-btn.delete-btn:hover {
  border-color: var(--red);
  box-shadow: 0 0 6px rgba(255,59,59,0.35);
  background: rgba(255,59,59,0.12);
}

.deck-tile-action-btn.delete-btn:hover svg {
  stroke: var(--red);
}

/* ─── Tile Content ─── */
.tile-content {
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--spacing-xs);
}

.deck-labels-content {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.tile-description {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: auto 0 0 0;
}

.tile-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;  /* let rows span full width so margin-left:auto pushes children to the right edge */
}

.tile-meta,
.tile-meta-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* Right-align the page-specific trailing element of each footer row:
   - Public Decks: the .deck-rating (stars + count) sits at the right
   - My Decks: the Complete / Incomplete .status-badge sits at the right
   margin-left:auto consumes all remaining row whitespace so any items
   in front of it (creator name, tournament-archived badge, visibility
   toggle) stay left-aligned naturally. */
.tile-meta-row .deck-rating,
.tile-meta-row .status-badge.complete,
.tile-meta-row .status-badge.incomplete {
  margin-left: auto;
}

/* ─── Label Badges ─── */
.label-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  white-space: nowrap;
}

.label-badge.aggro       { background: rgba(255,59,59,0.15);  color: var(--red);    border: 1px solid rgba(255,59,59,0.3); }
.label-badge.control     { background: rgba(0,217,255,0.1);   color: var(--info);   border: 1px solid rgba(0,217,255,0.25); }
.label-badge.midrange    { background: rgba(46,255,126,0.08); color: var(--neon);   border: 1px solid var(--border); }
.label-badge.combo       { background: rgba(150,60,220,0.12); color: #c090ff;       border: 1px solid rgba(150,60,220,0.28); }
.label-badge.competitive { background: rgba(255,184,77,0.12); color: var(--amber);  border: 1px solid rgba(255,184,77,0.3); }
.label-badge.casual      { background: rgba(74,102,87,0.2);   color: var(--text-3); border: 1px solid var(--border); }
.label-badge.default     { background: var(--panel);          color: var(--text-3); border: 1px solid var(--border); }

/* ─── Status Badges (desktop) ─── */
.completion-badge,
.deck-value-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 2px 6px;
  white-space: nowrap;
}

/* Leading neon glyph inside a badge (◢, $, ◆) */
.completion-badge .badge-glyph,
.deck-value-badge .badge-glyph,
.status-badge .badge-glyph {
  color: inherit;
  opacity: 0.85;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0;
}

.status-badge.tournament-archived .badge-glyph {
  color: var(--color-warning);
}

.completion-badge {
  background: rgba(0,217,255,0.08);
  color: var(--info);
  border: 1px solid rgba(0,217,255,0.22);
}

.deck-value-badge {
  background: rgba(46,255,126,0.08);
  color: var(--neon);
  border: 1px solid var(--border);
}

.status-badge.complete {
  background: rgba(46,255,126,0.08);
  color: var(--neon);
  border: 1px solid var(--border);
}

.status-badge.incomplete {
  background: rgba(255,184,77,0.1);
  color: var(--amber);
  border: 1px solid rgba(255,184,77,0.28);
}

.status-badge.public {
  background: rgba(0,217,255,0.08);
  color: var(--info);
  border: 1px solid rgba(0,217,255,0.22);
}

.status-badge.private {
  background: rgba(74,102,87,0.18);
  color: var(--text-3);
  border: 1px solid var(--border);
}

.status-badge.tournament-archived {
  background: rgba(255,215,0,0.1);
  color: var(--color-warning);
  border: 1px solid rgba(255,215,0,0.28);
}

/* ─── Locked tile (gold border) ─── */
.deck-tile.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border: 1.5px solid rgba(255,215,0,0.55);
  pointer-events: none;
  opacity: 1;
  z-index: 10;
}

/* ─── Visibility Toggle — HUD square (Public/Private switch) ─── */
.visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0;
  background: transparent;
  border: none;
  transition: color var(--transition-fast);
}

.visibility-toggle:has(.visibility-checkbox:checked) {
  color: var(--neon);
}

.visibility-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.visibility-slider {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(46, 255, 126, 0.45);
  border-radius: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
}

.visibility-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 8px;
  height: 8px;
  border-radius: 0;
  background: rgba(216, 245, 225, 0.55);
  transition: left var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.visibility-checkbox:checked + .visibility-slider {
  background: rgba(46, 255, 126, 0.1);
  border-color: var(--neon);
}

.visibility-checkbox:checked + .visibility-slider::after {
  left: 16px;
  background: var(--neon);
  box-shadow: 0 0 6px var(--neon-glow);
}

.visibility-toggle:hover .visibility-slider {
  border-color: var(--neon);
}

.visibility-label { color: inherit; }

/* ─── Creator Info (public decks) ─── */
.deck-creator {
  display: flex;
  align-items: center;
  gap: 5px;
}

.creator-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.creator-name {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  letter-spacing: 0.04em;
}

/* ─── Stars / Rating ─── */
.deck-rating { display: flex; align-items: center; gap: 4px; }
.stars { display: flex; gap: 1px; }
.star { font-size: 11px; color: var(--text-3); line-height: 1; }
.star.filled { color: var(--amber); }
.rating-count { font-family: var(--font-mono); font-size: 9px; color: var(--text-3); }

} /* end @media (min-width: 769px) */


/* ===========================================================
 * Mobile compact tiles with cover-card backgrounds (Phase 5)
 *
 * On mobile, each .deck-tile becomes a card-art-backed banner:
 * the deck's cover card image fills the tile, with a left-to-right
 * dark scrim providing legibility for the deck name and status
 * pill that overlay on top.
 *
 * Decorative chrome (favorite, edit, delete, color gradient bar,
 * label badges, description, completion %, deck value, visibility
 * toggle, tournament-archived badge) is hidden — those actions
 * still live in the deck-details modal (which itself slides up
 * as a sheet via Phase 2).
 * =========================================================== */
@media (max-width: 768px) {
    /* Decks grid -> single-column stack with a small gap between tiles */
    .decks-grid {
        display: block;
        grid-template-columns: none;
        gap: 0;
        margin: 0 16px 80px;
    }

    /* Each tile -> banner row with cover card art as the background */
    .deck-tile {
        position: relative;
        height: 116px;
        margin: 0 0 10px;
        padding: 0;
        overflow: hidden;
        border-radius: 14px;
        border: none;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
        background: var(--surface-tertiary);
        color: #fff;
        cursor: pointer;
        transition: transform 0.12s ease;
    }
    .deck-tile:active {
        transform: scale(0.985);
    }

    /* The card-cover wrapper becomes the absolute-positioned image container.
       The image fills the tile, biased toward the right so character art
       (typically centered/upper in a card) lands on the visible side. */
    .deck-tile .card-cover {
        position: absolute;
        inset: 0;
        margin: 0;
        padding: 0;
        background: transparent;
        overflow: hidden;
        aspect-ratio: auto;
        height: auto;
        /* No explicit z-index — avoid creating a stacking context that
           would trap the title underneath the scrim. */
    }
    .deck-tile .card-cover-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        /* Bias visible window toward the upper portion of the card so the
           character / Mobile Suit artwork lands in frame. */
        object-position: center 20%;
        /* Scale up past the printed border so we don't see the card frame. */
        transform: scale(1.15);
        border-radius: 0;
    }

    /* Left-to-right scrim sits above the image but below the overlay.
       Implemented as a pseudo-element on .card-cover so all three pieces
       (image, scrim, overlay) live in the same parent and stack cleanly
       by source order + z-index. */
    .deck-tile .card-cover::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg,
            rgba(0, 0, 0, 0.78) 0%,
            rgba(0, 0, 0, 0.55) 35%,
            rgba(0, 0, 0, 0.18) 65%,
            rgba(0, 0, 0, 0) 100%);
        pointer-events: none;
        z-index: 1;
    }

    /* Promote overlay children so name + colors land directly on the tile,
       not constrained inside the cover wrapper. */
    .deck-tile .card-cover-overlay {
        position: absolute;
        left: 14px;
        top: 14px;
        right: 14px;
        bottom: 14px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        z-index: 2;
        background: none;
        padding: 0;
        border-radius: 0;
    }

    .deck-tile .card-cover-title {
        font-size: 17px;
        font-weight: 700;
        color: #fff;
        line-height: 1.2;
        margin: 0;
        padding: 0;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
        text-align: left;
        max-width: 70%;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Color pips at the bottom-left over the scrim */
    .deck-tile .card-cover-colors {
        display: flex;
        gap: 6px;
        padding: 0;
        margin: 0;
    }
    /* Keep the colored word badges (BLUE / GREEN …) on mobile too, matching
       desktop — don't collapse them into empty circles. */
    .deck-tile .color-badge {
        flex-shrink: 0;
    }

    /* Status pill -> bottom-right corner, glassy backing for legibility */
    .deck-tile .tile-content {
        display: contents;
    }
    .deck-tile .tile-footer,
    .deck-tile .tile-meta-row {
        display: contents;
    }
    .deck-tile .deck-labels-content,
    .deck-tile .tile-description,
    .deck-tile .tile-divider,
    .deck-tile .tile-meta-row .completion-badge,
    .deck-tile .tile-meta-row .deck-value-badge,
    .deck-tile .tile-meta-row .visibility-toggle,
    .deck-tile .tile-meta-row .tournament-archived,
    .deck-tile .color-gradient-bar,
    .deck-tile .favorite-button,
    .deck-tile .deck-tile-actions {
        display: none;
    }
    .deck-tile .status-badge {
        position: absolute;
        right: 14px;
        bottom: 14px;
        z-index: 2;
        margin: 0;
        font-size: 11px;
        font-weight: 700;
        padding: 4px 10px;
        border-radius: 999px;
        white-space: nowrap;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.25);
        text-shadow: none;
    }
    .deck-tile .status-badge.complete {
        background: rgba(46, 204, 113, 0.7);
        border-color: rgba(255, 255, 255, 0.35);
    }
    .deck-tile .status-badge.incomplete {
        background: rgba(0, 0, 0, 0.5);
    }

    /* Public-decks-specific banner overrides (favorite button, rating pill,
       creator name, etc.) live in styles/pages/public_decks.css since they
       need page-container scoping to win over the desktop rules there. */

    /* Floating Action Button — created by JS at the end of the page */
    .my-decks-fab {
        position: fixed;
        right: 22px;
        bottom: calc(82px + env(safe-area-inset-bottom));
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--color-primary);
        color: white;
        display: grid;
        place-items: center;
        font-size: 28px;
        font-weight: 300;
        line-height: 1;
        border: none;
        box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4);
        z-index: var(--z-mobile-tab-bar);
        cursor: pointer;
        text-decoration: none;
        transition: transform 0.12s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .my-decks-fab:active {
        transform: scale(0.92);
    }

    .my-decks-fab {
        box-shadow: 0 6px 16px rgba(10, 132, 255, 0.5);
    }

    /* Hide the existing "Create Your First Deck" button-style empty state action,
       since the FAB is now the create entry point. Empty state still shows the
       text/heading for context. */
    .empty-state .btn-primary {
        display: none;
    }
}

/* Hide FAB on desktop entirely */
@media (min-width: 769px) {
    .my-decks-fab {
        display: none !important;
    }
}
