:root {
  --bg: #f4f4f2;
  --bg-elevated: #ffffff;
  --text: #2b2b2b;
  --title: #1f1f1f;
  --muted: #7a7168;
  --faint: #9a9a9a;
  --border: #e6e6e6;
  --accent: #6d4c5c;
  --accent-soft: #efe3e8;
  --shadow: 0 1px 2px rgba(30, 20, 15, .05), 0 10px 28px -14px rgba(30, 20, 15, .16);
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1b1817;
  --bg-elevated: #252120;
  --text: #ded7cf;
  --title: #f3ede6;
  --muted: #a89d92;
  --faint: #8a8079;
  --border: #3a332f;
  --accent: #e2b6c8;
  --accent-soft: #3a2a30;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px -14px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1817; --bg-elevated: #252120; --text: #ded7cf; --title: #f3ede6;
    --muted: #a89d92; --faint: #8a8079; --border: #3a332f;
    --accent: #e2b6c8; --accent-soft: #3a2a30;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 28px -14px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

/* ==========================================================================
   Identite par organisation : chaque organisation peut redefinir les memes
   variables ci-dessus (rien d'autre) pour avoir son propre habillage sans
   toucher au reste du site.
========================================================================== */
body[data-org="Chapelle"] {
  --bg: #f2ede4; --bg-elevated: #faf8f3; --text: #2c2c30; --title: #1c1c22;
  --muted: #64626b; --faint: #97949c; --border: #dcd6c9;
  --accent: #35577a; --accent-soft: #dbe4ec;
}
:root[data-theme="dark"] body[data-org="Chapelle"] {
  --bg: #1a1d22; --bg-elevated: #23272e; --text: #dfe1e6; --title: #f1f2f5;
  --muted: #a3a8b3; --faint: #767c88; --border: #363c46;
  --accent: #7ea3c4; --accent-soft: #26333f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-org="Chapelle"] {
    --bg: #1a1d22; --bg-elevated: #23272e; --text: #dfe1e6; --title: #f1f2f5;
    --muted: #a3a8b3; --faint: #767c88; --border: #363c46;
    --accent: #7ea3c4; --accent-soft: #26333f;
  }
}

body[data-org="Galerie"] {
  --bg: #ebe1cc; --bg-elevated: #f4ecd9; --text: #2a2019; --title: #241b15;
  --muted: #5c4c3d; --faint: #8a7a67; --border: #ddd0b8;
  --accent: #b5583c; --accent-soft: #f0ddd0;
}
/* data-theme est pose sur <html> (voir app.js initTheme), pas sur <body> ou
   vit data-org : selecteur descendant, pas un selecteur compose sur le meme
   element. */
:root[data-theme="dark"] body[data-org="Galerie"] {
  --bg: #1f1712; --bg-elevated: #2a1f18; --text: #e8dcc8; --title: #f4ead9;
  --muted: #b8a58e; --faint: #8f7c68; --border: #4a382c;
  --accent: #d97a58; --accent-soft: #3d281e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-org="Galerie"] {
    --bg: #1f1712; --bg-elevated: #2a1f18; --text: #e8dcc8; --title: #f4ead9;
    --muted: #b8a58e; --faint: #8f7c68; --border: #4a382c;
    --accent: #d97a58; --accent-soft: #3d281e;
  }
}

@font-face {
  font-family: "Bitter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/bitter-bold.woff2") format("woff2");
}
body[data-org="Galerie"] .event-card h3,
body[data-org="Galerie"] .org-card h2 {
  font-family: "Bitter", Georgia, serif;
}
body[data-org="Galerie"] .event-card { border-top: 4px solid var(--accent); }

/* Bandeau terracotta en en-tete (comme la devanture) : le lettrage detoure
   a ete decoupe sur ce fond precis, il ne se fond proprement que dessus. */
body[data-org="Galerie"] .site-header {
  background: linear-gradient(175deg, var(--accent) 0%, #7c3b28 100%);
  border-bottom-color: #7c3b28;
}
body[data-org="Galerie"] .site-header p { color: #f4e5d2; opacity: .92; }
body[data-org="Galerie"] .site-nav a { color: #f4e5d2; }

.site-title-img { max-width: 420px; width: 90%; height: auto; display: block; margin: 0 auto; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px 60px; }
.wrap-wide { max-width: 1080px; }

/* ---------- Header ---------- */
.site-header {
  padding: 40px 20px 26px; text-align: center; border-bottom: 1px solid var(--border);
  background: var(--bg-elevated); position: relative;
}
.site-header h1 { font-size: 30px; margin: 0 0 8px; color: var(--title); }
.site-header p { color: var(--muted); font-size: 15px; margin: 0; max-width: 480px; margin: 0 auto; }
.site-nav { display: flex; justify-content: center; gap: 22px; margin-top: 20px; }
.site-nav a { color: var(--accent); text-decoration: none; font-weight: 700; font-size: 14px; }
.site-nav a:hover { text-decoration: underline; }
.theme-toggle {
  position: absolute; top: 18px; right: 18px; border: 1px solid var(--border); background: var(--bg-elevated);
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer; font-size: 15px; color: var(--text);
}

/* ---------- Filtres ---------- */
.filters { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 26px 0 8px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--muted);
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Sections ---------- */
.section { margin-top: 34px; }
.section h2 { font-size: 19px; color: var(--title); margin: 0 0 4px; }
.section .section-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.empty {
  text-align: center; color: var(--muted); font-size: 14px; padding: 30px 20px; border: 1px dashed var(--border);
  border-radius: var(--radius); background: var(--bg-elevated);
}

/* ---------- Cartes evenement ---------- */
.event-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 14px; box-shadow: var(--shadow); cursor: pointer;
}
.event-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.event-badge {
  display: inline-block; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 999px; color: #fff; flex-shrink: 0; margin: 0 6px 8px 0;
}
.event-card h3 { margin: 0 0 4px; font-size: 18px; color: var(--title); }
.event-sub { color: var(--muted); font-size: 13px; margin: 0; }
.event-sub span:not(:last-child)::after { content: " · "; }
.event-desc { margin-top: 12px; font-size: 14.5px; line-height: 1.6; color: var(--text); }
.event-desc p { margin: 0 0 10px; }
.event-toggle { font-size: 12.5px; font-weight: 700; color: var(--accent); margin-top: 6px; }
.event-desc-full p { text-align: center; }
.event-desc-full img { width: 100%; height: auto; border-radius: calc(var(--radius) - 4px); display: block; margin: 4px 0 14px; }
.event-infos {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
}
.event-infos-label { font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--faint); margin: 0 0 8px; }
.event-infos p { margin: 0 0 6px; font-size: 12.5px; color: var(--faint); line-height: 1.5; }
.event-card.collapsed .event-desc-full, .event-card.collapsed .event-infos { display: none; }
.event-card.expanded .event-desc-preview { display: none; }

/* ---------- Calendrier ---------- */
.cal-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 30px; }
/* Un seul lieu par site (Chapelle ou Galerie) : la grille a 2 colonnes n'a de
   sens que pour l'apercu combine interne, sinon la carte reste collee a
   gauche. On la centre a la place. */
body[data-org]:not([data-org=""]) .cal-columns { grid-template-columns: 1fr; max-width: 560px; margin-left: auto; margin-right: auto; }
.cal-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.cal-card h2 { margin: 0 0 16px; font-size: 18px; color: var(--title); }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 14px; color: var(--title); text-transform: capitalize; }
.cal-nav {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1;
}
.cal-nav:hover { background: var(--accent-soft); border-color: var(--accent); }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 10.5px;
  font-weight: 800; color: var(--faint); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px;
}
/* Rangees (semaines) plus espacees que les colonnes (jours) : une case
   reste bien identifiable comme sa propre boite (numero + barre de periode
   ensemble), sans se confondre avec le numero de la semaine suivante juste
   en dessous. */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); column-gap: 3px; row-gap: 10px; }
.cal-day {
  position: relative; aspect-ratio: 1 / 1; border-radius: 8px; display: flex; flex-direction: column;
  font-size: 12px; color: var(--text); overflow: visible;
  background: var(--bg); border: 1px solid var(--border);
}
.cal-day.cal-empty { visibility: hidden; background: none; border-color: transparent; }
.cal-day.has-events { cursor: pointer; }
.cal-day.has-events:hover { background: var(--accent-soft); }

/* Case : deux zones FIXES (numero en haut, piste de la barre en bas) qui ne
   bougent jamais, et une zone du milieu qui prend tout l'espace restant
   entre les deux — c'est cet espace reellement disponible (pas un tiers
   theorique) qui est centre pour le point d'un evenement ponctuel. */
.cal-day-top { flex: 0 0 24px; display: flex; align-items: center; justify-content: center; position: relative; }
.cal-day-mid { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; position: relative; }
.cal-day-bottom { flex: 0 0 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative; margin-bottom: 5px; }

.cal-daynum { position: relative; z-index: 1; }
.cal-day.today .cal-day-top::before {
  content: ""; position: absolute; left: 2px; right: 2px; height: 21px;
  border: 1.5px solid var(--accent); border-radius: 6px; z-index: 0;
}

.cal-dots {
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
  display: flex; justify-content: center; gap: 4px;
}
.cal-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Barre de periode : dans la piste fixe du bas, deborde dans l'espace entre
   les cases (bridge-left/right) pour former une bande continue sans
   separation d'un jour a l'autre de la meme periode. */
.cal-bar { display: block; width: 100%; }
.cal-bar.round-left { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.cal-bar.round-right { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.cal-bar.bridge-left { margin-left: -3px; }
.cal-bar.bridge-right { margin-right: -3px; }

.cal-legend { display: flex; gap: 16px; margin-top: 14px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.cal-legend span { display: flex; align-items: center; gap: 6px; }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-legend-tint { width: 16px; height: 8px; border-radius: 4px; display: inline-block; }
.cal-detail { margin-top: 18px; }
.cal-detail-date { font-size: 12.5px; font-weight: 800; color: var(--accent); text-transform: capitalize; margin: 0 0 10px; }
.cal-detail .event-card { cursor: pointer; }

@media (max-width: 780px) {
  .cal-columns { grid-template-columns: 1fr; }
}

/* ---------- Contact ---------- */
.org-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 18px; box-shadow: var(--shadow); border-top: 4px solid var(--accent);
}
.org-card h2 { margin: 0 0 4px; font-size: 20px; color: var(--title); }
.org-card .org-desc { color: var(--text); font-size: 14.5px; line-height: 1.6; margin: 10px 0 16px; white-space: pre-line; }
.org-line { font-size: 13.5px; color: var(--muted); margin: 4px 0; }
.org-line strong { color: var(--text); }
.org-line a { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center; color: var(--faint); font-size: 12px; padding: 40px 20px 10px;
}
.site-footer a { color: var(--faint); }

.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .site-header h1 { font-size: 24px; }
  .event-card { padding: 16px; }
}
