/* ===== Palette limitée façon 8/16 bits ===== */
:root {
  --black: #000000;
  --white: #ffffff;
  --yellow: #f8d878;
  --grey: #bcbcbc;
  --link: #7cc4f8;
  --border: 4px;
  --radius: 10px;
  /* Polices système à chasse fixe (aucune police web) : rendu « terminal » rétro */
  --font: Consolas, "Lucida Console", "Courier New", monospace;
}

/* ===== Reset minimal ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: 1.125rem;
  line-height: 1.6;
  letter-spacing: 0.03em;
}

h1, h2, h3, strong, b {
  font-weight: 400;
}

strong {
  color: var(--yellow);
}

a {
  color: var(--link);
}

/* Focus clavier bien visible : contour jaune épais (bleu en mode classique) */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

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

/* ===== Lien d'évitement ===== */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 30;
  padding: 0.5rem 1rem;
  background: var(--black);
  border: 2px solid var(--white);
  color: var(--white);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ===== Fenêtre Dragon Quest : fond noir uni, bordure blanche épaisse ===== */
.win {
  position: relative;
  padding: 0.9rem 1.1rem;
  border: var(--border) solid var(--white);
  border-radius: var(--radius);
  background: var(--black);
  box-shadow: 0 0 0 3px var(--black);
}

/* Titre posé sur la bordure du haut, comme le nom du héros dans le jeu */
.win-title {
  position: absolute;
  top: -0.85em;
  left: 50%;
  margin: 0;
  padding: 0 0.5em;
  transform: translateX(-50%);
  background: var(--black);
  white-space: nowrap;
}

/* Curseur ▶ qui clignote */
@keyframes blink {
  50% { opacity: 0; }
}

/* ===== Écran de jeu ===== */
.screen {
  max-width: 1024px;
  margin: 0 auto;
  padding: 1rem;
}

.stage {
  position: relative;
}

.scene {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: var(--border) solid var(--white);
  border-radius: 6px;
  background: #3cbcfc;
}

.scene canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#backdrop {
  width: 100%;
  height: 100%;
}

#monster {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 24%;
  transform: translateX(-50%);
}

#fx,
.flash-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flash-fx {
  background: var(--white);
  opacity: 0;
}

.scene.flash .flash-fx {
  animation: flash 0.45s steps(1);
}

@keyframes flash {
  0% { opacity: 0.9; }
  25% { opacity: 0; }
  50% { opacity: 0.9; }
  75% { opacity: 0; }
}

#monster.hit {
  animation: flicker 0.12s steps(1) 6;
}

#monster.defeated {
  visibility: hidden;
}

@keyframes flicker {
  50% { visibility: hidden; }
}

.screen.shake {
  animation: shake 0.4s steps(8);
}

@keyframes shake {
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(6px, -2px); }
  60% { transform: translate(-4px, 0); }
  80% { transform: translate(4px, 2px); }
}

/* Fenêtre d'état : nom, vocation, niveau, PV, PM */
.site-header {
  margin-bottom: 1rem;
}

.status-win {
  padding-top: 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1.2;
}

.status-class {
  margin: 0.2rem 0 0.5rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  margin: 0;
}

.stats div {
  display: flex;
  gap: 0.5rem;
}

.stats dt {
  color: var(--grey);
}

.stats dd {
  margin: 0;
}

/* ===== Barres de vie (Alexis et monstre) ===== */
.hp-bar {
  display: inline-block;
  position: relative;
  width: 100%;
  height: 12px;
  border: 2px solid var(--white);
  background: var(--black);
  vertical-align: middle;
}

.hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: #58d854;
  transition: width 0.4s steps(6);
}

.hp-fill[data-level="warn"] {
  background: #f8d878;
}

.hp-fill[data-level="low"] {
  background: #f83800;
}

.hero-hp {
  max-width: 16rem;
  margin-top: 0.4rem;
}

/* Petite fenêtre au-dessus du monstre : nom, barre, PV restants */
.foe-hud {
  position: absolute;
  left: 50%;
  bottom: 54%;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.1rem 0.6rem;
  transform: translateX(-50%);
  border: 3px solid var(--white);
  border-radius: 6px;
  background: var(--black);
  font-size: 1rem;
  white-space: nowrap;
}

.foe-hud .hp-bar {
  width: 5rem;
}

.foe-hud[hidden] {
  display: none;
}

/* Options : son et animations */
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

/* Boutons compacts pour tenir côte à côte sur téléphone (texte toujours à 16 px) */
.options .btn {
  padding: 0.25rem 0.6rem;
  font-size: 1rem;
}

/* ===== Menu de commandes + fenêtre de message ===== */
.battle-ui {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

/* Une colonne sur téléphone, deux dès 480 px (voir les media queries) */
.commands {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.1rem 1rem;
  margin: 0.3rem 0 0;
  padding: 0;
  list-style: none;
}

.command {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.25rem 0.2rem 0.25rem 1.5rem;
  border: 0;
  background: none;
  color: var(--white);
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.command::before {
  content: "▶";
  position: absolute;
  left: 0.2rem;
  opacity: 0;
}

.command:hover::before,
.command:focus-visible::before,
.command.selected::before {
  opacity: 1;
  animation: blink 1s steps(1) infinite;
}

/* Menu : curseur ▶ façon Dragon Quest + texte jaune souligné au focus clavier */
.command:focus-visible {
  outline: none;
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Fenêtre des sorts : s'ouvre par-dessus le menu, comme un sous-menu du jeu */
.command-area {
  position: relative;
}

.command-win {
  height: 100%;
}

.spell-win {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 1.5rem;
  z-index: 6;
  max-width: 20rem;
}

.spells {
  margin: 0.3rem 0 0;
  padding: 0;
  list-style: none;
}

.spell {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.2rem 0.2rem 0.2rem 1.5rem;
  border: 0;
  background: none;
  color: var(--white);
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.spell::before {
  content: "▶";
  position: absolute;
  left: 0.2rem;
  opacity: 0;
}

.spell:hover::before,
.spell:focus-visible::before {
  opacity: 1;
  animation: blink 1s steps(1) infinite;
}

.spell:focus-visible {
  outline: none;
  color: var(--yellow);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.spell-cost {
  color: var(--grey);
}

.message-win {
  min-height: 7.2rem;
}

.message {
  margin: 0;
}

.message.more::after {
  content: " ▼";
  animation: blink 0.8s steps(1) infinite;
}

/* ===== Contenu du CV ===== */
.cv {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 1rem 1.5rem;
}

.cv-window {
  padding: 2.25rem 1.25rem 1.75rem;
}

.cv-window section {
  margin-top: 1.5rem;
  scroll-margin-top: 1.5rem;
}

.cv-window section:first-of-type {
  margin-top: 0.5rem;
}

h2 {
  margin: 0 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--white);
  font-size: 1.35rem;
  text-transform: uppercase;
}

h3 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.4;
}

.meta {
  margin: 0.1rem 0 0.4rem;
  color: var(--yellow);
}

/* Phrase de résultat sous une expérience ou un projet */
.result {
  margin: 0 0 0.4rem;
}

.entry {
  margin-bottom: 1rem;
}

.entry ul {
  margin: 0;
  padding-left: 1.4rem;
  list-style: none;
}

.entry li {
  position: relative;
}

.entry li::before {
  content: "・";
  position: absolute;
  left: -1.3rem;
}

/* Listes façon menu : la ligne survolée reçoit le curseur ▶ */
.cursor-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cursor-list li {
  position: relative;
  padding: 0.2rem 0 0.2rem 1.5rem;
}

.cursor-list li::before {
  content: "▶";
  position: absolute;
  left: 0.2rem;
  opacity: 0;
}

.cursor-list li:hover::before {
  opacity: 1;
  animation: blink 1s steps(1) infinite;
}

.contact,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.chips li,
.contact li {
  padding: 0.2rem 0.8rem;
  border: 2px solid var(--white);
  border-radius: 6px;
}

.cv-actions {
  margin: 1.5rem 0 0;
  text-align: center;
}

.btn {
  padding: 0.3rem 1rem;
  border: 3px solid var(--white);
  border-radius: 8px;
  background: var(--black);
  color: var(--white);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.btn:hover {
  color: var(--yellow);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.close-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 3;
  width: 44px;
  height: 44px;
  padding: 0;
}

/* Sans JavaScript, la scène (dessinée en JS) resterait vide : on la masque,
   les commandes deviennent de simples liens vers le CV affiché en dessous */
html:not(.js) .scene {
  display: none;
}

/* ===== Mode JavaScript : le CV complet s'ouvre depuis le menu ===== */
.js .cv {
  display: none;
}

.js.cv-open {
  overflow: hidden;
}

.js.cv-open .cv {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 20;
  max-width: none;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.85);
}

.js.cv-open .cv-window {
  max-width: 820px;
  margin: 0 auto;
  animation: open-window 0.3s steps(5, end);
}

.js.cv-open #closeCv {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 5;
}

@keyframes open-window {
  from { transform: scaleY(0.05); }
}

/* ===== Fenêtre d'une section ===== */
dialog {
  width: 100%;
  max-width: min(720px, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--white);
  overflow: visible;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.panel {
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.5rem 1.25rem 2rem;
}

.panel h2 {
  padding-right: 3rem;
}

.panel::after {
  content: "▼";
  position: absolute;
  right: 1rem;
  bottom: 0.3rem;
  animation: blink 0.8s steps(1) infinite;
}

dialog[open] .panel {
  animation: open-window 0.25s steps(4, end);
}

/* ===== Pied de page ===== */
.site-footer {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0.5rem 1rem 2rem;
  color: var(--grey);
  text-align: center;
}

.site-footer p {
  margin: 0.2rem 0;
}

/* ===== Dès 480 px : menu de commandes sur deux colonnes ===== */
@media (min-width: 480px) {
  .commands {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Entre 760 et 1024 px, le menu est à côté du message : trop étroit pour 2 colonnes */
@media (min-width: 760px) and (max-width: 1023px) {
  .commands {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===== Desktop : état par-dessus la scène, menu et message côte à côte ===== */
@media (min-width: 760px) {
  .site-header {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 2;
  }

  .options {
    position: absolute;
    right: 0.8rem;
    bottom: 0.6rem;
    margin: 0;
  }

  .battle-ui {
    grid-template-columns: minmax(22rem, 0.9fr) 1.4fr;
    align-items: stretch;
  }

  .cv-window {
    padding: 2.5rem 2.5rem 2rem;
  }
}

/* ===== Mouvement réduit (réglage du système ou bouton « Animations : non ») ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.no-motion {
  scroll-behavior: auto;
}

.no-motion *,
.no-motion *::before,
.no-motion *::after {
  animation: none !important;
  transition: none !important;
}

/* ===== Mode classique : version sobre (fond clair, police système, sans jeu) =====
   La classe est posée sur <body> par js/app.js (et sur <html> dès le chargement
   pour éviter un flash du jeu). */
.classic {
  background: #f5f5f0;
  color: #1e1e1e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: normal;
}

.classic *,
.classic *::before,
.classic *::after {
  animation: none !important;
  transition: none !important;
}

.classic .scene,
.classic .stats,
.classic .hero-hp,
.classic .message-win,
.classic .win-title,
.classic .spell-win,
.classic .close-btn,
.classic #fightBtn,
.classic #journalBtn,
.classic #soundBtn,
.classic #motionBtn {
  display: none !important;
}

.classic .win {
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
  color: #1e1e1e;
}

.classic .site-header {
  position: static;
}

.classic .battle-ui {
  grid-template-columns: 1fr;
}

.classic h1,
.classic h2,
.classic h3 {
  color: #1e1e1e;
}

.classic h2 {
  border-bottom-color: #1e1e1e;
}

.classic strong {
  color: inherit;
  font-weight: 700;
}

.classic .meta {
  color: #555555;
}

.classic a {
  color: #0b57d0;
}

.classic .command {
  color: #1e1e1e;
  text-transform: none;
}

.classic .chips li,
.classic .contact li {
  border-color: #bbbbbb;
}

.classic .btn {
  border: 1px solid #888888;
  border-radius: 6px;
  background: #ffffff;
  color: #1e1e1e;
}

.classic .btn:hover {
  color: #0b57d0;
}

.classic .site-footer {
  color: #555555;
}

.classic a:focus-visible,
.classic button:focus-visible {
  outline-color: #0b57d0;
}

.classic .command:focus-visible {
  color: #0b57d0;
}

.classic .skip-link {
  background: #1e1e1e;
  color: #ffffff;
}

/* Le CV complet est affiché directement, sans fenêtre à ouvrir */
html.classic .cv {
  display: block;
  position: static;
  max-width: 1024px;
  padding: 0 1rem 1.5rem;
  overflow: visible;
  background: none;
}

/* ===== Bandeau recruteur : l'essentiel en un coup d'œil ===== */
.pitch {
  margin-bottom: 1rem;
}

.pitch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
}

.pitch-actions .btn {
  color: var(--white);
  text-decoration: none;
}

.pitch-actions .pitch-cv {
  border-color: var(--yellow);
  background: var(--yellow);
  color: var(--black);
}

.pitch-actions .btn:hover {
  background: var(--white);
  color: var(--black);
}

.classic .pitch-actions .btn {
  color: #1e1e1e;
}

.classic .pitch-actions .pitch-cv {
  border-color: #0b57d0;
  background: #0b57d0;
  color: #ffffff;
}

.classic .stage {
  display: none;
}

/* Scène plus basse sur ordinateur, pour voir le menu sans défiler */
@media (min-width: 1000px) {
  .scene {
    aspect-ratio: 21 / 9;
  }

  #backdrop,
  #fx {
    object-fit: cover;
  }

  #monster {
    width: 20%;
  }

  .foe-hud {
    bottom: 57%;
  }
}

/* ===== Bouton « Mode classique » : bien visible, en haut à droite ===== */
.mode-bar {
  display: flex;
  justify-content: flex-end;
}

.mode-btn {
  margin-bottom: 0.75rem;
  padding: 0.5rem 1rem;
  border-color: var(--white);
  background: var(--yellow);
  color: var(--black);
}

.mode-btn:hover {
  background: var(--white);
  color: var(--black);
}

.classic .mode-btn,
.classic .mode-btn:hover {
  border-color: #0b57d0;
  background: #0b57d0;
  color: #ffffff;
}

.mode-btn:focus-visible,
.classic .mode-btn:focus-visible {
  outline-color: var(--link);
}

.classic .mode-btn:focus-visible {
  outline-color: #1e1e1e;
}

/* Écran large : sur la bande à droite du jeu */
@media (min-width: 1300px) {
  .mode-btn {
    position: fixed;
    top: 1rem;
    right: max(0.5rem, calc((100vw - 1024px) / 4 - 4rem));
    width: 7rem;
    margin: 0;
    padding: 0.6rem 0.4rem;
  }
}

/* En-tête visible uniquement à l'impression */
.print-only {
  display: none;
}

/* ===== Impression : CV standard sur une page A4, sans le style Dragon Quest ===== */
@media print {
  @page {
    size: A4;
    margin: 11mm 13mm;
  }

  html,
  body {
    background: #fff;
    color: #000;
  }

  body {
    font-family: "Segoe UI", Calibri, Arial, Helvetica, sans-serif;
    font-size: 9.5pt;
    line-height: 1.3;
    letter-spacing: normal;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    text-shadow: none !important;
  }

  .screen,
  .site-footer,
  .close-btn,
  .cv-actions,
  .win-title,
  #presentation .contact,
  dialog,
  .skip-link {
    display: none !important;
  }

  .js .cv,
  .js.cv-open .cv,
  .cv {
    display: block;
    position: static;
    max-width: none;
    padding: 0;
    background: none;
    overflow: visible;
  }

  /* Mise en page sur deux colonnes : parcours à gauche, atouts à droite */
  .cv-window,
  .js.cv-open .cv-window {
    display: grid;
    grid-template-columns: 1.75fr 1fr;
    grid-template-areas:
      "head head"
      "pres pres"
      "exp  form"
      "exp  comp"
      "proj lang"
      "proj hob";
    grid-template-rows: auto auto auto auto auto 1fr;
    column-gap: 9mm;
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: none;
    color: #000;
  }

  .print-only {
    display: block;
  }

  .print-header {
    grid-area: head;
    margin-bottom: 3.5mm;
    padding-bottom: 3mm;
    border-bottom: 2px solid #000;
  }

  .print-name {
    margin: 0;
    font-size: 22pt;
    font-weight: 700;
    line-height: 1.1;
  }

  .print-title {
    margin: 1mm 0 0;
    font-size: 12pt;
  }

  .print-contact {
    margin: 1.5mm 0 0;
    font-size: 9.5pt;
    color: #333;
  }

  #presentation { grid-area: pres; }
  #experiences { grid-area: exp; }
  #projets { grid-area: proj; }
  #projets .entry > p:last-child { display: none; }

  /* Sur papier, l'adresse des liens de projets s'affiche en clair */
  /* QR codes : sur papier, ils remplacent les liens cliquables */
  .qr {
    float: right;
    width: 16mm;
    height: 16mm;
    margin: 0 0 1mm 3mm;
  }

  .qr-site {
    width: 20mm;
    height: 20mm;
    margin: 0 0 0 4mm;
  }
  #formations { grid-area: form; }
  #competences { grid-area: comp; }
  #langues { grid-area: lang; }
  #hobbies { grid-area: hob; }

  .cv-window section,
  .cv-window section:first-of-type {
    margin: 0 0 3mm;
    break-inside: avoid;
  }

  #presentation p {
    margin: 0;
  }

  h2 {
    margin: 0 0 2mm;
    padding-bottom: 0.8mm;
    border-bottom: 1px solid #000;
    font-size: 9.5pt;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  h3 {
    font-size: 9.5pt;
    font-weight: 600;
  }

  strong {
    color: #000;
    font-weight: 600;
  }

  .meta {
    margin: 0 0 1mm;
    font-size: 9.5pt;
    font-style: italic;
    color: #444;
  }

  .entry {
    margin-bottom: 2mm;
    break-inside: avoid;
  }

  .entry ul,
  .cursor-list {
    margin: 0;
    padding-left: 4mm;
  }

  .entry li::before,
  .cursor-list li::before {
    content: "•";
    position: absolute;
    left: -3.5mm;
    opacity: 1;
  }

  .cursor-list li {
    padding: 0 0 0.8mm;
  }

  .chips {
    display: block;
    margin: 0;
  }

  .chips li {
    display: inline;
    padding: 0;
    border: 0;
  }

  .chips li:not(:last-child)::after {
    content: " · ";
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
