/* ==========================================
   1. GRUNDINSTÄLLNINGAR & VARIABLER
   ========================================== */
:root {
    --gold: #d4af37;
    --wood: #4a332d;
    --bg-dark: #1a1a1a;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle, #2c1e14 0%, #000000 100%);
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

/* Fix för rullning: Datorn är "låst", mobilen scrollar fritt */
@media (min-width: 1025px) {
    body { height: 100vh; overflow: hidden; }
}

/* 2. SITE BANNER */
.site-banner {
    position: fixed;
    top: 0; width: 100%; z-index: 500;
    background: linear-gradient(to bottom, rgba(0,0,0,0.95) 70%, transparent 100%);
    text-align: center; padding: 25px 0;
}

.site-banner h1 {
    margin: 0; font-size: 2.2rem; color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 2px; text-transform: uppercase;
}

/* 3. FÖNSTERKOMPONENTER */
.guestbook-sidebar, .news-sidebar, .main-stage {
    background: rgba(15, 15, 15, 0.85);
    border: 3px solid var(--wood);
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(0,0,0,1), inset 0 0 60px rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    box-sizing: border-box;
}

.timer-container { 
    padding: 20px; 
    background: rgba(44, 30, 20, 0.4); 
    border: 1px solid var(--wood); 
    border-radius: 10px; 
    text-align: center; 
    margin: 20px 0; 
}

.countdown-timer { 
    font-size: 2.2rem; 
    font-family: monospace; 
    color: var(--gold); 
    font-weight: bold; 
}

/* 4. DATOR-LAYOUT (> 1024px) */
@media (min-width: 1025px) {
    .battlefield {
        display: flex; justify-content: center; align-items: center; 
        height: 100vh; padding-top: 80px; padding-bottom: 220px; gap: 20px;
    }
    .guestbook-sidebar, .news-sidebar { width: 20%; max-width: 300px; height: 60dvh; padding: 20px; }
    .main-stage { width: 45%; max-width: 850px; height: 60dvh; padding: 40px; }

    .player-hand { display: flex; justify-content: center; align-items: flex-end; position: fixed; bottom: 0; width: 100%; height: 220px; z-index: 100; }
    .card-wrapper { width: 75px; height: 220px; position: relative; display: flex; align-items: flex-end; justify-content: center; }
    
    .hand-card {
        width: 120px; height: 170px; background-image: url('hpback.png');
        background-size: cover; border-radius: 10px; border: 3px solid #000;
        position: absolute; bottom: 20px; transition: transform 0.4s;
        display: flex; justify-content: center; align-items: flex-end; padding-bottom: 15px; text-decoration: none;
    }
    .hand-card span { background: rgba(0, 0, 0, 0.85); color: white; padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; border: 1px solid var(--wood); }
    
    /* Rotationer på datorn */
    .card-wrapper:nth-child(1) .hand-card { transform: rotate(-25deg) translateY(45px); }
    .card-wrapper:nth-child(2) .hand-card { transform: rotate(-18deg) translateY(25px); }
    .card-wrapper:nth-child(3) .hand-card { transform: rotate(-10deg) translateY(10px); }
    .card-wrapper:nth-child(4) .hand-card { transform: rotate(0deg)   translateY(0px); }
    .card-wrapper:nth-child(5) .hand-card { transform: rotate(10deg)  translateY(10px); }
    .card-wrapper:nth-child(6) .hand-card { transform: rotate(18deg)  translateY(25px); }
    .card-wrapper:nth-child(7) .hand-card { transform: rotate(25deg)  translateY(45px); }

    .card-wrapper:hover { z-index: 600; }
    .card-wrapper:hover .hand-card { transform: rotate(0deg) translateY(-120px) scale(1.4); border-color: var(--gold); }
}

/* 5. MOBIL-LAYOUT (Fixar ordningen!) */
@media (max-width: 1024px) {
    body { overflow-y: auto; }
    .site-banner h1 { font-size: 1.2rem; }
    .battlefield { 
        display: flex; flex-direction: column; 
        padding: 90px 10px 150px 10px; gap: 20px; height: auto;
    }

    /* ÄNDRA ORDNINGEN HÄR */
    .main-stage { order: 1; width: 100%; min-height: 400px; padding: 20px; }
    .news-sidebar { order: 2; width: 100%; padding: 20px; height: auto; }
    .guestbook-sidebar { order: 3; width: 100%; padding: 20px; height: auto; }

    .player-hand {
        display: flex; justify-content: center; align-items: center;
        position: fixed; bottom: 0; left: 0; width: 100%; height: 110px;
        background: rgba(10, 10, 10, 0.98); border-top: 2px solid var(--wood);
        z-index: 9999; gap: 5px; padding: 0 5px;
    }
    .card-wrapper { width: 13.5%; height: 90px; }
    .hand-card {
        width: 100%; height: 100%; background-image: url('hpback.png');
        background-size: cover; border: 1px solid var(--gold); border-radius: 5px;
        display: flex; align-items: flex-end; justify-content: center;
        text-decoration: none; transform: none !important;
    }
    .hand-card span { background: rgba(0,0,0,0.8); font-size: 0.5rem; color: white; width: 90%; text-align: center; margin-bottom: 5px; }
    .countdown-timer { font-size: 1.6rem; }
}

/* 6. KONTAKTFORMULÄR & SOCIALA MEDIER */
.contact-container { display: flex; gap: 30px; align-items: flex-start; margin-top: 20px; text-align: left; }
@media (max-width: 1024px) { .contact-container { flex-direction: column; } }

.contact-form { flex: 1; width: 100%; }
.contact-form input, .contact-form textarea { 
    width: 100%; padding: 12px; margin-bottom: 10px; 
    background: rgba(0,0,0,0.5); border: 1px solid var(--wood); 
    color: white; border-radius: 5px; box-sizing: border-box; 
}
.contact-social { width: 200px; flex-shrink: 0; text-align: center; }
@media (max-width: 1024px) { .contact-social { width: 100%; } }

/* 7. DÄCK-GALLERI & MODAL */
.deck-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; padding-top: 20px; }
@media (max-width: 1024px) { .deck-grid { grid-template-columns: repeat(2, 1fr); } }

.deck-thumbnail { width: 100%; border-radius: 8px; border: 2px solid var(--wood); cursor: pointer; transition: border-color 0.3s; }
.deck-thumbnail:hover { border-color: var(--gold); }
.deck-caption { margin-top: 8px; font-size: 0.85rem; color: #f0e6d2; text-align: center; }

/* Uppdaterad sektion för årtals-navigering */
.year-nav { 
    display: grid; 
    /* Skapar kolumner som är minst 85px breda. Fyller ut raden automatiskt */
    grid-template-columns: repeat(auto-fit, minmax(85px, 1fr)); 
    gap: 10px; 
    margin-bottom: 25px; 
    width: 100%;
}

.year-nav button { 
    background: var(--wood); 
    color: white; 
    border: 1px solid #000; 
    padding: 10px 5px; /* Lite mindre padding på sidorna för att få plats */
    cursor: pointer; 
    border-radius: 5px; 
    transition: 0.3s; 
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
}

.year-nav button.active { 
    background: var(--gold) !important; 
    color: black !important; 
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

.year-nav button:hover {
    background: #5d4239; /* Lite ljusare brun vid hover */
    border-color: var(--gold);
}

/* Mobiljustering: Om skärmen är väldigt smal, gör 3 kolumner fastställt */
@media (max-width: 400px) {
    .year-nav {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .year-nav button {
        font-size: 0.8rem;
    }
}


.modal { 
    display: none; position: fixed; z-index: 10000; left: 0; top: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.95); justify-content: center; align-items: center; flex-direction: column; 
}
#modal-img { 
    max-width: 90%; 
    max-height: 80vh; 
    border: 3px solid white; 
    box-shadow: 0 0 30px rgba(0,0,0,0.5); 
    /* NYTT FÖR ZOOM: */
    touch-action: pinch-zoom; 
    object-fit: contain;
}

#modal-caption { 
    text-align: center; 
    color: white; 
    margin-top: 15px; 
    font-weight: bold; 
    font-size: 1.2rem; 
}

/* Gör så att bildgalleriet också använder grid-systemet - NU MED AUTO-FIT */
#picture-gallery {
    display: grid;
    /* Automatiskt antal kolumner, bilderna blir minst 150px breda men fyller ut */
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    padding-top: 20px;
}


/* Länkar */
.tournament-link, .rules-link { color: var(--gold); text-decoration: none; font-weight: bold; }
.tournament-link:hover, .rules-link:hover { text-decoration: underline; }

/* Styling för Lightbox-navigering */
.modal-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Grundstyling för pilarna (Dator) */
.modal-prev, .modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--gold);
    border: 2px solid var(--gold);
    font-size: 30px;
    padding: 15px 20px;
    cursor: pointer;
    border-radius: 5px;
    z-index: 10005;
    transition: 0.3s;
    user-select: none; /* Hindrar att man markerar text när man klickar snabbt */
}

.modal-prev { left: 20px; }
.modal-next { right: 20px; }

/* Mobilanpassning för pilarna */
@media (max-width: 1024px) {
    .modal-prev, .modal-next {
        top: auto;
        bottom: 10px; /* Flyttar ner dem till botten */
        transform: none;
        padding: 10px 25px;
        font-size: 24px;
        background: var(--wood); /* Gör dem lite tydligare på mobilen */
    }

    .modal-prev {
        left: 10%; /* Placeras till vänster om bildtexten */
    }

    .modal-next {
        right: 10%; /* Placeras till höger om bildtexten */
    }

    /* Justera containern så bilden får plats ovanför pilarna */
    .modal-image-container {
        margin-bottom: 60px; 
    }
    
    #modal-img {
        max-height: 65vh; /* Gör bilden lite mindre så pilarna får plats under */
    }
}


.modal-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: white;
    font-size: 50px;
    cursor: pointer;
    z-index: 10006;
}

.alert-text {
    color: #ff4444;
    font-weight: bold;
    border: 1px solid #ff4444;
    padding: 10px;
    margin-top: 10px;
}

/* Gör alla partner/sociala bilder enhetliga */
.contact-social img {
    width: 120px !important; /* Bestämmer en fast bredd för alla */
    height: auto;
    border: 2px solid var(--gold); /* Ger alla samma guldram */
    border-radius: 8px;
    background: white; /* Bra för QR-koder och loggor med transparens */
    padding: 5px;
    box-sizing: border-box;
    transition: transform 0.3s;
}

.contact-social img:hover {
    transform: scale(1.05); /* En liten effekt när man hovrar */
}


.links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.old-school-link {
    text-decoration: none;
    color: white;
}

.link-card {
    background: rgba(44, 30, 20, 0.6);
    border: 2px solid var(--wood);
    padding: 15px;
    border-radius: 8px;
    transition: 0.3s;
    text-align: center;
}

.link-card:hover {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.1);
    transform: translateY(-3px);
}

.link-title {
    display: block;
    color: var(--gold);
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.link-desc {
    font-size: 0.8rem;
    color: #ccc;
    font-style: italic;
}
