/*
 * EbookLand : thème mobile « sombre et premium » (maquettes validées).
 *
 * Actif uniquement :
 *   - sur les pages dont <body> porte la classe "prem" (définie via $bodyClass = 'prem' avant header.php) ;
 *   - sur écran de 760 px de large ou moins.
 * Le thème sombre ne s'applique pas au bureau ; les rangées de catégories s'affichent aussi au bureau.
 *
 * Palette : fond #0F1020, cartes #181A2E, traits #2A2D4A, or #E8B94A, texte #F4F1E8, texte secondaire #A5A7BD.
 */

/* Éléments propres au thème : cachés partout par défaut. */
.prem-greeting,
.prem-feature { display: none; }

/* Les catégories sont visibles sur toute taille d’écran, comme les ajouts récents. */
.prem-rails { display: block; }
.prem-rails .prem-all-link {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 1140px;
  min-height: 48px;
  margin: 20px auto 30px;
  border: 1px solid #b87400;
  border-radius: 25px;
  color: #82530a;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 760px) {

  body.prem {
    --prem-bg: #0F1020;
    --prem-card: #181A2E;
    --prem-card-2: #1C1F38;
    --prem-chip: #242744;
    --prem-line: #2A2D4A;
    --prem-gold: #E8B94A;
    --prem-text: #F4F1E8;
    --prem-muted: #A5A7BD;
    --prem-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
    background: var(--prem-bg);
    color: var(--prem-text);
    font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    padding-bottom: 0; /* le pied de page réserve déjà la place du menu du bas */
  }

  body.prem a:focus-visible,
  body.prem button:focus-visible,
  body.prem input:focus-visible {
    outline: 2px solid var(--prem-gold);
    outline-offset: 2px;
  }

  /* ---------- En-tête ---------- */
  body.prem .site-header {
    position: static;
    background: var(--prem-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: 0;
  }
  body.prem .header-inner { padding: 20px 20px 0; }
  body.prem .header-main { grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; }
  body.prem .brand { grid-column: 1; grid-row: 1; color: var(--prem-text); }
  body.prem .header-actions { grid-column: 2; grid-row: 1; }
  body.prem .brand-mark { width: 34px; height: 30px; }
  body.prem .brand-mark svg path { stroke: var(--prem-bg); }
  body.prem .brand-tagline { display: none; }
  body.prem .brand-name {
    font-family: var(--prem-serif);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .01em;
    text-transform: lowercase;
    color: var(--prem-text);
  }
  body.prem .brand-name::first-letter { text-transform: uppercase; }
  body.prem .brand-name .accent {
    display: inline-block;
    color: var(--prem-gold);
    text-transform: lowercase;
  }
  body.prem .brand-name .accent::first-letter { text-transform: uppercase; }

  body.prem .header-action {
    width: 44px;
    height: 44px;
    background: var(--prem-card);
    border: 1px solid var(--prem-line);
    color: var(--prem-text);
    box-shadow: none;
  }
  body.prem .notification-dot { background: var(--prem-gold); border-color: var(--prem-card); }

  body.prem .prem-greeting {
    display: block;
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 20px 0 0;
    font-family: var(--prem-serif);
    font-size: 27px;
    font-weight: 600;
    line-height: 1.15;
    color: var(--prem-text);
  }

  body.prem .search-shell { grid-column: 1 / -1; grid-row: 3; margin-top: 16px; }
  body.prem .search-shell form {
    height: 50px;
    padding: 0 6px 0 16px;
    background: var(--prem-card);
    border: 1px solid var(--prem-line);
    box-shadow: none;
  }
  body.prem .search-icon { width: 19px; height: 19px; color: var(--prem-muted); }
  body.prem .search-shell input { color: var(--prem-text); font-size: 14px; }
  body.prem .search-shell input::placeholder { color: var(--prem-muted); opacity: 1; }
  body.prem .search-filter { background: var(--prem-chip); color: var(--prem-gold); }

  body.prem .top-nav { display: none; }

  /* Suggestions de recherche en direct */
  body.prem .search-live-dropdown {
    background: var(--prem-card);
    border-color: var(--prem-line);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .55);
  }
  body.prem .search-live-heading,
  body.prem .search-live-author,
  body.prem .search-live-empty { color: var(--prem-muted); }
  body.prem .search-live-book { color: var(--prem-text); border-bottom-color: var(--prem-line); }
  body.prem .search-live-book:hover,
  body.prem .search-live-book:focus-visible { background: var(--prem-card-2); }
  body.prem .search-live-thumb { background: var(--prem-bg); }
  body.prem .search-live-price { color: var(--prem-gold); }
  body.prem .search-live-all { background: var(--prem-gold); color: var(--prem-bg); }

  /* ---------- Accueil : bannière remplacée par « À la une » ---------- */
  body.prem .home-hero { display: none; }

  body.prem .prem-feature {
    display: flex;
    gap: 18px;
    margin: 24px 20px 0;
    padding: 18px;
    border-radius: 26px;
    background: var(--prem-card);
    border: 1px solid var(--prem-line);
  }
  body.prem .prem-feature-cover {
    flex: 0 0 124px;
    width: 124px;
    align-self: flex-start;
    display: block;
    overflow: hidden;
    border-radius: 6px 12px 12px 6px;
    background: var(--prem-bg);
    box-shadow: 0 16px 30px rgba(0, 0, 0, .5);
  }
  body.prem .prem-feature-cover img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 190px;
    object-fit: contain;
  }
  body.prem .prem-feature-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
  }
  body.prem .prem-eyebrow {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .16em;
    color: var(--prem-gold);
  }
  body.prem .prem-feature h2 {
    margin: 6px 0 0;
    font-family: var(--prem-serif);
    font-size: 21px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--prem-text);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
  }
  body.prem .prem-feature h2 a { color: inherit; text-decoration: none; }
  body.prem .prem-feature-author { display: block; margin-top: 6px; font-size: 13px; color: var(--prem-muted); }
  body.prem .prem-feature-meta { display: block; margin-top: 8px; font-size: 12px; font-weight: 500; color: var(--prem-muted); }
  body.prem .prem-feature-price { font-size: 18px; font-weight: 700; color: var(--prem-text); }
  body.prem .prem-feature-price small { font-size: 12px; font-weight: 500; color: var(--prem-muted); }
  body.prem .prem-feature-add {
    margin-top: 10px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 22px;
    background: var(--prem-gold);
    color: var(--prem-bg);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
  }
  body.prem .prem-feature-add svg { width: 18px; height: 18px; }

  /* ---------- Titres de sections ---------- */
  body.prem .new-books-section,
  body.prem .latest-section { padding: 0 20px; }
  body.prem .new-books-section { margin: 24px 0 0; }
  body.prem .latest-section { margin: 26px 0 30px; }

  body.prem .section-heading { margin-bottom: 14px; }
  body.prem .section-heading h2 {
    padding-left: 0;
    font-family: var(--prem-serif);
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--prem-text);
  }
  body.prem .section-heading h2::before { display: none; }
  body.prem .section-heading a { color: var(--prem-gold); font-size: 13px; font-weight: 600; }

  /* ---------- Ajouter récemment : rangée de couvertures ---------- */
  body.prem .new-books-slider {
    --recent-gap: 14px;
    grid-auto-columns: 128px;
    gap: 14px;
    margin: 0 -20px;
    padding: 2px 20px 8px;
    scroll-padding-inline: 20px;
    scrollbar-width: none;
  }
  body.prem .new-books-slider::-webkit-scrollbar { display: none; }
  body.prem .recent-book-card { gap: 4px; color: var(--prem-text); }
  body.prem .recent-book-cover {
    margin-bottom: 6px;
    background: var(--prem-card);
    border: 1px solid var(--prem-line);
    border-radius: 6px 12px 12px 6px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, .45);
  }
  body.prem .recent-book-placeholder { color: var(--prem-gold); }
  body.prem .recent-book-title { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--prem-text); }
  body.prem .recent-book-author,
  body.prem .recent-book-price {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.prem .recent-book-author { font-size: 12px; color: var(--prem-muted); }
  body.prem .recent-book-price { font-size: 13px; font-weight: 700; color: var(--prem-gold); }
  body.prem .recent-book-price small { font-size: 11px; font-weight: 600; }

  /* ---------- Rangées par catégorie, entre les ajouts récents et « Nos livres » ---------- */
  body.prem .prem-rails { display: block; margin-bottom: 30px; }
  body.prem .prem-all-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 52px;
    margin: 28px 20px 0;
    border: 1px solid var(--prem-gold);
    border-radius: 26px;
    color: var(--prem-gold);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
  }

  /* ---------- Ancienne liste « Nos livres » (conservée si on la réaffiche) ---------- */
  body.prem .latest-section .latest-grid { display: flex; flex-direction: column; gap: 12px; }

  body.prem .latest-grid > .ebook-card {
    display: grid !important;
    grid-template-columns: 64px minmax(0, 1fr);
    column-gap: 14px;
    align-items: center;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 12px !important;
    border-radius: 20px !important;
    background: var(--prem-card) !important;
    border: 1px solid var(--prem-line) !important;
    box-shadow: none !important;
    overflow: visible;
  }
  body.prem .latest-grid .ebook-cover-link { grid-column: 1; display: block; width: 64px; }
  body.prem .latest-grid .ebook-cover-wrap {
    position: relative;
    width: 64px;
    height: 92px;
    aspect-ratio: auto;
    padding: 0;
    overflow: hidden;
    border-radius: 4px 8px 8px 4px;
    background: var(--prem-bg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, .4);
  }
  body.prem .latest-grid .ebook-cover { display: block; width: 100%; height: 100%; object-fit: contain; }
  body.prem .latest-grid .ebook-card .ebook-format {
    position: absolute;
    z-index: 1;
    top: 3px;
    right: 3px;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 7px;
    line-height: 1.1;
    background: rgba(15, 16, 32, .88);
    color: var(--prem-gold);
  }

  body.prem .latest-grid .ebook-card-body {
    grid-column: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    align-items: center;
    min-width: 0;
    padding: 0 !important;
  }
  body.prem .latest-grid .ebook-category {
    grid-column: 1;
    display: block;
    margin: 0 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--prem-gold);
  }
  body.prem .latest-grid .ebook-title {
    grid-column: 1;
    display: -webkit-box;
    min-height: 0;
    margin: 0 0 3px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    /* ebook-cards.css impose une couleur foncée en !important : il faut la battre. */
    color: var(--prem-text) !important;
    text-decoration: none !important;
  }
  body.prem .latest-grid .ebook-title:hover { color: var(--prem-gold) !important; }
  body.prem .latest-grid .ebook-author {
    grid-column: 1;
    margin: 0;
    font-size: 12px;
    color: var(--prem-muted);
  }
  body.prem .latest-grid .ebook-card-bottom { display: contents; }
  body.prem .latest-grid .ebook-price {
    grid-column: 1;
    margin-top: 5px;
    font-size: 14px;
    font-weight: 700;
    color: var(--prem-text);
  }
  body.prem .latest-grid .ebook-price small { font-size: 11px; font-weight: 500; color: var(--prem-muted); }
  body.prem .latest-grid .ebook-cart {
    grid-column: 2;
    grid-row: 1 / span 4;
    align-self: center;
    flex: none;
    /* ebook-cards.css fixe 32 à 39 px en !important : on impose une cible tactile de 44 px. */
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    display: grid !important;
    place-items: center;
    border-radius: 22px;
    background: var(--prem-gold);
    color: var(--prem-bg) !important;
    box-shadow: none;
  }
  body.prem .latest-grid .ebook-cart:hover { background: #f1c75e; transform: none; }
  body.prem .latest-grid .ebook-cart svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    max-width: 20px !important;
  }

  /* ---------- Menu du bas ---------- */
  body.prem .bottom-menu {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    border-radius: 34px;
    background: var(--prem-card-2);
    border: 1px solid var(--prem-line);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
  body.prem .bottom-menu a {
    min-height: 54px;
    background: transparent;
    color: var(--prem-muted);
    font-size: 11px;
    font-weight: 600;
  }
  body.prem .bottom-menu a.disabled { opacity: 1; } /* garde un contraste lisible */
  body.prem .bottom-menu a.active { background: transparent; color: var(--prem-gold); font-weight: 700; }
  body.prem .bottom-menu a.active .icon-home { fill: currentColor; }
  body.prem .bottom-menu a .badge {
    background: var(--prem-gold);
    color: var(--prem-bg);
    border-color: var(--prem-card-2);
  }

  /* Menu latéral des catégories */
  body.prem #sideMenu { background: var(--prem-card); box-shadow: 18px 0 45px rgba(0, 0, 0, .5); }
  body.prem .side-menu-head h3 { font-family: var(--prem-serif); font-weight: 600; color: var(--prem-text); }
  body.prem .side-close { background: var(--prem-chip); color: var(--prem-text); }
  body.prem #sideMenu .side-category { color: var(--prem-text); }
  body.prem #sideMenu .side-category:hover { background: var(--prem-chip); color: var(--prem-gold); }
  body.prem #sideMenu .side-category span:last-child { color: var(--prem-muted); }

  /* Bouton WhatsApp : au-dessus du menu du bas */
  body.prem .whatsapp-float { right: 16px; bottom: 104px; }

  /* ---------- Pied de page ---------- */
  body.prem .site-footer { margin-top: 30px; background: #0A0B17; border-top: 1px solid var(--prem-line); }
  body.prem .footer-brand { font-family: var(--prem-serif); }
  body.prem .footer-brand span { color: var(--prem-gold); }
  body.prem .footer-links a:hover { color: var(--prem-gold); }
}
