/**
 * Card Detail Page Styles
 * Styles for the card detail view with tabs (Notation, Photos, Video, Vente, Infos)
 *
 * Created: 2025-12-25
 */

/* ========================================
   PAGE CONTAINER
   ======================================== */

.card-detail-page {
    min-height: 100vh;
    background: var(--bg-app);
    padding-bottom: 120px;
}

/* ========================================
   PAGE HEADER - Card Detail Variant
   Uses the common page-header pattern with custom layout
   PROGRESSIF: scale + opacité pilotés par JS, pas de toggle binaire
   ======================================== */

.page-header--card-detail {
    position: sticky;
    top: 64px;
    z-index: 100;

    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;

    /* hauteur constante = aucun saut */
    padding: 16px 24px 16px 16px;

    /* anti scroll-anchoring */
    overflow-anchor: none;

    /* variables pilotées par JS (progressif) */
    --cd-shrink: 1;
    --cd-toolbar-scale: 1;
    --cd-bg-opacity: 0;

    /* pas de transition sur transform (piloté par scroll) */
    background: transparent;
    border-bottom: 1px solid transparent;

    /* pour empiler proprement le ::before derrière */
    isolation: isolate;
}

/* Couche visuelle: blur + fond + bordure, opacité variable */
.page-header--card-detail::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 14, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: var(--cd-bg-opacity);
    pointer-events: none;
    z-index: 0;
    will-change: opacity;
    /* Transition douce pour l'opacité */
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-header--card-detail::after {
    display: none;
}

/* Tout le contenu au-dessus du ::before */
.page-header--card-detail > * {
    position: relative;
    z-index: 1;
}

.page-header--card-detail .page-header__content {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: 16px;
}

/* Toolbar scale piloté par scroll + transition douce */
.page-header--card-detail .page-header__toolbar {
    margin-top: 0;
    width: 100%;
    justify-content: flex-start;
    transform: scale(var(--cd-toolbar-scale));
    transform-origin: left center;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Card identity group (thumb + scores + likes) */
.card-detail-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-detail-scores {
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Back Button - FIXED SIZE for stable tap zone */
.page-header--card-detail .btn-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}

/* Scale only the icon, not the button */
.page-header--card-detail .btn-back i {
    transform: scale(var(--cd-shrink));
    transform-origin: center;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-header--card-detail .btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Card Mini Thumbnail - Scalable element */
.card-mini-thumb {
    width: 36px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transform: scale(var(--cd-shrink));
    transform-origin: center left;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Score Badges - Scalable elements */
.card-detail-identity .card-score-badge,
.card-detail-identity .card-user-score-badge {
    position: static;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    top: auto;
    left: auto;
    z-index: auto;
    transform: scale(var(--cd-shrink));
    transform-origin: center left;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-detail-identity .card-score-badge i {
    font-size: 0.55rem;
    color: #facc15;
}

.card-detail-identity .card-user-score-badge {
    background: #3b82f6;
    font-size: 13px;
}

/* Likes - Scalable element */
.card-likes {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    transform: scale(var(--cd-shrink));
    transform-origin: center left;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-likes i {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    transition: color 0.2s ease, transform 0.2s ease;
}

.card-likes.liked i {
    color: #ef4444;
}

.card-likes:hover {
    background: rgba(255, 255, 255, 0.1);
}

.card-likes:active {
    transform: scale(0.95);
}

/* Like pulse animation */
.card-likes.like-pulse i {
    animation: likePulse 0.3s ease;
}

@keyframes likePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Like error animation (rate limited) */
.card-likes.like-error {
    animation: likeError 0.3s ease;
}

@keyframes likeError {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Like disabled state with tooltip */
.card-likes.like-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.card-likes.like-disabled::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.card-likes.like-disabled:hover::after,
.card-likes.like-disabled.show-tooltip::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Icon Buttons - FIXED SIZE for stable tap zone */
.card-detail-actions .btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.card-detail-actions .btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Scale only the icon, not the button */
.card-detail-actions .btn-icon i {
    transform: scale(var(--cd-shrink));
    transform-origin: center;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sell Button */
.btn-sell {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sell:hover {
    background: var(--accent-hover);
}

/* ========================================
   TAB CONTENT
   ======================================== */

.card-detail-content {
    padding: 0;
}

.card-tab-content {
    display: none;
    padding: 20px 96px;
    animation: fadeIn 0.3s ease;
}

.card-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tab Sections */
.tab-section {
    margin-bottom: 28px;
}

.tab-section:last-child {
    margin-bottom: 0;
}

/* Tab Sections Grid - 2 columns layout */
.tab-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: start;
    margin-bottom: 28px;
}

.tab-sections-grid .tab-section {
    margin-bottom: 0;
}

/* Column container for stacking sections vertically */
.tab-section-column {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.tab-section-column .tab-section {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .tab-sections-grid {
        grid-template-columns: 1fr;
    }
}

.tab-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========================================
   COMMUNITY SCORE CARD
   ======================================== */

.community-score-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
}

.community-score-badge {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    background: #22c55e;
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
    flex-shrink: 0;
}

.community-score-details {
    flex: 1;
    min-width: 0;
}

.community-score-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

.meta-chip i {
    font-size: 12px;
    color: var(--accent);
}

.median-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

/* ========================================
   SCORE DISTRIBUTION
   ======================================== */

.distribution-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.distribution-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.distribution-label {
    width: 28px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
    flex-shrink: 0;
}

.distribution-bar-container {
    flex: 1;
    height: 20px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.distribution-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    min-width: 2px;
}

.distribution-count {
    width: 24px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-align: left;
    flex-shrink: 0;
}

/* ========================================
   RATERS LIST
   ======================================== */

.raters-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}

.rater-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rater-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.rater-item:first-child {
    padding-top: 0;
}

.rater-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.rater-note {
    font-size: 18px;
    font-weight: 700;
    min-width: 28px;
}

.rater-name {
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rater-rank {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.rater-pts {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
}

/* Legacy styles - can be removed later */
.rater-avatar,
.rater-avatar-placeholder {
    display: none;
}

.rater-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.rater-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

.rater-score {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* ========================================
   RELIABILITY METRICS - Premium Design
   ======================================== */

.reliability-table {
    background: #161616;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(12px);
}

.reliability-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.reliability-header-note {
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reliability-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease;
}

.reliability-row:hover {
    background: rgba(255, 255, 255, 0.02);
    margin: 0 -12px;
    padding: 12px;
    border-radius: 8px;
}

.reliability-row:last-child {
    border-bottom: none;
}

.reliability-row.reliability-result {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.reliability-row.reliability-result:hover {
    margin: 16px -12px 0;
    padding: 16px 24px;
}

.reliability-label {
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 8px;
}

.reliability-value-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reliability-value {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-display);
    min-width: 32px;
    text-align: right;
}

.reliability-result-value {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reliability-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.reliability-score {
    font-size: 28px;
    font-weight: 800;
    font-family: var(--font-display);
}

/* Progress bar for metrics */
.reliability-metric-bar {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.reliability-metric-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   PHOTOS TAB - Pokemon Card Layout
   ======================================== */

/* Grid: 2 cards side by side, maximize space */
.photos-grid {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 32px;
    padding: 24px;
}

/* Each photo card container - fill available space */
.photo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    flex: 1;
    max-width: 380px;
}

/* Card frame - aspect ratio 63:88 (Pokemon card standard) */
.photo-card-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 63 / 88;
    border-radius: 12px;
    overflow: hidden;
    background: #161616;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

/* The actual card image */
.photo-card-frame .card-photo {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.photo-card-frame:hover .card-photo {
    transform: scale(1.02);
}

/* Label under the card */
.photo-card-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
}

/* Responsive: stack on small screens */
@media (max-width: 680px) {
    .photos-grid {
        flex-direction: column;
        align-items: center;
        gap: 24px;
        padding: 16px;
    }

    .photo-card {
        max-width: 300px;
        width: 100%;
    }
}

/* ========================================
   VIDEO TAB
   ======================================== */

.video-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.card-video {
    width: 100%;
    display: block;
    max-height: 70vh;
}

.video-quality-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    font-size: 12px;
    color: #fff;
}

/* ========================================
   EMPTY & LOADING STATES
   ======================================== */

.empty-text {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 14px;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--accent);
    font-size: 24px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .page-header--card-detail {
        top: 0;
        padding: 12px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-header--card-detail .page-header__content {
        flex: 1;
        min-width: 0;
    }

    .card-detail-identity {
        gap: 8px;
    }

    .page-header--card-detail .page-header__toolbar {
        order: 3;
        width: 100%;
    }

    .card-tab-content {
        padding: 16px 12px;
    }

    .community-score-card {
        padding: 16px;
        gap: 14px;
    }

    .community-score-badge {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }

    .reliability-grid {
        gap: 8px;
    }

    .reliability-card {
        padding: 16px 8px;
    }

    .reliability-value {
        font-size: 20px;
    }

    .reliability-label {
        font-size: 10px;
    }

    .rater-item {
        padding: 10px 12px;
    }

    .rater-avatar,
    .rater-avatar-placeholder {
        width: 36px;
        height: 36px;
    }

    .rater-score {
        min-width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .community-score-card {
        flex-direction: column;
        text-align: center;
    }

    .community-score-meta {
        justify-content: center;
    }

    .btn-sell {
        display: none;
    }
}
