:root {
  --hue: 27;
  --sat: 69%;
  --white: hsl(0, 0%, 100%);
  --orange-primary: rgba(196, 90, 40, 1); /* #c45a28 */
  --orange-glow: rgba(196, 90, 40, 0.2);
  --orange-border: rgba(196, 90, 40, 0.8);
  --gold-primary: rgba(212, 168, 75, 1); /* #d4a84b */
  --border-color: #392e4e;
  --background-dark: #060010;
  color-scheme: light dark;
}

.card-grid {
  /* Masonry-style columns (column-count set via inline style from JS) */
  padding: 0.5em;
  max-width: 100%;
  width: 100%;
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.5rem);
}

.magic-bento-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 100%;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--background-dark);
  font-weight: 300;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;

  --glow-x: 50%;
  --glow-y: 50%;
  --glow-intensity: 0;
  --glow-radius: 200px;
}

/* Subtle depth layering (no visual gaps) */
.magic-bento-card:nth-child(odd) {
  z-index: 2;
}

.magic-bento-card:nth-child(3n) {
  z-index: 3;
}

.magic-bento-card:nth-child(5n) {
  z-index: 4;
}

.magic-bento-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.magic-bento-card-content {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.magic-bento-image {
  width: 100%;
  height: auto;
  display: block;
}

/* Transparent background for GIFs to preserve their transparency */
.magic-bento-card--transparent {
  background: transparent;
  border-color: transparent;
}

.magic-bento-card--transparent:hover {
  border-color: var(--border-color);
}

.magic-bento-gif {
  /* Ensure GIF transparency is preserved */
  background: transparent;
}

.magic-bento-credit {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent);
  color: var(--white);
  padding: 1em;
  font-size: 0.75em;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.magic-bento-card:hover .magic-bento-credit {
  opacity: 1;
}

.magic-bento-credit a {
  color: var(--gold-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.magic-bento-credit a:hover {
  color: var(--white);
  text-decoration: underline;
}

/* Mobile: Narrower padding */
@media (max-width: 599px) {
  .card-grid {
    width: 96%;
    margin: 0 auto;
    padding: 0.25em;
  }
}

/* Border glow effect */
.magic-bento-card--border-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  padding: 4px;
  background: radial-gradient(
    var(--glow-radius) circle at var(--glow-x) var(--glow-y),
    rgba(212, 168, 75, calc(var(--glow-intensity) * 0.5)) 0%,
    rgba(212, 168, 75, calc(var(--glow-intensity) * 0.25)) 30%,
    transparent 60%
  );
  border-radius: inherit;
  -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;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.magic-bento-card--border-glow:hover::after {
  opacity: 1;
}

.magic-bento-card--border-glow:hover {
  box-shadow:
    0 4px 16px rgba(122, 68, 40, 0.3),
    0 0 20px var(--orange-glow);
}

.particle-container {
  position: relative;
  overflow: hidden;
}

.particle::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: rgba(212, 168, 75, 0.2);
  border-radius: 50%;
  z-index: -1;
}

.particle-container:hover {
  box-shadow:
    0 4px 20px rgba(122, 68, 40, 0.2),
    0 0 30px var(--orange-glow);
}

/* Global spotlight styles */
.global-spotlight {
  mix-blend-mode: screen;
  will-change: transform, opacity;
  z-index: 200 !important;
  pointer-events: none;
}

.bento-section {
  position: relative;
  user-select: none;
}
