/* =========================================================
   Feuilleton — Styles de base
   Reset, typographie, structure, composants.
   ========================================================= */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; /* Empêche le débordement horizontal */
}

img, picture, svg {
  max-width: 100%;
  display: block;
}

/* ---------- Typographie ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 0.6em;
  color: var(--ink);
}

h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.2rem); }
h3 { font-size: clamp(1.2rem, 2.2vw, 1.6rem); }
h4 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

/* ---------- Liens ---------- */
a {
  color: var(--bordeaux);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--bordeaux-dark); }

/* ---------- Boutons (base commune) ---------- */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background: var(--bordeaux);
  color: var(--cream);
}
.btn-primary:hover {
  background: var(--bordeaux-dark);
  color: var(--cream);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn-ghost:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.btn-full {
  width: 100%;
  margin-top: var(--space-2);
}

/* Bouton spécifique à la barre de navigation */
.btn-nav {
  background: var(--bordeaux);
  color: var(--cream) !important;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-family: var(--font-ui);
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn-nav:hover {
  background: var(--bordeaux-dark);
  color: var(--cream) !important;
}

.btn-nav--ghost {
  background: transparent;
  color: var(--ink) !important;
  border: 1px solid var(--border);
}
.btn-nav--ghost:hover {
  border-color: var(--bordeaux);
  color: var(--bordeaux) !important;
  background: transparent;
}

/* ---------- Conteneurs ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ---------- Filet or ---------- */
.gold-rule {
  display: block;
  width: 48px;
  height: 2px;
  background: var(--gold);
  border: 0;
  margin: var(--space-4) 0;
}

/* =========================================================
   En-tête et Navigation (Header)
   ========================================================= */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  gap: var(--space-4);
}

.site-header__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.site-header__brand:hover { color: var(--bordeaux); }

.site-header__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}
.site-header__nav a {
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.site-header__nav a:hover { color: var(--bordeaux); }

.nav-user {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-left: var(--space-2);
}

/* Boutons toggle (thème + hamburger) */
.theme-toggle, .nav-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.theme-toggle:hover, .nav-toggle:hover { border-color: var(--ink-soft); }

.nav-toggle {
  display: none; /* Caché sur ordinateur */
}

/* =========================================================
   Pied de page (Footer)
   ========================================================= */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-8) 0;
  margin-top: var(--space-16);
}
.site-footer__text {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.9rem;
  margin: 0;
}

/* =========================================================
   Page d'accueil (Hero & Rayons)
   ========================================================= */
.hero {
  padding: var(--space-16) 0;
  text-align: center;
}
.hero__eyebrow {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-4);
}
.hero__title { margin-bottom: var(--space-4); }
.hero__lead {
  color: var(--ink-soft);
  font-size: 1.1rem;
  max-width: 50ch;
  margin: var(--space-4) auto var(--space-6);
}
.hero__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.hero .gold-rule { margin-left: auto; margin-right: auto; }

.shelf {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--border);
}
.shelf__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.shelf__head h2 { margin: 0; }
.shelf__head .gold-rule { margin: 0; }
.shelf__empty {
  color: var(--ink-faint);
  font-style: italic;
  padding: var(--space-8) var(--space-4);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  margin: 0;
  font-size: 0.95rem;
}

/* =========================================================
   Grille d'histoires (Story Grid)
   ========================================================= */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-4);
}

.story-card {
  display: block;
  color: var(--ink);
  transition: transform 0.2s ease;
}
.story-card:hover {
  transform: translateY(-4px);
  color: var(--ink);
}

.story-card__cover-wrapper {
  aspect-ratio: 2 / 3;
  margin-bottom: var(--space-3);
  overflow: hidden;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  background: var(--cream-deep);
}
.story-card__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.story-card:hover .story-card__cover { transform: scale(1.05); }

.story-card__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream-deep);
  border: 1px solid var(--border);
}
.story-card__cover--placeholder span {
  font-family: var(--font-display);
  font-size: 3rem;
  color: var(--gold);
  opacity: 0.5;
}
.story-card__title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story-card__author {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
}

/* =========================================================
   Fiche Histoire (Detail)
   ========================================================= */
.story-detail { padding: var(--space-8) 0; }
.story-detail__header {
  display: flex;
  gap: var(--space-8);
  margin-bottom: var(--space-12);
  align-items: flex-start;
}
.story-detail__cover-wrapper {
  width: 240px;
  flex-shrink: 0;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-cover);
  background: var(--cream-deep);
}
.story-detail__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story-detail__meta {
  flex-grow: 1;
  padding-top: var(--space-4);
}
.story-detail__category {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 600;
  display: block;
  margin-bottom: var(--space-2);
}
.story-detail__title {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: var(--space-2);
}
.story-detail__author {
  font-family: var(--font-read);
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.1rem;
  margin-bottom: var(--space-4);
}
.story-detail__stats {
  display: flex;
  gap: var(--space-2);
  font-size: 0.9rem;
  color: var(--ink-faint);
  margin-bottom: var(--space-6);
}
.story-detail__summary {
  max-width: var(--measure);
  margin-bottom: var(--space-12);
  font-family: var(--font-read);
  font-size: 1.1rem;
}
.story-detail__chapters { max-width: var(--container-narrow); }

/* Liste des chapitres */
.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
}
.chapter-list__item { border-bottom: 1px solid var(--border); }
.chapter-list__link {
  display: flex;
  align-items: center;
  padding: var(--space-4) 0;
  color: var(--ink);
  transition: background 0.15s ease, padding 0.15s ease;
}
.chapter-list__link:hover {
  background: var(--cream-deep);
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}
.chapter-list__number {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-faint);
  width: 60px;
  flex-shrink: 0;
}
.chapter-list__title {
  flex-grow: 1;
  font-family: var(--font-display);
  font-size: 1.1rem;
}
.chapter-list__badge {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
}
.chapter-list__badge--free { background: rgba(63, 107, 79, 0.1); color: var(--success); }
.chapter-list__badge--paid { background: rgba(168, 131, 75, 0.15); color: var(--gold); }

/* =========================================================
   Lecteur de Chapitre (Reader)
   ========================================================= */
.chapter-body {
  font-family: var(--font-read);
  font-size: 1.125rem;
  line-height: var(--line-read);
  color: var(--ink);
  max-width: var(--measure);
  margin: 0 auto;
}
.chapter-body > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.4em;
  line-height: 0.9;
  float: left;
  padding: 0.05em 0.1em 0 0;
  color: var(--gold);
}
.chapter-body p { margin: 0 0 1.2em; }
.chapter-body h2, .chapter-body h3 {
  font-family: var(--font-display);
  margin-top: 1.8em;
}

.reader { padding: var(--space-8) 0 var(--space-16); }
.reader__header { text-align: center; margin-bottom: var(--space-12); }
.reader__back {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: var(--space-6);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
}
.reader__back:hover { color: var(--bordeaux); }
.reader__story-title {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.reader__title { font-size: clamp(1.8rem, 4vw, 2.5rem); }
.reader__header .gold-rule { margin-left: auto; margin-right: auto; }
.reader__footer {
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
}
.reader__nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* =========================================================
   Formulaires & Dashboard
   ========================================================= */
.auth-container {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}
.auth-box {
  background: var(--cream-deep);
  padding: var(--space-8);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 440px;
}
.auth-title { text-align: center; font-size: 2rem; margin-bottom: var(--space-2); }
.auth-subtitle { text-align: center; color: var(--ink-soft); margin-bottom: var(--space-6); }
.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }
.form-group label { font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  transition: border-color 0.15s ease;
}
.form-input:focus { outline: none; border-color: var(--bordeaux); }
.form-help { font-size: 0.8rem; color: var(--ink-faint); }
.form-errors { color: var(--danger); font-size: 0.85rem; font-weight: 500; }
.auth-footer { text-align: center; margin-top: var(--space-6); font-size: 0.9rem; color: var(--ink-soft); }

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-8);
}
.dashboard-header h1 { margin: 0; font-size: 2rem; }

/* Badges de statut */
.badge {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}
.badge-success { background: rgba(63, 107, 79, 0.1); color: var(--success); }
.badge-warning { background: rgba(168, 131, 75, 0.15); color: var(--gold); }
.badge-draft { background: rgba(28, 26, 23, 0.08); color: var(--ink-soft); }

input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
  transform: scale(1.2);
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================
   RESPONSIVE MOBILE (Menu Hamburger & Layouts)
   ========================================================= */
@media (max-width: 768px) {

  /* --- HEADER MOBILE --- */
  .site-header__inner {
    flex-wrap: wrap;
    padding: var(--space-3);
    gap: var(--space-2);
  }
  .site-header__brand {
    order: 1;
    margin-right: auto;
  }
  .site-header__controls {
    order: 2;
  }
  .nav-toggle {
    display: inline-flex; /* On montre le bouton hamburger */
  }

  /* Le menu par défaut est caché sur mobile */
  .site-header__nav {
    display: none;
    order: 4;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    margin: var(--space-3) 0 0 0;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border);
  }

  /* Quand le JS ajoute la classe .is-open, on affiche le menu */
  .site-header__nav.is-open {
    display: flex;
  }

  .site-header__nav .btn-nav {
    width: 100%;
    text-align: center;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
  }

  .nav-user {
    display: block;
    text-align: center;
    width: 100%;
    margin: var(--space-2) 0;
  }

  /* --- AUTRES PAGES MOBILE --- */
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .chapter-list__item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-2) !important;
  }
  .chapter-list__item > div {
    width: 100%;
    justify-content: space-between;
  }
  .story-card > div:last-child {
    flex-direction: column;
  }
  .story-detail__header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .story-detail__cover-wrapper {
    width: 180px;
  }
  .story-detail__stats {
    justify-content: center;
  }
  .story-detail__actions {
    display: flex;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
  }
}