/* ============================================================================
   Unity of Raleigh — month calendar
   ----------------------------------------------------------------------------
   Built on the tokens in styles.css so a palette change carries through here
   rather than drifting.

   The design brief was "not Google's embed". That view looks bad for three
   reasons — a dense border grid, grey-on-grey, and generic chips — so every
   choice below pushes the other way: space instead of boxes, hairlines only
   between weeks, and chips that carry their event's own colour.

   Restraint is deliberate. There are no images in the cells: a month of
   thumbnails reads as noise. Imagery belongs in the day panel and the list.
   ========================================================================== */

.cal-wrap {
  --cal-gap:        0.28rem;
  --cal-cell-h:     7.5rem;
  --cal-hairline:   #ece7dd;

  /* One colour per event family, matched by the same keyword logic that picks
     an event's photo (getImage in js/main.js) — so there is one taxonomy, not
     two, and a new keyword improves both at once.
     Colour is never the only signal: every chip also carries its title. */
  --cal-service:    #1e2a4a;  --cal-service-bg:  rgba(30, 42, 74, 0.07);
  --cal-study:      #55648a;  --cal-study-bg:    rgba(107, 122, 153, 0.11);
  --cal-wellness:   #a87820;  --cal-wellness-bg: rgba(168, 120, 32, 0.11);
  --cal-prayer:     #2d3f6b;  --cal-prayer-bg:   rgba(45, 63, 107, 0.09);
  --cal-outreach:   #3f7a5a;  --cal-outreach-bg: rgba(63, 122, 90, 0.11);
  --cal-music:      #b8891f;  --cal-music-bg:    rgba(201, 149, 42, 0.12);
  --cal-other:      #5a6070;  --cal-other-bg:    rgba(90, 96, 112, 0.08);
}

/* Visually hidden but still announced. The site had no such utility, and the
   admin pages' .da-sr lives inside their own inline <style>, so it is not
   available here. */
.cal-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── The view bar: month navigation + List/Calendar toggle ───────────────── */

.cal-viewbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.cal-viewbar__left {
  display: flex;
  align-items: center;
  min-height: 2.25rem;          /* holds the row's height when the nav is away */
}

.cal-monthnav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Names the view you are looking at, and leads the row. The month beside it is
   deliberately smaller: both are set in Lora, so without a clear size
   difference they read as one run-on phrase rather than a label and its value. */
.cal-viewlabel {
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--color-indigo);
  white-space: nowrap;
  margin: 0 1.75rem 0 0;        /* the gap that separates label from controls */
}

.cal-viewlabel--list { margin-right: 0; }

/* Only the label belonging to the current view is shown, and the one that is
   hidden is removed rather than made invisible — otherwise it would hold empty
   space in the middle of the row. */
.cal-wrap[data-view="grid"] .cal-viewlabel--list { display: none; }
.cal-wrap[data-view="list"] .cal-monthnav        { display: none; }

/* The list keeps a comfortable reading measure while the grid uses the full
   container. Was an inline style on the list element. */
.cal-list-inner {
  max-width: 912px;
  margin: 0 auto;
  padding-right: 6px;
}

.cal-navbtn {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-border);
  background: var(--color-white);
  border-radius: var(--radius-full);
  color: var(--color-indigo);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cal-navbtn:hover:not(:disabled) { background: var(--color-cream); border-color: var(--color-slate-light); }
.cal-navbtn:disabled             { opacity: 0.35; cursor: default; }

.cal-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 11ch;         /* stops the arrows shuffling as month names change */
  text-align: center;
  margin: 0 0.35rem;
}

.cal-today {
  border: none;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.cal-today:hover     { color: var(--color-indigo); }
.cal-today[hidden]   { display: none; }

.cal-viewbar__right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Quieter than the toggle beside it — printing is an occasional action, not a
   choice about how to read the page. */
.cal-print {
  border: 1px solid var(--color-border);
  background: var(--color-white);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.cal-print:hover { color: var(--color-indigo); border-color: var(--color-slate-light); }

/* Segmented control. Two buttons rather than a checkbox: each view is a
   destination with its own label, and aria-pressed says which one you are on. */
.cal-toggle {
  display: inline-flex;
  padding: 3px;
  background: var(--color-cream-dark);
  border-radius: var(--radius-full);
}

.cal-toggle__btn {
  border: none;
  background: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.cal-toggle__btn:hover { color: var(--color-indigo); }
.cal-toggle__btn[aria-pressed="true"] {
  background: var(--color-indigo);
  color: var(--color-white);
  box-shadow: var(--shadow-sm);
}

/* Which view is showing. Set by js/calendar-grid.js on .cal-wrap; CSS is the
   single authority on visibility so the mobile breakpoint can override it
   without contradicting an attribute. */
.cal-wrap[data-view="grid"] .cal-list-view     { display: none; }
.cal-wrap[data-view="list"] .cal-calendar-view { display: none; }
.cal-wrap[data-view="list"] .cal-monthnav      { visibility: hidden; }

/* ── The grid ────────────────────────────────────────────────────────────── */

/* A real <table>, not a pile of divs. Screen readers already know how to walk a
   grid of dates when it is marked up as one, and it gives us column headers for
   free. */
.cal {
  width: 100%;
  border-collapse: separate;
  border-spacing: var(--cal-gap);
  table-layout: fixed;                /* seven equal columns regardless of content */
}

.cal caption {
  caption-side: top;
  text-align: left;
  font-size: 0;                       /* the visible title lives in .cal-title */
}

.cal th {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--color-slate);
  padding: 0 0 0.5rem;
  text-align: center;
}

.cal td {
  vertical-align: top;
  height: var(--cal-cell-h);          /* on a cell this behaves as a minimum */
  padding: 0.4rem 0.4rem 0.5rem;
  background: var(--color-white);
  border-radius: var(--radius-sm);
  border-top: 1px solid var(--cal-hairline);
}

/* Sunday leads a church week, so the column gets a whisper of tint rather than
   a heading or a rule — enough to anchor the eye, not enough to shout. */
.cal td:first-child { background: #fdfcf9; }

.cal-day--outside   { background: transparent !important; border-top-color: transparent; }
.cal-day--outside .cal-day__num { color: #cfc9bd; }

.cal-day__num {
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  height: 1.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums; /* dates line up column to column */
  color: var(--color-text);
  border-radius: var(--radius-full);
  margin-bottom: 0.3rem;
}

.cal-day--today .cal-day__num {
  background: var(--color-gold);
  color: var(--color-white);
}

/* Clickable days lift very slightly. Days with nothing on stay inert — there is
   nothing to open, and a hover state would promise otherwise. */
.cal-day--has-events { cursor: pointer; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.cal-day--has-events:hover,
.cal-day--has-events:focus-visible {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  outline: none;
}
.cal-day--has-events:focus-visible { box-shadow: 0 0 0 2px var(--color-gold); }

.cal-day--selected { box-shadow: 0 0 0 2px var(--color-indigo) !important; }

/* ── Event chips ─────────────────────────────────────────────────────────── */

/* Chips are real <button>s: they are the keyboard route into a day, which is
   what lets the day cell itself stay a plain <td> and keeps the table's
   semantics intact for screen readers. Hence the reset. */
.cal-chip {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.35;
  padding: 0.15rem 0.35rem 0.15rem 0.45rem;
  margin-bottom: 0.18rem;
  border: none;
  border-left: 3px solid var(--cal-other);
  background: var(--cal-other-bg);
  border-radius: 0 3px 3px 0;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Present in the page but not shown on screen — the day cell would grow to fit
   five events and the month would lose its rhythm. Print puts them back. */
.cal-chip--overflow { display: none; }

.cal-chip:hover { filter: brightness(0.96); }
.cal-chip:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 1px;
}

.cal-chip__time { font-variant-numeric: tabular-nums; color: var(--color-text-muted); margin-right: 0.2rem; }

.cal-chip--service  { border-left-color: var(--cal-service);  background: var(--cal-service-bg); }
.cal-chip--study    { border-left-color: var(--cal-study);    background: var(--cal-study-bg); }
.cal-chip--wellness { border-left-color: var(--cal-wellness); background: var(--cal-wellness-bg); }
.cal-chip--prayer   { border-left-color: var(--cal-prayer);   background: var(--cal-prayer-bg); }
.cal-chip--outreach { border-left-color: var(--cal-outreach); background: var(--cal-outreach-bg); }
.cal-chip--music    { border-left-color: var(--cal-music);    background: var(--cal-music-bg); }

.cal-more {
  display: block;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 0 0 0 0.45rem;
  margin-top: 0.1rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cal-more:hover { color: var(--color-indigo); }

/* ── Day detail panel ────────────────────────────────────────────────────── */

.cal-panel {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.cal-panel[hidden] { display: none; }

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

.cal-panel__date {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--color-indigo);
  margin: 0;
}

.cal-panel__close {
  border: none;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.cal-panel__close:hover { color: var(--color-indigo); }

/* ── States ──────────────────────────────────────────────────────────────── */

.cal-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .cal-wrap      { --cal-cell-h: 6rem; }
  .cal-chip      { font-size: 0.7rem; }
  .cal-viewlabel { font-size: 1.2rem; margin-right: 1rem; }
  .cal-title     { font-size: 1.05rem; }
}

/* Below this a seven-column grid stops being a calendar and starts being a
   puzzle. The list is genuinely the better view on a phone, so the grid and its
   toggle step aside entirely rather than degrading into something cramped.
   Because visibility is driven by [data-view] rather than the `hidden`
   attribute, this override cannot leave anything visible-but-hidden to a
   screen reader. */
@media (max-width: 640px) {
  .cal-viewbar { display: none; }
  .cal-wrap[data-view="grid"] .cal-calendar-view { display: none; }
  .cal-wrap[data-view="grid"] .cal-list-view     { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .cal-navbtn, .cal-toggle__btn, .cal-day--has-events { transition: none; }
  .cal-day--has-events:hover { transform: none; }
}

/* ── Print ───────────────────────────────────────────────────────────────── */

/* Both views print, and whichever one is on screen is the one that comes out.
   The earlier version always hid the list, so printing from list view produced
   a blank page.
   Note there is no [data-view] switching here: the rules above already hide the
   view you are not looking at, and repeating them would only create a second
   place to keep in step. */
@media print {

  /* Screen-only chrome. */
  .site-header,
  .site-footer,
  .breadcrumb-bar,
  .page-hero,
  .cal-toggle,
  .cal-print,
  .cal-navbtn,
  .cal-today,
  .cal-panel,
  .donate-modal,
  .gcal-actions { display: none !important; }

  .section { padding-block: 0 !important; }

  /* The heading block becomes a title: "Calendar View" over "August 2026", or
     just "List View". */
  .cal-viewbar       { display: block; margin-bottom: 0.5rem; }
  .cal-viewbar__left { display: block; min-height: 0; }
  .cal-monthnav      { display: block; }
  .cal-viewlabel     { display: block; font-size: 12pt; color: #000; margin: 0 0 0.1rem; }
  .cal-title {
    display: block;
    font-size: 17pt;
    text-align: left;
    min-width: 0;
    margin: 0 0 0.3rem;
    color: #000;
  }

  /* ── Grid ─────────────────────────────────────────────── */

  .cal { border-spacing: 0; border-collapse: collapse; }

  .cal th {
    color: #000;
    border-bottom: 1pt solid #000;
    font-size: 8pt;
  }

  .cal td {
    border: 0.5pt solid #999;
    height: auto;
    min-height: 0;
    padding: 3pt;
    background: none !important;
  }

  .cal-day__num { color: #000; font-size: 9pt; margin-bottom: 2pt; }

  /* The gold disc would print as a grey blob and mean nothing on paper. */
  .cal-day--today .cal-day__num { background: none; color: #000; text-decoration: underline; }

  /* On paper there is no hover and no panel, so nothing may hide behind
     "+2 more": every event in the month appears, wrapped rather than clipped.
     overflow-wrap is doing real work here — the table is fixed-layout, so a
     long unbroken word ("Restauracion") would otherwise run straight through
     the day's right-hand border and into the next. */
  .cal-chip,
  .cal-chip--overflow {
    display: block;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
    font-size: 7.5pt;
    line-height: 1.25;
    background: none !important;
    border-left: 2pt solid #000;
    color: #000;
    break-inside: avoid;
  }

  /* Its whole job was to stand in for what is now printed in full. */
  .cal-more { display: none; }

  /* Titles are the long text; keep them from stretching the fixed columns. */
  .cal td { overflow-wrap: anywhere; }

  /* ── List ─────────────────────────────────────────────── */

  .cal-list-inner { max-width: none; padding: 0; }

  /* The list is built with inline styles, so overriding it needs !important. */
  .gcal-item {
    display: block !important;
    border: 0 !important;
    border-bottom: 0.5pt solid #999 !important;
    border-radius: 0 !important;
    margin: 0 0 6pt !important;
    padding-bottom: 5pt;
    break-inside: avoid;
  }

  /* The photo goes: it is decorative, and a page of them costs a cartridge. */
  .gcal-item__media img { display: none !important; }

  /* Which leaves the date badge floating over nothing — so it stops being
     white-on-black and becomes a plain line of text above the title. */
  .gcal-item__media {
    position: static !important;
    overflow: visible !important;
  }
  .gcal-item__date {
    position: static !important;
    background: none !important;
    color: #000 !important;
    text-align: left !important;
    padding: 0 !important;
    font-size: 9pt !important;
  }
  .gcal-item__date span { display: inline !important; font-size: 9pt !important; }
  .gcal-item__date span:first-child::after { content: ' '; }

  .gcal-item__body { padding: 0 !important; display: block !important; }
  .gcal-item__body h4 { font-size: 11pt !important; color: #000 !important; }
  .gcal-item__body p  { font-size: 9pt !important; color: #000 !important; }

  .cal-wrap { break-inside: auto; }

  /* Orientation is set by js/calendar-grid.js, which knows which view is
     showing: landscape suits seven columns, portrait suits a list. This is the
     fallback when scripting is off. */
  @page { margin: 12mm; }
}
