/*
 * kokrea-theme.css — Dark/Light mode · Contraste WCAG AA · Polices mobile ×2
 * Auteur : Pierre-Yves Huan | design9 | contact@design9.fr
 */

/* ══════════════════════════════════════════════════════════
   1. DARK MODE — corrections contraste (main.css baseline)
══════════════════════════════════════════════════════════ */
:root {
  --c-muted:  rgba(212,184,150,.80);
  --c-border: rgba(212,184,150,.22);
}

/* ══════════════════════════════════════════════════════════
   2. LIGHT MODE
══════════════════════════════════════════════════════════ */
[data-theme="light"] {
  --c-dark:    #f0ebe3;
  --c-mid:     #e4ddd3;
  --c-ocean:   #d4cdc5;
  --c-surface: rgba(230,224,216,.92);
  --c-salt:    #1a1208;
  --c-sand:    #3d2810;
  --c-gold:    #7a4e0c;
  --c-gold-h:  #5e3c0a;
  --c-green:   #1a4a28;
  --c-green-l: #1a5e34;
  --c-coral:   #a83020;
  --c-blue:    #1a4e80;
  --c-muted:   rgba(50,28,8,.75);
  --c-border:  rgba(50,28,8,.16);
}

[data-theme="light"] body             { background: #f0ebe3; color: var(--c-salt); }
[data-theme="light"] .navbar-fixed    { background: rgba(240,235,227,.96); border-bottom-color: rgba(50,28,8,.12); backdrop-filter: blur(12px); }
[data-theme="light"] .navbar-logo     { color: var(--c-salt); }
[data-theme="light"] .nav-links       { background: rgba(240,235,227,.98); }
[data-theme="light"] .nav-link        { color: rgba(50,28,8,.65); }
[data-theme="light"] .nav-link:hover,
[data-theme="light"] .nav-link.active { color: var(--c-gold); }
[data-theme="light"] .card,
[data-theme="light"] .card-base,
[data-theme="light"] .nm-info-card,
[data-theme="light"] .review-card,
[data-theme="light"] .step-card,
[data-theme="light"] .feature-card,
[data-theme="light"] .parcours-card,
[data-theme="light"] .etape-row,
[data-theme="light"] .circuit-card   { background: rgba(200,192,183,.35); border-color: var(--c-border); }
[data-theme="light"] .section-alt    { background: rgba(50,28,8,.04); }
[data-theme="light"] h1,[data-theme="light"] h2,[data-theme="light"] h3,[data-theme="light"] h4 { color: var(--c-salt); }
[data-theme="light"] .t-muted        { color: var(--c-muted); }
[data-theme="light"] .alert-info     { background: rgba(26,78,128,.1);  color: #1a4e80; border-color: rgba(26,78,128,.3); }
[data-theme="light"] .alert-success  { background: rgba(26,94,52,.1);   color: #1a5e34; border-color: rgba(26,94,52,.3); }
[data-theme="light"] .alert-error    { background: rgba(168,48,32,.1);  color: #a83020; border-color: rgba(168,48,32,.3); }
[data-theme="light"] .form-control   { background: rgba(50,28,8,.06); border-color: rgba(50,28,8,.2); color: var(--c-salt); }
[data-theme="light"] .form-control:focus { border-color: var(--c-gold); box-shadow: 0 0 0 3px rgba(122,78,12,.15); }
[data-theme="light"] .form-control::placeholder { color: rgba(50,28,8,.35); }
[data-theme="light"] .parallax-overlay { opacity: .5; }
[data-theme="light"] .app             { background: #f0ebe3; }
[data-theme="light"] .app-header      { background: rgba(240,235,227,.96); border-bottom-color: rgba(50,28,8,.12); color: var(--c-salt); }
[data-theme="light"] .progress-track  { background: rgba(50,28,8,.1); }
[data-theme="light"] .stage-card,
[data-theme="light"] .nav-screen,
[data-theme="light"] .question-screen { color: var(--c-salt); }
[data-theme="light"] .stage-badge     { background: rgba(50,28,8,.08); color: var(--c-sand); border-color: rgba(50,28,8,.15); }
[data-theme="light"] .stage-location  { color: rgba(50,28,8,.6); }
[data-theme="light"] .cultural-box    { background: rgba(50,28,8,.05); border-color: rgba(50,28,8,.15); }
[data-theme="light"] .cultural-label  { color: var(--c-gold); }
[data-theme="light"] .cultural-text   { color: var(--c-sand); }
[data-theme="light"] .map-info        { background: rgba(50,28,8,.05); border-color: rgba(50,28,8,.12); }
[data-theme="light"] .distance-display { color: var(--c-sand); }
[data-theme="light"] .answer-textarea { background: rgba(50,28,8,.06); border-color: rgba(50,28,8,.2); color: var(--c-salt); }
[data-theme="light"] .location-status.in-range  { background: rgba(26,94,52,.1);   color: #1a5e34; border-color: rgba(26,94,52,.3); }
[data-theme="light"] .location-status.out-range { background: rgba(168,48,32,.1);  color: #a83020; border-color: rgba(168,48,32,.3); }
[data-theme="light"] .location-status.locating  { background: rgba(26,78,128,.1);  color: #1a4e80; border-color: rgba(26,78,128,.25); }
[data-theme="light"] .dot             { background: rgba(50,28,8,.15); }
[data-theme="light"] .dot.done        { background: var(--c-gold); }
[data-theme="light"] .dot.current     { background: var(--c-gold); box-shadow: 0 0 0 2px rgba(122,78,12,.3); }

/* ══════════════════════════════════════════════════════════
   3. BOUTON BASCULE NUIT / JOUR (pill toggle)
══════════════════════════════════════════════════════════ */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: none;
  padding: .3rem .45rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s;
  flex-shrink: 0;
}
.theme-switch:hover       { background: rgba(212,184,150,.07); }
.theme-switch:focus-visible { outline: 2px solid var(--c-gold); outline-offset: 3px; }

.theme-switch-label {
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--c-muted);
  line-height: 1;
  transition: color .25s;
  user-select: none;
  pointer-events: none;
}
/* Label actif : Nuit en dark, Jour en light */
:root:not([data-theme="light"]) .theme-switch .theme-switch-label:first-child { color: var(--c-salt); }
[data-theme="light"] .theme-switch .theme-switch-label:last-child            { color: var(--c-salt); }

.theme-switch-track {
  width: 46px;
  height: 25px;
  background: var(--c-mid);
  border: 1.5px solid var(--c-border);
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background .3s, border-color .3s;
  pointer-events: none;
}
[data-theme="light"] .theme-switch-track { background: var(--c-gold); border-color: var(--c-gold-h); }

.theme-switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--c-sand);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), background .25s;
  pointer-events: none;
}
[data-theme="light"] .theme-switch-thumb { transform: translateX(21px); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* Position dans .navbar */
.navbar .theme-switch { margin-left: auto; margin-right: .4rem; }
@media (min-width: 1024px) {
  .navbar .theme-switch { margin-left: .75rem; margin-right: 0; order: 99; }
}

/* Mode clair */
[data-theme="light"] .theme-switch:hover       { background: rgba(50,28,8,.06); }
[data-theme="light"] .theme-switch-label       { color: rgba(50,28,8,.45); }
[data-theme="light"] .theme-switch-label:last-child { color: var(--c-salt); }

/* ══════════════════════════════════════════════════════════
   4. BURGER + SIDENAV DU JEU (game.php)
══════════════════════════════════════════════════════════ */
.game-burger {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 26px; height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.game-burger-bar {
  display: block;
  width: 100%; height: 2px;
  background: var(--c-sand);
  border-radius: 2px;
  transition: background .2s, transform .25s;
}
.game-burger:hover .game-burger-bar     { background: var(--c-gold); }
.game-burger.is-open .game-burger-bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.game-burger.is-open .game-burger-bar:nth-child(2) { opacity: 0; }
.game-burger.is-open .game-burger-bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.game-sidenav {
  position: fixed;
  top: 0; right: 0;
  width: min(300px, 88vw);
  height: 100%;
  background: var(--c-mid);
  border-left: 1px solid var(--c-border);
  z-index: 1100;
  transform: translateX(102%);
  transition: transform .32s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  padding: var(--sp-lg) var(--sp-md);
  gap: var(--sp-md);
  box-shadow: -6px 0 32px rgba(0,0,0,.4);
  overflow-y: auto;
}
.game-sidenav.is-open { transform: translateX(0); }

.sidenav-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1099;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.sidenav-overlay.is-open { opacity: 1; pointer-events: auto; }

.sidenav-header {
  display: flex;
  justify-content: flex-end;
  padding-bottom: var(--sp-sm);
  border-bottom: 1px solid var(--c-border);
}
.sidenav-close {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: 50%;
  color: var(--c-sand);
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  line-height: 1;
}
.sidenav-close:hover { border-color: var(--c-gold); color: var(--c-gold); }

.sidenav-user { display: flex; flex-direction: column; gap: .25rem; }
.sidenav-user-label {
  font-size: .58rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--c-muted);
}
.sidenav-username { font-size: 1.1rem; color: var(--c-salt); font-weight: 600; }

.sidenav-divider { border: none; border-top: 1px solid var(--c-border); margin: 0; }

.sidenav-nav { display: flex; flex-direction: column; gap: .3rem; }
.sidenav-link {
  font-size: .88rem;
  color: var(--c-sand);
  text-decoration: none;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  transition: background .2s, color .2s;
  display: block;
}
.sidenav-link:hover { background: rgba(212,184,150,.08); color: var(--c-salt); }
.sidenav-logout     { color: var(--c-coral); }
.sidenav-logout:hover { background: rgba(196,87,58,.1); color: var(--c-coral); }

.sidenav-theme { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-sm); }
.sidenav-theme-label {
  font-size: .58rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--c-muted);
}
.sidenav-theme .theme-switch { padding: .3rem 0; margin-left: 0; }

/* header-actions minimal */
.header-actions {
  display: flex; align-items: center; gap: var(--sp-sm);
  flex-shrink: 0; margin-left: auto;
}

/* Light mode sidenav */
[data-theme="light"] .game-sidenav      { background: #f0ebe3; border-left-color: rgba(50,28,8,.12); box-shadow: -6px 0 32px rgba(0,0,0,.12); }
[data-theme="light"] .game-burger-bar   { background: var(--c-sand); }
[data-theme="light"] .sidenav-close     { border-color: rgba(50,28,8,.2); color: var(--c-sand); }
[data-theme="light"] .sidenav-divider   { border-color: rgba(50,28,8,.12); }
[data-theme="light"] .sidenav-link      { color: var(--c-sand); }
[data-theme="light"] .sidenav-link:hover { background: rgba(50,28,8,.06); color: var(--c-salt); }

/* ══════════════════════════════════════════════════════════
   5. POLICES MOBILE ×2
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  html { font-size: 17px; }
  .t-label,.form-label   { font-size: .75rem; }
  .form-hint,.form-error  { font-size: .8rem; }
  .btn          { font-size: .85rem; min-height: 46px; }
  .btn-lg       { font-size: 1rem; padding: 1.1rem 2.5rem; }
  .form-control { font-size: 1rem; padding: .85rem 1rem; }
  .badge        { font-size: .68rem; padding: .3rem .7rem; }
  .stage-title       { font-size: 1.45rem; }
  .stage-description { font-size: 1rem; line-height: 1.65; }
  .location-status   { font-size: 1rem; padding: .85rem 1rem; }
  .distance-value    { font-size: 1.5rem; }
  .btn-arrived,
  .btn-nav           { font-size: 1rem; padding: 1.1rem 1.5rem; min-height: 54px; }
  .btn-submit        { font-size: 1rem; padding: 1.1rem; }
  .question-text     { font-size: 1.05rem; line-height: 1.65; }
  .answer-textarea   { font-size: 1rem; padding: .85rem; }
  .cultural-text     { font-size: .95rem; line-height: 1.65; }
}

/* ══════════════════════════════════════════════════════════
   6. LEAFLET / CARTE PROXIMITÉ
══════════════════════════════════════════════════════════ */
.prox-map-outer {
  margin: var(--sp-md) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--c-border);
}
#map-container { height: 260px; width: 100%; background: var(--c-mid); }
@media (max-width: 768px) { #map-container { height: 220px; } }

.leaflet-container            { font-family: var(--f-body) !important; background: var(--c-mid) !important; }
.leaflet-popup-content-wrapper{ background: var(--c-mid) !important; color: var(--c-salt) !important; border: 1px solid var(--c-border) !important; box-shadow: var(--shadow-sm) !important; border-radius: var(--radius-md) !important; }
.leaflet-popup-tip            { background: var(--c-mid) !important; }
.leaflet-control-zoom a       { background: var(--c-mid) !important; color: var(--c-salt) !important; border-color: var(--c-border) !important; }
.leaflet-control-zoom a:hover { background: var(--c-ocean) !important; }
.leaflet-control-attribution  { background: rgba(7,20,32,.7) !important; color: rgba(212,184,150,.5) !important; font-size: 9px !important; }
[data-theme="light"] .leaflet-container { background: #e8e0d4 !important; }
[data-theme="light"] .leaflet-popup-content-wrapper { background: #fff !important; color: #1a1208 !important; }
[data-theme="light"] .leaflet-popup-tip { background: #fff !important; }
[data-theme="light"] .leaflet-control-zoom a { background: #fff !important; color: #3d2810 !important; border-color: rgba(50,28,8,.2) !important; }
[data-theme="light"] .leaflet-control-attribution { background: rgba(240,235,227,.8) !important; color: rgba(50,28,8,.5) !important; }

.kk-target-icon { width:32px;height:32px;display:flex;align-items:center;justify-content:center;font-size:20px;filter:drop-shadow(0 2px 4px rgba(0,0,0,.5)); }

.prox-gate { margin:var(--sp-md) 0; padding:var(--sp-lg) var(--sp-md); background:rgba(196,146,58,.07); border:1px dashed rgba(196,146,58,.4); border-radius:var(--radius-md); text-align:center; }
.prox-gate-icon { font-size:2rem; display:block; margin-bottom:.6rem; }
.prox-gate-msg  { color:var(--c-sand); font-size:.88rem; line-height:1.65; max-width:290px; margin:0 auto; }
.prox-gate-dist { font-family:var(--f-display); font-size:1.4rem; color:var(--c-gold); font-style:italic; display:block; margin-top:.3rem; }
.prox-content   { animation: prox-reveal .4s ease; }
@keyframes prox-reveal { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ══════════════════════════════════════════════════════════
   7. CARTE CIRCUIT NOIRMOUTIER
══════════════════════════════════════════════════════════ */
.circuit-map-section { padding:var(--sp-3xl) 0; border-top:1px solid var(--c-border); border-bottom:1px solid var(--c-border); }
#nm-circuit-map { height:420px; width:100%; border-radius:var(--radius-md); overflow:hidden; border:1px solid var(--c-border); background:var(--c-mid); }
@media (max-width:768px) { #nm-circuit-map { height:300px; } }

.kk-stage-pin { width:28px;height:28px;background:var(--c-gold);border:2px solid #fff;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;color:var(--c-dark);font-family:var(--f-body);box-shadow:0 2px 6px rgba(0,0,0,.45);cursor:pointer;transition:transform .15s,background .15s; }
.kk-stage-pin:hover { transform:scale(1.15); background:var(--c-gold-h); }

/* ══════════════════════════════════════════════════════════
   8. LAYOUT NAVBAR — burger GAUCHE, toggle DROITE
   Ordre HTML : [nav-toggle] [navbar-brand] [nav-links] [theme-switch]
   main.css a justify-content:space-between → ça suffit
══════════════════════════════════════════════════════════ */

/* Desktop : nav-toggle masqué, liens poussés à droite */
@media (min-width: 769px) {
  .nav-toggle  { display: none !important; }
  .navbar-brand { flex-shrink: 0; }
  .nav-links   { margin-left: auto; margin-right: var(--sp-sm); }
  .theme-switch { flex-shrink: 0; }
}

/* Mobile : burger gauche, brand centre (flex:1), toggle droite */
@media (max-width: 768px) {
  /* Forcer la disposition en ligne, pas space-between */
  .navbar {
    justify-content: flex-start !important;
    gap: var(--sp-sm);
  }
  .nav-toggle  { display: flex !important; flex-shrink: 0; }
  .navbar-brand { flex: 1; }               /* prend tout l'espace central */
  .nav-links   { display: none; }           /* masqué sauf .nav-open */
  .nav-links.nav-open { display: flex; }    /* ouvert = plein écran (main.css) */
  .theme-switch { margin-left: 0; flex-shrink: 0; }
}

/* ══════════════════════════════════════════════════════════
   9. TOGGLE : état aria-checked reflète le thème
══════════════════════════════════════════════════════════ */
.theme-switch[aria-checked="true"]  .theme-switch-track { background: var(--c-gold); border-color: var(--c-gold-h); }
.theme-switch[aria-checked="true"]  .theme-switch-thumb { transform: translateX(21px); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.theme-switch[aria-checked="false"] .theme-switch-track { background: var(--c-mid); border-color: var(--c-border); }
.theme-switch[aria-checked="false"] .theme-switch-thumb { transform: translateX(0); background: var(--c-sand); }

/* ══════════════════════════════════════════════════════════
   10. LIGHT MODE : overrides supplémentaires navbar
══════════════════════════════════════════════════════════ */
[data-theme="light"] .nav-toggle span { background: var(--c-sand); }
