/* =============================================================================
   Horizon Play — Design System partagé
   -----------------------------------------------------------------------------
   Direction artistique "Observatoire Horizon" : fond navy profond, electric
   blue #03A1EF comme signature lumineuse, coral #E46F71 en signal, typo
   éditoriale (Fraunces) combinée à du system sans et du JetBrains Mono.
   Restraint maximal — l'electric blue ne brille que pour ce qui compte.

   ADN emprunté au dactylo (voir ../../dactylo/index.html) qui définit
   déjà les couleurs Horizon dans ses :root vars. Les noms sont différents
   ici (--horizon-*) mais les valeurs sont identiques, c'est volontaire.
============================================================================= */

:root {
  /* ----- Palette Horizon (alignée 1:1 sur le dactylo) ----- */
  --horizon-bg:           #05091F;
  --horizon-bg-card:      #0d1229;
  --horizon-bg-card-lift: #131a38;
  --horizon-bg-hover:     #161c3a;
  --horizon-bg-overlay:   #090e26;
  --horizon-border:       #1f2747;
  --horizon-border-strong:#2a3457;

  --horizon-accent:       #03A1EF;  /* primaire Horizon — signature lumineuse */
  --horizon-accent-bright:#38b8f3;
  --horizon-accent-dim:   #0477b0;
  --horizon-accent-glow:  rgba(3, 161, 239, 0.22);

  --horizon-warm:         #E46F71;  /* secondaire — signal, erreur, rang 2 */
  --horizon-warm-dim:     #b7545e;
  --horizon-warm-glow:    rgba(228, 111, 113, 0.2);

  --horizon-soft:         #7488B0;  /* tertiaire — textes discrets, rang 3 */
  --horizon-soft-dim:     #52648c;

  --horizon-success:      #86EFAC;

  --horizon-text:         #d4d4d4;
  --horizon-text-bright:  #fafafa;
  --horizon-text-dim:     #666c84;
  --horizon-text-whisper: #3a4566;

  /* ----- Couleurs fonctionnelles du quiz (réalignées sur la palette Horizon)
     Les 4 boutons participant DOIVENT rester maximalement distincts parce que
     les joueurs matchent visuellement la couleur de leur bouton mobile avec
     celle de l'écran présentateur sous pression de temps. On conserve donc
     4 teintes contrastées mais dans un registre Horizon : coral chaud,
     electric blue primaire, ambre chaud, menthe fraîche.
  */
  --choice-0:      #E46F71;  /* coral Horizon */
  --choice-0-dark: #a1434d;
  --choice-1:      #03A1EF;  /* electric blue Horizon */
  --choice-1-dark: #0477b0;
  --choice-2:      #F5B93A;  /* ambre */
  --choice-2-dark: #b88621;
  --choice-3:      #6FE4A8;  /* menthe */
  --choice-3-dark: #4ba47a;

  /* ----- Typographie ----- */
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                  'Helvetica Neue', sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, Monaco, Consolas, monospace;

  /* ----- Rayons ----- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --radius-xl: 28px;

  /* ----- Ombres & glows ----- */
  --shadow-card: 0 24px 60px -22px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-lift: 0 42px 80px -28px rgba(0, 0, 0, 0.75), 0 2px 12px rgba(0, 0, 0, 0.5);
  --glow-accent: 0 0 32px rgba(3, 161, 239, 0.32);
  --glow-warm:   0 0 32px rgba(228, 111, 113, 0.28);
}

/* =============================================================================
   Reset minimal — on ne touche pas plus que nécessaire.
============================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--horizon-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

html { font-size: 16px; }
html, body { min-height: 100vh; }

body {
  font-family: var(--font-sans);
  background: var(--horizon-bg);
  color: var(--horizon-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01" on, "cv11" on;
  line-height: 1.5;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
}
input, textarea, select {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* =============================================================================
   Starfield atmosphérique — pur CSS, zéro asset.
   -----------------------------------------------------------------------------
   Un champ d'étoiles stylisé via radial-gradients superposés. Deux couches :
   - couche 1 : une dizaine de points lumineux à des positions fixes
   - couche 2 (::after) : deux halos diffus (electric + coral) pour la profondeur
   L'ensemble respire doucement via animation d'opacité (14 s cycle).
============================================================================= */
.horizon-starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1px 1px at 17% 12%, rgba(255, 255, 255, 0.65) 50%, transparent 100%),
    radial-gradient(1px 1px at 63% 8%,  rgba(255, 255, 255, 0.42) 50%, transparent 100%),
    radial-gradient(1px 1px at 84% 24%, rgba(255, 255, 255, 0.55) 50%, transparent 100%),
    radial-gradient(1.5px 1.5px at 41% 32%, rgba(3, 161, 239, 0.45) 50%, transparent 100%),
    radial-gradient(1px 1px at 8% 45%,  rgba(255, 255, 255, 0.32) 50%, transparent 100%),
    radial-gradient(1px 1px at 92% 58%, rgba(255, 255, 255, 0.48) 50%, transparent 100%),
    radial-gradient(1px 1px at 27% 72%, rgba(255, 255, 255, 0.38) 50%, transparent 100%),
    radial-gradient(1.5px 1.5px at 68% 80%, rgba(228, 111, 113, 0.40) 50%, transparent 100%),
    radial-gradient(1px 1px at 52% 91%, rgba(255, 255, 255, 0.52) 50%, transparent 100%),
    radial-gradient(1px 1px at 14% 96%, rgba(255, 255, 255, 0.28) 50%, transparent 100%),
    radial-gradient(1px 1px at 38% 55%, rgba(255, 255, 255, 0.36) 50%, transparent 100%),
    radial-gradient(1px 1px at 76% 42%, rgba(255, 255, 255, 0.44) 50%, transparent 100%);
  opacity: 0.9;
  animation: horizon-starfield-breathe 14s ease-in-out infinite;
}
.horizon-starfield::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 45% at 20% 12%, rgba(3, 161, 239, 0.14), transparent 70%),
    radial-gradient(ellipse 55% 50% at 88% 78%, rgba(228, 111, 113, 0.08), transparent 72%),
    radial-gradient(ellipse 100% 60% at 50% 120%, rgba(3, 161, 239, 0.06), transparent 70%);
  pointer-events: none;
}
@keyframes horizon-starfield-breathe {
  0%, 100% { opacity: 0.72; }
  50%      { opacity: 1;    }
}

/* Body wrapper — les pages qui veulent le starfield ajoutent .horizon-body
   sur leur <body> et mettent un <div class="horizon-starfield"> en enfant. */
.horizon-body {
  position: relative;
  min-height: 100vh;
}
.horizon-body > *:not(.horizon-starfield) {
  position: relative;
  z-index: 1;
}

/* =============================================================================
   Typographie partagée
============================================================================= */
.horizon-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--horizon-soft);
}

.horizon-display {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--horizon-text-bright);
  font-optical-sizing: auto;
}
.horizon-display--xl { font-size: clamp(3rem, 7vw, 5.75rem); }
.horizon-display--lg { font-size: clamp(2rem, 5vw, 3.5rem); }
.horizon-display--md { font-size: clamp(1.4rem, 3vw, 2.1rem); }

.horizon-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* =============================================================================
   Boutons primaires partagés
============================================================================= */
.horizon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.05rem 2rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: transform 0.16s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.22s ease,
              background 0.2s ease,
              color 0.2s ease;
}
.horizon-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  transform: none !important;
}

.horizon-btn--primary {
  background: var(--horizon-accent);
  color: #001523;
  box-shadow: 0 0 0 1px var(--horizon-accent-dim), var(--glow-accent);
}
.horizon-btn--primary:hover:not(:disabled) {
  background: var(--horizon-accent-bright);
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--horizon-accent-bright),
              0 0 44px rgba(3, 161, 239, 0.42);
}
.horizon-btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

/* End-of-session actions (nouvelle session + retour tableau de bord) */
.end-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}
.end-back {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--horizon-soft);
  text-decoration: none;
  padding: 0.5rem 1rem;
  transition: color 0.2s;
}
.end-back:hover {
  color: var(--horizon-text-bright);
}
.intro-back {
  margin-top: 2rem;
}
/* Bouton "Rejoindre une nouvelle session" (participant) */
.go-rejoin-btn {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.8rem 1.8rem;
  background: var(--horizon-accent);
  color: var(--horizon-navy, #05091F);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.go-rejoin-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(3, 161, 239, 0.4);
}

/* Bouton "Tester seul" (intro des outils) */
.horizon-btn--solo {
  background: transparent;
  color: var(--horizon-soft);
  border: 1px dashed var(--horizon-border);
  font-size: 0.82rem;
}
.horizon-btn--solo:hover:not(:disabled) {
  color: var(--horizon-text-bright);
  border-color: var(--horizon-soft);
  background: var(--horizon-bg-hover);
}

.horizon-btn--ghost {
  background: transparent;
  color: var(--horizon-text);
  border-color: var(--horizon-border);
}
.horizon-btn--ghost:hover:not(:disabled) {
  background: var(--horizon-bg-hover);
  border-color: var(--horizon-soft);
  color: var(--horizon-text-bright);
}

/* =============================================================================
   Fields partagés
============================================================================= */
.horizon-field {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.horizon-field__label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--horizon-soft);
}
.horizon-field__input {
  padding: 1.05rem 1.15rem;
  background: var(--horizon-bg-card);
  border: 1px solid var(--horizon-border);
  border-radius: var(--radius-md);
  color: var(--horizon-text-bright);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.horizon-field__input::placeholder {
  color: var(--horizon-text-whisper);
}
.horizon-field__input:hover {
  border-color: var(--horizon-border-strong);
}
.horizon-field__input:focus {
  border-color: var(--horizon-accent);
  background: var(--horizon-bg-overlay);
  box-shadow: 0 0 0 4px rgba(3, 161, 239, 0.12), 0 0 24px rgba(3, 161, 239, 0.14);
}

/* =============================================================================
   Shapes (triangle/losange/cercle/carré) — utilisés dans le quiz pour
   différencier les 4 choix aux yeux des participants en complément
   de la couleur (accessibility + fallback color-blind).
============================================================================= */
.horizon-shape {
  display: inline-block;
  width: 1em;
  height: 1em;
  background: currentColor;
}
.horizon-shape--0 { clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }     /* triangle */
.horizon-shape--1 { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); } /* losange */
.horizon-shape--2 { border-radius: 50%; }                                  /* cercle */
.horizon-shape--3 { border-radius: 14%; }                                  /* carré */

/* =============================================================================
   Animations partagées
============================================================================= */
@keyframes horizon-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes horizon-pop-in {
  0%   { opacity: 0; transform: scale(0.85); }
  70%  { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes horizon-pulse-accent {
  0%   { box-shadow: 0 0 0 0 rgba(3, 161, 239, 0.55); }
  70%  { box-shadow: 0 0 0 18px rgba(3, 161, 239, 0);  }
  100% { box-shadow: 0 0 0 0 rgba(3, 161, 239, 0);     }
}
@keyframes horizon-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1);   }
}

.horizon-fade-up { animation: horizon-fade-up 0.55s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
.horizon-pop-in  { animation: horizon-pop-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.horizon-pulse   { animation: horizon-pulse-accent 2.2s ease-out infinite; }

/* Staggered reveal — à appliquer sur les enfants d'un conteneur */
.horizon-stagger > * {
  animation: horizon-fade-up 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.horizon-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.horizon-stagger > *:nth-child(2) { animation-delay: 0.15s; }
.horizon-stagger > *:nth-child(3) { animation-delay: 0.25s; }
.horizon-stagger > *:nth-child(4) { animation-delay: 0.35s; }
.horizon-stagger > *:nth-child(5) { animation-delay: 0.45s; }
.horizon-stagger > *:nth-child(6) { animation-delay: 0.55s; }

/* =============================================================================
   Dots animés — indicateur d'attente
============================================================================= */
.horizon-dots {
  display: inline-flex;
  gap: 8px;
}
.horizon-dots span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--horizon-accent);
  animation: horizon-dot 1.25s ease-in-out infinite;
}
.horizon-dots span:nth-child(2) { animation-delay: 0.18s; }
.horizon-dots span:nth-child(3) { animation-delay: 0.36s; }

/* =============================================================================
   Utilitaires
============================================================================= */
.horizon-hidden { display: none !important; }
.horizon-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Toast d'erreur / notification */
.horizon-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--horizon-bg-card);
  color: var(--horizon-text-bright);
  padding: 0.9rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--horizon-warm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-card), var(--glow-warm);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  pointer-events: none;
}
.horizon-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Scrollbars minimalistes */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--horizon-border-strong) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--horizon-border-strong);
  border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--horizon-soft-dim);
}

/* =============================================================================
   Quiz compatibility aliases
   -----------------------------------------------------------------------------
   L'HTML/JS du quiz utilise des classes historiques (.hidden, .fade-in,
   .pop-in, .toast, .shape, .choice-N) qui datent d'avant le design system.
   Plutôt que de patcher tous les HTML/JS, on définit ici des alias qui
   pointent vers les primitives Horizon. Ça évite aussi toute duplication
   entre presenter.css et play.css pour les utilitaires partagés.
============================================================================= */

.hidden { display: none !important; }

.fade-in { animation: horizon-fade-up 0.55s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
.pop-in  { animation: horizon-pop-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.shape {
  display: inline-block;
  width: 1em;
  height: 1em;
  background: currentColor;
}
.shape-0 { clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }
.shape-1 { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.shape-2 { border-radius: 50%; }
.shape-3 { border-radius: 14%; }

/* Les 4 couleurs fonctionnelles du quiz, utilisées telles quelles par l'HTML
   existant (classes `.choice-0` à `.choice-3`). Le shadow inset est un rappel
   matériel discret qui suggère un relief sans tomber dans le kahoot. */
.choice-0 {
  background: var(--choice-0);
  color: #fff;
  box-shadow: inset 0 -4px 0 var(--choice-0-dark);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.choice-1 {
  background: var(--choice-1);
  color: #fff;
  box-shadow: inset 0 -4px 0 var(--choice-1-dark);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.choice-2 {
  background: var(--choice-2);
  color: #fff;
  box-shadow: inset 0 -4px 0 var(--choice-2-dark);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.choice-3 {
  background: var(--choice-3);
  color: #fff;
  box-shadow: inset 0 -4px 0 var(--choice-3-dark);
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Toast legacy (pour l'HTML quiz qui utilise .toast.show) */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--horizon-bg-card);
  color: var(--horizon-text-bright);
  padding: 0.9rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--horizon-warm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-card), var(--glow-warm);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Accessibilité — respecte reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .horizon-starfield { animation: none; }
}
