/*
 * GAMES.CSS - Mobile-First Layout and Styling
 *
 * This file handles the responsive display of game rule cards
 * using CSS Grid and Flexbox, adhering to the mobile-first strategy.
 */

/* ========================================================= */
/* 1. Base Card Styling (Mobile-First: Single Column) */
/* ========================================================= */

.game-rules-card {
    /* Semantic container for the card component */
    display: flex;
    flex-direction: column;
    
    /* Aesthetics from common.css variables */
    border: 1px solid var(--border-color);
    background-color: var(--color-secondary); /* Inverse color for contrast on card */
    color: var(--color-primary); /* Primary text color on card */
    padding: 20px;
    margin-bottom: 20px;
    
    /* Visual depth and interactivity setup */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Subtle default shadow */
}

/* Interactivity: Card Lift on Hover/Focus */
.game-rules-card:hover,
.game-rules-card:focus-within {
    /* Pseudo-classes for visual feedback */
    transform: translateY(-5px);
    /* Enhances interactivity with a "lift" effect */
    
    /* Using a calculated color for the shadow to ensure visibility in both themes */
    /* Assumes a black shadow for visual depth, regardless of primary color */
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.4); 
}

.game-title {
    /* Ensures headings stand out within the card */
    font-family: var(--font-family-header);
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--color-primary); 
}

.game-objective {
    /* Subtle separator for the objective statement */
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 15px;
    font-size: 0.95em;
}


/* ========================================================= */
/* 2. Rule Item Styling (Flexbox for internal content) */
/* ========================================================= */

.rule-item {
    /* Mobile-First: Stacks term and description vertically */
    display: flex;
    flex-direction: column; 
    margin-bottom: 15px;
    padding-left: 10px; /* Indent for visual separation */
}

.rule-term {
    /* Ensures the term is clearly distinguished */
    font-weight: 900;
    font-size: 1.1em;
    margin-bottom: 5px;
}

/* ========================================================= */
/* 3. Progressive Disclosure (JS Toggle) Classes */
/* ========================================================= */

.rules-collapsible {
    /* Core CSS for the Read More/Less functionality */
    max-height: 200px; /* Initial height for 'clipping' long content on mobile */
    overflow: hidden;
    transition: max-height 0.4s ease-in-out;
    padding-bottom: 10px;
}

.rules-collapsible.is-expanded {
    /* When JS adds this class, the max-height expands to show all content */
    max-height: 2000px; /* Arbitrarily large value to reveal all content */
}

.rules-toggle-btn {
    /* Styling for the JavaScript-inserted button */
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--color-primary);
    background-color: var(--color-secondary);
    color: var(--color-primary);
    cursor: pointer;
    font-family: var(--font-family-body);
    font-size: 1em;
    text-align: center;
}

.rules-toggle-btn:hover {
    /* Subtle interaction feedback */
    background-color: var(--color-primary);
    color: var(--color-secondary);
    opacity: 0.8; 
}

.rules-toggle-btn:focus {
    /* Accessibility Focus Indicator */
    outline: 2px dashed var(--color-primary);
    outline-offset: 2px;
}

/* ========================================================= */
/* 4. Layout Grid and Responsive Media Queries */
/* ========================================================= */

.game-library-grid {
    /* Default: Mobile-First Single Column */
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

/* 4.1. Intermediate/Tablet Breakpoint: Transition to Two-Column Grid */
/* Min-width: 480px accommodates most modern mobiles (e.g., iPhone 15 Pro, 393px width) and tablets */
@media (min-width: 480px) {
    
    .game-library-grid {
        /* CSS Grid Layout Module: Auto-fit for flexible column sizing */
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        /* Cards will wrap efficiently, ensuring a minimum card width of 280px */
    }

    /* Card Layout Shift: Transition to Side-by-Side (Image on left, Text on right) 
       This is a conceptual rule for future image integration.
    .game-rules-card {
        flex-direction: row; 
    }
    .game-rules-card > * {
        flex-basis: 50%;
    } */

    /* Rule Item Layout Shift: Switch to Side-by-Side (Term on left, Description on right) */
    .rule-item {
        /* CSS Flexible Box Layout Module: Term and Description side-by-side */
        flex-direction: row;
        padding-left: 0;
        gap: 10px; /* Space between term and description */
    }

    .rule-term {
        /* Fix the width of the term column for alignment */
        flex: 0 0 120px; 
        margin-bottom: 0;
    }
}


/* 4.2. Desktop Breakpoint: Transition to Three-Column Grid */
/* Min-width: 950px provides ample room for a cleaner desktop/large tablet layout */
@media (min-width: 950px) {
    .game-library-grid {
        /* CSS Grid Layout Module: Three explicit columns */
        grid-template-columns: repeat(3, 1fr);
    }
}


/* ========================================================= */
/* 5. Rules of Engagement (CSS Grid Layout) */
/* ========================================================= */

.rules-of-engagement-grid {
    /* Mobile-First Default: Single column */
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 40px;
    text-align: center;
}

.rules-of-engagement-grid dl {
    /* Each rule is a definition list, styled as a card */
    background-color: var(--color-secondary);
    color: var(--color-primary);
    border: 1px solid var(--border-color);
    padding: 15px;
    transition: box-shadow 0.3s ease;
}

.rule-principle {
    /* Definition Term (The Principle) */
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 5px;
}

.rule-description {
    /* Definition Description (The Rule Text) */
    margin-left: 0;
    font-size: 0.9em;
    padding-top: 5px;
    border-top: 1px dashed rgba(var(--color-primary-rgb), 0.1);
}

.rule-source {
    /* Citation style */
    display: block;
    margin-top: 5px;
    opacity: 0.7;
    font-style: italic;
    text-align: center;
}

/* Media Query: Desktop/Large Tablet Layout (Two-Column) */
@media (min-width: 768px) {
    .rules-of-engagement-grid {
        /* CSS Grid Layout Module: Two equal columns */
        grid-template-columns: repeat(2, 1fr);
    }
}