/**
 * Article Metrics Styles — Scholarly Design System
 * Uses design tokens from design-system.css
 * Dark mode handled automatically via token redefinition — no separate selectors needed
 */

/* ============================================================================
   METRIC ANIMATIONS
   ============================================================================ */

@keyframes metricPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes spinRefresh {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.metric-updated {
    animation: metricPulse 0.5s ease-in-out;
    color: var(--oa-green);
    font-weight: bold;
}

.spinning {
    animation: spinRefresh 1s linear infinite;
}

/* ============================================================================
   METRIC DISPLAY
   ============================================================================ */

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    transition: background-color 0.18s ease;
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-item:hover {
    background-color: var(--bg-subtle);
    padding-left: 8px;
    padding-right: 8px;
    margin-left: -8px;
    margin-right: -8px;
    border-radius: var(--radius-sm);
}

.metric-label {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-label i {
    margin-right: 8px;
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.metric-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    transition: all 0.2s ease;
}

/* ============================================================================
   ALTMETRIC BREAKDOWN
   ============================================================================ */

.formula-box {
    background: var(--bg-subtle);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 15px;
    margin: 15px 0;
}

.formula-title {
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.formula-title i {
    margin-right: 8px;
    color: var(--accent);
}

.formula-content code {
    display: block;
    background: var(--paper);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--accent);
    font-family: var(--font-mono);
    overflow-x: auto;
    white-space: nowrap;
}

/* Weight explanation items */
.weight-explanation {
    margin-top: 15px;
}

.weight-item {
    margin-bottom: 12px;
    padding: 10px;
    background: var(--paper);
    border-radius: var(--radius-md);
    border-left: 3px solid transparent;
    transition: box-shadow 0.18s ease;
}

.weight-item:hover {
    box-shadow: var(--shadow-sm);
}

.weight-item:nth-child(1) { border-left-color: var(--accent); }
.weight-item:nth-child(2) { border-left-color: var(--oa-green); }
.weight-item:nth-child(3) { border-left-color: var(--muted); }
.weight-item:nth-child(4) { border-left-color: var(--text-subtle); }

.weight-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-main);
}

.weight-label i {
    font-size: 1.1rem;
}

.weight-label .badge {
    font-size: 0.72rem;
    padding: 4px 8px;
}

.weight-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
    padding-left: 28px;
}

/* Calculation details */
.calculation-details {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 15px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.88rem;
    color: var(--text-main);
}

.calc-row.total {
    border-top: 2px solid var(--accent);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1rem;
}

.total-score {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.15rem;
}

/* Score guide */
.guide-content {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 12px;
}

.guide-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.guide-item:last-child {
    border-bottom: none;
}

.score-range {
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    min-width: 80px;
    text-align: center;
}

.score-range.low {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.score-range.medium {
    background: #FFF8E1;
    color: #8D6E0F;
}

.score-range.high {
    background: #E8F5E9;
    color: var(--oa-green);
}

.score-range.exceptional {
    background: var(--primary-50);
    color: var(--accent);
}

.score-meaning {
    font-size: 0.82rem;
    color: var(--text-muted);
    flex: 1;
    margin-left: 12px;
}

/* ============================================================================
   RESPONSIVE — 768px
   ============================================================================ */

@media (max-width: 768px) {
    .metric-value {
        font-size: 1.15rem;
    }

    .metric-label {
        font-size: 0.85rem;
    }

    .formula-content code {
        font-size: 0.72rem;
        padding: 8px;
    }

    .weight-item {
        padding: 8px;
        margin-bottom: 10px;
    }

    .weight-label {
        flex-wrap: wrap;
        gap: 6px;
    }

    .weight-desc {
        padding-left: 0;
        margin-top: 5px;
    }

    .calculation-details {
        padding: 10px;
    }

    .calc-row {
        font-size: 0.78rem;
        padding: 6px 0;
    }

    .total-score {
        font-size: 1rem;
    }

    .guide-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .score-range {
        min-width: auto;
    }

    .score-meaning {
        margin-left: 0;
    }

    .article-sidebar.mobile-view {
        margin-top: 20px;
    }

    .sidebar-section {
        margin-bottom: 20px;
    }

    .sidebar-section h3 {
        font-size: 1rem;
    }

    .altmetric-breakdown.mobile-compact {
        max-height: 300px;
        overflow-y: auto;
    }
}

/* ============================================================================
   RESPONSIVE — 480px
   ============================================================================ */

@media (max-width: 480px) {
    .metric-value {
        font-size: 1rem;
    }

    .metric-label {
        font-size: 0.78rem;
    }

    .metric-label i {
        font-size: 0.92rem;
        width: 18px;
    }

    .formula-content code {
        font-size: 0.68rem;
        padding: 6px;
    }

    .weight-item {
        padding: 6px;
    }

    .weight-label {
        font-size: 0.82rem;
    }

    .weight-desc {
        font-size: 0.72rem;
    }

    .calculation-details {
        padding: 8px;
    }

    .calc-row {
        font-size: 0.72rem;
    }

    .total-score {
        font-size: 0.92rem;
    }

    .metric-info small {
        font-size: 0.68rem;
    }
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.metric-value .spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 0.15rem;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-contrast: high) {
    .metric-item {
        border-bottom-width: 2px;
    }

    .formula-box {
        border-width: 2px;
    }

    .weight-item {
        border-left-width: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .metric-updated,
    .spinning,
    .weight-item {
        animation: none !important;
        transition: none !important;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .metric-item {
        page-break-inside: avoid;
    }

    .weight-item:hover {
        box-shadow: none;
    }

    .calculation-example,
    .score-guide {
        page-break-inside: avoid;
    }

    .collapse:not(.show) {
        display: block !important;
        height: auto !important;
    }
}