/* ============================================================
   LiturgicalMissals — Old-Book Aesthetic
   Side-by-side Latin/Vernacular layout.
   Off-white pages, red & black ink, serif typography.
   ============================================================ */

:root {
    --page-bg: #f5f0e8;
    --page-bg-dark: #e8e0d0;
    --ink-black: #1a1a1a;
    --ink-red: #8b1a1a;
    --ink-muted: #5a5245;
    --border-color: #c9bea8;
    --accent-gold: #8b7535;

    --font-body: 'Crimson Text', 'Georgia', serif;
    --font-heading: 'Cinzel', 'Times New Roman', serif;

    --content-width: 960px;
    --spacing: 1.5rem;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    color: var(--ink-black);
    background-color: var(--page-bg);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.site-header {
    background-color: var(--page-bg-dark);
    border-bottom: 2px solid var(--border-color);
    padding: 0.75rem var(--spacing);
}

.header-inner {
    max-width: var(--content-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ink-black);
    text-decoration: none;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-nav a,
.site-nav select {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--ink-muted);
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--ink-red);
}

/* --- Font Size Controls --- */
.font-size-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.font-size-controls button {
    font-family: var(--font-heading);
    font-weight: 700;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    color: var(--ink-muted);
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    font-size: 0.8rem;
    line-height: 1.2;
}

.font-size-controls button:hover {
    border-color: var(--ink-red);
    color: var(--ink-red);
}

/* --- Collapsible Eucharistic Prayers --- */
.ep-collapsible .ep-body {
    display: none;
}

.ep-collapsible.ep-expanded .ep-body {
    display: block;
}

/* EP preview: visible when collapsed, hidden when expanded */
.ep-preview {
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.ep-preview-text {
    font-size: 0.85rem;
    color: var(--ink-muted);
    font-style: italic;
    line-height: 1.5;
}

.ep-collapsible.ep-expanded .ep-preview {
    display: none;
}

.ep-heading {
    cursor: pointer;
}

.ep-heading:hover {
    color: var(--ink-red);
}

.ep-toggle-hint {
    font-size: 0.75rem;
    font-family: var(--font-body);
    font-weight: normal;
    color: var(--ink-muted);
    margin-left: 0.5rem;
}

.ep-expanded .ep-toggle-hint::before {
    content: '[hide]';
}

.ep-expanded .ep-toggle-hint {
    font-size: 0;
}

.ep-expanded .ep-toggle-hint::before {
    font-size: 0.75rem;
}

/* --- Main Content --- */
.page-content {
    flex: 1;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: var(--spacing);
    width: 100%;
}

/* --- Footer --- */
.site-footer {
    background-color: var(--page-bg-dark);
    border-top: 2px solid var(--border-color);
    padding: 1rem var(--spacing);
    text-align: center;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--ink-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* --- Mass Page Layout --- */
.mass-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--ink-red);
}

.mass-date {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--ink-muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.mass-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ink-black);
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.mass-subtitle {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 1rem;
    color: var(--ink-muted);
}

.mass-color-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.15rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    font-family: var(--font-heading);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

/* --- Mass Sections --- */
.mass-section {
    margin-bottom: 1.75rem;
}

.mass-section:last-child {
    margin-bottom: 0;
}

/* Section heading: centered, bold, with red rule */
.section-heading {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-align: center;
    color: var(--ink-black);
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
}

/* Section heading subtitle: right-column language translation, smaller */
.section-heading-sub {
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    text-align: center;
    color: var(--ink-muted);
    margin-top: -0.3rem;
    margin-bottom: 0.5rem;
    font-style: italic;
}

/* Rubric: centered italic in red — traditional missal convention */
.section-rubric {
    font-style: italic;
    color: var(--ink-red);
    font-size: 0.85rem;
    text-align: center;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

/* Bilingual rubric row keeps the two-column grid but with rubric styling */
.section-rubric-row {
    margin-bottom: 0.75rem;
}

.section-rubric-row .section-rubric {
    text-align: left;
    margin-bottom: 0;
}

/* Congregational rubric: instructions for the faithful (kneel, stand, sit, sing) */
/* Distinct from the priest's rubric: smaller, centered, bracketed */
.congregation-rubric {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-style: normal;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-red);
    text-align: center;
    margin-bottom: 0.5rem;
    padding: 0.3rem 0;
}

/* --- Two-Column Side-by-Side Layout --- */
.bilingual-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.col-latin,
.col-vernacular {
    font-size: 0.95rem;
    line-height: 1.7;
}

.col-latin {
    /* Latin text — slightly different feel */
}

.col-vernacular {
    /* Vernacular text */
}

/* When only one language is available */
.single-column {
    max-width: 680px;
    margin: 0 auto;
    font-size: 0.95rem;
    line-height: 1.7;
}

/* --- Section Dividers --- */
.section-divider {
    text-align: center;
    margin: 1.5rem 0;
    color: var(--border-color);
    font-size: 0.8rem;
    letter-spacing: 0.3em;
}

.section-divider-line {
    border: none;
    border-top: 2px solid var(--ink-red);
    margin: 2rem auto;
    width: 80%;
}

/* Major part headings (Mass of the Catechumens, Mass of the Faithful, etc.) */
.mass-part-heading {
    text-align: center;
    margin: 2.5rem 0 1.5rem;
    padding: 0.75rem 0;
    border-top: 2px solid var(--ink-red);
    border-bottom: 2px solid var(--ink-red);
}

.mass-part-heading h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    font-style: italic;
    color: var(--ink-black);
    letter-spacing: 0.08em;
}

/* --- Day Navigation --- */
.day-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
}

.day-nav-arrow {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--ink-muted);
    text-decoration: none;
}

.day-nav-arrow:hover {
    color: var(--ink-red);
}

.day-nav-today {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-red);
    text-decoration: none;
    border: 1px solid var(--ink-red);
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
}

.day-nav-today:hover {
    background-color: var(--ink-red);
    color: var(--page-bg);
}

/* --- Alternative Mass Selector --- */
.alt-mass-selector {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background-color: var(--page-bg-dark);
}

.alt-mass-selector > p {
    font-family: var(--font-heading);
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 0.6rem;
}

.alt-mass-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
}

.alt-mass-option {
    display: inline-block;
    font-family: var(--font-body);
    color: var(--ink-black);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 2px;
    transition: border-color 0.15s;
}

.alt-mass-option:hover {
    border-color: var(--border-color);
}

.alt-mass-option.active {
    border-color: var(--ink-red);
    background-color: var(--page-bg);
}

.alt-mass-name {
    font-weight: 600;
}

.alt-mass-rank {
    font-size: 0.75rem;
    color: var(--ink-muted);
    margin-left: 0.4rem;
    font-style: italic;
}

/* --- Section Table of Contents (quick-jump) --- */
.section-toc {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
}

.toc-toggle {
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--page-bg-dark);
    color: var(--ink-black);
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.toc-toggle:hover {
    border-color: var(--ink-red);
}

.toc-links {
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    background: var(--page-bg);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.section-toc.open .toc-links {
    display: flex;
}

.toc-links a {
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--ink-muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
}

.toc-links a:hover {
    color: var(--ink-red);
    background: var(--page-bg-dark);
}

/* --- Role markers: P./V./S. (priest/celebrant) and R./℟. (people's responses) --- */
.response-marker {
    color: var(--ink-red);
    font-weight: 700;
}

.celebrant-marker {
    color: var(--ink-black);
    font-weight: 700;
}

/* Consecration words displayed in uppercase bold */
.consecration-words {
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Legend explaining P./R./V. abbreviations */
.role-legend {
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--ink-muted);
    margin-bottom: 1.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background-color: var(--page-bg-dark);
}

/* Note before Eucharistic Prayers explaining only one is used */
.ep-usage-note {
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-style: italic;
    color: var(--ink-muted);
    margin-bottom: 1rem;
    padding: 0.5rem;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--ink-muted);
}

.empty-state h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--ink-black);
}

.empty-state p {
    font-style: italic;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    .page-content {
        padding: var(--spacing) 1rem;
    }

    /* Keep side-by-side but tighter on tablets */
    .bilingual-row {
        gap: 1rem;
    }

    .mass-title {
        font-size: 1.3rem;
    }

    .site-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .site-title {
        font-size: 1rem;
    }

    .mass-title {
        font-size: 1.1rem;
    }

    .day-nav-arrow {
        font-size: 0.75rem;
    }

    .alt-mass-options {
        align-items: stretch;
    }

    /* Compact side-by-side on small phones */
    .bilingual-row {
        gap: 0.5rem;
    }

    .col-latin,
    .col-vernacular {
        font-size: 0.85rem;
        line-height: 1.55;
    }

    .section-rubric {
        font-size: 0.75rem;
    }

    .congregation-rubric {
        font-size: 0.6rem;
    }

    .page-content {
        padding: 0.75rem 0.5rem;
    }

    /* Header compact layout for small phones */
    .header-inner {
        flex-direction: column;
        gap: 0.4rem;
    }

    .site-nav {
        width: 100%;
        justify-content: center;
    }

    .site-nav select,
    .site-nav input[type="date"] {
        font-size: 0.75rem;
        padding: 0.15rem 0.2rem;
        max-width: 5.5rem;
    }
}

/* --- Scroll behavior for anchor links --- */
html {
    scroll-behavior: smooth;
}

.mass-section {
    scroll-margin-top: 1rem;
}

/* --- Print Stylesheet --- */
@media print {
    .site-header,
    .site-footer,
    .day-nav,
    .alt-mass-selector,
    .section-toc,
    .site-nav,
    .font-size-controls {
        display: none !important;
    }

    body {
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }

    .page-content {
        max-width: 100%;
        padding: 0;
    }

    .mass-header {
        border-bottom: 2pt solid #000;
        margin-bottom: 1em;
        padding-bottom: 0.5em;
    }

    .mass-title {
        font-size: 16pt;
    }

    .mass-color-badge {
        border: 1pt solid #000;
    }

    .bilingual-row {
        gap: 1em;
    }

    .section-heading {
        font-size: 11pt;
        border-bottom: 0.5pt solid #999;
        margin-top: 1em;
    }

    .mass-section {
        page-break-inside: avoid;
    }

    a {
        color: #000;
        text-decoration: none;
    }
}
