* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/*
 * Color Philosophy:
 * - UI elements (buttons, links, text) use neutral grays
 * - ONLY the calendar/date area uses liturgical colors
 * - Liturgical colors change based on the church season:
 *   Purple (Advent, Lent), Gold (Christmas, Easter), Green (Ordinary Time, Epiphany),
 *   Red (Pentecost), Black (Triduum)
 * - All colors defined here as CSS variables for single source of truth
 */
:root {
    --primary-color: #4b5563;
    --bg-color: #fafafa;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Liturgical Colors */
    --liturgical-purple: #6b46c1;
    --liturgical-green: #047857;
    --liturgical-gold: #e6b800;
    --liturgical-red: #dc2626;
    --liturgical-black: #1f2937;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 1rem;
    padding: 1rem 0 0.5rem;
    position: relative;
}

.lang-toggle {
    position: absolute;
    top: 1rem;
    right: 0;
    background: none;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.lang-toggle:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.date-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 0.75rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.date-display {
    flex: 1;
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background-color 0.3s ease;
}

/* Liturgical Season Colors for Date Display */
/*
 * WHY ATTRIBUTE SELECTORS [class*="season-"]:
 * Instead of listing all 8 seasons (advent, lent, ordinary, pentecost, etc.),
 * we use attribute selectors to match ANY class containing "season-".
 * Benefits:
 * 1. DRY - define once instead of listing 8 seasons multiple times
 * 2. Maintainable - adding new seasons requires no CSS changes here
 * 3. Readable - clear intent: "all seasons get white text"
 */

/* All seasons default to white text */
.date-display[class*="season-"] {
    color: white;
}

/* Liturgical day info is slightly dimmed for visual hierarchy */
.date-display[class*="season-"] .liturgical-day {
    color: rgba(255, 255, 255, 0.9);
}

/*
 * Liturgical background colors
 *
 * WHY COMBINED SELECTORS:
 * Both .date-display and .readings-content.completed use the same liturgical
 * colors. By defining them together, we have a single source of truth.
 * Change purple once, it updates both the date box and completed readings box.
 */
.date-display.season-advent,
.date-display.season-lent,
.readings-content.completed.season-advent,
.readings-content.completed.season-lent {
    background: var(--liturgical-purple);
}

.date-display.season-ordinary,
.date-display.season-epiphany,
.readings-content.completed.season-ordinary,
.readings-content.completed.season-epiphany {
    background: var(--liturgical-green);
}

.date-display.season-pentecost,
.readings-content.completed.season-pentecost {
    background: var(--liturgical-red);
}

.date-display.season-triduum,
.readings-content.completed.season-triduum {
    background: var(--liturgical-black);
}

/* Exception: Christmas and Easter use gold with dark text */
.date-display.season-christmas,
.date-display.season-easter,
.readings-content.completed.season-christmas,
.readings-content.completed.season-easter {
    background: var(--liturgical-gold);
    color: var(--text-primary);
}

.date-display.season-christmas .liturgical-day,
.date-display.season-easter .liturgical-day {
    color: inherit; /* Use parent's dark text color */
}

.current-date {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.liturgical-day {
    font-size: 0.875rem;
    margin-top: 0.25rem;
    line-height: 1.4;
}

.liturgical-cycle {
    font-weight: 600;
    font-size: 0.875rem;
}

.liturgical-season {
    font-weight: 500;
}

.liturgical-special {
    font-weight: 600;
}

.liturgical-separator {
    margin: 0 0.5rem;
    opacity: 0.7;
}

/* Focus indicators for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.nav-button:focus-visible,
.today-button:focus-visible,
.info-button:focus-visible,
.office-button:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--primary-color);
}

.calendar-day:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.nav-button {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.nav-button:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.nav-button:active {
    transform: scale(0.95);
}

.info-button {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-family: Georgia, serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 4px;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.info-button:hover {
    filter: brightness(1.1);
    transform: scale(1.1);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 2rem;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-content h2 {
    margin: 0 0 1rem;
    font-size: 1.2rem;
}

.modal-content p {
    margin: 0 0 0.8rem;
}

.modal-content ul {
    margin: 0 0 0.8rem;
    padding-left: 1.2rem;
}

.modal-content li {
    margin-bottom: 0.4rem;
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 4px 8px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-attribution {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-color);
}

.modal-attribution a {
    color: var(--primary-color);
}

.calendar-controls {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.calendar-toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.calendar-panel {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0.75rem 1rem;
    z-index: 50;
    width: 280px;
}

.calendar-panel[hidden] {
    display: none;
}

.calendar-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.375rem;
}

.calendar-month-label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.calendar-nav-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.calendar-nav-btn:hover {
    color: var(--text-primary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.125rem 0;
}

.calendar-day {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    color: var(--text-primary);
    padding: 0.3rem 0;
    transition: background-color 0.15s, color 0.15s;
}

.calendar-day:hover {
    opacity: 0.8;
}

.calendar-day.other-month {
    color: var(--text-secondary);
    opacity: 0.4;
}

.calendar-day.read {
    color: white;
}

.calendar-day.today {
    font-weight: 700;
}

.calendar-day.selected {
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.today-button {
    display: block;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.today-button:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.dropdown {
    padding: 0.375rem 0.5rem;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    background: white;
    color: var(--text-primary);
    font-size: 0.8125rem;
    cursor: pointer;
}

.dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
}

.readings-content .dropdown {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
}

.readings-content.completed .dropdown {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.95);
}

.readings-content {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
}

/* Completed readings: white text for all colored seasons */
.readings-content.completed[class*="season-"] {
    color: white;
}

.readings-content.completed[class*="season-"] a {
    color: white;
    text-decoration: underline;
}

/* Exception: Christmas and Easter links use dark text */
.readings-content.completed.season-christmas a,
.readings-content.completed.season-easter a {
    color: var(--text-primary);
    text-decoration: underline;
}

.loading {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
}

.error {
    text-align: center;
    color: var(--liturgical-red);
    padding: 2rem;
}

.scripture-list {
    list-style: none;
    margin-top: 2.5rem;
}

.scripture-item {
    padding: 0.5rem 0;
}

.scripture-item a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.0625rem;
    font-weight: 500;
    transition: color 0.2s;
}

.scripture-item a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

.daily-office-links {
    background: var(--card-bg);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.office-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.daily-office-links h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.office-note {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.office-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.office-button {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.office-button:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/*
 * Mark as Read Button
 *
 * WHY ABSOLUTE POSITIONING:
 * Fixed in upper-right corner so it doesn't move when changing dates.
 * This prevents the jarring "jumping around" effect that would occur if
 * it was at the bottom of variable-length scripture lists.
 */
.mark-complete-button {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    z-index: 10;
}

.mark-complete-button:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* When not completed - show as action button */
.mark-complete-button:not(.completed) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.mark-complete-button:not(.completed):hover {
    background: var(--primary-color);
    color: white;
}

/* When completed - show as checked */
.mark-complete-button.completed {
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
    border-color: rgba(255, 255, 255, 0.95);
}

.mark-complete-button.completed:hover {
    background: rgba(255, 255, 255, 0.85);
}

/* For gold backgrounds (Christmas/Easter) */
.readings-content.completed.season-christmas .mark-complete-button.completed,
.readings-content.completed.season-easter .mark-complete-button.completed {
    background: white;
    border-color: white;
}

.checkmark {
    font-size: 1.125rem;
    transition: transform 0.2s;
}

.mark-complete-button.completed .checkmark {
    transform: scale(1.15);
}

@media (max-width: 640px) {
    body {
        padding: 0.5rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    .date-navigation {
        padding: 0.75rem;
    }

    .current-date {
        font-size: 1rem;
    }

    .liturgical-day {
        font-size: 0.8125rem;
    }

    .readings-content {
        padding: 1.25rem;
    }


    .nav-button {
        width: 40px;
        height: 40px;
    }

    .mark-complete-button {
        top: 0.75rem;
        left: 0.75rem;
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
        gap: 0.25rem;
    }


    .scripture-list {
        margin-top: 2.25rem;
    }

    .calendar-panel {
        width: calc(100vw - 1rem);
    }

    .calendar-day {
        font-size: 0.875rem;
        padding: 0.5rem 0;
    }
}

@media (max-width: 480px) {
    .office-buttons {
        gap: 0.5rem;
    }

    .office-button {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
}
