/* RM Webstudios : base commune des freebies (styles, composants) */

:root {
  --dark: #1A1A1A;
  --beige: #E4E2DD;
  --tile-dark: #262626;
  --green: #4B6D14;
  --green-l: #88B33D;
  --muted-dark: #A9A59E;
  --muted-beige: #4D4D4D;
  --star: #F2B705;
  --danger: #C2462E;

  --font-title: "Anton", "Arial Narrow", sans-serif;
  --font-text: "Arimo", Arial, sans-serif;

  --gutter: 16px;
  --col: 640px;
  --header-h: 64px;
  --nav-h: 90px;
  --radius-tile: 26px;
  --radius-pill: 40px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --dur: .45s;
}

/* Thèmes d'écran : sombre / beige, appliqués sur body */
body[data-theme="dark"] {
  --bg: var(--dark);
  --fg: #FFFFFF;
  --muted: var(--muted-dark);
  --line: rgba(255, 255, 255, .14);
  --tile: var(--tile-dark);
  --chip-line: rgba(255, 255, 255, .28);
  --btn-bg: var(--beige);
  --btn-fg: var(--dark);
  --accent: var(--green-l);
  --pill-bg: var(--beige);
  --pill-fg: var(--dark);
}
body[data-theme="beige"] {
  --bg: var(--beige);
  --fg: var(--dark);
  --muted: var(--muted-beige);
  --line: rgba(26, 26, 26, .14);
  --tile: #EDEBE7;
  --chip-line: rgba(26, 26, 26, .3);
  --btn-bg: var(--dark);
  --btn-fg: var(--beige);
  --accent: var(--green);
  --pill-bg: var(--dark);
  --pill-fg: var(--beige);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background-color .5s var(--ease), color .5s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.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;
}

/* ---------- Typographie ---------- */
.fw-h1, .fw-h2, .fw-h3 {
  font-family: var(--font-title);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
  margin: 0;
  text-transform: none;
}
.fw-h1 { font-size: 40px; }
.fw-h2 { font-size: 32px; }
.fw-h3 { font-size: 24px; }
@media (min-width: 900px) {
  .fw-h1 { font-size: 72px; }
  .fw-h2 { font-size: 48px; }
  .fw-h3 { font-size: 28px; }
}
.fw-kicker {
  font: 700 11px/1.4 var(--font-text);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 14px;
}
.fw-lead { color: var(--muted); margin: 14px 0 0; max-width: 34em; }
.fw-small { font-size: 13px; color: var(--muted); }
.fw-pill {
  display: inline-block;
  font-family: var(--font-text);
  font-weight: 700;
  font-size: .5em;
  line-height: 1;
  padding: .32em .7em .38em;
  border-radius: var(--radius-pill);
  background: var(--pill-bg);
  color: var(--pill-fg);
  vertical-align: .32em;
  white-space: nowrap;
}
.fw-pill--green { background: var(--green); color: #fff; }
.fw-num {
  font-family: var(--font-title);
  font-size: 48px;
  line-height: 1;
  color: var(--accent);
  margin: 0 0 10px;
}
@media (min-width: 900px) { .fw-num { font-size: 64px; } }

/* ---------- Badge avec point qui pulse ---------- */
.fw-badge {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 13px; font-weight: 700;
}
.fw-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-l);
  box-shadow: 0 0 0 0 rgba(136, 179, 61, .6);
  animation: fw-pulse 2s infinite;
  flex: none;
}
@keyframes fw-pulse {
  0% { box-shadow: 0 0 0 0 rgba(136, 179, 61, .55); }
  70% { box-shadow: 0 0 0 9px rgba(136, 179, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(136, 179, 61, 0); }
}

/* ---------- En-tête : marque, progression, son ---------- */
.fw-header {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: var(--header-h);
  background: var(--bg);
  transition: background-color .5s var(--ease);
}
.fw-header-in {
  max-width: var(--col); height: 100%; margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 14px;
}
.fw-brand { font: 700 14px var(--font-text); white-space: nowrap; }
.fw-brand b { color: var(--accent); }
.fw-progress { flex: 1; display: flex; gap: 5px; }
.fw-progress i {
  flex: 1; height: 4px; border-radius: 4px;
  background: var(--line); overflow: hidden; position: relative;
}
.fw-progress i::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent);
  transform: scaleX(var(--p, 0)); transform-origin: left;
  transition: transform .6s var(--ease);
}
.fw-icon-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: transparent;
  display: grid; place-items: center;
}
.fw-icon-btn svg { width: 18px; height: 18px; }

/* ---------- Scène et écrans ---------- */
.fw-stage {
  padding: calc(var(--header-h) + 18px) var(--gutter) calc(var(--nav-h) + 40px);
  min-height: 100vh; min-height: 100dvh;
}
.fw-stage.no-nav { padding-bottom: 48px; }
.fw-screen { max-width: var(--col); margin: 0 auto; }
.fw-screen.is-entering { animation: fw-in var(--dur) var(--ease) both; }
.fw-screen.is-entering.from-back { animation-name: fw-in-back; }
@keyframes fw-in { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes fw-in-back { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
.fw-block { margin-top: 28px; }
.fw-block-label { font-weight: 700; margin: 0 0 12px; }

/* Apparition en cascade des éléments d'un écran */
.fw-rise { animation: fw-rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms + 120ms); }
@keyframes fw-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Boutons ---------- */
.fw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 58px; padding: 0 30px;
  border-radius: var(--radius-pill);
  font: 700 16px var(--font-text);
  border: 1.5px solid var(--btn-bg);
  background: var(--btn-bg); color: var(--btn-fg);
  text-decoration: none;
  transition: transform .15s var(--ease), opacity .2s;
  -webkit-user-select: none; user-select: none;
}
.fw-btn:active { transform: scale(.97); }
.fw-btn svg { width: 18px; height: 18px; }
.fw-btn--ghost { background: transparent; color: var(--fg); border-color: var(--chip-line); }
.fw-btn--block { width: 100%; }
.fw-btn[aria-disabled="true"] { opacity: .45; }
.fw-link {
  background: none; border: 0; padding: 6px 0;
  font-weight: 700; font-size: 14px; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Barre de navigation du bas ---------- */
.fw-nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 14px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  transition: background-color .5s var(--ease), transform .4s var(--ease);
}
.fw-nav.is-hidden { transform: translateY(110%); }
.fw-nav-in { max-width: var(--col); margin: 0 auto; display: flex; gap: 10px; position: relative; }
.fw-back {
  width: 58px; height: 58px; flex: none;
  border-radius: 50%; border: 1.5px solid var(--chip-line); background: transparent;
  display: grid; place-items: center;
}
.fw-back svg { width: 20px; height: 20px; }
.fw-back[hidden] { display: none; }
.fw-nav .fw-btn { flex: 1; }
.fw-nav-msg {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 26px);
  text-align: center; font-size: 14px; font-weight: 700;
  pointer-events: none; opacity: 0; transform: translateY(6px);
  transition: opacity .25s, transform .25s var(--ease);
}
.fw-nav-msg span { background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: var(--radius-pill); }
.fw-nav-msg.is-on { opacity: 1; transform: none; }
.fw-shake { animation: fw-shake .4s; }
@keyframes fw-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---------- Choix : rangées d'options ---------- */
.fw-options { display: grid; gap: 10px; }
.fw-option {
  width: 100%; text-align: left;
  display: flex; align-items: center; gap: 14px;
  min-height: 64px; padding: 16px 20px;
  border-radius: var(--radius-tile);
  border: 1.5px solid var(--line);
  background: var(--tile);
  transition: border-color .25s, background-color .25s, transform .15s var(--ease);
}
.fw-option:active { transform: scale(.985); }
.fw-option-text { flex: 1; font-weight: 700; }
.fw-option-text small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; margin-top: 2px; }
.fw-option .fw-check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--chip-line);
  display: grid; place-items: center;
  transition: background-color .25s, border-color .25s;
}
.fw-option .fw-check svg { width: 14px; height: 14px; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .35s var(--ease) .05s; }
.fw-option[aria-pressed="true"] { border-color: var(--accent); }
.fw-option[aria-pressed="true"] .fw-check { background: var(--green); border-color: var(--green); color: #fff; }
.fw-option[aria-pressed="true"] .fw-check svg { stroke-dashoffset: 0; }

/* Grille de tuiles (secteurs) */
.fw-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 600px) { .fw-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fw-grid .fw-option { flex-direction: column; align-items: flex-start; gap: 10px; min-height: 104px; padding: 16px; }
.fw-grid .fw-option svg.fw-ico { width: 26px; height: 26px; color: var(--accent); }
.fw-grid .fw-option-text { font-size: 15px; line-height: 1.3; }

/* ---------- Pastilles à cocher ---------- */
.fw-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fw-chip {
  min-height: 44px; padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--chip-line);
  background: transparent;
  font-weight: 700; font-size: 15px;
  transition: background-color .25s, border-color .25s, color .25s, transform .15s var(--ease);
}
.fw-chip:active { transform: scale(.96); }
.fw-chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- Tuiles et cartes ---------- */
.fw-tile {
  border-radius: var(--radius-tile);
  padding: 30px;
  background: var(--tile);
}
.fw-tile--dark {
  background: var(--tile-dark); color: #fff;
  --fg: #fff; --bg: var(--tile-dark);
  --muted: var(--muted-dark); --accent: var(--green-l); --line: rgba(255,255,255,.14);
  --chip-line: rgba(255,255,255,.3); --btn-bg: var(--beige); --btn-fg: var(--dark);
}
.fw-tile--green { background: var(--green); color: #fff; --muted: rgba(255,255,255,.8); --accent: #fff; }
@media (max-width: 380px) { .fw-tile { padding: 24px; } }

/* Carte « Le conseil de Rika » */
.fw-tip {
  margin-top: 26px;
  border-radius: var(--radius-tile);
  padding: 26px 30px 28px;
  background: var(--pill-bg); color: var(--pill-fg);
  --muted: currentColor;
  position: relative;
  opacity: 0; transform: translateY(16px);
  transition: opacity .55s var(--ease), transform .55s var(--ease);
}
.fw-tip.is-on { opacity: 1; transform: none; }
.fw-tip .fw-kicker { color: var(--green-l); margin-bottom: 10px; }
body[data-theme="dark"] .fw-tip .fw-kicker { color: var(--green); }
.fw-tip-main { font: 400 24px/1.15 var(--font-title); margin: 0; }
.fw-tip-sub { margin: 10px 0 0; font-size: 15px; opacity: .78; }
.fw-tip-arrow { position: absolute; top: -22px; right: 26px; width: 54px; height: 34px; color: var(--accent); }

/* ---------- Curseur ---------- */
.fw-range { margin-top: 22px; }
.fw-range-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.fw-range-head label { font-weight: 700; }
.fw-range-val { font: 400 28px/1 var(--font-title); color: var(--accent); white-space: nowrap; }
input[type="range"].fw-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 36px; background: transparent; margin: 0;
  touch-action: pan-y;
}
.fw-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--line) var(--fill, 50%)); }
.fw-slider::-moz-range-track { height: 6px; border-radius: 6px; background: var(--line); }
.fw-slider::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
.fw-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 30px; height: 30px; margin-top: -12px;
  border-radius: 50%; background: var(--fg); border: 6px solid var(--bg);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.fw-slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--fg); border: 5px solid var(--bg); box-shadow: 0 0 0 1.5px var(--accent); }

/* ---------- Champ texte ---------- */
.fw-input {
  width: 100%; height: 58px; padding: 0 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--chip-line);
  background: transparent;
  font-size: 16px;
}
.fw-input::placeholder { color: var(--muted); opacity: .8; }
.fw-input:focus { outline: none; border-color: var(--accent); }

/* ---------- Jauge circulaire ---------- */
.fw-gauge { position: relative; width: 120px; height: 120px; flex: none; }
.fw-gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.fw-gauge circle { fill: none; stroke-width: 10; }
.fw-gauge .bg { stroke: var(--line); }
.fw-gauge .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease); }
.fw-gauge-val { position: absolute; inset: 0; display: grid; place-items: center; font: 400 30px/1 var(--font-title); }

/* ---------- Étoiles ---------- */
.fw-stars { display: inline-flex; gap: 3px; color: var(--star); }
.fw-stars svg { width: 18px; height: 18px; }

/* ---------- Confettis ---------- */
.fw-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- Bouton son ---------- */
.fw-sound .on { display: none; }
.fw-sound[aria-pressed="true"] .on { display: block; }
.fw-sound[aria-pressed="true"] .off { display: none; }

/* ---------- Survol : seulement sur les appareils qui le permettent ---------- */
@media (hover: hover) and (pointer: fine) {
  .fw-option:hover { border-color: var(--chip-line); }
  .fw-chip:hover { border-color: var(--fg); }
  .fw-btn:hover { opacity: .88; }
}

/* ---------- Réduire les animations ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .fw-dot { animation: none; }
}

/* ---------- Impression (enregistrer le plan en PDF) ---------- */
@media print {
  body { background: #fff !important; color: #1A1A1A !important; }
  .fw-header, .fw-nav, .fw-noprint, .fw-confetti { display: none !important; }
  .fw-stage { padding: 0 !important; }
  .fw-tile, .fw-tip { break-inside: avoid; }
  .fw-tile--dark, .fw-tile--green { color: #1A1A1A !important; background: #EDEBE7 !important; }
}

h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
.fw-tip-sub:empty { display: none; }
