@layer components {
  /* Constrain image to 300px and make frame smaller */
  .polaroid .wrapper > div:first-child {
    max-width: 300px;
  }

  .polaroid .wrapper > div:first-child img {
    width: 300px;
    height: auto;
    max-width: 300px;
    display: block;
  }

  /* Make the frame padding smaller */
  .polaroid .wrapper {
    padding: 0.75rem !important; /* Reduced from p-4 (1rem) */
  }

  .polaroid-picture {
    position: relative;
    display: inline-block;
    transition: transform 0.5s ease-out;
    --rotation: 0deg;
    cursor: pointer !important;
    transform-style: preserve-3d;
    /* Drop shadow on the entire polaroid */
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  }

  .polaroid-picture:hover {
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35)) drop-shadow(0 6px 12px rgba(0, 0, 0, 0.25));
  }

  .polaroid-picture .polaroid {
    transform-style: preserve-3d;
  }

  .polaroid-picture .wrapper {
    transform-style: preserve-3d;
    will-change: transform;
  }

  .polaroid-picture__frame {
    background: #f5f5f0;
    padding: 12px 12px 48px 12px;
    /* Drop shadow */
    box-shadow:
      0 8px 16px rgba(0, 0, 0, 0.2),
      0 4px 8px rgba(0, 0, 0, 0.15),
      0 2px 4px rgba(0, 0, 0, 0.1),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.1);
    position: relative;
    max-width: 100%;
    
    /* Vintage paper texture effect */
    background-image:
      radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
      radial-gradient(circle at 80% 70%, rgba(0, 0, 0, 0.05) 0%, transparent 50%),
      linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    
    /* Ripped/worn edges effect using clip-path with irregular pattern */
    clip-path: polygon(
      0% 1px,
      1px 0%,
      3px 0%,
      5px 1px,
      98% 0%,
      99% 1px,
      100% 3px,
      100% 5px,
      100% 95%,
      99% 97%,
      98% 99%,
      95% 100%,
      5px 100%,
      3px 99%,
      1px 97%,
      0% 95%,
      0% 5px,
      0% 1px
    );
  }

  /* White border with worn edges */
  .polaroid-picture__frame::before {
    content: '';
    position: absolute;
    inset: -2px;
    border: 2px solid white;
    clip-path: polygon(
      0% 2px,
      2px 0%,
      4px 0%,
      6px 2px,
      97% 0%,
      98% 1px,
      99% 3px,
      100% 5px,
      100% 93%,
      98% 95%,
      97% 97%,
      95% 99%,
      5px 99%,
      3px 97%,
      2px 95%,
      0% 93%,
      0% 5px,
      0% 2px
    );
    pointer-events: none;
    z-index: 1;
  }

  /* Additional worn edge texture */
  .polaroid-picture__frame::after {
    content: '';
    position: absolute;
    inset: 0;
    background: 
      /* Irregular edge highlights and shadows for worn effect */
      radial-gradient(ellipse at 0% 0%, rgba(255, 255, 255, 0.4) 0%, transparent 3%),
      radial-gradient(ellipse at 100% 0%, rgba(255, 255, 255, 0.4) 0%, transparent 3%),
      radial-gradient(ellipse at 0% 100%, rgba(0, 0, 0, 0.15) 0%, transparent 3%),
      radial-gradient(ellipse at 100% 100%, rgba(0, 0, 0, 0.15) 0%, transparent 3%),
      linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 0.5%, transparent 1%),
      linear-gradient(0deg, transparent 0%, rgba(255, 255, 255, 0.2) 0.5%, transparent 1%),
      linear-gradient(90deg, transparent 99%, rgba(0, 0, 0, 0.1) 99.5%, transparent 100%),
      linear-gradient(0deg, transparent 99%, rgba(0, 0, 0, 0.1) 99.5%, transparent 100%);
    pointer-events: none;
    z-index: 2;
  }

  .polaroid-picture__image {
    width: 280px;
    height: 280px;
    background: white;
    position: relative;
    overflow: hidden;
    
    /* Large white border all around - at least 20px */
    border: 20px solid white;
    box-sizing: border-box;
    /* Padding to create space for inner div */
    padding: 20px 20px 40px 20px;
  }

  .polaroid-picture__inner {
    width: 100%;
    height: 100%;
    background: #e5e5e5;
    border-style: inset;
    border-width: 2px;
    border-color: rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    /* Additional inset shadow effect */
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 -2px 4px rgba(0, 0, 0, 0.1);
  }

  /* Ensure the image inside respects the border */
  .polaroid-picture__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .polaroid-picture__overlay {
    position: absolute;
    z-index: 10;
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: 0.1em;
    color: #3D2817; /* dark brown */
    text-shadow:
      0 0 8px rgba(255, 255, 255, 0.9),
      0 0 12px rgba(255, 255, 255, 0.7),
      1px 1px 2px rgba(255, 255, 255, 0.8),
      -1px -1px 2px rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    pointer-events: none;
  }

  .polaroid-picture__caption {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    color: #333;
    text-align: center;
    line-height: 1.4;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
  }

  /* Responsive sizing */
  @media (max-width: 640px) {
    .polaroid-picture__image {
      width: 200px;
      height: 200px;
    }

    .polaroid-picture__overlay {
      font-size: 1.5rem;
    }
  }
}

