/* =====================================================
   Glass Cards Component
   Reusable glass morphism card with 3D tilt effects

   Modifiers:
   --interactive    : Enables 3D tilt on hover/click
   --static         : Display only, no interactions
   --nested         : For cards inside other glass cards (inherits parent tilt)

   Size modifiers:
   --poster         : 3:4 aspect ratio (default original)
   --square         : 1:1 aspect ratio
   --banner         : 4:1 aspect ratio
   --wide           : 16:9 aspect ratio
   --portrait       : 2:3 aspect ratio
   --landscape      : 4:3 aspect ratio
   --auto           : Natural content size

   Optional elements:
   __glow           : Color bleed effect behind card. Use with wrapper:
                      <div class="glass-card-wrapper">
                          <div class="glass-card__glow" style="background-image: url('...')"></div>
                          <div class="glass-card ...">...</div>
                      </div>

   Data attributes for --interactive cards:
   data-tilt-max        : Maximum tilt angle in degrees (default: 8)
   data-tilt-perspective: Perspective distance in px (default: 1000)
   data-parallax-amount : Image parallax movement in px (default: 5)
   data-lift-y          : Vertical lift on hover in px (default: 12)
   data-lift-z          : Z-axis lift on hover in px (default: 20)
   ===================================================== */

/* =====================================================
   Base Card
   ===================================================== */

.glass-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Glass border effect */
.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    padding: 1px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.05) 40%,
        transparent 50%,
        transparent 80%,
        rgba(0, 0, 0, 0.2) 100%
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 10;
}

/* Inner highlight for depth */
.glass-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.15),
        inset -1px -1px 0 rgba(0, 0, 0, 0.2);
    pointer-events: none;
    z-index: 10;
}

.glass-card__image {
    position: absolute;
    inset: 0;
    transition: transform 0.15s ease-out;
}

.glass-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =====================================================
   Size Modifiers - Aspect Ratios
   ===================================================== */

/* Default poster size (3:4) - matches original app-card */
.glass-card--poster {
    aspect-ratio: 3 / 4;
}

/* Square (1:1) */
.glass-card--square {
    aspect-ratio: 1 / 1;
}

/* Banner (4:1) */
.glass-card--banner {
    aspect-ratio: 4 / 1;
}

/* Wide banner (16:9) */
.glass-card--wide {
    aspect-ratio: 16 / 9;
}

/* Portrait (2:3) */
.glass-card--portrait {
    aspect-ratio: 2 / 3;
}

/* Landscape (4:3) */
.glass-card--landscape {
    aspect-ratio: 4 / 3;
}

/* Auto - uses natural content size */
.glass-card--auto {
    aspect-ratio: auto;
}

/* =====================================================
   Glow Effect - Image color bleeding behind the card
   Usage: Add .glass-card__glow element with inline background-image
   ===================================================== */

/* Wrapper for glow effect - glow sits outside the card */
.glass-card-wrapper {
    position: relative;
    display: block;
}

.glass-card-wrapper > .glass-card__glow {
    display: none; /* TEMP: disabled for testing */
    position: absolute;
    inset: -20px;
    background-size: cover;
    background-position: center;
    filter: blur(50px) saturate(1.4);
    opacity: 0.5;
    z-index: 0;
    border-radius: 24px;
    transition: opacity 0.4s ease, filter 0.4s ease;
    pointer-events: none;
}

.glass-card-wrapper:hover > .glass-card__glow {
    opacity: 0.6;
    filter: blur(60px) saturate(1.5);
}

.glass-card-wrapper > .glass-card {
    position: relative;
    z-index: 1;
}

/* =====================================================
   Nested Card - Inherits parent tilt, no independent motion
   ===================================================== */

.glass-card--nested {
    /* Nested cards don't have their own transform-style */
    transform-style: flat;
    /* Reduced shadows since parent provides depth */
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.2),
        0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Subtle border enhancement for nested cards */
.glass-card--nested::before {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0.15) 20%,
        rgba(255, 255, 255, 0.03) 40%,
        transparent 50%,
        transparent 80%,
        rgba(0, 0, 0, 0.15) 100%
    );
}

/* Nested cards inside interactive parent follow parent's hover state */
.glass-card--interactive:hover .glass-card--nested::before {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.2) 20%,
        rgba(255, 255, 255, 0.05) 40%,
        transparent 50%,
        transparent 80%,
        rgba(0, 0, 0, 0.2) 100%
    );
}

/* =====================================================
   Interactive Card - With hover/click effects
   ===================================================== */

.glass-card--interactive {
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

.glass-card--interactive:hover {
    box-shadow:
        0 35px 60px rgba(0, 0, 0, 0.4),
        0 25px 40px rgba(0, 0, 0, 0.3),
        0 15px 25px rgba(0, 0, 0, 0.2),
        0 5px 10px rgba(0, 0, 0, 0.15);
}

.glass-card--interactive:hover::before {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.5) 0%,
        rgba(255, 255, 255, 0.25) 20%,
        rgba(255, 255, 255, 0.08) 40%,
        transparent 50%,
        transparent 80%,
        rgba(0, 0, 0, 0.25) 100%
    );
}

.glass-card--interactive:hover::after {
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.25),
        inset -1px -1px 0 rgba(0, 0, 0, 0.25);
}

.glass-card--interactive.is-pressed {
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.2) !important;
}

.glass-card--interactive.is-pressed::before {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0.1) 20%,
        transparent 50%,
        rgba(0, 0, 0, 0.15) 100%
    );
}

.glass-card--interactive.is-pressed::after {
    box-shadow:
        inset 1px 1px 0 rgba(255, 255, 255, 0.08),
        inset -1px -1px 0 rgba(0, 0, 0, 0.15);
}

/* Light shine overlay - positioned by JS */
.glass-card__shine {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: radial-gradient(
        circle at var(--shine-x, 50%) var(--shine-y, 50%),
        rgba(255, 255, 255, 0.12) 0%,
        rgba(255, 255, 255, 0.05) 25%,
        transparent 50%
    );
}

.glass-card--interactive:hover .glass-card__shine {
    opacity: 1;
}

/* =====================================================
   Card Overlay - Glass panel with content
   ===================================================== */

.glass-card__overlay {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 16px 12px;
    z-index: 2;
}

/* Glassmorphism panel */
.glass-card__overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease, backdrop-filter 0.4s ease, -webkit-backdrop-filter 0.4s ease;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-bottom-color: rgba(255, 255, 255, 0.1);
    border-right-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.25),
        0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Dark backing for text readability */
.glass-card__overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: -2;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.glass-card--interactive:hover .glass-card__overlay::before {
    opacity: 1;
    backdrop-filter: blur(20px) saturate(1.5) brightness(1.05);
    -webkit-backdrop-filter: blur(20px) saturate(1.5) brightness(1.05);
}

.glass-card--interactive:hover .glass-card__overlay::after {
    opacity: 1;
}

/* Content animations */
.glass-card__title,
.glass-card__price,
.glass-card__btn {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.glass-card--interactive:hover .glass-card__title {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.05s;
}

.glass-card--interactive:hover .glass-card__price {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.1s;
}

.glass-card--interactive:hover .glass-card__btn {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.15s;
}

/* =====================================================
   Card Content Styles
   ===================================================== */

.glass-card__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 10px 0;
    line-height: 1.2;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.glass-card__price {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 5px 8px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.glass-card__price-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin-right: 5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.glass-card__price-period {
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    margin-left: 5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.glass-card__price-value {
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(var(--primary-color-rgb), 0.8) 100%);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.glass-card__btn {
    display: none;
}

/* =====================================================
   Discount Badge
   ===================================================== */

.glass-card__discount {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 6px 10px;
    border-radius: 8px;
    z-index: 5;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: var(--gap-xs);
}

.glass-card__discount::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 8px #4ade80;
}

/* =====================================================
   Static Card - No interactions (for display)
   ===================================================== */

.glass-card--static {
    pointer-events: none;
}

/* =====================================================
   Responsive Styles
   ===================================================== */

@media (max-width: 768px) {
    .glass-card__overlay {
        left: 6px;
        right: 6px;
        bottom: 6px;
        padding: 10px 8px;
    }
    .glass-card__overlay::before {
        opacity: 1;
        backdrop-filter: blur(16px) saturate(1.5) brightness(1.05);
        -webkit-backdrop-filter: blur(16px) saturate(1.5) brightness(1.05);
        border-radius: 10px;
    }
    .glass-card__overlay::after {
        opacity: 1;
        border-radius: 10px;
    }
    .glass-card__title,
    .glass-card__price,
    .glass-card__btn {
        opacity: 1;
        transform: translateY(0);
        transition-delay: 0s;
    }
    .glass-card__shine {
        display: none;
    }
}
