/* =========================================================
   Lance les Dés ! – feuille de style
   3 ambiances festives : fete (défaut), neon, tropical
   ========================================================= */

:root,
[data-theme="fete"] {
  /* 🎪 Fête foraine : violet, rose bonbon, jaune soleil */
  --bg-1: #7b2ff7;
  --bg-2: #f107a3;
  --bg-3: #ff9a00;
  --card: #ffffff;
  --text: #2b1055;
  --muted: #6b5a8e;
  --accent: #ffd60a;
  --accent-text: #2b1055;
  --primary: #f107a3;
  --primary-text: #ffffff;
  --primary-2: #7b2ff7;
  --border: #eadcff;
  --shadow: 0 12px 30px rgba(43, 16, 85, .25);
}

[data-theme="neon"] {
  /* 🕹️ Néon arcade : fond nuit, cyan, magenta, vert acide */
  --bg-1: #0b0221;
  --bg-2: #1a0b3d;
  --bg-3: #2d0b59;
  --card: #150832;
  --text: #f4ecff;
  --muted: #b9a8e0;
  --accent: #00f5d4;
  --accent-text: #0b0221;
  --primary: #ff00e5;
  --primary-text: #ffffff;
  --primary-2: #7b2ff7;
  --border: #3a2170;
  --shadow: 0 0 24px rgba(255, 0, 229, .35);
}

[data-theme="tropical"] {
  /* 🌴 Tropical : turquoise, corail, mangue */
  --bg-1: #00b4d8;
  --bg-2: #48cae4;
  --bg-3: #ffb703;
  --card: #fffdf7;
  --text: #023047;
  --muted: #3d6277;
  --accent: #ffb703;
  --accent-text: #023047;
  --primary: #fb6f50;
  --primary-text: #ffffff;
  --primary-2: #e63946;
  --border: #d6f2f7;
  --shadow: 0 12px 30px rgba(2, 48, 71, .22);
}

/* Polices par écriture */
:root {
  --font-head: "Baloo 2", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:lang(hi) {
  --font-head: "Baloo 2", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-body: "Noto Sans Devanagari", system-ui, sans-serif;
}
:lang(ar) {
  --font-head: "Baloo Bhaijaan 2", "Noto Sans Arabic", system-ui, sans-serif;
  --font-body: "Noto Sans Arabic", system-ui, sans-serif;
}
:lang(zh) {
  --font-head: "Baloo 2", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  --font-body: "Nunito", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-1);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,.18) 0 6px, transparent 7px),
    radial-gradient(circle at 80% 35%, rgba(255,255,255,.15) 0 4px, transparent 5px),
    radial-gradient(circle at 60% 80%, rgba(255,255,255,.12) 0 5px, transparent 6px),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-size: 220px 220px, 160px 160px, 260px 260px, 100% 100%;
  background-attachment: fixed;
  line-height: 1.6;
}

h1, h2, h3, .logo, .roll-btn, .total { font-family: var(--font-head); }

a { color: inherit; }

.skip-link {
  position: absolute; top: -10rem; inset-inline-start: 1rem;
  background: var(--accent); color: var(--accent-text); padding: .5rem 1rem; z-index: 10;
}
.skip-link:focus { top: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- En-tête ---------- */
.site-header {
  max-width: 960px; margin: 0 auto; padding: 1rem 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo {
  color: #fff; text-decoration: none; font-size: 1.5rem; font-weight: 800;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.logo-dice { display: inline-block; animation: wobble 3s ease-in-out infinite; }

.theme-picker { display: flex; gap: .4rem; background: rgba(255,255,255,.2); padding: .3rem; border-radius: 999px; }
.theme-btn {
  border: 0; background: transparent; font-size: 1.25rem; width: 2.4rem; height: 2.4rem;
  border-radius: 50%; cursor: pointer; transition: transform .2s, background .2s;
}
.theme-btn:hover { transform: scale(1.15); }
.theme-btn[aria-pressed="true"] { background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.2); }

.header-tools { display: flex; align-items: center; gap: .6rem; }

/* Menu des langues (liens explorables par Google, fonctionne sans JS) */
.lang-menu { position: relative; }
.lang-menu summary {
  list-style: none; cursor: pointer; color: #fff; font-weight: 700; white-space: nowrap;
  background: rgba(255,255,255,.2); padding: .45rem .8rem; border-radius: 999px;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu:not([open]) ul { display: none; }
.lang-menu summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.lang-menu ul {
  position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); z-index: 20;
  list-style: none; margin: 0; padding: .4rem; min-width: 10rem;
  background: var(--card); border: 2px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.lang-menu a {
  display: block; padding: .45rem .8rem; border-radius: 10px; text-decoration: none; color: var(--text);
}
.lang-menu a:hover, .lang-menu a:focus-visible { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.lang-menu a[aria-current="page"] { font-weight: 800; color: var(--primary); }

@media (max-width: 520px) {
  .site-header { flex-wrap: wrap; justify-content: center; }
  .logo { font-size: 1.3rem; }
}

/* Page d'accueil : choix de la langue */
.root-picker { max-width: 520px; margin: 0 auto; padding: 3rem 16px; text-align: center; color: #fff; }
.root-picker h1 { font-size: 2.6rem; }
.root-langs { list-style: none; padding: 0; display: grid; gap: .6rem; }
.root-langs a {
  display: block; padding: .8rem 1rem; border-radius: 16px; text-decoration: none; font-weight: 700;
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}

/* ---------- Hero ---------- */
main { max-width: 960px; margin: 0 auto; padding: 0 16px 2rem; }

.hero { text-align: center; color: #fff; padding: 1rem 0 1.5rem; }
.hero h1 {
  font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.1; margin: 0 0 .5rem;
  text-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.highlight {
  background: var(--accent); color: var(--accent-text);
  padding: 0 .4em; border-radius: .4em; display: inline-block; transform: rotate(-3deg);
}
.tagline { font-size: 1.15rem; margin: 0; opacity: .95; }

/* ---------- Cartes ---------- */
.card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: clamp(1rem, 4vw, 2rem); margin-bottom: 1.5rem;
  border: 2px solid var(--border);
}

/* ---------- Lanceur ---------- */
.roller { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .roller { grid-template-columns: 340px 1fr; } }

.controls { display: flex; flex-direction: column; gap: 1rem; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field legend { font-weight: 700; display: block; margin-bottom: .4rem; }

.stepper { display: flex; align-items: stretch; gap: .4rem; }
.stepper input { flex: 1; min-width: 0; text-align: center; }
.step {
  width: 3rem; border: 0; border-radius: 14px; font-size: 1.5rem; font-weight: 800; cursor: pointer;
  background: var(--accent); color: var(--accent-text); transition: transform .1s;
}
.step:active { transform: scale(.92); }

input[type="number"] {
  font: inherit; font-size: 1.25rem; font-weight: 700; color: var(--text);
  background: transparent; border: 2px solid var(--border); border-radius: 14px; padding: .55rem .8rem;
  width: 100%;
}
input[type="number"]:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.preset {
  font: inherit; font-weight: 800; padding: .55rem 0; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border); background: transparent; color: var(--text);
  transition: transform .15s, background .15s;
}
.preset:hover { transform: translateY(-2px); }
.preset.is-active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

.custom-label { display: block; margin: .6rem 0 .3rem; color: var(--muted); font-size: .95rem; }

.notation { margin: 0; color: var(--muted); }
.notation strong { color: var(--text); font-size: 1.2rem; }

.error { margin: 0; color: #d00000; font-weight: 700; }
[data-theme="neon"] .error { color: #ff6b6b; }

.roll-btn {
  font-size: 1.5rem; font-weight: 800; padding: .9rem 1rem; border: 0; border-radius: 18px; cursor: pointer;
  color: var(--primary-text);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 0 rgba(0,0,0,.2), var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
.roll-btn:hover { transform: translateY(-2px); }
.roll-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.roll-btn:focus-visible, .preset:focus-visible, .step:focus-visible, .theme-btn:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 3px;
}
.hint { margin: 0; font-size: .85rem; color: var(--muted); text-align: center; }
kbd { font-family: inherit; border: 1px solid var(--border); border-bottom-width: 3px; border-radius: 6px; padding: 0 .35em; font-size: .85em; }

/* ---------- Résultats ---------- */
.results { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.tray {
  min-height: 200px; border-radius: 20px; padding: 1rem;
  display: flex; flex-wrap: wrap; gap: .8rem; align-content: center; justify-content: center;
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,.03) 0 12px, transparent 12px 24px),
    color-mix(in srgb, var(--accent) 18%, transparent);
  border: 3px dashed var(--border);
}

.die {
  --size: 64px;
  width: var(--size); height: var(--size); border-radius: 16px;
  display: grid; place-items: center;
  color: #fff; font-family: var(--font-head); font-weight: 800; font-size: 1.6rem;
  direction: ltr;
  background: var(--die-bg, #8338ec);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.2), 0 6px 12px rgba(0,0,0,.2);
  animation: roll .6s cubic-bezier(.2,.8,.3,1.2) both;
  position: relative;
}
.die.small { --size: 52px; font-size: 1.25rem; }
.die.long { font-size: 1.05rem; }
.die.is-max { outline: 4px solid var(--accent); outline-offset: 2px; }
.die.is-min { opacity: .75; }

/* Dés à 6 faces avec points */
.die.pips {
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: 10px; place-items: center;
}
.pip { width: 11px; height: 11px; border-radius: 50%; background: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.die.small .pip { width: 9px; height: 9px; }

.summary { text-align: center; }
.placeholder { color: var(--muted); margin: 0; }
.total {
  font-size: clamp(2.5rem, 9vw, 4rem); font-weight: 800; line-height: 1;
  margin: 0; color: var(--primary);
}
.total-label { margin: 0 0 .3rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
.stats { display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap; margin: .6rem 0 0; padding: 0; list-style: none; color: var(--muted); }
.stats strong { color: var(--text); }
.celebrate { margin: .5rem 0 0; font-weight: 800; color: var(--primary); animation: pop .5s both; }

/* ---------- Historique ---------- */
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.history-head h2 { margin: 0; font-size: 1.4rem; }
.link-btn { font: inherit; background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; }
.history { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-direction: column; gap: .4rem; max-height: 260px; overflow-y: auto; }
.history li {
  display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .8rem; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); font-size: .95rem;
}
.history .h-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.history .h-total { font-weight: 800; white-space: nowrap; }
.history:empty::before { content: attr(data-empty); color: var(--muted); }

/* ---------- Contenu SEO ---------- */
.content h2 { font-size: 1.6rem; margin: 1.5rem 0 .6rem; }
.content h2:first-child { margin-top: 0; }
.content li { margin-bottom: .3rem; }
.usecases { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.usecase { padding: 1rem; border-radius: 18px; background: color-mix(in srgb, var(--accent) 14%, transparent); }
.usecase h3 { margin: .2rem 0; font-size: 1.2rem; }
.usecase p { margin: 0; font-size: .95rem; }
.usecase-icon { font-size: 2rem; }
.content details { border-bottom: 2px solid var(--border); padding: .6rem 0; }
.content summary { cursor: pointer; font-weight: 700; }
.content details p { margin: .5rem 0 0; color: var(--muted); }
code { background: color-mix(in srgb, var(--accent) 25%, transparent); padding: 0 .3em; border-radius: 4px; }

.ad-slot { min-height: 250px; margin-bottom: 1.5rem; }

/* ---------- Pied de page ---------- */
.site-footer { text-align: center; color: #fff; padding: 1rem 16px 2rem; font-size: .9rem; }
.site-footer p { margin: .2rem 0; }

/* ---------- Confettis ---------- */
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- Animations ---------- */
@keyframes roll {
  0%   { transform: translateY(-60px) rotate(-200deg) scale(.4); opacity: 0; }
  70%  { transform: translateY(6px) rotate(12deg) scale(1.08); opacity: 1; }
  100% { transform: translateY(0) rotate(0) scale(1); }
}
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes wobble { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-15deg); } }

.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px) rotate(-1deg); } 75% { transform: translateX(6px) rotate(1deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* =========================================================
   Navigation entre outils
   ========================================================= */
.tool-nav {
  display: flex; justify-content: center; flex-wrap: wrap; gap: .5rem; margin: .2rem 0 .4rem;
}
.tool-nav a {
  color: #fff; text-decoration: none; font-weight: 700; white-space: nowrap;
  padding: .45rem .95rem; border-radius: 999px; background: rgba(255,255,255,.18);
  border: 2px solid transparent; transition: background .2s, transform .2s;
}
.tool-nav a:hover { background: rgba(255,255,255,.3); transform: translateY(-2px); }
.tool-nav a[aria-current="page"] { background: #fff; color: var(--primary); }
[data-theme="neon"] .tool-nav a[aria-current="page"] { background: var(--card); border-color: var(--primary); }
.tool-nav a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Petits éléments partagés */
.muted { color: var(--muted); }
.mini-card {
  border: 2px dashed var(--border); border-radius: 16px; padding: .8rem 1rem;
}
.mini-card h3 { margin: 0; font-size: 1.1rem; }
.stats-col { flex-direction: column; align-items: flex-start; gap: .2rem; margin-top: .5rem; }
.hint-start { text-align: start; margin-top: .3rem; }
.row-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.small-btn {
  font: inherit; font-weight: 700; padding: .45rem .9rem; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border); background: transparent; color: var(--text);
}
.small-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.small-btn:focus-visible, .check input:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .95rem; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--primary); }
textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: transparent;
  border: 2px solid var(--border); border-radius: 14px; padding: .6rem .8rem; resize: vertical; min-height: 9rem;
}
textarea:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.roll-btn:disabled { opacity: .7; cursor: wait; }

/* =========================================================
   Pile ou face
   ========================================================= */
.coin-stage {
  min-height: 220px; border-radius: 20px; padding: 1.2rem;
  display: flex; flex-wrap: wrap; gap: 1rem; align-content: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 3px dashed var(--border); perspective: 900px;
}
.coin { --size: 150px; width: var(--size); height: var(--size); }
.coin-stage.many .coin { --size: 84px; }
.coin-inner {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  transition: transform 1.3s cubic-bezier(.2,.7,.25,1) var(--delay, 0ms);
}
.coin-face {
  position: absolute; inset: 0; border-radius: 50%; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 800; color: #6b4300;
  background: radial-gradient(circle at 35% 30%, #fff6c4 0 12%, #ffd60a 40%, #e09f00 100%);
  box-shadow: inset 0 0 0 calc(var(--size) * .06) #f0b400, inset 0 0 0 calc(var(--size) * .085) #ffe680, 0 10px 22px rgba(0,0,0,.25);
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}
.coin-tails {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 35% 30%, #ffffff 0 12%, #dfe4ee 40%, #9aa3b5 100%);
  box-shadow: inset 0 0 0 calc(var(--size) * .06) #b5bdcc, inset 0 0 0 calc(var(--size) * .085) #eef1f6, 0 10px 22px rgba(0,0,0,.25);
  color: #3b4252;
}
.coin-symbol { font-size: calc(var(--size) * .32); line-height: 1; }
.coin-word { font-size: calc(var(--size) * .15); line-height: 1.2; padding: 0 .4em; text-align: center; }
.coin-result { font-size: clamp(1.8rem, 6vw, 3rem); }

/* =========================================================
   Roue de la fortune
   ========================================================= */
@media (min-width: 800px) { .roller.wheel-layout { grid-template-columns: 1fr 320px; } }
.wheel-wrap { position: relative; width: min(100%, 440px); margin: 0 auto; aspect-ratio: 1; }
#wheel { width: 100%; height: 100%; display: block; cursor: pointer; border-radius: 50%;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.wheel-pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%); z-index: 2;
  width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent;
  border-top: 34px solid var(--text); filter: drop-shadow(0 3px 2px rgba(0,0,0,.3));
}
[data-theme="neon"] .wheel-pointer { border-top-color: var(--accent); }
.wheel-result { font-size: clamp(1.8rem, 6vw, 3rem); overflow-wrap: anywhere; }
