/* =============================================
   LIBRA v2 — style.css
   Theme: Dark Editorial + Living Library
   ============================================= */

:root {
  --bg:        #0b0b0b;
  --surface:   #141414;
  --surface2:  #1c1c1c;
  --surface3:  #242424;
  --border:    #282828;
  --border2:   #333;
  --text:      #e5e0d8;
  --muted:     #6e6e66;
  --muted2:    #4a4a44;
  --accent:    #c8a86c;
  --accent2:   #e2c688;
  --white:     #f4f0e8;
  --red:       #c86c6c;
  --font-d:    'Playfair Display', Georgia, serif;
  --font-b:    'DM Sans', sans-serif;
  --font-m:    'DM Mono', monospace;
  --r:         4px;
  --rl:        12px;
  --ease:      cubic-bezier(.4,0,.2,1);
  --t:         0.28s var(--ease);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::selection { background: var(--accent); color: #000; }

/* ── NAV ─────────────────────────────────────── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(11,11,11,.88);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--t);
}
.nav.scrolled { border-bottom-color: rgba(200,168,108,.2); }

.nav-inner {
  max-width: 1300px; margin: 0 auto; padding: 0 32px;
  height: 66px; display: flex; align-items: center; justify-content: space-between;
}

.logo {
  font-family: var(--font-m); font-size: 1.05rem;
  letter-spacing: .28em; color: var(--accent); text-decoration: none; font-weight: 500;
}

.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-links a {
  color: var(--muted); text-decoration: none; font-size: .85rem;
  letter-spacing: .04em; transition: color var(--t);
}
.nav-links a:hover { color: var(--text); }

.nav-btn {
  padding: 8px 18px; font-family: var(--font-b); font-size: .78rem;
  letter-spacing: .06em; border-radius: var(--r); cursor: pointer; transition: all var(--t);
}
.ghost-btn { background: transparent; border: 1px solid var(--border2); color: var(--muted); }
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.accent-btn { background: var(--accent); border: none; color: #000; font-weight: 500; }
.accent-btn:hover { background: var(--accent2); }

.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.hamburger span { display: block; width: 22px; height: 1.5px; background: var(--text); transition: var(--t); }

/* ── MOBILE MENU ─────────────────────────────── */
.mobile-menu {
  position: fixed; top: 66px; left: 0; right: 0; z-index: 99;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 20px 24px; display: flex; flex-direction: column; gap: 14px;
  transform: translateY(-110%); transition: transform var(--t);
}
.mobile-menu.open { transform: translateY(0); }
.mobile-link { color: var(--text); text-decoration: none; font-size: .95rem; padding: 6px 0; border-bottom: 1px solid var(--border); }
.mobile-btn { padding: 12px 16px; font-family: var(--font-b); font-size: .875rem; border-radius: var(--r); cursor: pointer; }
.ghost-mob { background: transparent; border: 1px solid var(--border2); color: var(--muted); }
.accent-mob { background: var(--accent); border: none; color: #000; font-weight: 500; }

/* ── HERO ────────────────────────────────────── */
.hero {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 110px 32px 80px; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(200,168,108,.08) 0%, transparent 65%),
    radial-gradient(ellipse 50% 80% at 15% 90%, rgba(200,168,108,.04) 0%, transparent 60%);
}
.hero-bg-text {
  position: absolute; font-family: var(--font-d); font-size: clamp(100px,22vw,300px);
  font-weight: 700; color: rgba(200,168,108,.025); letter-spacing: -.06em;
  pointer-events: none; user-select: none; top: 50%; left: 50%; transform: translate(-50%,-50%);
  white-space: nowrap;
}
.hero-eyebrow {
  font-family: var(--font-m); font-size: .72rem; letter-spacing: .22em; color: var(--accent);
  text-transform: uppercase; margin-bottom: 28px; animation: fadeUp .7s ease both;
}
.hero-title {
  font-family: var(--font-d); font-size: clamp(2.6rem,6.5vw,5.5rem);
  line-height: 1.1; font-weight: 400; color: var(--white); margin-bottom: 22px;
  animation: fadeUp .7s ease .1s both;
}
.hero-title span { display: block; }
.hero-title em { display: block; font-style: italic; color: var(--accent); }
.hero-sub { font-size: 1rem; color: var(--muted); max-width: 460px; margin-bottom: 40px; animation: fadeUp .7s ease .18s both; }

.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-bottom: 60px; animation: fadeUp .7s ease .26s both; }
.btn-primary {
  display: inline-block; background: var(--accent); color: #000; text-decoration: none;
  padding: 13px 32px; font-size: .875rem; font-weight: 500; letter-spacing: .04em;
  border-radius: var(--r); transition: all var(--t);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-2px); }
.btn-ghost {
  display: inline-block; border: 1px solid var(--border2); color: var(--muted);
  background: transparent; padding: 13px 32px; font-family: var(--font-b); font-size: .875rem;
  letter-spacing: .04em; border-radius: var(--r); cursor: pointer; transition: all var(--t);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.hero-stats { display: flex; align-items: center; gap: 36px; animation: fadeUp .7s ease .34s both; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-num { font-family: var(--font-d); font-size: 1.9rem; color: var(--accent); font-weight: 700; }
.stat-label { font-size: .7rem; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.stat-sep { width: 1px; height: 44px; background: var(--border); }

/* ── SECTION SHARED ──────────────────────────── */
.section-header { text-align: center; margin-bottom: 48px; }
.section-tag { font-family: var(--font-m); font-size: .68rem; letter-spacing: .22em; color: var(--accent); text-transform: uppercase; display: block; margin-bottom: 10px; }
.section-header h2 { font-family: var(--font-d); font-size: clamp(1.8rem,4vw,2.8rem); font-weight: 400; color: var(--white); }

/* ── BOOKS SECTION ───────────────────────────── */
.books-section { max-width: 1300px; margin: 0 auto; padding: 100px 32px; }

.controls-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-bottom: 48px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.filter-btn {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 7px 18px; font-family: var(--font-b); font-size: .78rem; letter-spacing: .05em;
  border-radius: 100px; cursor: pointer; transition: all var(--t);
}
.filter-btn:hover { border-color: var(--muted); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 500; }

.search-wrap { position: relative; flex-shrink: 0; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1rem; pointer-events: none; }
.search-input {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 9px 16px 9px 34px; font-family: var(--font-b); font-size: .85rem;
  border-radius: var(--r); width: 220px; outline: none; transition: border-color var(--t);
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted2); }

/* ── GRID ────────────────────────────────────── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 28px;
}

.book-card { cursor: pointer; animation: fadeUp .45s ease both; }
.book-card:hover { transform: translateY(-7px); transition: transform var(--t); }
.book-card.hidden { display: none; }

.cover-wrap {
  position: relative; width: 100%; aspect-ratio: 2/3;
  border-radius: var(--rl); overflow: hidden;
  border: 1px solid rgba(255,255,255,.06); margin-bottom: 14px;
  background: var(--surface2);
}

.cover-img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; transition: opacity var(--t);
}

.cover-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 16px;
  text-align: center;
}
.fallback-letter {
  font-family: var(--font-d); font-size: 3.5rem; font-style: italic;
  color: rgba(255,255,255,.15); line-height: 1;
}
.fallback-title {
  font-family: var(--font-d); font-size: .7rem; color: rgba(255,255,255,.25);
  line-height: 1.3; max-width: 90%;
}

.cover-hover {
  position: absolute; inset: 0; background: rgba(200,168,108,.18);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t); border-radius: var(--rl);
}
.cover-hover span {
  border: 1px solid var(--accent); color: var(--accent); padding: 9px 20px;
  font-size: .75rem; letter-spacing: .1em; border-radius: var(--r); background: rgba(0,0,0,.65);
}
.book-card:hover .cover-hover { opacity: 1; }

.cover-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.card-genre { font-family: var(--font-m); font-size: .62rem; letter-spacing: .15em; color: var(--accent); text-transform: uppercase; margin-bottom: 5px; }
.card-title { font-family: var(--font-d); font-size: .95rem; font-weight: 400; color: var(--white); line-height: 1.3; margin-bottom: 3px; }
.card-author { font-size: .78rem; color: var(--muted); }
.card-year { font-size: .72rem; color: var(--muted2); font-family: var(--font-m); margin-top: 3px; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.inline-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: inherit; text-decoration: underline; }

/* ── COMMENTS ────────────────────────────────── */
.comments-section { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 100px 32px; }
.comments-container { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1.3fr; gap: 56px; align-items: start; }
.comment-form-wrap h3 { font-family: var(--font-d); font-size: 1.5rem; font-weight: 400; color: var(--white); margin-bottom: 22px; }
.comment-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, textarea, select {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 15px; font-family: var(--font-b); font-size: .875rem;
  border-radius: var(--r); width: 100%; outline: none; transition: border-color var(--t);
  resize: vertical;
}
input::placeholder, textarea::placeholder { color: var(--muted2); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236e6e66' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.star-rating { display: flex; gap: 4px; }
.star { font-size: 1.5rem; color: var(--border2); cursor: pointer; transition: color var(--t); }
.star.active, .star:hover { color: var(--accent); }
.submit-btn { background: var(--accent); color: #000; border: none; padding: 11px 26px; font-family: var(--font-b); font-size: .875rem; font-weight: 500; letter-spacing: .04em; border-radius: var(--r); cursor: pointer; transition: all var(--t); white-space: nowrap; }
.submit-btn:hover { background: var(--accent2); transform: translateY(-1px); }
.submit-btn.full-w { width: 100%; margin-top: 10px; }
.comments-list { display: flex; flex-direction: column; gap: 16px; max-height: 500px; overflow-y: auto; padding-right: 6px; }
.comment-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--rl); padding: 18px 22px; animation: fadeUp .4s ease both; }
.comment-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #000; display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: .85rem; flex-shrink: 0; }
.cmeta { flex: 1; }
.cmeta strong { display: block; font-size: .875rem; color: var(--white); }
.cbk { font-size: .73rem; color: var(--accent); font-family: var(--font-m); }
.cstars { color: var(--accent); font-size: .85rem; }
.comment-card p { font-size: .85rem; color: var(--muted); line-height: 1.7; }

/* ── FOOTER ──────────────────────────────────── */
.footer { max-width: 1300px; margin: 0 auto; padding: 56px 32px 28px; }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 28px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.footer-inner p { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.footer-note { font-size: .78rem; color: var(--muted); text-align: right; line-height: 1.9; }
.footer-bottom { font-size: .73rem; color: var(--muted2); text-align: center; letter-spacing: .05em; }

/* ── OVERLAYS & MODALS ───────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.8);
  backdrop-filter: blur(10px); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity var(--t);
}
.overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; max-width: 520px; width: 100%; position: relative;
  transform: translateY(18px); transition: transform var(--t);
  max-height: 92vh; overflow-y: auto;
}
.overlay.open .modal { transform: translateY(0); }

.close-btn {
  position: absolute; top: 14px; right: 14px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: .78rem;
  display: flex; align-items: center; justify-content: center; transition: all var(--t); z-index: 2;
}
.close-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal-tag { font-family: var(--font-m); font-size: .64rem; letter-spacing: .18em; color: var(--accent); text-transform: uppercase; display: block; margin-bottom: 8px; }
.modal h2 { font-family: var(--font-d); font-size: 1.75rem; font-weight: 400; color: var(--white); margin-bottom: 8px; }
.modal-sub { font-size: .85rem; color: var(--muted); margin-bottom: 24px; line-height: 1.7; }
.modal-sub em { color: var(--accent); font-style: normal; }

/* Book Modal */
.book-modal { display: flex; gap: 28px; max-width: 600px; }
.bm-cover-wrap { width: 110px; flex-shrink: 0; }
.bm-cover-img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px; border: 1px solid rgba(255,255,255,.08); }
.bm-cover-fb { width: 100%; aspect-ratio: 2/3; border-radius: 8px; border: 1px solid rgba(255,255,255,.08); background: var(--surface2); display: flex; align-items: center; justify-content: center; font-family: var(--font-d); font-size: 2rem; font-style: italic; color: rgba(255,255,255,.15); }
.bm-body { flex: 1; }
.bm-author { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.bm-desc { font-size: .85rem; color: var(--muted); line-height: 1.75; margin-bottom: 22px; }
.sources-label { font-size: .75rem; color: var(--muted2); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 12px; font-family: var(--font-m); }
.source-list { display: flex; flex-direction: column; gap: 10px; }
.source-btn { display: flex; align-items: center; gap: 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--rl); padding: 15px 18px; text-decoration: none; color: var(--text); transition: all var(--t); }
.source-btn:hover { border-color: var(--accent); background: rgba(200,168,108,.07); transform: translateX(4px); }
.src-icon { font-size: 1.4rem; }
.source-btn div { flex: 1; }
.source-btn strong { display: block; color: var(--white); font-size: .9rem; }
.source-btn span { font-size: .75rem; color: var(--muted); }
.src-arr { color: var(--accent); font-size: 1rem; }

/* Admin Modal */
.admin-modal { max-width: 580px; }
.ai-row { display: flex; gap: 10px; margin-bottom: 24px; }
.ai-input { flex: 1; font-size: .9rem; }
.ai-btn {
  background: var(--accent); color: #000; border: none; padding: 11px 22px;
  font-family: var(--font-b); font-size: .85rem; font-weight: 500; border-radius: var(--r);
  cursor: pointer; transition: all var(--t); white-space: nowrap; min-width: 110px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.ai-btn:hover { background: var(--accent2); }
.ai-btn:disabled { opacity: .6; cursor: not-allowed; }

.ai-preview { animation: fadeUp .35s ease both; }
.preview-top { display: flex; gap: 20px; margin-bottom: 16px; }
.preview-cover-wrap { width: 90px; flex-shrink: 0; position: relative; aspect-ratio: 2/3; border-radius: 8px; overflow: hidden; background: var(--surface2); border: 1px solid var(--border); }
.preview-cover { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.preview-fb { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-d); font-size: 2rem; font-style: italic; color: rgba(255,255,255,.15); }
.cover-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.5); }
.preview-fields { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fg { display: flex; flex-direction: column; gap: 5px; }
.fg label { font-size: .72rem; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; font-family: var(--font-m); }

/* Suggest Modal */
.suggest-modal { max-width: 480px; }
.suggest-fields { display: flex; flex-direction: column; gap: 12px; margin-bottom: 4px; }

/* ── ANIMATIONS ──────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

.spinner { display: inline-block; animation: spin .8s linear infinite; }

/* ── TOAST ───────────────────────────────────── */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--accent); color: var(--text);
  padding: 11px 28px; border-radius: 100px; font-size: .85rem; z-index: 999;
  animation: fadeUp .3s ease; box-shadow: 0 8px 32px rgba(0,0,0,.5);
  white-space: nowrap; pointer-events: none;
}

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 900px) {
  .comments-container { grid-template-columns: 1fr; gap: 36px; }
  .book-modal { flex-direction: column; }
  .bm-cover-wrap { width: 80px; }
}

@media (max-width: 768px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }
  .controls-row { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
  .search-wrap { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; }
  .footer-note { text-align: left; }
  .hero-stats { gap: 20px; }
}

@media (max-width: 520px) {
  .nav-inner { padding: 0 20px; }
  .hero { padding: 100px 20px 60px; }
  .books-section, .comments-section { padding: 64px 20px; }
  .books-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .hero-stats { flex-direction: column; gap: 10px; }
  .stat-sep { width: 44px; height: 1px; }
  .hero-actions { flex-direction: column; align-items: center; }
  .modal { padding: 24px 18px; }
  .ai-row { flex-direction: column; }
  .preview-top { flex-direction: column; }
  .preview-cover-wrap { width: 70px; }
  .form-footer { flex-direction: column; align-items: flex-start; }
  .submit-btn { width: 100%; }
}