/* ═══════════════════════════════════════════════════════════════
   style.css — PYTHIA CTF
   Design basé sur modele/index.html
   Palette : fond #0d0618, violet #bd93f9, rose #ff79c6
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────── */
:root {
  --bg:         #0d0618;
  --violet:     #bd93f9;
  --violet-dim: rgba(189, 147, 249, 0.15);
  --violet-faint: rgba(189, 147, 249, 0.08);
  --rose:       #ff79c6;
  --rose-dim:   rgba(255, 121, 198, 0.15);
  --rose-faint: rgba(255, 121, 198, 0.08);
  --green:      #50fa7b;
  --text:       #e2d9f3;
  --text-muted: #6e5f8a;
  --text-dim:   #4a3d5c;
  --border:     rgba(189, 147, 249, 0.2);
  --border-rose: rgba(255, 121, 198, 0.3);
  --gold:       #c9a84c;   /* conservé pour titres serif PYTHIA */
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 14px;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(189, 147, 249, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 121, 198, 0.07) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 6, 24, 0.8);
  backdrop-filter: blur(10px);
}

/* PYTHIA — violet, lettres espacées */
.site-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--violet);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

/* Badge niveau — pilule violette */
.header-level {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--violet-faint);
  border: 1px solid var(--border);
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 0.1em;
}

.header-level span {
  color: var(--violet);
}

/* ── Main ────────────────────────────────────────────────────── */
.site-main {
  flex: 1;
  display: flex;
  align-items: stretch;
}

/* ── Footer ──────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 10px 28px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════
   PAGE D'ACCUEIL — intro.html
   ══════════════════════════════════════════════════════════════ */

.intro-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  padding: 4rem 2rem;
  text-align: center;
}

.intro-title {
  font-family: Georgia, serif;
  font-size: 5rem;
  color: var(--violet);
  letter-spacing: 0.3em;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 60px rgba(189, 147, 249, 0.25);
}

.intro-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 500px;
  line-height: 2;
  margin-bottom: 3rem;
  letter-spacing: 0.05em;
}

.btn-start {
  background: var(--rose-faint);
  border: 1px solid var(--border-rose);
  color: var(--rose);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 12px 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-start:hover:not(:disabled) {
  background: rgba(255, 121, 198, 0.25);
  box-shadow: 0 0 20px rgba(255, 121, 198, 0.15);
}

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

.intro-error {
  margin-top: 1.2rem;
  color: #ff5555;
  font-size: 0.85rem;
}

/* ══════════════════════════════════════════════════════════════
   PAGE DE LOGIN — login.html
   ══════════════════════════════════════════════════════════════ */

/* Formulaire centré sous le titre */
.login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 300px;
}

/* Conteneur de l'input — même style que chat-input-area */
.login-input-wrapper {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input-wrapper:focus-within {
  border-color: var(--border-rose);
  box-shadow: 0 0 20px rgba(255, 121, 198, 0.06);
}

/* Champ de saisie du code */
.login-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  text-align: center;
  letter-spacing: 0.25em;
  caret-color: var(--rose);
}

.login-input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* ══════════════════════════════════════════════════════════════
   PAGE DE JEU — chat.html
   ══════════════════════════════════════════════════════════════ */

.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
  gap: 0;
}

/* ── Carte du personnage (30%) ─────────────────────────────── */
.character-card {
  width: 30%;
  min-width: 220px;
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: opacity 0.5s ease;
}

.character-card.card-fade {
  opacity: 0;
}

.character-level {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.character-name {
  font-family: Georgia, serif;
  font-size: 1.4rem;
  color: var(--violet);
  line-height: 1.3;
}

.character-era {
  font-size: 12px;
  color: var(--rose);
  font-style: italic;
}

.character-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
  margin-top: 0.3rem;
}

/* ── Zone de chat (70%) ────────────────────────────────────── */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px;
  gap: 12px;
}

/* Historique des messages */
.chat-history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

.chat-history::-webkit-scrollbar       { width: 4px; }
.chat-history::-webkit-scrollbar-track { background: transparent; }
.chat-history::-webkit-scrollbar-thumb {
  background: rgba(189, 147, 249, 0.3);
  border-radius: 4px;
}

/* ── Bulles de message ──────────────────────────────────────── */
.bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Bulle joueur — rose, droite */
.bubble-user {
  align-self: flex-end;
  background: var(--rose-dim);
  border: 1px solid var(--border-rose);
  color: #ffc8e8;
}

.bubble-user .bubble-label {
  display: none; /* le préfixe > suffit */
}

.bubble-user .bubble-content::before {
  content: '> ';
  color: var(--rose);
  font-weight: 700;
}

/* Bulle oracle — violet, gauche */
.bubble-oracle {
  align-self: flex-start;
  background: var(--violet-faint);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 0 20px rgba(189, 147, 249, 0.05);
}

.bubble-oracle .bubble-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--violet);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

/* Indicateur de chargement */
.bubble-loading {
  color: var(--text-muted);
  font-style: italic;
  border-style: dashed !important;
}

.bubble-content {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Message système */
.system-message {
  align-self: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 11px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--violet-faint);
  border-radius: 20px;
  text-align: center;
  max-width: 80%;
  letter-spacing: 0.05em;
}

/* ── Zone de saisie ─────────────────────────────────────────── */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-area:focus-within {
  border-color: var(--border-rose);
  box-shadow: 0 0 20px rgba(255, 121, 198, 0.05);
}

/* Symbole › avant l'input */
.chat-input-area::before {
  content: '›';
  color: var(--rose);
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  caret-color: var(--rose);
}

.chat-input::placeholder { color: var(--text-dim); }
.chat-input:disabled      { opacity: 0.4; }

.btn-send {
  background: var(--rose-dim);
  border: 1px solid var(--border-rose);
  color: var(--rose);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-send:hover:not(:disabled) {
  background: rgba(255, 121, 198, 0.25);
  box-shadow: 0 0 16px rgba(255, 121, 198, 0.15);
}

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

/* ── Avatar carte personnage ────────────────────────────────── */
.character-avatar-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 1.2rem;
}

.character-avatar {
  width: 144px;
  height: 144px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  box-shadow: 0 0 24px rgba(189,147,249,0.15);
}

.character-avatar.character-avatar-error {
  background: rgba(189,147,249,0.1);
}

/* ── Avatar oracle ──────────────────────────────────────────── */
.bubble-oracle-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bubble-avatar,
.bubble-avatar-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--border);
  object-fit: cover;
}

.bubble-avatar-placeholder {
  background: rgba(189, 147, 249, 0.1);
}

/* ── Flag inline ────────────────────────────────────────────── */
.bubble-flag {
  color: var(--green);
  font-size: 13px;
  margin-top: 10px;
  letter-spacing: 0.04em;
}

/* ── Bouton Continuer ───────────────────────────────────────── */
.btn-continue {
  margin-top: 10px;
  align-self: flex-start;
  background: var(--rose-faint);
  border: 1px solid var(--border-rose);
  color: var(--rose);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-continue:hover:not(:disabled) {
  background: rgba(255, 121, 198, 0.25);
  box-shadow: 0 0 16px rgba(255, 121, 198, 0.15);
}

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

/* ── Overlay de briefing ────────────────────────────────────── */
#briefing-overlay {
  position: fixed;
  inset: 0;
  background: #0d0618;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 3rem 2rem;
  text-align: center;
  transition: opacity 0.4s ease;
}

#briefing-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.briefing-text {
  color: var(--text);
  font-size: 13px;
  line-height: 2.2;
  max-width: 520px;
  white-space: pre-line;
  margin-bottom: 2.5rem;
}

.btn-briefing {
  background: var(--violet-faint);
  border: 1px solid var(--border);
  color: var(--violet);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-briefing:hover {
  background: rgba(189, 147, 249, 0.2);
  box-shadow: 0 0 20px rgba(189, 147, 249, 0.15);
}

/* ── Écran de victoire ──────────────────────────────────────── */
#victory-screen {
  position: fixed;
  inset: 0;
  background: #0d0618;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 3rem 2rem;
  text-align: center;
}

#victory-screen.visible {
  display: flex;
}

.victory-title {
  font-family: Georgia, serif;
  font-size: 3rem;
  color: var(--violet);
  letter-spacing: 0.3em;
  margin-bottom: 2.5rem;
  text-shadow: 0 0 60px rgba(189, 147, 249, 0.3);
}

.victory-text {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 2.2;
  max-width: 460px;
  white-space: pre-line;
  margin-bottom: 1.5rem;
}

.victory-flag {
  color: var(--green);
  font-size: 14px;
  letter-spacing: 0.05em;
}

/* ══════════════════════════════════════════════════════════════
   THÈMES PAR NIVEAU — variables redéfinies sur body
   Tout élément utilisant --violet, --violet-dim, --violet-faint,
   --border bascule automatiquement.
   ══════════════════════════════════════════════════════════════ */

/* ── Niveau 2 — Jaune / Alice ───────────────────────────────── */
body[data-level="2"] {
  --violet:       #e5c100;
  --violet-dim:   rgba(229, 193, 0, 0.15);
  --violet-faint: rgba(229, 193, 0, 0.08);
  --border:       rgba(229, 193, 0, 0.2);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(229, 193, 0, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 121, 198, 0.07) 0%, transparent 60%);
}

/* ── Niveau 3 — Vert / Trinity ──────────────────────────────── */
body[data-level="3"] {
  --violet:       #50fa7b;
  --violet-dim:   rgba(80, 250, 123, 0.15);
  --violet-faint: rgba(80, 250, 123, 0.08);
  --border:       rgba(80, 250, 123, 0.2);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(80, 250, 123, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 121, 198, 0.07) 0%, transparent 60%);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — laptop 13"
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .chat-layout {
    flex-direction: column;
  }

  .character-card {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 1rem 1.5rem;
    gap: 0.5rem;
  }

  .character-desc { display: none; }

  .intro-title { font-size: 3rem; }
}
