/* Wishlist-specific styles: grid and cards per spec */

/* Hide SVG filters so they don't take up space */
.svg-filters {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 259px);
  gap: 6px;
  /* Center the grid to match retro-divider and breadcrumbs alignment */
  justify-content: center;
  padding: 12px 0;
  margin: 0 auto;
  max-width: calc(259px * 4 + 6px * 3);
}

/* Boxed retro title with stacked side lines */
.retro-divider {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  align-items: center;
  /* match the width of a single product row (4 columns + gaps) and center it */
  width: calc(259px * 4 + 6px * 3);
  margin: 0 auto;
  box-sizing: border-box;
  /* Liquid glass effect - physics-based refraction, no background */
  backdrop-filter: url(#physics-based-filter);
  -webkit-backdrop-filter: url(#physics-based-filter);
  border: 1px solid var(--border);
  pointer-events: auto;
  transition: all 0.3s ease;
}

@media (max-width: 640px) {
  .retro-divider {
    top: 10px;
    width: calc(100% - 32px);
    max-width: 100%;
  }

  .retro-divider .divider-title {
    padding: 0 10px;
  }
}

.line-group {
  flex: 1;
  min-height: 10px;
  /* ensures enough room for stacked lines */
  background-image: repeating-linear-gradient(to bottom,
      var(--border) 0px,
      var(--border) 1px,
      transparent 1px,
      transparent 3px);
  background-size: 100% auto;
  background-position: center center;
  /* center the stacked-lines vertically */
  background-repeat: no-repeat;
  box-sizing: border-box;
}

.divider-title {
  position: relative;
  padding: 0 20px;
  /* horizontal padding around text */
  background: var(--card-bg);
  /* break behind text uses card bg */
}

.divider-title span {
  font-size: 15px;
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  font-weight: 400;
  display: inline-block;
  text-align: center;
}

.divider-title {
  z-index: 1;
}

/* Breadcrumbs: small badge-like category filters under the retro title */
.breadcrumbs {
  margin: 10px 0 -9px 0;
  display: flex;
  justify-content: center;
}

.breadcrumbs-inner {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: space-between;
  /* Changed to space-between for left crumbs and right search */
  /* Match the grid width for perfect alignment */
  width: calc(259px * 4 + 6px * 3);
  max-width: calc(259px * 4 + 6px * 3);
  box-sizing: border-box;
}

.crumb {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}

/* Breadcrumb separator */
.crumb:not(:first-child)::before {
  content: "/";
  display: inline-block;
  margin-right: 8px;
  color: var(--text);
  opacity: 0.5;
  font-size: 12px;
}

.crumb.active {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.03), transparent);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02) inset;
}

.crumb:focus {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}

/* New: Search input on the right side of breadcrumbs */
.breadcrumb-search {
  display: flex;
  align-items: center;
  gap: 4px;
}

.breadcrumb-search input {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  width: 120px;
  /* Fixed width for consistency */
  box-sizing: border-box;
}

.breadcrumb-search input::placeholder {
  color: var(--text);
  opacity: 0.6;
}

.breadcrumb-search input:focus {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 1478px) {

  /* Force mobile-style fluid width earlier as requested */
  .retro-divider {
    width: calc(100% - 32px);
    max-width: 100%;
    margin: 0 auto;
  }

  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    width: calc(100% - 32px);
    max-width: 100%;
    padding: 0;
    gap: 12px;
    margin: 0 auto;
  }
}

@media (max-width: 1490px) {

  /* Laptop Rule: Lock to 3 columns (matches Playground/Inventory grid) */
  .retro-divider,
  .breadcrumbs-inner,
  #social-footer {
    width: calc(259px * 3 + 6px * 2) !important;
    max-width: calc(259px * 3 + 6px * 2) !important;
  }

  /* Ensure grids match this on other pages if they use .product-grid */
  .product-grid {
    grid-template-columns: repeat(3, 259px);
    max-width: calc(259px * 3 + 6px * 2);
  }
}

@media (max-width: 1200px) {

  /* Tablet Rule: Lock to 2 columns */
  .retro-divider,
  .breadcrumbs-inner,
  #social-footer {
    width: calc(259px * 2 + 6px * 1) !important;
    max-width: calc(259px * 2 + 6px * 1) !important;
  }

  .product-grid {
    grid-template-columns: repeat(2, 259px);
    width: calc(259px * 2 + 6px * 1);
    max-width: calc(259px * 2 + 6px * 1);
  }
}

@media (max-width: 1024px) {

  /* Mobile Rule: Fluid Width (100% - 32px) for perfect alignment */
  .retro-divider,
  .breadcrumbs-inner,
  #social-footer {
    width: calc(100% - 32px) !important;
    max-width: 100% !important;
  }

  .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .product-grid {
    width: calc(100% - 32px);
    max-width: 100%;
    padding: 0;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    /* Match Playground spacing */
  }

  .product-card {
    width: 100% !important;
  }
}

/* Make text slightly smaller/compact like mobile if needed for alignment */
.crumb {
  font-size: 11px;
  padding: 4px 6px;
}

.breadcrumbs-inner {
  width: calc(100% - 32px);
  max-width: 100%;
  /* Allow wrapping if needed, similar to mobile */
  flex-wrap: wrap;
}

/* Hide search bar on tablet to prevent overlap (User functionality request) */
.breadcrumb-search {
  display: none;
}

/* Make text slightly smaller/compact like mobile if needed for alignment */
.crumb {
  font-size: 11px;
  padding: 4px 6px;
}

@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    width: calc(100% - 32px);
    max-width: calc(100% - 32px);
    padding: 0;
    gap: 12px;
    margin: 0 auto;
  }

  .retro-divider {
    width: calc(100% - 32px);
    margin: 0 auto;
  }

  .breadcrumbs-inner {
    width: calc(100% - 32px);
  }

  .breadcrumb-search {
    display: none;
  }
}

@media (max-width: 640px) {
  .product-grid {
    grid-template-columns: 1fr;
    width: calc(100% - 32px);
    padding: 0;
    gap: 12px;
    margin: 0 auto;
  }

  .retro-divider {
    width: calc(100% - 32px);
    margin: 0 auto;
  }

  .breadcrumbs-inner {
    width: calc(100% - 32px);
    gap: 6px;
    flex-wrap: wrap;
  }

  .crumb {
    padding: 4px 7px;
    font-size: 11px;
  }

  .crumb:not(:first-child)::before {
    margin-right: 6px;
    font-size: 11px;
  }

  .product-card {
    width: 100%;
    max-width: 100%;
  }

  .product-card .product-info {
    padding: 8px;
  }

  .brand-name {
    font-size: 8px;
  }

  .product-name {
    font-size: 11px;
  }

  .price {
    font-size: 11px;
  }
}

.product-card {
  width: 259px;
  max-width: 100%;
  /* Allow card to shrink on smaller screens */
  height: auto;
  /* allow card height to adapt to media area */
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  text-decoration: none;
  color: inherit;
  position: relative;
  /* needed for hover-light pseudo-element */
  /* subtle animation: elevate slightly on hover/focus */
  /* subtle hover: tiny upward movement + soft shadow (middle ground) */
  transition: transform 120ms cubic-bezier(.2, .8, .2, 1), box-shadow 120ms ease, opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1), translate 0.8s cubic-bezier(0.19, 1, 0.22, 1);
  will-change: transform, box-shadow, opacity, translate;
  /* Prevent long-press from triggering browser context menu / image selection */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  user-select: none;
  /* Smooth text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  /* Initial state for animation */
  opacity: 0;
  translate: 0 40px;
}

/* Animated state when card loads */
.product-card.loaded {
  opacity: 1;
  translate: 0 0;
}

/* Edge-style cursor-tracking border glow: edges glow based on cursor proximity anywhere on page.
   The radial gradient is positioned at the cursor's location relative to each card.
   Uses a pseudo-element overlay with pointer-events: none. */
.product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  /* thickness of the glow border */
  background: radial-gradient(400px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      var(--card-glow, rgba(255, 255, 255, 0.5)),
      transparent 40%);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  opacity: 1;
  /* Always visible, fades based on cursor distance */
  transition: none;
  /* Smooth real-time tracking without transition delay */
}

/* Theme-specific glow colors */
:root {
  /* light theme: darker glow for more visibility on light backgrounds */
  --card-glow: rgba(0, 0, 0, 0.416);
}

:root[data-theme="dark"] {
  /* dark theme: brighter/lighter white glow for more visibility on dark background */
  --card-glow: rgba(255, 255, 255, 0.299);
}

.product-card .product-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  /* predictable square media area */
  padding: 8px;
  /* breathing room so contained images don't touch edges */
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.product-card .product-media img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  /* preserve aspect ratio, don't crop */
  object-position: center;
}

.product-card .product-info {
  min-height: 26px;
  padding: 6px;
  /* slight increase for breathing room */
  display: flex;
  align-items: stretch;
  /* allow left column to fill available height */
  justify-content: space-between;
  box-sizing: border-box;
  overflow: hidden;
}

/* Hover / focus styles: tiny lift + gentle shadow. Include focus-visible for keyboard users. */
.product-card:hover,
.product-card:focus-within,
.product-card:focus-visible {
  /* tiny lift + very soft shadow — a middle ground between none and a stronger lift */
  transform: translateY(-1.5px);
  box-shadow: 0 5px 12px rgba(2, 6, 23, 0.035);
}

/* Slightly different shadow in dark mode so the lift is visible but not harsh */
:root[data-theme="dark"] .product-card:hover,
:root[data-theme="dark"] .product-card:focus-within,
:root[data-theme="dark"] .product-card:focus-visible {
  box-shadow: 0 5px 12px rgba(255, 255, 255, 0.02);
}

/* Ensure keyboard users see a visible focus outline */
.product-card:focus-visible {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .product-card {
    transition: none !important;
  }

  .product-card:hover,
  .product-card:focus-within,
  .product-card:focus-visible {
    transform: none !important;
    box-shadow: none !important;
  }

  /* disable cursor-tracking glow for reduced-motion users */
  .product-card::before {
    opacity: 0 !important;
  }
}

.info-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* allows children to ellipsis */
  height: 100%;
  justify-content: flex-start;
  gap: 1px;
}

.brand-name {
  font-size: 7px;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
  padding-top: 2px;
}

.product-name {
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.info-right {
  margin-left: 8px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  align-self: center;
  /* keep right-side content vertically centered */
}

/* price styling is defined below */
.badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  font-size: 9px;
  border-radius: 2px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1;
}

/* status-text: use badge-like appearance but inline (for product detail) */
.status-text {
  color: var(--text);
  font-size: 10px;
  font-weight: 400;
  display: inline-block;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  line-height: 1;
}

.card-wrap {
  position: relative;
}

.status-want {
  border-color: var(--border);
}

.status-own {
  border-color: var(--border);
}

/* Product detail overrides */
.product-article {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
  margin-top: 12px;
}

.product-article h1 {
  margin: 0 0 8px 0;
}

.product-media img {
  width: 100%;
  height: auto;
}

.meta {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status.own {
  color: var(--text);
}

/* Uniform price styling: small, normal weight, same color everywhere */
.price {
  font-size: 10px;
  font-weight: 400;
  color: var(--text);
}

/* Mobile responsive overrides for cards */
@media (max-width: 768px) {
  .product-card {
    width: 100%;
    /* Full width of grid cell */
  }
}

@media (max-width: 800px) {
  .product-article {
    grid-template-columns: 1fr;
  }
}

/* --- Expand Button & Trump Card Styles --- */

/* Expand Button */
.card-expand-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 2px;
  /* Square to match page style */
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-5px);
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 10;
  padding: 0;
  /* No box-shadow */
}

.card-expand-btn::after {
  content: "⤢";
  /* Unicode expand arrows */
  font-size: 16px;
  line-height: 1;
}

.product-card:hover .card-expand-btn,
.product-card:focus-within .card-expand-btn {
  opacity: 1;
  transform: translateY(0);
}

/* Hide expand button on smaller screens - use long-press instead */
@media (max-width: 768px) {
  .card-expand-btn {
    display: none;
  }
}

/* Trump Card Overlay */
.trump-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.05);
  /* Slight tint only, no blur, so card refracts content */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.trump-overlay.active {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Container for position-based animation */
.trump-card-container {
  width: 320px;
  max-width: 90vw;
  position: relative;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  /* Initial transform set by JS based on origin card position */
}

/* Glass Lens - The refraction layer (like glassui.html #glass-lens) */
.glass-lens {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
  /* Filter applied via JS: backdrop-filter: url(#physics-based-filter) */
}

/* Glass lens built into each grid card (OFF by default) */
.card-glass-lens {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  /* backdrop-filter applied via JS when expanded */
}

/* Placeholder to maintain grid layout when card is expanded */
.card-placeholder {
  visibility: hidden;
}

/* Expanded card state - glass effect applied to card itself */
.product-card.card-expanded {
  border-radius: 2px;
  backdrop-filter: url(#physics-based-filter);
  -webkit-backdrop-filter: url(#physics-based-filter);
  background: transparent;
}

.product-card.card-expanded .product-media,
.product-card.card-expanded .product-info {
  background: transparent;
}

/* Also make the border on the media transparent to not block refraction */
.product-card.card-expanded .product-media {
  border-bottom-color: rgba(255, 255, 255, 0.2);
  /* Fill most of the card height */
  flex: 1;
  aspect-ratio: unset;
  padding: 24px;
}

/* Scale the image to fill the expanded media area */
.product-card.card-expanded .product-media img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

/* Larger info section for expanded card */
.product-card.card-expanded .product-info {
  padding: 12px 16px;
  min-height: 50px;
  flex-shrink: 0;
}

.product-card.card-expanded .brand-name {
  font-size: 9px;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

.product-card.card-expanded .product-name {
  font-size: 13px;
  font-weight: 500;
  white-space: normal;
  line-height: 1.3;
}

.product-card.card-expanded .price {
  font-size: 13px;
  font-weight: 400;
}

/* Trump Card Content - Sits on top of glass lens */
.trump-card-content {
  position: relative;
  z-index: 2;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  background: transparent;
  /* Let glass lens show through */
}

/* Glass Card Styles (Kept for product detail pages) */
.glass-card {
  width: 320px;
  /* Slightly larger than grid cards */
  max-width: 90vw;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.01);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border-radius: 20px;
  /* Match value from glassui.js logic */
}

/* Dark mode adjustments for glass card */
:root[data-theme="dark"] .glass-card {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.glass-card .product-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  /* Subtle inner bg */
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-card .product-media img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.glass-card .product-info {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  min-height: 50px;
}

.glass-card .info-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.glass-card .brand-name {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text);
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.glass-card .product-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.glass-card .info-right .price {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* Trump Card Content Inner Styles */
.trump-card-content .product-media {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 16px;
  background: transparent;
  /* No BG - glass lens shows through */
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  /* Separator line matching inventory cards */
}

.trump-card-content .product-media img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.trump-card-content .product-info {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  /* No BG - glass lens shows through */
  min-height: 50px;
}

.trump-card-content .info-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.trump-card-content .brand-name {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text);
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.trump-card-content .product-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.trump-card-content .info-right .price {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* Glass Border Glow (Specific for Trump Card) */
.glass-card::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  background: radial-gradient(300px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
      rgba(255, 255, 255, 0.4),
      transparent 40%);
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}