/* =============================================================
   DESIGN SYSTEM
============================================================= */
:root {
  --primary:    #FF6B3D;
  --secondary:  #007AFF;
  --text:       #1A1A1A;
  --text-muted: #6E6E73;
  --bg:         #F9F9FB;
  --card:       #FFFFFF;
  --border:     #E5E5EA;
  --shadow:     rgba(0,0,0,0.06);
}

body.dark {
  --bg:         #0d0d0f;
  --text:       #f2f2f7;
  --card:       #1d1d1f;
  --border:     #3a3a3c;
  --text-muted: #9e9e9e;
  --secondary:  #4ea8ff;
}


/* =============================================================
   GLOBAL
============================================================= */
body {
  margin: 0;
  padding: 0;
  overflow-x: clip; /* anti scroll horizontal — safe pour sticky */
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  transition: background 0.25s, color 0.25s;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* =============================================================
   APP LOADER
============================================================= */
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
  transition: opacity .3s ease, transform .3s ease;
}

.app-loader.is-hidden {
  opacity: 0;
  transform: scale(1.02);
  pointer-events: none;
}

.app-loader-inner {
  width: min(520px, 92vw);
  text-align: center;
}

.loader-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  margin-bottom: .4rem;
}

.loader-sub {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.loader-hint {
  margin-top: .9rem;
  font-size: .9rem;
  color: var(--text-muted);
}

.loader-bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
  box-shadow: 0 6px 22px var(--shadow);
}

.loader-bar-fill {
  height: 100%;
  width: 45%;
  background: var(--secondary);
  border-radius: 999px;
  animation: loaderMove 1.1s ease-in-out infinite;
}

@keyframes loaderMove {
  0%   { transform: translateX(-120%); }
  50%  { transform: translateX(60%); }
  100% { transform: translateX(220%); }
}


/* =============================================================
   HEADER
============================================================= */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  padding: 10px 12px 8px;
  transition: padding 0.25s ease, height 0.25s ease;
  overflow: visible !important;
}

body.dark header {
  background: rgba(20,20,22,0.85);
}

/* Mode compact (scroll) */
header.is-compact {
  height: 56px;
  padding: 0 12px;
  overflow: hidden !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

header.is-compact .subtitle {
  display: none;
}

#headerTop {
  text-align: center;
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

header h1,
header p {
  margin: 0;
}


/* =============================================================
   LOGO
============================================================= */
.logo-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  margin-bottom: .15rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.logo-wrapper:visited,
.logo-wrapper:hover,
.logo-wrapper:active {
  color: inherit;
  text-decoration: none;
}

.logo-wrapper:hover .logo-circle {
  transform: scale(1.15);
}

.logo-circle {
  width: 10px;
  height: 10px;
  background: var(--primary);
  border-radius: 50%;
}

.logo {
  font-family: 'Lora', serif;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  padding-top: 4px;
  margin: 0;
}

.logo span { opacity: .6; }

.subtitle {
  font-weight: 500;
  opacity: 0.85;
  letter-spacing: 0.01em;
  margin: .2rem 0 .65rem;
  font-size: .83rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}


/* =============================================================
   FILTRE PRINCIPAL
============================================================= */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  overflow: visible !important;
}

#headerFilters {
  margin-top: 0.2rem;
  transition: transform .22s ease, opacity .16s ease;
  overflow: visible !important;
}

#headerFilters.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Front loading bar */
.front-loading {
  margin: 12px auto;
  max-width: 420px;
  text-align: center;
  font-size: 14px;
  color: #555;
}

.front-loading.hidden { display: none; }

.front-loading .bar {
  height: 3px;
  background: linear-gradient(90deg, #ddd 25%, #3b82f6 37%, #ddd 63%);
  background-size: 400% 100%;
  animation: loadingMove 1.4s infinite linear;
  border-radius: 2px;
  margin-bottom: 6px;
}

@keyframes loadingMove {
  0%   { background-position: 100% 0; }
  100% { background-position:   0% 0; }
}


/* =============================================================
   LIGNE GÉO / VILLE
============================================================= */
.row {
  position: relative;
  max-width: 460px;
  margin: 0.6rem auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: rgba(0,0,0,0.03);
  border-radius: 16px;
  padding: 0.6rem;
  box-shadow: 0 4px 18px rgba(0,0,0,0.06);
}

body.dark .row {
  background: rgba(255,255,255,0.06);
}

/* Bouton géoloc */
.geo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(0,0,0,0.12);
  transition: background .15s ease, transform .12s ease, box-shadow .12s ease;
  flex-shrink: 0;
}

.geo-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

.geo-btn:active {
  transform: translateY(0);
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

.geo-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,122,255,0.35);
}

.geo-btn.loading {
  opacity: 0.85;
  pointer-events: none;
}

.geo-btn.loading .geo-ico {
  animation: geo-spin 1s linear infinite;
}

.geo-btn.active {
  background: var(--secondary);
}

.geo-btn.active .geo-ico .disc {
  opacity: 0.18;
}

@keyframes geo-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.geo-ico {
  width: 22px;
  height: 22px;
  display: block;
}

.geo-ico .disc {
  fill: currentColor;
  opacity: 0;
  transition: opacity .15s ease;
}

/* Wrap + hint sous le bouton */
.geo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.geo-wrap .geo-hint {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.85;
  white-space: nowrap;
  pointer-events: none;
}

/* Message d'erreur géoloc — remplace les alert() */
.geo-error {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
  background: #e03e2d;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  z-index: 600;
  pointer-events: none;
  animation: geoErrorIn 0.2s ease forwards;
}

@keyframes geoErrorIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Champ ville */
#cityInput {
  flex: 1;
  min-width: 0; /* fix flexbox shrink */
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  padding: 0.55rem 0.7rem;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  box-sizing: border-box;
}

/* Réinitialiser */
.reset-text {
  font-size: 0.8rem;
  opacity: 0.6;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.reset-text:hover { color: var(--secondary); }

/* Autocomplete */
#autoList {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 220px;
  overflow-y: auto;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 4px 18px var(--shadow);
  display: none;
  z-index: 500;
}

#autoList div {
  padding: .6rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

#autoList div:hover { background: #e1e1e133; }


/* =============================================================
   RAYON
============================================================= */
.radius-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 8px auto;
  max-width: 100%;
  padding: 0 4px;
}

.r-btn {
  flex: 1;
  max-width: 65px;
  padding: 6px 2px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.r-btn.active {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary);
}

.r-btn:hover:not(.active) {
  background: var(--border);
  color: var(--text);
}


/* =============================================================
   DATES
============================================================= */
.date-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.date-input {
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.2;
  height: 42px;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  min-width: 120px;
}

/* Popup calendrier — centrée en fixed */
.date-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 280px;
  max-width: 90vw;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  z-index: 10000;
  display: none;
}

/* Overlay flou */
#calOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#calOverlay.is-visible { display: block; opacity: 1; }


/* =============================================================
   CALENDRIER INTERNE
============================================================= */
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.cal-title {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-transform: capitalize;
}

.cal-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.15s ease;
}

.cal-btn:hover {
  background: var(--border);
  transform: translateY(-1px);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-dow {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  padding-bottom: 8px;
  text-align: center;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.1s ease;
  color: var(--text);
}

.cal-day:hover:not(.disabled):not(.selected) {
  background: rgba(255, 107, 61, 0.1);
  color: var(--primary);
}

.cal-day.selected {
  background: var(--secondary);
  color: white;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

.cal-day.disabled {
  opacity: 0.15;
  cursor: not-allowed;
}


/* =============================================================
   BOUTON "PROPOSER UN SPECTACLE"
============================================================= */
.propose-btn {
  position: fixed;
  top: 0.6rem;
  right: 1.2rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  z-index: 1000;
  max-width: 4.6rem;
  text-align: center;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  color: #ff6b3d;
  background: rgba(255, 107, 61, 0.08);
  border: 1px solid rgba(255, 107, 61, 0.25);
  opacity: 0.55;
  transition: opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.propose-btn:hover {
  opacity: 0.85;
  background: rgba(255, 107, 61, 0.14);
  border-color: rgba(255, 107, 61, 0.45);
}

body.hide-propose .propose-btn {
  opacity: 0;
  pointer-events: none;
}

/* Masqué sur mobile étroit */
@media (max-width: 520px) {
  .propose-btn { display: none; }
}


/* =============================================================
   GRILLE D'ÉVÉNEMENTS
============================================================= */
#grid {
  max-width: 1200px;
  margin: 1rem auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.3rem;
}

/* Skeleton */
.skel-card {
  height: 270px;
  border-radius: 18px;
  background: linear-gradient(90deg, #ececec 25%, #f5f5f5 50%, #ececec 75%);
  background-size: 200% 100%;
  animation: sk 1.2s infinite;
}

@keyframes sk {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Carte */
.card {
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform .15s;
  animation: fadeIn 0.4s ease forwards;
}

.card:hover { transform: translateY(-3px); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.card-content { padding: 1.1rem 1rem; }

.title {
  font-family: 'Lora', serif;
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.city, .place { font-size: .88rem; color: var(--text-muted); }
.date         { color: var(--primary); margin-top: .3rem; font-weight: 600; }
.desc         { font-size: .9rem; color: var(--text-muted); margin-top: .45rem; }


/* =============================================================
   DISCOVERY HINTS
============================================================= */
.discovery-hint {
  max-width: 900px;
  width: calc(100% - 2rem); /* empêche le débordement sur mobile */
  margin: 1rem auto 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(255,107,61,0.12);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 4px 18px var(--shadow);
  box-sizing: border-box;
}

body.dark .discovery-hint {
  background: rgba(255,107,61,0.22);
}

.discovery-footer-hint {
  max-width: 900px;
  width: calc(100% - 2rem);
  margin: 1.5rem auto 2rem;
  padding: 0 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  box-sizing: border-box;
}

.discovery-footer-hint strong { color: var(--text); }

/* Masqués après localisation */
body.has-location .discovery-hint,
body.has-location .discovery-footer-hint {
  display: none;
}


/* =============================================================
   FOOTER
============================================================= */
.footer {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
}

.subtitle-strong {
  font-weight: 700;
  color: var(--text);
}

.footer-agenda {
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
}

.footer-legal {
  font-size: 0.8rem;
  opacity: 0.7;
}


/* =============================================================
   RESPONSIVE — DESKTOP (≥601px)
============================================================= */
@media (min-width: 601px) {
  .logo     { font-size: 1.6rem; }
  .subtitle { font-size: 0.95rem; line-height: 1.3; }
}


/* =============================================================
   RESPONSIVE — MOBILE (≤600px)
============================================================= */
@media (max-width: 600px) {

  header {
    padding: 6px 12px 4px;
  }

  .logo {
    font-size: 1.9rem;
    line-height: 1.05;
    margin-bottom: 0.2rem;
  }

  .subtitle {
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    line-height: 1.2;
    color: var(--text);
  }

  #headerFilters {
    margin-top: 0.2rem;
  }
}


/* =============================================================
   RESPONSIVE — PETIT MOBILE (≤390px) — date-row
============================================================= */
@media (max-width: 390px) {

  .filter-group .date-row {
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .filter-group .date-row .date-input {
    min-width: 100px;
    font-size: 0.85rem;
    padding: 0.45rem 0.5rem;
  }
}


/* =============================================================
   RESPONSIVE — TRÈS PETIT MOBILE (≤380px) — iPhone SE
============================================================= */
@media (max-width: 380px) {

  /* Subtitle masqué : gain ~35px dans le header sticky */
  .subtitle {
    display: none;
  }

  .logo {
    font-size: 1.75rem;
    letter-spacing: -0.015em;
  }

  #headerFilters {
    margin-top: 0;
  }

  .discovery-hint {
    margin-top: 0.6rem;
    padding: 0.6rem;
    font-size: 0.85rem;
  }
}


/* =============================================================
   RESPONSIVE — ULTRA PETIT (≤360px) — Galaxy S8
============================================================= */
@media (max-width: 360px) {

  .logo { font-size: 1.7rem; }

  .discovery-hint {
    font-weight: 500;
    background: rgba(255,107,61,0.10);
    margin-top: 0.4rem;
    padding: 0.5rem;
  }
}


/* =============================================================
   SAFARI iOS — FIX ZOOM SUR INPUT
============================================================= */
@supports (-webkit-touch-callout: none) {
  input, textarea, select {
    font-size: 16px !important;
  }
}