/* ==========================================================================
   calendar.css: the church calendar on events.html (month grid, list view,
   details dialog). Data and behavior are in calendar.js / calendar-data.js.
   ========================================================================== */
.gu-cal {
  --c-school: var(--crimson);
  --c-study: var(--brass);
  --c-special: #1f6b48;
  background: #fffdf9;
  border: 1px solid var(--line);
  border-top: 4px solid var(--crimson);
  box-shadow: 0 20px 44px rgba(36, 22, 27, 0.1);
}
.cal-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 1rem clamp(1rem, 2.5vw, 1.6rem);
  border-bottom: 1px solid var(--line);
}
.cal-nav, .cal-actions { display: flex; align-items: center; gap: 0.6rem; }
.cal-title { margin: 0; min-width: 9ch; text-align: center; font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
.cal-btn {
  display: inline-grid; place-items: center;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid rgba(36, 22, 27, 0.25); background: var(--paper); color: var(--crimson);
  cursor: pointer; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.cal-btn svg { width: 16px; height: 16px; }
.cal-btn:hover:not(:disabled) { background: var(--crimson); border-color: var(--crimson); color: #fff; }
.cal-btn:disabled { opacity: 0.35; cursor: default; }
.cal-btn--text, .cal-views button {
  width: auto; height: 2.5rem; border-radius: 999px; padding: 0 1.1rem;
  font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; font-size: 0.85rem;
}
.cal-views { display: inline-flex; border: 1px solid rgba(36, 22, 27, 0.25); border-radius: 999px; padding: 3px; background: var(--paper); }
.cal-views button { height: 2.1rem; border: 0; background: none; color: var(--ink-soft); cursor: pointer; }
.cal-views button[aria-pressed="true"] { background: var(--crimson); color: #fff; }
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; list-style: none; margin: 0;
  padding: 0.75rem clamp(1rem, 2.5vw, 1.6rem);
  font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; font-size: 0.8rem; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.cal-legend li { display: inline-flex; align-items: center; gap: 0.5em; }
.cal-legend li::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.cat-school { --c: var(--c-school, #8f0038); }
.cat-study { --c: var(--c-study, #c69a3b); }
.cat-special { --c: var(--c-special, #1f6b48); }

/* Month grid */
.cal-grid { display: grid; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow div {
  padding: 0.55rem 0.7rem;
  font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 600; font-size: 0.78rem; color: var(--ink-soft);
  background: var(--paper-2); border-bottom: 1px solid var(--line);
}
.cal-day {
  min-height: 118px; padding: 0.45rem 0.45rem 0.6rem;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.3rem; min-width: 0;
}
.cal-row .cal-day:last-child { border-right: 0; }
.cal-row:last-child .cal-day { border-bottom: 0; }
.cal-day .num {
  font-family: var(--f-label); font-weight: 600; font-size: 0.95rem; color: var(--ink);
  width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 50%; margin-left: -0.15rem;
}
.cal-day.out { background: repeating-linear-gradient(135deg, rgba(36, 22, 27, 0.025) 0 6px, transparent 6px 12px); }
.cal-day.out .num { color: rgba(36, 22, 27, 0.3); }
.cal-day.out .cal-chip { opacity: 0.45; }
.cal-day.today { background: #fff6e2; }
.cal-day.today .num { background: var(--crimson); color: #fff; }

.cal-chip {
  display: grid; grid-template-columns: auto 1fr; column-gap: 0.4em; align-items: baseline;
  width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-size: 0.82rem; line-height: 1.25; color: var(--ink);
  background: color-mix(in srgb, var(--c) 10%, #fff); border: 0; border-left: 3px solid var(--c);
  border-radius: 3px; padding: 0.3rem 0.45rem;
  transition: background 0.15s ease, transform 0.15s ease;
}
.cal-chip:hover, .cal-chip:focus-visible { background: color-mix(in srgb, var(--c) 20%, #fff); transform: translateY(-1px); }
.cal-chip .t { font-family: var(--f-label); font-weight: 600; letter-spacing: 0.04em; color: color-mix(in srgb, var(--c) 80%, #000); white-space: nowrap; }
.cal-chip .n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip .s { grid-column: 2; font-size: 0.78rem; color: var(--ink-soft); }
/* Month cells are narrow: stack time over name so nothing gets cut off. */
.cal-grid .cal-chip { grid-template-columns: 1fr; }
.cal-grid .cal-chip .n { white-space: normal; overflow: visible; }
.cal-grid .cal-chip .s { grid-column: 1; }
.cal-chip.cat-study .t { color: #7a5a14; }

/* List view */
.cal-list { list-style: none; margin: 0; padding: 0; }
.cal-list-day {
  display: grid; grid-template-columns: 4.2rem 1fr; gap: 1rem;
  padding: 0.9rem clamp(1rem, 2.5vw, 1.6rem); border-bottom: 1px solid var(--line);
}
.cal-list-day:last-child { border-bottom: 0; }
.cal-list-day.today { background: #fff6e2; }
.cal-list-date { text-align: center; line-height: 1; }
.cal-list-date .dow { display: block; font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 600; font-size: 0.78rem; color: var(--crimson); margin-bottom: 0.25rem; }
.cal-list-date .dd { font-family: var(--f-display); font-size: 2rem; }
.cal-list-items { display: grid; gap: 0.45rem; align-content: start; }
.cal-list-items .cal-chip { font-size: 0.98rem; padding: 0.55rem 0.75rem; }
.cal-list-items .cal-chip .n { white-space: normal; }
.cal-empty { padding: 2.5rem 1.5rem; text-align: center; color: var(--ink-soft); font-style: italic; margin: 0; }

/* Standing weekly items (not on the Google Calendar), set like a line from a
   printed bulletin: label + event, separated by small crimson crosses. */
.cal-foot {
  padding: 1.25rem clamp(1rem, 2.5vw, 1.6rem) 0.6rem; background: var(--paper-2); border-top: 1px solid var(--line);
}
/* The weekly standing services: three even columns, each with its day on top
   (marked with a small cross) and the service beneath, split by fine rules. */
.cal-standing {
  list-style: none; margin: 0; padding: 0 0 1.1rem;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px dashed rgba(36, 22, 27, 0.18);
}
.cal-standing li {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 0.15rem 1rem; text-align: center;
}
.cal-standing li + li { border-left: 1px solid var(--line); }
.cal-standing-when {
  display: inline-flex; align-items: center; gap: 0.55em;
  font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; font-size: 0.8rem;
  color: var(--crimson);
}
.cal-standing-when::before {
  content: ""; width: 8px; height: 11px; flex: none;
  background: var(--cross-crimson) center / contain no-repeat;
}
.cal-standing-what { font-family: var(--f-display); font-size: 1.25rem; line-height: 1.2; color: var(--ink); text-wrap: balance; }
.cal-standing-what small { display: block; margin-top: 0.15rem; font-family: var(--f-body); font-size: 0.9rem; color: var(--ink-soft); }
.cal-foot-bar { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem 1.5rem; flex-wrap: wrap; margin-top: 0.4rem; }
.cal-foot-bar p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); font-style: italic; }
@media (max-width: 760px) {
  /* Phones: one service per row, left aligned, split by fine rules. */
  .cal-standing { grid-template-columns: minmax(0, 1fr); padding-bottom: 0.4rem; }
  .cal-standing li { align-items: flex-start; text-align: left; gap: 0.2rem; padding: 0.7rem 0; }
  .cal-standing li:first-child { padding-top: 0; }
  .cal-standing li + li { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .cal-views { display: none; }
  .cal-nav { width: 100%; justify-content: space-between; }
  .cal-actions { width: 100%; justify-content: center; }
}

/* Details dialog */
.cal-dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  border: 0; border-top: 5px solid var(--crimson); border-radius: 6px; padding: 1.8rem 1.8rem 1.5rem;
  background: #fffdf9; color: var(--ink);
  box-shadow: 0 30px 70px rgba(20, 8, 12, 0.35);
}
.cal-dialog::backdrop { background: rgba(42, 6, 18, 0.55); backdrop-filter: blur(2px); }
.cal-dialog h3 { font-size: clamp(1.7rem, 1.4rem + 1vw, 2.2rem); margin: 0.5rem 2.5rem 0.3rem 0; }
.cal-dialog p { font-size: 1.02rem; }
.cal-close {
  position: absolute; top: 0.8rem; right: 0.8rem; width: 2.3rem; height: 2.3rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper); font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--ink);
  transition: color 0.22s ease, background-color 0.22s ease, border-color 0.22s ease, box-shadow 0.25s ease;
}
.cal-close:hover { background: var(--crimson); color: #fff; border-color: var(--crimson); }
.cal-dialog-cat {
  display: inline-flex; align-items: center; gap: 0.5em;
  font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; font-size: 0.8rem; color: var(--ink-soft);
}
.cal-dialog-cat::before { content: ""; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.cal-when { font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; font-size: 0.92rem; color: var(--crimson); }
.cal-classes { list-style: none; padding: 0; margin: 0 0 1rem; border-top: 1px solid var(--line); }
.cal-classes li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 0.3rem 1rem; flex-wrap: wrap; }
.cal-classes b { font-family: var(--f-display); font-weight: 400; font-size: 1.15rem; }
.cal-classes span { color: var(--ink-soft); font-size: 0.98rem; }
.cal-meta { margin: 0.4rem 0 0; font-size: 0.98rem; color: var(--ink-soft); }
.cal-meta b { font-family: var(--f-label); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; font-size: 0.8rem; color: var(--ink); margin-right: 0.5rem; }

/* Calendar footer link: a comfortable tap target. */
.cal-foot .card-more { display: inline-flex; align-items: center; min-height: 44px; }

/* "Today" button: only shown after paging away from the current month. */
.cal-btn--text[data-cal-today] { opacity: 0; visibility: hidden; transform: translateY(-3px); transition: opacity 0.25s ease, transform 0.3s ease, visibility 0s linear 0.3s, background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.cal-btn--text[data-cal-today].is-away { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
@keyframes today-pulse { 0% { box-shadow: inset 0 0 0 0 rgba(198, 154, 59, 0); } 30% { box-shadow: inset 0 0 0 3px rgba(198, 154, 59, 0.9); } 100% { box-shadow: inset 0 0 0 0 rgba(198, 154, 59, 0); } }
.cal-day.today.pulse, .cal-list-day.today.pulse { animation: today-pulse 1.4s ease-out; }
/* On phones the Today button is alone on its row; drop the row until it's needed. */
@media (max-width: 760px) { .cal-actions:not(:has(.is-away)) { display: none; } }
