/* ============================================================
   Dampierre-en-Yvelines — l'app des administrés
   DA v2 : « le village à la pointe ». Clair et chaleureux mais
   vivant : hero dégradé vert forêt, tuiles colorées, tabbar
   flottante glassy, micro-animations. Fraunces / Inter.
   Mobile-first absolu ; desktop cappé à 460px centré.
   ============================================================ */

:root {
  --bg: #f4f2ea;
  --surface: #ffffff;
  --ink: #22281f;
  --ink-soft: #5f675c;
  --ink-faint: #989e91;
  --line: #e6e3d7;

  --green: #1b4030;
  --green-mid: #2c5e43;
  --green-soft: #e4ede3;
  --ocre: #a06b1e;
  --cream: #f6f4ee;

  --grad-hero: linear-gradient(140deg, #16382a 0%, #245239 55%, #38704e 100%);
  --grad-green: linear-gradient(135deg, #245239, #38704e);

  --font-head: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 20px;
  --shadow: 0 1px 2px rgba(34, 40, 31, 0.04), 0 8px 24px rgba(34, 40, 31, 0.07);
  --shadow-green: 0 10px 30px rgba(27, 64, 48, 0.28);
  --ease-spring: cubic-bezier(0.2, 0.7, 0.2, 1);
  --tabbar-h: 66px;
}

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

html, body { overflow-x: clip; } /* clip, pas hidden : garde la tabbar fixed ancrée au viewport (gotcha iOS) */

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 30px);
}

/* Aurora discrète : le fond respire au lieu d'être plat */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(560px 380px at 88% -6%, rgba(56, 112, 78, 0.13), transparent 65%),
    radial-gradient(480px 340px at -12% 24%, rgba(160, 107, 30, 0.09), transparent 60%),
    var(--bg);
}

a { color: var(--green-mid); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }

/* ── Cadre desktop : l'app reste un objet mobile ─────────────── */
@media (min-width: 600px) {
  body {
    max-width: 460px;
    margin: 0 auto;
    box-shadow: 0 0 0 1px var(--line), 0 18px 60px rgba(34, 40, 31, 0.14);
    min-height: 100vh;
  }
  body::before { max-width: 460px; left: 50%; transform: translateX(-50%); }
  .brand { max-width: 460px; left: 50%; transform: translateX(-50%); }
  .tabbar { width: min(calc(100% - 28px), 432px); }
}

/* ── Header identité ─────────────────────────────────────────── */
.brand {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  text-decoration: none;
  color: var(--ink);
}
.brand-mark { display: grid; place-items: center; }
.brand-mark img { display: block; filter: drop-shadow(0 1px 2px rgba(34, 40, 31, 0.18)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.06rem;
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ocre);
}

/* ── Routes ──────────────────────────────────────────────────── */
.route { display: none; }
.route.active { display: block; }

.section { padding: 18px 18px 8px; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 12px 0 6px;
}
.section-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.55rem;
  color: var(--green);
}
.section-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-faint);
}
.section > .muted.small { margin-bottom: 14px; }

/* ── Hero (tab Actus) ────────────────────────────────────────── */
.hero {
  position: relative;
  margin: 12px 14px 0;
  padding: 24px 22px 52px;
  border-radius: 26px;
  background: var(--grad-hero);
  box-shadow: var(--shadow-green);
  color: var(--cream);
  overflow: hidden;
}
.hero::after {
  /* reflet doux en haut à droite */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(320px 200px at 85% -20%, rgba(246, 236, 200, 0.18), transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; }
.hero-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--cream) 62%, transparent);
  margin-bottom: 7px;
}
.hero-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.85rem;
  line-height: 1.12;
  letter-spacing: 0.005em;
}
.hero-sub {
  margin-top: 7px;
  font-size: 0.92rem;
  color: color-mix(in srgb, var(--cream) 78%, transparent);
}
.hero-mark {
  position: absolute;
  right: -26px;
  bottom: -34px;
  width: 158px;
  height: 158px;
  color: rgba(246, 244, 238, 0.07);
  transform: rotate(-8deg);
}

/* Les accès rapides chevauchent le hero */
.section-hero-overlap { padding-top: 0; }
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: -36px 0 24px;
  position: relative;
  z-index: 2;
}
.quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 13px 4px 11px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s var(--ease-spring), box-shadow 0.15s ease;
}
.quick:active { transform: scale(0.93); }
.quick-ic {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
}
.ic-green { background: #e2efe4; color: #2c5e43; }
.ic-ocre  { background: #f7ecd5; color: #a06b1e; }
.ic-red   { background: #fbe4dc; color: #c04a2e; }
.ic-blue  { background: #e0ebf7; color: #1f5a95; }
.quick-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  color: var(--ink-soft);
}

/* ── Entrée en cascade des listes ────────────────────────────── */
.route.active .card,
.route.active .event,
.route.active .group,
.route.active .month-label,
.route.active .hero,
.route.active .quick-grid {
  animation: rise 0.5s var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.route.active .quick-grid { --i: 1; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ── Cards actus ─────────────────────────────────────────────── */
.cards { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 18px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 17px 18px 16px;
  transition: transform 0.15s var(--ease-spring);
}
.card:active { transform: scale(0.985); }
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.card-date { font-size: 0.78rem; font-weight: 500; color: var(--ink-faint); }
.card-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.18rem;
  line-height: 1.28;
  margin-bottom: 7px;
}
.card-text { font-size: 0.94rem; color: var(--ink-soft); }
.card-link {
  display: inline-block;
  margin-top: 11px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

/* La une : la première actu est mise en scène */
.card.featured {
  background: var(--grad-hero);
  box-shadow: var(--shadow-green);
  color: var(--cream);
  position: relative;
  overflow: hidden;
}
.card.featured::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(260px 170px at 90% -12%, rgba(246, 236, 200, 0.16), transparent 70%);
  pointer-events: none;
}
.card.featured .card-title { font-size: 1.34rem; color: var(--cream); }
.card.featured .card-text { color: color-mix(in srgb, var(--cream) 80%, transparent); }
.card.featured .card-date { color: color-mix(in srgb, var(--cream) 55%, transparent); }
.card.featured .card-link { color: var(--cream); text-decoration: underline; text-underline-offset: 3px; position: relative; z-index: 1; }
.card.featured .chip { background: rgba(246, 244, 238, 0.16); color: var(--cream); }

/* ── Chips catégories ────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  background: #edece2;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip-animations    { background: #f7e7cd; color: #8c5011; }
.chip-culture       { background: #ebe2f6; color: #654396; }
.chip-municipal     { background: var(--green-soft); color: var(--green); }
.chip-social        { background: #f7e2d6; color: #9c5028; }
.chip-sport         { background: #ddeaf8; color: #1f5a95; }
.chip-environnement { background: #e0f0da; color: #35703a; }

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 16px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-filter {
  padding: 8px 15px;
  font-size: 0.82rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.15s var(--ease-spring), background 0.2s ease, color 0.2s ease;
}
.chip-filter:active { transform: scale(0.94); }
.chip-filter.active {
  background: var(--grad-green);
  color: #fff;
  box-shadow: 0 6px 18px rgba(27, 64, 48, 0.3);
}

/* ── Agenda ──────────────────────────────────────────────────── */
.agenda { display: flex; flex-direction: column; gap: 12px; padding-bottom: 18px; }

.month-label {
  font-family: var(--font-head);
  font-weight: 600;
  font-style: italic;
  font-size: 1.08rem;
  color: var(--ocre);
  margin: 10px 0 0;
}

.event {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 15px;
  transition: transform 0.15s var(--ease-spring);
}
.event:active { transform: scale(0.985); }
.event-date {
  flex: 0 0 54px;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 9px 0 10px;
  background: var(--grad-green);
  border-radius: 15px;
  color: var(--cream);
  box-shadow: 0 5px 14px rgba(27, 64, 48, 0.24);
}
.event-weekday {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.75;
}
.event-day {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.1;
}
.event-body { min-width: 0; }
.event-body .card-meta { margin-bottom: 6px; }
.event-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.28;
}
.event-when {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--green-mid);
  margin: 3px 0 6px;
}
.event-text { font-size: 0.9rem; color: var(--ink-soft); }

/* ── Recherche ───────────────────────────────────────────────── */
.search-wrap { margin: 8px 0 16px; }
.search {
  width: 100%;
  padding: 14px 18px 14px 46px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23989e91' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.8-3.8'/%3E%3C/svg%3E") no-repeat 16px center / 19px;
  border: 0;
  border-radius: 999px;
  box-shadow: var(--shadow);
  -webkit-appearance: none;
  appearance: none;
}
.search::placeholder { color: var(--ink-faint); }
.search:focus { outline: 2px solid var(--green-mid); outline-offset: -1px; }

/* ── Groupes accordéon (Démarches + Ma ville) ────────────────── */
.groups { display: flex; flex-direction: column; gap: 12px; padding-bottom: 18px; }

.group {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  scroll-margin-top: calc(66px + env(safe-area-inset-top)); /* deep-link : ne pas passer sous le header sticky */
}
.group-head {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
}
.group-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  font-size: 1.22rem;
  line-height: 1;
  background: color-mix(in srgb, var(--green-soft) 65%, var(--surface));
  border-radius: 13px;
}
.group-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.group-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.08rem;
  flex: 1;
}
.group-titles .group-title { flex: initial; }
.group-sub { font-size: 0.8rem; color: var(--ink-faint); }
.group-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 2px 9px;
}
.group-caret {
  font-size: 1.3rem;
  color: var(--ink-faint);
  transform: rotate(90deg);
  transition: transform 0.3s var(--ease-spring);
}
.group.open .group-caret { transform: rotate(-90deg); }

/* Dépliage fluide : grid-rows 0fr → 1fr */
.group-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.34s var(--ease-spring);
}
.group.open .group-body { grid-template-rows: 1fr; }
.group-body-in { overflow: hidden; min-height: 0; border-top: 1px solid var(--line); }

/* Items de démarche (accordéon interne) */
.item { border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 13px 16px;
  text-align: left;
}
.item-head:active { background: color-mix(in srgb, var(--green-soft) 55%, transparent); }
.item-title { font-weight: 600; font-size: 0.98rem; transition: color 0.2s ease; }
.item-summary { font-size: 0.83rem; color: var(--ink-faint); }
.item-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s var(--ease-spring);
}
.item.open .item-body { grid-template-rows: 1fr; }
.item-body-in { overflow: hidden; min-height: 0; padding: 0 16px; }
.item.open .item-body-in { padding-bottom: 16px; }
.item.open .item-head .item-title { color: var(--green); }
.item-body p { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 9px; }

.item-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 4px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s var(--ease-spring);
}
.btn:active { transform: scale(0.95); }
.btn-link { background: var(--grad-green); color: #fff; box-shadow: 0 5px 14px rgba(27, 64, 48, 0.24); }
.btn-tel { background: var(--green-soft); color: var(--green); }

/* Lignes info (Ma ville) */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}
.row:last-child { border-bottom: 0; }
.row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.row-label { font-weight: 600; font-size: 0.94rem; }
.row-detail { font-size: 0.84rem; color: var(--ink-soft); }
.row-glyph { font-size: 0.95rem; color: var(--green-mid); flex: 0 0 auto; }
.row-action:active { background: color-mix(in srgb, var(--green-soft) 55%, transparent); }

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 26px 10px 8px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.app-footer p + p { margin-top: 8px; }

/* ── Tab bar flottante ───────────────────────────────────────── */
.tabbar {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  z-index: 40;
  display: flex;
  padding: 6px;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 26px;
  box-shadow: 0 10px 34px rgba(34, 40, 31, 0.18);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 7px;
  border-radius: 20px;
  text-decoration: none;
  color: var(--ink-faint);
  transition: color 0.2s ease, background 0.25s var(--ease-spring), transform 0.15s var(--ease-spring);
}
.tab:active { transform: scale(0.94); }
.tab-label { font-size: 0.64rem; font-weight: 650; letter-spacing: 0.02em; }
.tab.active {
  color: var(--green);
  background: var(--green-soft);
}

/* ── Accessibilité ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
:focus-visible { outline: 2px solid var(--green-mid); outline-offset: 2px; }
