* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: #f5f5f5; }
#app { min-height: 100vh; padding: 1rem; }
.header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.header h1 { margin: 0; font-size: 1.25rem; }
.back { background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0.25rem; }
.lang-toggle { margin-inline-start: auto; background: none; border: 1px solid rgba(0,0,0,0.15); border-radius: 6px; padding: 0.25rem 0.625rem; font-size: 0.8rem; font-weight: 600; cursor: pointer; color: #555; white-space: nowrap; flex-shrink: 0; }
.lang-toggle:hover { background: rgba(0,0,0,0.05); color: #333; }
.categories { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.category-card { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1rem; background: #fff; border: none; border-radius: 8px; cursor: pointer; text-align: start; text-decoration: none; color: inherit; }
/* pointer-events: none so clicks always hit the card; card is clickable before image loads */
.category-thumb { width: 64px; height: 64px; flex-shrink: 0; object-fit: cover; border-radius: 4px; background: #e8e8e8; pointer-events: none; }
.category-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.category-name { font-weight: 600; }
.category-desc { color: #666; font-size: 0.9rem; }
/* L:/M:/H: tier counts — same gate as image-level dots (?debugLevel=1 / VITE_DEBUG_IMAGE_LEVELS) */
body:not(.debug-image-levels) .prefetch-stats {
  display: none !important;
}
.prefetch-stats { flex-shrink: 0; font-size: 0.7rem; color: #888; min-width: 8rem; visibility: visible; }
.items { display: flex; flex-direction: column; gap: 1rem; }
.items-error { justify-content: center; align-items: center; min-height: 12rem; text-align: center; gap: 1rem; }
.items-error .error-message { margin: 0; color: #666; }
.retry-items { padding: 0.5rem 1rem; font-size: 1rem; font-weight: 600; cursor: pointer; background: #333; color: #fff; border: none; border-radius: 6px; }
.retry-items:hover { background: #555; }
.item { display: flex; gap: 1rem; background: #fff; padding: 1rem; border-radius: 8px; }
.item-img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: #e8e8e8; }
/* Div placeholder until real image loads: same size, solid background, no img request */
.item-img-placeholder { display: block; min-width: 80px; min-height: 80px; }
.item-body { flex: 1; min-width: 0; }
.item-name { margin: 0 0 0.25rem; font-size: 1rem; }
.item-desc { margin: 0; color: #666; font-size: 0.875rem; }
.item-price { margin: 0.5rem 0 0; font-weight: 600; }
.item-hint { font-weight: 400; color: #888; font-size: 0.85em; }
.loading, .error { text-align: center; padding: 2rem; color: #666; }

/* Typing caret animation */
@keyframes blink-caret {
  0%, 100% { border-color: currentColor; }
  50% { border-color: transparent; }
}
.typing-caret {
  display: inline-block;
  border-right: 3px solid;
  padding-right: 2px;
  animation: blink-caret 0.7s step-end infinite;
}

/* Skeleton / shimmer placeholders */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton-text {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  min-width: 140px;
  display: inline-block;
}
.skeleton-card { }
.skeleton-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}
/* Match final category thumb size so placeholder doesn't appear massive before content loads */
.category-card .skeleton-thumb {
  width: 64px;
  height: 64px;
  min-width: 64px;
  flex-shrink: 0;
  aspect-ratio: unset;
}
.skeleton-name {
  display: block;
  margin-top: 0.5rem;
  height: 1em;
  width: 60%;
  margin-left: auto;
  margin-right: auto;
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}
.error { color: #c00; }

/* Image level debug indicator (L1=red, L2=blue, L3=green); visible only when .debug-image-levels on body */
.img-level-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.img-level-dot {
  display: none;
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  border: 1px solid #ffffff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.65);
}
.img-level-dot[data-level="L1"] { background: red; }
.img-level-dot[data-level="L2"] { background: blue; }
.img-level-dot[data-level="L3"] { background: green; }
/* Enable with ?debugLevel=1 in URL or VITE_DEBUG_IMAGE_LEVELS=true at build */
body.debug-image-levels .img-level-dot { display: block; }
#lightbox .img-level-dot {
  /* Scale with viewport so it stays visible on large screenshots/displays. */
  width: clamp(16px, 1.8vw, 30px);
  height: clamp(16px, 1.8vw, 30px);
  top: clamp(6px, 0.8vw, 14px);
  left: clamp(6px, 0.8vw, 14px);
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.75);
}

/* Analytics panel: same gate as image-level dots — only when body.debug-image-levels (see main.ts / bandwidth). */
body:not(.debug-image-levels) #debug-panel {
  display: none !important;
}
/* Collapsed state still uses .visible; hide entirely when debug is off (above wins with !important). */
#debug-panel:not(.visible) {
  display: none;
}
#debug-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  min-width: 200px;
  min-height: 60px;
  max-width: 360px;
  max-height: 50vh;
  overflow: auto;
  background: #1a1a1a;
  color: #e0e0e0;
  font-size: 12px;
  padding: 10px 12px;
  border-radius: 8px 0 0 0;
  border: 1px solid #444;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.4);
  z-index: 9999;
  transition: max-height 0.15s ease-out, transform 0.15s ease-out, opacity 0.15s ease-out;
}
#debug-panel.collapsed {
  max-height: 28px;
  overflow: hidden;
  cursor: pointer;
}
#debug-panel .debug-panel-inner strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
  font-size: 13px;
}
#debug-panel .debug-panel-inner pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, monospace;
}
/* Header + toggle affordance */
#debug-panel .debug-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
#debug-panel .debug-panel-title {
  flex: 1;
}
#debug-panel .debug-panel-copy {
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 12px;
  margin-right: 6px;
  padding: 0 4px;
}
#debug-panel .debug-panel-copy:hover {
  color: #fff;
}
#debug-panel .debug-panel-toggle {
  background: transparent;
  border: none;
  color: #bbb;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}
#debug-panel .debug-panel-toggle:hover {
  color: #fff;
}
#debug-panel.collapsed .debug-panel-body,
#debug-panel.collapsed .debug-cache-progress,
#debug-panel.collapsed .debug-panel-actions {
  display: none;
}
#debug-panel .debug-panel-actions {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #333;
}
#debug-panel #debug-show-language {
  background: rgba(255,255,255,0.1);
  border: 1px solid #555;
  border-radius: 4px;
  color: #ccc;
  font-size: 0.75rem;
  padding: 4px 8px;
  cursor: pointer;
}
#debug-panel #debug-show-language:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* Cache progress bar in debug panel */
#debug-panel .debug-cache-progress {
  margin-bottom: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #333;
}
#debug-panel .debug-cache-progress-header {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 4px;
}
#debug-panel .debug-cache-progress-bar {
  display: flex;
  flex-direction: row;
  height: 8px;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}
#debug-panel .debug-cache-progress-fill {
  height: 100%;
  min-width: 0;
  transition: width 0.2s ease-out;
}
#debug-panel .debug-cache-progress-cached {
  background: linear-gradient(90deg, #2a7a3e 0%, #3d9b52 100%);
  border-radius: 4px 0 0 4px;
}
#debug-panel .debug-cache-progress-failed {
  background: linear-gradient(90deg, #8b2e2e 0%, #b53d3d 100%);
  border-radius: 0 4px 4px 0;
}
#debug-panel .debug-cache-progress-text {
  font-size: 11px;
  color: #888;
  font-family: ui-monospace, monospace;
}

/* Lightbox for full-size image with zoom */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  flex-direction: column;
}
#lightbox.open { display: flex; }
#lightbox .lightbox-image-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  min-height: 0;
  width: 100%;
}
/* Zoom applies to .img-level-wrap in JS so the level dot stays above the image (transform on img hid the dot). */
#lightbox .lightbox-image-wrap .img-level-wrap {
  transform-origin: center center;
  transition: transform 0.1s ease-out;
}
#lightbox .lightbox-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 0;
}
#lightbox .lightbox-image-wrap .img-level-dot {
  z-index: 50;
}
#lightbox .lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
#lightbox .lightbox-close:hover { background: rgba(255,255,255,0.35); }
#lightbox .lightbox-zoom-controls {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0,0,0,0.6);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}
#lightbox .lightbox-zoom-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}
#lightbox .lightbox-zoom-btn:hover { background: rgba(255,255,255,0.35); }
#lightbox .lightbox-zoom-value {
  min-width: 3rem;
  text-align: center;
  color: #fff;
  font-size: 0.9rem;
}

/* ── Splash screen ────────────────────────────────────────────────────────── */
#splash {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  padding: 1.5rem;
}
.splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
  max-width: 360px;
  width: 100%;
}
.splash-name {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2.25rem);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  min-height: 1.2em;
}
.splash-loading {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.55);
}
.splash-tagline {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.01em;
}
.splash-lang-buttons {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.splash-lang-btn {
  flex: 1;
  padding: 0.875rem 1rem;
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.splash-lang-btn:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.45);
}
.splash-lang-btn:active {
  transform: scale(0.97);
}
@keyframes splash-btn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}
.splash-card--venue-pending .splash-lang-btn {
  animation: splash-btn-pulse 1.35s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .splash-card--venue-pending .splash-lang-btn {
    animation: none;
  }
}
.splash-lang-btn-ar {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  direction: rtl;
}
@keyframes splash-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
#splash.splash-exit {
  animation: splash-fade-out 0.25s ease-out forwards;
  pointer-events: none;
}

/* ── RTL layout overrides ─────────────────────────────────────────────────── */
/* text-align: start on .category-card handles LTR/RTL text direction automatically. */
/* flex-direction: row with direction:rtl moves the thumbnail to the right side naturally. */
[dir=rtl] .item-body { text-align: right; }
[dir=rtl] .lightbox-details { text-align: right; }

/* Item details below the image in lightbox */
#lightbox .lightbox-details {
  display: none;
  flex-shrink: 0;
  max-height: 40vh;
  overflow-y: auto;
  padding: 1rem 2rem 2rem;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  text-align: left;
}
#lightbox .lightbox-details.lightbox-details-visible {
  display: block;
}
#lightbox .lightbox-detail-name {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
}
#lightbox .lightbox-detail-desc {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.9);
  white-space: pre-wrap;
  word-break: break-word;
}
#lightbox .lightbox-detail-price {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
}
