/*
 * Base Styles
 * Typography, CSS variables, and foundational styles
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --pico-line-height: 1.7;

    /* Custom reading-optimized variables */
    --reading-max-width: 65ch;
    --verse-number-color: var(--pico-muted-color);

    /* Liturgical season colors */
    --color-advent: 128, 0, 128;
    --color-christmas: 255, 215, 0;
    --color-epiphany: 0, 128, 0;
    --color-lent: 128, 0, 128;
    --color-easter: 255, 215, 0;
    --color-trinity: 0, 128, 0;

    /* Special day colors */
    --color-red: 180, 30, 30; /* Pentecost, martyrs */
    --color-rose: 200, 120, 140; /* Gaudete, Laetare */
    --color-black: 30, 30, 30; /* Good Friday */
}

/* ==========================================================================
   Typography & Font Options
   ========================================================================== */

/* Default serif font - must use html selector to override Pico's :root */
html,
html[data-font-family="serif"] {
    --pico-font-family: Georgia, "Times New Roman", "Noto Serif", serif;
}

/* Line spacing options for accessibility */
html[data-line-spacing="compact"] {
    --pico-line-height: 1.4;
}

html[data-line-spacing="normal"] {
    --pico-line-height: 1.7;
}

html[data-line-spacing="relaxed"] {
    --pico-line-height: 2;
}

/* Sans-serif font option for accessibility */
html[data-font-family="sans-serif"] {
    --pico-font-family:
        system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        sans-serif;
}

/* Base typography enhancements */
html {
    /* Enable ligatures and better kerning */
    text-rendering: optimizeLegibility;

    /* Modern line wrapping - avoids orphans and awkward breaks */
    text-wrap: pretty;

    /* Smooth scrolling for anchor links */
    scroll-behavior: smooth;
}

/* Consistent transitions for interactive elements */
a,
button,
[role="button"] {
    transition:
        color 0.15s ease,
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

/* Scripture text benefits from narrower line length for readability */
.scripture-text {
    max-width: var(--reading-max-width);
}

/* Improve paragraph spacing and flow */
p {
    text-align: left;
    orphans: 2;
    widows: 2;
}

/* ==========================================================================
   Prose Text - Improved readability for longer passages
   ========================================================================== */

/* Long liturgical prose (exhortations, confessions, absolutions) */
.minister,
.priest,
.all {
    text-align: justify;
    text-justify: inter-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* Explicit prose class for marked-up sections */
.prose p {
    text-indent: 1.5em;
    margin-bottom: 0.5rem;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* First paragraph after a heading or rubric should not be indented */
.prose h1 + p,
.prose h2 + p,
.prose h3 + p,
.prose h4 + p,
.prose .rubric + p {
    text-indent: 0;
}

/* Don't indent single paragraphs */
.prose p:only-child {
    text-indent: 0;
}

/* ==========================================================================
   Drop Caps - Decorative first letters for chapter/section openings
   ========================================================================== */

/* Drop cap span - wraps the first letter of chapter text */
span.drop-cap {
    float: left;
    font-size: 3.5em;
    line-height: 0.8;
    padding-right: 0.08em;
    padding-top: 0.05em;
    font-weight: 400;
    color: var(--pico-primary);
}

/* First verse needs overflow:hidden to contain the floated drop cap for hover highlight */
.scripture-text p.first-verse {
    overflow: hidden;
}

/* ==========================================================================
   Red Letter Text - Words of Jesus
   ========================================================================== */

/* Red letter text is only shown when the preference is enabled */
html[data-red-letter="on"] .red-letter {
    color: var(--red-letter-color, #b71c1c);
}

/* Slightly brighter red for dark mode for better contrast */
html[data-theme="dark"][data-red-letter="on"] .red-letter,
html[data-theme="auto"][data-red-letter="on"] .red-letter {
    --red-letter-color: #c62828;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="auto"][data-red-letter="on"] .red-letter {
        --red-letter-color: #c62828;
    }
}

/* Keep drop cap in primary color even for red letter verses */
html[data-red-letter="on"] .red-letter .drop-cap {
    color: var(--pico-primary);
}

/* ==========================================================================
   Small Caps for Divine Names (LORD)
   ========================================================================== */

.divine-name {
    font-variant: small-caps;
    text-transform: lowercase;
}

/* ==========================================================================
   Liturgical Ribbon - colored bar indicating the liturgical season
   ========================================================================== */

.liturgical-ribbon {
    height: 4px;
    width: 100%;
}

.liturgical-ribbon.season-advent {
    background: rgb(var(--color-advent));
}
.liturgical-ribbon.season-christmas {
    background: rgb(var(--color-christmas));
}
.liturgical-ribbon.season-epiphany {
    background: rgb(var(--color-epiphany));
}
.liturgical-ribbon.season-lent {
    background: rgb(var(--color-lent));
}
.liturgical-ribbon.season-easter {
    background: rgb(var(--color-easter));
}
.liturgical-ribbon.season-trinity {
    background: rgb(var(--color-trinity));
}

/* Special day overrides */
.liturgical-ribbon.color-red {
    background: rgb(var(--color-red));
}
.liturgical-ribbon.color-rose {
    background: rgb(var(--color-rose));
}
.liturgical-ribbon.color-black {
    background: rgb(var(--color-black));
}

/* ==========================================================================
   Button Styling - Modern horizontal gradient
   ========================================================================== */

/* Primary buttons with horizontal gradient that shifts on hover */
button[type="submit"],
input[type="submit"],
[role="button"].primary,
a[role="button"]:not(.secondary):not(.outline):not(.contrast) {
    background-image: linear-gradient(
        to right,
        color-mix(in srgb, var(--pico-primary-background) 85%, black) 0%,
        var(--pico-primary-background) 51%,
        color-mix(in srgb, var(--pico-primary-background) 85%, black) 100%
    );
    background-size: 200% auto;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition:
        background-position 0.3s ease,
        box-shadow 0.3s ease;
}

button[type="submit"]:hover,
input[type="submit"]:hover,
[role="button"].primary:hover,
a[role="button"]:not(.secondary):not(.outline):not(.contrast):hover {
    background-position: right center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

button[type="submit"]:active,
input[type="submit"]:active,
[role="button"].primary:active,
a[role="button"]:not(.secondary):not(.outline):not(.contrast):active {
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

/* Secondary/outline buttons with subtle depth */
button.secondary,
button.outline,
[role="button"].secondary,
[role="button"].outline {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

button.secondary:hover,
button.outline:hover,
[role="button"].secondary:hover,
[role="button"].outline:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Fix outline button text color (Pico override) */
button.outline {
    background-color: transparent;
    color: var(--pico-primary);
}

button.outline:hover,
button.outline:focus {
    background-color: transparent;
    color: var(--pico-primary-hover);
}

/* ==========================================================================
   Card Shadow - Consistent subtle elevation
   ========================================================================== */

/* Standardized card shadow for a polished, professional look */
article,
.source-card,
.auth-prompt-card {
    box-shadow:
        rgba(9, 30, 66, 0.25) 0px 1px 1px,
        rgba(9, 30, 66, 0.13) 0px 0px 1px 1px;
}

/* ==========================================================================
   Horizontal Rules
   ========================================================================== */

hr {
    border: none;
    border-top: 1px solid var(--pico-muted-border-color);
    margin: 0;
    padding: 0;
}

main hr {
    margin-bottom: 2rem;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    html {
        font-size: 11pt;
    }

    main.container {
        max-width: 100%;
    }

    .scripture-text sup {
        color: #666;
    }

    header.container nav,
    footer.container {
        display: none;
    }
}
