/* ═══════════════════════════════════════
   UGC LEVELS — page-specific styles
   Base theme (palette, fonts, navbar, page-hero, footer, .section-wrap)
   comes from css/styles.css, loaded before this file. Only the level
   feed grid + its status states are defined here.
═══════════════════════════════════════ */

:root {
  /* styles.css sets color-scheme: light globally; this page is dark-themed
     (navy/coral/yellow on blue), so scrollbars/native controls should match. */
  color-scheme: dark;
}

/* ═══════════════════════════════════════
   PAGE LAYOUT — sidebar + main
═══════════════════════════════════════ */
.ugc-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  /* Full-bleed rather than a centered 1280px column: pins the sidebar to the
     true left edge of the page and gives the feed grid the rest of the
     viewport, so more GIF columns fit before wrapping. */
  width: 100%;
  padding: 24px 20px 60px;
  box-sizing: border-box;
}

#UGClevels-page-context{
  max-width: none;
}

.ugc-main {
  flex: 1;
  min-width: 0;
}

.ugc-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1.2rem, 2.6vw, 1.9rem);
  color: var(--white);
  text-align: center;
  margin-bottom: 22px;
  /* stroke/shadow treatment comes free from styles.css's [class*="title"] rule */
}

#feed {
  display: grid;
  /* Fixed at 6 columns on desktop — wider screens grow the cards themselves
     (via 1fr) rather than adding more columns. Narrower screens step down
     via the breakpoints below instead of auto-fill packing in extra columns. */
  grid-template-columns: repeat(6, 1fr);
  gap: 18px;
}
/* ═══════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════ */
.ugc-sidebar {
  flex: 0 0 300px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: rgba(20, 29, 66, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--card-radius);
  padding: 28px 24px;
  position: sticky;
  top: 16px;
  margin-top: 3.2rem;
}

.ugc-search {
  position: relative;
}

.ugc-search input {
  width: 100%;
  padding: 13px 44px 13px 18px;
  border: none;
  border-radius: 999px;
  background: #ece6f0;
  color: var(--text-body);
  font-family: 'Fira Sans Condensed', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  box-sizing: border-box;
  /* Display names/short IDs are always uppercase — mirrors the JS, which
     also uppercases the value actually sent to the search RPCs. Visual
     only (text-transform doesn't touch the underlying value/cursor). */
  text-transform: uppercase;
}

.ugc-search input::placeholder {
  color: #6b6b7a;
  text-transform: none;
}

.ugc-search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #57576b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.ugc-search-btn svg {
  width: 18px;
  height: 18px;
}

.ugc-toggle-group {
  display: flex;
  gap: 10px;
}

.ugc-toggle-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 10px;
  border: none;
  border-radius: 999px;
  background: rgba(107, 88, 80, 0.75);
  color: var(--white);
  font-family: 'Luckiest Guy', cursive;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.ugc-toggle-pill:hover {
  transform: translateY(-1px);
}

.ugc-toggle-pill.active {
  background: var(--coral);
}

/* Sidebar filters don't apply while searching (see UGClevels.js) — dimmed
   and inert rather than silently doing nothing when clicked. */
.ugc-toggle-pill:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.ugc-toggle-star {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #6b5850;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
}

.ugc-filter-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ugc-checkbox {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}

/* Same as .ugc-toggle-pill:disabled above, but the checkbox's actual form
   control is a visually-hidden input (opacity:0) — its own :disabled state
   wouldn't be visible, so JS toggles this class on the label instead. */
.ugc-checkbox--disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

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

.ugc-checkbox-box {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.ugc-checkbox-box::after {
  content: '';
  width: 12px;
  height: 7px;
  margin-top: -2px;
  border-left: 3px solid var(--white);
  border-bottom: 3px solid var(--white);
  transform: rotate(-45deg) scale(0);
  transition: transform 0.15s;
}

.ugc-checkbox input:checked + .ugc-checkbox-box {
  background: #2a2a2a;
}

.ugc-checkbox input:checked + .ugc-checkbox-box::after {
  transform: rotate(-45deg) scale(1);
}

.ugc-checkbox input:focus-visible + .ugc-checkbox-box {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

.ugc-checkbox-label {
  font-family: 'Fira Sans Condensed', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--white);
}

/* ═══════════════════════════════════════
   LEVEL CARD
═══════════════════════════════════════ */
.level-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background-color: var(--navy);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.level-card:hover {
  transform: translateY(-4px);
  border-color: var(--coral);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

/* Dark vignette that fades in on hover so the stat badges stay legible
   over arbitrary (possibly light) thumbnail images */
.level-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, transparent 40%),
              linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0%, transparent 35%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 1;
}

.level-card:hover::before {
  opacity: 1;
}

/* ─── Hover-only: play/like stat badges (top-left) ─── */
.level-card__stats {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.level-card:hover .level-card__stats {
  opacity: 1;
  transform: translateY(0);
}

.level-card__stat {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--white);
  font-weight: 800;
  font-size: 0.95rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.level-card__stat svg {
  width: 16px;
  height: 16px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* ─── Hover-only: centered Play button ─── */
.level-card__play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0088ff;
  color: var(--white);
  font-family: 'Luckiest Guy', cursive;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  padding: 10px 20px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.level-card:hover .level-card__play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.level-card__play svg {
  width: 13px;
  height: 13px;
}

/* ─── Display name badge (bottom-right) — always visible, not hover-only ─── */
.level-card__name {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--yellow-card);
  color: var(--navy);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  max-width: calc(100% - 20px);
  pointer-events: none;
}

.level-card__name svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.level-card__name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═══════════════════════════════════════
   STATUS STATES (loading / end / retry)
═══════════════════════════════════════ */
.status-card {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 24px;
  color: var(--white);
  text-align: center;
  font-family: 'Fira Sans Condensed', sans-serif;
  font-weight: 600;
}

.status-card p {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--white);
}

.status-card--sentinel {
  padding: 8px;
  min-height: 1px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.retry-button {
  padding: 12px 32px;
  font-family: 'Luckiest Guy', cursive;
  font-size: 12px;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 30px;
  background: var(--coral);
  color: var(--white);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.retry-button:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* ═══════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════ */
@media (max-width: 900px) {
  .ugc-layout {
    flex-direction: column;
    /* align-items: flex-start (desktop rule) controls the CROSS axis, which
       becomes horizontal once flex-direction is column — left as-is, .ugc-main
       would shrink to its content width instead of filling the screen. */
    align-items: stretch;
  }

  .ugc-sidebar {
    position: static;
    width: 100%;
    flex: none;
  }

  /* styles.css only switches the navbar to the hamburger menu at
     max-width:768px — tuned for other pages' ~8 nav links. This page adds
     TUTORIALS + USER CREATIONS (10 total), which measurably wraps
     .nav-links to a second line as early as ~875px. Switch earlier here so
     the desktop nav is never shown at a width where it would wrap. */
  .nav-links {
    display: none;
  }

  .mobile-toggle {
    display: block;
  }

  .navbar-inner {
    justify-content: space-between;
  }

  /* Base rule is fixed at 6 columns for desktop; step down to 4 once the
     sidebar stacks on top and .ugc-main takes the full (narrower) width,
     so cards don't get squeezed to ~95px instead of growing/shrinking with
     the viewport like the desktop layout does. */
  #feed {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 480px) {
  #feed {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .level-card__name {
    font-size: 0.72rem;
  }
}

/* Touch devices have no hover — keep the stat badges (not the center Play
   button, which stays a hover/desktop affordance) visible at all times so
   the information isn't unreachable on mobile. (.level-card__name is now
   always visible regardless of hover, so it no longer needs to be listed here.) */
@media (hover: none) {
  .level-card__stats {
    opacity: 1;
    transform: none;
  }

  .level-card::before {
    opacity: 1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.32) 0%, transparent 30%),
                linear-gradient(0deg, rgba(0, 0, 0, 0.3) 0%, transparent 30%);
  }
}
