/* ================================================================
   TRÉSOR LITTÉRAIRE — main.css
   Système design centralisé. Toutes les pages importent ce fichier.
   v1.0 — 2026
   ================================================================ */

/* ── 1. VARIABLES ─────────────────────────────────────────────── */
:root {
  /* Palette */
  --rouge:        #a10f13;
  --rouge-2:      #d82b2f;
  --rouge-dark:   #7a0b0e;
  --or:           #d4af37;
  --or-light:     #f6e9c0;
  --or-pale:      #fff7e6;
  --creme:        #fff9f0;
  --border:       #e8d5b7;
  --border-light: #f2e4cc;
  --texte:        #1a1209;
  --texte-2:      #4a3728;
  --texte-3:      #7a6655;
  --fond:         #fdf8f2;

  /* Typographie */
  --font-titre:   'Cinzel', serif;
  --font-corps:   'Playfair Display', serif;
  --font-ui:      'Lato', sans-serif;

  /* Espacements */
  --gap-xs:  4px;
  --gap-sm:  8px;
  --gap-md:  16px;
  --gap-lg:  24px;
  --gap-xl:  40px;

  /* Rayons */
  --r-sm:    8px;
  --r-md:    14px;
  --r-lg:    20px;
  --r-pill:  999px;

  /* Ombres */
  --shadow-sm:  0 2px 8px rgba(0,0,0,.08);
  --shadow-md:  0 6px 20px rgba(0,0,0,.12);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.16);

  /* Header height (utilisé pour padding-top des pages) */
  --header-h: 110px;
}

/* ── 2. RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-corps);
  background-color: var(--fond);
  color: var(--texte);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ── 3. HEADER ────────────────────────────────────────────────── */
.tl-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 12px rgba(161,15,19,.08);
}

.tl-header__inner {
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
  padding: 8px 12px;
}

/* Ligne haute : logo + titre */
.tl-header__top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tl-header__logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--rouge);
  box-shadow: var(--shadow-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.tl-header__brand {
  font-family: var(--font-titre);
  font-weight: 700;
  font-size: 20px;
  color: var(--rouge);
  letter-spacing: 1.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,.15), 0 0 12px rgba(212,175,55,.25);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Ligne basse : nav + recherche */
.tl-header__bottom {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
}

/* Bouton nav (boutique, accueil…) */
.tl-btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--rouge), var(--rouge-2));
  color: var(--or-light);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .6px;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(161,15,19,.3);
  border: 1px solid rgba(255,255,255,.15);
  white-space: nowrap;
  flex-shrink: 0;
  transition: filter .18s;
}
.tl-btn-nav:hover { filter: brightness(1.12); }

/* Barre de recherche */
.tl-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.tl-search__input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--r-pill) 0 0 var(--r-pill);
  background: var(--or-pale);
  font-family: var(--font-corps);
  font-size: 13px;
  color: var(--texte);
  outline: none;
  transition: border-color .2s;
}
.tl-search__input:focus { border-color: var(--rouge); }

.tl-search__btn {
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: linear-gradient(135deg, var(--rouge), var(--rouge-2));
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
  transition: filter .18s;
}
.tl-search__btn:hover { filter: brightness(1.1); }

/* ── 4. FOOTER ────────────────────────────────────────────────── */
.tl-footer {
  background: linear-gradient(135deg, var(--rouge-dark), var(--rouge-2));
  color: var(--or-light);
  text-align: center;
  padding: 18px 16px;
  margin-top: var(--gap-xl);
  font-family: var(--font-corps);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 1px;
  border-top: 1px solid rgba(212,175,55,.3);
  text-shadow: 0 1px 3px rgba(0,0,0,.35);
}

/* ── 5. GRILLE EBOOKS ─────────────────────────────────────────── */
.tl-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Carte ebook */
.tl-card {
  position: relative;
  background: #fff;
  border-radius: var(--r-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex: 0 0 calc(50% - 5px);
  max-width: calc(50% - 5px);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.tl-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.tl-card.is-fullrow {
  flex: 0 0 100% !important;
  max-width: 100% !important;
}

.tl-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(18,138,63,.9);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-ui);
  padding: 5px 10px;
  border-radius: var(--r-pill);
  display: none;
  z-index: 5;
  backdrop-filter: blur(3px);
}
.tl-card.is-added .tl-card__badge { display: inline-flex; }

.tl-card__cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
}

.tl-card__body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tl-card__title {
  font-family: var(--font-corps);
  font-size: 14px;
  font-weight: 800;
  color: var(--texte);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
  margin-bottom: 6px;
}

.tl-card__price {
  color: var(--rouge);
  font-weight: 900;
  font-size: 16px;
  font-family: var(--font-ui);
  margin-bottom: 10px;
}

.tl-card__actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: auto;
}

/* Boutons carte */
.tl-btn-obtenir {
  width: 100%;
  padding: 10px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--rouge), var(--rouge-2));
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(161,15,19,.25);
  transition: filter .18s;
}
.tl-btn-obtenir:hover { filter: brightness(1.1); }

.tl-btn-panier {
  width: 100%;
  padding: 9px;
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--texte);
  border: 2px solid var(--or);
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .18s, color .18s;
}
.tl-btn-panier:hover { background: var(--or-light); }

/* ── 6. SECTIONS ──────────────────────────────────────────────── */
.tl-section {
  max-width: 1000px;
  margin: 16px auto 100px;
  padding: 0 12px;
}

.tl-section__header {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-sm);
  border-bottom: 2px solid var(--border-light);
}

.tl-section__title {
  font-family: var(--font-titre);
  font-size: 18px;
  color: var(--texte-2);
  letter-spacing: .8px;
}

.tl-section__count {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--texte-3);
  background: var(--border-light);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-weight: 700;
}

/* ── 7. PAGINATION ────────────────────────────────────────────── */
.tl-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: var(--gap-lg);
}

.tl-pagination__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 14px;
  color: var(--texte-2);
  transition: all .18s;
}
.tl-pagination__item:hover { border-color: var(--rouge); color: var(--rouge); }
.tl-pagination__item.active {
  background: var(--rouge);
  border-color: var(--rouge);
  color: #fff;
}
.tl-pagination__item.disabled {
  opacity: .35;
  pointer-events: none;
}

/* ── 8. TOAST ─────────────────────────────────────────────────── */
.tl-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 80px;
  z-index: 20000;
  display: none;
  align-items: center;
  gap: 10px;
  background: rgba(20,12,8,.88);
  border: 1px solid rgba(212,175,55,.25);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(8px);
  color: #fff;
  font-family: var(--font-ui);
}
.tl-toast.visible { display: flex; }

.tl-toast__icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(33,160,86,.2);
  border: 1px solid rgba(33,160,86,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tl-toast__msg {
  flex: 1;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-toast__undo {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  transition: background .18s;
}
.tl-toast__undo:hover { background: rgba(255,255,255,.22); }

/* ── 9. MENU BAS (navigation mobile) ─────────────────────────── */
.tl-nav-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: #fff;
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: stretch;
  box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  height: 62px;
}

.tl-nav-bottom__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  color: var(--texte-3);
  text-transform: uppercase;
  letter-spacing: .4px;
  transition: color .18s;
  padding: 8px 4px;
  position: relative;
}
.tl-nav-bottom__item:hover,
.tl-nav-bottom__item.active { color: var(--rouge); }

.tl-nav-bottom__icon { font-size: 20px; line-height: 1; }

.tl-nav-bottom__badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: var(--rouge);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── 10. LOADER SCROLL INFINI ─────────────────────────────────── */
.tl-loader {
  display: none;
  width: 100%;
  text-align: center;
  padding: var(--gap-md);
  color: var(--texte-3);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
}
.tl-loader.visible { display: block; }
.tl-loader::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--rouge);
  border-radius: 50%;
  animation: tl-spin .7s linear infinite;
  vertical-align: middle;
  margin-left: 8px;
}

@keyframes tl-spin { to { transform: rotate(360deg); } }

/* ── 11. FORMULAIRES ──────────────────────────────────────────── */
.tl-form { display: flex; flex-direction: column; gap: var(--gap-md); }

.tl-field { display: flex; flex-direction: column; gap: 6px; }

.tl-label {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--texte-2);
  letter-spacing: .3px;
}

.tl-input,
.tl-select,
.tl-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--or-pale);
  font-family: var(--font-corps);
  font-size: 14px;
  color: var(--texte);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.tl-input:focus,
.tl-select:focus,
.tl-textarea:focus {
  border-color: var(--rouge);
  box-shadow: 0 0 0 3px rgba(161,15,19,.1);
}
.tl-textarea { min-height: 120px; resize: vertical; }

.tl-btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--rouge), var(--rouge-2));
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .5px;
  box-shadow: 0 4px 16px rgba(161,15,19,.3);
  transition: filter .18s, transform .18s;
}
.tl-btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.tl-btn-primary:active { transform: translateY(0); }

.tl-btn-secondary {
  padding: 10px 20px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--texte-2);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  transition: border-color .18s, color .18s;
}
.tl-btn-secondary:hover { border-color: var(--rouge); color: var(--rouge); }

/* ── 12. ALERTS ───────────────────────────────────────────────── */
.tl-alert {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.tl-alert--success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.tl-alert--error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.tl-alert--info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.tl-alert--warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── 13. BARRE RÉSULTATS RECHERCHE ───────────────────────────── */
.tl-results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-md);
  padding: 10px 14px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  margin-bottom: var(--gap-md);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--texte-2);
}

.tl-results-bar__reset {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--texte);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  transition: background .18s;
}
.tl-results-bar__reset:hover { background: var(--rouge); }

/* ── 14. PAGE LAYOUT ──────────────────────────────────────────── */
.tl-page { padding-top: var(--header-h); padding-bottom: 80px; }

/* ── 15. CATÉGORIE BREADCRUMB ─────────────────────────────────── */
.tl-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--texte-3);
  margin-bottom: var(--gap-md);
}
.tl-breadcrumb a { color: var(--rouge); font-weight: 600; }
.tl-breadcrumb__sep { opacity: .5; }

/* ── 16. RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 420px) {
  :root { --header-h: 100px; }

  .tl-header__brand { font-size: 17px; }
  .tl-btn-nav       { font-size: 11px; padding: 7px 11px; }
  .tl-search__input { font-size: 12px; padding: 8px 10px; }
  .tl-card__title   { font-size: 13px; }
  .tl-card__price   { font-size: 15px; }
}

@media (min-width: 640px) {
  .tl-card {
    flex: 0 0 calc(33.333% - 7px);
    max-width: calc(33.333% - 7px);
  }
}

@media (min-width: 900px) {
  .tl-card {
    flex: 0 0 calc(25% - 8px);
    max-width: calc(25% - 8px);
  }
}
