/**
 * ============================================================================
 * WALT DISNEY WORLD DAILY TRIVIA - Main Stylesheet
 * ============================================================================
 * This stylesheet defines all visual styling for the trivia application.
 * Theme colors, animations, responsive layouts, and modal styling are
 * centralized here for easy customization.
 *
 * Structure:
 * 1. Theme variables and fonts
 * 2. Main page layout and components
 * 3. Category card styling
 * 4. Modal overlay and dialog styling
 * 5. Answer buttons and feedback
 * 6. Decorative images (Mickey and Minnie)
 * 7. Responsive breakpoints
 */

/**
 * ============================================================================
 * CSS CUSTOM PROPERTIES (VARIABLES)
 * ============================================================================
 * All themeable colors are defined as CSS variables at the root level.
 * Change these values to quickly re-skin the entire site.
 */
:root {
    /* Primary color palette */
    --bg: #8ee7ff;                                /* Sky blue background */
    --tile: #7a4ff2;                              /* Default category tile color (purple) */
    --tile-hover: #6b41e7;                        /* Hover state for tiles */
    --tile-active: #5f37dc;                       /* Active/clicked state for tiles */
    --text: #111;                                 /* Main text color (near black) */
    --tile-text: #fff;                            /* Text on category tiles (white) */
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.08);   /* Consistent shadow for elevated elements */
    --radius: 22px;                               /* Border radius for rounded corners */

    /* Modal styling */
    --panel-bg: rgba(255, 255, 255, 0.92);       /* Semi-transparent white background */
    --panel-border: rgba(0, 0, 0, 0.08);         /* Subtle border color */

    /* Primary site font stack (Waltograph is the Disney-branded font) */
    --font-disney: "Waltograph", "Waltograph42", "Waltograph UI", "Comic Sans MS", cursive;
}

/**
 * ============================================================================
 * FONT LOADING
 * ============================================================================
 * Waltograph is the signature Disney font family.
 * Attempts to use locally installed fonts first, then falls back to web fonts.
 * Includes multiple file formats for broad browser compatibility.
 */
/* Waltograph font loading:
   - `local(...)` uses the visitor's installed font (if present)
   - `url(...)` serves the font from this repo for everyone else
   Note: GitHub Pages is case-sensitive, so we include lowercase variants. */
@font-face {
    font-family: "Waltograph";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src:
        local("Waltograph"),
        local("Waltograph42"),
        url("../assets/fonts/Waltograph.woff2") format("woff2"),
        url("../assets/fonts/waltograph.woff2") format("woff2"),
        url("../assets/fonts/Waltograph42.woff2") format("woff2"),
        url("../assets/fonts/Waltograph.woff") format("woff"),
        url("../assets/fonts/waltograph.woff") format("woff"),
        url("../assets/fonts/Waltograph42.woff") format("woff"),
        url("../assets/fonts/Waltograph.ttf") format("truetype"),
        url("../assets/fonts/waltograph.ttf") format("truetype"),
        url("../assets/fonts/Waltograph42.ttf") format("truetype"),
        url("../assets/fonts/Waltograph.otf") format("opentype"),
        url("../assets/fonts/Waltograph42.otf") format("opentype"),
        url("../assets/fonts/waltograph.otf") format("opentype"),
        url("../assets/fonts/waltograph42.otf") format("opentype");
}

/* Some Waltograph downloads register as "Waltograph42" instead of "Waltograph". */
@font-face {
    font-family: "Waltograph42";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src:
        local("Waltograph42"),
        local("Waltograph"),
        url("../assets/fonts/Waltograph42.woff2") format("woff2"),
        url("../assets/fonts/Waltograph.woff2") format("woff2"),
        url("../assets/fonts/Waltograph42.woff") format("woff"),
        url("../assets/fonts/Waltograph.woff") format("woff"),
        url("../assets/fonts/Waltograph42.ttf") format("truetype"),
        url("../assets/fonts/Waltograph.ttf") format("truetype"),
        url("../assets/fonts/Waltograph42.otf") format("opentype"),
        url("../assets/fonts/waltograph42.otf") format("opentype"),
        url("../assets/fonts/Waltograph.otf") format("opentype"),
        url("../assets/fonts/waltograph.otf") format("opentype");
}

/**
 * ============================================================================
 * GLOBAL STYLES
 * ============================================================================
 * Base styling for all elements, body, and document structure.
 */

/* Apply border-box sizing model to all elements for predictable layouts */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-disney);
}

/**
 * ============================================================================
 * MODAL STYLING
 * ============================================================================
 * The modal overlay is the dialog box that displays questions and answer
 * choices. It's hidden by default and opened via JavaScript when a
 * category button is clicked.
 */

/* Modal overlay (opened by JS by toggling [data-open="true"]) */
.modal {
    position: fixed;
    inset: 0;
    display: none;                         /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 50;                          /* Above all page content */
}

/* Show modal when data-open="true" is set by JavaScript */
.modal[data-open="true"] {
    display: flex;
}

/* Semi-transparent backdrop behind modal content */
.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(3px);            /* Frosted glass effect */
}

/* Main modal panel/dialog box */
.modal__panel {
    position: relative;
    width: min(760px, 94vw);               /* Responsive width: 760px max or 94% of viewport */
    border-radius: 18px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
    overflow: hidden;
}

/* Header section containing title and close button */
.modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 18px 0;
}

.modal__kicker {
    font-family: var(--font-disney);
    font-size: 20px;
    letter-spacing: 0.4px;
    opacity: 0.85;
}

.modal__title {
    margin: 2px 0 0;
    font-family: var(--font-disney);
    font-weight: 400;
    font-size: 40px;
    line-height: 1.05;
}

/* Close button in top-right corner of modal */
.icon-btn {
    appearance: none;
    border: 0;
    background: transparent;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: rgba(0, 0, 0, 0.7);
    transition: background-color 140ms ease, color 140ms ease;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.85);
}

.icon-btn:focus-visible {
    outline: 3px solid rgba(0, 0, 0, 0.35);
    outline-offset: 2px;
}

/* Body section containing question and answer choices */
.modal__body {
    padding: 14px 18px 18px;
}

/* Question text styling */
.question {
    margin: 0 0 14px;
    font-family: var(--font-disney);
    font-size: 26px;
    line-height: 1.22;
    letter-spacing: 0.2px;
}

/**
 * ============================================================================
 * ANSWER BUTTONS AND FEEDBACK
 * ============================================================================
 * Answer buttons are dynamically created by JavaScript and marked with
 * data-state="correct|wrong" after the user clicks them.
 */

/* Container for answer choice buttons (displays as grid) */
.answers {
    display: grid;
    gap: 10px;
}

/* Individual answer choice buttons */
.answer-btn {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    padding: 12px 12px;
    text-align: center;
    cursor: pointer;
    font-family: var(--font-disney);
    font-size: 24px;
    line-height: 1.1;
    transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

/* Hover effect: slight upward movement and border highlight */
.answer-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 0, 0, 0.18);
}

/* Disabled state: no hover effects, reduced opacity */
.answer-btn[disabled] {
    cursor: default;
    transform: none;
    opacity: 0.75;
}

/* Correct answer styling: green background and border */
.answer-btn[data-state="correct"] {
    background: rgba(46, 204, 113, 0.18);  /* Semi-transparent green */
    border-color: rgba(46, 204, 113, 0.55);
}

/* Wrong answer styling: red background and border */
.answer-btn[data-state="wrong"] {
    background: rgba(231, 76, 60, 0.18);   /* Semi-transparent red */
    border-color: rgba(231, 76, 60, 0.55);
}

/* Feedback message (success/failure text) */
.feedback {
    margin: 12px 0 0;
    min-height: 22px;
    font-family: var(--font-disney);
    font-size: 22px;
    line-height: 1.15;
}

.modal__footer {
    padding: 0 18px 18px;
    display: flex;
    justify-content: flex-end;
}

.secondary-btn {
    appearance: none;
    border: 0;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 14px;
    padding: 10px 14px;
    cursor: pointer;
    font-family: var(--font-disney);
    font-size: 22px;
    letter-spacing: 0.2px;
    transition: background-color 120ms ease, transform 120ms ease;
}

.secondary-btn:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.secondary-btn:active {
    transform: translateY(0);
}

.secondary-btn:focus-visible {
    outline: 3px solid rgba(0, 0, 0, 0.35);
    outline-offset: 2px;
}

/**
 * ============================================================================
 * MAIN PAGE LAYOUT
 * ============================================================================
 * The main page layout is a centered grid container with the title at the top
 * and the 3×3 category grid below.
 */

/* Main page container with centered layout */
.page {
    width: min(880px, 92vw);               /* 880px max on desktop, 92% on mobile */
    margin: 0 auto;                        /* Horizontal centering */
    padding: clamp(28px, 4vw, 56px) 0 clamp(32px, 6vw, 72px);  /* Vertical padding, scales responsively */
    display: grid;
    justify-items: center;
    gap: clamp(18px, 3.2vw, 34px);        /* Gap between title and category grid */
    position: relative;
    z-index: 1;                           /* Above decorative images */
}

/* Main page title */
.title {
    margin: 0;
    text-align: center;
    font-family: var(--font-disney);
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: 0.5px;
    font-size: clamp(40px, 5vw, 64px);   /* Scales responsively from 40px to 64px */
}

/**
 * ============================================================================
 * CATEGORY GRID AND CARDS
 * ============================================================================
 * The 3×3 grid of clickable category buttons. Uses CSS Grid for
 * responsive layout that adapts to smaller screens.
 */

/* 3x3 grid container for category cards */
.category-grid {
    width: fit-content;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, auto);  /* Three equal columns */
    gap: clamp(18px, 3vw, 30px);             /* Responsive gap between cards */
    justify-content: center;
    justify-items: center;
}

/* Individual category card / button */
.category-card {
    appearance: none;                     /* Remove default button styling */
    border: 0;
    background: var(--tile);              /* Purple by default */
    color: var(--tile-text);              /* White text */
    border-radius: var(--radius);         /* Rounded corners */
    box-shadow: var(--shadow);            /* Subtle drop shadow */
    width: 210px;
    height: clamp(92px, 11vw, 128px);    /* Responsive height based on viewport */
    padding: 18px 16px;
    display: grid;                        /* Center content both ways */
    place-items: center;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: transform 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

/* Label text inside category card */
.category-card__label {
    font-family: var(--font-disney);
    font-weight: 400;
    line-height: 1.1;
    font-size: clamp(20px, 2.25vw, 30px);  /* Scales responsively */
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

/* Card styling when user answers correctly (answer is marked correct) */
.category-card[data-state="correct"] {
    background: rgba(46, 204, 113, 1);   /* Green */
    box-shadow: none;
    cursor: pointer;
}

/* Card styling when user answers incorrectly (answer is marked wrong) */
.category-card[data-state="wrong"] {
    background: rgba(231, 76, 60, 1);    /* Red */
    box-shadow: none;
    cursor: pointer;
}

/* Hover effect for unanswered cards (not [data-state] = no answer yet) */
.category-card:not([disabled]):not([data-state]):hover {
    background: var(--tile-hover);       /* Darker purple */
    transform: translateY(-1px);         /* Slight upward movement */
}

/* Active/click state */
.category-card:not([disabled]):active {
    background: var(--tile-active);      /* Even darker purple */
    transform: translateY(0);            /* Return to normal position */
}

/* Focus state for keyboard navigation */
.category-card:not([disabled]):focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.9);
    outline-offset: 3px;
}

/* Respect user's motion preference (accessibility) */
@media (prefers-reduced-motion: reduce) {
    .category-card {
        transition: none;
    }
}

/* Decorative Mickey image on the right side of the screen */
/* EDITED: Added .minnie-figure to share dimensions and base styling */
.mickey-figure,
.minnie-figure {
    position: fixed;
    top: 49%;
    transform: translateY(-50%);
    max-height: clamp(450px, 42vh, 800px);  /* Responsive height: 450px to 800px */
    width: auto;                             /* Maintain aspect ratio */
    pointer-events: none;                    /* Don't interfere with clicks */
    user-select: none;                       /* Can't select as text */
    z-index: 0;                             /* Behind all page content */
}

/* Mickey on the right side */
.mickey-figure {
    right: max(30px, 2vw);                  /* 30px minimum, or 2% of viewport width */
}

/* Minnie on the left side */
.minnie-figure {
    left: max(60px, 2vw);
}

/**
 * ============================================================================
 * RESPONSIVE BREAKPOINTS (MEDIA QUERIES)
 * ============================================================================
 * Layout and sizing adjustments for smaller screens and mobile devices.
 */

/* Tablet and smaller desktop screens (720px and below) */
@media (max-width: 720px) {

    /* Reduce decorative image sizes on smaller screens for better content focus */
    .mickey-figure,
    .minnie-figure {
        max-height: clamp(180px, 32vh, 280px);
        opacity: 0.85;
    }

    .mickey-figure {
        right: max(24px, 8vw);
    }

    .minnie-figure {
        left: max(24px, 8vw);
    }
}

/* Mobile layout: reduce from 3 columns to 2 columns */
@media (max-width: 720px) {
    .category-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Small screens: single column for category grid */
@media (max-width: 440px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
}

/**
 * ============================================================================
 * FOOTER STYLING
 * ============================================================================
 * Date, game number, and elapsed timer display at the bottom of the page.
 */

/* Footer container and main stats section */
.game-footer {
    text-align: center;
    font-family: var(--font-disney);
    font-size: clamp(30px, 3vw, 26px);
    line-height: 1.4;
    padding-top: 5px;
    color: var(--text);
    text-shadow: 0px 1px 2px rgba(255, 255, 255, 0.8);
    opacity: 1.0;
}

/* Social media link in footer */
.game-footer .social-link {
    font-size: clamp(30px, 2.5vw, 22px);
    margin-top: 2px;
    opacity: 1.0;
}

/* Disclaimer text in footer */
.game-footer .disclaimer-link {
    font-size: clamp(19px, 1.8vw, 18px);
    margin-top: 4px;
    opacity: 1.0;
}