/* ==========================================================================
   Fjord Kingdoms — Feuille de style principale
   Thème sombre charbon, typographie dorée, variables CSS + dark/light mode.
   ========================================================================== */

:root, [data-theme="dark"] {
  --color-bg:        #0e0b07;
  --color-surface:   #161109;
  --color-surface-2: #1e1710;
  --color-surface-3: #261f14;
  --color-border:    oklch(0.7 0.03 60 / 0.18);
  --color-text:      #d4c9a8;
  --color-text-muted:#8a7d5c;
  --color-primary:   #c8a96a;
  --color-primary-h: #e2c890;
  --color-accent:    #b5652d;
  --color-accent-h:  #d0793a;
  --color-gold:      #f0d090;
  --color-red:       #c04040;
  --color-red-h:     #e06060;
  --color-success:   #6ab040;
  --color-shadow:    oklch(0 0 0 / 0.5);
  --shadow-sm:  0 1px 2px var(--color-shadow);
  --shadow-md:  0 4px 16px var(--color-shadow);
  --shadow-lg:  0 12px 40px var(--color-shadow);
  --radius:     6px;
  --font-title: 'Cinzel', serif;
  --font-body:  'Crimson Text', serif;
}

[data-theme="light"] {
  --color-bg:        #f5f0e8;
  --color-surface:   #ede6d6;
  --color-surface-2: #e3dac6;
  --color-surface-3: #d8ccb2;
  --color-text:      #2a1f0e;
  --color-text-muted:#6b5a3a;
  --color-border:    oklch(0.4 0.03 60 / 0.25);
}

/* -------------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }

/* Sécurité responsive : aucune image ne déborde de son conteneur (mobile). */
img { max-width: 100%; height: auto; }

html, body {
  margin: 0;
  padding: 0;
  /* Filet de sécurité mobile : empêche tout élément large de décaler la page.
     « clip » (et non « hidden ») pour ne pas casser la navbar sticky. */
  max-width: 100%;
  overflow-x: clip;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-title);
  color: var(--color-primary);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover { color: var(--color-primary-h); }

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* --------------------------------------------------------------------- Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2, .card h3 { margin-top: 0; }

.grid {
  display: grid;
  gap: 1.25rem;
}
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ------------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-title);
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { background: var(--color-surface-3); border-color: var(--color-primary); }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--color-primary);
  color: #1a1305;
  border-color: var(--color-primary);
  font-weight: 600;
}
.btn--primary:hover { background: var(--color-primary-h); color: #1a1305; }

.btn--danger { background: var(--color-red); color: #fff; border-color: var(--color-red); }
.btn--danger:hover { background: var(--color-red-h); color: #fff; }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--color-surface-2); }

.btn--accent {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  font-weight: 600;
}
.btn--accent:hover { background: var(--color-accent-h); color: #fff; border-color: var(--color-accent-h); }

.btn--sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn--lg { padding: 0.7rem 1.5rem; font-size: 1.05rem; }
.btn--block { width: 100%; }

/* --------------------------------------------------------------------- Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.form-inline { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }

/* Honeypot : champ caché aux humains, piège à bots. */
.hp-field { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ---------------------------------------------------------------------- Flash */
.flash {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  border: 1px solid var(--color-border);
  animation: flash-in 0.3s ease;
}
.flash--success { background: oklch(0.5 0.12 140 / 0.2); border-color: var(--color-success); }
.flash--error   { background: oklch(0.5 0.15 25 / 0.2); border-color: var(--color-red); }
.flash--warning { background: oklch(0.6 0.13 80 / 0.2); border-color: var(--color-gold); }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------- Progress */
.progress-bar {
  position: relative;
  background: var(--color-surface-3);
  border-radius: 99px;
  height: 16px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}
.progress-bar__fill {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.4s ease;
}
.progress-bar__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--color-text);
}

/* --------------------------------------------------------------------- Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
table.data th, table.data td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}
table.data th {
  font-family: var(--font-title);
  color: var(--color-primary);
  font-size: 0.85rem;
}
table.data tr:hover td { background: var(--color-surface-2); }

/* Conteneur à défilement horizontal pour les tableaux larges sur petit écran. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* --------------------------------------------------------------------- Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.topbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar__brand {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-gold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.topbar__logo {
  height: 36px;
  width: auto;
  display: block;
  border-radius: 6px;
}
.topbar__nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.topbar__nav a { font-family: var(--font-title); font-size: 0.9rem; }

/* Compte à rebours de la prochaine saison : masqué sur desktop (visible au
   survol via l'info-bulle), affiché en clair sur mobile (survol peu pratique). */
.season-next { display: none; color: var(--color-text-muted); font-size: 0.85em; }

/* HUD (pastilles d'information) */
.hud {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 0.2rem 0.65rem;
  font-size: 0.85rem;
}
.hud-stat--gold { color: var(--color-gold); }
.icon-gold {
  height: 1em;
  width: auto;
  vertical-align: -0.18em;
  margin-right: 0.2em;
}
.hud-stat--gold .icon-gold { vertical-align: -0.22em; }
.hud-stat--danger { color: var(--color-red-h); }
.hud-stat--ok { color: var(--color-success); }

/* Bandeau « repos à l'église » (dans le flux, sous la navbar) */
.rest-banner {
  background: #fdf6d3;
  color: #5a4a12;
  border-bottom: 1px solid #e4d68a;
  padding: 0.6rem 1rem;
  text-align: center;
  font-size: 0.92rem;
}
.rest-banner a {
  color: #5a4a12;
  font-weight: 600;
  text-decoration: underline;
  margin-left: 0.4rem;
  white-space: nowrap;
}

/* --------------------------------------------------------------------- Footer */
.game-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.game-footer a { margin: 0 0.5rem; }

/* ----------------------------------------------------------------- Utilities */
.text-muted { color: var(--color-text-muted); }
.text-gold  { color: var(--color-gold); }
.text-danger{ color: var(--color-red-h); }
.text-success { color: var(--color-success); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.75rem;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
}

/* Boutons de filtre du marché (bascule par ressource, filtrage AJAX). */
.market-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.market-filters__label {
  color: var(--color-primary);
  font-family: var(--font-title);
  font-size: 0.85rem;
  margin-right: 0.25rem;
}
.market-filter-btn {
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--color-surface-3);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.market-filter-btn:hover { border-color: var(--color-primary); color: var(--color-primary-h); }
.market-filter-btn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #1a1409;
  font-weight: 600;
}
#market-listings.is-loading,
#users-table.is-loading { opacity: 0.5; transition: opacity 0.15s; }
.badge--danger { background: oklch(0.5 0.15 25 / 0.3); border-color: var(--color-red); }
.badge--ok { background: oklch(0.5 0.12 140 / 0.25); border-color: var(--color-success); }
.badge--warn { background: oklch(0.6 0.13 75 / 0.25); border-color: var(--color-primary); }

.changelog-list { list-style: none; padding-left: 0; margin: 0; }
.changelog-list li { padding: 0.35rem 0; display: flex; gap: 0.5rem; align-items: baseline; }
.changelog-list .badge { flex: 0 0 auto; }

.hero {
  text-align: center;
  padding: 3rem 1rem;
}
.hero h1 { font-size: 2.6rem; }
.hero p { font-size: 1.2rem; color: var(--color-text-muted); max-width: 640px; margin: 0 auto 1.5rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

.guide-cta { background: var(--color-surface-2); border-color: var(--color-accent); }
.guide-cta h2 { margin-top: 0; }
.guide-cta .btn { margin-top: 0.5rem; }

.auth-wrap { max-width: 420px; margin: 2rem auto; }

.home-showcase {
  margin: 2rem auto;
  max-width: 960px;
}
.home-showcase img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius, 8px);
  border: 1px solid var(--color-border);
}

.seo-intro {
  max-width: 820px;
  margin: 2.5rem auto 0;
  text-align: center;
}
.seo-intro h2 { font-size: 1.6rem; margin-bottom: 1rem; }
.seo-intro p {
  color: var(--color-text-muted);
  text-align: left;
  margin: 0 0 1rem;
}

/* ------------------------------------------------------------ Combat / équip. */
.combat-log {
  white-space: pre-line;
  line-height: 1.6;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.equip-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}
.equip-slot {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}
.equip-slot__label { font-size: 0.8rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.equip-slot__item { margin: 0.3rem 0; }
.equip-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.equip-list__item:last-child { border-bottom: none; }

/* ------------------------------------------------------------ Forge (accordéon) */
.forge-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-2);
  margin-bottom: 0.6rem;
}
.forge-group > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 1rem;
  font-family: var(--font-title);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: var(--radius);
}
.forge-group > summary::-webkit-details-marker { display: none; }
.forge-group > summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--color-text-muted);
  transition: transform 0.2s;
}
.forge-group[open] > summary::after { transform: rotate(180deg); }
.forge-group[open] > summary { border-bottom: 1px solid var(--color-border); border-radius: var(--radius) var(--radius) 0 0; }
.forge-group > summary:hover { background: var(--color-surface-3); }
.forge-count {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 0.05rem 0.5rem;
}
.forge-group__body { padding: 0.25rem 1rem 0.5rem; }
.forge-item__info { flex: 1; min-width: 0; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hud { width: 100%; margin-left: 0; }

  /* Navbar allégée : on masque les liens secondaires (tous accessibles depuis
     la carte du village) pour gagner de la hauteur. Restent : Village,
     Personnage, Boutique, Guide, Déconnexion. */
  .topbar__nav .nav-secondary { display: none; }

  /* Compte à rebours de saison visible en clair sur mobile (pas de survol). */
  .season-next { display: inline; }

  /* Tableaux « empilés » : chaque ligne devient une carte lisible sur mobile,
     ce qui garde le bouton d'action (ex. « Attaquer ») toujours visible. */
  table.data--stack thead { display: none; }
  table.data--stack, table.data--stack tbody, table.data--stack tr, table.data--stack td { display: block; width: 100%; }
  table.data--stack tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.7rem;
  }
  table.data--stack td {
    border: none;
    padding: 0.3rem 0;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    text-align: right;
  }
  table.data--stack td::before {
    content: attr(data-label);
    font-family: var(--font-title);
    color: var(--color-primary);
    font-size: 0.85rem;
    text-align: left;
  }
  table.data--stack td.data__action { display: block; text-align: center; padding-top: 0.5rem; }
  table.data--stack td.data__action::before { content: none; }
  table.data--stack td.data__action .btn { width: 100%; }
}

/* ---- Spécialisations (Voie & talents) ---- */
.spec-currencies {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-around;
  text-align: center;
}
.spec-currency { display: flex; flex-direction: column; align-items: center; min-width: 90px; }
.spec-currency__icon { font-size: 1.6rem; line-height: 1; }
.spec-currency__value { font-size: 1.4rem; font-weight: 700; }
.spec-currency__label { font-size: 0.8rem; color: var(--color-primary); }

.spec-banner { border-left: 4px solid var(--color-primary); }

.spec-path-card { display: flex; flex-direction: column; }
.spec-path-card form, .spec-path-card > .btn { margin-top: auto; }

.spec-talents { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.spec-talent {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--color-surface-2);
}
.spec-talent--owned  { border-color: var(--color-success); background: oklch(0.5 0.12 140 / 0.10); }
.spec-talent--available { border-color: var(--color-primary); }
.spec-talent--future { opacity: 0.7; }
.spec-talent--locked { opacity: 0.85; }
.spec-talent--major  { border-width: 2px; border-color: var(--color-accent); }
.spec-talent__head { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.35rem; }
.spec-talent__desc { font-size: 0.85rem; margin: 0.25rem 0; }
.spec-talent__meta { font-size: 0.8rem; margin: 0.35rem 0 0; }
