/* ═══════════════════════════════════════════════════════════
   style.css  —  Charte graphique : النَّمْلَةُ وَالفِيلُ
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --cream:      #EDE8CE;
  --parchment:  #F5F0DC;
  --parch-lt:   #FAF7EE;

  --olive:      #6B7C3A;
  --olive-dk:   #4E5C28;
  --olive-lt:   #D4DDB0;
  --olive-xlt:  #EDF2D8;

  --gold:       #C9A84C;
  --gold-lt:    #EDD98A;
  --gold-xlt:   #F7EFCA;

  --brown:      #2C1A0E;
  --brown-md:   #5C3A1E;
  --brown-lt:   #8B6747;

  --white:      #FFFFFF;
  --shadow-sm:  0 2px 12px rgba(44,26,14,.08);
  --shadow:     0 4px 24px rgba(44,26,14,.12);
  --shadow-lg:  0 8px 40px rgba(44,26,14,.16);

  --radius:     16px;
  --radius-sm:  10px;
  --radius-xs:  6px;

  --font-fr:    'Nunito', sans-serif;
  --font-ar:    'Noto Naskh Arabic', serif;

  /* Ornement latéral : motif SVG or */
  --ornt-size:  28px;
}

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

body {
  font-family: var(--font-fr);
  background: var(--cream);
  color: var(--brown);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Texture parchemin subtile */
  background-image:
    radial-gradient(circle at 20% 80%, rgba(201,168,76,.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(107,124,58,.05) 0%, transparent 50%);
}

/* ── Utilitaires ──────────────────────────────────────────── */
.hidden       { display: none !important; }
.hidden-field { display: none; }

body.lang-ar .fr { display: none; }
body.lang-ar .ar { display: inline !important; }
body.lang-ar,
body.lang-ar input,
body.lang-ar select { direction: rtl; }
body.lang-ar .form-row        { direction: rtl; }
body.lang-ar .story-page-text { text-align: right; direction: rtl; }
body.lang-ar .audio-item      { direction: rtl; }

.ar { display: none; font-family: var(--font-ar); }

/* ════════════════════════════════════════════════════════════
   HEADER — Inspiré de la couverture du livre
   ════════════════════════════════════════════════════════════ */
.site-header {
  background: var(--parch-lt);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Barre dorée ornementale à gauche du header */
.header-ornt {
  width: 6px;
  align-self: stretch;
  min-height: 48px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-lt) 50%, var(--gold) 100%);
  border-radius: 3px;
  flex-shrink: 0;
}

.header-titles { flex: 1; min-width: 0; text-align: center; }

/* Série — petit texte olive en haut */
.series-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-ar);
  font-size: .72rem;
  color: var(--olive);
  font-weight: 700;
  letter-spacing: .01em;
  margin-bottom: 2px;
  direction: rtl;
}
.series-tag::before,
.series-tag::after {
  content: '🌿';
  font-size: .6rem;
}

.title-ar {
  font-family: var(--font-ar);
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  font-weight: 700;
  color: var(--brown);
  line-height: 1.2;
  direction: rtl;
}

/* Sous-titre encadré pointillé — comme sur la couverture */
.subtitle-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  border: 1.5px dashed var(--olive);
  border-radius: 50px;
  padding: 3px 12px;
  background: var(--olive-xlt);
}
.subtitle-banner .leaf { color: var(--olive); font-size: .7rem; }
.subtitle-banner span  {
  font-family: var(--font-ar);
  font-size: .7rem;
  color: var(--olive-dk);
  font-weight: 700;
  direction: rtl;
}

.lang-toggle {
  flex-shrink: 0;
  background: var(--olive-xlt);
  border: 2px solid var(--olive-lt);
  border-radius: 50px;
  color: var(--olive-dk);
  cursor: pointer;
  font-family: var(--font-fr);
  font-size: .75rem;
  font-weight: 800;
  padding: 6px 12px;
  transition: background .2s, border-color .2s;
  white-space: nowrap;
}
.lang-toggle:hover {
  background: var(--olive-lt);
  border-color: var(--olive);
}

/* ════════════════════════════════════════════════════════════
   SECTION FORMULAIRE
   ════════════════════════════════════════════════════════════ */
.section-form {
  padding: 28px 16px 60px;
  max-width: 680px;
  margin: 0 auto;
}

.form-card {
  background: var(--parch-lt);
  border-radius: var(--radius);
  border: 2px solid var(--gold-lt);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
}

/* Coin décoratif or */
.form-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: linear-gradient(225deg, var(--gold-xlt) 0%, transparent 60%);
}
.form-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 60px; height: 60px;
  background: linear-gradient(45deg, var(--olive-xlt) 0%, transparent 70%);
}

.form-hero {
  text-align: center;
  margin-bottom: 28px;
}

.hero-emoji {
  font-size: 2.8rem;
  display: block;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 6px rgba(44,26,14,.15));
}

.form-intro {
  font-size: .92rem;
  line-height: 1.75;
  color: var(--brown-md);
}

/* Séparateur doré */
.divider-gold {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-lt), var(--gold), var(--gold-lt), transparent);
  border: none;
  margin: 20px 0;
}

/* ── Champs ───────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 420px) { .form-row { grid-template-columns: 1fr; } }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: .82rem;
  font-weight: 800;
  color: var(--brown-md);
  letter-spacing: .02em;
}

.field input,
.field select {
  background: var(--white);
  border: 1.5px solid var(--gold-lt);
  border-radius: var(--radius-sm);
  color: var(--brown);
  font-family: var(--font-fr);
  font-size: .93rem;
  padding: 11px 14px;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--olive);
  box-shadow: 0 0 0 3px rgba(107,124,58,.12);
}
.field.invalid input,
.field.invalid select {
  border-color: #C0392B;
}

.error-msg {
  font-size: .76rem;
  color: #C0392B;
  display: none;
}
.field.invalid .error-msg { display: block; }
body.lang-ar .error-msg    { display: none !important; }

/* ── Consentement ─────────────────────────────────────────── */
.consent-field { margin-top: 4px; }
.consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: .86rem !important;
  font-weight: 400 !important;
}
.consent-label input[type="checkbox"] {
  width: 20px; height: 20px; min-width: 20px;
  margin-top: 2px;
  accent-color: var(--olive);
  cursor: pointer;
}
.consent-text { line-height: 1.6; color: var(--brown-lt); }

/* ── Bouton submit ────────────────────────────────────────── */
.btn-submit {
  background: linear-gradient(135deg, var(--olive) 0%, var(--olive-dk) 100%);
  border: none;
  border-radius: 50px;
  color: var(--white);
  cursor: pointer;
  font-family: var(--font-fr);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .03em;
  margin-top: 12px;
  padding: 14px 28px;
  width: 100%;
  box-shadow: 0 4px 16px rgba(107,124,58,.35);
  transition: transform .15s, box-shadow .15s;
}
.btn-submit:hover  { transform: translateY(-2px); box-shadow: 0 6px 22px rgba(107,124,58,.45); }
.btn-submit:active { transform: translateY(0); }
.btn-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.form-error {
  margin-top: 12px;
  background: #FDE8E8;
  border: 1px solid #F5B8B8;
  border-radius: var(--radius-sm);
  color: #C0392B;
  font-size: .86rem;
  padding: 10px 14px;
  text-align: center;
}

/* ── Toast succès ─────────────────────────────────────────── */
.form-success {
  margin-top: 14px;
  background: var(--olive-xlt);
  border: 1.5px solid var(--olive-lt);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s ease, transform .35s ease;
}
.form-success.toast-in {
  opacity: 1;
  transform: translateY(0);
}
.success-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}
.success-body strong {
  display: block;
  font-size: .95rem;
  color: var(--olive-dk);
  margin-bottom: 2px;
}
.success-body p {
  font-size: .82rem;
  color: var(--brown-md);
  margin: 0;
}

/* ── Bouton loading ───────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  animation: spin .8s linear infinite;
  font-style: normal;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.btn-submit {
  position: relative; /* nécessaire pour le spinner absolu */
}
.btn-text-fr,
.btn-text-ar {
  transition: opacity .2s;
}

@keyframes spin {
  from { transform: translateX(-50%) rotate(0deg); }
  to   { transform: translateX(-50%) rotate(360deg); }
}

/* ════════════════════════════════════════════════════════════
   SECTION HISTOIRE
   ════════════════════════════════════════════════════════════ */
.section-story {
  padding: 0 0 60px;
  max-width: 720px;
  margin: 0 auto;
}

/* ── Story header — couverture ────────────────────────────── */
.story-header {
  background: var(--parch-lt);
  border-bottom: 3px solid var(--gold);
  padding: 32px 24px 36px;
  text-align: center;
  position: relative;
}

/* Barre dorée ornementale droite */
.story-header::after {
  content: '◆  ·  ◆  ·  ◆  ·  ◆  ·  ◆';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 28px;
  writing-mode: vertical-rl;
  font-size: .45rem;
  letter-spacing: 6px;
  color: var(--gold);
  background: linear-gradient(180deg, var(--gold-xlt), var(--gold-lt), var(--gold-xlt));
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-series {
  font-family: var(--font-ar);
  font-size: .75rem;
  color: var(--olive);
  font-weight: 700;
  margin-bottom: 8px;
  direction: rtl;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.story-series::before,
.story-series::after { content: '🌿'; font-size: .6rem; }

.story-title-ar {
  font-family: var(--font-ar);
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  font-weight: 700;
  color: var(--brown);
  direction: rtl;
  line-height: 1.2;
  margin-bottom: 10px;
}

/* Bandeau sous-titre pointillé */
.story-subtitle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px dashed var(--olive);
  border-radius: 50px;
  padding: 6px 18px;
  background: var(--olive-xlt);
  margin-bottom: 20px;
}
.story-subtitle-wrap .leaf { color: var(--olive); font-size: .75rem; }
.story-subtitle-ar {
  font-family: var(--font-ar);
  font-size: .88rem;
  color: var(--olive-dk);
  font-weight: 700;
  direction: rtl;
}
.story-subtitle-fr {
  font-size: .8rem;
  color: var(--olive-dk);
  font-style: italic;
  font-weight: 600;
}

.welcome-msg {
  display: inline-block;
  background: var(--gold-xlt);
  border: 1.5px solid var(--gold-lt);
  border-radius: 50px;
  font-size: .88rem;
  font-weight: 700;
  color: var(--brown-md);
  padding: 7px 20px;
  margin-top: 4px;
}

/* ── Pages de l'histoire ──────────────────────────────────── */
.story-pages {
  padding: 28px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.story-page {
  background: var(--parch-lt);
  border: 1.5px solid var(--gold-lt);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}

/* Trait doré gauche */
.story-page::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, var(--gold), var(--gold-lt), var(--gold));
  border-radius: 4px 0 0 4px;
}

.story-page-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  background: var(--olive);
  border-radius: 50px;
  font-size: .7rem;
  font-weight: 800;
  padding: 2px 10px;
  color: var(--white);
  letter-spacing: .03em;
}

.story-page-body {
  padding: 18px 20px 20px 22px;
}

.story-page-text { white-space: pre-line; }

.story-page-text.text-ar {
  font-family: var(--font-ar);
  font-size: clamp(1.05rem, 4vw, 1.2rem);
  line-height: 2.1;
  direction: rtl;
  text-align: right;
  color: var(--brown);
  margin-bottom: 10px;
}

.story-page-text.text-fr {
  font-size: clamp(.82rem, 3vw, .9rem);
  line-height: 1.7;
  color: var(--brown-lt);
  font-style: italic;
  border-top: 1.5px dashed var(--gold-lt);
  padding-top: 10px;
  margin-top: 4px;
}

/* ── Section audio ────────────────────────────────────────── */
.audio-section {
  padding: 20px 16px 8px;
}

.audio-section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brown);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.audio-section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-lt), transparent);
  border-radius: 2px;
}

.audio-desc {
  font-size: .86rem;
  color: var(--brown-lt);
  margin-bottom: 18px;
}

.audio-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audio-item {
  background: var(--parch-lt);
  border: 1.5px solid var(--gold-lt);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  transition: box-shadow .2s, border-color .2s;
}
.audio-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--gold);
}

.audio-item iframe {
  width: 100%;
  height: 60px;
  border: none;
  border-radius: var(--radius-xs);
  margin-top: 8px;
  display: block;
}

.audio-icon {
  background: var(--olive-xlt);
  border: 1.5px solid var(--olive-lt);
  border-radius: 50%;
  color: var(--olive);
  font-size: 1.2rem;
  height: 42px; width: 42px; min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-info { flex: 1; min-width: 0; }

.audio-page-label {
  font-size: .72rem;
  font-weight: 800;
  color: var(--brown-lt);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 2px;
}
.audio-page-label .label-ar {
  font-family: var(--font-ar);
  text-transform: none;
  letter-spacing: 0;
  direction: rtl;
  display: none;
}
body.lang-ar .audio-page-label .label-fr { display: none; }
body.lang-ar .audio-page-label .label-ar { display: inline; }

.audio-preview {
  font-size: .82rem;
  color: var(--brown);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-ar);
  direction: rtl;
}

.audio-btn {
  background: var(--olive);
  border: none;
  border-radius: 50px;
  color: var(--white);
  cursor: pointer;
  font-family: var(--font-fr);
  font-size: .78rem;
  font-weight: 800;
  padding: 7px 14px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.audio-btn:hover { background: var(--olive-dk); }
.audio-btn.no-link {
  background: var(--olive-lt);
  color: var(--brown-lt);
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Badge vert rond (inspiré couverture) ─────────────────── */
.cover-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--olive);
  border-radius: 50%;
  width: 72px; height: 72px;
  color: var(--white);
  font-family: var(--font-ar);
  font-size: .62rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
  direction: rtl;
  box-shadow: 0 3px 12px rgba(107,124,58,.4);
  margin: 16px auto 0;
  display: block;
  padding: 8px;
}

/* ── Footer ───────────────────────────────────────────────── */
.story-footer {
  text-align: center;
  padding: 28px 16px 48px;
  border-top: 2px solid var(--gold-lt);
  margin-top: 24px;
}
.story-footer p {
  font-size: .9rem;
  color: var(--brown-lt);
  line-height: 2;
}
.story-footer .author {
  font-family: var(--font-ar);
  font-weight: 700;
  color: var(--brown-md);
  direction: rtl;
  font-size: 1rem;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 600px) {
  .section-form  { padding: 36px 24px 80px; }
  .form-card     { padding: 36px 40px; }
  .story-pages   { padding: 32px 24px 24px; }
  .audio-section { padding: 24px 24px 16px; }
}
