:root {
  --bg: #faf6ee;
  --surface: #ffffff;
  --ink: #1f2a33;
  --muted: #5f6b75;
  --line: #e7e0d2;
  --danube: #1d5f8a;
  --danube-soft: #e3eef5;
  --wheat: #d9a441;
  --wheat-soft: #fbf1dc;
  --good: #2f8a55;
  --bad: #c0453a;

  --histoire: #b5523b;
  --religion: #7b5ea7;
  --culture: #1d5f8a;
  --nature: #3f8f5a;
  --moderne: #c98a1d;

  --radius: 14px;
  --shadow: 0 8px 30px rgba(31, 42, 51, .14);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; margin: 0; }
button { font: inherit; cursor: pointer; }

/* ---------- En-tête ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--danube);
  color: #fff;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--wheat); font-size: 22px;
}
.brand h1 { font-size: 1.35rem; }
.brand p { margin: 2px 0 0; opacity: .8; font-size: .85rem; }
.progress { min-width: 200px; font-size: .85rem; }
.progress-bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.25); margin-top: 6px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--wheat); transition: width .4s; }

/* ---------- Mise en page ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: 0; }
.sidebar { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; background: var(--bg); }
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }

/* ---------- Onglets ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 12px 6px; border: 0; background: none;
  color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent;
}
.tab.active { color: var(--danube); border-bottom-color: var(--wheat); }
.panel { display: none; overflow-y: auto; padding: 14px 16px 24px; flex: 1; }
.panel.active { display: block; }

/* ---------- Itinéraire ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 4px 10px; font-size: .8rem; color: var(--muted);
}
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.summary { font-size: .85rem; color: var(--muted); margin: 0 0 10px; }

.stops { list-style: none; margin: 0; padding: 0; }
.stop {
  display: flex; gap: 12px; align-items: center;
  padding: 10px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.stop:hover { transform: translateX(3px); box-shadow: var(--shadow); }
.stop.active { border-color: var(--wheat); box-shadow: 0 0 0 2px var(--wheat); }
.stop.dimmed { opacity: .35; }
.stop-num {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.stop-body { min-width: 0; }
.stop-title { font-weight: 700; font-size: .95rem; }
.stop-sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop.visited .stop-num::after { content: '✓'; }
.stop.visited .stop-num span { display: none; }
.leg { font-size: .75rem; color: var(--muted); padding: 5px 0 5px 26px; border-left: 2px dashed var(--line); margin-left: 26px; }

/* ---------- Fiche d'un lieu ---------- */
.card {
  position: absolute; z-index: 1000; top: 16px; right: 16px; bottom: 84px;
  width: min(400px, calc(100% - 32px));
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-y: auto; transition: transform .25s, opacity .25s;
}
.card.hidden { transform: translateX(30px); opacity: 0; pointer-events: none; }
.card-head { padding: 18px 18px 14px; color: #fff; position: relative; }
.card-head .emoji { font-size: 2rem; }
.card-head h2 { font-size: 1.35rem; margin-top: 4px; }
.card-head .ro { opacity: .85; font-size: .85rem; font-style: italic; margin-top: 2px; }
.card-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px;
  border-radius: 50%; border: 0; background: rgba(255,255,255,.25); color: #fff; font-size: 1.1rem;
}
.card-body { padding: 16px 18px 20px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.badge { font-size: .75rem; padding: 3px 9px; border-radius: 99px; background: var(--danube-soft); color: var(--danube); font-weight: 500; }
.card-body p { line-height: 1.55; margin: 0 0 12px; }
.fact { background: var(--wheat-soft); border-left: 4px solid var(--wheat); padding: 10px 12px; border-radius: 8px; font-size: .9rem; }
.fact strong { display: block; margin-bottom: 2px; }
.card-body h3 { font-size: 1rem; margin: 18px 0 8px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 12px; border-radius: 10px; font-weight: 500; font-size: .85rem;
}
.btn:hover { border-color: var(--danube); }
.btn.on { background: var(--good); border-color: var(--good); color: #fff; }

.vocab { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.flip {
  perspective: 600px; height: 70px; border: 0; background: none; padding: 0;
}
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .45s; transform-style: preserve-3d;
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 4px; border-radius: 10px; font-size: .8rem; font-weight: 500;
  backface-visibility: hidden;
}
.flip-front { background: var(--danube-soft); color: var(--danube); }
.flip-back { background: var(--wheat-soft); color: #7a5410; transform: rotateY(180deg); }

.comments { list-style: none; padding: 0; margin: 0 0 10px; }
.comments li { background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-size: .88rem; }
.comments .who { font-weight: 700; font-size: .8rem; color: var(--danube); }
.comment-form { display: grid; gap: 6px; }
.comment-form input, .comment-form textarea, .lex-tools input[type=search] {
  font: inherit; font-size: .88rem; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.comment-form textarea { resize: vertical; min-height: 60px; }
.muted { color: var(--muted); font-size: .85rem; }

/* ---------- Contrôles de la visite ---------- */
.tour-controls {
  position: absolute; z-index: 1000; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; gap: 6px; background: var(--surface); padding: 6px; border-radius: 99px; box-shadow: var(--shadow);
}
.tour-controls button { white-space: nowrap; border: 0; background: var(--bg); border-radius: 99px; padding: 10px 14px; font-weight: 700; }
.tour-controls .primary { background: var(--danube); color: #fff; padding: 10px 20px; }

/* ---------- Marqueurs ---------- */
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.35);
  transition: transform .2s;
}
.pin span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: .85rem; }
.pin.visited { outline: 3px solid var(--good); }
.pin.active { transform: rotate(-45deg) scale(1.3); }
.pin.dimmed { opacity: .3; }
.route-walk { stroke-dasharray: 10 8; animation: march 1.2s linear infinite; }
@keyframes march { to { stroke-dashoffset: -18; } }

/* ---------- Quiz ---------- */
.quiz-top { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.quiz-q { font-family: 'Fraunces', Georgia, serif; font-size: 1.2rem; margin: 6px 0 14px; }
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
.choice:hover:not(:disabled) { border-color: var(--danube); }
.choice.correct { background: #e4f4ea; border-color: var(--good); }
.choice.wrong { background: #fbe7e5; border-color: var(--bad); }
.feedback { margin: 12px 0; font-weight: 500; }
.quiz-end { text-align: center; padding: 20px 0; }
.quiz-end .score { font-family: 'Fraunces', serif; font-size: 3rem; color: var(--danube); }

/* ---------- Lexique ---------- */
.lex-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lex-tools input[type=search] { flex: 1; min-width: 150px; }
.switch { font-size: .85rem; display: flex; align-items: center; gap: 6px; }
.hint { font-size: .8rem; color: var(--muted); }
.lexique { width: 100%; border-collapse: collapse; font-size: .9rem; }
.lexique td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.lexique td.fr { font-weight: 500; }
.lexique td.lieu { font-size: 1rem; width: 28px; }
.lexique.hide-ro td.ro:not(.shown) { color: transparent; background: var(--wheat-soft); border-radius: 6px; cursor: pointer; }

/* ---------- Téléphone ---------- */
@media (max-width: 800px) {
  html, body { height: auto; }
  .layout { flex: none; grid-template-columns: minmax(0, 1fr); grid-template-rows: 65vh auto; }
  .panel { overflow: visible; }
  .map-wrap { order: -1; }
  .sidebar { border-right: 0; border-top: 1px solid var(--line); }
  .card { top: 12px; bottom: 76px; right: 12px; left: 12px; width: auto; }
  .brand h1 { font-size: 1.1rem; }
  .progress { width: 100%; }
}
