/* ==========================================================================
   1. SELF-HOSTED TYPOGRAPHY (@font-face)
   ========================================================================== */
/* 
   ACCESSIBILITY & PERFORMANCE: We self-host custom fonts ('big_one' and 'normal_one') 
   using WOFF2 and WOFF formats. 'font-display: swap' ensures that text remains 
   visible to users while custom fonts are loading, preventing invisible text bugs.
*/

@font-face {
    font-family: 'big_one';
    src: url('/fonts/SpaceGrotesk-Light.woff2') format('woff2'),
        url('/fonts/SpaceGrotesk-Light.woff') format('woff');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'normal_one';
    src: url('/fonts/AtkinsonHyperlegible-Regular.woff2') format('woff2'),
        url('/fonts/AtkinsonHyperlegible-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}


/* ==========================================================================
   2. CSS VARIABLES & DARK MODE SCHEMES (:root)
   ========================================================================== */
/* 
   ACCESSIBILITY: CSS variables allow centralized color management. By using 
   '@media (prefers-color-scheme: dark)', the site automatically adapts to the 
   user's operating system preferences, ensuring high contrast and reducing 
   eye strain for users who require dark mode.
*/

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f4f4f6;
    --text-main: #121212;
    --brand-purple: #57068c;
    --border-color: #767676;
    --focus-outline: #005fcc;
    --focus-bg: #e0f0ff;
    --focus-glow: rgba(87, 6, 140, 0.4);
    --font-heading: 'big_one', arial, helvetica, sans-serif;
    --font-body: 'normal_one', arial, helvetica, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #121212;
        --bg-secondary: #1e1e1e;
        --text-main: #f8f9fa;
        --brand-purple: #b57cff;
        --border-color: #8c8c8c;
        --focus-outline: #6ea8fe;
        --focus-bg: #1a2a40;
        --focus-glow: rgba(181, 124, 255, 0.5);
    }
}


/* ==========================================================================
   3. MODERN CSS RESET & BASE STYLES
   ========================================================================== */

/* 
   ACCESSIBILITY & CONSISTENCY: Universal box-sizing ensures that padding 
   and borders are included in element width/height calculations, preventing 
   layout breakage across different browsers.
*/
*, *::before, *::after {
    box-sizing: border-box;
}

/* Clear default browser margins for predictable layout spacing */
body, h1, h2, h3, h4, p, figure, blockquote, dl, dd {
    margin: 0;
}

html {
    font-size: 100%;
    /* Smooth scrolling provides a polished transition when clicking anchor jump links */
    scroll-behavior: smooth;
}

/* 
   MACRO LAYOUT (CSS GRID): 
   The body acts as our primary two-dimensional layout container, dividing the 
   viewport into distinct header, main content, and footer rows.
*/
body {
    display: grid;
    min-height: 100vh;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "headery"
        "mainy"
        "footery";
    font-family: var(--font-body);
    /* Fluid typography scales smoothly between viewports while remaining readable */
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    line-height: 1.5;
    letter-spacing: 0.03em;
    background-color: var(--bg-primary);
    color: var(--text-main);
}

h1,
h2,
h3,
legend,
nav a {
    font-family: var(--font-heading);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}


/* ==========================================================================
   4. ACCESSIBILITY (SKIP LINKS & FOCUS STATES)
   ========================================================================== */

/* 
   ACCESSIBILITY (Screen Reader & Keyboard Users): 
   'skip-link' stays hidden off-screen by default, but pops into view when 
   focused by a keyboard user tab-navigating into the page. 
   NOTE: z-index: 2000 ensures it floats above the sticky header (z-index: 1000).
*/
.skip-link {
    position: absolute;
    top: -200px;
    left: 0;
    background: #000000;
    color: #ffffff;
    padding: 1.5em;
    z-index: 2000;
    text-decoration: none;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--focus-outline);
}

/* 
   ACCESSIBILITY: Clear, high-contrast visual indicators for keyboard focus 
   ensure that users navigating via keyboards always know where they are.
*/
a:focus {
    outline: 2px dotted var(--focus-outline);
    background-color: var(--focus-bg);
    color: var(--text-main);
}

/* 
   ACCESSIBILITY (Touch Targets): Enforces WCAG minimum interactive target 
   size guidelines (at least 44x44px) for touch and mouse users.
*/
a,
button,
input[type="submit"] {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* 
   ACCESSIBILITY & UX: 'scroll-margin-top' creates an offset buffer when 
   jumping to anchors on desktop, preventing the sticky header from overlapping 
   and hiding the target content.
*/
@media (min-width: 768px) {
    #sections,
    #milestones,
    #music,
    #literature,
    #web,
    #guy-fawkes,
    #union-1707,
    #union-1801,
    #ni-1922 {
        scroll-margin-top: 7rem;
    }
}


/* ==========================================================================
   5. HEADER & MAIN NAVIGATION (FLEXBOX USAGE)
   ========================================================================== */

header {
    grid-area: headery;
    /* 
       FLEXBOX: Stacks the header title and navigation vertically on mobile 
       with a clean gap.
    */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem 2rem;
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
}

header h1 {
    margin: 0;
    font-size: clamp(1.75rem, 3vw, 2.5rem);
}

header h1 span {
    color: var(--brand-purple);
}

nav a i,
nav a svg {
    margin-right: 0.5rem;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    /* 
       FLEXBOX: Arranges navigation list items horizontally in a row and 
       allows them to wrap onto multiple lines smoothly on smaller screens.
    */
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35rem;
}

nav a {
    color: var(--text-main);
    text-decoration: none;
    font-weight: bold;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    border-bottom: 2px solid transparent;
    font-size: 0.85rem;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

nav a:hover {
    background-color: var(--bg-primary);
    border-bottom-color: var(--brand-purple);
}

/* ACCESSIBILITY: Explicitly highlights the current page for assistive tech / visual cues */
nav a#current_page {
    background-color: var(--bg-primary);
    border-bottom: 2px solid var(--brand-purple);
}


/* ==========================================================================
   6. MAIN LAYOUT & STATISTICS GRID (CSS GRID USAGE)
   ========================================================================== */

main {
    grid-area: mainy;
}

#hero h2,
#hero p,
#main-content,
#sidebar {
    margin: 0;
    padding: 2rem;
}

.fa-heart,
.fa-star {
    color: red;
}

/* 
   CSS GRID (Statistics Gallery): 
   Creates a responsive two-column grid layout for statistic cards on mobile 
   screens, organizing data cleanly into equal fractions (`1fr`).
*/
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 1.25rem;
    text-align: center;
}

.stat-card .number {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--brand-purple);
    font-weight: bold;
    display: block;
    margin-bottom: 0.25rem;
}

.stat-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.stat-card p {
    margin: 0;
    font-size: 0.9rem;
}


/* ==========================================================================
   7. JUMP LINKS & NAVIGATION PILLS (FLEXBOX USAGE)
   ========================================================================== */

.intro-heading {
    font-weight: bold;
    margin-bottom: 0.5rem;
}

/* 
   FLEXBOX (Pill Navigation Row): 
   Uses flexbox with wrapping enabled so internal section jump buttons stay 
   neatly aligned and wrap gracefully on narrow viewports.
*/
.intro-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.intro-links a {
    background-color: var(--bg-secondary);
    color: var(--text-main);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.intro-links a:hover {
    border-color: var(--brand-purple);
    background-color: var(--bg-primary);
    color: var(--brand-purple);
}

.intro-links a:focus {
    outline: 3px solid var(--focus-outline);
    outline-offset: 2px;
    background-color: var(--focus-bg);
    color: var(--text-main);
}


/* ==========================================================================
   8. CARD & TIMELINE ARCHITECTURE (DRY PRINCIPLE + FLEXBOX/GRID)
   ========================================================================== */
/* 
   DRY PRINCIPLE & LAYOUT COMBINATION: 
   - CSS GRID manages the outer gallery containers (`interests-grid`, `timeline-container`), 
     controlling column counts across breakpoints.
   - FLEXBOX manages the internal vertical layout of each card (`interest-card`, `timeline-item`), 
     ensuring content stretches and return links stay pinned to the bottom.
*/

.interests-grid,
.timeline-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.interest-card,
.timeline-item {
    position: relative;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 1.5rem;
    /* FLEXBOX: Stacks card content vertically and pushes footer links to the bottom */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.timeline-item {
    border-left: 4px solid var(--brand-purple);
    border-radius: 0 4px 4px 0;
}

.interest-card a.card-link,
.timeline-item a.card-link {
    display: block;
    color: var(--text-main);
    text-decoration: none;
}

.interest-card a.card-link:focus,
.timeline-item a.card-link:focus {
    outline: 3px solid var(--focus-outline);
    outline-offset: 2px;
}

.interest-card img,
.timeline-item img {
    width: 100%;
    height: auto;
    margin-bottom: 1rem;
    border-radius: 2px;
}

.interest-card h3,
.timeline-item h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--brand-purple);
}

.interest-card p,
.timeline-item p {
    margin: 0;
}

.interest-card .return-link,
.timeline-item .return-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--brand-purple);
    text-decoration: underline;
    align-self: flex-start;
    position: relative;
    z-index: 2;
}

.interest-card .return-link:hover,
.timeline-item .return-link:hover {
    color: var(--text-main);
}


/* ==========================================================================
   9. FAQ ACCORDION GROUP (CSS GRID USAGE)
   ========================================================================== */
/* ACCESSIBILITY: Uses native HTML <details> and <summary> elements for built-in keyboard and screen reader accessibility without JavaScript. */

.faq-accordion-group {
    /* CSS GRID: Stacks FAQ accordion items vertically with a consistent gap */
    display: grid;
    gap: 1rem;
    margin-top: 1.5rem;
}

details {
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem 1.5rem;
}

summary {
    font-family: var(--font-heading);
    font-weight: bold;
    cursor: pointer;
}

details p {
    margin-top: 1rem;
    margin-bottom: 0;
}


/* ==========================================================================
   10. FORM LAYOUT & CONTROLS (CSS GRID & FLEXBOX USAGE)
   ========================================================================== */

fieldset {
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

legend {
    font-weight: bold;
    padding: 0 0.5rem;
}

/* CSS GRID: Arranges form row fields cleanly */
.form-row {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

/* FLEXBOX: Stacks form submit and reset buttons vertically on mobile */
.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

/* FLEXBOX: Aligns radio buttons and checkboxes horizontally with their text labels */
.radio-item,
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="radio"],
input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
}

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    background-color: var(--bg-primary);
    color: var(--text-main);
    box-sizing: border-box;
}

/* ACCESSIBILITY: Enhanced high-contrast focus rings for interactive form elements */
input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
    outline: none;
    border-color: var(--brand-purple);
    box-shadow: 0 0 8px var(--focus-glow);
}

input[type="submit"] {
    background-color: var(--brand-purple);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: bold;
    border-radius: 4px;
}

@media (prefers-color-scheme: dark) {
    input[type="submit"] {
        color: #121212;
    }
}

input[type="submit"]:hover,
input[type="submit"]:focus {
    background-color: #333333;
    color: #ffffff;
    cursor: pointer;
    outline: 3px solid var(--focus-outline);
    outline-offset: 2px;
}


/* ==========================================================================
   11. MEDIA QUERIES (RESPONSIVE DESIGN BREAKPOINTS)
   ========================================================================== */

@media (min-width: 768px) {
    header {
        /* FLEXBOX: Switches header layout to a horizontal row on tablet/desktop */
        position: sticky;
        top: 0;
        z-index: 1000;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    nav ul {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 1.25rem;
    }

    nav a {
        padding: 0.5rem 1rem;
        font-size: clamp(1rem, 1.2vw, 1.15rem);
        border-bottom-width: 3px;
    }

    /* 
       HIDE ON DESKTOP (Interests Page Jump Links Only): 
       Completely removes the interests section jump heading and pill links from 
       the visual layout and keyboard tab order on screens 768px and wider.
       Note: .timeline-intro-links is preserved so historical milestones stay visible.
    */
    .intro-heading,
    .intro-links:not(.timeline-intro-links) {
        display: none;
    }

    /* 
       MACRO LAYOUT (CSS GRID): 
       Transforms the main content area into a two-column desktop grid with a 
       dedicated sidebar (`2fr` for main content, `1fr` for the sidebar).
    */
    main {
        display: grid;
        grid-template-areas:
            "hero hero"
            "main-content sidebar";
        grid-template-columns: 2fr 1fr;
    }

    #hero {
        grid-area: hero;
        background-color: var(--bg-secondary);
        min-height: 12vh;
    }

    #main-content {
        grid-area: main-content;
        min-height: 40vh;
        padding: 3rem;
    }

    #sidebar {
        grid-area: sidebar;
        background-color: var(--bg-secondary);
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* CSS GRID: Expands interest cards to 2 columns on tablet screens */
    .interests-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* CSS GRID: Aligns form labels and inputs side-by-side on desktop */
    .form-row {
        grid-template-columns: 12rem 1fr;
        align-items: center;
    }

    /* FLEXBOX: Aligns form submission buttons in a horizontal row on desktop */
    .button-group {
        flex-direction: row;
        align-items: center;
    }
}

@media (min-width: 1024px) {
    /* CSS GRID: Expands interest cards to a 3-column gallery on wide desktop screens */
    .interests-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* ==========================================================================
   12. FOOTER
   ========================================================================== */

footer {
    grid-area: footery;
}

footer,
footer p {
    width: 100%;
    text-align: center;
    background-color: #000000;
    color: #ffffff;
    padding: 4px 0;
}

footer a {
    color: #ffffff;
    text-decoration: underline;
    justify-content: center;
}