/* ============================================================
   BBATTL.com - Styles
   Playful editorial arena / vintage broadsheet aesthetic
   ============================================================ */

/* --- RESET & BASE --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --paper-base: #f5f0e8;
    --frost-overlay: rgba(232, 238, 244, 0.8);
    --ink-primary: #2c3e50;
    --battle-red: #c0392b;
    --corner-blue: #5d6d7e;
    --highlight-gold: #f0c040;
    --skeleton-shimmer: #dfe6ed;
    --skeleton-shimmer-light: #eef2f7;
    --grid-rule: #c8d6e5;
    --frost-border: rgba(255, 255, 255, 0.7);
    --darker-paper: #e8ddd0;
    --font-display: 'Bebas Neue', sans-serif;
    --font-secondary: 'Archivo Black', sans-serif;
    --font-body: 'Libre Baskerville', serif;
    --font-mono: 'Space Mono', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--paper-base);
    color: var(--ink-primary);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.65;
    overflow-x: hidden;
    position: relative;
}

/* --- PAPER GRAIN TEXTURE OVERLAY --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    filter: url(#paper-grain);
    background: var(--paper-base);
    opacity: 0.35;
    mix-blend-mode: multiply;
}

/* --- ARENA ENTRANCE --- */
#arena-entrance {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper-base);
    transition: opacity 0.6s ease;
}

#arena-entrance.hidden {
    opacity: 0;
    pointer-events: none;
}

#arena-paper-left,
#arena-paper-right {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    background: var(--paper-base);
    z-index: 2;
    transition: clip-path 0.8s cubic-bezier(0.77, 0, 0.175, 1);
}

#arena-paper-left {
    left: 0;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

#arena-paper-right {
    right: 0;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

#arena-paper-left.torn {
    clip-path: polygon(0 0, 48% 0, 52% 15%, 46% 30%, 53% 45%, 47% 60%, 54% 75%, 48% 90%, 50% 100%, 0 100%);
    transform: translateX(-100%);
    transition: clip-path 0.6s cubic-bezier(0.77, 0, 0.175, 1), transform 0.8s cubic-bezier(0.77, 0, 0.175, 1) 0.3s;
}

#arena-paper-right.torn {
    clip-path: polygon(52% 0, 100% 0, 100% 100%, 50% 100%, 48% 90%, 54% 75%, 47% 60%, 53% 45%, 46% 30%, 52% 15%);
    transform: translateX(100%);
    transition: clip-path 0.6s cubic-bezier(0.77, 0, 0.175, 1), transform 0.8s cubic-bezier(0.77, 0, 0.175, 1) 0.3s;
}

#arena-title {
    font-family: var(--font-display);
    font-size: 20vw;
    color: var(--ink-primary);
    letter-spacing: 0.05em;
    z-index: 3;
    display: flex;
    text-transform: uppercase;
    line-height: 1;
}

.arena-letter {
    opacity: 0;
    display: inline-block;
    transition: opacity 0.1s;
}

.arena-letter.visible {
    opacity: 1;
}

.arena-letter.shake {
    animation: screenShake 0.1s ease-in-out;
}

@keyframes screenShake {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-3px, 2px); }
    50% { transform: translate(3px, -2px); }
    75% { transform: translate(-2px, -1px); }
    100% { transform: translate(0, 0); }
}

/* --- VISIBLE GRID OVERLAY --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    padding: 0 calc((100% - 1200px) / 2);
}

.grid-line {
    width: 1px;
    height: 100%;
    background: var(--grid-rule);
    opacity: 0.2;
    transition: opacity 0.4s ease, background-color 0.4s ease, width 0.3s ease;
}

.grid-line.highlight {
    opacity: 0.5;
    background: var(--highlight-gold);
    width: 2px;
}

/* --- FROSTED NAVIGATION RIBBON --- */
#nav-ribbon {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: rgba(245, 240, 232, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#nav-ribbon.scrolled {
    border-bottom-color: var(--grid-rule);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.nav-wordmark {
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--ink-primary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-search {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background 0.2s;
}

.nav-search:hover {
    background: rgba(44, 62, 80, 0.08);
}

/* --- MAIN CONTENT --- */
#main-content {
    position: relative;
    z-index: 2;
    padding-top: 100vh;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- BATTLE CARDS --- */
.battle-card {
    position: relative;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    padding: 80px calc((100vw - 1200px) / 2);
    background: var(--frost-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--frost-border);
    margin-bottom: 0;
    perspective: 1000px;
}

.battle-card-inner {
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    /* Double rule border */
    border: 2px solid var(--corner-blue);
    outline: 1px solid var(--corner-blue);
    outline-offset: 3px;
    padding: 60px 48px;
    background: rgba(245, 240, 232, 0.5);
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

/* Crease fold marks */
.battle-card-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, rgba(93, 109, 126, 0.1), transparent);
    transform: rotate(0.5deg);
}

.battle-card-inner::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(93, 109, 126, 0.08), transparent);
}

/* --- CORNER STAMP --- */
.corner-stamp {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    background: repeating-radial-gradient(
        circle at 0 0,
        transparent 0,
        transparent 4px,
        var(--corner-blue) 4px,
        var(--corner-blue) 5px,
        transparent 5px,
        transparent 9px
    );
    background-size: 9px 9px;
}

.corner-stamp::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    background: var(--paper-base);
    border: 1px solid var(--corner-blue);
}

.stamp-number {
    position: relative;
    z-index: 1;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--corner-blue);
    font-weight: 700;
}

/* --- BATTLE TITLE --- */
.battle-title {
    font-family: var(--font-display);
    font-size: clamp(48px, 10vw, 144px);
    color: var(--ink-primary);
    text-align: center;
    letter-spacing: 0.04em;
    line-height: 1;
    margin-bottom: 48px;
    text-transform: uppercase;
}

/* --- BATTLE MATCHUP --- */
.battle-matchup {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    position: relative;
}

.combatant {
    flex: 1;
    max-width: 400px;
    text-align: center;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.combatant-left {
    transform: translateX(-80px);
}

.combatant-right {
    transform: translateX(80px);
}

.combatant.revealed {
    opacity: 1;
    transform: translateX(0);
}

.combatant-icon {
    margin-bottom: 16px;
}

.combatant-name {
    font-family: var(--font-secondary);
    font-size: clamp(28px, 5vw, 60px);
    color: var(--ink-primary);
    text-transform: uppercase;
    margin-bottom: 12px;
    line-height: 1.1;
}

.combatant-desc {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    color: var(--corner-blue);
}

/* --- VS MEDALLION --- */
.vs-medallion {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px dashed var(--corner-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--paper-base);
    flex-shrink: 0;
    align-self: center;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(-60px);
    transition: opacity 0.5s ease 0.3s, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s;
}

.vs-medallion.revealed {
    opacity: 1;
    transform: translateY(0);
}

.vs-text {
    font-family: var(--font-display);
    font-size: 32px;
    color: var(--battle-red);
    letter-spacing: 0.05em;
    /* Stencil-cut effect */
    text-shadow:
        2px 0 0 var(--paper-base),
        -2px 0 0 var(--paper-base),
        0 2px 0 var(--paper-base),
        0 -2px 0 var(--paper-base);
}

/* --- BATTLE RESULT --- */
.battle-result {
    text-align: center;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px dashed var(--grid-rule);
}

.result-label {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--corner-blue);
    letter-spacing: 0.12em;
    display: block;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.result-score {
    font-family: var(--font-mono);
    font-size: 28px;
    color: var(--ink-primary);
    letter-spacing: 0.08em;
    position: relative;
    display: inline-block;
}

.result-score.highlight-flash {
    animation: highlightFlash 0.5s ease;
}

@keyframes highlightFlash {
    0% { background: transparent; }
    30% { background: var(--highlight-gold); }
    100% { background: transparent; }
}

/* Typewriter cursor */
.result-score::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--ink-primary);
    margin-left: 4px;
    vertical-align: middle;
    animation: cursorBlink 0.6s step-end infinite;
}

.result-score.done::after {
    display: none;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- SKELETON LOADERS --- */
.skeleton-loader {
    position: absolute;
    top: 60px;
    left: 48px;
    right: 48px;
    bottom: 60px;
    z-index: 3;
    transition: opacity 0.4s ease, transform 0.6s ease;
}

.skeleton-loader.peeling {
    opacity: 0;
    transform: translateZ(20px) rotateX(-3deg);
}

.skeleton-loader.hidden {
    display: none;
}

.skeleton-title {
    height: 60px;
    background: linear-gradient(90deg, var(--skeleton-shimmer) 25%, var(--skeleton-shimmer-light) 50%, var(--skeleton-shimmer) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 40px;
    max-width: 70%;
    margin-left: auto;
    margin-right: auto;
}

.skeleton-combatants {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.skeleton-name {
    height: 120px;
    width: 35%;
    background: linear-gradient(90deg, var(--skeleton-shimmer) 25%, var(--skeleton-shimmer-light) 50%, var(--skeleton-shimmer) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-vs {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--skeleton-shimmer) 25%, var(--skeleton-shimmer-light) 50%, var(--skeleton-shimmer) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    flex-shrink: 0;
}

.skeleton-score {
    height: 30px;
    max-width: 200px;
    margin: 30px auto 0;
    background: linear-gradient(90deg, var(--skeleton-shimmer) 25%, var(--skeleton-shimmer-light) 50%, var(--skeleton-shimmer) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Battle content hidden until skeleton peels */
.battle-content {
    opacity: 0;
    transition: opacity 0.4s ease 0.2s;
}

.battle-card.loaded .battle-content {
    opacity: 1;
}

/* --- TORN EDGE --- */
.torn-edge {
    position: absolute;
    bottom: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: var(--darker-paper);
    clip-path: polygon(
        0% 0%, 2% 60%, 5% 20%, 8% 70%, 11% 10%, 14% 55%, 17% 30%, 20% 80%,
        23% 15%, 26% 65%, 29% 25%, 32% 75%, 35% 10%, 38% 60%, 41% 35%, 44% 85%,
        47% 20%, 50% 70%, 53% 15%, 56% 55%, 59% 30%, 62% 80%, 65% 10%, 68% 65%,
        71% 25%, 74% 75%, 77% 20%, 80% 60%, 83% 35%, 86% 85%, 89% 15%, 92% 70%,
        95% 25%, 98% 55%, 100% 0%
    );
    z-index: 1;
}

/* --- EDITORIAL DISPATCHES --- */
.editorial-dispatch {
    max-width: 720px;
    margin: 80px auto;
    padding: 0 24px;
    position: relative;
}

.dispatch-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    position: relative;
}

.dispatch-date {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--corner-blue);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.whistle-icon {
    flex-shrink: 0;
}

/* Coffee ring stain */
.coffee-ring {
    position: absolute;
    top: -20px;
    right: -10px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at center,
        transparent 30%,
        rgba(180, 140, 80, 0.06) 35%,
        rgba(180, 140, 80, 0.12) 40%,
        rgba(180, 140, 80, 0.04) 50%,
        transparent 55%
    );
    pointer-events: none;
}

/* Randomize coffee ring positions */
.battle-card:nth-child(3n) .coffee-ring {
    top: -30px;
    right: 20px;
    width: 90px;
    height: 90px;
}

.editorial-dispatch:nth-child(4n) .coffee-ring {
    top: -15px;
    right: -25px;
    width: 70px;
    height: 70px;
    transform: rotate(15deg);
}

.dispatch-text {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.65;
    color: var(--ink-primary);
    margin-bottom: 20px;
}

.dispatch-text:last-child {
    margin-bottom: 0;
}

.dispatch-signoff {
    font-style: italic;
    color: var(--corner-blue);
    font-size: 16px;
    margin-top: 32px;
}

/* --- DASHED DIVIDER --- */
.dashed-divider {
    width: 100%;
    height: 1px;
    border-top: 2px dashed var(--grid-rule);
    margin-top: 48px;
    position: relative;
}

.dashed-divider::before {
    content: '\2702';
    position: absolute;
    left: 0;
    top: -12px;
    font-size: 16px;
    color: var(--grid-rule);
}

/* --- EDITORIAL FINAL --- */
.editorial-final {
    padding-bottom: 120px;
    margin-bottom: 0;
}

.editorial-final .dashed-divider {
    display: none;
}

/* --- 3D CARD TILT ON HOVER --- */
.battle-card:hover .battle-card-inner {
    /* JS will handle dynamic values */
    transition: transform 0.1s ease;
}

/* --- RESPONSIVE --- */
@media (max-width: 1240px) {
    #grid-overlay {
        padding: 0 24px;
    }

    .battle-card {
        padding: 60px 24px;
    }

    .battle-card-inner {
        padding: 48px 32px;
    }
}

@media (max-width: 768px) {
    #arena-title {
        font-size: 28vw;
    }

    .battle-title {
        font-size: clamp(36px, 8vw, 72px);
        margin-bottom: 32px;
    }

    .battle-matchup {
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    .combatant {
        max-width: 100%;
    }

    .combatant-left {
        transform: translateX(-40px);
    }

    .combatant-right {
        transform: translateX(40px);
    }

    .combatant-name {
        font-size: clamp(24px, 7vw, 40px);
    }

    .vs-medallion {
        width: 60px;
        height: 60px;
        margin: 16px 0;
        transform: translateY(-30px);
    }

    .vs-text {
        font-size: 24px;
    }

    .battle-card-inner {
        padding: 40px 20px;
    }

    .skeleton-loader {
        top: 40px;
        left: 20px;
        right: 20px;
        bottom: 40px;
    }

    .editorial-dispatch {
        margin: 48px auto;
    }

    .corner-stamp {
        width: 44px;
        height: 44px;
    }

    .stamp-number {
        font-size: 9px;
    }

    #grid-overlay {
        display: none;
    }

    .nav-wordmark {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .battle-card {
        padding: 40px 12px;
    }

    .battle-card-inner {
        padding: 32px 16px;
        outline-offset: 2px;
    }

    .combatant-desc {
        font-size: 14px;
    }

    .dispatch-text {
        font-size: 16px;
    }
}
