/* ============================================
   KMTJ Entertainment — Jeron's Stylesheet
   Pages: rules.html & reservations.html
   Author: Jeron Aidoo

   Features:
   - CSS Variables (:root & scoped)
   - Variable calculations
   - All advanced selectors
   - CSS Nesting
   - Mobile-first media queries
   - Print styles
   ============================================ */

/* ========== CSS VARIABLES ========== */

:root {
    /* Team Color Palette - ONLY THESE 6 COLORS */
    --bg-dark: #050b18;
    --bg-light: #0a192f;
    --accent: #4da3ff;
    --text-main: #fff;
    --text-muted: #9fb3c8;
    --card-bg: rgba(255, 255, 255, 0.3);

    /* Typography */
    --font-primary: 'Poppins', 'segoe ui', SansSerif;
    --font-heading: 'Georgia', 'Times New Roman', serif;

    /* Spacing (with calculations) */
    --spacing-unit: 1rem;
    --spacing-xs: calc(var(--spacing-unit) * 0.5);
    --spacing-sm: var(--spacing-unit);
    --spacing-md: calc(var(--spacing-unit) * 2);
    --spacing-lg: calc(var(--spacing-unit) * 3);
    --spacing-xl: calc(var(--spacing-unit) * 4);

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-round: 50%;

    /* Transitions */
    --transition-fast: 0.2s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;

    /* Shadows with accent color */
    --shadow-sm: 0 2px 4px rgba(77, 163, 255, 0.1);
    --shadow-md: 0 4px 12px rgba(77, 163, 255, 0.15);
    --shadow-lg: 0 8px 24px rgba(77, 163, 255, 0.2);
    --shadow-glow: 0 0 20px rgba(77, 163, 255, 0.4);

    /* Z-index scale */
    --z-base: 1;
    --z-dropdown: 10;
    --z-sticky: 100;
    --z-modal: 1000;
}

/* Scoped variables for specific sections */
.rules-page {
    --section-spacing: var(--spacing-lg);
    --card-padding: var(--spacing-md);
}

.reservations-page {
    --form-spacing: var(--spacing-md);
    --button-padding: calc(var(--spacing-xs) * 1.5) var(--spacing-md);
}


/* ========== MOBILE-FIRST BASE STYLES ========== */

/* Universal selector with box-sizing */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--bg-dark);
    min-height: 100vh;
    margin: 0;
}

main {
    flex: 1;
}


/* ========== ADVANCED SELECTORS ========== */

/* --- Descendant Combinator (space) --- */
.container section {
    margin-bottom: var(--spacing-md);
}

/* --- Child Combinator (>) --- */
.card > .card-header {
    background: linear-gradient(135deg, var(--bg-light), var(--accent));
    border: none;
    color: var(--text-main);
    font-weight: 600;
}

header {
    background-color: var(--bg-light);
}

.bg-light {
    color: var(--bg-dark) !important;
}

.bg-light span,
.bg-light .fw-bold {
    color: var(--bg-dark) !important;
}

/* --- Adjacent Sibling Combinator (+) --- */
h2 + p {
    margin-top: var(--spacing-xs);
    color: var(--text-muted);
    font-style: italic;
}

/* --- General Sibling Combinator (~) --- */
.alert ~ .alert {
    margin-top: var(--spacing-sm);
}

/* --- Attribute Selectors --- */

/* Exact match */
[data-page="rules"] {
    background-color: var(--bg-light);
}

/* Contains word */
button[class~="btn-primary"] {
    background-color: var(--accent);
    border-color: var(--accent);

    /* Nesting pseudo-class */
    &:hover {
        background-color: var(--accent);
        border-color: var(--accent);
        box-shadow: var(--shadow-glow);
        transform: translateY(-2px);
        opacity: 0.8;
    }

    &:active {
        transform: translateY(0);
    }
}

/* Starts with */
a[href^="http"]::after {
    content: " ↗";
    font-size: 0.8em;
    opacity: 0.6;
}

/* Ends with */
a[href$=".pdf"]::before {
    content: "📄 ";
}

/* Contains substring */
input[type*="text"],
input[type*="email"],
input[type*="tel"],
input[type="number"],
textarea{
    border: 2px solid rgba(77, 163, 255, 0.3);
    border-radius: var(--radius-sm);
    padding: var(--spacing-xs);
    font-family: inherit;
    transition: border-color var(--transition-fast);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);

    /* Nesting pseudo-class inside */
    &:focus {
        outline: none;
        border-color: var(--accent);
        box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.2);
        background-color: rgba(255, 255, 255, 0.08);
        color: var(--text-main);
    }

    &::placeholder {
        color: var(--text-muted);
        font-style: italic;
    }
}


/* --- Pseudo-Class Selectors --- */

/* :first-child */
.list-group-item:first-child {
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
    font-weight: 600;
}

/* :last-child */
.list-group-item:last-child {
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

/* :nth-child() - zebra striping */
.accordion-item:nth-child(odd) {
    background-color: rgba(77, 163, 255, 0.03);
}

/* :nth-child(even) */
.accordion-item:nth-child(even) {
    background-color: rgba(77, 163, 255, 0.05);
}

/* :nth-of-type() */
.card:nth-of-type(2) {
    box-shadow: var(--shadow-md);
    border: 2px solid var(--accent);
}

/* :not() - negative selector */
button:not([disabled]) {
    cursor: pointer;

    &:hover {
        opacity: 0.9;
    }
}

/* :disabled */
button:disabled,
input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

/* :checked (for radio/checkbox) */
input[type="checkbox"]:checked,
input[type="radio"]:checked {
    accent-color: var(--accent);
}

/* :required and :optional */
input:required {
    border-left: 3px solid var(--accent);
}

input:optional {
    border-left: 3px solid var(--bg-light);
}

/* :valid and :invalid */
input:valid:not(:placeholder-shown) {
    border-color: var(--accent);
}

input:invalid:not(:placeholder-shown) {
    border-color: var(--accent);
    opacity: 0.7;
}

/* :empty */
.card-body:empty::before {
    content: "No content available";
    color: var(--text-muted);
    font-style: italic;
}


/* --- Structural Pseudo-Classes --- */

/* :first-of-type */
section:first-of-type {
    margin-top: var(--spacing-lg);
}

/* :last-of-type */
section:last-of-type {
    margin-bottom: var(--spacing-xl);
}

/* :only-child */
.alert:only-child {
    margin: var(--spacing-md) auto;
    max-width: 800px;
}


/* --- Pseudo-Element Selectors --- */

/* ::before and ::after */
.badge::before {
    content: "★ ";
    margin-right: 2px;
}

.page-author::after {
    content: " ✓";
    color: var(--accent);
    font-size: 0.9em;
}

/* ::first-letter */
.lead::first-letter {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--accent);
}

/* ::selection */
::selection {
    background-color: var(--accent);
    color: var(--bg-dark);
}

/* ========== CSS NESTING ========== */

/* Navbar nesting */
.navbar {
    background: linear-gradient(90deg, var(--bg-dark) 0%, var(--bg-light) 100%) !important;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(77, 163, 255, 0.2);
    position: sticky;
    top: 0;
    z-index: var(--z-modal);

    /* Nesting with & selector */
    &-brand {
        font-family: var(--font-heading);
        font-size: 1.5rem;
        transition: transform var(--transition-fast);
        color: var(--text-main) !important;

        &:hover {
            transform: scale(1.05);
        }

        img {
            filter: drop-shadow(0 0 8px rgba(77, 163, 255, 0.4));
        }
    }

    &-nav {
        .nav-link {
            position: relative;
            color: var(--text-muted) !important;
            transition: color var(--transition-fast);

            &::after {
                content: '';
                position: absolute;
                bottom: 0;
                left: 50%;
                width: 0;
                height: 2px;
                background: var(--accent);
                transition: all var(--transition-normal);
                transform: translateX(-50%);
            }

            &:hover {
                color: var(--text-main) !important;

                &::after {
                    width: 80%;
                }
            }

            &.active {
                color: var(--accent) !important;
                font-weight: 600;

                &::after {
                    width: 100%;
                }
            }
        }
    }
}

/* Card nesting with complex selectors */
.card {
    border: 1px solid rgba(77, 163, 255, 0.2);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    background: var(--card-bg);
    backdrop-filter: blur(10px);

    &:hover {
        box-shadow: var(--shadow-lg);
        transform: translateY(-4px);
        border-color: var(--accent);
    }

    .card-header {
        h2, h3, h4, h5 {
            margin: 0;
            color: var(--text-main);

            i {
                margin-right: var(--spacing-xs);
                opacity: 0.9;
            }
        }
    }

    .card-body {
        padding: var(--spacing-md);

        .list-group-item {
            border-left: 3px solid transparent;
            transition: border-color var(--transition-fast), padding-left var(--transition-fast);
            background-color: transparent;
            border-color: rgba(77, 163, 255, 0.1);
            color: var(--text-main);

            &:hover {
                border-left-color: var(--accent);
                padding-left: calc(var(--spacing-sm) + 4px);
                background-color: rgba(77, 163, 255, 0.1);
            }

            i {
                transition: transform var(--transition-fast);
            }

            &:hover i {
                transform: scale(1.2);
            }
        }
    }
}

/* Accordion nesting */
.accordion {
    .accordion-item {
        border: 1px solid rgba(77, 163, 255, 0.2);
        margin-bottom: var(--spacing-xs);
        border-radius: var(--radius-md);
        overflow: hidden;
        background: var(--card-bg);
        backdrop-filter: blur(10px);

        .accordion-button {
            background-color: rgba(77, 163, 255, 0.1);
            color: var(--text-main);
            font-weight: 600;
            padding: var(--spacing-sm) var(--spacing-md);

            &:not(.collapsed) {
                background: linear-gradient(135deg, var(--bg-light), var(--accent));
                color: var(--text-main);
                box-shadow: var(--shadow-md);

                i {
                    color: var(--accent);
                }
            }

            &:focus {
                box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.3);
                border-color: var(--accent);
            }

            .badge {
                font-size: 0.85em;
                padding: 0.35em 0.65em;
                transition: transform var(--transition-fast);
            }

            &:hover .badge {
                transform: scale(1.1);
            }
        }

        .accordion-body {
            background-color: rgba(10, 25, 47, 0.5);
            padding: var(--spacing-md);
            border-top: 2px solid rgba(77, 163, 255, 0.2);
            color: var(--text-main);
        }
    }
}


/* Form nesting */
form {
    fieldset {
        border: 2px solid rgba(77, 163, 255, 0.2);
        border-radius: var(--radius-md);
        padding: var(--spacing-md);
        margin-bottom: var(--spacing-md);
        background-color: rgba(10, 25, 47, 0.3);

        legend {
            font-family: var(--font-heading);
            color: var(--accent);
            font-weight: 700;
            padding: 0 var(--spacing-sm);
            font-size: 1.1rem;
        }

        .form-label {
            font-weight: 600;
            color: var(--text-main);
            margin-bottom: var(--spacing-xs);

            &::after {
                content: ":";
            }
        }

        .form-control,
        .form-select {
            border: 2px solid rgba(77, 163, 255, 0.3);
            border-radius: var(--radius-sm);
            padding: calc(var(--spacing-xs) * 1.5);
            transition: all var(--transition-fast);
            background-color: rgba(255, 255, 255, 0.05);
            color: var(--text-main);

            option {
                background-color: var(--bg-light);  /* dark bg for the list */
                color: var(--text-main);            /* white text on dark bg */
            }

            &:focus {
                border-color: var(--accent);
                box-shadow: 0 0 0 4px rgba(77, 163, 255, 0.2);
                outline: none;
                background-color: rgba(255, 255, 255, 0.08);
            }
        }

        .form-check {
            padding-left: calc(var(--spacing-md) + var(--spacing-xs));

            .form-check-input {
                margin-top: 0.3em;
                cursor: pointer;

                &:checked {
                    background-color: var(--accent);
                    border-color: var(--accent);
                }

                &:focus {
                    box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.3);
                }
            }

            .form-check-label {
                cursor: pointer;
                color: var(--text-main);

                a {
                    color: var(--accent);
                    text-decoration: underline;

                    &:hover {
                        color: var(--text-main);
                    }
                }
            }
        }
    }
}

/* Alert nesting with nested media query */
.alert {
    border-left: 4px solid;
    border-radius: var(--radius-md);

    &.alert-info {
        border-left-color: var(--accent);
        background-color: rgba(77, 163, 255, 0.15);
        color: var(--text-main);

        .alert-heading {
            color: var(--accent);
        }
    }

    &.alert-success {
        border-left-color: var(--accent);
        background-color: rgba(77, 163, 255, 0.15);
        color: var(--text-main);

        ul li strong {
            color: var(--accent);
        }
    }

    &.alert-warning {
        border-left-color: var(--accent);
        background-color: rgba(77, 163, 255, 0.15);
        color: var(--text-main);

        a {
            color: var(--text-main);
            font-weight: 600;
        }
    }

    &.alert-danger {
        border-left-color: var(--accent);
        background-color: rgba(77, 163, 255, 0.15);
        color: var(--text-main);
    }

    /* Nested media query inside component */
    @media (max-width: 576px) {
        & {
            font-size: 0.9rem;
            padding: var(--spacing-sm);
        }
    }
}

/* Seating chart buttons nesting */
.btn-outline-success {
    border-color: var(--accent);
    color: var(--accent);

    &:hover:not(:disabled) {
        background-color: var(--accent);
        border-color: var(--accent);
        color: var(--text-main);
        transform: scale(1.1);
    }

    &:disabled {
        cursor: not-allowed;
        opacity: 0.4;
    }
}

/* Footer nesting */
.site-footer {
    background: linear-gradient(180deg, var(--bg-light) 0%, var(--bg-dark) 100%) !important;
    border-top: 1px solid rgba(77, 163, 255, 0.2);

    a {
        color: var(--accent);
        transition: color var(--transition-fast);

        &:hover {
            color: var(--text-main);
            text-decoration: underline;
        }
    }

    .page-author {
        color: var(--accent);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
}


/* ========== MEDIA QUERIES (Mobile-First) ========== */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    :root {
        --spacing-unit: 1.125rem;
    }

    body {
        font-size: 1rem;
    }

    .container {
        max-width: 540px;
    }

    .card {
        &-body {
            padding: calc(var(--spacing-md) * 1.2);
        }
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    :root {
        --spacing-unit: 1.25rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    .navbar {
        &-nav {
            .nav-link {
                margin: 0 var(--spacing-xs);
                padding: var(--spacing-xs) var(--spacing-sm);
            }
        }
    }

    /* 2-column layout for cards on tablets */
    .row-cols-md-2 > * {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Sticky booking summary on tablet+ */
    .sticky-top {
        position: sticky;
        top: calc(var(--spacing-md) + 56px);
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    :root {
        --spacing-unit: 1.5rem;
    }

    body {
        font-size: 1.0625rem;
    }

    .container {
        max-width: 960px;
    }

    /* 3-column layout for ticket cards */
    .col-lg-4 {
        transition: transform var(--transition-normal);

        &:hover {
            transform: scale(1.02);
            z-index: var(--z-dropdown);
        }
    }

    /* Enhanced hover effects on desktop */
    .card {
        &:hover {
            transform: translateY(-8px);
            box-shadow: var(--shadow-lg);
        }
    }

    /* Side-by-side form layout */
    form {
        .row {
            display: flex;
            gap: var(--spacing-sm);
        }
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    h1 {
        font-size: 3rem;
    }

    /* Add breathing room */
    section {
        padding: var(--spacing-xl) 0;
    }
}

/* Extra extra large devices (1400px and up) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}


/* ========== PRINT STYLES ========== */

@media print {
    /* Hide unnecessary elements */
    .navbar,
    .btn,
    button,
    .site-footer,
    .sticky-top {
        display: none !important;
    }

    /* Reset colors for print */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    /* Show links */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Avoid page breaks inside elements */
    .card,
    .accordion-item,
    fieldset {
        page-break-inside: avoid;
        border: 1px solid #ddd !important;
        margin-bottom: 1rem;
    }

    /* Page headers for print */
    h1, h2, h3 {
        page-break-after: avoid;
        font-weight: bold;
    }

    /* Show page numbers */
    @page {
        margin: 2cm;

        @bottom-right {
            content: "Page " counter(page) " of " counter(pages);
        }
    }

    /* First page header */
    body::before {
        content: "KMTJ Entertainment - Theater Rules & Reservations";
        display: block;
        font-size: 1.5rem;
        font-weight: bold;
        text-align: center;
        margin-bottom: 2rem;
        padding-bottom: 1rem;
        border-bottom: 2px solid #000;
    }
}


/* ========== UTILITY & HELPER CLASSES ========== */

/* Custom spacing utilities using calculations */
.mt-custom {
    margin-top: calc(var(--spacing-md) + var(--spacing-sm));
}

.py-custom {
    padding-top: calc(var(--spacing-lg) * 0.75);
    padding-bottom: calc(var(--spacing-lg) * 0.75);
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, var(--accent), var(--text-main));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Animated gradient border */
.gradient-border {
    position: relative;

    &::before {
        content: '';
        position: absolute;
        inset: -2px;
        border-radius: var(--radius-lg);
        padding: 2px;
        background: linear-gradient(45deg, var(--accent), var(--bg-light));
    }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}