/* =====================
   CSS VARIABLES
===================== */
:root {
    --bg: #f2f2f2;
    --card-bg: #ffffff;
    --text: #222;
    --muted: #555;
    --header-bg: #3a3a3a;
    --control-bg: #ffffff;
    --border: #ddd;
}

body.dark {
    --bg: #121212;
    --card-bg: #1e1e1e;
    --text: #eeeeee;
    --muted: #aaaaaa;
    --header-bg: #2a2a2a;
    --control-bg: #1a1a1a;
    --border: #333;
}

/* =====================
   BASE
===================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.2s, color 0.2s;
}

/* =====================
   LOADER
===================== */

.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader img {
  width: 80px;
  height: 80px;
  animation: spin 1s linear infinite;
  opacity: 0.9;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* hide helper */
.loader.hidden {
  display: none;
}

/* =====================
   HEADER
===================== */
header {
    padding: 16px;
    background: var(--header-bg);
    color: white;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
}

.header-icon {
    position: static;
    margin-left: 8px;
    height: 40px;
    width: auto;
    display: inline-block;
}

@media (max-width: 480px) {
    .header-icon {
        height: 32px;
    }
}

.theme-toggle {
    position: absolute;
    right: 16px;
    top: 16px;
    background: rgba(17, 15, 15, 0.2);
    border: none;
    color: white;
    /* make the button span the header inner height and keep horizontal padding */
    bottom: 16px;
    padding: 0 10px;
    border-radius: 6px;
    cursor: pointer;
}

.theme-toggle img {
    /* make the icon fill the button's height while keeping aspect ratio */
    height: 50%;
    width: auto;
    display: block;
}

/* =====================
   CONTROLS
===================== */
.controls {
    padding: 12px 16px;
    background: var(--control-bg);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
}

/* =====================
   GRID & CARDS
===================== */
.grid {
    display: grid;
    gap: 16px;
    padding: 16px;
    /* Use fixed column width and center the grid so cards don't stretch to fill space */
    grid-template-columns: repeat(auto-fill, 220px);
    justify-content: center;
}

@media (max-width: 520px) {

    /* On narrow screens allow cards to be fluid and fill available width */
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        justify-content: start;
    }
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.card-image-wrapper {
    position: relative;
    width: 100%;
}

.card img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: #444;
    display: block;
}

.language-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.2rem;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.card-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-title {
    font-weight: 700;
    font-size: 1rem;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Fallback image visual cue */
.grayscale img {
  filter: grayscale(100%) contrast(0.9) brightness(0.95);
}

/* Optional: slight color return on hover */
.grayscale img:hover {
  filter: grayscale(0%);
  transition: filter 0.2s ease;
}


/* =====================
   BADGES
===================== */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.badge {
    font-size: 0.7rem;
    padding: 4px 6px;
    border-radius: 6px;
    background: #444;
    color: white;
}

.badge.owned {
    background: #43a047;
}

.badge.bought {
    background: #fbc02d;
    color: #222;
}

/* =====================
     PROGRESS BARS
===================== */
.progress-section {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: var(--control-bg);
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-label {
    min-width: 100px;
    font-size: 0.9rem;
    color: var(--muted);
}

.progress {
    position: relative;
    flex: 1;
    height: 18px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.03));
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #43a047, #66bb6a);
    width: 0%;
    transition: width 300ms ease;
}

.progress-fill-bought {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #fbc02d, #ffd54f);
    width: 0%;
    transition: width 300ms ease;
    z-index: 1;
}

.progress-fill-owned {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #43a047, #66bb6a);
    width: 0%;
    transition: width 300ms ease;
    z-index: 2;
}

.progress-text {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--text);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

body.dark .progress {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.03);
}

body.dark .progress-fill {
    background: linear-gradient(90deg, #66bb6a, #43a047);
}

/* Completion star */
.progress-star {
    min-width: 24px;
    text-align: center;
    font-size: 1.1rem;
    color: gold;
    line-height: 1;
    margin-left: 8px;
}

.progress-row.completed .progress-text {
    font-weight: 700;
}

/* hide star when not completed (empty content) */
.progress-star:empty {
    display: inline-block;
    /* Changed from none to inline-block to reserve space */
}