/**
 * Gallery 3D Card Flipper - Part 1 client-facing carousel
 * Palette: --bg #0D0F12, --accent #00C4FF, --text #fff, --text-muted #6b7280, --border #1f2329
 */

/* Global overflow fix (unconditional) - prevents carousel bleeding on mobile */
html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

.gallery-3d-carousel {
    --g3d-bg: #0D0F12;
    --g3d-bg2: #13161a;
    --g3d-bg3: #1a1e24;
    --g3d-accent: #00C4FF;
    --g3d-text: #FFFFFF;
    --g3d-text-muted: #6b7280;
    --g3d-border: #1f2329;
    font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
    position: relative;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 0 2.5rem;
}

.gallery-3d-scene {
    position: relative;
    width: 100%;
}

.gallery-3d-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    max-width: 540px;
    margin: 0 auto;
}
/* Arrow buttons: 42px desktop, 36px mobile */
.gallery-3d-arrow {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0.5px solid var(--g3d-border);
    border-radius: 50%;
    background: #1a1a1a;
    color: #aaa;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.gallery-3d-arrow:hover:not(:disabled) {
    background: #2a2a2a;
    color: #fff;
}
.gallery-3d-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Card slot: centered, max 420px desktop */
.gallery-3d-card-slot {
    flex: 1;
    min-width: 0;
    max-width: 420px;
    display: flex;
    justify-content: center;
}
/* Card wrapper */
.gallery-3d-card {
    width: 100%;
    height: 460px;
    border-radius: 20px;
    background: #111318;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.gallery-3d-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}
.gallery-3d-card.flipped .gallery-3d-card-inner {
    transform: rotateY(180deg);
}

.gallery-3d-front,
.gallery-3d-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 20px;
    overflow: hidden;
}
.gallery-3d-back {
    transform: rotateY(180deg);
}

/* Front: image area 210px */
.gallery-3d-img-area {
    height: 210px;
    background: #1a1a22;
    position: relative;
    overflow: hidden;
}
.gallery-3d-img-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-3d-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-3d-placeholder-icon {
    font-size: 3rem;
    opacity: 0.5;
}
.gallery-3d-style-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    background: var(--g3d-accent);
    color: #003d50;
    font-size: 11px;
    font-weight: 500;
    border-radius: 20px;
}

/* Front: body */
.gallery-3d-body {
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gallery-3d-artist-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.gallery-3d-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--g3d-accent);
    color: #003d50;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.gallery-3d-avatar-initials {
    font-size: 13px;
    font-weight: 600;
}
.gallery-3d-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-3d-artist-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gallery-3d-artist-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--g3d-text);
}
.gallery-3d-artist-label {
    font-size: 11px;
    color: #777;
}
.gallery-3d-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--g3d-text);
    margin: 0;
    line-height: 1.3;
}
.gallery-3d-desc {
    font-size: 13px;
    color: #888;
    line-height: 1.6;
    margin: 0;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.gallery-3d-flip-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #555;
    margin-top: auto;
}
.gallery-3d-flip-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* Back face */
.gallery-3d-back-inner {
    padding: 24px 22px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: space-between;
}
.gallery-3d-back-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gallery-3d-back-label {
    font-size: 11px;
    color: var(--g3d-accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.gallery-3d-back-title {
    font-size: 19px;
    font-weight: 500;
    color: var(--g3d-text);
    margin: 0;
}
.gallery-3d-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.gallery-3d-grid-cell {
    background: #1a1a1a;
    border: 0.5px solid #2a2a2a;
    border-radius: 10px;
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gallery-3d-cell-label {
    font-size: 11px;
    color: #666;
}
.gallery-3d-cell-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--g3d-text);
}
.gallery-3d-avail {
    background: #0d2e1f;
    border: 0.5px solid #1a5c3a;
    border-radius: 10px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--g3d-accent);
}
.gallery-3d-avail-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--g3d-accent);
    flex-shrink: 0;
}
.gallery-3d-avail-text {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
}
.gallery-3d-back-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
}
.gallery-3d-back-btn {
    padding: 0 1rem;
    height: 46px;
    border-radius: 12px;
    border: 0.5px solid #333;
    background: transparent;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.gallery-3d-back-btn:hover {
    border-color: #555;
    color: #ccc;
}
.gallery-3d-book-btn {
    flex: 1;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--g3d-accent);
    color: #003d50;
    border-radius: 12px;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.2s;
}
.gallery-3d-book-btn:hover {
    background: #00b0e6;
}

/* Counter: DM Mono */
.gallery-3d-counter {
    font-family: 'DM Mono', 'Consolas', monospace;
    font-size: 13px;
    color: var(--g3d-text-muted);
    text-align: center;
    margin-top: 12px;
}

/* ===== MOBILE FIXES (max-width: 768px) — do not touch desktop (≥769px) ===== */
@media (max-width: 768px) {
    /* 0. SECTION WRAPPER - prevents horizontal bleed, force full-width chain */
    #portfolio-gallery-section,
    #portfolio-gallery-section .section-container,
    #portfolio-gallery-section .cards-wrapper,
    #cubeGalleryWrap,
    #distortedGalleryContainer,
    .distorted-gallery-container {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box !important;
    }
    /* Section-container: stretch so cards-wrapper takes full width (override align-items: center) */
    #portfolio-gallery-section .section-container {
        align-items: stretch !important;
    }
    /* Force carousel container to full width */
    #portfolio-gallery-section .cards-wrapper {
        align-items: stretch !important;
        width: 100% !important;
    }

    /* 1. CARD SIZE & CENTERING */
    .gallery-3d-scene,
    .gallery-3d-carousel [class*="scene"] {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
    }
    .gallery-3d-scene {
        min-height: clamp(440px, 100vw, 560px) !important;
        height: clamp(440px, 100vw, 560px) !important;
    }
    .gallery-3d-row {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        align-items: center !important;
        gap: clamp(6px, 2vw, 10px) !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    .gallery-3d-card-slot {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow: hidden !important;
        display: flex !important;
        justify-content: center !important;
    }
    .gallery-3d-card {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: clamp(420px, 95vw, 540px);
    }

    /* 2. CARD FRONT FACE — stack vertically */
    .gallery-3d-front {
        flex-direction: column !important;
        height: auto !important;
        min-height: clamp(420px, 90vw, 500px);
        display: flex !important;
    }
    .gallery-3d-img-area {
        width: 100% !important;
        height: clamp(160px, 38vw, 210px) !important;
        flex-shrink: 0;
        overflow: hidden !important;
    }
    .gallery-3d-img-area img {
        width: 100% !important;
        height: 100% !important;
        min-width: 0 !important;
        object-fit: cover !important;
        display: block !important;
    }
    /* Style badge: top-left on mobile to prevent clipping */
    .gallery-3d-style-badge {
        right: auto !important;
        left: 12px !important;
        max-width: calc(100% - 24px) !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    /* Title & description overflow */
    .gallery-3d-title {
        font-size: clamp(17px, 5vw, 22px) !important;
        white-space: normal !important;
        word-break: break-word !important;
        overflow: hidden !important;
    }
    .gallery-3d-desc {
        font-size: clamp(12px, 3vw, 14px) !important;
        white-space: normal !important;
        word-break: break-word !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    .gallery-3d-body {
        width: 100% !important;
        padding: clamp(14px, 4vw, 20px) !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    /* 3. CARD BACK FACE — single column, NO split */
    .gallery-3d-back .gallery-3d-back-image,
    .gallery-3d-back-img-col,
    .gallery-3d-back-left,
    .gallery-3d-back [class*="back"][class*="image"],
    .gallery-3d-back [class*="back"][class*="img"],
    .gallery-3d-back [class*="back"][class*="left"] {
        display: none !important;
    }
    .gallery-3d-back {
        flex-direction: column !important;
        height: auto !important;
        min-height: clamp(420px, 90vw, 520px);
        min-width: 0 !important;
        width: 100% !important;
        padding: clamp(16px, 4vw, 24px) clamp(14px, 4vw, 20px) !important;
        gap: clamp(10px, 3vw, 14px) !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        display: flex !important;
    }
    .gallery-3d-back-inner {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        flex: 1 !important;
        padding: 0 !important;
        gap: clamp(10px, 3vw, 14px) !important;
    }
    /* Hide any back image/left column if present (single-column back only) */
    .gallery-3d-back .back-image,
    .gallery-3d-back .back-img-col,
    .gallery-3d-back .back-left,
    .gallery-3d-back [class*="back"][class*="image"],
    .gallery-3d-back [class*="back"][class*="img"],
    .gallery-3d-back [class*="back"][class*="left"] {
        display: none !important;
    }
    .gallery-3d-back .back-details,
    .gallery-3d-back .back-right,
    .gallery-3d-back .back-info,
    .gallery-3d-back .back-content,
    .gallery-3d-back [class*="back"][class*="detail"],
    .gallery-3d-back [class*="back"][class*="right"],
    .gallery-3d-back [class*="back"][class*="info"] {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 !important;
        padding: 0 !important;
    }

    /* 5. DETAIL CHIPS GRID */
    .gallery-3d-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: clamp(7px, 2vw, 10px) !important;
        width: 100% !important;
    }
    .gallery-3d-grid-cell {
        padding: clamp(9px, 2.5vw, 12px) clamp(10px, 3vw, 13px) !important;
    }

    /* 6. BACK FACE HEADER */
    .gallery-3d-back-label {
        font-size: clamp(10px, 2.5vw, 11px) !important;
    }
    .gallery-3d-back-title {
        font-size: clamp(16px, 4.5vw, 20px) !important;
        line-height: 1.2 !important;
    }

    /* 7. AVAILABILITY BAR */
    .gallery-3d-avail {
        width: 100% !important;
        flex-shrink: 0 !important;
        padding: clamp(9px, 2.5vw, 12px) 14px !important;
        font-size: clamp(11px, 2.8vw, 13px) !important;
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    /* 8. BUTTON ROW */
    .gallery-3d-back-actions {
        flex-direction: row !important;
        gap: 9px !important;
        width: 100% !important;
        margin-top: auto !important;
    }
    .gallery-3d-back-btn {
        height: clamp(42px, 10vw, 48px) !important;
        font-size: clamp(12px, 3vw, 14px) !important;
        padding: 0 clamp(12px, 3vw, 16px) !important;
        flex-shrink: 0 !important;
    }
    .gallery-3d-book-btn {
        height: clamp(42px, 10vw, 48px) !important;
        font-size: clamp(12px, 3vw, 14px) !important;
        flex: 1 !important;
    }

    /* 9. ARROW BUTTONS */
    .gallery-3d-arrow {
        width: clamp(32px, 8vw, 38px) !important;
        height: clamp(32px, 8vw, 38px) !important;
        min-width: clamp(32px, 8vw, 38px) !important;
        min-height: clamp(32px, 8vw, 38px) !important;
        flex-shrink: 0 !important;
    }

    /* 10. COUNTER & SWIPE HINT */
    .gallery-3d-counter {
        font-size: clamp(12px, 3vw, 13px) !important;
        margin-top: 10px !important;
        text-align: center !important;
        color: #3a3f48 !important;
    }
    .gallery-3d-swipe-hint {
        font-size: 11px;
        color: #252a30;
        text-align: center;
        margin-top: 5px;
    }

    /* 11. PAGE-LEVEL CENTERING - carousel must stay in viewport */
    .gallery-3d-carousel {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important; /* stretch so scene takes full width; center was shrinking it */
        padding-left: clamp(12px, 4vw, 20px) !important;
        padding-right: clamp(12px, 4vw, 20px) !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    .gallery-3d-scene {
        max-width: 100% !important;
    }
}

@media (max-width: 380px) {
    .gallery-3d-scene {
        height: clamp(400px, 105vw, 460px) !important;
        min-height: clamp(400px, 105vw, 460px) !important;
    }
    .gallery-3d-back {
        padding: 12px !important;
    }
    .gallery-3d-grid {
        gap: 6px !important;
    }
    .gallery-3d-back-title {
        font-size: clamp(15px, 5vw, 18px) !important;
    }
}

/* Hide swipe hint on desktop */
@media (min-width: 767px) {
    .gallery-3d-swipe-hint {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-3d-card-inner {
        transition: none;
    }
}

@media (max-width: 766px) {

  /* ── SECTION & WRAPPER ── */
  #portfolio-gallery-section,
  #portfolio-gallery-section .section-container,
  #portfolio-gallery-section .cards-wrapper,
  #distortedGalleryContainer,
  .gallery-3d-carousel,
  .gallery-3d-scene,
  .gallery-3d-row {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
  }

  /* ── CAROUSEL ROW: arrow + card + arrow (actual gallery-3d classes) ── */
  .gallery-3d-row,
  .distorted-gallery-carousel,
  .gallery-carousel-row,
  .carousel-row,
  [class*="carousel-row"] {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    gap: clamp(6px, 2vw, 10px) !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    transform: none !important;
    left: 0 !important;
    position: relative !important;
  }

  /* Carousel container: full width, symmetric padding */
  .gallery-3d-carousel {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: clamp(12px, 4vw, 20px) !important;
    padding-right: clamp(12px, 4vw, 20px) !important;
    box-sizing: border-box !important;
  }

  /* Card slot: flex to take remaining space, center the card */
  .gallery-3d-card-slot {
    flex: 1 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    overflow: hidden !important;
  }

  /* ── ARROW BUTTONS ── */
  .gallery-3d-arrow,
  .distorted-gallery-carousel .carousel-arrow,
  .gallery-carousel-row .carousel-arrow,
  .carousel-arrow,
  [class*="carousel-arrow"],
  [class*="gallery-arrow"],
  .artist-nav-btn,
  [class*="nav-arrow"] {
    width: clamp(32px, 8vw, 40px) !important;
    height: clamp(32px, 8vw, 40px) !important;
    min-width: clamp(32px, 8vw, 40px) !important;
    flex-shrink: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
  }

  /* ── SCENE (perspective wrapper) ── */
  .gallery-3d-scene,
  .gallery-card-scene,
  .card-scene,
  .distorted-gallery-scene,
  [class*="card-scene"],
  [class*="gallery-scene"],
  [class*="-scene"] {
    flex: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: clamp(460px, 125vw, 560px) !important;
    overflow: hidden !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
  }

  /* ── 3D CARD ── */
  .gallery-3d-card,
  .gallery-card-3d,
  .card-3d,
  [class*="card-3d"],
  [class*="card3d"],
  [class*="gallery-card"] {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
    transform-origin: center center !important;
  }

  /* Flipped state — preserve the rotateY only */
  .gallery-card-3d.flipped,
  .card-3d.flipped {
    transform: rotateY(180deg) !important;
  }

  /* ── BOTH FACES ── */
  .gallery-card-face,
  .card-face,
  [class*="card-face"],
  [class*="gallery-face"],
  .face {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: clamp(12px, 3vw, 18px) !important;
    overflow: hidden !important;
    left: 0 !important;
    right: 0 !important;
    box-sizing: border-box !important;
  }

  /* ── FRONT FACE: vertical stack ── */
  .gallery-card-face.front,
  .card-face.front,
  .face.front,
  [class*="card-front"] {
    flex-direction: column !important;
  }

  /* ── FRONT IMAGE AREA ── */
  .gallery-card-face.front .card-image-area,
  .face.front .img-area,
  .face.front [class*="img-area"],
  .face.front [class*="image-area"],
  [class*="card-image"] {
    width: 100% !important;
    height: clamp(185px, 48vw, 240px) !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    border-radius: 0 !important;
  }

  .gallery-card-face.front .card-image-area img,
  .face.front [class*="img-area"] img,
  .face.front [class*="image-area"] img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
  }

  /* ── FRONT BODY ── */
  .gallery-card-face.front .card-body,
  .face.front .front-body,
  .face.front [class*="card-body"],
  [class*="card-front-body"] {
    width: 100% !important;
    padding: clamp(13px, 4vw, 18px) !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    flex: 1 !important;
  }

  /* ── CARD TITLE: no overflow ── */
  [class*="card-title"],
  [class*="artwork-title"],
  .gallery-card-title {
    font-size: clamp(16px, 4.5vw, 20px) !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: hidden !important;
  }

  /* ── CARD DESCRIPTION ── */
  [class*="card-desc"],
  [class*="card-description"],
  .gallery-card-desc {
    font-size: clamp(12px, 3vw, 13px) !important;
    white-space: normal !important;
    word-break: break-word !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
  }

  /* ── BACK FACE: single full-width column ── */
  .gallery-card-face.back,
  .card-face.back,
  .face.back,
  [class*="card-back"] {
    flex-direction: column !important;
    padding: clamp(15px, 4vw, 22px) clamp(13px, 4vw, 18px) !important;
    gap: clamp(9px, 2.5vw, 13px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }

  /* Hide any image panel on back face */
  .face.back [class*="back-img"],
  .face.back [class*="back-image"],
  .face.back [class*="back-left"],
  .face.back [class*="img-col"],
  [class*="card-back-image"] {
    display: none !important;
  }

  /* Back details full width */
  .face.back [class*="back-detail"],
  .face.back [class*="back-info"],
  .face.back [class*="back-right"],
  .face.back [class*="back-content"],
  [class*="card-back-details"] {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  /* ── DETAIL CHIPS GRID ── */
  [class*="detail-grid"],
  [class*="det-grid"],
  [class*="details-grid"],
  .card-details-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: clamp(6px, 2vw, 9px) !important;
    width: 100% !important;
  }

  /* ── AVAILABILITY BAR ── */
  .gallery-3d-avail,
  [class*="avail"],
  [class*="availability"],
  .card-availability {
    width: 100% !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    font-size: clamp(11px, 2.8vw, 13px) !important;
  }

  .gallery-3d-avail-dot {
    flex-shrink: 0 !important;
  }

  /* ── BUTTON ROW ── */
  [class*="btn-row"],
  [class*="button-row"],
  .card-btn-row {
    flex-direction: row !important;
    gap: 8px !important;
    width: 100% !important;
    margin-top: auto !important;
    box-sizing: border-box !important;
  }

  [class*="btn-back"],
  .card-back-btn {
    height: clamp(40px, 10vw, 46px) !important;
    font-size: clamp(12px, 3vw, 13px) !important;
    padding: 0 clamp(10px, 3vw, 14px) !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
  }

  [class*="btn-book"],
  .card-book-btn {
    height: clamp(40px, 10vw, 46px) !important;
    font-size: clamp(12px, 3vw, 13px) !important;
    flex: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* ── COUNTER ── */
  [class*="carousel-counter"],
  [class*="card-counter"],
  .gallery-counter {
    width: 100% !important;
    text-align: center !important;
    margin-top: 10px !important;
  }

  /* ── STYLE BADGE: prevent right-edge clip ── */
  [class*="style-badge"],
  [class*="category-badge"],
  .card-style-badge {
    max-width: calc(100% - 16px) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

}

/* ── EXTRA SMALL: 360px and below ── */
@media (max-width: 380px) {

  .gallery-card-scene,
  [class*="card-scene"],
  [class*="-scene"] {
    height: clamp(420px, 135vw, 480px) !important;
  }

  .gallery-card-face.front .card-image-area,
  .face.front [class*="img-area"] {
    height: clamp(165px, 44vw, 200px) !important;
  }

  .gallery-card-face.back,
  .face.back,
  [class*="card-back"] {
    padding: 12px !important;
    gap: 8px !important;
  }

  [class*="detail-grid"],
  [class*="det-grid"] {
    gap: 6px !important;
  }

  .carousel-arrow,
  [class*="carousel-arrow"],
  .artist-nav-btn {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
  }

}

/* ============================================
   CUBE GALLERY ROTATOR (Portfolio section)
   ============================================ */
.cube-gallery-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.5vw, 18px) !important;
  width: 100%;
  padding: clamp(16px, 3vw, 32px) clamp(8px, 2vw, 16px) !important;
  overscroll-behavior: auto;
  overscroll-behavior-y: auto;
}

.cube-gallery-wrap.hidden {
  display: none !important;
}

.cube-gallery-stage {
  width: clamp(240px, 65vw, 360px);
  height: clamp(240px, 65vw, 360px);
  perspective: clamp(600px, 120vw, 900px) !important;
  transform-style: flat !important;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  flex-shrink: 0;
  touch-action: pan-y;
}

.cube-gallery-stage:active {
  cursor: grabbing;
}

.cube-gallery-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d !important;
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.cube-gallery-face {
  position: absolute !important;
  overflow: hidden !important;
  width: clamp(240px, 65vw, 360px);
  height: clamp(240px, 65vw, 360px);
  border-radius: clamp(12px, 3vw, 18px) !important;
  border: 0.5px solid #1f2329;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.cube-gallery-face img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: center top !important;
  display: block !important;
  z-index: 1 !important;
}

.cube-gallery-face-grad {
  position: absolute !important;
  inset: 0 !important;
  z-index: 5 !important;
  pointer-events: none !important;
  background: linear-gradient(
    to top,
    rgba(13,15,18,0.92) 0%,
    rgba(13,15,18,0.1) 50%,
    transparent 75%
  ) !important;
}

.cube-gallery-face-label {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
  z-index: 20 !important;
  overflow: visible !important;
  padding: 0 !important;
  margin: 0 !important;
  background: none !important;
}

.cube-gallery-face-tag {
  position: absolute !important;
  top: clamp(10px, 3%, 16px) !important;
  left: clamp(10px, 3%, 16px) !important;
  z-index: 99 !important;
  display: inline-flex !important;
  align-items: center !important;
  width: auto !important;
  max-width: calc(100% - 32px) !important;
  height: auto !important;
  font-size: clamp(9px, 2.2vw, 11px) !important;
  font-weight: 700 !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
  letter-spacing: 0.04em !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
  pointer-events: none !important;
  line-height: 1.4 !important;
  isolation: isolate !important;
}

/* Hard override for any framework conflicts */
#distortedGalleryContainer .cube-gallery-face-tag,
#cubeGalleryWrap .cube-gallery-face-tag,
.cube-gallery-face .cube-gallery-face-tag {
  position: absolute !important;
  top: clamp(10px, 3%, 16px) !important;
  left: clamp(10px, 3%, 16px) !important;
  z-index: 99 !important;
  display: inline-block !important;
  width: auto !important;
  max-width: calc(100% - 24px) !important;
  padding: 4px 12px !important;
  border-radius: 20px !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  white-space: nowrap !important;
  pointer-events: none !important;
  line-height: 1.4 !important;
}

#distortedGalleryContainer .cube-gallery-face-tag {
  width: auto !important;
  min-width: 0 !important;
  max-width: fit-content !important;
}

.cube-gallery-face-title {
  font-size: clamp(13px, 3.2vw, 16px) !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  line-height: 1.25 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  width: 100% !important;
  margin-top: 4px !important;
}

.cube-gallery-detail {
  background: #13161a;
  border: 0.5px solid #1f2329;
  border-radius: clamp(12px, 3vw, 16px);
  padding: 14px 16px 16px !important;
  width: 100%;
  max-width: clamp(300px, 90vw, 480px);
  display: flex;
  flex-direction: column;
  gap: 10px !important;
  transition: opacity 0.2s, transform 0.2s;
}

.cube-gallery-detail.transitioning {
  opacity: 0;
  transform: translateY(4px);
}

.cgd-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
}

.cgd-name {
  font-size: clamp(15px, 3.5vw, 19px) !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  line-height: 1.2 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.cgd-role {
  font-size: clamp(11px, 2.5vw, 12px) !important;
  color: #6b7280 !important;
  margin-top: 2px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.cgd-tag {
  font-size: clamp(9px, 2vw, 10px) !important;
  font-weight: 700 !important;
  padding: 3px 10px !important;
  border-radius: 20px !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  align-self: center !important;
  line-height: 1.4 !important;
  display: inline-block !important;
  width: auto !important;
  max-width: fit-content !important;
}

.cgd-desc {
  font-size: clamp(12px, 2.8vw, 13px) !important;
  color: #6b7280 !important;
  line-height: 1.6 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  margin: 0 !important;
}

.cgd-btns {
  display: flex;
  gap: clamp(8px, 2vw, 10px);
  flex-wrap: wrap;
}

/* Flip container for cube gallery detail card */
.cgd-flip-container {
  perspective: 800px;
  width: 100%;
  max-width: clamp(300px, 90vw, 480px);
}

.cgd-flip-inner {
  position: relative;
  width: 100%;
  min-height: 160px;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1);
}

.cgd-flip-inner.flipped {
  transform: rotateY(180deg);
}

.cgd-flip-front,
.cgd-flip-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Front face: explicit 0deg so backface culling works with the inner rotation */
.cgd-flip-front {
  position: relative;
  z-index: 2;
  transform: rotateY(0deg);
}

.cgd-flip-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  background: #0d0f1a;
  border: 0.5px solid rgba(0, 210, 255, 0.12);
  border-radius: clamp(12px, 3vw, 16px);
  padding: 20px !important;
  display: flex;
  flex-direction: column;
  gap: 12px !important;
  z-index: 1;
  font-family: "Century Gothic", CenturyGothic, "AppleGothic", "Gill Sans MT", Calibri, sans-serif;
}

.cgd-back-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

/* Title + style chip inline (no absolute positioning) */
.cgd-back-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.cgd-back-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 22px;
  font-weight: 400;
  color: #e8f0fe;
  line-height: 1.1;
  margin: 0;
  min-width: 0;
}

.cgd-back-subtitle {
  font-family: "Century Gothic", CenturyGothic, "AppleGothic", "Gill Sans MT", Calibri, sans-serif;
  font-size: 11px;
  color: #5a6a7a;
  line-height: 1.4;
  margin: 0;
}

.cgd-flip-back .cgd-back-tag {
  position: static !important;
  flex-shrink: 0;
  align-self: center !important;
  margin: 0 !important;
}

.cgd-back-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
}

.cgd-back-row-divider {
  grid-column: 1 / -1;
  height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid rgba(0, 210, 255, 0.08);
}

.cgd-back-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  min-width: 0;
}

.cgd-back-label {
  font-family: "Century Gothic", CenturyGothic, "AppleGothic", "Gill Sans MT", Calibri, sans-serif;
  font-size: 9px;
  color: #5a6a7a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.cgd-back-value {
  font-family: "Bebas Neue", sans-serif;
  font-size: 16px;
  color: #e8f0fe;
  font-weight: 400;
  line-height: 1.2;
}

.cgd-back-desc {
  font-size: clamp(11px, 2.2vw, 12px) !important;
  color: #5a6a7a !important;
  line-height: 1.5 !important;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  display: -webkit-box;
}

.cgd-back-btns {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.cgd-btn-close {
  background: transparent;
  border: 0.5px solid #2e343d;
  border-radius: 9px;
  color: #9ca3af;
  font-size: clamp(12px, 2.5vw, 13px);
  font-weight: 500;
  padding: 0 14px;
  height: clamp(38px, 9vw, 42px);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.cgd-btn-close:hover {
  border-color: rgba(0, 212, 255, 0.5);
  color: #00d4ff;
}

.cgd-btn-ghost {
  flex-shrink: 0;
  background: transparent;
  border: 0.5px solid #2e343d;
  border-radius: 9px !important;
  color: #9ca3af;
  font-size: clamp(12px, 2.5vw, 13px) !important;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 500;
  padding: 0 clamp(12px, 3vw, 16px);
  height: clamp(38px, 9vw, 42px) !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.cgd-btn-ghost:hover {
  border-color: rgba(0,196,255,0.35);
  color: #ffffff;
}

.cgd-btn-primary {
  flex: 1;
  background: #00C4FF;
  border: none;
  border-radius: 9px !important;
  color: #003d50;
  font-size: clamp(12px, 2.5vw, 13px) !important;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  height: clamp(38px, 9vw, 42px) !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

.cgd-btn-primary:hover {
  background: #00b0e6;
}

.cube-gallery-nav {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: clamp(20px, 5vw, 32px) !important;
  padding: 4px 0 !important;
  width: 100% !important;
}

.cg-arr {
  width: clamp(42px, 10vw, 48px) !important;
  height: clamp(42px, 10vw, 48px) !important;
  border-radius: 50% !important;
  background: #1a1e24 !important;
  border: 1px solid #3a3f48 !important;
  color: #ffffff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  transition: background 0.2s, border-color 0.2s, transform 0.15s !important;
  -webkit-tap-highlight-color: transparent !important;
  flex-shrink: 0 !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) !important;
}

.cg-arr:hover {
  background: rgba(0,196,255,0.15) !important;
  border-color: #00C4FF !important;
  color: #00C4FF !important;
  transform: scale(1.05) !important;
}

.cg-arr:active {
  transform: scale(0.94) !important;
}

.cg-arr svg {
  width: 18px !important;
  height: 18px !important;
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 2.5 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  display: block !important;
  flex-shrink: 0 !important;
}

.cg-counter {
  font-size: clamp(14px, 3vw, 16px) !important;
  color: #9ca3af !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 52px !important;
  justify-content: center !important;
  font-weight: 500 !important;
}

.cg-sep {
  color: #3a3f48 !important;
}

@media (min-width: 768px) {
  .cube-gallery-wrap {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 56px 60px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    max-width: 960px !important;
    margin: 0 auto !important;
    padding: 0 24px !important;
    box-sizing: border-box !important;
  }

  .cube-gallery-stage {
    width: clamp(300px, 36vw, 420px) !important;
    height: clamp(300px, 36vw, 420px) !important;
    flex-shrink: 0 !important;
    order: 1 !important;
  }

  .cube-gallery-face {
    width: clamp(300px, 36vw, 420px) !important;
    height: clamp(300px, 36vw, 420px) !important;
  }

  .cube-gallery-detail,
  .cgd-flip-container {
    flex: 1 !important;
    min-width: 0 !important;
    max-width: 340px !important;
  }
  .cgd-flip-container {
    order: 2 !important;
    align-self: center !important;
    margin-left: 24px !important;
  }
  .cube-gallery-detail {
    padding-left: 12px !important;
  }

  .cube-gallery-nav {
    order: 3 !important;
    width: 100% !important;
    margin-top: 28px !important;
    flex-shrink: 0 !important;
  }
}

@media (min-width: 768px) {
  .cube-gallery-face-title {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .cube-gallery-wrap {
    max-width: 1040px !important;
    gap: 56px 60px !important;
  }
  .cube-gallery-stage {
    width: 420px !important;
    height: 420px !important;
  }
  .cube-gallery-face {
    width: 420px !important;
    height: 420px !important;
  }
  .cube-gallery-detail,
  .cgd-flip-container {
    max-width: 360px !important;
  }
}

@media (max-width: 767px) {
  .cube-gallery-wrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 0 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .cube-gallery-stage {
    width: clamp(200px, 68vw, 280px) !important;
    height: clamp(200px, 68vw, 280px) !important;
    flex-shrink: 0 !important;
    margin: 0 auto 48px auto !important;
  }

  .cube-gallery-detail {
    margin-top: 8px !important;
  }

  .cube-gallery-nav {
    margin-top: 20px !important;
  }

  .cube-gallery-face {
    width: clamp(200px, 68vw, 280px) !important;
    height: clamp(200px, 68vw, 280px) !important;
  }

  .cube-gallery-face-title {
    display: none !important;
  }
  .cube-gallery-face-tag {
    top: 10px !important;
    left: 10px !important;
    font-size: 9px !important;
    padding: 3px 10px !important;
    max-width: calc(100% - 20px) !important;
    z-index: 99 !important;
  }

  .cube-gallery-face-grad {
    background: linear-gradient(
      to top,
      rgba(13,15,18,0.3) 0%,
      transparent 50%
    ) !important;
  }

  .cube-gallery-detail,
  .cgd-flip-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .cube-gallery-detail {
    padding: 14px 16px !important;
    gap: 8px !important;
  }

  .cgd-name {
    font-size: clamp(16px, 4.5vw, 19px) !important;
    white-space: normal !important;
  }

  .cgd-role {
    font-size: 12px !important;
    color: #6b7280 !important;
  }

  .cgd-desc {
    font-size: 12px !important;
    -webkit-line-clamp: 2 !important;
  }

  .cgd-btns {
    display: flex !important;
    flex-direction: row !important;
    gap: 9px !important;
  }

  .cgd-btn-ghost {
    flex-shrink: 0 !important;
    height: 40px !important;
    font-size: 12px !important;
    padding: 0 14px !important;
  }

  .cgd-btn-primary {
    flex: 1 !important;
    height: 40px !important;
    font-size: 12px !important;
  }

  .cube-gallery-nav {
    gap: 28px !important;
    width: 100% !important;
    justify-content: center !important;
  }

  .cg-arr {
    width: 44px !important;
    height: 44px !important;
  }
}

@media (max-width: 380px) {
  .cube-gallery-stage {
    width: clamp(180px, 72vw, 240px) !important;
    height: clamp(180px, 72vw, 240px) !important;
  }
  .cube-gallery-face {
    width: clamp(180px, 72vw, 240px) !important;
    height: clamp(180px, 72vw, 240px) !important;
  }
  .cube-gallery-face-tag {
    top: 8px !important;
    left: 8px !important;
    font-size: 9px !important;
    padding: 3px 9px !important;
    max-width: calc(100% - 16px) !important;
  }
  .cgd-btns {
    flex-direction: column !important;
  }
  .cgd-btn-ghost,
  .cgd-btn-primary {
    width: 100% !important;
    justify-content: center !important;
  }
}
