/* ============================================================
   MIDNIGHT ARCHIVE — Ubooquity 3 Dark Theme
   A noir library aesthetic with golden accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ─── CSS VARIABLES ────────────────────────────────────────── */
:root {
  --bg-base:        #0a0b14;
  --bg-surface:     #12131f;
  --bg-elevated:    #1c1d2e;
  --bg-hover:       #252638;
  --bg-card:        #161724;
  --accent-gold:    #d4a843;
  --accent-gold-dk: #a07830;
  --accent-glow:    rgba(212, 168, 67, 0.15);
  --text-primary:   #f0ebe0;
  --text-secondary: #9999b0;
  --text-muted:     #55566e;
  --border:         rgba(255,255,255,0.07);
  --border-accent:  rgba(212, 168, 67, 0.3);
  --shadow:         0 4px 24px rgba(0,0,0,0.6);
  --shadow-card:    0 2px 12px rgba(0,0,0,0.5);
  --radius:         10px;
  --radius-sm:      6px;
  --font-display:   'Crimson Pro', Georgia, serif;
  --font-body:      'DM Sans', system-ui, sans-serif;
  --transition:     0.2s ease;
  --cover-w:        173px;
  --cover-h:        249px;
}
/* ─── GRID LAYOUT ──────────────────────────────────────────── */
.covers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cover-w), 1fr));
  gap: 20px;
}
/* ─── RESET & BASE ──────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: #f0c96a; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ─── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ─── LAYOUT WRAPPER ────────────────────────────────────────── */
#content-wrapper, .content-wrapper, #main-content, main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

/* ─── HEADER / NAVBAR ────────────────────────────────────────── */
#topbar, .topbar, header {
  background: linear-gradient(180deg, rgba(10,11,20,0.98) 0%, rgba(10,11,20,0.92) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Brand / logo area */
.brand, #home-link, .home-link {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-gold) !important;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Nav buttons */
#topbar a, .topbar a, .topbar-btn {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
#topbar a:hover, .topbar a:hover { 
  color: var(--text-primary); 
  background: var(--bg-elevated);
}

/* Search bar */
#searchbar, .searchbar, input[type="search"], input[type="text"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  width: 220px;
  outline: none;
  transition: all var(--transition);
}
#searchbar:focus, input[type="search"]:focus, input[type="text"]:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  width: 280px;
}

/* ─── BREADCRUMB / BACK BUTTON ─────────────────────────────── */
#back-button, .back-btn, .breadcrumb {
  color: var(--text-secondary);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
#back-button:hover { color: var(--accent-gold); }

/* ─── PAGE TITLE ─────────────────────────────────────────────── */
.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 32px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ─── HOME PAGE — CATEGORY CARDS ─────────────────────────────── */
.home-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.category-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.category-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow), 0 0 0 1px var(--border-accent);
}
.category-card:hover::before { opacity: 1; }

.category-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}
.category-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.category-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.category-latest-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--accent-gold);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.category-latest-link:hover { color: #f0c96a; }
.category-latest-link::after { content: '→'; transition: transform var(--transition); }
.category-latest-link:hover::after { transform: translateX(3px); }

/* ─── BOOK GRID ──────────────────────────────────────────────── */
#books-container, .books-grid, #items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(var(--cover-w) + 16px), 1fr));
  gap: 20px;
  margin-top: 24px;
}

/* Book / folder card */
.book-card, .item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  display: flex;
  flex-direction: column;
}
.book-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--border-accent);
  box-shadow: var(--shadow), 0 0 20px var(--accent-glow);
}

/* Cover image */
.book-cover-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 2/3;
  background: var(--bg-elevated);
}
.book-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
  display: block;
}
.book-card:hover .book-cover-wrap img { transform: scale(1.05); }

/* Hover overlay with actions */
.book-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 60%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.book-card:hover .book-overlay { opacity: 1; }

.btn-read {
  background: var(--accent-gold);
  color: #0a0b14;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  text-decoration: none;
  display: block;
}
.btn-read:hover { background: #f0c96a; color: #0a0b14; }

/* Progress bar */
.reading-progress {
  height: 3px;
  background: var(--bg-elevated);
  position: absolute;
  bottom: 0; left: 0; right: 0;
}
.reading-progress-bar {
  height: 100%;
  background: var(--accent-gold);
  transition: width var(--transition);
}

/* Reading status badge */
.status-badge {
  position: absolute;
  top: 8px; right: 8px;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}
.status-badge.status_unread     { background: var(--text-muted); }
.status-badge.status_inprogress { background: var(--accent-gold); }
.status-badge.status_finished   { background: #5acc8a; }

/* File extension badge */
.ext-badge {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  color: var(--text-secondary);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
}

/* Book info below cover */
.book-info {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.book-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.book-author {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-series {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Folder card variant */
.folder-card .book-cover-wrap {
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: auto;
  height: 120px;
}
.folder-icon {
  font-size: 3rem;
  color: var(--text-muted);
}
.folder-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── PAGINATION ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 36px 0 16px;
}
.pagination a, .page-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pagination a:hover, .page-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
  color: var(--text-primary);
}
.pagination .current-page {
  color: var(--accent-gold);
  background: var(--accent-glow);
  border-color: var(--border-accent);
  min-width: 34px;
  text-align: center;
}
.hidden { display: none !important; }

/* ─── SORT / FILTER TOPBAR ───────────────────────────────────── */
.sort-panel, #sort-options {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.sort-panel label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.sort-panel input[type="radio"] { accent-color: var(--accent-gold); }

/* Settings popup */
.popup, .modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-primary);
}
.popup h2, .modal h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--accent-gold);
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

/* ─── BOOK DETAILS PAGE ──────────────────────────────────────── */
.details-page {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 36px;
  margin-top: 32px;
  max-width: 900px;
}
.details-cover img {
  width: 220px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
}
.details-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.details-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.details-author {
  font-size: 1rem;
  color: var(--accent-gold);
  font-weight: 500;
}
.meta-row {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.meta-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 90px;
  flex-shrink: 0;
}
.details-description {
  margin-top: 12px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 600px;
}
.details-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.btn-primary {
  background: var(--accent-gold);
  color: #0a0b14;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-primary:hover { background: #f0c96a; color: #0a0b14; }
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-secondary:hover { border-color: var(--border-accent); color: var(--text-primary); }

.rating { color: var(--accent-gold); font-size: 1rem; letter-spacing: 2px; }
.tag {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 3px 9px;
  border-radius: 30px;
  border: 1px solid var(--border);
}

/* ─── LOGIN PAGE ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(212,168,67,0.06) 0%, transparent 65%), var(--bg-base);
}
.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px 40px;
  width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.login-tagline {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.login-field input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition);
}
.login-field input:focus {
  border-color: var(--border-accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-btn {
  width: 100%;
  background: var(--accent-gold);
  color: #0a0b14;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--transition);
}
.login-btn:hover { background: #f0c96a; }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  :root { --font-size-base: 14px; }
  #topbar { padding: 0 12px; }
  .details-page { grid-template-columns: 1fr; }
  .details-cover img { width: 160px; }
  .home-categories { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .home-categories { grid-template-columns: 1fr; }
}
/* ==========================================================
   🎭 MIDNIGHT ARCHIVE – ENHANCED EFFECTS (FIXED)
   Compatible avec ta structure actuelle
   ========================================================== */

/* ==========================================================
   1️⃣ 3D PREMIUM COVER EFFECT
   ========================================================== */

.book-cover-wrap {
  perspective: 1200px;
}

.book-cover-wrap img {
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  transform-style: preserve-3d;
}

.book-card:hover .book-cover-wrap img {
  transform: rotateX(6deg) rotateY(-6deg) scale(1.06);
  box-shadow:
    0 25px 50px rgba(0,0,0,0.6),
    0 0 35px rgba(212,168,67,0.35);
}
/* ==========================================================
   2️⃣ STAR PARALLAX BACKGROUND – SAFE VERSION
   ========================================================== */

html {
  background-color: var(--bg-base);
}

body {
  position: relative;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(212,168,67,0.06), transparent),
    radial-gradient(2px 2px at 60% 70%, rgba(212,168,67,0.04), transparent),
    radial-gradient(1px 1px at 40% 50%, rgba(212,168,67,0.03), transparent);
  background-size: 300px 300px;
  animation: stars 200s linear infinite;
}

@keyframes stars {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: -75px -75px, -50px -50px, -25px -25px; }
}

#content-wrapper,
#main-content,
main {
  position: relative;
  z-index: 1; /* garde les cartes au-dessus */
}
/* ==========================================================
   3️⃣ GOLD NEON TITLE (SUBTLE PREMIUM)
   ========================================================== */

.book-title {
  transition: text-shadow 0.3s ease;
}

.book-card:hover .book-title {
  text-shadow:
    0 0 10px var(--accent-gold),
    0 0 20px var(--accent-gold),
    0 0 35px rgba(212,168,67,0.6);
}

/* ==========================================================
   4️⃣ CINEMATIC PAGE FADE
   ========================================================== */

#main-content,
#content-wrapper {
  animation: fadeInSlide 0.6s ease-out;
}

@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* ==========================================================
   🎭 SAFE ENHANCEMENTS (NO JS CONFLICT)
   ========================================================== */

/* Amélioration visuelle sans toucher au transform JS */

div[onclick^="window.location"] {
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

/* On laisse le translateY géré par Ubooquity */
div[onclick^="window.location"]:hover {
  box-shadow:
    0 15px 40px rgba(0,0,0,0.6),
    0 0 25px rgba(212,168,67,0.25);
  border-color: var(--border-accent);
}

/* Glow titre – safe */
div[onclick^="window.location"] > div:last-child > div:first-child {
  transition: text-shadow 0.3s ease;
}

div[onclick^="window.location"]:hover > div:last-child > div:first-child {
  text-shadow:
    0 0 8px var(--accent-gold),
    0 0 18px var(--accent-gold);
}
