:root {
  --navy: #1f2a44;
  --navy-2: #2c3b5e;
  --gold: #c9a227;
  --gold-soft: #f3e7bf;
  --wine: #7a1f2b;
  --bg: #f7f3ea;
  --card: #ffffff;
  --text: #22262e;
  --muted: #6b6f78;
  --line: #e6dfcf;
  --live: #1f8a4c;
  --live-bg: #e3f5ea;
  --soon: #b26a00;
  --soon-bg: #fff1d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 68, 0.06), 0 6px 20px rgba(31, 42, 68, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; color: var(--navy); margin: 0; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.3rem; }

button { font: inherit; cursor: pointer; }
a { color: var(--navy-2); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Cabeçalho ---------- */
.hero {
  background:
    radial-gradient(circle at 50% -20%, rgba(201, 162, 39, 0.35), transparent 60%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  text-align: center;
  padding: 2.2rem 1rem 3.4rem;
}
.hero__icon {
  font-size: 2rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.4rem;
}
.hero h1 { color: #fff; font-size: clamp(2rem, 6vw, 2.8rem); letter-spacing: 0.01em; }
.hero__subtitle { margin: 0.25rem 0 0; color: var(--gold-soft); font-weight: 500; }
.hero__clock {
  display: inline-block;
  margin: 0.9rem 0 0;
  padding: 0.3rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  font-size: 0.85rem;
  color: #e8ebf3;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: -2rem auto 0;
  padding: 0 1rem 3rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.notice {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: var(--gold-soft);
  border: 1px solid #e6d18e;
  color: #5a4710;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}
.notice p { margin: 0; }

.link-btn {
  background: none;
  border: 0;
  color: var(--wine);
  font-weight: 600;
  padding: 0.2rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Próximos ---------- */
.upcoming__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.6rem;
}
.up-item {
  width: 100%;
  height: 100%;
  text-align: left;
  display: grid;
  gap: 0.15rem;
  align-content: start;
  background: #fbf9f4;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.up-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.up-item--live { border-left-color: var(--live); background: #f4fbf6; }
.up-item--soon { border-left-color: var(--soon); }
.up-item__when { font-size: 0.78rem; font-weight: 600; color: var(--wine); text-transform: uppercase; letter-spacing: 0.03em; }
.up-item__name { font-weight: 600; color: var(--navy); }
.up-item__meta { font-size: 0.82rem; color: var(--muted); }
.up-item .badge { justify-self: start; margin-top: 0.25rem; }

/* ---------- Filtros ---------- */
.filters { display: grid; gap: 0.9rem; }
.filters .section-head { margin-bottom: 0; }
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.2rem;
}
.filter-group { display: grid; gap: 0.4rem; min-width: 0; }
.filter-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  border: 1px solid var(--line);
  background: #fbf9f4;
  color: var(--text);
  border-radius: 999px;
  padding: 0.42rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip:hover { border-color: var(--gold); }
.chip[aria-checked="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

input[type="time"], input[type="search"], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: #fbf9f4;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  min-height: 42px;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.time-wrap { display: flex; gap: 0.4rem; }
.time-wrap input { flex: 1; }
.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0 0.8rem;
  color: var(--navy);
  font-weight: 600;
  font-size: 0.85rem;
}
.icon-btn:hover { border-color: var(--gold); }

/* ---------- Resultados ---------- */
.results-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.5rem 0 0.8rem;
}
.results-head p { margin: 0.1rem 0 0; }

.tabs {
  display: inline-flex;
  background: #ebe4d3;
  border-radius: 999px;
  padding: 3px;
}
.tab {
  border: 0;
  background: transparent;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy-2);
}
.tab[aria-selected="true"] { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

#results { display: grid; gap: 1rem; }

/* Por dia */
.day-group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.day-group--today { border-color: var(--gold); }
.day-group__title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.1rem;
  background: #fbf7ec;
  border-bottom: 1px solid var(--line);
}
.day-group__title .muted { margin-left: auto; font-family: "Inter", sans-serif; font-weight: 500; }
.day-group__empty { padding: 1rem 1.1rem; margin: 0; }

.pill {
  font-family: "Inter", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gold);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.session-list { list-style: none; margin: 0; padding: 0; }
.session {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.session:last-child { border-bottom: 0; }
.session--past { opacity: 0.55; }
.session--live { background: #f4fbf6; }
.session__time { display: grid; line-height: 1.2; }
.session__start { font-size: 0.75rem; color: var(--muted); }
.session__start strong { display: block; font-size: 1.25rem; color: var(--navy); }
.session__end { font-size: 0.8rem; color: var(--muted); }
.session__main { min-width: 0; }
.session__meta { font-size: 0.85rem; color: var(--muted); margin-top: 0.1rem; }
.session__tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.session__tags:empty { display: none; }

.parish-link {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  font-weight: 600;
  color: var(--navy);
  font-size: 1rem;
}
.parish-link:hover { color: var(--wine); text-decoration: underline; text-underline-offset: 3px; }

.map-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fbf9f4;
  text-decoration: none;
  font-size: 1.1rem;
}
.map-btn:hover { border-color: var(--gold); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #eef0f4;
  color: var(--muted);
}
.badge--live { background: var(--live-bg); color: var(--live); }
.badge--live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.6s infinite;
}
.badge--soon { background: var(--soon-bg); color: var(--soon); }
.badge--later { background: #e9eef8; color: var(--navy-2); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.tag {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #f6efe0;
  color: #6a5320;
  border: 1px solid #ecdfbf;
}

/* Por paróquia */
.parish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.parish-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.6rem;
  align-content: start;
}
.parish-card header { display: grid; gap: 0.1rem; }
.parish-card__title { font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.3rem; line-height: 1.15; }
.parish-card p { margin: 0; }
.parish-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  margin-top: auto;
}
.sched { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.sched li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  align-items: baseline;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: #fbf9f4;
}
.sched li.is-match { background: #eef2fb; }
.sched li.is-dim { opacity: 0.5; }
.sched__days { font-weight: 600; color: var(--wine); min-width: 84px; }
.sched__time { font-weight: 600; color: var(--navy); }
.sched__who { font-size: 0.82rem; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.btn:hover { background: var(--navy-2); }
.btn--ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn--ghost:hover { background: #fbf9f4; border-color: var(--gold); }

/* Semana */
.week-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.week { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 0.85rem; }
.week th, .week td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; text-align: left; }
.week thead th {
  background: #fbf7ec;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--navy-2);
  position: sticky;
  top: 0;
}
.week thead th small { display: block; font-size: 0.65rem; color: var(--gold); text-transform: lowercase; }
.week thead th.is-dim { opacity: 0.45; }
.week tbody th {
  position: sticky;
  left: 0;
  background: #fff;
  min-width: 190px;
  max-width: 230px;
  font-weight: 400;
  border-right: 1px solid var(--line);
}
.week tbody th small { display: block; color: var(--muted); }
.week .parish-link { font-size: 0.9rem; }
.week td.is-today, .week th.is-today { background: #fffaf0; }
.week td.is-selected, .week thead th.is-selected { background: #eef2fb; box-shadow: inset 2px 0 0 var(--navy-2), inset -2px 0 0 var(--navy-2); }
.week thead th.is-selected { color: var(--navy); }
.week tbody tr:last-child th, .week tbody tr:last-child td { border-bottom: 0; }
.tchip {
  display: block;
  white-space: nowrap;
  margin-bottom: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 600;
  background: #eef2fb;
  color: var(--navy);
}
.tchip.is-dim { opacity: 0.35; }
.tchip--live { background: var(--live-bg); color: var(--live); }
.tchip--soon { background: var(--soon-bg); color: var(--soon); }
.tchip--past { text-decoration: line-through; }
.legend { margin: 0.5rem 0 0; }

/* Vazio */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty__icon { font-size: 2rem; }
.empty p { margin: 0.4rem 0; color: var(--muted); }

.footnote { margin: 0; }

/* Trava a rolagem de fundo quando a modal está aberta */
body.modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* ---------- Diálogo ---------- */
dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(560px, calc(100% - 1.5rem));
  max-height: min(85vh, 680px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  color: var(--text);
}
dialog::backdrop { background: rgba(20, 26, 40, 0.55); backdrop-filter: blur(2px); }
.dialog__body {
  position: relative;
  padding: 1.4rem 1.4rem 1.2rem;
  display: grid;
  gap: 0.7rem;
  overscroll-behavior: contain;
}
.dialog__body h2 { font-size: 1.8rem; line-height: 1.1; padding-right: 2rem; }
.dialog__body p { margin: 0; }
.dialog__eyebrow { font-size: 0.8rem; font-weight: 600; color: var(--wine); text-transform: uppercase; letter-spacing: 0.05em; }
.dialog__close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}
.dlg-table { width: 100%; border-collapse: collapse; }
.dlg-table th, .dlg-table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.dlg-table th { font-weight: 600; color: var(--navy); width: 42%; }
.dlg-table td div + div { margin-top: 0.25rem; }
.dlg-table tr.is-today { background: #fffaf0; }
.dialog__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ---------- Responsivo ---------- */
@media (max-width: 680px) {
  .filter-row { grid-template-columns: 1fr; }
  #upcoming-sub { display: none; }
  .session { grid-template-columns: 74px 1fr auto; gap: 0.7rem; padding: 0.75rem 0.85rem; }
  .session__start strong { font-size: 1.1rem; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 0.45rem 0.5rem; }
  .parish-grid { grid-template-columns: 1fr; }
  .parish-card footer { flex-direction: column; align-items: stretch; }
}
