/* ═══════════════════════════════════════════════════════════
   HYBRID ENGINE STYLES
   — Skeleton screens
   — View transitions
   — Progress bar
   — Offline banner
═══════════════════════════════════════════════════════════ */

/* ─── SKELETON BASE ──────────────────────────────────────── */
@keyframes skel-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skel {
  background: linear-gradient(
    90deg,
    var(--panel) 25%,
    var(--card)  50%,
    var(--panel) 75%
  );
  background-size: 800px 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}

/* ─── SKELETON SHAPES ────────────────────────────────────── */
.skeleton-page {
  padding: 28px 24px 60px;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skel-hero    { height: 120px; border-radius: var(--r); }
.skel-card    { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.skel-header  { height: 14px; width: 120px; }
.skel-grid    { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.skel-btn     { height: 52px; border-radius: var(--r-sm); }
.skel-btn-full{ height: 52px; border-radius: var(--r-sm); }
.skel-divider { height: 1px; background: var(--border); animation: none; }
.skel-title   { height: 28px; width: 60%; }
.skel-tabs    { height: 36px; width: 80%; border-radius: 50px; }
.skel-steps   { height: 40px; border-radius: 50px; }
.skel-input   { height: 46px; border-radius: var(--r-sm); }
.skel-card-full { height: 300px; border-radius: var(--r); }
.skel-breadcrumb { height: 12px; width: 200px; border-radius: 50px; }

/* Sub-category grid skeleton */
.skel-sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.skel-sub-card {
  aspect-ratio: 4/3;
  border-radius: var(--r);
}

/* Leaderboard row skeleton */
.skel-row {
  display: grid;
  grid-template-columns: 44px 44px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.skel-rank     { height: 20px; width: 24px; border-radius: 4px; }
.skel-avatar-sm{ width: 40px; height: 40px; border-radius: 50%; }
.skel-avatar-lg{ width: 80px; height: 80px; border-radius: 50%; }
.skel-info     { display: flex; flex-direction: column; gap: 6px; }
.skel-name     { height: 14px; width: 70%; }
.skel-sub      { height: 11px; width: 50%; }
.skel-votes    { height: 14px; border-radius: 4px; }

/* ─── VIEW TRANSITION ────────────────────────────────────── */
/* Only hint opacity: a transform hint can promote a layer that breaks
   position:fixed descendants (viewport-fixed UI inside #app-root). */
#app-root {
  will-change: opacity;
}

/* ─── PROGRESS BAR ───────────────────────────────────────── */
#nav-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  z-index: 99998;
  pointer-events: none;
  /* width and opacity controlled inline by hybrid.js */
}

/* ─── OFFLINE BANNER ─────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}

#offline-banner {
  transition: opacity .3s ease;
}

/* ─── LIGHT THEME ────────────────────────────────────────── */
[data-theme="light"] .skel {
  background: linear-gradient(
    90deg,
    #e8e8f0 25%,
    #f0f0f8 50%,
    #e8e8f0 75%
  );
  background-size: 800px 100%;
}

/* ─── MOBILE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .skeleton-page { padding: 16px 14px calc(var(--bottom-h) + 16px); }
  .skel-sub-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════
   LAZY IMAGE SYSTEM
   — Blur-up placeholder
   — Fade-in on load
   — Initials fallback via parent ::after
═══════════════════════════════════════════════════════════ */

/* Base state — image not yet loaded */
img[data-lazy],
img.img-blur-placeholder {
  filter: blur(8px);
  transform: scale(1.05);
  transition: filter .35s ease, transform .35s ease, opacity .3s ease;
  opacity: .7;
}

/* Loading state — spinner ring on parent */
img.img-loading {
  opacity: .5;
}

/* Loaded state — sharp, full opacity */
img.img-loaded {
  filter: none;
  transform: scale(1);
  opacity: 1;
}

/* ─── Instagram-style nav progress bar ───────────────────── */
/* The progress bar in hybrid.js already has the gradient.
   This adds the animated shimmer sweep on top of it. */
#nav-progress::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.35) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: nav-shimmer .9s ease-in-out infinite;
}

@keyframes nav-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ─── Contestant photo container ─────────────────────────── */
.contestant_profile {
  position: relative;
  overflow: hidden;
}

/* Initials shown when image fails or hasn't loaded */
.contestant_profile::after {
  content: attr(data-initials);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(18px, 3vw, 26px);
  color: var(--muted);
  background: var(--panel);
  z-index: 0;
  pointer-events: none;
}

/* Hide initials once image loads */
.contestant_profile:has(img.img-loaded)::after {
  display: none;
}

/* Image sits above the initials */
.contestant_photo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── Leaderboard avatar ─────────────────────────────────── */
.lb-avatar {
  position: relative;
  overflow: hidden;
}

.lb-avatar::after {
  content: attr(data-initials);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border-radius: 50%;
  z-index: 0;
}

.lb-avatar:has(img.img-loaded)::after { display: none; }

.lb-avatar-img {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

/* ─── Sub-category card images ───────────────────────────── */
.sub_category_bg_img {
  transition: filter .35s ease, transform .35s ease, opacity .3s ease;
}

.sub_category_bg_img[data-lazy] {
  filter: blur(6px);
  transform: scale(1.08);
  opacity: .6;
}

.sub_category_bg_img.img-loaded {
  filter: none;
  transform: scale(1);
  opacity: 1;
}
