/* ==========================================================================
   1. BASE & RESETS
   ========================================================================== */

*, html, body {
  -webkit-tap-highlight-color: transparent !important;
}

* {
  outline: none !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
}

body.locked-input {
  overflow: hidden !important;
  touch-action: none !important;
  pointer-events: none !important;
}

a {
  color: inherit;
  text-decoration: none !important;
  cursor: default;
}

img:not(.tab-avatar):not(.brand-spinner):not(#giant-wooper) {
  height: 25px;
  width: auto;
  vertical-align: middle;
}

td {
  line-height: 1.5;
  height: 4em;
}

/* ==========================================================================
   2. LAYOUT & STRUCTURE
   ========================================================================== */

main {
  flex: 1;
  margin-top: 0;
  margin-bottom: 0;
}

.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

#footer-randomizer img {
  vertical-align: middle !important;
  transform: translateY(-2px) !important;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%/2, max(250px, 100%/4)), 1fr)) !important;
}

.section-header {
  border-bottom: 2px solid var(--pico-muted-border-color);
  padding-bottom: 0.5rem;
  margin-top: 2rem;
  color: var(--pico-secondary);
}

.overflow-auto table td,
.overflow-auto table th {
  text-align: center;
}

.fixed {
  table-layout: fixed;
}

/* ==========================================================================
   3. NAVIGATION & TABS
   ========================================================================== */

.nav-flex {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none !important;
}

.nav-logo {
  height: 2rem !important;
  width: auto !important;
}

.tab-row-wrapper {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 2rem;
  position: relative;
}

.tab-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.9rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  flex-shrink: 0;
  max-width: 100%;
}

.tab-row-wrapper.can-scroll-left::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to right, var(--pico-background-color), transparent);
  z-index: 2;
  pointer-events: none;
}

.tab-row-wrapper.can-scroll-right::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to left, var(--pico-background-color), transparent);
  z-index: 2;
  pointer-events: none;
}

@media (min-width: 768px) {
  .tab-row { overflow-x: visible; justify-content: center; }
}

.tab-card {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 220px;
  max-width: 400px;
  scroll-snap-align: start;
  padding: 0.75rem 1rem;
  background-color: var(--pico-card-background-color);
  border: 2px solid transparent;
  border-radius: var(--pico-border-radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: default;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1.5);
}

.tab-card.active-tab {
  background-color: var(--pico-form-element-background-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tab-avatar {
  width: 2.8rem !important;
  height: 2.8rem !important;
  border-radius: 50%;
  margin-right: 1rem;
  object-fit: cover;
  pointer-events: none;
}

.tab-label {
  flex: 1;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 24px;
  line-height: 1;
  transform: translateY(1px);
}

.tab-pane { display: none; animation: fadeIn 0.3s ease-in-out; }
.tab-pane.active-pane { display: block; }

/* ==========================================================================
   4. CARDS & BADGES
   ========================================================================== */

.card-link {
  text-decoration: none !important;
  color: inherit;
  display: block;
  outline: none;
}

.card-link article {
  height: 100%;
  margin: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1.5), box-shadow 0.2s ease, border-color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
  .card-link:hover article,
  .card-link:focus-visible article {
    transform: translateY(-4px);
    border-color: var(--pico-primary);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
  }
}

@media (hover: none), (pointer: coarse) {
  .card-link:active article {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border-color: var(--pico-primary);
    transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
  }
}

.card-body-flex {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  align-items: center !important;
  width: 100%;
}

.card-body-flex .progress-badge {
  flex-shrink: 0;
  margin-left: 1rem !important;
}

.locked-card, .missing-card {
  opacity: 0.5;
  filter: grayscale(100%);
  cursor: not-allowed;
  pointer-events: none;
}

/* Language Badges */
.lang-badge {
  font-size: 0.7rem;
  padding: 2px 0;
  border-radius: 4px;
  font-weight: bold;
  display: inline-block;
  width: 36px;
  text-align: center;
}
.lang-EN { background: var(--pico-primary-background); color: var(--pico-primary-inverse); }
.lang-JP { background: #d32f2f; color: white; }
.lang-KR { background: #673ab7; color: white; }

/* Progress Badges */
.progress-badge {
  background-color: #e2e8f0 !important; color: #1e293b !important; border: 1px solid #94a3b8 !important;
  display: flex; align-items: center; justify-content: center; height: 1.8rem; padding: 0 0.8rem;
  border-radius: 50px; font-size: 0.8rem; font-weight: bold; margin: 0 !important; line-height: 1 !important;
  box-sizing: border-box; white-space: nowrap;
}

body .progress-badge.complete,
article .progress-badge.complete,
div .progress-badge.complete {
  background-color: #2e7d32 !important;
  color: #ffffff !important;
  border-color: #2e7d32 !important;
  pointer-events: none !important;
  opacity: 1 !important;
}

@media (prefers-color-scheme: dark), html[data-theme="dark"] {
  .progress-badge:not(.complete) {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
  }
}

/* ==========================================================================
   5. COLLECTION TRACKER
   ========================================================================== */

.set-tracker { margin-bottom: 0 !important; }

.set-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}

.set-header:last-child { margin-bottom: 0 !important; }

.set-title {
  margin: 0 !important;
  margin-right: 1.5rem !important;
  font-size: 1.25rem;
  font-weight: bold;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  line-height: normal;
  padding-bottom: 0;
  transform: translateY(1px);
  position: relative;
}

.set-title:has(.smart-marquee.is-scrolling)::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1.5rem;
  background: linear-gradient(to left, var(--pico-card-background-color) 0%, transparent 100%);
  pointer-events: none;
}

.set-title:has(.smart-marquee.is-scrolling)::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 1rem;
  background: linear-gradient(to right, var(--pico-card-background-color) 0%, transparent 100%);
  pointer-events: none;
  z-index: 2;
  animation: leftFadeToggle 8s linear infinite;
}

.set-stats {
  display: flex;
  align-items: center;
  margin: 0 !important;
}

/* Progress Bars */
.binder-progress-track {
  width: 100%; height: 1.5rem; background-color: var(--pico-muted-border-color);
  border-radius: 1rem; overflow: hidden; position: relative; display: flex;
  align-items: center; justify-content: center;
}

.binder-progress-fill.holo-bar {
  height: 100%;
  border-radius: 1rem;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  background-image: linear-gradient(to right, #1e293b 0%, #334155 25%, #475569 50%, #334155 75%, #1e293b 100%);
  background-size: 200% 100%;
  background-repeat: repeat !important;
  will-change: background-position;
  transform: translateZ(0);
  animation: foilShine 3s linear infinite !important;
}

.binder-progress-text {
  position: relative; z-index: 3; color: #ffffff !important; font-weight: bold; font-size: 0.9rem;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8); cursor: default !important;
  min-width: 3rem; text-align: center; display: inline-block; opacity: 1;
}

.binder-progress-track:hover .binder-progress-text,
.binder-progress-text:hover { color: #ffffff !important; }

/* Holo Themes */
.binder-progress-fill.holo-bar.theme-modern { background-image: linear-gradient(to right, #0ea5e9 0%, #e11d48 25%, #ea580c 50%, #7c3aed 75%, #0ea5e9 100%); }
.binder-progress-fill.holo-bar.theme-holo { background-image: linear-gradient(to right, #e91e63 0%, #ff8c00 25%, #ffeb3b 50%, #e91e63 100%); }
.binder-progress-fill.holo-bar.theme-rainbow { background-image: linear-gradient(to right, #ff3b3b 0%, #ff9d00 16%, #ffeb3b 33%, #4caf50 50%, #2196f3 66%, #9c27b0 83%, #ff3b3b 100%); }
.binder-progress-fill.holo-bar.theme-galactic { background-image: linear-gradient(to right, #1e1b4b 0%, #4c1d95 30%, #22d3ee 50%, #312e81 70%, #1e1b4b 100%); }
.binder-progress-fill.holo-bar.theme-mega { background-image: linear-gradient(to right, #00ffff 0%, #a3e635 25%, #7c3aed 50%, #ec4899 75%, #00ffff 100%); }
.binder-progress-fill.holo-bar.theme-classic { background-image: linear-gradient(to right, #ee1515 0%, #3b4cca 25%, #ffcb05 50%, #4dad5b 75%, #ee1515 100%); }
.binder-progress-fill.holo-bar.theme-johto { background-image: linear-gradient(to right, #fbbf24 0%, #cbd5e1 25%, #22d3ee 50%, #cbd5e1 75%, #fbbf24 100%); }
.binder-progress-fill.holo-bar.theme-rumble-logo { background-image: linear-gradient(to right, #ff3333 0%, #ffcc00 20%, #33cc33 40%, #0099ff 60%, #9933ff 80%, #ff3333 100%) !important; background-size: 200% auto; animation: foilShine 4s linear infinite !important; }
.binder-progress-fill.holo-bar.theme-151 { background-image: linear-gradient(to right, #f472b6 0%, #c084fc 25%, #22d3ee 50%, #c084fc 75%, #f472b6 100%); }

/* Index Page Overrides */
body.index-page .set-tracker.minimal-card { margin-bottom: 0 !important; display: block; text-align: center; }
body.index-page .set-tracker.minimal-card .set-header { display: flex; align-items: center; justify-content: center; height: 2.5rem; margin-bottom: 0 !important; width: 100%; }
body.index-page .set-tracker.minimal-card .set-title { flex: 0 1 auto !important; margin: 0 !important; }

/* ==========================================================================
   6. SHOWCASE CAROUSEL
   ========================================================================== */

.showcase-wrapper {
  margin-top: 1rem;
  margin-bottom: 3rem;
}

.showcase-img {
  width: 100%;
  height: auto !important;
  border-radius: 4px;
  margin-bottom: 0.5rem;

  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-select: none;
}

.image-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

.showcase-badge-position {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
}

.showcase-rail {
  display: flex;
  width: 100%;
  gap: 0;
  padding: 0;
  margin: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.showcase-rail::-webkit-scrollbar {
  display: none;
}

.showcase-rail .showcase-card {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  cursor: default;
}

.showcase-rail .showcase-card:active {
  cursor: grabbing;
}

.showcase-rail article {
  width: 100%;
  max-width: 380px;
  padding: 1.5rem;
  margin: 0 auto;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 1rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
  transition: none !important;
  transform: none !important;
}

.showcase-rail.is-dragging {
  scroll-snap-type: none !important; /* Temporarily turns off snapping */
  cursor: grabbing !important;
}

.showcase-rail.is-dragging .showcase-card {
  cursor: grabbing !important;
}

.showcase-pagination {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  position: relative; /* REQUIRED so the blob can position itself inside */
}

.showcase-blob {
  position: absolute;
  left: 0;
  height: 8px;
  border-radius: 50px;
  z-index: 1;
  pointer-events: none;
  background-color: var(--pico-muted-color); /* Guaranteed neutral gray */
  opacity: 0; /* Starts completely invisible */
  will-change: transform, width, height, top, opacity;
  transition: opacity 0.2s ease; /* Fades in and out smoothly */
}

.showcase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--pico-muted-border-color);
  transition: background-color 0.3s ease, transform 0.3s ease;
  position: relative;
  z-index: 2;
}

.showcase-dot.active {
  background-color: var(--dot-active-color) !important;
  transform: scale(1.3);
}

.showcase-card .showcase-meta {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
  display: flex !important;
  flex-direction: column !important;
  gap: 0.75rem !important;
}

.showcase-card .meta-row {
  display: grid !important;
  grid-template-columns: 1fr auto !important;
  align-items: center !important;
  width: 100% !important;
  gap: 1rem !important;
}

.showcase-card .card-name {
  font-size: 1.15rem !important;
  color: var(--pico-h1-color) !important;
  margin: 0 !important;
}

.showcase-card .card-number,
.showcase-card .set-name,
.showcase-card .rarity-text {
  font-size: 0.9rem !important;
  color: var(--pico-muted-color) !important;
  margin: 0 !important;
}

.showcase-card .meta-row > :last-child {
  justify-self: end !important;
  text-align: right !important;
}

/* ==========================================================================
   7. OVERLAYS, TOOLTIPS & ANIMATIONS
   ========================================================================== */

.tippy-box { border-radius: 50px !important; }
.tippy-content { padding: 0.25rem 0.5rem !important; }

#loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--pico-background-color); z-index: 9999; display: flex; justify-content: center; align-items: center; transition: opacity 0.3s ease-out, visibility 0.3s ease-out; }
.fade-out { opacity: 0; visibility: hidden; }
.brand-spinner { width: 80px; height: auto; animation: pulse 1.5s ease-in-out infinite; }

#back-to-top { position: fixed; bottom: 20px; right: 20px; width: 55px; height: 55px; z-index: 999; background-color: var(--pico-card-background-color); border: none; border-radius: 50%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); background-image: url('/img/favicon.webp'); background-size: 75%; background-position: center; background-repeat: no-repeat; cursor: default; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.2s cubic-bezier(0.2, 0, 0, 1.5); }
#back-to-top:active { transform: scale(0.85); }
#back-to-top.visible { opacity: 1; visibility: visible; }
#back-to-top.spinning { animation: spinWooper 0.5s linear infinite; pointer-events: none; }

#giant-wooper {
  position: fixed;
  bottom: -200px;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 80vw;
  max-width: 400px;
  height: auto !important;
  object-fit: contain;
  z-index: 9999;
  pointer-events: none;
}
#giant-wooper.photobomb-anim { animation: wooperJumpY 1.5s forwards, wooperJumpX 1.5s linear forwards; }

.smart-marquee { display: inline-block; }
.smart-marquee.is-scrolling { animation: preciseTicker 8s linear infinite; }

/* --- Keyframes --- */
@keyframes preciseTicker { 0%, 15% { transform: translateX(0); } 75%, 90% { transform: translateX(calc(var(--scroll-dist) - 2rem)); } 100% { transform: translateX(0); } }
@keyframes foilShine { 0% { background-position: 0% center; } 100% { background-position: 200% center; } }
@keyframes pulse { 0% { transform: scale(0.85); opacity: 0.8; } 50% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(0.85); opacity: 0.8; } }
@keyframes spinWooper { 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes leftFadeToggle { 0%, 15% { opacity: 0; } 15.01%, 99.99% { opacity: 1; } 100% { opacity: 0; } }
@keyframes wooperJumpY { 0% { bottom: -200px; animation-timing-function: ease-out; } 50% { bottom: 50%; animation-timing-function: ease-in; } 100% { bottom: -200px; } }
@keyframes wooperJumpX { 0% { left: -20vw; } 50% { left: 50%; } 100% { left: 120vw; } }

/* ==========================================================================
   8. UTILITIES
   ========================================================================== */

.noSelect {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.noSelect:focus {
  outline: none !important;
}

.text-center { text-align: center; }
.col-name { text-align: left !important; }
.text-muted { color: var(--pico-muted-color); }
.cursor, .link, .cursor-default { cursor: default; text-decoration: none !important; }

.mb-large { margin-bottom: 3rem !important; }
.mt-medium { margin-top: 1.5rem !important; }
.mr-small { margin-right: 0.5rem !important; }
.grid-spacing { margin-bottom: 3rem; }
.no-margin { margin-bottom: 0 !important; }
