/* ── Mobile first — Fête de la Morue ── */
:root {
  --bleu-marine: #004972;
  --jaune-or: #E8B233;
  --jaune-or-alt: #EAB334;
  --orange: #F68A4E;
  --rouge-corail: #F05362;
  --rose-pale: #EF98A0;
  --blanc: #FFFFFF;
  --bleu-ecailles: #DFE8ED;

  --jour-couleur: var(--bleu-marine);
  --jour-couleur-light: rgba(0, 73, 114, 0.14);

  --font-titre: "Lalezar", "Twinkle Star", cursive;
  --font-titre-accent: "Twinkle Star", cursive;
  --font-texte: "Source Sans 3", system-ui, sans-serif;

  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 73, 114, 0.15);
  --header-h: auto;
  --bottom-nav-h: calc(56px + env(safe-area-inset-bottom, 0px));
  --map-h-liste: clamp(160px, 32dvh, 240px);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-texte);
  font-size: 15px;
  line-height: 1.45;
  color: var(--bleu-marine);
  background: var(--bleu-ecailles);
  touch-action: manipulation;
}

/* ── App shell (plein écran mobile) ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 100%;
  overflow: hidden;
}

/* ── Header compact ── */
.site-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--jour-couleur) 0%, color-mix(in srgb, var(--jour-couleur) 82%, #000) 100%);
  color: var(--blanc);
  transition: background var(--transition);
}

.header-inner {
  padding: 0.55rem 1rem 0.65rem;
  text-align: center;
}

.header-title {
  margin: 0;
  font-family: var(--font-titre);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.15;
}

.header-edition {
  font-family: var(--font-titre-accent);
  font-size: 0.85em;
  color: var(--blanc);
  white-space: nowrap;
}

/* ── Day tabs ── */
.day-nav {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--blanc);
  border-bottom: 1px solid rgba(0, 73, 114, 0.1);
}

.day-btn {
  flex: 1;
  padding: 7px 4px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-texte);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--blanc);
  position: relative;
  overflow: hidden;
  min-height: 34px;
  -webkit-tap-highlight-color: transparent;
}

.day-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.55;
  transition: opacity var(--transition);
}

.day-btn[data-day="2026-06-05"]::before { background: var(--rouge-corail); }
.day-btn[data-day="2026-06-06"]::before { background: var(--bleu-marine); }
.day-btn[data-day="2026-06-07"]::before { background: var(--jaune-or); }

.day-btn-label {
  position: relative;
  z-index: 1;
  display: block;
  white-space: nowrap;
  line-height: 1.2;
}

.day-btn-label small {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.92;
}

.day-btn[data-day="2026-06-07"] .day-btn-label,
.day-btn[data-day="2026-06-07"] .day-btn-label small { color: var(--bleu-marine); }

.day-btn.is-active::before { opacity: 1; }
.day-btn.is-active { box-shadow: inset 0 0 0 2px var(--blanc); }
.day-btn:not(.is-active) { opacity: 0.7; }

/* ── Banner ── */
.day-banner {
  flex-shrink: 0;
  background: var(--blanc);
  border-bottom: 3px solid var(--jour-couleur);
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  color: #444;
  line-height: 1.4;
}

/* ── Filtre activité ── */
.filters-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bleu-ecailles);
  border-bottom: 1px solid rgba(0, 73, 114, 0.08);
}

.filter-chip {
  flex: 1;
  min-width: 0;
  font-family: var(--font-texte);
  font-size: 0.9rem;
  font-weight: 600;
  height: 42px;
  padding: 0 38px 0 16px;
  border: 1.5px solid var(--jour-couleur-light);
  border-radius: 999px;
  background-color: var(--blanc);
  color: var(--bleu-marine);
  cursor: pointer;
  appearance: none;
  box-shadow: var(--shadow);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23004972' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  text-overflow: ellipsis;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.filter-chip:focus-visible {
  outline: none;
  border-color: var(--jour-couleur);
  box-shadow: 0 0 0 3px var(--jour-couleur-light);
}

.filter-reset {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--rouge-corail);
  color: var(--blanc);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, opacity var(--transition);
}

.filter-reset[hidden] { display: none; }

.filter-reset:active { transform: scale(0.9); }

/* ── Zone contenu ── */
.content-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Carte (toujours visible) ── */
.map-wrap {
  flex-shrink: 0;
  position: relative;
  height: var(--map-h-liste);
  transition: height 0.3s ease;
}

.content-area[data-view="carte"] .map-wrap {
  flex: 1;
  height: auto;
  min-height: 0;
}

.map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.btn-geoloc {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 500;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--blanc);
  color: var(--jour-couleur);
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-geoloc:active { transform: scale(0.92); }
.btn-geoloc.is-active { background: var(--jour-couleur); color: var(--blanc); }
.btn-geoloc.is-loading { opacity: 0.6; pointer-events: none; }

/* ── Liste programme ── */
.liste-meta {
  flex-shrink: 0;
  margin: 0;
  padding: 5px 12px;
  font-size: 0.75rem;
  color: #555;
  background: var(--bleu-ecailles);
  border-bottom: 1px solid rgba(0, 73, 114, 0.1);
}

.content-area[data-view="carte"] .liste-meta,
.content-area[data-view="partenaires"] .liste-meta,
.content-area[data-view="newsletter"] .liste-meta {
  display: none;
}

.panel-liste {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 12px;
  background: var(--bleu-ecailles);
}

.content-area[data-view="carte"] .panel-liste,
.content-area[data-view="partenaires"] .panel-liste,
.content-area[data-view="newsletter"] .panel-liste {
  display: none;
}

.content-area[data-view="partenaires"] .map-wrap,
.content-area[data-view="partenaires"] .panel-sheet,
.content-area[data-view="newsletter"] .map-wrap,
.content-area[data-view="newsletter"] .panel-sheet {
  display: none;
}

.content-area[data-view="liste"] .panel-sheet,
.content-area[data-view="partenaires"] .panel-sheet,
.content-area[data-view="newsletter"] .panel-sheet {
  display: none;
}

.time-group { margin-bottom: 12px; }

.time-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -8px 6px;
  padding: 6px 8px;
  position: sticky;
  top: -1px;
  z-index: 5;
  background: var(--bleu-ecailles);
  border-bottom: 1px solid rgba(0, 73, 114, 0.1);
}

.time-group-hour {
  font-family: var(--font-titre);
  font-size: 1.1rem;
  color: var(--jour-couleur);
  white-space: nowrap;
}

.time-group-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--jour-couleur), transparent);
}

/* ── Carte événement ── */
.event-card {
  position: relative;
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  box-shadow: var(--shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow var(--transition), transform var(--transition);
}

.event-card:active { transform: scale(0.99); }

.event-card.is-highlighted {
  z-index: 2;
  box-shadow: inset 0 0 0 2px var(--jour-couleur), var(--shadow);
}

.event-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.event-title {
  margin: 0;
  font-family: var(--font-titre);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--bleu-marine);
  line-height: 1.15;
  flex: 1;
  min-width: 0;
}

.event-typo {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--jour-couleur-light);
  color: var(--jour-couleur);
  line-height: 1.2;
  white-space: nowrap;
}

.event-lieu-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--orange);
  margin-bottom: 4px;
}

.event-lieu-row svg { flex-shrink: 0; }

.event-propose {
  font-size: 0.75rem;
  font-style: italic;
  opacity: 0.7;
  margin-bottom: 4px;
}

.event-text {
  margin: 0;
  font-size: 0.84rem;
  color: #555;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--blanc);
  border-radius: var(--radius);
}

.empty-state-emoji { font-size: 2rem; }
.empty-state p { margin: 0.5rem 0 0; color: #666; font-size: 0.9rem; }

/* ── Partenaires ── */
.panel-partenaires {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 12px 16px;
  background: var(--bleu-ecailles);
}

.partenaires-title {
  margin: 0 0 12px;
  font-family: var(--font-titre);
  font-size: 1.2rem;
  color: var(--jour-couleur);
  text-align: center;
}

.partenaires-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.partenaire-logo {
  aspect-ratio: 1;
  background: var(--blanc);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 1px dashed #ccc;
}

.partenaire-logo-inner {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(135deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aaa;
  font-size: 0.58rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  line-height: 1.2;
  padding: 4px;
}

/* ── Newsletter ── */
#app-shell[data-view="newsletter"] .day-nav,
#app-shell[data-view="newsletter"] .filters-bar,
#app-shell[data-view="newsletter"] .day-banner {
  display: none;
}

.panel-newsletter {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 12px 16px;
  background: var(--bleu-ecailles);
}

.newsletter-card {
  background: var(--blanc);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
}

.newsletter-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-titre);
  font-size: 1.35rem;
  color: var(--jour-couleur);
  text-align: center;
}

.newsletter-intro {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: #555;
  text-align: center;
  line-height: 1.45;
}

.newsletter-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bleu-marine);
  margin-bottom: 6px;
}

.newsletter-input {
  width: 100%;
  font-family: var(--font-texte);
  font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid var(--jour-couleur-light);
  border-radius: var(--radius);
  background: var(--blanc);
  color: var(--bleu-marine);
  margin-bottom: 1rem;
}

.newsletter-input:focus {
  outline: none;
  border-color: var(--jour-couleur);
  box-shadow: 0 0 0 3px var(--jour-couleur-light);
}

.newsletter-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.82rem;
  color: #444;
  line-height: 1.4;
  margin-bottom: 1.25rem;
  cursor: pointer;
}

.newsletter-check input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--jour-couleur);
}

.newsletter-submit {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  background: var(--jour-couleur);
  color: var(--blanc);
  font-family: var(--font-texte);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease;
}

.newsletter-submit:active { opacity: 0.85; }

.newsletter-error {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--rouge-corail);
  text-align: center;
}

.newsletter-success {
  text-align: center;
  padding: 0.5rem 0;
}

.newsletter-success-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-titre);
  font-size: 1.2rem;
  color: var(--jour-couleur);
}

.newsletter-success-text {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: #444;
}

.newsletter-test-note {
  margin: 0;
  padding: 0.75rem;
  font-size: 0.78rem;
  color: #666;
  background: var(--bleu-ecailles);
  border-radius: var(--radius);
  line-height: 1.4;
}

/* ── Bottom sheet (mode carte) ── */
.panel-sheet {
  flex-shrink: 0;
  background: var(--blanc);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  max-height: 42dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: #ccc;
  border-radius: 2px;
  margin: 8px auto 4px;
  flex-shrink: 0;
}

.sheet-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 1rem;
}

.sheet-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #888;
  text-align: center;
  padding: 0.5rem 0;
}

.sheet-title {
  margin: 0 0 2px;
  font-family: var(--font-titre);
  font-size: 1.15rem;
  color: var(--jour-couleur);
}

.sheet-addr {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: #777;
}

.sheet-event {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 0;
  border: none;
  border-bottom: 1px solid #eee;
  background: none;
  font-family: var(--font-texte);
  font-size: 0.85rem;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.sheet-event:active {
  background: var(--jour-couleur-light);
}

.sheet-event:last-child { border-bottom: none; }

.sheet-event-time {
  font-weight: 700;
  color: var(--jour-couleur);
}

.sheet-event-name { font-weight: 600; }

/* ── Bottom nav ── */
.bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--blanc);
  border-top: 1px solid rgba(0, 73, 114, 0.12);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  min-height: 56px;
  border: none;
  background: transparent;
  font-family: var(--font-texte);
  font-size: 0.7rem;
  font-weight: 700;
  color: #888;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--transition);
}

.bottom-nav-btn.is-active {
  color: var(--jour-couleur);
}

.bottom-nav-btn svg { stroke: currentColor; }

/* ── Marqueurs carte ── */
.marker-pin {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2.5px solid var(--blanc);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.marker-pin.is-active {
  transform: rotate(-45deg) scale(1.25);
  z-index: 1000 !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.marker-pin span {
  transform: rotate(45deg);
  font-size: 12px;
  font-weight: 800;
  color: var(--blanc);
  line-height: 1;
}

.user-marker {
  width: 16px;
  height: 16px;
  background: #2196F3;
  border: 3px solid var(--blanc);
  border-radius: 50%;
  box-shadow: 0 0 0 2px #2196F3, 0 2px 8px rgba(0,0,0,0.3);
}

/* Leaflet overrides mobile */
.leaflet-control-attribution { font-size: 9px !important; }

/* ── Thèmes jour ── */
body[data-day="2026-06-05"] {
  --jour-couleur: var(--rouge-corail);
  --jour-couleur-light: rgba(240, 83, 98, 0.14);
}

body[data-day="2026-06-06"] {
  --jour-couleur: var(--bleu-marine);
  --jour-couleur-light: rgba(0, 73, 114, 0.14);
}

body[data-day="2026-06-07"] {
  --jour-couleur: var(--jaune-or);
  --jour-couleur-light: rgba(232, 178, 51, 0.2);
}

body[data-day="2026-06-07"] .site-header {
  background: linear-gradient(135deg, var(--jaune-or) 0%, var(--jaune-or-alt) 100%);
  color: var(--bleu-marine);
}

body[data-day="2026-06-07"] .header-title { color: var(--bleu-marine); }

body[data-day="2026-06-07"] .bottom-nav-btn.is-active { color: var(--bleu-marine); }
body[data-day="2026-06-07"] .btn-geoloc.is-active { background: var(--bleu-marine); }

/* ── Desktop (progressive enhancement) ── */
@media (min-width: 768px) {
  .app-shell {
    max-width: 520px;
    margin: 0 auto;
    border-left: 1px solid rgba(0,73,114,0.08);
    border-right: 1px solid rgba(0,73,114,0.08);
  }

  .header-title { font-size: 2rem; }
  .map-wrap { --map-h-liste: 280px; }
}
