@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Pro:ital,wght@0,300;0,400;1,300&display=swap');

/* ─── Variables ───────────────────────────────────────────────── */
:root {
  --bg:          #06060f;
  --surface:     #0d0d22;
  --surface-2:   #12123a;
  --gold:        #c9a84c;
  --gold-light:  #e8cc7a;
  --silver:      #a8b8cc;
  --nebula:      #6b4de6;
  --nebula-soft: rgba(107, 77, 230, 0.18);
  --cyan:        #4dc9c9;
  --text:        #e4ddd0;
  --text-muted:  #7a8499;
}

/* ─── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Star Field ──────────────────────────────────────────────── */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ─── App Wrapper — centré verticalement ─────────────────────── */
.app-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
}

.timeline-section { width: 100%; }

/* ─── Timeline Wrapper (contenant positionné pour l'axis-line) ─ */
/*
 * L'axis-line EST ICI, pas dans .timeline-axis.
 * Quand .timeline-axis scrolle horizontalement, l'axis-line
 * reste fixe car elle est dans le parent non-scrollable.
 */
.timeline-wrapper { position: relative; }

/* ─── Axis Line — fixe, centrée verticalement ────────────────── */
.axis-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(90deg,
    transparent 0%,
    var(--nebula) 5%,
    var(--gold) 20%,
    var(--gold) 80%,
    var(--nebula) 95%,
    transparent 100%);
  box-shadow: 0 0 8px var(--gold), 0 0 24px rgba(201,168,76,.3);
  pointer-events: none;
  z-index: 1;
}

/* ─── Timeline Axis (scrollable) ──────────────────────────────── */
.timeline-axis {
  /*
   * Hauteur fixe = 2 × espace_carte.
   * Carte : image(140) + info(~105) = 245px.
   * Connecteur : tick-line(40) + tick-dot(10) = 50px.
   * Espace total au-dessus (ou en dessous) de l'axe = 245 + 15(gap) + 45 = 305px.
   * Hauteur totale = 305 × 2 = 610px.
   */
  height: 800px;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

.timeline-axis:active { cursor: grabbing; }
.timeline-axis::-webkit-scrollbar { height: 4px; }
.timeline-axis::-webkit-scrollbar-track { background: transparent; }
.timeline-axis::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 2px; }

/* ─── Cards Track ─────────────────────────────────────────────── */
.cards-track {
  display: flex;
  align-items: stretch; /* les cartes occupent toute la hauteur */
  height: 100%;
  min-width: max-content;
  padding: 0 60px;
}

/* ─── Person Card ─────────────────────────────────────────────── */
.person-card {
  --card-hue: 200;
  position: relative;
  width: 200px;
  height: 100%;         /* = 610px */
  flex-shrink: 0;
  margin: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: riseIn .7s cubic-bezier(.16,1,.3,1) both;
  z-index: 2;
}

/*
 * ABOVE : card-body en HAUT, connecteur entre card-body et l'axe.
 * justify-content: flex-start → card-body commence à y=0.
 * Card-body : 0 → ~245px.
 * Gap : ~15px.
 * Connecteur top: calc(50% - 45px) = 305 - 45 = 260px.
 * ↑ tick-line : 260 → 300px
 * ↑ tick-dot  : 300 → 310px  → centre du dot = 305px = 50% ✓
 */
.person-card.above {
  justify-content: flex-start;
}

/*
 * BELOW : connecteur entre l'axe et card-body en BAS.
 * justify-content: flex-end → card-body finit à y=610px.
 * Card-body : ~365 → 610px.
 * Gap : ~15px.
 * Connecteur top: calc(50% - 5px) = 305 - 5 = 300px.
 * ↑ tick-dot  : 300 → 310px  → centre du dot = 305px = 50% ✓
 * ↑ tick-line : 310 → 350px
 */
.person-card.below {
  justify-content: flex-end;
}

/* ─── Connector ───────────────────────────────────────────────── */
/*
 * Positionné en absolu pour placer le dot EXACTEMENT sur l'axe.
 *
 * .above  DOM : [tick-line(40px), tick-dot(10px)]  → ligne en haut, dot en bas
 *   top: calc(50% - 45px)
 *   → connecteur s'étend de (50%-45px) à (50%+5px)
 *   → centre tick-dot = 50% - 45px + 40px + 5px = 50% ✓
 *
 * .below  DOM : [tick-dot(10px), tick-line(40px)]  → dot en haut, ligne en bas
 *   top: calc(50% - 5px)
 *   → connecteur s'étend de (50%-5px) à (50%+45px)
 *   → centre tick-dot = 50% - 5px + 5px = 50% ✓
 */
.person-card .connector {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.person-card.above .connector { top: calc(50% - 45px); }
.person-card.below .connector { top: calc(50% - 5px);  }

.connector .tick-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(180deg, transparent, hsl(var(--card-hue), 75%, 60%));
}

.person-card.below .connector .tick-line {
  background: linear-gradient(180deg, hsl(var(--card-hue), 75%, 60%), transparent);
}

.connector .tick-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid hsl(var(--card-hue), 75%, 60%);
  box-shadow:
    0 0 8px  hsl(var(--card-hue), 75%, 60%),
    0 0 20px hsla(var(--card-hue), 75%, 60%, .4);
}

/* ─── Card Body ───────────────────────────────────────────────── */
.card-body {
  background: linear-gradient(145deg, rgba(18,18,58,.95) 0%, rgba(13,13,34,.98) 100%);
  border: 1px solid hsla(var(--card-hue), 70%, 55%, .25);
  border-radius: 12px;
  overflow: hidden;
  width: 100%;
  transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease;
  box-shadow:
    0 0 20px hsla(var(--card-hue), 70%, 55%, .12),
    0 0 60px rgba(107, 77, 230, .08);
}

.card-body:hover {
  transform: translateY(-6px);
  border-color: hsla(var(--card-hue), 70%, 60%, .6);
  box-shadow:
    0 0 30px hsla(var(--card-hue), 70%, 55%, .28),
    0 0 80px hsla(var(--card-hue), 70%, 55%, .12),
    0 20px 40px rgba(0,0,0,.5);
}

.card-body img {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
  filter: brightness(.9) saturate(.8);
  transition: filter .3s ease;
}

.card-body:hover img { filter: brightness(1.05) saturate(1); }

.card-info {
  padding: 14px 14px 16px;
  text-align: center;
  position: relative;
}

.card-info::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, hsl(var(--card-hue), 70%, 55%), transparent);
}

.card-name {
  font-family: 'Cinzel', serif;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--gold-light);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.card-title {
  font-size: .85rem;
  color: var(--silver);
  font-style: italic;
  font-weight: 300;
  margin-bottom: 10px;
  line-height: 1.3;
}

.card-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: hsla(var(--card-hue), 60%, 40%, .18);
  border: 1px solid hsla(var(--card-hue), 70%, 55%, .45);
  border-radius: 20px;
  padding: 4px 14px;
  font-family: 'Cinzel', serif;
  font-size: .75rem;
  letter-spacing: .08em;
  color: hsl(var(--card-hue), 80%, 75%);
}

.card-score::before {
  content: '✦';
  font-size: .6rem;
  color: hsl(var(--card-hue), 80%, 65%);
}

/* ─── Empty State ─────────────────────────────────────────────── */
.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: .1em;
}

.empty-state .big-star {
  font-size: 3rem;
  display: block;
  margin-bottom: 16px;
  opacity: .3;
}

/* ─── Secret Form Portal ──────────────────────────────────────── */
#dragon-portal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6,6,15,.85);
  backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  animation: fadeIn .4s ease both;
}

#dragon-portal.open { display: flex; }

.portal-card {
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
  border: 1px solid rgba(201,168,76,.3);
  border-radius: 20px;
  padding: 48px 40px;
  width: min(480px, 92vw);
  box-shadow: 0 0 60px rgba(107,77,230,.25), 0 0 120px rgba(201,168,76,.08);
  animation: portalOpen .5s cubic-bezier(.16,1,.3,1) both;
  position: relative;
}

.portal-card::before {
  content: '✦ PORTAIL CÉLESTE ✦';
  position: absolute;
  top: -14px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  padding: 4px 20px;
  font-family: 'Cinzel', serif;
  font-size: .6rem;
  letter-spacing: .25em;
  color: var(--gold);
  white-space: nowrap;
}

.portal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem; line-height: 1;
  transition: color .2s; padding: 4px;
}

.portal-close:hover { color: var(--gold); }

.portal-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: var(--gold-light);
  letter-spacing: .12em;
  margin-bottom: 28px;
  text-align: center;
}

.field-group { margin-bottom: 16px; }

.field-group label {
  display: block;
  font-size: .7rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: 'Cinzel', serif;
}

.field-group input {
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(201,168,76,.2);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.field-group input:focus {
  border-color: rgba(201,168,76,.6);
  box-shadow: 0 0 0 3px rgba(201,168,76,.08), 0 0 16px rgba(201,168,76,.1);
}

.field-group input[type="file"] {
  padding: 10px 16px; cursor: pointer;
  font-size: .85rem; color: var(--text-muted);
}

.field-group input[type="file"]::file-selector-button {
  background: var(--nebula-soft);
  border: 1px solid rgba(107,77,230,.4);
  border-radius: 6px;
  color: var(--silver);
  padding: 4px 12px; cursor: pointer;
  font-family: 'Cinzel', serif;
  font-size: .65rem; letter-spacing: .1em;
  margin-right: 12px; transition: background .2s;
}

.field-group input[type="file"]::file-selector-button:hover {
  background: rgba(107,77,230,.28);
}

.submit-btn {
  width: 100%; padding: 14px; margin-top: 8px;
  background: linear-gradient(135deg, rgba(201,168,76,.15), rgba(107,77,230,.2));
  border: 1px solid rgba(201,168,76,.4);
  border-radius: 8px; color: var(--gold-light);
  font-family: 'Cinzel', serif;
  font-size: .8rem; letter-spacing: .2em;
  text-transform: uppercase; cursor: pointer;
  transition: all .25s ease;
}

.submit-btn:hover {
  background: linear-gradient(135deg, rgba(201,168,76,.28), rgba(107,77,230,.32));
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,.2);
  transform: translateY(-1px);
}

.submit-btn:active { transform: translateY(0); }

/* ─── Animations ──────────────────────────────────────────────── */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(30px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes portalOpen {
  from { opacity: 0; transform: scale(.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE — frise verticale
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {

  .app-wrapper { padding: 30px 16px; justify-content: flex-start; }

  /* Axe vertical */
  .timeline-axis {
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
    cursor: default;
  }

  .axis-line {
    top: 0; bottom: 0;
    left: 50%; right: auto;
    width: 2px; height: 100%;
    transform: translateX(-50%);
    background: linear-gradient(180deg,
      transparent 0%, var(--nebula) 3%,
      var(--gold) 15%, var(--gold) 85%,
      var(--nebula) 97%, transparent 100%);
  }

  /* Track verticale */
  .cards-track {
    flex-direction: column;
    min-width: unset;
    width: 100%;
    height: auto;
    padding: 24px 0;
    align-items: stretch;
    gap: 20px;
  }

  /*
   * Cartes en mode ligne :
   * .above  DOM : [card-body][connector(tick-line, tick-dot)]
   *   → row : carte à gauche, dot à droite vers l'axe central
   * .below  DOM : [connector(tick-dot, tick-line)][card-body]
   *   → row : dot à gauche vers l'axe central, carte à droite
   */
  .person-card {
    width: 50%;
    height: auto;
    flex-direction: row;
    align-items: center;
    margin: 0;
  }

  .person-card.above {
    align-self: flex-start;
    justify-content: flex-start;
  }

  .person-card.below {
    align-self: flex-end;
    justify-content: flex-start;
  }

  /* Connector redevient dans le flux (non absolu) */
  .person-card .connector {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    width: 40px;
  }

  /* Tick-line horizontale */
  .connector .tick-line {
    height: 1px;
    width: 30px;
    flex: 1;
  }

  /* .above : transparent (carte) → couleur (axe, à droite) */
  .person-card.above .connector .tick-line {
    background: linear-gradient(90deg, transparent, hsl(var(--card-hue), 75%, 60%));
  }

  /* .below : couleur (axe, à gauche) → transparent (carte) */
  .person-card.below .connector .tick-line {
    background: linear-gradient(90deg, hsl(var(--card-hue), 75%, 60%), transparent);
  }

  .card-body { flex: 1; min-width: 0; }
  .card-body img { height: 170px; }
  .card-info { padding: 10px 10px 12px; }
  .portal-card { padding: 36px 24px; }
}