/* ── Shared league-facing page styles ────────────────────────────────────────
   Merges: tables2.css (§1), results.css (§2), analysis.css (§3),
           licence.html inline styles (§4)
   Used by: tables2.html, tables3.html, results.html, analysis.html,
            penalties.html, licence.html
   Served at: /league.css
   Depends on: /modern.css (loaded first)
   ───────────────────────────────────────────────────────────────────────── */


/* ═══════════════════════════════════════════════════════════════════════════
   §1 — Championship standings (tables2.html, tables3.html)
   Source: tables2.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* Header: compact display on standings pages */
body.page-standings .header {
    padding: 8px;
    margin-bottom: 15px;
}

/* Animated dot overlay on all gradient headers */
.header::before {
    animation: dotMove 15s linear infinite;
}

@keyframes dotMove {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(100px, 100px); }
}

/* Championship title: large version (standings pages only) */
body.page-standings .league-title {
    font-size: 4.5rem;
    letter-spacing: 4px;
    animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5), 4px 4px 20px rgba(0, 0, 0, 0.3); }
    50%       { text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5), 4px 4px 30px rgba(255, 255, 255, 0.4); }
}

/* .subtitle is used as the league-title element in tables2/tables3 HTML */
body.page-standings .subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: 3.0rem;
    text-align: center;
    margin-top: 2px;
    letter-spacing: 8px;
    font-weight: 900;
    text-transform: uppercase;
}

.update-info {
    text-align: center;
    margin-top: 3px;
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 400;
}

/* ── Class navigation buttons ───────────────────────────────────────────── */
.class-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.class-btn {
    font-family: 'Orbitron', sans-serif;
    background: var(--card-bg);
    border: 2px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    overflow: hidden;
}

.class-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--btn-hover-bg);
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.class-btn:hover::before {
    width: 300px;
    height: 300px;
}

.class-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--btn-hover-shadow);
}

.class-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--neon-color) 100%);
    border-color: var(--neon-color);
    color: #000;
    box-shadow: 0 8px 25px var(--btn-active-shadow);
}

.class-btn span {
    position: relative;
    z-index: 1;
}

/* ── Table container ────────────────────────────────────────────────────── */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.table-container::-webkit-scrollbar { height: 12px; }

.table-container::-webkit-scrollbar-track {
    background: var(--border-subtle);
    border-radius: 6px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 6px;
    transition: background 0.3s ease;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--neon-color);
}

.table-wrapper { min-width: max-content; }

/* ── Table header row ───────────────────────────────────────────────────── */
.table-header {
    display: grid;
    gap: 8px;
    padding: 10px;
    background: var(--table-header-bg);
    border-radius: 10px;
    margin-bottom: 10px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 1px solid var(--table-header-border);
    width: max-content;
    min-width: 100%;
}

.header-cell {
    text-align: center;
    color: var(--neon-color);
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 6px;
}

.header-cell:hover {
    background: var(--header-cell-hover);
    transform: scale(1.05);
}

.header-cell.name { text-align: left; }

/* ── Table data rows ────────────────────────────────────────────────────── */
.table-row {
    display: grid;
    gap: 8px;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    margin-bottom: 8px;
    align-items: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    animation: rowFadeIn 0.6s ease-out backwards;
    width: max-content;
    min-width: 100%;
}

@keyframes rowFadeIn {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}

.table-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.table-row:hover::before { opacity: 1; }

.table-row:hover {
    background: var(--card-hover);
    border-color: var(--primary-color);
    transform: translateX(10px);
    box-shadow:
        0 8px 30px var(--row-hover-shadow),
        inset 0 0 40px var(--row-hover-inset);
}

/* ── Position badge ─────────────────────────────────────────────────────── */
.position {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 900;
    background: transparent;
    border: 3px solid var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 2px 10px var(--position-shadow);
    transition: all 0.3s ease;
}

.table-row:hover .position {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 4px 15px var(--position-hover-shadow);
}

.position.p1 {
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    border: none;
    color: #000;
    box-shadow: 0 4px 20px rgba(241, 196, 15, 0.6);
    animation: goldPulse 2s ease-in-out infinite;
}

@keyframes goldPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(241, 196, 15, 0.6); }
    50%       { box-shadow: 0 6px 30px rgba(241, 196, 15, 0.8); }
}

.position.p2 {
    background: linear-gradient(135deg, #95a5a6 0%, #bdc3c7 100%);
    border: none;
    color: #000;
    box-shadow: 0 4px 20px rgba(189, 195, 199, 0.5);
}

.position.p3 {
    background: linear-gradient(135deg, #d35400 0%, #e67e22 100%);
    border: none;
    color: #000;
    box-shadow: 0 4px 20px rgba(230, 126, 34, 0.5);
}

/* ── Driver names ───────────────────────────────────────────────────────── */
.driver-name {
    font-size: 1.1rem;
    font-weight: 700;
    text-align: left;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Driver names in teams table (smaller, truncation-friendly) */
.teams-driver-name {
    font-size: 0.85rem;
    font-weight: 700;
    text-align: left;
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.table-row:hover .driver-name,
.table-row:hover .teams-driver-name {
    color: var(--neon-color);
    transform: translateX(5px);
}

/* ── Points cells ───────────────────────────────────────────────────────── */
.points {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Orbitron', monospace;
    padding: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s ease;
    position: relative;
}

.points:hover {
    background: var(--points-hover-bg);
    transform: scale(1.08);
}

.points.best {
    background: var(--best-score-bg);
    color: var(--neon-color);
    font-weight: 700;
    box-shadow: inset 0 0 10px var(--best-score-shadow);
}

.points.best::after {
    content: '★';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 0.8rem;
    color: var(--neon-color);
    animation: starTwinkle 1.5s ease-in-out infinite;
}

@keyframes starTwinkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.6; transform: scale(1.2); }
}

/* ── Total points ───────────────────────────────────────────────────────── */
.total {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 900;
    font-family: 'Orbitron', sans-serif;
    color: var(--neon-color);
    text-shadow: 0 0 10px var(--total-text-shadow);
    animation: totalPulse 2s ease-in-out infinite;
}

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

/* ── Penalties column ───────────────────────────────────────────────────── */
.penalties {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Orbitron', monospace;
}

.penalties.zero { color: var(--primary-dark); }

/* Loading shimmer animation (used by JS) */
@keyframes shimmer {
    0%   { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

/* ── Scroll-to-top button ───────────────────────────────────────────────── */
.scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--neon-color) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px var(--scroll-btn-shadow);
    transition: all 0.3s ease;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

.scroll-top.visible {
    opacity: 1;
    pointer-events: all;
}

.scroll-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px var(--scroll-btn-hover-shadow);
}

.scroll-top::before {
    content: '↑';
    font-size: 1.5rem;
    font-weight: 900;
    color: #000;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
    body.page-standings .league-title { font-size: 3.5rem; }
    body.page-standings .subtitle { font-size: 2.2rem; }
    .container { padding: 15px; }
}

@media (max-width: 768px) {
    .container { padding: 10px; }
    body.page-standings .header { padding: 15px 10px; margin-bottom: 10px; }
    body.page-standings .league-title { font-size: 1.8rem; letter-spacing: 2px; }
    body.page-standings .subtitle { font-size: 1.2rem; letter-spacing: 3px; }

    .update-info { font-size: 0.75rem; }
    .class-nav { gap: 8px; margin: 10px 0; }
    .class-btn { padding: 8px 16px; font-size: 0.8rem; letter-spacing: 1px; }
    .table-container { padding: 8px; border-radius: 8px; }
    .table-header { display: none !important; }
    .table-row {
        grid-template-columns: 1fr !important;
        gap: 12px;
        padding: 15px;
        margin-bottom: 12px;
    }

    .position {
        position: absolute;
        top: 15px;
        left: 15px;
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    .driver-name { padding-left: 70px; font-size: 1.2rem; padding-top: 5px; padding-bottom: 10px; }
    .teams-driver-name { padding-left: 70px; font-size: 1rem; padding-top: 5px; padding-bottom: 10px; }

    .points, .penalties, .total {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 10px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 6px;
    }

    .points::before, .penalties::before, .total::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-secondary);
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .points.best::after { position: static; margin-left: 8px; }

    .total {
        font-size: 1.1rem;
        background: var(--mobile-total-bg);
        border: 1px solid var(--mobile-total-border);
    }

    .scroll-top { bottom: 20px; right: 20px; width: 45px; height: 45px; }
}

@media (max-width: 480px) {
    body.page-standings .league-title { font-size: 1.4rem; letter-spacing: 1px; }
    body.page-standings .subtitle { font-size: 1rem; letter-spacing: 2px; }
    .class-btn { padding: 6px 12px; font-size: 0.75rem; }
    .driver-name { font-size: 1rem; }
    .teams-driver-name { font-size: 0.85rem; }
    .position { width: 40px; height: 40px; font-size: 1rem; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   §2 — Results page
   Source: results.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Legacy table layout (dark-themed) ──────────────────────────────────── */
.full_width_table {
    color: white;
    clear: both;
}

.narrow_table {
    padding: 10px;
    width: 50%;
    float: left;
    color: white;
}

.table {
    margin: 0 0 20px 0;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: table;
}

@media screen and (max-width: 580px) {
    .table { display: block; }
}

.row {
    display: table-row;
    background: #1e1e1e;
}

.row:nth-of-type(odd) { background: #252525; }

.cell {
    padding: 6px 12px;
    display: table-cell;
    vertical-align: middle;
    color: white;
}

@media screen and (max-width: 580px) {
    .row  { padding: 8px 0; display: block; }
    .cell { padding: 2px 12px; display: block; }
}

/* ── Page subtitle (results, penalties, licence) ─────────────────────────── */
.subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    text-align: center;
    color: white;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
    margin-top: 5px;
}

/* ── Cross-page navigation ───────────────────────────────────────────────── */
.page-nav {
    text-align: center;
    margin-top: 8px;
    font-size: 1rem;
}

.page-nav a {
    color: white;
    text-decoration: underline;
    font-family: 'Rajdhani', sans-serif;
    opacity: 0.85;
    transition: opacity 0.2s, color 0.2s;
}

.page-nav a:hover {
    opacity: 1;
    color: var(--neon-color);
}

/* Centre all results table cell text */
#results_displayed .cell { text-align: center; }

/* ── Table header row: theme colour, reset modern.css .header leaks ─────── */
/* Cells have class="cell row header blue" so .row.header matches directly   */
.row.header {
    background: var(--primary-dark);
    color: white;
    padding: 6px 12px;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
    overflow: visible;
    position: static;
    text-align: center;
    white-space: normal;
    word-break: break-word;
}

.row.header::before { display: none; }


/* ═══════════════════════════════════════════════════════════════════════════
   §3 — Analysis page
   Source: analysis.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* Container: narrower for analysis page */
body.page-analysis .container { max-width: 1400px; }

/* Header: more spacious for analysis page */
body.page-analysis .header {
    padding: 20px 24px;
    margin-bottom: 24px;
}

/* Centre all content in header (benefits all pages using .header-content) */
.header-content { text-align: center; }

/* ── Round cards grid ───────────────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 4px;
}

.round-card {
    background: var(--card-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 24px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.round-card.available { cursor: pointer; }

.round-card.available:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(var(--primary-rgb, 46, 204, 113), 0.2);
    border-color: var(--primary-color);
}

.card-round-label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.card-track-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 10px;
}

.card-date {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-subtle);
    padding-top: 14px;
}

/* ── Status badges ──────────────────────────────────────────────────────── */
.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
}

.status-badge.available {
    background: rgba(var(--primary-rgb, 46, 204, 113), 0.15);
    color: var(--primary-color);
    border: 1px solid rgba(var(--primary-rgb, 46, 204, 113), 0.3);
}

.status-badge.coming-soon {
    background: rgba(120, 120, 120, 0.1);
    color: #666;
    border: 1px solid rgba(120, 120, 120, 0.2);
}

.card-action-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: gap 0.2s;
}

.round-card.available:hover .card-action-link { gap: 8px; }

/* ── Analysis iframe view ───────────────────────────────────────────────── */
#analysis-view { display: none; }

.analysis-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.back-btn {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 999px;
    padding: 8px 20px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.back-btn:hover {
    background: var(--primary-color);
    color: #0a0a0a;
}

.round-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

#analysis-frame {
    width: 100%;
    height: 80vh;
    border: none;
    border-radius: 8px;
    background: #fff;
}

.loading-msg {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 0;
    font-size: 1.1rem;
}


/* ═══════════════════════════════════════════════════════════════════════════
   §4 — Licence page extras
   Source: licence.html inline <style> block
   ═══════════════════════════════════════════════════════════════════════════ */

.class-section { margin-bottom: 40px; }
.class-title { margin: 10px 0 0 0; }


/* ═══════════════════════════════════════════════════════════════════════════
   §5 — Detail modal (penalties, sessions)
   ═══════════════════════════════════════════════════════════════════════════ */

.detail-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 1000;
    overflow-y: auto;
}

.detail-modal {
    position: relative;
    margin: 60px auto;
    max-width: 640px;
    background: #1a1a1a;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    padding: 28px 32px;
}

.detail-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.detail-modal-title {
    font-family: 'Orbitron', sans-serif;
    color: var(--primary-color);
    margin: 0 0 20px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.detail-modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin-bottom: 20px;
}

.detail-modal-label {
    color: #aaa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-modal-value {
    color: #eee;
    font-size: 0.9rem;
    word-break: break-word;
}

.detail-modal-input {
    background: #2a2a2a;
    border: 1px solid var(--primary-color);
    color: #eee;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 100%;
    box-sizing: border-box;
}

.detail-modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.detail-modal-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.detail-modal-btn.primary {
    background: var(--primary-color);
    color: #000;
}

.detail-modal-btn.secondary {
    background: #444;
    color: #eee;
}
