/* =============================================================
   VGC Wrapped — Consolidated Stylesheet
   Single source of truth for index.html + wrapped.html + slides.
   Replaces all inline <style> blocks.
   ============================================================= */

/* ─── 1. Custom Properties ────────────────────────────────── */
:root {
    --vgc-blue: #0b347a;
    --vgc-blue-alt: #0d3b8a;
    --vgc-yellow: #fed105;
    --text-stroke: 2px #000000;
    --slide-top-offset: 64px;
    --banner-height: 40px;
}

/* ─── 2. Base Styles ──────────────────────────────────────── */
body {
    margin: 0;
    background-color: #051630;
    font-family: 'Montserrat', sans-serif;
    color: #E2E8F0;
}

/* Index page: scrollable column layout */
body.page-index {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Wrapped page: fixed viewport, centered */
body.page-wrapped {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

/* ─── 3. Shared Typography ────────────────────────────────── */
.vgc-header {
    font-family: 'Kanit', sans-serif;
    font-weight: 800;
    color: #ffffff;
    -webkit-text-stroke: var(--text-stroke);
    text-transform: uppercase;
    line-height: 1.1;
    paint-order: stroke fill;
    text-shadow: 0px 4px 0px rgba(0, 0, 0, 0.4);
}

.vgc-header-yellow {
    color: var(--vgc-yellow);
}

/* ─── 4. Shared UI Components ─────────────────────────────── */
.vgc-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(-45deg, var(--vgc-blue), var(--vgc-blue) 40px, var(--vgc-blue-alt) 40px, var(--vgc-blue-alt) 80px);
    z-index: -1;
}

.vgc-top-banner {
    background-color: var(--vgc-yellow);
    height: var(--banner-height);
    width: 100%;
    border-bottom: 3px solid #d4ae00;
}

.glass-panel {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Custom scrollbar (webkit) */
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--vgc-yellow);
}

/* ─── 5. Index Page ───────────────────────────────────────── */

/* Index: top banner is simpler (no absolute positioning) */
body.page-index .vgc-top-banner {
    height: 15px;
    border-bottom: 2px solid #d4ae00;
}

/* Index: header sizing */
body.page-index .vgc-header {
    font-size: clamp(3rem, 8vw, 6rem);
}

/* Index: search input */
.search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: clamp(0.75rem, 1.5vw, 1rem) clamp(1rem, 2vw, 1.5rem);
    border-radius: 0.5rem;
    font-size: clamp(1rem, 2vw, 1.25rem);
    font-weight: 600;
    transition: border-color 0.2s;
    outline: none;
}

.search-input:focus {
    border-color: var(--vgc-yellow);
}

/* Index: scale container */
body.page-index #scaleContainer {
    transform-origin: center center;
    width: min(100%, 64rem);
}

/* Index: glass panel full width */
body.page-index .glass-panel {
    width: min(100%, 100%);
    padding: 1.5rem 3rem;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Index: mode buttons */
.mode-btn {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #9ca3af;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn.active {
    background: var(--vgc-yellow);
    color: black;
    border-color: var(--vgc-yellow);
}

/* Index: search results dropdown */
.results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
}

.result-item {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s;
}

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

.result-item:hover {
    background: rgba(254, 209, 5, 0.2);
}

.player-name {
    font-weight: 700;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    color: white;
}

.player-country {
    font-weight: 600;
    color: #9ca3af;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    text-transform: uppercase;
}

/* ─── 6. Wrapped Page — Container ─────────────────────────── */

#wrapped-container {
    position: relative;
    width: 98vw;
    max-width: 1800px;
    height: 95vh;
    min-height: 680px;
    min-width: 1120px;
    background: repeating-linear-gradient(-45deg, var(--vgc-blue), var(--vgc-blue) 40px, var(--vgc-blue-alt) 40px, var(--vgc-blue-alt) 80px);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform-origin: center center;
}

/* Wrapped: top banner is absolute positioned */
body.page-wrapped .vgc-top-banner {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
}

/* Wrapped: logo */
.vgc-logo {
    position: absolute;
    top: 4px;
    left: 32px;
    height: 64px;
    z-index: 30;
    filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.5));
}

/* ─── 7. Progress Bar ─────────────────────────────────────── */
.progress-container {
    position: absolute;
    top: calc(var(--banner-height) + 8px);
    left: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    z-index: 50;
}

.progress-segment {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--vgc-yellow);
    transition: width 0.3s ease;
}

/* ─── 8. Slide System ─────────────────────────────────────── */
.slide {
    position: absolute;
    top: var(--slide-top-offset);
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-in-out, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform: scale(0.98);
    display: flex;
    flex-direction: column;
    padding: 1rem 2rem;
    overflow: hidden; /* Localized scrollbars inside components on desktop */
}

.slide.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    z-index: 10;
}

/* Slide content grids — margin bottom to clear the desktop controls */
.slide > .grid {
    margin-bottom: 5.5rem;
    gap: 1rem;
}

/*
 * Targeted size reductions (replaces the removed `html { font-size: 80% }` hack).
 * Only the elements that were too large at default rem sizing are adjusted here.
 */

/* Slide section titles — reduced from text-7xl (4.5rem) to ~3.5rem */
.slide > header .vgc-header {
    font-size: 3.5rem;
}

/* Slide section headers — tighter margins */
.slide > header {
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

/* Glass panels — slightly tighter for density */
.slide .glass-panel {
    padding: 1rem;
}

.slide .stat-number-giant {
    font-size: clamp(4rem, 18vh, 12rem);
}


/* ─── 9. Slide Controls ───────────────────────────────────── */
.controls {
    position: absolute;
    bottom: 30px;
    right: 40px;
    z-index: 60;
    display: flex;
    gap: 1rem;
}

.control-btn {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: var(--vgc-yellow);
    color: black;
    border-color: var(--vgc-yellow);
}

.control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ─── 10. Share / Export (Slide 5) ─────────────────────────── */

/* Export-specific: fixed dimensions for screenshot rendering */
.export-slide {
    width: 1366px;
    height: 768px;
    transform-origin: top left;
}

#scaleContainer {
    width: 640px;
    height: auto;
    flex-shrink: 0;
}

/* Fix image rendering during modern-screenshot export */
.exporting img {
    display: inline-block !important;
    vertical-align: top !important;
}

/* Export visibility helpers */
.exporting .export-hide {
    display: none !important;
}

.exporting * {
    text-overflow: clip !important;
}

.exporting .export-untruncate {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* Share card fixed dimensions — required for image export */
#card-competitor,
#card-strategist,
#card-battler {
    min-width: 640px !important;
    max-width: 640px !important;
    width: 640px !important;
    min-height: 800px !important;
    height: auto !important;
    max-height: none !important;
    -webkit-text-size-adjust: 100% !important;
    -moz-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
    flex-shrink: 0 !important;
}

#shareScaleWrapper {
    transform-origin: top center;
    width: fit-content;
    margin: 0 auto;
}

/* Share card scale container */
.share-card-container {
    width: 640px;
    height: auto;
    flex-shrink: 0;
}

/* Export button */
.export-btn {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--vgc-yellow);
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 2rem;
    font-family: 'Kanit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
}

.export-btn:hover:not(:disabled) {
    background: var(--vgc-yellow);
    color: black;
}

.export-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.export-btn.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Share navigation buttons */
.share-nav-btn {
    position: relative;
    z-index: 50;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.share-nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ─── 11. Responsive — Index ──────────────────────────────── */

@media (max-height: 750px) {
    body.page-index main {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

@media (max-width: 768px) {
    body.page-index .mode-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        flex: 1;
        text-align: center;
    }

    body.page-index .search-input {
        font-size: 1rem;
        padding: 0.8rem 1rem;
    }
}

/* ─── 12. Responsive — Wrapped ────────────────────────────── */

@media (max-width: 768px) {
    #wrapped-container {
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        border-radius: 0;
        border: none;
        transform: none !important;
    }

    .slide {
        padding: 1.5rem 1rem 1rem 1rem;
        bottom: 85px !important; /* height of controls */
        overflow-y: auto; /* Allow full slide scroll on mobile */
    }

    .slide > .grid {
        margin-bottom: 0 !important; /* Spacing handled by slide padding-bottom */
    }

    .slide > .grid {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        gap: 1rem !important;
    }

    .slide .grid > [class*="col-span-"] {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        flex: none !important;
        overflow: visible !important;
    }

    .slide .glass-panel {
        height: auto !important;
        min-height: 0 !important;
        flex: none !important;
        overflow: visible !important;
    }

    /* Reset inner scroll lists on mobile */
    .slide .glass-panel .overflow-y-auto {
        overflow-y: visible !important;
        height: auto !important;
        flex: none !important;
    }

    .slide .vgc-header {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    /* Wrap header items vertically on mobile to prevent collisions */
    .slide > header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .slide > header .vgc-header {
        font-size: 2.25rem !important;
    }

    /* Scale down the sub-headers (like event count) on mobile */
    .slide > header span.vgc-header {
        font-size: 1.35rem !important;
    }

    .controls {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 15px;
        background: rgba(5, 22, 48, 0.98);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        justify-content: center;
        gap: 0.5rem;
        z-index: 100;
    }

    .control-btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        flex: 1;
        text-align: center;
    }

    .vgc-logo {
        height: 50px;
        left: 10px;
        top: 15px;
    }

    .progress-container {
        top: 50px;
        left: 10px;
        right: 10px;
    }
}
