/* =========================================
   CORE VARIABLES & RESET
   ========================================= */
:root {
  --max-width: 100%;
  --bg-color: #000;
  --text-color: #fff;
  --border-color: #262626;
  --accent-color: #0095f6;
  --secondary-text: #a8a8a8;
  --nav-height: 50px;
  --sale-color: #2fe66b;
  --muted: #a8a8a8;
}

body {
  background-color: #fff;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-bottom: 60px;
}

/* =========================================
   GRID LAYOUT
   ========================================= */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background-color: #fff;
  padding-bottom: 20px;
}

/* Mobile: 3 */
.grid{ grid-template-columns: repeat(3, 1fr); }

/* Tablet: 4 */
@media (min-width: 700px){
  .grid{ grid-template-columns: repeat(4, 1fr); }
}

/* Desktop: 5 */
@media (min-width: 1100px){
  .grid{ grid-template-columns: repeat(5, 1fr); }
}

.tile {
  display: block;
  background: #efefef;
  aspect-ratio: 3 / 4;
  cursor: pointer;
  border: 0;
  padding: 0;
  position: relative;
  overflow: hidden;
}

.tile img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.tile.sold {
  filter: grayscale(1);
  opacity: 0.45;
  cursor: default;
}

.tile.sold::after {
  content: "SOLD";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.35);
}

/* =========================================
   TILE META & COUNTDOWN
   ========================================= */
.tile-meta {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 11px;
  line-height: 1.05; /* was 1; helps when shrinking for mobile */
  letter-spacing: 0.2px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-meta .brand {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.tile-meta .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  flex: 0 0 auto;
}

.tile-meta .off {
  color: #ff0000;
  font-weight: 700;
  flex: 0 0 auto;
}

/* NEW: mini tags inside tile-meta (image 2) */
.tile-meta .tag-mini{
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.2px;
  flex: 0 0 auto;
}

/* Safety: never show SALE / TIME LIMITED mini tags on grid tiles */
.tile-meta .tag-mini { display: none !important; }

.countdown-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.3px;
  line-height: 1.05; /* added for consistency */
  color: #fff;
  background: rgba(255, 59, 48, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  white-space: nowrap;
}

.countdown-pill.soon { background: rgba(255, 149, 0, 0.88); }
.countdown-pill.urgent { background: rgba(255, 59, 48, 0.92); }

#status {
  padding: 20px;
  text-align: center;
  color: #666;
  font-size: 14px;
}

/* =========================================
   SEARCH BAR
   ========================================= */
.index-search-wrap {
  padding: 5px 10px;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #eee;
}

.index-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-search {
  flex: 1;
  background: #efefef;
  border-radius: 8px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  min-width: 0;
}

.site-search #q {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  line-height: 1.1;
  padding: 0;
  height: 18px;
  min-width: 0;
}

.smart-search-label {
  font-size: 11px;
  font-weight: 700;
  color: #111;
  letter-spacing: 0.2px;
  white-space: nowrap;
  user-select: none;
}

.quick-chips {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid #e6e6e6;
  background: #fff;
  color: #111;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

.chip:hover { background: #f6f6f6; }
.chip:active { transform: scale(0.98); }

/* =========================================
   FEED OVERLAY (VERTICAL MODE) - LIGHT THEME
   ========================================= */
.feed-overlay {
  position: fixed;
  inset: 0;

  /* light background in vertical mode */
  background: #fff;

  z-index: 2000;
  display: none;
  flex-direction: column;

  /* default text color for overlay */
  color: #111;
}

.feed-overlay.active { display: flex; }

/* Top row: back button left, title centered */
.feed-nav {
  display: grid;
  grid-template-columns: 40px 1fr 40px; /* left / center / right spacer */
  align-items: center;

  height: 32px;
  padding: 0 10px;
  gap: 8px;

  background: #fff;
  border-bottom: 1px solid #eee;
}

/* Back arrow button: outline only, no container box */
.back-btn {
  justify-self: start;
  background: transparent;
  border: 0;
  box-shadow: none;

  padding: 0;          /* remove rectangle feel */
  margin: 0;
  line-height: 0;

  color: #111;         /* SVG stroke uses currentColor */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.back-btn:hover,
.back-btn:active,
.back-btn:focus {
  background: transparent;
  outline: none;
}

.back-btn svg {
  width: 16px;
  height: 16px;
  display: block; /* avoids baseline alignment issues */
}

.feed-title {
  justify-self: center;
  margin: 0;
  line-height: 1;
  font-size: 12px;
  font-weight: 700;
  color: #111;
}

.feed-list {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  height: 100%;
  background: #fff;
}

.feed-list::-webkit-scrollbar { display: none; }

/* =========================================
   FEED POST
   ========================================= */
.feed-post {
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;

  /* was: background: var(--bg-color); */
  background: #fff;

  /* was: border-bottom: 1px solid var(--border-color); */
  border-bottom: 1px solid #eee;

  position: relative;
}

.post-header {
  flex: 0 0 auto;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 6px;

  background: #fff;
  color: #111;
}

.avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  padding: 1px;
}

.avatar-inner {
  width: 100%;
  height: 100%;

  /* keep avatar center dark like IG; change to #fff if you want */
  background: #000;

  border-radius: 50%;
  border: 1px solid #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 10px;
  line-height: 1;
  color: #fff;
}

.username { font-weight: 600; font-size: 12px; line-height: 1.1; color: #111; }

/* =========================================
   CAROUSEL
   ========================================= */
.post-media-wrap {
  flex: 1;
  position: relative;
  width: 100%;

  /* was: background: #000; */
  background: #fff;

  min-height: 0;
}

.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar { display: none; }

.carousel-item {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;

  /* was: background: #000; */
  background: #fff;
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.dots-overlay {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
  z-index: 5;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;

  /* dark dots on light bg */
  background: rgba(0, 0, 0, 0.25);

  transition: background 0.2s;
}

.dot.active { background: rgba(0, 0, 0, 0.8); }

/* =========================================
   POST FOOTER
   ========================================= */
.post-footer {
  flex: 0 0 auto;

  /* was: background: var(--bg-color); */
  background: #fff;

  padding: 10px 14px 12px;
  color: #111;
}

.price-buy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.buy-side {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
}

.countdown-inline {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;

  /* was: color: rgba(255, 255, 255, 0.92); */
  color: #111;

  padding: 6px 10px;
  border-radius: 999px;

  /* was: border: 1px solid rgba(255, 255, 255, 0.22); */
  border: 1px solid rgba(0, 0, 0, 0.12);

  background: rgba(255, 59, 48, 0.10);
  white-space: nowrap;
}

.countdown-inline.soon { background: rgba(255, 149, 0, 0.15); }
.countdown-inline.urgent { background: rgba(255, 59, 48, 0.16); }

.buy-btn-feed {
  background-color: var(--accent-color);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex: 0 0 auto;
}

.price-block {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.price-now {
  font-size: 18px;
  font-weight: 800;

  /* was: color: #fff; */
  color: #111;

  letter-spacing: 0.2px;
}

.price-was {
  font-size: 13px;

  /* was: color: var(--muted); */
  color: #666;

  text-decoration: line-through;
  text-decoration-thickness: 1.5px;

  /* was: text-decoration-color: rgba(255, 255, 255, 0.35); */
  text-decoration-color: rgba(0, 0, 0, 0.35);
}

.off-pill {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--sale-color);
  border: 1px solid rgba(47, 230, 107, 0.35);
  background: rgba(47, 230, 107, 0.10);
  padding: 4px 8px;
  border-radius: 999px;
  line-height: 1;
}

.caption-section {
  font-size: 14px;
  line-height: 1.45;
}

.caption-line { color: #111; }
.caption-user { font-weight: 700; margin-right: 6px; color: #111; }

.caption-desc {
  color: #111;
  white-space: pre-wrap;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.caption-desc.expanded {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}

.see-more-btn {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;

  /* was: color: var(--secondary-text); */
  color: #666;

  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* =========================================
   LIGHTBOX
   ========================================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  background: rgba(0, 0, 0, 0.96);
}

.lightbox.active { display: block; }

.lightbox-track {
  height: 100%;
  width: 100%;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
  touch-action: pan-x;
}

.lightbox-track::-webkit-scrollbar { display: none; }

.lightbox-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.lightbox-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.lightbox-swipe-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: transparent;
  touch-action: pan-y;
}

.lightbox-top {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0 12px;
  z-index: 3;
  pointer-events: none;
}

.lightbox-close {
  pointer-events: auto;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  cursor: pointer;
}

.lightbox-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  display: flex;
  gap: 6px;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}

.lightbox-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-dot.active { background: rgba(255, 255, 255, 0.92); }

/* =========================================
   SPLASH CONTROL (prevents content flashing)
   ========================================= */
html.show-splash #app-content { visibility: hidden; }
html.no-splash #app-content { visibility: visible; }

/* Splash exists but is only displayed when show-splash is present */
#splash-screen { display: none; }
html.show-splash #splash-screen { display: flex; }

/* =========================================
   ADVANCED SPLASH SCREEN (Snow + Icon)
   ========================================= */
#splash-screen {
  position: fixed;
  inset: 0;
  background-color: #ffffff;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

#splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  position: relative;
  z-index: 2;
  animation: pulseLogo 2s infinite ease-in-out;
}

.splash-logo {
  width: 350px;
  height: 350px;
  object-fit: contain;
  display: block;
}

#snow-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.snowflake {
  position: absolute;
  top: -10px;
  background-color: #fff;
  border-radius: 50%;
  pointer-events: none;
  animation: fall linear infinite;
}

@keyframes fall {
  0% { transform: translateY(-10vh) translateX(0); }
  100% { transform: translateY(110vh) translateX(20px); }
}

@keyframes pulseLogo {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===========================
   Splash: single source of truth
   =========================== */

/* Default hidden */
#splash-screen { display: none; }

/* Visible only when html.show-splash */
html.show-splash #splash-screen { display: flex; }

/* Prevent app flashing */
html.show-splash #app-content { visibility: hidden; }
html.no-splash #app-content { visibility: visible; }

/* Hard safety: when splash is off, it must never intercept taps */
html.no-splash #splash-screen {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}