:root {
    --bg-color: #f7f4ef;
    --paper-color: #ffffff;
    --text-color: #2c2c2c;
    --primary-color: #002244; /* Royal Navy Blue */
    --accent-color: #a68b5b; /* Antique Gold */
    --border-color: #dcd6ce;
    --hover-color: #8b7355;
    --accent-light: rgba(166, 139, 91, 0.12);

    /* Liturgical Colors */
    --liturgical-green: #556B2F;
    --liturgical-purple: #4B0082;
    --liturgical-white: #D4AF37;
    --liturgical-red: #8B0000;
    --liturgical-rose: #C71585;
    --liturgical-gold: #D4AF37;

    --font-display: 'UnifrakturMaguntia', serif;
    --font-monastic: 'Uncial Antiqua', serif;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Lora', serif;
    --font-title: 'Cinzel', serif;
}

/* Animations */
@keyframes ctaPulse {
    0% { box-shadow: 0 0 0 0 rgba(166, 139, 91, 0.6); }
    100% { box-shadow: 0 0 0 10px rgba(166, 139, 91, 0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

* {
    box-sizing: border-box;
}

/* Accessibility */
.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;
}

html {
    scroll-behavior: smooth;
}

/* Accessibility: Global focus visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 2px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-body);
    line-height: 1.7;
    margin: 0;
    padding: 0;
    font-size: 19px;
    animation: fadeIn 0.6s ease;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}

a:hover {
    color: var(--hover-color);
    border-bottom: 1px solid var(--accent-color);
}

/* Header & Nav */
header {
    border-bottom: 3px solid var(--accent-color);
    background: var(--paper-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow 0.3s ease, padding 0.3s ease;
    animation: slideDown 0.7s ease;
}

header.scrolled {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
}

.site-title {
    font-family: var(--font-title);
    font-size: 1.4rem;
    color: var(--primary-color);
    letter-spacing: 0.08em;
    margin: 0;
    text-transform: uppercase;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2rem;
}

nav li {
    margin-bottom: 0;
}

nav a {
    color: var(--text-color);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-family: var(--font-heading);
    padding-bottom: 0.3rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    position: relative;
    border-bottom: none;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-color), var(--hover-color));
    transition: width 0.35s ease;
}

nav a:hover::after,
nav a.active::after {
    width: 100%;
}

nav a.active, nav a:hover {
    color: var(--primary-color);
    border-bottom: none;
}

nav a i {
    font-size: 0.9em;
    opacity: 0.7;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

nav a:hover i {
    opacity: 1;
    transform: scale(1.15);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 6rem 2rem 5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #003366 40%, #1a3a5c 100%);
    color: #f7f4ef;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(166, 139, 91, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.hero::after {
    content: '\2720';
    position: absolute;
    font-size: 20rem;
    color: rgba(255, 255, 255, 0.025);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    font-family: var(--font-heading);
}

.hero h1 {
    color: #f7f4ef;
    font-size: 3.5rem;
    border-bottom: none;
    margin: 0 0 1.25rem 0;
    padding-bottom: 0;
    animation: fadeInUp 0.8s ease 0.2s both;
    letter-spacing: normal;
}

.hero h1::after {
    color: var(--accent-color);
    animation: fadeIn 1s ease 0.8s both;
}

.hero .hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.15rem;
    font-style: italic;
    color: rgba(247, 244, 239, 0.8);
    max-width: 520px;
    margin: 0 auto 2.5rem;
    line-height: 1.9;
    animation: fadeInUp 0.8s ease 0.4s both;
}

.hero .hero-cta {
    display: inline-block;
    padding: 0.9rem 2.8rem;
    border: 1.5px solid var(--accent-color);
    color: var(--accent-color);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    border-radius: 2px;
    transition: background 0.4s ease, color 0.4s ease, transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 0.8s ease 0.6s both;
}

@media (prefers-reduced-motion: no-preference) {
    .hero .hero-cta {
        animation: fadeInUp 0.8s ease 0.6s both, ctaPulse 2s ease-out 1.4s infinite;
    }
}

.hero .hero-cta:hover, .hero .hero-cta:focus {
    animation-play-state: paused;
}

.hero .hero-cta:hover {
    background: var(--accent-color);
    color: #002244;
    border-bottom: 1.5px solid var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(166, 139, 91, 0.3);
}

/* Main Content */
main {
    max-width: 850px;
    margin: 0 auto;
    padding: 4rem;
    background: var(--paper-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 40px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border-color);
    margin-bottom: 4rem;
    animation: fadeInUp 0.7s ease 0.2s both;
    border-radius: 2px;
}

/* Typography */
h1, h2, h3 {
    color: var(--primary-color);
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
    position: relative;
}

h1::after {
    content: "\2020";
    display: block;
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-top: 0.5rem;
    font-weight: normal;
}

h2 {
    font-family: var(--font-monastic);
    font-weight: 400;
    font-size: 1.8rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5em;
    margin-top: 3rem;
}

h3 {
    font-family: var(--font-monastic);
    font-weight: 400;
}

h2 i {
    color: var(--accent-color);
    font-size: 0.85em;
}

h2 a {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

p {
    margin-bottom: 1.5rem;
}

blockquote {
    border-left: none;
    margin: 3rem 0;
    padding: 2.25rem 2.5rem;
    font-style: italic;
    color: var(--text-color);
    font-size: 1.05em;
    text-align: center;
    position: relative;
    background: linear-gradient(135deg, var(--accent-light) 0%, transparent 100%);
    border-radius: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(166, 139, 91, 0.1);
}

blockquote:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(166, 139, 91, 0.08);
}

blockquote::before {
    content: "\201C";
    display: block;
    font-size: 3.5rem;
    color: var(--accent-color);
    line-height: 1;
    margin-bottom: -0.8rem;
    font-family: var(--font-heading);
    opacity: 0.7;
}

/* Components */
.drop-cap::first-letter {
    font-family: var(--font-heading);
    font-size: 4.2rem;
    float: left;
    line-height: 0.78;
    margin-right: 0.6rem;
    margin-top: 0.1rem;
    color: var(--primary-color);
    font-weight: 700;
}

ul {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.75rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 1rem;
    font-size: 0.85rem;
    color: rgba(247, 244, 239, 0.7);
    font-family: var(--font-heading);
    letter-spacing: 0.06em;
    background: linear-gradient(135deg, var(--primary-color) 0%, #003366 100%);
    border-top: 3px double var(--accent-color);
}

footer p {
    margin: 0;
}

footer a {
    color: var(--accent-color);
}

/* Specific Page Styles */
.sacrament-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
}

.sacrament-grid section {
    background: var(--paper-color);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--accent-color);
    border-radius: 6px;
    padding: 2rem;
    transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
}

.sacrament-grid section:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0, 34, 68, 0.10);
    border-color: rgba(166, 139, 91, 0.3);
}

.sacrament-grid h2 {
    font-size: 1.4rem;
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.sacrament-grid p {
    font-size: 0.95rem;
    color: var(--text-color);
    opacity: 0.85;
    margin-bottom: 0;
}

.resource-list {
    list-style: none;
    padding: 0;
}

.resource-list li {
    margin-bottom: 2rem;
    border-bottom: 1px dotted var(--border-color);
    padding-bottom: 1.5rem;
    padding-left: 1.5rem;
    border-left: 3px solid transparent;
    border-radius: 0 6px 6px 0;
    transition: border-left-color 0.3s ease, background 0.3s ease;
}

.resource-list li:hover {
    border-left-color: var(--accent-color);
    background: var(--accent-light);
}

.resource-list h3 {
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.resource-list h3 i {
    color: var(--accent-color);
}

/* Expandable sections (details/summary) */
details {
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--accent-color);
    padding-left: 1.2rem;
    transition: background 0.3s ease, border-left-color 0.3s ease;
}

details[open] {
    background: var(--accent-light);
    border-radius: 0 8px 8px 0;
    padding: 0.5rem 1.2rem 1rem;
    margin-bottom: 1.5rem;
    border-left-color: var(--hover-color);
}

summary {
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: var(--primary-color);
    padding: 0.6rem 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5em;
    transition: color 0.3s ease;
}

summary::-webkit-details-marker {
    display: none;
}

summary::before {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.7em;
    color: var(--accent-color);
    transition: transform 0.3s ease;
    display: inline-block;
    width: 1em;
    flex-shrink: 0;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

summary:hover {
    color: var(--hover-color);
}

details p, details ul {
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

details .scripture-ref {
    font-style: italic;
    color: var(--text-color);
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Mystery groups */
.mystery-group {
    margin-bottom: 2rem;
}

.mystery-group h3 {
    font-size: 1.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.mystery-group h3 i {
    color: var(--accent-color);
    font-size: 0.85em;
}

.mystery-day {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-color);
    opacity: 0.75;
    margin-bottom: 0.75rem;
    font-family: var(--font-body);
}

/* Mass section parts */
.mass-part {
    margin-bottom: 1.5rem;
}

.mass-part h3 {
    font-size: 1.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5em;
}

.mass-part h3 i {
    color: var(--accent-color);
    font-size: 0.85em;
}

/* Decorative divider */
.divider {
    text-align: center;
    margin: 3rem 0;
    color: var(--accent-color);
    font-size: 1.5rem;
    letter-spacing: 0.5em;
}

/* Page-specific hero banners */
.page-banner {
    text-align: center;
    padding: 3.5rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #003366 100%);
    color: #f7f4ef;
    margin-bottom: 0;
    position: relative;
    overflow: hidden;
}

.page-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(166, 139, 91, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.page-banner h1 {
    color: #f7f4ef;
    border-bottom: none;
    margin: 0;
    padding-bottom: 0;
    animation: fadeInUp 0.6s ease both;
}

.page-banner h1::after {
    color: var(--accent-color);
}

.page-banner p {
    color: rgba(247, 244, 239, 0.8);
    font-style: italic;
    max-width: 600px;
    margin: 0.5rem auto 0;
    animation: fadeInUp 0.6s ease 0.15s both;
}

/* Hamburger — base (overridden in menubar section below) */
.hamburger {
    display: none;
}

@media (max-width: 700px) {
    main {
        padding: 2rem 1.5rem;
        margin: 0;
        box-shadow: none;
        border: none;
        background: transparent;
    }

    h1::after {
        display: none;
    }

    .hero {
        padding: 3rem 1.5rem;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .page-banner {
        padding: 2rem 1.5rem;
    }

    .sacrament-grid section {
        padding: 1.5rem;
    }

    h2 {
        flex-wrap: wrap;
    }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0.01ms !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0.01ms !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Liturgical accent border colors */
header.liturgical-green  { border-bottom-color: var(--liturgical-green); }
header.liturgical-purple { border-bottom-color: var(--liturgical-purple); }
header.liturgical-white  { border-bottom-color: var(--liturgical-white); }
header.liturgical-red    { border-bottom-color: var(--liturgical-red); }
header.liturgical-rose   { border-bottom-color: var(--liturgical-rose); }
header.liturgical-gold   { border-bottom-color: var(--liturgical-gold); }

/* Calendar Subscription */
.calendar-subscription {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.calendar-subscription input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-color);
    background: var(--paper-color);
    border-radius: 4px;
}

.calendar-subscription .copy-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    font-family: var(--font-heading);
    text-transform: uppercase;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 140px;
    justify-content: center;
}

.calendar-subscription .copy-btn:hover {
    background: var(--hover-color);
}

.calendar-subscription .copy-btn.success {
    background-color: var(--liturgical-green);
    cursor: default;
}

/* Accessibility: Skip Link */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: #fff;
    padding: 1rem 2rem;
    z-index: 10000;
    text-decoration: none;
    font-family: var(--font-heading);
    border-radius: 0 0 4px 4px;
    transition: top 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--accent-color);
    color: var(--primary-color);
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 1.2rem;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--hover-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

@media (max-width: 700px) {
    #back-to-top {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* Refactored inline styles */
.reading-feast-title {
    text-align: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.copy-success-message {
    display: none;
    color: var(--liturgical-green);
    font-size: 0.9em;
    margin-top: 0.5rem;
}

.calendar-subsection-title {
    margin-top: 1rem;
}

/* Moved from today.html */
.readings-container {
    max-width: 800px;
    margin: 0 auto;
}

.reading-section {
    margin-bottom: 3rem;
}

.reading-header {
    text-align: center;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.reading-citation {
    font-style: italic;
    color: var(--accent-color);
    text-align: center;
    display: block;
    margin-top: 0.5rem;
}

.reading-text {
    text-align: justify;
}

.verse-number {
    font-size: 0.8em;
    vertical-align: super;
    color: var(--text-color);
    opacity: 0.55;
    margin-right: 0.2em;
}

.response-text {
    font-weight: bold;
    font-style: italic;
}

/* ========================
   DARK MODE
   ======================== */
body.theme-dark {
    --bg-color: #0f1419;
    --paper-color: #1a2332;
    --text-color: #e0dbd2;
    --primary-color: #c5d8f2;
    --accent-color: #c9a96e;
    --border-color: #2d3f52;
    --hover-color: #dfc07e;
    --accent-light: rgba(201, 169, 110, 0.14);
}

body.theme-dark .hero {
    background: linear-gradient(135deg, #0d1926 0%, #152238 40%, #1a2d45 100%);
}

body.theme-dark .hero::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(201, 169, 110, 0.1) 0%, transparent 70%);
}

body.theme-dark .page-banner {
    background: linear-gradient(135deg, #0d1926 0%, #152238 100%);
}

body.theme-dark .page-banner::before {
    background: radial-gradient(ellipse at 50% 0%, rgba(201, 169, 110, 0.08) 0%, transparent 70%);
}

body.theme-dark footer {
    background: linear-gradient(135deg, #0d1926 0%, #152238 100%);
}

body.theme-dark header {
    background: var(--paper-color);
    border-bottom-color: var(--accent-color);
}

body.theme-dark header.scrolled {
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
}

body.theme-dark main {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    border-color: var(--border-color);
}

body.theme-dark .sacrament-grid section {
    border-color: var(--border-color);
    border-top-color: var(--accent-color);
}

body.theme-dark .sacrament-grid section:hover {
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
}

body.theme-dark blockquote {
    background: linear-gradient(135deg, rgba(201, 169, 110, 0.08) 0%, transparent 100%);
}

body.theme-dark .submenu {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

body.theme-dark .brand-logo {
    filter: brightness(0) invert(0.9);
}

/* ========================
   HEADER GRID LAYOUT
   ======================== */
header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    text-align: left;
    margin-bottom: 0;
}

header.scrolled {
    padding: 0.5rem 1.5rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
}

header.scrolled .site-title {
    font-size: 1.4rem;
    margin: 0;
}

/* Brand / Site title — left column */
.site-title {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin: 0;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    font-family: var(--font-title);
    text-transform: uppercase;
    color: var(--primary-color);
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-title);
    text-transform: uppercase;
    color: var(--primary-color);
    border-bottom: none;
    white-space: nowrap;
}

.brand-link:hover {
    color: var(--accent-color);
    border-bottom: none;
}

.brand-logo {
    width: 1.5rem;
    height: 1.5rem;
}

/* Navigation — center column */
header nav {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
}

.menu-root {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0;
    margin: 0;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.menu-root > li {
    position: relative;
}

.menu-root > li > a,
.menu-trigger {
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-heading);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.76rem;
    padding: 0.45rem 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: none;
    border: none;
    position: relative;
}

.menu-root > li > a::after,
.menu-trigger::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-color), var(--hover-color));
    transition: width 0.35s ease;
}

.menu-root > li > a::before,
.menu-trigger::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
}

.menu-trigger i:last-child {
    font-size: 0.65em;
    transition: transform 0.2s ease;
}

.menu-dropdown.open > .menu-trigger i:last-child {
    transform: rotate(180deg);
}

.menu-root > li > a:hover,
.menu-root > li > a.active,
.menu-trigger:hover,
.menu-trigger.active,
.menu-dropdown.open > .menu-trigger {
    color: var(--primary-color);
}

.menu-root > li > a:hover::after,
.menu-root > li > a.active::after,
.menu-trigger:hover::after,
.menu-trigger.active::after,
.menu-dropdown.open > .menu-trigger::after {
    width: 100%;
}

/* Dropdown submenus */
.submenu {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 50%;
    transform: translateX(-50%);
    list-style: none;
    margin: 0;
    padding: 0.4rem;
    background: var(--paper-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 200;
}

.menu-dropdown.open .submenu {
    display: block;
}

.submenu a {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
    border-radius: 0.45rem;
    border-bottom: none;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    color: var(--text-color);
    transition: background 0.2s;
    position: relative;
}

.submenu a::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
}

.submenu a:hover,
.submenu a.active {
    background: var(--accent-light);
    color: var(--primary-color);
    border-bottom: none;
}

/* Utility buttons — right column */
.menu-utilities {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    position: static;
}

.icon-btn {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.82rem;
    transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s;
    position: relative;
}

.icon-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
}

.icon-btn:hover {
    color: var(--primary-color);
    border-color: var(--accent-color);
    background: var(--accent-light);
    transform: scale(1.08);
}

/* Hamburger — hidden on desktop, shown on mobile */
.hamburger {
    display: none;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.05rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 0.35rem 0.55rem;
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
}

.hamburger:hover {
    color: var(--primary-color);
    border-color: var(--accent-color);
}

/* ========================
   MOBILE NAV (≤ 768px)
   ======================== */
@media (max-width: 768px) {
    header {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        padding: 0.75rem 1rem;
        gap: 0;
    }

    header.scrolled {
        padding: 0.65rem 1rem;
    }

    .site-title {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
    }

    .hamburger {
        display: inline-flex;
        grid-column: 2;
        grid-row: 1;
        align-self: center;
    }

    .menu-utilities {
        display: none;
    }

    header nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: stretch;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease, padding 0.35s ease, margin 0.35s ease;
    }

    header nav.open {
        max-height: 600px;
        border-top: 1px solid var(--border-color);
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        margin-top: 0.5rem;
    }

    .menu-root {
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        padding: 0;
        overflow-x: visible;
        white-space: normal;
    }

    .menu-root > li > a,
    .menu-trigger {
        width: 100%;
        border-radius: 6px;
        justify-content: flex-start;
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
        white-space: normal;
    }

    .submenu {
        position: static;
        transform: none;
        box-shadow: none;
        border: none;
        border-left: 2px solid var(--accent-color);
        border-radius: 0;
        padding: 0.15rem 0 0.25rem 1rem;
        background: transparent;
        min-width: unset;
        margin-left: 0.75rem;
    }

    body.theme-dark .submenu {
        box-shadow: none;
    }

    .submenu a {
        font-size: 0.82rem;
        padding: 0.45rem 0.65rem;
        border-radius: 6px;
    }
}

/* ========================
   SEARCH OVERLAY
   ======================== */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.search-overlay.open {
    opacity: 1;
    visibility: visible;
}

.search-dialog {
    width: 90%;
    max-width: 560px;
    background: var(--paper-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transform: translateY(-12px) scale(0.97);
    transition: transform 0.25s ease;
}

.search-overlay.open .search-dialog {
    transform: translateY(0) scale(1);
}

body.theme-dark .search-dialog {
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.2s ease;
}

.search-input-wrap:focus-within {
    border-bottom-color: var(--accent-color);
}

.search-input-wrap i {
    color: var(--accent-color);
    font-size: 1rem;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.5;
}

.search-input:focus-visible {
    outline: none; /* Inherits focus indication from .search-input-wrap:focus-within */
}

.search-input::placeholder {
    color: var(--text-color);
    opacity: 0.85;
}

.search-kbd {
    font-family: var(--font-heading);
    font-size: 0.65rem;
    color: var(--text-color);
    opacity: 0.85;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    position: relative;
}

.search-kbd::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
}

.search-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.5rem;
}

.search-results::-webkit-scrollbar {
    width: 6px;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.search-result {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: none;
}

.search-result:hover,
.search-result.active {
    background: var(--accent-light);
    color: var(--text-color);
    border-bottom: none;
}

.search-result-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 8px;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-color);
    font-size: 0.85rem;
}

.search-result.active .search-result-icon {
    background: var(--accent-color);
    color: var(--paper-color);
}

.search-result-text {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    color: var(--primary-color);
    line-height: 1.3;
}

.search-result-desc {
    font-size: 0.78rem;
    color: var(--text-color);
    opacity: 0.85;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-arrow {
    color: var(--accent-color);
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.search-result:hover .search-result-arrow,
.search-result.active .search-result-arrow {
    opacity: 1;
    transform: translateX(2px);
}

.search-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-color);
    opacity: 0.85;
    font-size: 0.9rem;
}

.search-empty i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    opacity: 0.85;
}

.search-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-color);
    opacity: 0.85;
    font-family: var(--font-heading);
    letter-spacing: 0.03em;
}

.search-footer kbd {
    font-family: inherit;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
}

@media (max-width: 768px) {
    .search-overlay {
        padding-top: 2rem;
    }

    .search-dialog {
        width: 95%;
        border-radius: 12px;
    }

    .search-footer {
        display: none;
    }
}

/* ========================
   PRINT STYLES
   ======================== */
@media print {
    /* Hide navigation, header, footer, and interactive elements */
    header, footer, .hero, .page-banner, .skip-link, .back-to-top,
    .search-overlay, .theme-toggle, .nav-search, .calendar-subscription,
    .hamburger {
        display: none !important;
    }

    /* Reset body and main container for print */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
    }

    main {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
        width: 100% !important;
    }

    /* Ensure text is readable and visible */
    p, h1, h2, h3, h4, li, blockquote {
        color: black !important;
        page-break-inside: avoid;
    }

    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }

    /* Links */
    a {
        text-decoration: underline;
        color: black !important;
    }

    /* Expand details for printing */
    details {
        border: none !important;
    }
    details[open] {
        background: transparent !important;
        padding: 0 !important;
        margin-bottom: 1rem;
    }
}

/* Reading Time */
.reading-time {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
    animation: fadeInUp 0.6s ease 0.3s both;
}

.reading-time i {
    font-size: 0.8em;
    opacity: 0.8;
}
