/* ===== SYD'S PLAYGROUND STYLES ===== */

.playground-page {
  min-height: calc(100vh - 100px);
  padding-bottom: 3rem;
}

.section-intro {
  max-width: 700px;
  margin: 0 auto 1.5rem;
  text-align: left;
  line-height: 1.6;
}

.floating-canvas-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  justify-items: center;
  padding: 1.5rem 0;
  perspective: 1000px;
  max-width: 1100px;
  margin: 0 auto;
}

.floating-canvas {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 4 / 3.5;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 0.875rem;
  cursor: pointer;
  transition: 
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    max-width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  box-shadow:
    8px 8px 18px var(--shadow-dark),
    -8px -8px 18px var(--shadow-light),
    inset 0 1px 2px rgba(255, 255, 255, 0.08);
  animation: float 6s ease-in-out infinite;
  transform-style: preserve-3d;
  z-index: 1;
  /* Touch-friendly minimum size */
  min-height: 220px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.floating-canvas:nth-child(1) { animation-delay: 0s; }
.floating-canvas:nth-child(2) { animation-delay: -1.5s; }
.floating-canvas:nth-child(3) { animation-delay: -3s; }
.floating-canvas:nth-child(4) { animation-delay: -4.5s; }
.floating-canvas:nth-child(5) { animation-delay: -2.2s; }

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotateX(1deg) rotateY(-1deg);
  }
  25% {
    transform: translateY(-8px) rotateX(-0.5deg) rotateY(0.5deg);
  }
  50% {
    transform: translateY(-4px) rotateX(0.5deg) rotateY(1deg);
  }
  75% {
    transform: translateY(-10px) rotateX(-1deg) rotateY(-0.5deg);
  }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .floating-canvas {
    animation: none;
    transition-duration: 0.2s;
  }
}

.floating-canvas:hover {
  box-shadow:
    12px 12px 24px var(--shadow-dark),
    -12px -12px 24px var(--shadow-light),
    inset 0 1px 3px rgba(255, 255, 255, 0.12),
    0 0 20px rgba(159, 133, 255, 0.15);
  animation-play-state: paused;
}

.floating-canvas.expanded {
  max-width: min(640px, calc(100vw - 2rem));
  aspect-ratio: auto;
  height: min(520px, calc(100vh - 180px));
  z-index: 100;
  animation: none;
  transform: translateY(-6px) rotateX(0deg) rotateY(0deg);
  box-shadow:
    16px 16px 32px var(--shadow-dark),
    -16px -16px 32px var(--shadow-light),
    inset 0 1px 4px rgba(255, 255, 255, 0.15),
    0 0 40px rgba(159, 133, 255, 0.2);
}

.canvas-label {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
  background: linear-gradient(
    120deg,
    #000000 0%,
    #333333 20%,
    #818181 40%,
    #989898 60%,
    #d6d6d6 80%,
    #ffffff 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  /* Touch-friendly tap area */
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-holder {
  width: 100%;
  height: calc(100% - 56px);
  min-height: 140px;
  border-radius: 0.75rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-holder canvas {
  display: block;
  border-radius: 0.5rem;
  max-width: 100%;
  max-height: 100%;
  /* Prevent canvas from capturing all touches */
  touch-action: none;
}

.canvas-instructions {
  font-size: 0.7rem;
  text-align: center;
  opacity: 0.5;
  margin-top: 0.375rem;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

/* Glow effect for active sketches */
.floating-canvas.active .canvas-holder {
  box-shadow: inset 0 0 15px rgba(159, 133, 255, 0.2);
}

/* ===== TABLET STYLES (768px - 1024px) ===== */
@media (max-width: 1024px) {
  .floating-canvas-container {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    padding: 1rem 0;
  }
  
  .floating-canvas {
    max-width: 320px;
    padding: 0.75rem;
  }
  
  .floating-canvas.expanded {
    max-width: min(580px, calc(100vw - 1.5rem));
    height: min(460px, calc(100vh - 160px));
  }
}

/* ===== MOBILE STYLES (< 768px) ===== */
@media (max-width: 768px) {
  .playground-page {
    padding-bottom: 2rem;
  }
  
  .section-intro {
    font-size: 0.9rem;
    padding: 0 0.5rem;
    margin-bottom: 1rem;
  }
  
  .floating-canvas-container {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0.75rem 0;
  }
  
  .floating-canvas {
    max-width: 100%;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 200px;
    padding: 0.75rem;
    box-shadow:
      6px 6px 14px var(--shadow-dark),
      -6px -6px 14px var(--shadow-light),
      inset 0 1px 2px rgba(255, 255, 255, 0.08);
    /* Disable float animation on mobile for performance */
    animation: none;
  }
  
  .floating-canvas.expanded {
    max-width: 100%;
    width: 100%;
    height: min(400px, calc(100vh - 140px));
    aspect-ratio: auto;
    box-shadow:
      10px 10px 24px var(--shadow-dark),
      -10px -10px 24px var(--shadow-light),
      inset 0 1px 3px rgba(255, 255, 255, 0.12),
      0 0 30px rgba(159, 133, 255, 0.15);
  }
  
  .canvas-label {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    min-height: 36px;
  }
  
  .canvas-holder {
    height: calc(100% - 52px);
    min-height: 120px;
    border-radius: 0.6rem;
  }
  
  .canvas-instructions {
    font-size: 0.65rem;
    margin-top: 0.3rem;
  }
  
  /* Mobile tap instruction */
  .floating-canvas:not(.expanded) .canvas-instructions::before {
    content: "Tap frame to expand • ";
  }
  
  .floating-canvas.expanded .canvas-instructions::before {
    content: "";
  }
}

/* ===== SMALL MOBILE (< 480px) ===== */
@media (max-width: 480px) {
  .playground-page {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .section-heading {
    font-size: 1.5rem;
  }
  
  .section-intro {
    font-size: 0.85rem;
  }
  
  .floating-canvas {
    aspect-ratio: 1 / 0.9;
    min-height: 180px;
    padding: 0.625rem;
  }
  
  .floating-canvas.expanded {
    height: min(360px, calc(100vh - 120px));
  }
  
  .canvas-label {
    font-size: 0.8rem;
    min-height: 34px;
  }
  
  .canvas-holder {
    height: calc(100% - 48px);
    min-height: 100px;
  }
  
  .canvas-instructions {
    font-size: 0.6rem;
  }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .floating-canvas-container {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
  }
  
  .floating-canvas {
    aspect-ratio: 16 / 10;
    min-height: 150px;
  }
  
  .floating-canvas.expanded {
    height: min(280px, calc(100vh - 80px));
    max-width: min(480px, calc(100vw - 2rem));
  }
  
  .canvas-label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    min-height: 28px;
  }
  
  .canvas-holder {
    height: calc(100% - 40px);
  }
  
  .canvas-instructions {
    display: none;
  }
}

/* Loading state */
.canvas-holder.loading::after {
  content: "Loading...";
  position: absolute;
  color: var(--text);
  opacity: 0.6;
  font-size: 0.85rem;
}

/* Camera permission notice */
.camera-notice {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 0.875rem;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 0.75rem;
  font-size: 0.8rem;
  opacity: 0.95;
  z-index: 10;
  max-width: 90%;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.floating-canvas {
  will-change: transform, box-shadow;
  contain: layout style;
}

.floating-canvas.expanded {
  contain: layout;
}

.canvas-holder {
  contain: strict;
}
