/* Direction artistique : simple et joyeuse, jaune soleil + encre, bords francs et ombres
   « autocollant ». Mobile d'abord : recherche en haut, choix du moment en bas, la carte au milieu.
   Un seul thème clair, assumé (la carte est claire elle aussi). */
:root {
  --sun: #ffd43b;
  --sun-soft: #fff3b8;
  --cream: #fffbea;
  --paper: #ffffff;
  --ink: #1d1a16;
  --muted: #6b6355;
  --soft-line: #eadfbf;
  /* Durée de soleil restante : plus c'est long, plus c'est intense. */
  --sun-1: #ffcc00;
  --sun-2: #ffa800;
  --sun-3: #ff8000;
  --sun-4: #f04e14;
  --shade: #5b6b8c;
  --radius: 20px;
  --pop: 3px 3px 0 var(--ink);
  --gap: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); overflow: hidden;
  font: 15px/1.35 "Bricolage Grotesque", system-ui, -apple-system, sans-serif; }
#map { position: absolute; inset: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
button { font: inherit; cursor: pointer; color: inherit; }
input { font: inherit; color: var(--ink); }

/* Boutons « pilule » partagés */
.pill, .chip { flex: none; border: 2px solid var(--ink); background: var(--paper); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; font-weight: 700; white-space: nowrap; line-height: 1.2;
  transition: transform .08s, box-shadow .08s, background .15s; }
.pill:active, .chip:active { transform: translate(1px, 1px); }
.pill.active, .chip.active { background: var(--ink); color: var(--sun); }
.pill:disabled { opacity: .35; cursor: default; }
@media (hover: hover) {
  .pill:not(:disabled):not(.active):hover, .chip:not(.active):hover { box-shadow: 2px 2px 0 var(--ink); transform: translate(-1px, -1px); }
}

/* ---------- Haut : logo + filtres sur une seule barre ---------- */

#top { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 8px; right: 56px; z-index: 3;
  display: flex; align-items: center; gap: 6px; width: min(360px, calc(100% - 62px));
  padding: 5px 5px 5px 6px; background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; box-shadow: var(--pop); }
.brand { display: flex; align-items: center; flex: none; text-decoration: none; color: var(--ink); }
.logo { width: 30px; height: 30px; flex: none; animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .logo { animation: none; } }
.filters { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.filters::-webkit-scrollbar { display: none; }
.chip { padding: 4px 8px; font-size: 13.5px; }

/* ---------- Bas : feuille (liste repliable + moment) ---------- */

#sheet { position: absolute; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 3;
  display: flex; flex-direction: column; max-height: calc(100% - 140px);
  background: var(--cream); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--pop); overflow: hidden; }

.list-btn { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--paper); color: var(--ink); padding: 0; margin-left: 2px; }
.list-btn.active { background: var(--ink); color: var(--sun); }
.count-line { font-size: 14px; font-weight: 600; margin: 0 4px 8px; }
#count { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

#list-wrap { overflow-y: auto; flex: 1; min-height: 0; border-bottom: 2px solid var(--ink); }
#sheet:not(.collapsed) { top: calc(70px + env(safe-area-inset-top)); }
#sheet.collapsed #list-wrap { display: none; }
.search-row { padding: 10px 10px 4px; position: sticky; top: 0; background: var(--cream); z-index: 1; }
#search { width: 100%; padding: 9px 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); font-size: 16px; }
#search:focus { outline: none; box-shadow: 2px 2px 0 var(--ink); }
#search::placeholder { color: #a39a86; }
#list { list-style: none; margin: 0; padding: 6px; }
#list li { padding: 9px 8px; cursor: pointer; display: flex; gap: 12px; align-items: center; border-radius: 12px; }
#list li:hover { background: var(--sun-soft); }
#list .dot { width: 34px; height: 34px; border-radius: 50%; flex: none; border: 2px solid var(--ink);
  display: grid; place-items: center; font-size: 17px; line-height: 1; }
#list .body { min-width: 0; flex: 1; }
#list .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .until { white-space: nowrap; font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
#list .until b { display: block; font-size: 15px; color: var(--ink); font-weight: 800; }
#list li.empty { cursor: default; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px 10px; }
#list li.empty:hover { background: none; }
#list li.empty strong { font-size: 17px; }

details.more { margin: 0 12px 6px; font-size: 14px; }
details.more summary { cursor: pointer; color: var(--muted); font-weight: 700; padding: 6px 2px; width: fit-content; }
.more-body { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; background: var(--paper);
  border: 2px dashed var(--soft-line); border-radius: 12px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { accent-color: var(--ink); width: 17px; height: 17px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1.5px solid var(--ink); }
.seo-link { display: block; padding: 8px 14px 14px; font-size: 13px; font-weight: 700; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--sun-2); text-decoration-thickness: 3px; text-underline-offset: 3px; }

/* Moment : une rangée de pilules (jour + repas), puis l'heure et le curseur lever → coucher */
#timecard { background: var(--sun); padding: 8px 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.moments { display: flex; align-items: center; gap: 5px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 3px; }
.moments::-webkit-scrollbar { display: none; }
.moments .pill { padding: 4px 10px; font-size: 13.5px; }
.moments .sep { flex: none; width: 2px; height: 20px; background: var(--ink); opacity: .25; border-radius: 1px; margin: 0 2px; }
.pick { position: relative; overflow: hidden; }
.pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.time-row { display: flex; align-items: center; gap: 12px; }
#time { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; min-width: 78px; }
.track { position: relative; flex: 1; padding-top: 4px; }
.daylight { position: absolute; left: 0; right: 0; top: 13px; height: 12px; border-radius: 6px; border: 2px solid var(--ink); }
#slider { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 0;
  background: transparent; position: relative; z-index: 1; }
#slider::-webkit-slider-runnable-track { height: 12px; background: transparent; }
#slider::-moz-range-track { height: 12px; background: transparent; }
#slider::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; margin-top: -9px;
  border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); cursor: grab; }
#slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--paper);
  border: 3px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.ticks { position: relative; height: 15px; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; opacity: .65; }
.ticks .sunmark { opacity: 1; }
.ticks .sunmark.rise { transform: none; }
.ticks .sunmark.set { transform: translateX(-100%); }
#sun-info { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sun-info:empty { display: none; }

/* ---------- Popup ---------- */

.maplibregl-popup-content { background: var(--cream); color: var(--ink); border-radius: var(--radius);
  padding: 14px 16px; border: 2px solid var(--ink); box-shadow: var(--pop); font-family: inherit; }
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { font-size: 22px; padding: 4px 10px; color: var(--ink); }
.pop h3 { margin: 0 0 2px; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; padding-right: 22px; }
.pop .status { margin: 8px 0 4px; font-weight: 700; display: inline-block; background: var(--sun);
  border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px; font-size: 13.5px; }
.pop .status.closed { background: var(--paper); }
.pop .gmaps { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--sun-2); text-decoration-thickness: 3px; text-underline-offset: 3px; }
.pop canvas { display: block; margin: 6px auto 0; }
.pop .legend { font-size: 11.5px; color: var(--muted); text-align: center; display: block; }

/* Contrôles carte : colonne à droite, crédits repliés dessous */
.maplibregl-ctrl-top-right { top: calc(8px + env(safe-area-inset-top)); right: 6px; }
.maplibregl-ctrl-group { border: 2px solid var(--ink) !important; border-radius: 12px !important;
  box-shadow: 2px 2px 0 var(--ink) !important; overflow: hidden; }
.maplibregl-ctrl-attrib.maplibregl-compact { margin: 6px 0 0 !important; font-size: 11px; }

/* ---------- Grand écran : mêmes blocs, posés à gauche ---------- */

@media (min-width: 760px) {
  #top { top: 16px; left: 16px; }
  /* Le choix du moment reste en bas, centré ; la liste s'ouvre au-dessus. */
  #sheet { left: 50%; right: auto; bottom: 16px; width: 540px; transform: translateX(-50%); }
  #sheet:not(.collapsed) { top: auto; height: min(72vh, 680px); }
  .maplibregl-ctrl-top-right { top: 12px; right: 12px; }
}
@media (max-width: 420px) { .chip .ic { display: none; } }

.pop .places { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.pop .places li.current { color: var(--ink); font-weight: 700; }

/* Filtre type : liste déroulante native (sélecteur du téléphone), habillée en pilule */
.cat-select { position: relative; flex: 1; min-width: 0; }
.cat-select select { appearance: none; -webkit-appearance: none; width: 100%; font: inherit; font-weight: 700; font-size: 15px;
  padding: 6px 30px 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); color: var(--ink);
  cursor: pointer; text-overflow: ellipsis; }
.cat-select::after { content: "▾"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.legend .ramp { width: 70px; height: 12px; border-radius: 6px; border: 1.5px solid var(--ink); flex: none; }
.legend { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 10px; }

.clock { display: flex; flex-direction: column; align-items: flex-start; min-width: 84px; }
.clock #time { min-width: 0; }
#day-label { font-size: 12px; font-weight: 700; opacity: .7; margin-top: 2px; white-space: nowrap; }
