/* =====================================================
   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: var(--radius-lg);
    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.3s ease-out, box-shadow 0.3s ease-out;
}

.glass-card--interactive:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.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 — full-bleed bottom gradient, always visible
   Matches UI kit pattern: name top-left, price+arrow bottom
   ===================================================== */

.glass-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.85) 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 14px;
    z-index: 2;
}

/* =====================================================
   Overlay Rows — top and bottom content
   ===================================================== */

.glass-card__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.glass-card__row--bottom {
    align-items: flex-end;
}

/* =====================================================
   Card Content Styles
   ===================================================== */

.glass-card__title {
    font: 700 18px var(--title-font);
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

/* Price row: "from €X.XX/mo" */
.glass-card__price {
    display: flex;
    align-items: center;
    gap: 0;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.glass-card__price-label {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.75);
    margin-right: 4px;
}

.glass-card__price-value {
    font-family: var(--mono-font);
    font-style: normal;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 14px;
    background: none;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    text-shadow: none;
}

.glass-card__price-period {
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.75);
    margin-left: 0;
}

/* Arrow icon */
.glass-card__arrow {
    color: var(--primary-color);
    display: inline-flex;
}

.glass-card__btn {
    display: none;
}

/* Tag badge (top-right) */
.glass-card__tag {
    background: rgba(var(--primary-color-rgb), 0.2);
    padding: 3px 8px;
    border-radius: 6px;
    font: 600 10px var(--mono-font);
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary-color);
    border: 1px solid rgba(var(--primary-color-rgb), 0.4);
}

/* =====================================================
   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: var(--radius);
    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;
}

/* =====================================================
   Product Card - Store-style two-region layout
   Image on top with caption + dedicated foot strip with price
   ===================================================== */

.glass-card--product {
    display: flex;
    flex-direction: column;
    background: var(--gray-850);
}

/* Image becomes a flex item instead of absolute fill */
.glass-card--product .glass-card__image {
    position: relative;
    inset: auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Pull the <img> out of flow so it doesn't drive the flex item's intrinsic size */
.glass-card--product .glass-card__image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Dark fade at bottom of image blends into the foot strip */
.glass-card--product .glass-card__image::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 70%;
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(var(--gray-850-rgb), 0.35) 45%,
        rgba(var(--gray-850-rgb), 0.85) 80%,
        var(--gray-850) 100%);
}

/* Caption inside image — product name at the bottom of the image */
.glass-card__caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 12px 14px;
    pointer-events: none;
}

.glass-card__caption-title {
    font-family: var(--title-font);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Foot strip — below image, holds price + arrow */
.glass-card__foot {
    position: relative;
    z-index: 4;
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-850);
}

.glass-card__foot-info {
    flex: 1;
    min-width: 0;
}

.glass-card__foot-label {
    display: block;
    font-family: var(--mono-font);
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.glass-card__foot-price {
    margin-top: 4px;
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-family: var(--mono-font);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-heading);
}

.glass-card__foot-value {
    color: var(--text-heading);
}

.glass-card__foot-original {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: rgba(156, 163, 175, 0.6);
}

.glass-card__foot-period {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.glass-card__foot-arrow {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: none;
    color: var(--text-muted);
    transition: color 0.15s ease, transform 0.15s ease;
}

.glass-card--interactive.glass-card--product:hover .glass-card__foot-arrow {
    color: var(--primary-color);
    transform: translateX(2px);
}

/* Discount badge — move to top-right under --product (default is top-left) */
.glass-card--product .glass-card__discount {
    left: auto;
    right: 12px;
}

/* =====================================================
   Static Card - No interactions (for display)
   ===================================================== */

.glass-card--static {
    pointer-events: none;
}

/* =====================================================
   Responsive Styles
   ===================================================== */

@media (max-width: 768px) {
    .glass-card__overlay {
        padding: 10px;
    }
    .glass-card__title {
        font-size: 15px;
    }
    .glass-card__shine {
        display: none;
    }
}
