/**
 * Score Components
 *
 * Depth-based score displays with semantic color backgrounds
 * No borders - uses layering and shadows for visual hierarchy
 *
 * @package MattressProtectorReviews
 * @version 2.0.0 - Design System Transformation
 */

/* ============================================
   COMPACT SCORE OVERVIEW SECTION
   ============================================ */
.score-overview {
    background: var(--layer-2);
    border: none;
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    box-shadow: var(--shadow-medium);
    overflow: visible !important;  /* Fixed: Allow tooltips from child elements to escape */
}

.overall-score-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 2px solid var(--layer-3);
}

.overall-score-number {
    font-size: var(--text-5xl);
    font-weight: 700;
    line-height: 1;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overall-score-label {
    font-size: var(--text-sm);
    color: var(--text-caption);
    margin-top: 0.25rem;
}

.score-interpretation {
    background: var(--layer-3);
    padding: var(--space-sm);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-body);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-small);
}

/* ============================================
   PILLAR SCORES GRID
   ============================================ */
.pillar-scores-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    overflow: visible !important;  /* Fixed: Allow tooltips to escape grid boundaries */
}

.pillar-score-item {
    background: var(--layer-3);
    padding: var(--space-sm);
    border-radius: var(--radius-lg);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-small);
    transition: all var(--transition-base);
    position: relative;
    overflow: visible !important;  /* Fixed: Allow tooltips to escape and be visible */
    z-index: 1;  /* Base z-index */
}

.pillar-score-item:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
    z-index: var(--z-popover);  /* Raise above siblings when tooltip is shown */
}

/* Grade-based backgrounds with accent bars */
.pillar-score-item.excellent {
    background: var(--green-50);
}

.pillar-score-item.excellent::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--green-600);
}

.pillar-score-item.good {
    background: var(--blue-50);
}

.pillar-score-item.good::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--blue-600);
}

.pillar-score-item.average {
    background: var(--yellow-50);
}

.pillar-score-item.average::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--yellow-500);
}

.pillar-score-item.poor {
    background: var(--red-50);
}

.pillar-score-item.poor::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--red-600);
}

.pillar-score-label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-caption);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.25rem;
}

.pillar-score-value {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-heading);
}

.pillar-score-max {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ============================================
   SCORE GRID - For Product Pages
   ============================================ */
.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

/* ============================================
   LEGACY SCORE BADGE (for compatibility)
   ============================================ */
.score-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-xl);
    background: var(--layer-2);
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-large);
}

.score-circle {
    position: relative;
    width: 120px;
    height: 120px;
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-number {
    font-size: var(--text-4xl);
    font-weight: 700;
    line-height: 1;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-max {
    font-size: var(--text-sm);
    color: var(--text-caption);
}

/* SVG Circle for Score Visualization */
.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.35s;
    transform-origin: 50% 50%;
}

/* ============================================
   COMPARISON SCORE COLORS
   ============================================ */
.comparison-score-high {
    color: var(--green-600);
    font-weight: 700;
}

.comparison-score-medium {
    color: var(--yellow-500);
    font-weight: 700;
}

.comparison-score-low {
    color: var(--red-600);
    font-weight: 700;
}

/* ============================================
   QUICK STATS
   ============================================ */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.stat-item {
    padding: var(--space-md);
    background: var(--layer-3);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-small);
    transition: all var(--transition-base);
}

.stat-item:hover {
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-caption);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-heading);
}

/* ============================================
   SCORE GRADE BADGES
   ============================================ */
.score-grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-lg);
    font-size: var(--text-xl);
    font-weight: 700;
    border: none;
    box-shadow: var(--shadow-medium);
}

.score-grade-badge.grade-a {
    background: var(--gradient-primary);
    background: linear-gradient(135deg, var(--green-500), var(--green-600));
    color: var(--white);
    box-shadow: var(--highlight-top), 0 4px 8px rgba(22, 163, 74, 0.3);
}

.score-grade-badge.grade-b {
    background: var(--gradient-primary);
    color: var(--white);
    box-shadow: var(--highlight-top), 0 4px 8px rgba(37, 99, 235, 0.3);
}

.score-grade-badge.grade-c {
    background: linear-gradient(135deg, var(--yellow-400), var(--yellow-500));
    color: var(--gray-900);
    box-shadow: var(--highlight-top), 0 4px 8px rgba(234, 179, 8, 0.3);
}

.score-grade-badge.grade-d,
.score-grade-badge.grade-f {
    background: linear-gradient(135deg, var(--red-500), var(--red-600));
    color: var(--white);
    box-shadow: var(--highlight-top), 0 4px 8px rgba(220, 38, 38, 0.3);
}

/* ============================================
   SCORE BAR (Progress Bar)
   ============================================ */
.score-bar-container {
    width: 100%;
    height: 0.75rem;
    background: var(--layer-3);
    border-radius: var(--radius-full);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.score-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
    position: relative;
}

.score-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Score-based colors */
.score-bar-fill.excellent {
    background: linear-gradient(90deg, var(--green-500), var(--green-600));
}

.score-bar-fill.good {
    background: var(--gradient-primary);
}

.score-bar-fill.average {
    background: linear-gradient(90deg, var(--yellow-400), var(--yellow-500));
}

.score-bar-fill.poor {
    background: linear-gradient(90deg, var(--red-500), var(--red-600));
}

/* ============================================
   SCORE COMPARISON TABLE
   ============================================ */
.score-comparison-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    background: var(--layer-3);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    transition: all var(--transition-base);
}

.score-comparison-row:hover {
    background: var(--layer-4);
    transform: translateX(4px);
}

.score-comparison-row:last-child {
    margin-bottom: 0;
}

.score-comparison-label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-body);
}

.score-comparison-value {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-heading);
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .score-overview {
        padding: 1rem;
    }

    .overall-score-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .overall-score-number {
        font-size: var(--text-3xl);
    }

    .overall-score-label {
        font-size: var(--text-xs);
    }

    .score-interpretation {
        font-size: var(--text-xs);
        padding: 0.75rem;
    }

    .pillar-scores-grid {
        display: block;
    }

    .pillar-scores-grid > * + * {
        margin-top: 0.5rem;
    }

    .pillar-score-item {
        padding: 0.75rem;
    }

    .pillar-score-label {
        font-size: 0.65rem;
    }

    .pillar-score-value {
        font-size: var(--text-base);
    }

    .quick-stats {
        grid-template-columns: 1fr;
    }

    .score-grid {
        grid-template-columns: 1fr;
    }

    .score-badge {
        padding: var(--space-lg);
        gap: var(--space-sm);
    }

    .score-circle {
        width: 90px;
        height: 90px;
    }

    .score-number {
        font-size: var(--text-3xl);
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .pillar-score-item,
    .stat-item,
    .score-comparison-row {
        transition: none;
    }

    .score-bar-fill,
    .score-bar-fill::after {
        animation: none;
        transition: none;
    }
}


.pillar-card {
    padding: 2rem;
    background: linear-gradient(135deg, var(--white) 0%, var(--gray-100) 100%);
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pillar-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.pillar-card .pillar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.pillar-card .pillar-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-600);
}

.pillar-card .pillar-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-700);
    font-weight: 700;
    font-size: 0.875rem;
}

.pillar-card .pillar-icon {
    font-size: 1.5rem;
}

.pillar-card .pillar-score {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--blue-600) 0%, var(--blue-700) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pillar-card .pillar-context {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.75rem;
}

.pillar-card .pillar-score-interpretation {
    font-size: 0.9rem;
    color: var(--gray-600);
    line-height: 1.6;
}

.pillar-card .pillar-score-interpretation strong {
    color: var(--gray-900);
}

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

    .pillar-card {
        padding: 1.5rem;
    }
}
