:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e4e6ea;
  --text: #1a1b2e;
  --muted: #6b7280;
  --reading-size: 18px;
  --accent: #ad3326;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

button { background: none; border: none; cursor: pointer; font: inherit; touch-action: manipulation; }
a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.section-toggle:active { background: var(--border); }

.section-label {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.35;
  color: var(--text);
  padding-top: 2px;
  flex-shrink: 1;
  min-width: 0;
  overflow-wrap: break-word;
  hyphens: auto;
}

.section-ref {
  margin-left: auto;
  font-size: 1.0rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: 0.04em;
  padding-top: 2px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Feast switcher (multiple masses) */
.feast-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 12px 6px;
}
.feast-nav {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  transition: opacity 0.15s;
}
.feast-nav:active { opacity: 0.5; }
.feast-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.feast-title span {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--accent);
}
.feast-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding-bottom: 14px;
}
.feast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.25s, transform 0.25s;
}
.feast-dot--active {
  background: var(--accent);
  transform: scale(1.25);
}

/* State cards */
.error-card, .empty-card {
  margin: 32px 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}


/* Readings */
.feast-name {
  font-size: 1.05rem;
  font-weight: 700;
  padding: 16px 24px 12px;
  line-height: 1.3;
  text-align: center;
  color: var(--accent);
}
.mass-single .feast-name { font-size: 1.8rem; padding: 28px 28px 20px; }
.mass-tabs .feast-name { display: none; }

.reading-section {
  border-top: 1px solid var(--border);
}
.reading-section:first-of-type { border-top: none; }
.section-toggle {
  width: 100%;
  padding: 14px 16px 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
}
.gospel-section .section-label,
.gospel-section .section-ref { font-weight: 700; color: var(--accent); }
.psalm-section .section-toggle { flex-wrap: wrap; }
.psalm-section .section-label { hyphens: none; overflow-wrap: normal; }
.psalm-section .section-ref { order: 3; flex-basis: 100%; margin-left: 0; white-space: normal; }
.psalm-section .chevron { margin-left: auto; }
.chevron { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; margin-left: 8px; color: var(--muted); transition: transform 0.2s; }
.chevron--up { transform: rotate(180deg); }
.section-body {
  padding: 4px 16px 22px 18px;
  font-size: var(--reading-size);
  line-height: 1.7;
}
.section-body p+p { margin-top: 1em; }
.closing { margin-top: 1.2em; font-style: italic; color: var(--muted); font-size: 0.9em; }
.psalm-response { font-style: italic; font-weight: 600; margin-bottom: 1em; color: var(--accent); }
.psalm-verse { padding-left: 0.5em; }
.resp { color: var(--accent); font-weight: 700; font-style: normal; }
.alleluia-section .section-body { font-style: italic; }

[x-cloak] { display: none !important; }

/* ─── Dark mode ─────────────────────────────────────────── */
html.dark {
  --bg: #121212;
  --surface: #1e1e1e;
  --border: rgba(255, 255, 255, 0.1);
  --text: #e0e0e0;
  --muted: #9ca3af;
  --accent: #f87171;
}
html.dark .error-card, html.dark .empty-card { background: var(--surface); border-color: var(--border); }

/* ─── App shell ──────────────────────────────────────────── */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--text);
  width: 0%;
  z-index: 60;
  transition: width 0.1s ease-out;
  pointer-events: none;
}

.header-actions {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 50;
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  background: rgba(225, 227, 232, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.15s;
}
html.dark .icon-btn { background: rgba(58, 58, 58, 0.55); }
.icon-btn:active { opacity: 0.5; }

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 200, 'GRAD' 0, 'opsz' 24;
  font-size: 25px;
  user-select: none;
}

/* Settings panel — font size +/- buttons, anchored below the header buttons */
#settings-panel {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 40;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#settings-panel.settings-panel--open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.font-btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.font-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  color: var(--text);
  background: rgba(128, 128, 128, 0.14);
  transition: opacity 0.15s, background 0.15s;
}
.font-btn:active { background: rgba(128, 128, 128, 0.28); }
.font-btn:disabled { opacity: 0.3; pointer-events: none; }


/* Main reading area */
.reading-main {
  flex: 1 0 auto;
  padding-top: calc(1em + env(safe-area-inset-top));
  padding-bottom: calc(1em + env(safe-area-inset-bottom));
}

/* Native date picker, hidden but anchored just under the date header so the
   browser's popup opens near the date. Tapping the date drives it via showPicker(). */
#date-picker {
  position: fixed;
  top: calc(96px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

/* ─── Date header ────────────────────────────────────────── */
/* The current day as the page's hero, doubling as the calendar trigger, with
   links to step to the day before / after. */
.date-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 30px auto 20px;
  padding: 0 16px;
  text-align: center;
}
.date-weekday {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.date-full {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: clamp(2rem, 6vw, 2.4rem);
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
  padding: 2px 4px;
  transition: opacity 0.15s;
}
.date-full:active { opacity: 0.55; }
.date-cal-icon {
  font-size: 20px;
  color: var(--muted);
  align-self: center;
}
.date-nav {
  display: flex;
  gap: 20px;
  margin-top: 12px;
}
.date-link {
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  padding: 2px 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: opacity 0.15s;
}
.date-link:active { opacity: 0.55; }
.date-link:disabled {
  opacity: 0.32;
  pointer-events: none;
}

.site-footer {
  max-width: 640px;
  margin: 2.5rem auto 1.5rem;
  padding: 1.25rem 1.25rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
}
.site-footer p { margin: 0.3em 0; }
.site-footer a { color: inherit; }
