/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #000000;
    color: #ffffff;
    line-height: 1.6;
}

/* Header */
header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: #000000;
    position: relative;
    height: 120px;
    width: 100%;
}

.logo {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.logo img {
    width: 120px;
}

nav ul {
    list-style-type: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

nav ul li {
    margin: 0 20px;
}

nav ul li a {
    text-decoration: none;
    color: #ffffff;
    font-weight: bold;
    font-size: 1.1rem;
    padding: 12px 20px;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

nav ul li a:not(.active):hover {
    color: #4a90e2;
    border: 3px solid transparent;
    background: 
        linear-gradient(rgba(26, 26, 26, 0.8), rgba(45, 45, 45, 0.8)) padding-box,
        linear-gradient(90deg, 
            var(--primary-color, #4a90e2),
            rgba(74, 144, 226, 0.3),
            var(--primary-color, #4a90e2),
            rgba(74, 144, 226, 0.3),
            var(--primary-color, #4a90e2)
        ) border-box;
    background-size: 100%, 200% 100%;
    animation: flowingBorder 2s linear infinite;
}

nav ul li a.active {
    color: #4a90e2;
    font-weight: 900;
    position: relative;
    overflow: hidden;
    border: 3px solid transparent;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) padding-box,
                linear-gradient(45deg, #4a90e2, #4a90e2, #4a90e2, #4a90e2) border-box;
    background-size: 100% 100%, 400% 400%;
    animation: navFlowingBorder 15s ease-in-out infinite;
    box-shadow: 
        0 0 20px rgba(74, 144, 226, 0.4),
        0 8px 25px rgba(74, 144, 226, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Keyframes for navigation flowing border */
@keyframes navFlowingBorder {
    0% {
        background-position: 0% 0%, 0% 0%;
    }
    25% {
        background-position: 0% 0%, 100% 0%;
    }
    50% {
        background-position: 0% 0%, 100% 100%;
    }
    75% {
        background-position: 0% 0%, 0% 100%;
    }
    100% {
        background-position: 0% 0%, 0% 0%;
    }
}

/* Rules Hero Section */
.guide-hero {
    height: 300px;
    background-image: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('../bilder/bakgrunn-regler.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.guide-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.guide-hero h1 {
    font-size: 3.5rem;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Intro Section */
.intro-section {
    background-color: #1a1a1a;
    padding: 40px 20px;
    margin-bottom: 40px;
}

.intro-content {
    max-width: 800px;
    margin: 0 auto;
    color: #ffffff;
    line-height: 1.8;
}

.intro-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Rules Container */
.guides-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.guide-section {
    margin-bottom: 60px;
}

.guide-section h2 {
    color: #4a90e2;
    font-size: 1.8rem;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4a90e2;
}

/* Collapsible section styles (match /regler) */
.rule-section-wrapper {
    margin-bottom: 15px;
}

.section-header {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    padding: 8px 15px;
    border: 2px solid #4a90e2;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.section-header:hover {
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%);
    border-color: #6bb6ff;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.3);
}

.section-header h2 {
    color: #4a90e2;
    font-size: 1.1rem;
    margin: 0;
    padding: 0;
    border: none;
}

.toggle-icon {
    color: #4a90e2;
    font-size: 0.9rem;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.rule-section {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.4s ease;
    max-height: 5000px;
    opacity: 1;
}

.rule-section.collapsed {
    max-height: 0;
    opacity: 0;
}

.guides-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Rule Item and Click Effects */
.guide-item {
    position: relative;
}

.guide-title {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    padding: 20px 25px;
    border-radius: 12px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    border: 2px solid rgba(74, 144, 226, 0.3);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.guide-title::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(74, 144, 226, 0.2), transparent);
    transition: left 0.5s ease;
}

/* New flowing border effect */
.guide-title {
    position: relative;
    border: 3px solid transparent;
    background: 
        linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) padding-box,
        linear-gradient(90deg, 
            var(--primary-color, #4a90e2),
            rgba(74, 144, 226, 0.3),
            var(--primary-color, #4a90e2),
            rgba(74, 144, 226, 0.3),
            var(--primary-color, #4a90e2)
        ) border-box;
    background-size: 100% 100%, 200% 100%;
}

.guide-title:hover {
    background: 
        linear-gradient(135deg, #2d2d2d 0%, #404040 100%) padding-box,
        linear-gradient(90deg, 
            var(--primary-color, #4a90e2),
            rgba(74, 144, 226, 0.3),
            var(--primary-color, #4a90e2),
            rgba(74, 144, 226, 0.3),
            var(--primary-color, #4a90e2)
        ) border-box;
    background-size: 100% 100%, 200% 100%;
    animation: flowingBorder 2s linear infinite;
    transform: translateY(-2px);
    box-shadow: 
        0 0 20px rgba(74, 144, 226, 0.6),
        0 8px 25px rgba(74, 144, 226, 0.3),
        0 4px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.guide-title:hover::before {
    left: 100%;
}

.guide-title:active {
    transform: translateY(-1px);
    transition: transform 0.1s ease;
}

@keyframes flowingBorder {
    0% {
        background-position: center, 0% center;
    }
    100% {
        background-position: center, 200% center;
    }
}

/* Rule Explanation Styling */
.guide-explanation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 90%;
    max-width: 600px;
    background: linear-gradient(145deg, #1a1a1a 0%, #2d2d2d 100%);
    padding: 30px;
    border-radius: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 8px 20px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-height: 80vh;
    overflow-y: auto;
    border: 2px solid rgba(74, 144, 226, 0.5);
    backdrop-filter: blur(20px);
}

.guide-explanation.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.guide-explanation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4a90e2, transparent);
    border-radius: 20px 20px 0 0;
}

.guide-explanation h3 {
    color: #4a90e2;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(74, 144, 226, 0.3);
    font-size: 1.3rem;
    font-weight: 600;
    padding-right: 50px; /* Make room for close button */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.guide-explanation p {
    color: #ffffff;
    line-height: 1.8;
    font-size: 1rem;
    margin-bottom: 15px;
    /* Preserve newlines and multiple spaces like /regler */
    white-space: pre-wrap;
}

.rule-explanation p strong {
    color: #4a90e2;
    font-weight: 600;
}

.guide-explanation li {
    color: #ffffff;
    margin-bottom: 8px;
    line-height: 1.6;
}

.guide-details {
    white-space: pre-wrap;
}

/* Close Button */
.close-button {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4a90e2 0%, #6bb6ff 100%);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    box-shadow: 
        0 4px 15px rgba(74, 144, 226, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.close-button:hover {
    /* Use primary blue hover (match /regler) */
    background: var(--primary-color, #4a90e2);
    color: #000;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 
        0 6px 20px rgba(74, 144, 226, 0.6),
        0 3px 6px rgba(0, 0, 0, 0.3);
}

.close-button:active {
    transform: scale(0.95) rotate(90deg);
}

.guide-explanation-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.9) 100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999;
    backdrop-filter: blur(8px);
}

.guide-explanation-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Scrollbar styling */
.guide-explanation::-webkit-scrollbar {
    width: 8px;
}

.guide-explanation::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.guide-explanation::-webkit-scrollbar-thumb {
    background: #4a90e2;
    border-radius: 4px;
}

.guide-explanation::-webkit-scrollbar-thumb:hover {
    background: #218838;
}

/* Footer */
footer {
    background-color: #0a0a0a;
    color: #ffffff;
    padding: 60px 0 20px 0;
    margin-top: 60px;
    width: 100vw;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    gap: 40px;
    width: 100%;
}

.footer-section {
    flex: 1;
    min-width: 200px;
}

.footer-section h4 {
    color: #4a90e2;
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.footer-section p {
    color: #fff;
    line-height: 1.6;
    font-size: 0.95rem;
}

.footer-section p a {
    color: #4a90e2;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

.footer-section p a:hover {
    color: #6bb6ff;
    text-decoration: underline;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 12px;
}

.footer-section ul li a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 0.95rem;
}

.footer-section ul li a:hover {
    color: #4a90e2;
}

.social-links {
    display: flex;
    gap: 20px;
}

.social-links a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: #4a90e2;
}

.footer-bottom {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #222;
    text-align: center;
    width: 100%;
    background-color: #0a0a0a;
}

.footer-bottom p {
    color: #fff;
    font-size: 0.9rem;
}

/* Media Queries */
@media (max-width: 1200px) {
    .rules-container {
        padding: 0 30px;
    }
    
    .footer-container {
        padding: 0 30px;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        height: auto;
        padding: 20px;
    }

    .logo {
        position: static;
        transform: none;
        margin-bottom: 20px;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    nav ul li {
        margin: 5px 10px;
    }

    .rules-hero h1 {
        font-size: 2.5rem;
    }

    .rules-grid {
        grid-template-columns: 1fr;
    }

    .rule-explanation {
        width: 95%;
        padding: 20px;
        margin: 10px;
        max-height: 90vh;
    }

    .rule-title {
        padding: 12px 16px;
    }

    .rule-title:hover {
        transform: translateX(5px);
    }

    .rule-item {
        margin-bottom: 20px;
    }

    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }

    .social-links {
        justify-content: center;
    }

    .close-button {
        top: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    .rules-hero h1 {
        font-size: 2rem;
    }

    .intro-content p {
        font-size: 1rem;
    }

    .rule-section h2 {
        font-size: 1.5rem;
    }

    .rule-title {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .rule-explanation {
        padding: 15px;
    }

    .rule-explanation h3 {
        font-size: 1rem;
    }

    .rule-explanation p {
        font-size: 0.9rem;
    }

    .close-button {
        width: 25px;
        height: 25px;
        font-size: 16px;
    }
}
