/* Marhba — le globe de Moon.
   Jetons « La guerre des bisous ». Règles d'usage (contrastes WCAG mesurés) :
   - --rouge (#e0245e) : décor, épingles, filets. Jamais pour du petit texte (3,8:1 sur surface).
   - --rouge-fort (#d21f57) : fond des boutons principaux, texte crème dessus (4,8:1).
   - --rouge-texte (#ff5c8f) : texte rouge sur fond sombre (5,9:1).
   - --or (#f2b84b) : « à venir » (9,6:1 sur surface) ; --rose : texte secondaire (11,4:1).
   Mouvement : 180 ms (micro), 320 ms (panneaux), courbe --ease ; rien ne bouge si prefers-reduced-motion. */

@font-face { font-family: 'Fraunces'; src: url(fonts/fraunces-latin-wght-normal.woff2) format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Fraunces'; src: url(fonts/fraunces-latin-wght-italic.woff2) format('woff2'); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url(fonts/inter-latin-wght-normal.woff2) format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --nuit: #1a1020;
  --surface: #241629;
  --surface-2: #2f1d35;
  --filet: rgba(247, 198, 208, .16);
  --rouge: #e0245e;
  --rouge-fort: #d21f57;
  --rouge-texte: #ff5c8f;
  --rose: #f7c6d0;
  --creme: #fff6ef;
  --or: #f2b84b;
  --muted: #c9a9b4;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --arabe: 'Noto Naskh Arabic', 'Geeza Pro', 'Arabic Typesetting', 'Segoe UI', serif;
  --r-lg: 22px;
  --r-md: 14px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --t-micro: 180ms;
  --t-panel: 320ms;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 30%, #2a1630 0%, var(--nuit) 60%) fixed, var(--nuit);
  color: var(--creme);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
a { color: var(--rose); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--rose); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; z-index: 100; left: var(--gutter); top: -60px; background: var(--creme); color: var(--nuit); padding: 10px 14px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip:focus { top: calc(var(--safe-t) + 10px); }
.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; }

/* ----------------------------------------------------------------- globe */
.globe { position: fixed; inset: 0; touch-action: none; }
.globe canvas { display: block; }

/* Épingles (éléments HTML posés sur le globe) */
.pin {
  position: relative; width: 26px; height: 26px; padding: 0; border: 0; background: none;
  cursor: pointer; pointer-events: auto;
}
/* Le calque CSS2D de globe.gl pose transform et z-index en ligne sur .pin : on anime le SVG interne,
   et on force la pile pour l'épingle de la fiche ouverte. */
.pin svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .55)); transition: transform var(--t-micro) var(--ease); }
.pin.past .star { fill: var(--rouge); stroke: var(--creme); stroke-width: 1.6; }
.pin.upcoming .star { fill: var(--nuit); stroke: var(--or); stroke-width: 2.2; stroke-dasharray: 3.2 2.2; }
.pin.upcoming::before {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid var(--or); opacity: 0; animation: halo 2.4s var(--ease) infinite;
}
.pin.archived .star { fill: #5a4660; stroke: var(--muted); stroke-width: 1.4; }
.pin.is-active { z-index: 1000 !important; }
.pin.is-active svg { transform: scale(1.35); }
.pin:hover svg { transform: scale(1.18); }
.pin.is-active:hover svg { transform: scale(1.35); }
.pin-label {
  position: absolute; white-space: nowrap; pointer-events: none; z-index: 1;
  font: 600 12.5px/1 var(--sans); letter-spacing: .01em; color: var(--creme);
  background: rgba(26, 16, 32, .88); border: 1px solid var(--filet); padding: 5px 8px; border-radius: 999px;
  opacity: 0; transition: opacity var(--t-micro) var(--ease);
  /* par défaut : dessous */
  left: 50%; top: calc(100% + 4px); transform: translateX(-50%);
}
.pin.upcoming .pin-label { color: var(--or); }
/* Positions calculées par layoutLabels (lp-b, -r, -l, -t ; « 2 » = plus loin, avec trait de rappel) */
.pin.lp-r .pin-label, .pin.lp-r2 .pin-label { left: calc(100% + 4px); top: 50%; transform: translateY(-50%); }
.pin.lp-l .pin-label, .pin.lp-l2 .pin-label { left: auto; right: calc(100% + 4px); top: 50%; transform: translateY(-50%); }
.pin.lp-t .pin-label, .pin.lp-t2 .pin-label { top: auto; bottom: calc(100% + 4px); }
.pin.lp-r2 .pin-label { left: calc(100% + 26px); }
.pin.lp-l2 .pin-label { right: calc(100% + 26px); }
.pin.lp-b2 .pin-label { top: calc(100% + 26px); }
.pin.lp-t2 .pin-label { bottom: calc(100% + 26px); }
.pin-label::before { content: none; position: absolute; background: var(--rose); opacity: .75; }
.pin.lp-r2 .pin-label::before, .pin.lp-l2 .pin-label::before { content: ''; top: 50%; height: 1px; width: 22px; }
.pin.lp-r2 .pin-label::before { right: 100%; }
.pin.lp-l2 .pin-label::before { left: 100%; }
.pin.lp-b2 .pin-label::before, .pin.lp-t2 .pin-label::before { content: ''; left: 50%; width: 1px; height: 22px; }
.pin.lp-b2 .pin-label::before { bottom: 100%; }
.pin.lp-t2 .pin-label::before { top: 100%; }
.pin.show-label .pin-label, .pin.peek .pin-label, .pin:hover .pin-label { opacity: 1; }
/* Une étiquette révélée au survol passe au-dessus des autres */
.pin.peek, .pin:hover { z-index: 1001 !important; }
.pin.peek svg { transform: scale(1.18); }
@keyframes halo { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }

/* ---------------------------------------------------------------- haut */
.top {
  position: fixed; z-index: 20; left: 0; right: 0; top: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--safe-t) + 10px) var(--gutter) 0; pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 7px; border: 1px solid var(--filet);
  border-radius: 999px; background: rgba(36, 22, 41, .78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: pointer; text-align: left;
}
.brand-mark { display: block; width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font: 650 19px/1.1 var(--serif); letter-spacing: .01em; font-variation-settings: 'SOFT' 50, 'WONK' 0; }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-sub [lang='ar'] { font-family: var(--arabe); color: var(--rose); font-size: 13px; }

.round-btn {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 1px solid var(--filet); background: rgba(36, 22, 41, .78);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); cursor: pointer;
  transition: background var(--t-micro) var(--ease), transform var(--t-micro) var(--ease);
}
.round-btn.small { width: 40px; height: 40px; }
.round-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--creme); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round-btn svg .fill { fill: var(--creme); stroke: none; }
.round-btn:hover { background: var(--surface-2); }
.round-btn:active { transform: scale(.94); }
.round-btn:disabled { opacity: .35; cursor: default; }

/* Bandeau « bientôt » */
.soon {
  position: fixed; z-index: 19; left: var(--gutter); right: var(--gutter); margin: 0 auto; width: fit-content;
  top: calc(var(--safe-t) + 66px);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center;
  padding: 5px 6px 5px 12px; border-radius: 999px;
  background: rgba(26, 16, 32, .82); border: 1px solid rgba(242, 184, 75, .45);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  font-size: 13px; color: var(--or);
}
.soon b { font-weight: 650; }
.soon .soon-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--or); box-shadow: 0 0 0 0 rgba(242, 184, 75, .6); animation: beat 2.4s var(--ease) infinite; }
.soon button {
  border: 0; background: rgba(242, 184, 75, .14); color: var(--creme); border-radius: 999px; padding: 0 10px; min-height: 30px; cursor: pointer; font-size: 13px;
}
.soon button:hover { background: rgba(242, 184, 75, .26); }
@keyframes beat { 0% { box-shadow: 0 0 0 0 rgba(242, 184, 75, .6); } 70%, 100% { box-shadow: 0 0 0 9px rgba(242, 184, 75, 0); } }

/* Légende */
.legend {
  position: fixed; z-index: 30; right: var(--gutter); top: calc(var(--safe-t) + 62px);
  width: min(300px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface); border: 1px solid var(--filet); border-radius: var(--r-md);
  padding: 12px 14px; box-shadow: 0 18px 40px rgba(0, 0, 0, .45); font-size: 13.5px;
}
.legend-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.legend .dot { width: 14px; height: 14px; flex: none; border-radius: 50%; }
.legend .dot.past { background: var(--rouge); border: 2px solid var(--creme); }
.legend .dot.upcoming { border: 2px dashed var(--or); }
.legend .swatch { width: 18px; height: 12px; flex: none; border-radius: 3px; background: rgba(224, 36, 94, .38); border: 1px solid var(--rose); }
.legend .arc { width: 18px; height: 2px; flex: none; background: var(--rose); border-radius: 2px; }

/* ------------------------------------------------------- motif zellige */
.zellige-band {
  height: 8px; margin: -1px -1px 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: url(img/zellige.svg) 0 -10px / 28px 28px repeat-x;
  opacity: .45;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}

/* --------------------------------------------------------------- panneaux */
.panel, .welcome, .sheet {
  background: linear-gradient(180deg, rgba(47, 29, 53, .97), rgba(36, 22, 41, .98));
  border: 1px solid var(--filet); border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

/* Accueil */
.welcome {
  position: fixed; z-index: 40; left: var(--gutter); right: var(--gutter);
  bottom: calc(var(--safe-b) + var(--gutter));
  max-width: 460px; margin: 0 auto; overflow: hidden;
  padding: 0 22px 22px; text-align: center;
  animation: rise var(--t-panel) var(--ease) both;
}
.welcome-ar { margin: 18px 0 0; font: 400 30px/1.2 var(--arabe); color: var(--rose); }
.welcome-title { margin: 2px 0 6px; font: 600 44px/1.05 var(--serif); letter-spacing: -.01em; font-variation-settings: 'SOFT' 100, 'WONK' 1; }
.welcome-lead { margin: 0 auto 16px; max-width: 34ch; color: var(--rose); font-size: 16px; }
.stats { display: flex; justify-content: center; gap: 8px; margin: 0 0 18px; padding: 0; }
.stats div { flex: 1; max-width: 120px; background: rgba(26, 16, 32, .55); border: 1px solid var(--filet); border-radius: var(--r-md); padding: 8px 6px; }
.stats dt { order: 2; font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font: 650 26px/1.1 var(--serif); }
.stats div { display: flex; flex-direction: column-reverse; }
.stats .up dd { color: var(--or); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid var(--filet);
  background: var(--surface-2); color: var(--creme); font-weight: 600; font-size: 16px;
  text-decoration: none; cursor: pointer;
  transition: transform var(--t-micro) var(--ease), background var(--t-micro) var(--ease);
}
.btn.primary { background: var(--rouge-fort); border-color: transparent; box-shadow: 0 8px 24px rgba(224, 36, 94, .35); }
.btn.primary:hover { background: #dc2a61; }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.welcome .btn { width: 100%; }

/* ------------------------------------------------------------ liste (dock) */
.dock {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: 0;
  padding: 0 0 calc(var(--safe-b) + 12px);
  background: linear-gradient(180deg, transparent, rgba(26, 16, 32, .85) 38%);
  transition: opacity var(--t-panel) var(--ease), transform var(--t-panel) var(--ease);
}
@media (max-width: 899px) { body.sheet-open .soon { display: none; } }
body.welcome-open .dock, body.sheet-open .dock { opacity: 0; transform: translateY(16px); pointer-events: none; visibility: hidden; }
.filters { display: flex; gap: 6px; padding: 18px var(--gutter) 10px; }
.filters button {
  border: 1px solid var(--filet); background: rgba(36, 22, 41, .8); border-radius: 999px;
  padding: 7px 12px; font-size: 13.5px; font-weight: 550; cursor: pointer; color: var(--rose);
  min-height: 36px;
}
.filters button[aria-pressed='true'] { background: var(--creme); color: var(--nuit); border-color: var(--creme); }
.filters .count { opacity: .7; font-weight: 500; }
.list {
  list-style: none; margin: 0; padding: 2px var(--gutter) 4px; display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.list::-webkit-scrollbar { display: none; }
.list li { flex: none; scroll-snap-align: start; }
.chip {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 14px 8px 10px;
  border-radius: var(--r-md); border: 1px solid var(--filet); background: rgba(36, 22, 41, .92);
  cursor: pointer; text-align: left;
  transition: border-color var(--t-micro) var(--ease), background var(--t-micro) var(--ease);
}
.chip:hover { background: var(--surface-2); }
.chip[aria-current='true'] { border-color: var(--rose); background: var(--surface-2); }
.chip-star { width: 22px; height: 22px; flex: none; }
.chip-star .star { stroke-width: 1.8; }
.chip.past .star { fill: var(--rouge); stroke: var(--creme); }
.chip.upcoming .star { fill: transparent; stroke: var(--or); stroke-dasharray: 3 2; }
.chip.archived .star { fill: #5a4660; stroke: var(--muted); }
.chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.chip-name { font-weight: 650; font-size: 15px; }
.chip-sub { font-size: 12.5px; color: var(--muted); }
.chip.upcoming .chip-sub { color: var(--or); }
.list-empty { color: var(--muted); padding: 10px 0; }

/* ----------------------------------------------------------------- fiche */
.sheet {
  position: fixed; z-index: 35; left: 8px; right: 8px; bottom: calc(var(--safe-b) + 8px);
  max-height: min(74dvh, 640px); overflow: hidden auto; overscroll-behavior: contain;
  padding: 0 0 20px; animation: rise var(--t-panel) var(--ease) both;
}
.sheet:focus { outline: none; }
.sheet-tools { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 6px; padding: 10px 12px 0; }
.sheet-tools .round-btn { background: rgba(26, 16, 32, .75); }
.sheet-body { padding: 0 20px; margin-top: -30px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; letter-spacing: .02em;
}
.badge.past { background: var(--rose); color: var(--nuit); }
.badge.upcoming { background: var(--or); color: var(--nuit); }
.badge.archived { background: #5a4660; color: var(--creme); }
.sheet h2 { margin: 10px 0 0; font: 600 36px/1.05 var(--serif); letter-spacing: -.01em; padding-right: 0; font-variation-settings: 'SOFT' 60; }
.sheet .country { margin: 4px 0 0; color: var(--rose); font-size: 15px; }
.sheet .coords { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.note { margin: 12px 0 0; padding: 9px 12px; border-radius: 12px; background: rgba(26, 16, 32, .5); color: var(--muted); font-size: 13.5px; border: 1px solid var(--filet); }

.countdown {
  margin: 16px 0 0; display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px dashed rgba(242, 184, 75, .7);
  background: rgba(242, 184, 75, .07);
}
.countdown .big { font: 650 34px/1 var(--serif); color: var(--or); font-variant-numeric: tabular-nums; }
.countdown .what { font-size: 14px; color: var(--creme); }
.countdown .what small { display: block; color: var(--muted); font-size: 12.5px; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 0; }
.slot { border-radius: var(--r-md); padding: 11px 13px; background: rgba(26, 16, 32, .45); border: 1px solid var(--filet); min-width: 0; }
.slot.wide { grid-column: 1 / -1; }
.slot h3 { margin: 0 0 4px; font: 600 12px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.slot p, .slot ul { margin: 0; }
.slot ul { padding-left: 18px; }
.slot li + li { margin-top: 4px; }
.slot .val { font: 600 18px/1.25 var(--serif); }
.slot.empty { border: 1.5px dashed rgba(247, 198, 208, .38); background: transparent; }
.slot.empty .todo { display: flex; align-items: center; gap: 6px; color: var(--rose); font-size: 13.5px; font-style: italic; }
.slot.empty .todo svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.photos-title { margin: 20px 0 8px; font: 600 20px/1.2 var(--serif); }
.story { margin: 0 0 14px; }
.story h4 { margin: 0 0 2px; font-size: 15px; }
.story .meta { color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }
.story p { margin: 0 0 8px; white-space: pre-line; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid button { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--surface-2); cursor: zoom-in; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.guide-cta { margin: 18px 0 0; }
.guide-cta .btn { width: 100%; }
.guide-cta p { margin: 8px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* Photo plein écran */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(12, 7, 15, .94); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 88dvh; border-radius: 12px; }
.lightbox .round-btn { position: absolute; top: calc(var(--safe-t) + 12px); right: 12px; }

/* Chargement */
.loader { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 10px; background: var(--nuit); transition: opacity .5s var(--ease), visibility .5s; }
.loader img { animation: spin 6s linear infinite; }
.loader p { margin: 0; font: italic 500 18px/1 var(--serif); color: var(--rose); }
body:not(.is-loading) .loader { opacity: 0; visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* Sans WebGL : la liste reste utilisable */
body.no-globe .globe { display: none; }
body.no-globe .dock { position: fixed; top: calc(var(--safe-t) + 70px); bottom: auto; background: none; }
body.no-globe .list { flex-wrap: wrap; }

/* ------------------------------------------------------------ grand écran */
@media (min-width: 900px) {
  :root { --gutter: 24px; }
  .welcome { left: 32px; right: auto; bottom: auto; top: 50%; transform: translateY(-50%); width: 420px; animation: none; }
  .sheet { left: auto; right: 16px; top: calc(var(--safe-t) + 16px); bottom: 16px; width: 420px; max-height: none; }
  body.sheet-open .dock { opacity: 1; transform: none; pointer-events: auto; visibility: visible; right: 452px; }
  .soon { top: calc(var(--safe-t) + 16px); }
  .list { flex-wrap: wrap; overflow: visible; }
}

/* ----------------------------------------------------- mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .pin.upcoming::before { opacity: .6; transform: scale(1.1); }
}
