/* ── PageVault Frontend CSS ─────────────────────────────────────────────────── */

:root {
  --pv-ink:    #0d0d0d;
  --pv-paper:  #f5f0e8;
  --pv-cream:  #faf7f2;
  --pv-gold:   #c9a84c;
  --pv-gold-l: #f5ecd0;
  --pv-rust:   #b85c38;
  --pv-muted:  #a09880;
  --pv-border: #e0d8cc;
  --pv-white:  #ffffff;
}

/* ── STORE ──────────────────────────────────────────────────────────────────── */

#pv-store-app { font-family: Georgia, serif; }

.pv-book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
  padding: 8px 0 40px;
}

.pv-book-card {
  background: var(--pv-white);
  border: 1px solid var(--pv-border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pv-book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.pv-book-cover {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pv-paper);
}

.pv-book-cover-inner {
  width: 110px;
  height: 158px;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  box-shadow: 4px 4px 16px rgba(0,0,0,0.22), -2px 0 0 rgba(0,0,0,0.12);
  position: relative;
}

.pv-book-cover-inner::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 8px;
  background: rgba(0,0,0,0.18);
  border-radius: 3px 0 0 3px;
}

.pv-cover-title {
  font-size: 13px;
  font-weight: 700;
  color: white;
  line-height: 1.3;
}

.pv-cover-author {
  font-size: 10px;
  color: rgba(255,255,255,0.65);
  margin-top: 8px;
}

.pv-book-info {
  padding: 14px;
  border-top: 1px solid var(--pv-border);
}

.pv-book-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 4px;
  color: var(--pv-ink);
}

.pv-book-auth {
  font-size: 12px;
  color: var(--pv-muted);
  margin: 0 0 10px;
  font-style: italic;
}

.pv-book-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.pv-book-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--pv-ink);
}

.pv-genre-tag {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pv-gold);
  background: var(--pv-gold-l);
  padding: 3px 8px;
  border-radius: 3px;
}

.pv-buy-btn {
  width: 100%;
  padding: 9px;
  background: var(--pv-ink);
  color: white;
  border: none;
  font-family: Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.2s;
}

.pv-buy-btn:hover { background: var(--pv-rust); }

/* ── MODAL / OVERLAY ────────────────────────────────────────────────────────── */

.pv-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,13,13,0.72);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.pv-modal {
  background: var(--pv-cream);
  border-radius: 8px;
  width: 100%;
  max-width: 420px;
  padding: 32px;
  position: relative;
  animation: pvSlideUp 0.25s ease;
  font-family: Georgia, serif;
}

@keyframes pvSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.pv-modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  color: var(--pv-muted);
}

.pv-modal-title {
  font-size: 20px;
  margin: 0 0 6px;
  color: var(--pv-ink);
}

.pv-modal-sub {
  font-size: 13px;
  color: var(--pv-muted);
  margin: 0 0 20px;
}

.pv-form-group { margin-bottom: 14px; }

.pv-form-group label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--pv-muted);
  margin-bottom: 5px;
}

.pv-form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--pv-border);
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 15px;
  background: white;
  color: var(--pv-ink);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.pv-form-group input:focus { border-color: var(--pv-gold); }

.pv-order-total {
  background: var(--pv-paper);
  border: 1px solid var(--pv-border);
  border-radius: 4px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0;
  font-size: 14px;
}

.pv-order-total span:last-child {
  font-size: 20px;
  font-weight: 700;
}

.pv-pay-btn {
  width: 100%;
  padding: 14px;
  background: var(--pv-ink);
  color: white;
  border: none;
  border-radius: 4px;
  font-family: Georgia, serif;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

.pv-pay-btn:hover { background: #2c6a3a; }
.pv-pay-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pv-secure-note {
  text-align: center;
  font-size: 11px;
  color: var(--pv-muted);
  margin-top: 10px;
  letter-spacing: 0.04em;
}

/* Confirm box */
.pv-confirm-box { text-align: center; }

.pv-confirm-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.pv-confirm-box h2 { margin: 0 0 12px; font-size: 22px; }
.pv-confirm-box p  { color: var(--pv-muted); font-size: 14px; margin: 0 0 12px; }

.pv-email-box {
  background: var(--pv-gold-l);
  border: 1px solid var(--pv-gold);
  border-radius: 4px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--pv-ink);
  margin: 0 0 16px;
}

.pv-confirm-note { font-size: 13px; color: var(--pv-muted); line-height: 1.6; }

.pv-close-confirm-btn {
  margin-top: 20px;
  padding: 10px 28px;
  background: var(--pv-ink);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 14px;
}

/* ── READER ─────────────────────────────────────────────────────────────────── */

#pv-reader-app {
  font-family: Georgia, serif;
  min-height: 80vh;
}

.pv-reader-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--pv-muted);
}

.pv-reader-state h2 { color: var(--pv-ink); margin-bottom: 12px; }

.pv-back-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 24px;
  background: var(--pv-ink);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
}

.pv-reader-topbar {
  background: var(--pv-ink);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.pv-reader-brand {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pv-reader-controls { display: flex; gap: 6px; }

.pv-ctrl-btn {
  padding: 5px 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
  font-family: Georgia, serif;
}

.pv-ctrl-btn:hover { background: rgba(255,255,255,0.2); }
.pv-danger-btn { border-color: #e07060 !important; color: #ffb8a8 !important; }
.pv-danger-btn:hover { background: var(--pv-rust) !important; color: white !important; }

.pv-expiry-banner {
  background: #fff8e6;
  border-bottom: 1px solid #f0d78c;
  padding: 8px 20px;
  font-size: 13px;
  color: #7a5c00;
  text-align: center;
}

.pv-book-header {
  padding: 40px 20px 28px;
  text-align: center;
  border-bottom: 1px solid var(--pv-border);
  background: white;
}

.pv-book-title {
  font-size: clamp(22px, 4vw, 34px);
  margin: 0 0 8px;
  color: var(--pv-ink);
  line-height: 1.2;
}

.pv-book-author {
  font-size: 14px;
  color: var(--pv-muted);
  font-style: italic;
  margin: 0;
}

.pv-progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--pv-paper);
  border-bottom: 1px solid var(--pv-border);
}

.pv-progress-label { font-size: 12px; color: var(--pv-muted); white-space: nowrap; }
.pv-progress-pct   { font-size: 12px; color: var(--pv-muted); white-space: nowrap; }

.pv-progress-track {
  flex: 1;
  height: 5px;
  background: var(--pv-border);
  border-radius: 3px;
  overflow: hidden;
}

.pv-progress-fill {
  height: 100%;
  background: var(--pv-gold);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.pv-chapter-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--pv-border);
  background: white;
  scrollbar-width: thin;
}

.pv-chapter-tab {
  padding: 6px 14px;
  border: 1px solid var(--pv-border);
  border-radius: 3px;
  background: none;
  font-family: Georgia, serif;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--pv-muted);
  transition: all 0.15s;
}

.pv-chapter-tab:hover  { border-color: var(--pv-gold); color: var(--pv-gold); }
.pv-chapter-tab.active { background: var(--pv-ink); color: white; border-color: var(--pv-ink); }

.pv-chapter-content {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  line-height: 1.9;
  font-size: 17px;
  color: #2a2520;
}

.pv-chapter-content h2 {
  font-size: 24px;
  margin: 0 0 24px;
  color: var(--pv-ink);
}

.pv-chapter-content p { margin: 0 0 20px; text-align: justify; hyphens: auto; }

.pv-chapter-content p:first-of-type::first-letter {
  font-size: 56px;
  float: left;
  line-height: 0.82;
  margin: 6px 6px 0 0;
  color: var(--pv-rust);
  font-weight: 700;
}

.pv-chapter-num-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--pv-gold);
  margin-bottom: 8px;
}

.pv-bottom-nav {
  display: flex;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--pv-border);
  background: white;
  position: sticky;
  bottom: 0;
}

.pv-nav-btn {
  padding: 9px 22px;
  border: 1px solid var(--pv-border);
  background: white;
  font-family: Georgia, serif;
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  color: var(--pv-ink);
}

.pv-nav-btn:hover   { background: var(--pv-ink); color: white; border-color: var(--pv-ink); }
.pv-nav-btn:disabled{ opacity: 0.3; cursor: not-allowed; }
.pv-nav-btn:disabled:hover { background: white; color: var(--pv-ink); border-color: var(--pv-border); }
.pv-next-btn { background: var(--pv-ink); color: white; }
.pv-next-btn:hover { background: var(--pv-rust); border-color: var(--pv-rust); }

/* Delete modal */
.pv-delete-box { max-width: 360px; }
.pv-delete-box h3 { margin: 0 0 12px; font-size: 18px; }
.pv-delete-box p  { font-size: 14px; color: var(--pv-muted); line-height: 1.6; margin: 0 0 20px; }

.pv-delete-btns { display: flex; gap: 10px; }

.pv-cancel-btn {
  flex: 1; padding: 10px;
  border: 1px solid var(--pv-border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 14px;
}

.pv-delete-btn {
  flex: 1; padding: 10px;
  background: #c0392b;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
}

/* Spinner */
.pv-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--pv-border);
  border-top-color: var(--pv-gold);
  border-radius: 50%;
  animation: pvSpin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes pvSpin { to { transform: rotate(360deg); } }

/* Dark theme support */
.pv-dark #pv-reader-main {
  background: #1a1612;
}
.pv-dark .pv-chapter-content { color: #d4cdbf; }
.pv-dark .pv-book-header,
.pv-dark .pv-bottom-nav,
.pv-dark .pv-chapter-tabs { background: #221e19; border-color: #3a342c; }

@media (max-width: 480px) {
  .pv-ctrl-btn { padding: 4px 7px; font-size: 11px; }
  .pv-chapter-content { padding: 28px 16px 60px; font-size: 16px; }
  .pv-book-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
}
