/* ════════════════════════════════════════════════════════════════════════════
   I Ching — Feuille de style
   Design méditatif, équilibré, palette terre/encre/or
   ════════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #0f0e0c;
  --bg-card:     #1a1815;
  --bg-card-alt: #221f1b;
  --ink:         #e8e0d0;
  --ink-dim:     #b3a892;
  --gold:        #c9a84c;
  --gold-bright: #e0c068;
  --jade:        #6b9b7a;
  --rouge:       #b85450;
  --border:      #3a352e;
  --shadow:      rgba(0,0,0,0.5);
  --serif:       'Cormorant Garamond', Georgia, 'Noto Serif SC', serif;
  --serif-cn:    'Noto Serif SC', serif;
  /* Police de lecture : forte hauteur d'x, glyphes Latin complets (ponctuation,
     accents FR/ES) → pour les longs textes (interprétation IA, jugements). */
  --serif-read:  Georgia, 'Times New Roman', 'Noto Serif SC', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; font-size: 17px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Texture de fond subtile */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(201,168,76,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(107,155,122,0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   VIEWS
   ═══════════════════════════════════════════════════════════════════════════ */

.view {
  display: none;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.view.active { display: flex; flex-direction: column; align-items: center; }

/* ═══════════════════════════════════════════════════════════════════════════
   HOME
   ═══════════════════════════════════════════════════════════════════════════ */

.home-content {
  text-align: center;
  padding: 2rem;
  max-width: 700px;
  margin: auto;
  animation: fadeIn 1.2s ease;
}

.trigrammes-banner {
  font-size: 2rem;
  letter-spacing: 0.5em;
  color: var(--gold);
  opacity: 0.6;
  margin-bottom: 2rem;
}

.title-main {
  font-family: var(--serif-cn);
  font-size: 5rem;
  font-weight: 300;
  color: var(--gold-bright);
  letter-spacing: 0.15em;
  margin-bottom: 0.3rem;
  text-shadow: 0 0 30px rgba(201,168,76,0.2);
}

.title-sub {
  font-size: 1.4rem;
  color: var(--ink-dim);
  font-style: italic;
  letter-spacing: 0.1em;
  margin-bottom: 2.5rem;
}

.title-quote {
  font-size: 1.1rem;
  color: var(--ink-dim);
  font-style: italic;
  line-height: 1.8;
  margin-bottom: 3rem;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOUTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn-primary, .btn-secondary, .btn-tertiary, .btn-back {
  font-family: var(--serif);
  font-size: 1.1rem;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.03em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  color: #1a1815;
  padding: 0.8rem 2.5rem;
  border-radius: 2px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(201,168,76,0.2);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(201,168,76,0.35);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  padding: 0.8rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: 2px;
}
.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.btn-tertiary {
  background: transparent;
  color: var(--ink-dim);
  padding: 0.6rem 1.5rem;
  font-size: 1rem;
}
.btn-tertiary:hover { color: var(--gold); }

.btn-back {
  background: transparent;
  color: var(--ink-dim);
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  align-self: flex-start;
  margin-bottom: 1rem;
}
.btn-back:hover { color: var(--gold); }

/* ═══════════════════════════════════════════════════════════════════════════
   TIRAGE
   ═══════════════════════════════════════════════════════════════════════════ */

.tirage-container, .consultation-container, .aide-container {
  width: 100%;
  max-width: 800px;
  padding: 2rem;
  margin: 0 auto;
}

.tirage-phase { display: none; animation: fadeIn 0.6s ease; }
.tirage-phase.active { display: block; }

.tirage-container h2, .consultation-container h2, .aide-container h2 {
  font-size: 2rem;
  color: var(--gold-bright);
  font-weight: 400;
  margin-bottom: 1rem;
  text-align: center;
}

.phase-intro {
  text-align: center;
  color: var(--ink-dim);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.phase-hint {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* Question */
.question-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin: 2rem 0;
}
.question-box label {
  display: block;
  color: var(--gold);
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
}
.question-box textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  padding: 1rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.3s;
}
.question-box textarea:focus { border-color: var(--gold); }

/* Zone de tirage */
.tirage-area {
  display: flex;
  gap: 3rem;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.hexagram-construction {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  min-width: 200px;
}

.ligne-construct {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  animation: slideIn 0.5s ease forwards;
}

.ligne-bar {
  height: 14px;
  border-radius: 2px;
  position: relative;
}

.ligne-bar.yang {
  background: var(--gold);
  width: 180px;
}
.ligne-bar.yin {
  background: var(--gold);
  width: 180px;
}
.ligne-bar.yin::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 20px;
  background: var(--bg-card);
  transform: translateX(-50%);
}

.ligne-bar.mutant {
  box-shadow: 0 0 10px rgba(184,84,80,0.6);
  border: 1px solid var(--rouge);
}
.ligne-bar.mutant::before {
  content: '⚡';
  position: absolute;
  right: -28px;
  top: -6px;
  font-size: 0.9rem;
  color: var(--rouge);
}

.ligne-num {
  color: var(--ink-dim);
  font-size: 0.8rem;
  width: 20px;
  text-align: right;
}

/* Pièces */
.tirage-interaction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.pieces-area {
  display: flex;
  gap: 1.5rem;
  perspective: 600px;
}

.piece {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  background: radial-gradient(circle at 35% 35%, var(--gold-bright), var(--gold), #8a7330);
  color: #1a1815;
  box-shadow: 0 4px 10px var(--shadow), inset 0 2px 4px rgba(255,255,255,0.2);
  transition: transform 0.1s;
}

.piece.flipping {
  animation: coinFlip 0.8s ease;
}

.piece.yin {
  background: radial-gradient(circle at 35% 35%, #8a7a68, #5a4d3e, #3a3025);
  color: var(--ink-dim);
}

@keyframes coinFlip {
  0%   { transform: rotateY(0deg) translateY(0); }
  50%  { transform: rotateY(720deg) translateY(-40px); }
  100% { transform: rotateY(1440deg) translateY(0); }
}

.lancer-result {
  min-height: 60px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.95rem;
}
.lancer-result .total { color: var(--gold); font-weight: 600; }
.lancer-result .desc { display: block; margin-top: 0.3rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   RÉSULTATS
   ═══════════════════════════════════════════════════════════════════════════ */

.question-reminder {
  text-align: center;
  color: var(--ink-dim);
  font-style: italic;
  margin-bottom: 2rem;
  font-size: 1.05rem;
}

.hexagram-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem;
  margin-bottom: 2rem;
}

.hexagram-result h3 {
  font-size: 1.6rem;
  color: var(--gold-bright);
  font-weight: 400;
  margin-bottom: 0.3rem;
}
.hexagram-result .hex-num {
  color: var(--ink-dim);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.hexagram-visual {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 1.5rem auto;
  width: fit-content;
}

.hex-line {
  height: 16px;
  border-radius: 2px;
  position: relative;
  display: flex;
  align-items: center;
}
.hex-line.yang { background: var(--gold); width: 160px; }
.hex-line.yin  { background: var(--gold); width: 160px; }
.hex-line.yin::after {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 20px;
  background: var(--bg-card);
  transform: translateX(-50%);
}
.hex-line.mutant {
  box-shadow: 0 0 8px rgba(184,84,80,0.5);
  border: 1px solid var(--rouge);
}
.hex-line.mutant::before {
  content: '⚡';
  position: absolute;
  right: -26px;
  top: -4px;
  font-size: 0.85rem;
  color: var(--rouge);
}

.hex-label {
  font-size: 0.75rem;
  color: var(--ink-dim);
  width: 20px;
  text-align: right;
  margin-right: 8px;
}

.hex-line-wrapper {
  display: flex;
  align-items: center;
}

.hexagram-text {
  margin-top: 1.5rem;
}
.hexagram-text .label {
  color: var(--jade);
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.3rem;
}
.hexagram-text .label.sub {
  color: var(--ink-dim);
  font-size: 0.85rem;
  font-weight: 500;
  font-style: italic;
  margin-top: 0.8rem;
}
.hexagram-text .text {
  color: var(--ink);
  font-family: var(--serif-read);
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
  line-height: 1.8;
}
.hexagram-text .text.commentary {
  color: var(--ink-dim);
  font-family: var(--serif-read);
  font-size: 1rem;
  line-height: 1.75;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.trigrammes-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.trigrammes-info span { display: flex; align-items: center; gap: 0.3rem; }

.mutation-arrow {
  text-align: center;
  font-size: 2rem;
  color: var(--rouge);
  margin: 1rem 0;
  animation: pulse 2s ease infinite;
}

.resultat-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONSULTATION GRID
   ═══════════════════════════════════════════════════════════════════════════ */

.hexagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.hex-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}
.hex-card:hover {
  border-color: var(--gold);
  background: var(--bg-card-alt);
  transform: translateY(-3px);
  box-shadow: 0 5px 15px var(--shadow);
}

.hex-card .mini-hex {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  margin-bottom: 0.5rem;
}
.mini-line {
  height: 5px;
  border-radius: 1px;
  position: relative;
}
.mini-line.yang { background: var(--gold); width: 40px; }
.mini-line.yin  { background: var(--gold); width: 40px; }
.mini-line.yin::after {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 6px;
  background: var(--bg-card);
  transform: translateX(-50%);
}

.hex-card .hex-card-num {
  color: var(--ink-dim);
  font-size: 0.75rem;
}
.hex-card .hex-card-name {
  color: var(--ink);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal.active { display: flex; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 2.5rem;
  max-width: 750px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: fadeIn 0.4s ease;
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1.5rem;
  background: none;
  border: none;
  color: var(--ink-dim);
  font-size: 1.5rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--gold); }

/* ═══════════════════════════════════════════════════════════════════════════
   AIDE
   ═══════════════════════════════════════════════════════════════════════════ */

.aide-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.aide-section h3 {
  color: var(--gold);
  font-weight: 500;
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}
.aide-section p { margin-bottom: 0.8rem; color: var(--ink); }
.aide-section ul { margin-left: 1.5rem; margin-bottom: 0.8rem; }
.aide-section li { margin-bottom: 0.3rem; }

.lignes-table {
  margin-top: 1rem;
}
.ligne-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}
.ligne-val {
  color: var(--gold);
  font-weight: 600;
  display: inline-block;
  width: 100px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 700px) {
  .title-main { font-size: 3.5rem; }
  .tirage-area { flex-direction: column; align-items: center; gap: 1.5rem; }
  .hexagram-construction { align-items: center; }
  .hexagram-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .modal-content { padding: 1.5rem; }
  .tirage-container, .consultation-container, .aide-container { padding: 1rem; }
  .lang-selector { top: 0.5rem; right: 0.5rem; }
  .lang-btn { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
  .traits-list { padding: 0.5rem; }
  .trait-item { flex-direction: column; gap: 0.2rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SÉLECTEUR DE LANGUE
   ═══════════════════════════════════════════════════════════════════════════ */

.lang-selector {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 200;
  display: flex;
  gap: 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 0.05em;
}

.lang-btn:hover { color: var(--gold); }
.lang-btn.active {
  background: var(--gold);
  color: #1a1815;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TRAITS (6 lignes de texte)
   ═══════════════════════════════════════════════════════════════════════════ */

.traits-list {
  margin-top: 0.5rem;
  margin-bottom: 1.2rem;
}

.trait-item {
  display: flex;
  gap: 0.8rem;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
  transition: background 0.2s;
}

.trait-item:last-child { border-bottom: none; }
.trait-item:hover { background: var(--bg-card-alt); }

.trait-item.mutant {
  background: rgba(184, 84, 80, 0.08);
  border-left: 3px solid var(--rouge);
  padding-left: 0.6rem;
}

.trait-num {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.trait-item.mutant .trait-num { color: var(--rouge); }

.trait-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.trait-mutant-badge {
  background: var(--rouge);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

.trait-text {
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0.4rem;
}

.trait-text.commentary {
  color: var(--ink-dim);
  font-size: 0.9rem;
  padding-left: 0.8rem;
  border-left: 2px solid var(--border);
}

.trait-text strong {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   INTERPRÉTATION IA
   ═══════════════════════════════════════════════════════════════════════════ */

.ia-section {
  margin: 2rem 0;
  text-align: center;
}

.btn-ia {
  background: linear-gradient(135deg, var(--jade), #4a7a5a);
  color: #f0e8d8;
  font-family: var(--serif);
  font-size: 1.1rem;
  border: none;
  padding: 0.8rem 2.5rem;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 15px rgba(107, 155, 122, 0.2);
}

.btn-ia:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(107, 155, 122, 0.35);
}

.ia-content {
  margin-top: 1.5rem;
  text-align: left;
}

.ia-loading {
  text-align: center;
  color: var(--ink-dim);
  font-style: italic;
  padding: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}

.ia-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ia-result {
  background: var(--bg-card);
  border: 1px solid var(--jade);
  border-radius: 4px;
  padding: 1.6rem 2rem;
  font-family: var(--serif-read);
  font-size: 1.18rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
  color: var(--ink);
  max-width: 65ch;
  margin: 0 auto;
  animation: fadeIn 0.6s ease;
}

.ia-result p { margin-bottom: 1rem; }
.ia-result p:last-child { margin-bottom: 0; }
.ia-result strong { color: var(--gold-bright); font-weight: 700; }
.ia-result h3, .ia-result h4 {
  font-family: var(--serif);
  color: var(--gold-bright);
  line-height: 1.3;
  margin: 1.3rem 0 0.5rem;
}
.ia-result h3 { font-size: 1.45rem; }
.ia-result h4 { font-size: 1.2rem; }

.ia-error {
  background: rgba(184, 84, 80, 0.1);
  border: 1px solid var(--rouge);
  border-radius: 4px;
  padding: 1.5rem;
  text-align: center;
  color: var(--ink);
}

.ia-error small {
  color: var(--ink-dim);
  display: block;
  margin: 0.5rem 0 1rem;
}
