/* ====================================================================
   Foundry Forge — design system « La Forge des Mondes »
   ==================================================================== */

@font-face {
  font-family: "Cinzel";
  src: url("/public/fonts/cinzel.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("/public/fonts/alegreya.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: "Alegreya";
  src: url("/public/fonts/alegreya-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #0b0a12;
  --bg-2: #151021;
  --panel: rgba(26, 21, 38, 0.82);
  --panel-solid: #1a1526;
  --line: rgba(201, 163, 92, 0.22);
  --line-strong: rgba(201, 163, 92, 0.5);
  --ink: #e9ddc4;
  --muted: #a3937a;
  --faint: #6f6553;
  --gold: #c9a35c;
  --gold-bright: #eecf90;
  --ember: #e07a3f;
  --ember-glow: rgba(224, 122, 63, 0.35);
  --danger: #c25148;
  --ok: #8fae66;
  --display: "Cinzel", "Palatino Linotype", Palatino, serif;
  --body: "Alegreya", Georgia, "Times New Roman", serif;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

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

html { color-scheme: dark; }

body {
  min-height: 100vh;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(98, 60, 168, 0.16), transparent 60%),
    radial-gradient(1000px 600px at 8% 110%, rgba(224, 122, 63, 0.13), transparent 55%),
    radial-gradient(1600px 900px at 50% 50%, var(--bg-2), var(--bg) 75%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* Grain discret par-dessus le fond */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
  z-index: 1;
}

#embers {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

main, header.forge-nav { position: relative; z-index: 3; }

::selection { background: rgba(201, 163, 92, 0.35); }

a { color: var(--gold-bright); text-decoration: none; }
a:hover { text-shadow: 0 0 12px var(--ember-glow); }

/* ------------------------------------------------------------------ */
/* Typographie                                                         */
/* ------------------------------------------------------------------ */

h1, h2, h3, .brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
}

h1.page-title {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  background: linear-gradient(180deg, #f4dfae 20%, #c9a35c 65%, #8f6f35);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.subtitle {
  color: var(--muted);
  font-style: italic;
  margin-top: 0.35rem;
}

.eyebrow {
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
}

/* Séparateur orné */
.ornament {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--gold);
  margin: 1.1rem 0;
}
.ornament::before, .ornament::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong));
}
.ornament::after {
  background: linear-gradient(90deg, var(--line-strong), transparent);
}
.ornament span { font-size: 0.7rem; transform: rotate(45deg); }

/* ------------------------------------------------------------------ */
/* Navigation                                                          */
/* ------------------------------------------------------------------ */

header.forge-nav {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.9rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 12, 24, 0.92), rgba(15, 12, 24, 0.65));
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  color: var(--gold-bright);
}
.brand svg { width: 26px; height: 26px; filter: drop-shadow(0 0 6px var(--ember-glow)); }

.forge-nav nav {
  display: flex;
  gap: 1.2rem;
  margin-left: auto;
  align-items: center;
}
.forge-nav nav a {
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.4rem 0.2rem;
  border-bottom: 1px solid transparent;
  transition: color 0.25s, border-color 0.25s;
}
.forge-nav nav a:hover, .forge-nav nav a.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold);
  text-shadow: none;
}

.nav-user {
  color: var(--faint);
  font-style: italic;
  font-size: 0.92rem;
}

/* ------------------------------------------------------------------ */
/* Structure de page                                                   */
/* ------------------------------------------------------------------ */

main.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem);
}

main.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.6rem;
}

/* ------------------------------------------------------------------ */
/* Panneaux « arcane »                                                 */
/* ------------------------------------------------------------------ */

.arcane {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  padding: clamp(1.5rem, 4vw, 2.4rem);
}

/* Coins dorés */
.arcane::before, .arcane::after,
.arcane > .corners::before, .arcane > .corners::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--gold);
  border-style: solid;
  opacity: 0.8;
}
.arcane::before { top: 8px; left: 8px; border-width: 1px 0 0 1px; }
.arcane::after { top: 8px; right: 8px; border-width: 1px 1px 0 0; }
.arcane > .corners::before { bottom: 8px; left: 8px; border-width: 0 0 1px 1px; }
.arcane > .corners::after { bottom: 8px; right: 8px; border-width: 0 1px 1px 0; }

.auth-card {
  width: min(430px, 92vw);
  text-align: center;
}
.auth-card .brand { justify-content: center; font-size: 1.5rem; margin-bottom: 0.2rem; }
.auth-card .brand svg { width: 40px; height: 40px; }

.panel-wide { width: min(680px, 94vw); }

/* ------------------------------------------------------------------ */
/* Formulaires                                                         */
/* ------------------------------------------------------------------ */

form .field { text-align: left; margin-bottom: 1.05rem; }

label {
  display: block;
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  padding: 0.68rem 0.9rem;
  font-family: var(--body);
  font-size: 1rem;
  color: var(--ink);
  background: rgba(10, 8, 18, 0.65);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 163, 92, 0.15), 0 0 18px rgba(224, 122, 63, 0.12);
}
textarea { resize: vertical; min-height: 90px; }
select { appearance: none; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  pointer-events: none;
}

.hint { font-size: 0.85rem; color: var(--faint); margin-top: 0.35rem; }

.form-error {
  display: none;
  margin: 0.9rem 0 0;
  padding: 0.65rem 0.9rem;
  border: 1px solid rgba(194, 81, 72, 0.5);
  border-radius: 8px;
  background: rgba(194, 81, 72, 0.12);
  color: #e8a49d;
  font-size: 0.95rem;
}
.form-error.visible { display: block; animation: shake 0.4s; }

@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* ------------------------------------------------------------------ */
/* Boutons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #1a1207;
  background: linear-gradient(180deg, #ecd9a8, #c9a35c 55%, #a37f3c);
  border: 1px solid #8f6f35;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.25s, filter 0.2s;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(201, 163, 92, 0.35), 0 0 30px rgba(224, 122, 63, 0.18);
  filter: brightness(1.05);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

/* reflet qui balaie le bouton */
.btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
}
.btn:hover::after { left: 130%; }

.btn-ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { box-shadow: 0 0 18px rgba(201, 163, 92, 0.2); color: var(--gold-bright); }

.btn-danger {
  background: linear-gradient(180deg, #d98078, #b34a44 60%, #8c342f);
  border-color: #7c2e29;
  color: #fff1ec;
}

.btn-block { width: 100%; }

.btn-icon {
  padding: 0.45rem 0.7rem;
  font-size: 0.9rem;
  letter-spacing: 0;
}

/* ------------------------------------------------------------------ */
/* Grille de mondes                                                    */
/* ------------------------------------------------------------------ */

.world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.4rem;
}

.world-card {
  position: relative;
  min-height: 240px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  isolation: isolate;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3), box-shadow 0.3s, border-color 0.3s;
}
.world-card:hover {
  transform: translateY(-6px);
  border-color: var(--line-strong);
  box-shadow: 0 22px 45px rgba(0, 0, 0, 0.6), 0 0 35px rgba(224, 122, 63, 0.12);
}

.world-card .art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
  transition: transform 0.6s ease;
  z-index: -2;
}
.world-card:hover .art { transform: scale(1.09); }

.world-card .veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 10, 18, 0.1) 20%, rgba(11, 10, 18, 0.88) 78%);
  z-index: -1;
}

.world-card .card-body { padding: 1.1rem 1.2rem 1.2rem; }

.world-card h3 {
  font-size: 1.22rem;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.world-tags {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.45rem 0 0.8rem;
}

.tag {
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(11, 10, 18, 0.55);
}
.tag.shared { color: #b9a4e0; border-color: rgba(152, 116, 220, 0.4); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}
.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4d4358;
}
.status.running { color: var(--ember); }
.status.running .dot {
  background: var(--ember);
  box-shadow: 0 0 8px var(--ember);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 16px var(--ember), 0 0 4px var(--ember); opacity: 0.7; }
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.card-actions .btn { flex: 1; }

/* Carte « forger un monde » */
.world-card.create-card {
  border-style: dashed;
  border-color: var(--line);
  background: rgba(20, 16, 32, 0.4);
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  min-height: 240px;
}
.world-card.create-card:hover { color: var(--gold-bright); border-color: var(--gold); }
.create-card .rune {
  font-size: 2.6rem;
  font-family: var(--display);
  color: var(--gold);
  text-shadow: 0 0 18px var(--ember-glow);
  transition: transform 0.4s;
}
.world-card.create-card:hover .rune { transform: rotate(90deg) scale(1.15); }

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
  font-style: italic;
}

/* ------------------------------------------------------------------ */
/* Listes (partages, admin)                                            */
/* ------------------------------------------------------------------ */

.roster { list-style: none; display: grid; gap: 0.6rem; }

.roster li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 1rem;
  background: rgba(11, 9, 20, 0.5);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.roster li:hover { border-color: var(--line-strong); box-shadow: 0 0 16px rgba(201, 163, 92, 0.08); }

.roster .who { flex: 1; min-width: 0; }
.roster .who strong { display: block; color: var(--ink); }
.roster .who small { color: var(--faint); font-style: italic; }

.sigil {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 700;
  color: var(--gold-bright);
  background: radial-gradient(circle at 35% 30%, #3a2d55, #221a35);
  border: 1px solid var(--line-strong);
  text-transform: uppercase;
}

.pill {
  font-family: var(--display);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid;
}
.pill.pending { color: #e0b45c; border-color: rgba(224, 180, 92, 0.5); }
.pill.active { color: var(--ok); border-color: rgba(143, 174, 102, 0.5); }
.pill.disabled { color: var(--danger); border-color: rgba(194, 81, 72, 0.5); }
.pill.admin { color: #b9a4e0; border-color: rgba(152, 116, 220, 0.5); }

.section { margin-top: 2.2rem; }
.section h2 { font-size: 1.15rem; margin-bottom: 0.9rem; }

/* Chronique (audit) */
.chronicle { list-style: none; border-left: 1px solid var(--line-strong); padding-left: 1.2rem; display: grid; gap: 0.7rem; }
.chronicle li { position: relative; font-size: 0.92rem; color: var(--muted); }
.chronicle li::before {
  content: "";
  position: absolute;
  left: -1.45rem;
  top: 0.45em;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--gold);
  box-shadow: 0 0 8px var(--ember-glow);
}
.chronicle time { color: var(--faint); font-size: 0.8rem; display: block; }

/* Cases à cocher de partage */
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.5rem; }
.share-option { position: relative; }
.share-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.share-option .share-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(11, 9, 20, 0.5);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  font-size: 0.95rem;
  color: var(--muted);
}
.share-option input:checked + .share-label {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(201, 163, 92, 0.1);
  box-shadow: 0 0 14px rgba(201, 163, 92, 0.15);
}
.share-option input:focus-visible + .share-label { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ------------------------------------------------------------------ */
/* Attente / rune tournante                                            */
/* ------------------------------------------------------------------ */

.rune-circle {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 1.6rem auto;
}
.rune-circle .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed var(--gold);
  animation: spin 14s linear infinite;
  opacity: 0.7;
}
.rune-circle .ring.inner {
  inset: 16px;
  border-style: solid;
  border-color: rgba(201, 163, 92, 0.35);
  animation: spin 9s linear infinite reverse;
}
.rune-circle .core {
  position: absolute;
  inset: 38px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--ember) 0%, rgba(224, 122, 63, 0.15) 65%, transparent 75%);
  animation: breathe 2.6s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe {
  50% { transform: scale(1.28); filter: brightness(1.25); }
}

/* ------------------------------------------------------------------ */
/* Apparitions                                                         */
/* ------------------------------------------------------------------ */

.reveal { opacity: 0; transform: translateY(18px); animation: rise 0.7s ease forwards; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

body.leaving main { animation: sink 0.28s ease forwards; }
@keyframes sink { to { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ */
/* Divers                                                              */
/* ------------------------------------------------------------------ */

.error-hero { text-align: center; }
.error-hero .code {
  font-family: var(--display);
  font-size: 5rem;
  background: linear-gradient(180deg, #f4dfae, #8f6f35);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 1rem;
}
.back-link:hover { color: var(--gold-bright); }

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

@media (max-width: 640px) {
  .forge-nav { flex-wrap: wrap; gap: 0.6rem; }
  .forge-nav nav { margin-left: 0; width: 100%; justify-content: space-between; gap: 0.5rem; }
  .nav-user { display: none; }
}
