/* Mall Tile Field — Low-chrome discovery surface
   Portrait-first 9:16 video wall (Shorts-style)
   SoftProto mount point: #mallTileField[data-softproto-mount="tile-field"]

   Anchor model: This is the MIDDLE FIELD — dominates the Mall experience

   Motion modes:
   - Snap (default): page-style discrete movement
   - Glide: fluid scroll override

   Density presets (AI-controlled or viewport-adaptive):
   - 3x4, 3x5, 4x6, 5x8 (portrait-first dense walls)
   - 6x3 (desktop wide viewport - auto-selected for fine-pointer + landscape)
*/

:root {
  --field-columns: 3;
  --field-rows: 5;
}

/* ========== Projection Controls ========== */

.mall-projection {
  display: flex;
  gap: 0.4rem;
  padding: 0 0 0.5rem;
  flex-wrap: wrap;
}

/* ========== Density Controls ========== */

.mall-density-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0 0.75rem;
  flex-wrap: wrap;
}

.mall-density-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 0.25rem;
}

.mall-density-btn {
  min-width: 32px;
  min-height: 32px;
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}

.mall-density-btn:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
}

.mall-density-btn.active {
  border-color: rgba(141, 113, 255, 0.5);
  background: rgba(141, 113, 255, 0.15);
  color: #fff;
}

.mall-density-slider {
  width: 80px;
  height: 4px;
  margin-left: 0.5rem;
  accent-color: rgba(141, 113, 255, 0.8);
  cursor: pointer;
}

@media (max-width: 600px) {
  .mall-density-controls {
    display: none; /* Hide on mobile - auto-density is better */
  }
}

.mall-projection-chip {
  min-height: 44px; /* WCAG touch target */
  padding: 0.6rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mall-projection-chip:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.75);
}

.mall-projection-chip.active {
  border-color: rgba(141, 113, 255, 0.5);
  background: rgba(141, 113, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}

.mall-projection-chip:focus-visible {
  outline: 2px solid rgba(141, 113, 255, 0.6);
  outline-offset: 2px;
}

/* Category headers (when grouped) */
.mall-tile-category-header {
  grid-column: 1 / -1;
  padding: 0.5rem 0 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.mall-tile-category-header:first-child {
  padding-top: 0;
}

/* ========== Tile Field Container ========== */

.mall-tile-field-wrapper {
  flex: 1;
  overflow: auto;
  scroll-snap-type: both mandatory;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Smooth deceleration for phone-native feel */
  scroll-padding: 0;
  /* Desktop drag affordance */
  cursor: grab;
  /* Touch gesture clarity */
  touch-action: pan-x pan-y;
  /* For scroll shadow pseudo-elements */
  position: relative;
}

/* Active drag state */
.mall-tile-field-wrapper.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  scroll-behavior: auto;
  user-select: none;
}

/* Scroll edge shadows for spatial awareness */
.mall-tile-field-wrapper::before,
.mall-tile-field-wrapper::after {
  content: '';
  position: sticky;
  left: 0;
  right: 0;
  height: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease-out;
  z-index: 10;
}

.mall-tile-field-wrapper::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.15), transparent);
}

.mall-tile-field-wrapper::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.15), transparent);
}

.mall-tile-field-wrapper.can-scroll-up::before,
.mall-tile-field-wrapper.can-scroll-down::after {
  opacity: 1;
}

/* Glide mode: remove snap for fluid scrolling */
.mall-tile-field-wrapper.motion-glide {
  scroll-snap-type: none;
}

.mall-tile-field {
  display: grid;
  grid-template-columns: repeat(var(--field-columns, 3), 1fr);
  grid-auto-rows: auto;
  grid-auto-flow: row;
  gap: var(--tile-gap, 0.2rem);
  padding: 0;
  min-height: 100%;
  /* Content fade transition for expand/collapse */
  transition: opacity 120ms ease-out;
}

.mall-tile-field.transitioning {
  opacity: 0.7;
}

/* Density presets with adaptive styling (portrait-first, tight gaps) */
.mall-tile-field[data-density="3x4"] {
  --field-columns: 3;
  --field-rows: 4;
  --tile-radius: 0.5rem;
  --tile-gap: 0.25rem;
}
.mall-tile-field[data-density="3x5"] {
  --field-columns: 3;
  --field-rows: 5;
  --tile-radius: 0.4rem;
  --tile-gap: 0.2rem;
}
.mall-tile-field[data-density="4x6"] {
  --field-columns: 4;
  --field-rows: 6;
  --tile-radius: 0.35rem;
  --tile-gap: 0.15rem;
}
.mall-tile-field[data-density="5x8"] {
  --field-columns: 5;
  --field-rows: 8;
  --tile-radius: 0.25rem;
  --tile-gap: 0.1rem;
}
/* Desktop-optimized: wide landscape with 6 columns */
.mall-tile-field[data-density="6x3"] {
  --field-columns: 6;
  --field-rows: 3;
  --tile-radius: 0.5rem;
  --tile-gap: 0.35rem;
}

.mall-tile-field[data-density="6x3"] .mall-tile {
  aspect-ratio: 3 / 4;
}

/* Desktop dense wall presets — shorter aspect ratio for more rows */
.mall-tile-field[data-density="8x5"] {
  --field-columns: 8;
  --field-rows: 5;
  --tile-radius: 0.35rem;
  --tile-gap: 0.2rem;
}

.mall-tile-field[data-density="8x5"] .mall-tile {
  aspect-ratio: 3 / 4;
}

.mall-tile-field[data-density="10x6"] {
  --field-columns: 10;
  --field-rows: 6;
  --tile-radius: 0.3rem;
  --tile-gap: 0.15rem;
}

.mall-tile-field[data-density="10x6"] .mall-tile {
  aspect-ratio: 4 / 5;
}

.mall-tile-field[data-density="12x8"] {
  --field-columns: 12;
  --field-rows: 8;
  --tile-radius: 0.25rem;
  --tile-gap: 0.1rem;
}

.mall-tile-field[data-density="12x8"] .mall-tile {
  aspect-ratio: 1 / 1;
}

/* Ultra-wide desktop: 12 columns × 3 rows with landscape tiles */
.mall-tile-field[data-density="12x3"] {
  --field-columns: 12;
  --field-rows: 3;
  --tile-radius: 0.3rem;
  --tile-gap: 0.2rem;
}

.mall-tile-field[data-density="12x3"] .mall-tile {
  aspect-ratio: 4 / 3;
}

/* Maximum density: 15 columns for large screens */
.mall-tile-field[data-density="15x4"] {
  --field-columns: 15;
  --field-rows: 4;
  --tile-radius: 0.2rem;
  --tile-gap: 0.1rem;
}

.mall-tile-field[data-density="15x4"] .mall-tile {
  aspect-ratio: 1 / 1;
}

/* Wide landscape: 8 columns × 2 rows */
.mall-tile-field[data-density="8x2"] {
  --field-columns: 8;
  --field-rows: 2;
  --tile-radius: 0.4rem;
  --tile-gap: 0.25rem;
}

.mall-tile-field[data-density="8x2"] .mall-tile {
  aspect-ratio: 16 / 9;
}

@media (min-width: 600px) {
  .mall-tile-field {
    gap: 0.25rem;
  }
}

@media (min-width: 900px) {
  .mall-tile-field {
    gap: 0.35rem;
  }
}

/* ========== Tile ========== */

.mall-tile {
  position: relative;
  aspect-ratio: 9 / 16;
  border-radius: var(--tile-radius, 0.4rem);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  overflow: hidden;
}

/* Channel avatar tiles: contain to show full logo, cover for video thumbnails */
.mall-tile[data-tile-type="avatar"] {
  background-size: contain;
}

.mall-tile[data-tile-type="video"] {
  background-size: cover;
}

/* Loading shimmer while thumbnail loads */
.mall-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 20%,
    rgba(255, 255, 255, 0.04) 40%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 60%,
    transparent 80%
  );
  background-size: 200% 100%;
  animation: tile-shimmer 1.5s ease-in-out infinite;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.mall-tile.thumb-loaded::after {
  opacity: 0;
}

@keyframes tile-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.mall-tile {
  cursor: pointer;
  /* Snappy transitions for phone feel */
  transition: transform 100ms ease-out, border-color 100ms ease-out, box-shadow 100ms ease-out;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  scroll-snap-align: start;
  /* Ensure minimum tappable size */
  min-width: 3rem;
  min-height: 3rem;
}

.mall-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.12), transparent 40%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 50%);
  pointer-events: none;
}

.mall-tile:hover {
  transform: scale(1.02);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.24);
}

/* Keyboard focus: clear visible ring for accessibility */
.mall-tile:focus-visible {
  transform: scale(1.02);
  border-color: rgba(141, 113, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(141, 113, 255, 0.35), 0 8px 32px rgba(0, 0, 0, 0.24);
  outline: none;
}

.mall-tile:active {
  transform: scale(0.97);
}

/* Tap confirmation pulse — immediate visual feedback */
.mall-tile.tap-pulse {
  animation: tile-tap-pulse 180ms ease-out;
}

@keyframes tile-tap-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.mall-tile.is-inspecting {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

/* ========== Tile Content ========== */

.mall-tile-inner {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 0.35rem;
  position: relative;
  z-index: 1;
}

.mall-tile-token {
  font-family: var(--mono);
  font-size: 0.5rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.mall-tile-hero {
  font-size: clamp(1.2rem, 6vw, 1.8rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: rgba(255, 255, 255, 0.88);
  overflow: hidden;
  text-overflow: ellipsis;
}

.mall-tile-name {
  margin: 0;
  font-size: 0.6rem;
  font-weight: 500;
  line-height: 1.15;
  color: rgba(255, 255, 255, 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mall-tile-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  padding: 0.1rem 0.25rem;
  font-size: 0.45rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 0.2rem;
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(4px);
}

.mall-tile-badge.ready {
  background: rgba(40, 180, 99, 0.3);
  color: #81f0a3;
}

.mall-tile-badge.conditional {
  background: rgba(180, 130, 40, 0.3);
  color: #ffcf79;
}

/* Video queue count badge */
.mall-tile-queue-count {
  position: absolute;
  bottom: 0.25rem;
  right: 0.25rem;
  padding: 0.1rem 0.3rem;
  font-size: 0.5rem;
  font-weight: 700;
  font-family: var(--mono);
  border-radius: 0.2rem;
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
}

/* ========== Non-Video Tiles ========== */

/* Source action badge ("View Repo", "Open App", "Open Service") */
.mall-tile-action-badge {
  position: absolute;
  bottom: 0.25rem;
  left: 0.25rem;
  padding: 0.1rem 0.3rem;
  font-size: 0.45rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 0.2rem;
  background: rgba(141, 113, 255, 0.4);
  color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* Non-video tiles: subtle border accent, no video controls */
.mall-tile.non-video {
  border-color: rgba(141, 113, 255, 0.15);
}

.mall-tile.non-video:hover,
.mall-tile.non-video:focus-visible {
  border-color: rgba(141, 113, 255, 0.35);
}

/* Play state indicator — snappy for immediate feel */
.mall-tile-play-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Tightened timing for phone-native feel */
  transition: transform 80ms ease-out, opacity 80ms ease-out;
  opacity: 0;
  pointer-events: none;
}

.mall-tile.is-playing .mall-tile-play-indicator {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.mall-tile-play-indicator::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.35rem 0 0.35rem 0.55rem;
  border-color: transparent transparent transparent #fff;
  margin-left: 0.15rem;
}

.mall-tile.is-playing .mall-tile-play-indicator::before {
  /* Pause icon: two bars */
  border: none;
  width: 0.45rem;
  height: 0.6rem;
  background: linear-gradient(to right, #fff 35%, transparent 35%, transparent 65%, #fff 65%);
  margin-left: 0;
}

/* ========== Inline Preview Layer ========== */

.mall-tile-preview {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 120ms ease-out;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.mall-tile-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.25) 100%);
  pointer-events: none;
  z-index: 1;
}

.mall-tile-preview-stage {
  width: 100%;
  height: 100%;
}

.mall-tile-preview-host,
.mall-tile-preview-media,
.mall-tile-preview-stage iframe,
.mall-tile-preview-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
}

/* Active preview: show the preview layer and hide thumbnail background */
.mall-tile.is-previewing .mall-tile-preview {
  opacity: 1;
}

.mall-tile.is-previewing {
  background-image: none !important;
}

/* Hide play indicator during active preview */
.mall-tile.is-previewing .mall-tile-play-indicator {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}

/* Paused preview: show pause bars in play indicator */
.mall-tile.is-previewing.is-paused .mall-tile-play-indicator {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.mall-tile.is-previewing.is-paused .mall-tile-play-indicator::before {
  /* Pause bars */
  border: none;
  width: 0.45rem;
  height: 0.6rem;
  background: linear-gradient(to right, #fff 35%, transparent 35%, transparent 65%, #fff 65%);
  margin-left: 0;
}

/* Paused preview dims the preview layer slightly */
.mall-tile.is-paused .mall-tile-preview {
  opacity: 0.75;
}

/* Video-control tiles get extra top padding for controls */
.mall-tile.has-video-controls .mall-tile-inner {
  padding-top: 1.5rem;
}

/* ========== Audio Button (Inline Preview Mute Toggle) ========== */

.mall-tile-audio {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease;
  z-index: 10;
}

.mall-tile-audio svg,
.mall-tile-expand svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Audio button state: active (preview is playing for this tile) */
.mall-tile-audio.is-active {
  background: rgba(66, 160, 255, 0.45);
}

/* Audio button state: active and unmuted (sound is on) */
.mall-tile-audio.is-active:not(.is-muted) {
  background: rgba(66, 160, 255, 0.55);
  color: #fff;
}

/* Audio button state: active and muted (sound is off) */
.mall-tile-audio.is-active.is-muted {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.55);
}

/* Audio button state: paused preview */
.mall-tile.is-paused .mall-tile-audio.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
}

/* Touch devices: always show controls (no hover) */
@media (hover: none) {
  .mall-tile-expand,
  .mall-tile-audio,
  .mall-tile-enter {
    opacity: 1;
  }

  /* Video-backed tiles need control padding when controls are always visible */
  .mall-tile:has(.mall-tile-audio) .mall-tile-inner {
    padding-top: 1.5rem;
  }
}

/* ─── Expand Button (Fullscreen Entry on Tile) ─── */
.mall-tile-expand {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease;
  z-index: 10;
}

.mall-tile:hover .mall-tile-expand,
.mall-tile:focus-within .mall-tile-expand,
.mall-tile.is-previewing .mall-tile-expand {
  opacity: 1;
}

.mall-tile:hover .mall-tile-audio,
.mall-tile:focus-within .mall-tile-audio,
.mall-tile.is-previewing .mall-tile-audio {
  opacity: 1;
}

.mall-tile-expand:hover {
  background: rgba(124, 92, 252, 0.8);
}

/* Focus states for control buttons (keyboard accessibility) */
.mall-tile-audio:focus-visible,
.mall-tile-expand:focus-visible,
.mall-tile-enter:focus-visible {
  opacity: 1;
  outline: 2px solid rgba(141, 113, 255, 0.8);
  outline-offset: 2px;
  background: rgba(124, 92, 252, 0.6);
}

/* ─── Enter FoundUp Button (WSP 104 Canonical Route) ─── */
.mall-tile-enter {
  position: absolute;
  bottom: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease;
  z-index: 10;
}

.mall-tile-enter svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Enter button visible during preview or hover */
.mall-tile:hover .mall-tile-enter,
.mall-tile:focus-within .mall-tile-enter,
.mall-tile.is-previewing .mall-tile-enter {
  opacity: 1;
}

.mall-tile-enter:hover {
  background: rgba(40, 180, 99, 0.8);
}

/* Expanded FoundUp video field mode */
.mall-tile-field.expanded-mode {
  /* When viewing a single FoundUp's videos */
}

.mall-tile-field.expanded-mode .mall-tile {
  /* Video tiles in expanded mode */
}

/* Collapse indicator (shown in expanded mode) */
.mall-tile-field-collapse-hint {
  position: fixed;
  bottom: calc(6rem + var(--safe-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(0.5rem);
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 999px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}

.mall-tile-field-collapse-hint.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== Theme Colors (reuse from carousel) ========== */
/*
 * Each theme sets background-color as a fallback for broken poster images.
 * JS sets inline style="background-image: url(...)" which overrides the
 * gradient. background-color survives that override, so failed posters
 * degrade to a solid theme tone instead of transparent black.
 */

.mall-tile.theme-antifafm {
  background: linear-gradient(145deg, rgba(60, 11, 16, 0.96), rgba(122, 20, 28, 0.72) 60%, rgba(24, 7, 10, 0.98));
  background-color: #3c0b10;
}

.mall-tile.theme-gotjunk {
  background: linear-gradient(145deg, rgba(15, 60, 56, 0.96), rgba(27, 108, 92, 0.76) 60%, rgba(17, 25, 19, 0.98));
  background-color: #0f3c38;
}

.mall-tile.theme-magadoom {
  background: linear-gradient(145deg, rgba(27, 17, 56, 0.96), rgba(89, 28, 113, 0.76) 60%, rgba(12, 14, 28, 0.98));
  background-color: #1b1138;
}

.mall-tile.theme-tq {
  background: linear-gradient(145deg, rgba(11, 29, 60, 0.96), rgba(20, 80, 160, 0.72) 60%, rgba(8, 12, 28, 0.98));
  background-color: #0b1d3c;
}

.mall-tile.theme-vsa {
  background: linear-gradient(145deg, rgba(40, 40, 45, 0.96), rgba(80, 82, 88, 0.72) 60%, rgba(22, 22, 26, 0.98));
  background-color: #28282d;
}

.mall-tile.theme-pqn {
  background: linear-gradient(145deg, rgba(20, 50, 30, 0.96), rgba(50, 120, 70, 0.72) 60%, rgba(12, 20, 14, 0.98));
  background-color: #14321e;
}

/* Video Mall Catalog lane themes — distinct fallback colors per FoundUp */

.mall-tile.theme-move2japan {
  background: linear-gradient(145deg, rgba(16, 42, 58, 0.96), rgba(30, 90, 120, 0.72) 60%, rgba(8, 18, 28, 0.98));
  background-color: #102a3a;
}

/* Public property records use the same field, with readable factual metadata. */
.mall-tile.property-listing {
  min-height: 19rem;
  color: #f3f1f8;
}
.property-listing .mall-tile-inner {
  padding: 3rem 1.1rem 1.1rem;
  gap: 0.3rem;
  box-sizing: border-box;
}
.mall-property-photo-note {
  position: absolute;
  top: 1rem;
  left: 1.1rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.76);
}
.mall-property-location {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.76);
}
.property-listing .mall-tile-name {
  font-size: 1.05rem;
  line-height: 1.3;
  white-space: normal;
  color: #fff;
}
.mall-property-price {
  margin: 0.45rem 0 0.2rem;
  font-size: 1.5rem;
  letter-spacing: -0.025em;
}
.mall-property-area,
.mall-property-condition {
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
}
.mall-property-condition {
  margin-top: 0.35rem;
}
.mall-property-open {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Opt-in grouped projection: one vertical field, horizontal sequences per area.
   These rules are content-neutral; the adapter supplies names and membership. */
.mall-tile-field-wrapper.mall-field-grouped-wrapper {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-padding-block: 0.25rem;
  overscroll-behavior-y: contain;
  touch-action: pan-x pan-y pinch-zoom;
}

.mall-tile-field[data-layout="grouped"] {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  padding: 0.25rem 0.25rem 1rem;
}

.mall-field-group {
  min-width: 0;
  scroll-snap-align: start;
  scroll-margin-block-start: 0.25rem;
}

.mall-field-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0 0.15rem 0.4rem;
}

.mall-field-group-heading {
  margin: 0;
  color: var(--text, #f3f1f8);
  font-size: 1rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.mall-field-group-subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-dim, #b5b4c0);
  font-size: 0.73rem;
  line-height: 1.35;
}

.mall-field-group-controls {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.mall-group-nav {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  color: #f3f1f8;
  font-size: 1.1rem;
  cursor: pointer;
}

.mall-group-nav:disabled { opacity: 0.3; cursor: default; }
.mall-group-nav:focus-visible { outline: 2px solid #b5a0ff; outline-offset: 2px; }

.mall-field-group-track {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(14rem, 28vw, 18rem);
  gap: 0.6rem;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  padding: 0.2rem 0.15rem 0.65rem;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0.15rem;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  touch-action: pan-x pan-y pinch-zoom;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.mall-tile-field[data-layout="grouped"] .mall-tile {
  aspect-ratio: auto;
  min-width: 0;
  min-height: 16rem;
  scroll-snap-align: start;
  touch-action: pan-x pan-y pinch-zoom;
}

.mall-tile-field[data-layout="grouped"] .property-listing .mall-tile-inner {
  justify-content: flex-start;
  height: auto;
  min-height: 100%;
  padding: 2.15rem 0.85rem 0.85rem;
  gap: 0.2rem;
}

.mall-tile-field[data-layout="grouped"] .mall-property-photo-note {
  top: 0.75rem;
  left: 0.85rem;
  font-size: 0.69rem;
}

.mall-tile-field[data-layout="grouped"] .mall-property-location {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.72rem;
}

.mall-tile-field[data-layout="grouped"] .mall-tile-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 0.94rem;
  line-height: 1.3;
}

.mall-tile-field[data-layout="grouped"] .mall-property-price {
  margin: 0.3rem 0 0.15rem;
  font-size: 1.35rem;
}

.mall-tile-field[data-layout="grouped"] .mall-property-condition { margin-top: 0.2rem; }
.mall-tile-field[data-layout="grouped"] .mall-property-open { margin-top: 0.3rem; }
.mall-field-group-empty { color: var(--text-dim, #b5b4c0); font-size: 0.85rem; }

.mall-field-grouped-wrapper.is-dragging,
.mall-field-grouped-wrapper.motion-glide,
.mall-field-grouped-wrapper.is-dragging .mall-field-group-track,
.mall-field-grouped-wrapper.motion-glide .mall-field-group-track {
  scroll-snap-type: none;
}

@media (max-width: 600px) {
  .mall-field-group-track { grid-auto-columns: min(82%, 18rem); }
}

.mall-tile.theme-undaodu {
  background: linear-gradient(145deg, rgba(38, 18, 52, 0.96), rgba(80, 40, 110, 0.72) 60%, rgba(18, 10, 28, 0.98));
  background-color: #261234;
}

.mall-tile.theme-foundups_main,
.mall-tile.theme-foundups-main {
  background: linear-gradient(145deg, rgba(14, 40, 28, 0.96), rgba(30, 90, 60, 0.72) 60%, rgba(8, 20, 14, 0.98));
  background-color: #0e281c;
}

.mall-tile.theme-linkedin_012,
.mall-tile.theme-linkedin-012 {
  background: linear-gradient(145deg, rgba(10, 32, 56, 0.96), rgba(22, 70, 120, 0.72) 60%, rgba(6, 14, 28, 0.98));
  background-color: #0a2038;
}

.mall-tile.theme-linkedin_esingularity,
.mall-tile.theme-esingularity {
  background: linear-gradient(145deg, rgba(40, 28, 10, 0.96), rgba(100, 70, 22, 0.72) 60%, rgba(20, 14, 6, 0.98));
  background-color: #281c0a;
}

.mall-tile.theme-linkedin_tsingularity,
.mall-tile.theme-tsingularity {
  background: linear-gradient(145deg, rgba(20, 14, 42, 0.96), rgba(50, 30, 100, 0.72) 60%, rgba(10, 8, 22, 0.98));
  background-color: #140e2a;
}

.mall-tile.theme-linkedin_foundups,
.mall-tile.theme-foundups-ln {
  background: linear-gradient(145deg, rgba(18, 38, 22, 0.96), rgba(40, 85, 50, 0.72) 60%, rgba(10, 18, 12, 0.98));
  background-color: #122616;
}

/* Category-derived themes — fallback when no lane-specific theme matches */

.mall-tile.theme-cat-travel {
  background: linear-gradient(145deg, rgba(16, 42, 58, 0.96), rgba(30, 90, 120, 0.72) 60%, rgba(8, 18, 28, 0.98));
  background-color: #102a3a;
}

.mall-tile.theme-cat-music {
  background: linear-gradient(145deg, rgba(38, 18, 52, 0.96), rgba(80, 40, 110, 0.72) 60%, rgba(18, 10, 28, 0.98));
  background-color: #261234;
}

.mall-tile.theme-cat-startup {
  background: linear-gradient(145deg, rgba(14, 40, 28, 0.96), rgba(30, 90, 60, 0.72) 60%, rgba(8, 20, 14, 0.98));
  background-color: #0e281c;
}

.mall-tile.theme-cat-media {
  background: linear-gradient(145deg, rgba(60, 11, 16, 0.96), rgba(122, 20, 28, 0.72) 60%, rgba(24, 7, 10, 0.98));
  background-color: #3c0b10;
}

.mall-tile.theme-cat-thought-leadership {
  background: linear-gradient(145deg, rgba(10, 32, 56, 0.96), rgba(22, 70, 120, 0.72) 60%, rgba(6, 14, 28, 0.98));
  background-color: #0a2038;
}

.mall-tile.theme-cat-ai-education {
  background: linear-gradient(145deg, rgba(40, 28, 10, 0.96), rgba(100, 70, 22, 0.72) 60%, rgba(20, 14, 6, 0.98));
  background-color: #281c0a;
}

.mall-tile.theme-cat-ai-research {
  background: linear-gradient(145deg, rgba(20, 14, 42, 0.96), rgba(50, 30, 100, 0.72) 60%, rgba(10, 8, 22, 0.98));
  background-color: #140e2a;
}

.mall-tile.theme-default {
  background: linear-gradient(145deg, rgba(30, 30, 35, 0.96), rgba(60, 60, 68, 0.72) 60%, rgba(18, 18, 22, 0.98));
  background-color: #1e1e23;
}

/* ========== Inspector Overlay ========== */

.tile-inspector-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.tile-inspector-scrim.visible {
  opacity: 1;
  pointer-events: auto;
}

.tile-inspector {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(90vw, 380px);
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--surface);
  backdrop-filter: blur(32px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
  z-index: 181;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.tile-inspector.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.tile-inspector-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.tile-inspector-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tile-inspector-badge {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.tile-inspector-badge.ready {
  background: rgba(40, 180, 99, 0.25);
  color: #81f0a3;
}

.tile-inspector-badge.conditional {
  background: rgba(180, 130, 40, 0.25);
  color: #ffcf79;
}

.tile-inspector-name {
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.tile-inspector-tagline {
  margin: 0 0 1rem;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  line-height: 1.4;
}

.tile-inspector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.tile-inspector-field {
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
}

.tile-inspector-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 0.2rem;
}

.tile-inspector-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.tile-inspector-actions {
  display: flex;
  gap: 0.75rem;
}

.tile-inspector-enter {
  flex: 1;
  min-height: 48px; /* Thumb-comfortable tap target */
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease;
}

.tile-inspector-enter:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tile-inspector-enter:active {
  background: rgba(255, 255, 255, 0.24);
  transform: scale(0.98);
}

.tile-inspector-hint {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
}

/* ========== Phone Thumb-Zone: Inspector as Bottom Sheet ========== */

@media (max-width: 480px) {
  .tile-inspector {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    width: 100%;
    max-width: none;
    max-height: 85vh;
    border-radius: 1.5rem 1.5rem 0 0;
    padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-bottom, 0px));
  }

  .tile-inspector.visible {
    transform: translateY(0);
  }

  /* Compact grid on small screens */
  .tile-inspector-grid {
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .tile-inspector-field {
    padding: 0.5rem 0.65rem;
  }

  /* Larger action button for thumb reach */
  .tile-inspector-enter {
    min-height: 52px;
    font-size: 1rem;
  }

  /* Handle indicator at top */
  .tile-inspector::before {
    content: "";
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2rem;
    height: 0.25rem;
    border-radius: 0.125rem;
    background: rgba(255, 255, 255, 0.25);
  }

  .tile-inspector-header {
    padding-top: 0.5rem;
  }
}

/* ========== Reduced Mall Copy ========== */

.mall-copy-minimal {
  padding: 0.5rem 0 0.75rem;
}

.mall-copy-minimal h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  max-width: none;
}

/* ========== FLIP Transition Layer ========== */

.mall-flip-layer {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  border-radius: var(--tile-radius, 0.4rem);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  will-change: left, top, width, height, border-radius;
}

/* Geometry transition: animate left, top, width, height, border-radius */
.mall-flip-layer.flip-animating {
  transition:
    left 280ms cubic-bezier(0.32, 0.72, 0, 1),
    top 280ms cubic-bezier(0.32, 0.72, 0, 1),
    width 280ms cubic-bezier(0.32, 0.72, 0, 1),
    height 280ms cubic-bezier(0.32, 0.72, 0, 1),
    border-radius 280ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* Collapse uses slightly faster timing */
.mall-flip-layer.flip-collapsing {
  transition:
    left 250ms cubic-bezier(0.32, 0.72, 0, 1),
    top 250ms cubic-bezier(0.32, 0.72, 0, 1),
    width 250ms cubic-bezier(0.32, 0.72, 0, 1),
    height 250ms cubic-bezier(0.32, 0.72, 0, 1),
    border-radius 250ms cubic-bezier(0.32, 0.72, 0, 1);
}

/* Reduced-motion: skip animation, instant transition */
@media (prefers-reduced-motion: reduce) {
  .mall-flip-layer {
    transition: none !important;
  }

  .mall-tile-field.transitioning {
    transition: none;
  }
}

/* ========== Loading State ========== */

.mall-tile-field-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ========== Empty State ========== */

.mall-tile-field-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 0.5rem;
  color: var(--text-dim);
  text-align: center;
}

.mall-tile-field-empty-icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* Shared responsive browse: vertical groups, independent horizontal tracks.
   Density presets remain an explicit grid option; rows have no item/row cap. */
.mall-tile-field-wrapper.browse-rows {
  overflow-x: hidden;
  scroll-snap-type: y proximity;
}
.mall-tile-field[data-layout="rows"] {
  display: block;
  min-width: 0;
}
.mall-category-row { position: relative; min-width: 0; margin-bottom: 1.25rem; }
.mall-category-title { margin: 0; padding: .6rem 6rem .6rem .25rem; font-size: 1rem; text-transform: capitalize; }
.mall-category-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(148px, 22vw, 240px);
  gap: .65rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: .25rem;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  padding: .25rem .25rem .75rem;
}
.mall-tile-field[data-layout="rows"] .mall-tile {
  aspect-ratio: 16 / 9;
  min-width: 0;
  border-radius: .6rem;
  scroll-snap-align: start;
}
.mall-tile-field[data-layout="rows"] .mall-tile-name { font-size: .85rem; }
.mall-row-controls { position: absolute; right: .25rem; top: 0; display: flex; gap: .25rem; }
.mall-row-controls button { min-width: 44px; min-height: 44px; border-radius: .5rem; color: inherit; background: #252532; border: 1px solid #555; cursor: pointer; }
.mall-category-track:focus-visible, .mall-row-controls button:focus-visible { outline: 2px solid #b8a4ff; outline-offset: -2px; }
.mall-tile-field[data-layout="rows"].expanded-mode {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: .65rem;
}
.motion-glide .mall-category-track, .is-dragging .mall-category-track { scroll-snap-type: none; }
@media (prefers-reduced-motion: reduce) {
  .mall-tile-field-wrapper, .mall-category-track { scroll-behavior: auto; }
}
