/* ============================================================
   DyStories — PUBLIC UI (landing + auth + game master)
   Fond blanc + accents colorés + cartes propres
   ============================================================ */

:root{
  --bg: #ffffff;
  --text: #0f172a;         /* slate-900 */
  --muted: #64748b;        /* slate-500 */
  --border: rgba(15, 23, 42, 0.10);
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.08);
  --shadow-2: 0 16px 45px rgba(2, 6, 23, 0.10);

  /* accent “joyeux” mais sobre */
  --accent-1: #22c55e; /* green */
  --accent-2: #3b82f6; /* blue */
  --accent-3: #a855f7; /* purple */
  --accent-4: #f97316; /* orange */
  --accent-grad: linear-gradient(90deg, var(--accent-2), var(--accent-3), var(--accent-4), var(--accent-1));
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Layout */
.container{
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* Top bar */
.site-header{
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header-inner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand img{
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(2,6,23,0.08);
}

.brand .brand-text{
  display:flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand .brand-title{
  font-weight: 900;
  letter-spacing: -0.02em;
}
.brand .brand-subtitle{
  font-size: 0.88rem;
  color: var(--muted);
}

.header-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Buttons */
.btn{
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 18px rgba(2,6,23,0.06);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.btn:hover{
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active{ transform: translateY(0px); }

.btn-primary{
  border: 0;
  color: #fff;
  background: var(--accent-grad);
}

.btn-ghost{
  background: rgba(255,255,255,0.6);
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255,255,255,0.7);
}

/* Hero */
.hero{
  padding: 22px 0 10px;
}

.hero-grid{
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}

.card{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.hero h1{
  margin: 10px 0 8px;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.hero p{
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.kpi-row{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.kpi{
  flex: 1 1 160px;
  background: rgba(2, 6, 23, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}
.kpi .kpi-title{ color: var(--muted); font-size: .85rem; }
.kpi .kpi-value{ font-weight: 900; font-size: 1.1rem; margin-top: 2px; }

/* Worlds slider */
.section-title{
  display:flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 10px;
}
.section-title h2{
  margin: 0;
  font-size: 1.25rem;
}
.section-title .hint{ color: var(--muted); font-size: .95rem; }

.slider-wrap{
  position: relative;
}

.worlds-slider{
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 6px 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.worlds-slider::-webkit-scrollbar{ height: 10px; }
.worlds-slider::-webkit-scrollbar-thumb{
  background: rgba(2,6,23,0.18);
  border-radius: 999px;
}
.worlds-slider::-webkit-scrollbar-track{
  background: rgba(2,6,23,0.05);
  border-radius: 999px;
}

.world-card{
  flex: 0 0 320px;
  scroll-snap-align: start;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  display:flex;
  flex-direction: column;
}

.world-cover{
  height: 160px;
  background: #f8fafc;
  position: relative;
}

.world-cover img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display:block;
  background:
    linear-gradient(135deg,
      rgba(59,130,246,.15),
      rgba(168,85,247,.15),
      rgba(249,115,22,.15)
    );
}

.world-cover::after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(180deg, rgba(255,255,255,0) 35%, rgba(255,255,255,0.96));
}

.world-body{
  padding: 12px 14px 14px;
  margin-top: -34px; /* remonte sur le cover */
}

.world-name{
  font-weight: 900;
  margin: 0;
  font-size: 1.05rem;
}
.world-meta{
  margin-top: 6px;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.35;
}
.world-meta strong{ color: var(--text); }
.world-pitch{
  margin-top: 10px;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.45;
  min-height: 2.8em; /* stabilité */
}

/* Slider arrows (optionnel) */
.slider-arrow{
  position:absolute;
  top: 72px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
  cursor: pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  user-select:none;
}

.slider-arrow:hover{ filter: brightness(1.02); }
.slider-arrow.left{ left: -6px; }
.slider-arrow.right{ right: -6px; }

@media (max-width: 980px){
  .hero-grid{ grid-template-columns: 1fr; }
  .slider-arrow{ display:none; }
  .world-card{ flex-basis: 86vw; }
}

/* Auth forms */
.form{
  display:flex;
  flex-direction: column;
  gap: 10px;
}
label{ font-weight: 700; }
input, select, textarea{
  margin-top: 6px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
.small{ color: var(--muted); font-size: .92rem; }

.notice{
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(2,6,23,0.03);
}
.notice.ok{ border-color: rgba(34,197,94,0.25); background: rgba(34,197,94,0.08); }
.notice.err{ border-color: rgba(239,68,68,0.25); background: rgba(239,68,68,0.08); }

/* ==========================
   GAME MASTER PAGE
   ========================== */

body.gm-page{
  background: radial-gradient(1200px 600px at 10% 0%, rgba(59,130,246,.18), transparent 60%),
              radial-gradient(900px 500px at 90% 10%, rgba(168,85,247,.16), transparent 60%),
              radial-gradient(900px 600px at 50% 100%, rgba(249,115,22,.10), transparent 55%),
              #060814;
  color: #e5e7eb;
}

.gm-header{
  position: sticky;
  top: 0;
  z-index: 10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 14px 18px;
  background: rgba(6,8,20,.65);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.gm-brand{ display:flex; align-items:center; gap:12px; }
.gm-logo{ height:42px; width:auto; background:#fff; border-radius:10px; padding:6px; }
.gm-title{ font-weight:800; letter-spacing:.3px; font-size:1.05rem; }
.gm-subtitle{ color: rgba(229,231,235,.75); font-size:.9rem; }

.gm-nav{ display:flex; gap:10px; align-items:center; }
.gm-link{
  color:#c7d2fe;
  text-decoration:none;
  padding:8px 10px;
  border-radius:10px;
}
.gm-link:hover{ background: rgba(255,255,255,.06); }
.gm-logout{ color:#fecaca; }

.gm-wrap{ max-width: 1180px; margin: 0 auto; padding: 18px; }

.gm-flash{
  border:1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.gm-ok{ background: rgba(16,185,129,.12); }
.gm-err{ background: rgba(239,68,68,.14); }

.gm-grid{
  display:grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 16px;
}
@media (max-width: 980px){
  .gm-grid{ grid-template-columns: 1fr; }
}

.gm-card{
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.10);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}

.gm-h2{ margin: 0 0 8px; font-size:1.2rem; }
.gm-h3{ margin: 12px 0 8px; font-size:1rem; }
.gm-muted{ color: rgba(229,231,235,.72); margin: 0 0 10px; }

.gm-catalog{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
@media (max-width: 540px){
  .gm-catalog{ grid-template-columns: 1fr; }
}

.gm-world{
  display:flex;
  gap:10px;
  text-align:left;
  width:100%;
  cursor:pointer;
  border-radius: 16px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(3,7,18,.35);
  padding: 10px;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.gm-world:hover{
  transform: translateY(-1px);
  border-color: rgba(167,139,250,.35);
  background: rgba(3,7,18,.55);
}

.gm-world-cover{
  flex: 0 0 74px;
  height: 54px;
  border-radius: 12px;
  overflow:hidden;
  background: linear-gradient(135deg, rgba(59,130,246,.15), rgba(168,85,247,.12), rgba(249,115,22,.10));
}
.gm-world-cover img{ width:100%; height:100%; object-fit:cover; display:block; }

.gm-world-title{ font-weight:800; font-size: .98rem; }
.gm-world-meta{ font-size:.85rem; color: rgba(229,231,235,.7); }

.gm-form{ margin-top: 10px; }

.gm-steps{
  list-style:none;
  padding: 0;
  margin: 10px 0 0;
  border: 1px dashed rgba(255,255,255,.16);
  border-radius: 16px;
  min-height: 56px;
}
.gm-steps.empty::before{
  content:"Ajoute des mondes depuis le catalogue";
  display:block;
  padding: 14px;
  color: rgba(229,231,235,.55);
}

.gm-step{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.gm-step:last-child{ border-bottom:none; }
.gm-handle{ cursor:grab; opacity:.8; }
.gm-step-label{ flex:1; font-weight:600; }
.gm-x{
  border:none;
  background: transparent;
  color: rgba(254,202,202,.95);
  font-size: 1.35rem;
  cursor:pointer;
}

.gm-actions{ display:flex; gap:10px; margin-top: 12px; flex-wrap:wrap; }

.gm-btn{
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color:#e5e7eb;
  padding: 10px 12px;
  border-radius: 999px;
  text-decoration:none;
  cursor:pointer;
  font-weight:700;
}
.gm-btn:hover{ background: rgba(255,255,255,.10); }
.gm-primary{
  background: linear-gradient(135deg, rgba(59,130,246,.35), rgba(168,85,247,.28));
  border-color: rgba(167,139,250,.35);
}
.gm-danger{
  background: rgba(239,68,68,.18);
  border-color: rgba(239,68,68,.35);
}
.gm-small{ padding: 8px 10px; font-size: .9rem; }

.gm-list{ display:flex; flex-direction:column; gap:10px; margin-top: 8px; }
.gm-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(3,7,18,.35);
}
.gm-row-title{ font-weight:800; }
.gm-row-actions{ display:flex; gap:8px; align-items:center; }
.gm-row-actions form{ margin:0; }
