/* ═══════════════════════════════════════════════════════
   THE QUANT RAVEN — Stylesheet
   Aesthetic: Dark editorial luxury · Gold & obsidian
   Fonts: Playfair Display (display) + DM Sans (body)
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,900;1,400;1,700&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:          #0b0c0f;
  --bg-2:        #111318;
  --bg-3:        #181a21;
  --surface:     #1e2028;
  --surface-2:   #252830;
  --border:      #2a2d38;
  --border-light:#363a48;

  --gold:        #c9a84c;
  --gold-light:  #e2c47a;
  --gold-dim:    #8a6e30;
  --gold-glow:   rgba(201,168,76,.18);

  --text:        #e8e4da;
  --text-muted:  #8b8d96;
  --text-faint:  #4a4d58;

  --danger:      #c0392b;
  --success:     #27ae60;
  --info:        #2980b9;
  --warning:     #e67e22;

  --radius:      6px;
  --radius-lg:   12px;
  --transition:  .22s cubic-bezier(.4,0,.2,1);
  --font-display:'Playfair Display', Georgia, serif;
  --font-body:   'DM Sans', system-ui, sans-serif;

  --shadow-sm:   0 2px 8px rgba(0,0,0,.45);
  --shadow-md:   0 6px 24px rgba(0,0,0,.6);
  --shadow-gold: 0 0 28px rgba(201,168,76,.12);
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
a  { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* ── Grain overlay ─────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  opacity: .028;
  pointer-events: none;
  z-index: 9999;
}

/* ══════════════════════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════════════════════ */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(1.5rem, 5vw, 4rem);
  height: 68px;
  background: rgba(11,12,15,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex; align-items: center; gap: .75rem;
}

.nav-logo {
  height: 38px; width: auto;
  filter: drop-shadow(0 0 6px var(--gold-dim));
}

.nav-brand-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--text);
  white-space: nowrap;
}

.nav-brand-text span { color: var(--gold); }

.nav-links {
  display: flex; align-items: center; gap: 2rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  position: relative;
  transition: color var(--transition);
}

.nav-links a::after {
  content: '';
  position: absolute; bottom: -4px; left: 0;
  width: 0; height: 1px;
  background: var(--gold);
  transition: width var(--transition);
}

.nav-links a:hover { color: var(--gold); }
.nav-links a:hover::after { width: 100%; }

/* ══════════════════════════════════════════════════════════
   HERO
══════════════════════════════════════════════════════════ */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 6rem clamp(1.5rem, 8vw, 6rem) 5rem;
  overflow: hidden;
}

/* Radial gold orb */
.hero::before {
  content: '';
  position: absolute;
  top: -10%; left: 50%; transform: translateX(-50%);
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(201,168,76,.09) 0%, transparent 68%);
  pointer-events: none;
}

/* Horizontal rule decoration */
.hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}

.hero-eyebrow {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  padding: .3rem .9rem;
  margin-bottom: 2rem;
  animation: fadeInUp .6s ease both;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 6vw, 5.5rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 1.5rem;
  animation: fadeInUp .7s .1s ease both;
}

.hero-title em {
  font-style: italic;
  color: var(--gold);
}

.hero-subtitle {
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 2.8rem;
  font-weight: 300;
  animation: fadeInUp .7s .2s ease both;
}

.hero-cta {
  display: flex; align-items: center; gap: 1rem;
  justify-content: center; flex-wrap: wrap;
  animation: fadeInUp .7s .3s ease both;
}

/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .7rem 1.7rem;
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .05em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn-gold {
  background: var(--gold);
  color: #0b0c0f;
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,.25);
}
.btn-gold:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #0b0c0f;
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(201,168,76,.35);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-light);
}
.btn-outline:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--gold); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.btn-sm {
  padding: .4rem 1rem;
  font-size: .8rem;
}

/* ══════════════════════════════════════════════════════════
   SECTION TITLES
══════════════════════════════════════════════════════════ */
.section {
  padding: 5rem clamp(1.5rem, 6vw, 5rem);
}

.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.section-eyebrow {
  display: block;
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: .8rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 3.5vw, 3rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.section-title em { font-style: italic; color: var(--gold); }

.section-rule {
  display: block;
  width: 48px; height: 2px;
  background: var(--gold);
  margin: 1.2rem auto 0;
}

/* ══════════════════════════════════════════════════════════
   EBOOK CARDS
══════════════════════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.ebook-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
  display: flex; flex-direction: column;
  position: relative;
}

.ebook-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.ebook-card:hover {
  border-color: var(--gold-dim);
  transform: translateY(-5px);
  box-shadow: var(--shadow-gold), var(--shadow-md);
}
.ebook-card:hover::before { opacity: 1; }

.card-cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  background: var(--bg-3);
}

.card-cover-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(145deg, var(--bg-3) 0%, var(--surface-2) 100%);
  display: flex; align-items: center; justify-content: center;
}

.card-cover-placeholder svg {
  width: 48px; height: 48px;
  color: var(--text-faint);
}

.card-body {
  padding: 1.5rem;
  display: flex; flex-direction: column; flex: 1;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: .6rem;
}

.card-description {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 1.2rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto;
}

.card-price {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
}

.card-price-free {
  color: var(--success);
  font-size: 1rem;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════
   ABOUT SECTION
══════════════════════════════════════════════════════════ */
.about-section {
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.about-inner {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.about-inner p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-top: 1.2rem;
  line-height: 1.8;
}

/* ══════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════ */
footer {
  padding: 2.5rem clamp(1.5rem, 6vw, 5rem);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem;
}

.footer-brand {
  font-family: var(--font-display);
  font-size: .95rem;
  color: var(--text-muted);
}

.footer-brand span { color: var(--gold); }

.footer-note {
  font-size: .8rem;
  color: var(--text-faint);
}

/* ══════════════════════════════════════════════════════════
   ADMIN LAYOUT
══════════════════════════════════════════════════════════ */
.admin-layout {
  display: flex; min-height: 100vh;
}

.admin-sidebar {
  width: 240px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 2rem 0;
  display: flex; flex-direction: column;
  flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.sidebar-brand-name {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.sidebar-brand-name span { color: var(--gold); }
.sidebar-brand-sub {
  font-size: .72rem;
  color: var(--text-faint);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: .2rem;
}

.sidebar-nav {
  list-style: none;
  padding: 0 .75rem;
  flex: 1;
}

.sidebar-nav li + li { margin-top: .2rem; }

.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem;
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--surface);
  color: var(--gold);
}

.sidebar-nav svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.admin-main {
  flex: 1;
  padding: 2.5rem clamp(1.5rem, 4vw, 3rem);
  overflow-x: auto;
}

.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap; gap: 1rem;
}

.admin-page-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════
   ADMIN TABLE
══════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-light);
}

th {
  padding: .9rem 1.25rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

td {
  padding: 1rem 1.25rem;
  font-size: .9rem;
  color: var(--text);
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,.02); }

.table-cover {
  width: 44px; height: 56px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-3);
}

.table-price {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--gold);
}

.table-actions {
  display: flex; gap: .5rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-faint);
}

.empty-state svg {
  width: 48px; height: 48px;
  margin: 0 auto 1rem;
  color: var(--text-faint);
}

/* ══════════════════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════════════════ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  max-width: 680px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .5rem;
}

.form-control {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: .65rem 1rem;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}

.form-control::placeholder { color: var(--text-faint); }

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.file-upload-area {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.file-upload-area:hover {
  border-color: var(--gold-dim);
  background: var(--gold-glow);
}

.file-upload-area input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.file-upload-icon {
  font-size: 2rem;
  margin-bottom: .5rem;
  color: var(--text-faint);
}

.file-upload-text {
  font-size: .875rem;
  color: var(--text-muted);
}

.form-hint {
  font-size: .78rem;
  color: var(--text-faint);
  margin-top: .35rem;
}

.field-error {
  font-size: .8rem;
  color: var(--danger);
  margin-top: .3rem;
}

.form-actions {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md), var(--shadow-gold);
  position: relative;
}

.login-card::before {
  content: '';
  position: absolute; top: 0; left: 10%; right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 0 0 2px 2px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img {
  height: 52px;
  margin: 0 auto 1rem;
  filter: drop-shadow(0 0 8px var(--gold-dim));
}

.login-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: .4rem;
  color: var(--text);
}

.login-subtitle {
  text-align: center;
  font-size: .82rem;
  color: var(--text-faint);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

/* ══════════════════════════════════════════════════════════
   FLASH MESSAGES
══════════════════════════════════════════════════════════ */
.flash-container {
  padding: .75rem clamp(1.5rem, 6vw, 5rem);
}

.flash {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1.2rem;
  border-radius: var(--radius);
  font-size: .875rem;
  border: 1px solid transparent;
  margin-bottom: .5rem;
}

.flash-success { background: rgba(39,174,96,.12); border-color: rgba(39,174,96,.3); color: #6fcf97; }
.flash-danger  { background: rgba(192,57,43,.12); border-color: rgba(192,57,43,.3); color: #e07070; }
.flash-info    { background: rgba(41,128,185,.12); border-color: rgba(41,128,185,.3); color: #74b9f5; }
.flash-warning { background: rgba(230,126,34,.12); border-color: rgba(230,126,34,.3); color: #f0a05a; }

/* ══════════════════════════════════════════════════════════
   STATS CARDS (dashboard)
══════════════════════════════════════════════════════════ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: .4rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
}

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.animate-fade-in { animation: fadeIn .5s ease both; }

/* Staggered catalog cards */
.card-grid .ebook-card:nth-child(1) { animation: fadeInUp .5s .05s ease both; }
.card-grid .ebook-card:nth-child(2) { animation: fadeInUp .5s .10s ease both; }
.card-grid .ebook-card:nth-child(3) { animation: fadeInUp .5s .15s ease both; }
.card-grid .ebook-card:nth-child(4) { animation: fadeInUp .5s .20s ease both; }
.card-grid .ebook-card:nth-child(5) { animation: fadeInUp .5s .25s ease both; }
.card-grid .ebook-card:nth-child(6) { animation: fadeInUp .5s .30s ease both; }

/* ══════════════════════════════════════════════════════════
   DIVIDERS
══════════════════════════════════════════════════════════ */
.gold-divider {
  width: 60px; height: 1px;
  background: var(--gold-dim);
  margin: 2rem auto;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .nav-links { display: none; }

  .admin-sidebar {
    display: none;
  }

  .admin-main {
    padding: 1.5rem 1rem;
  }

  .form-card { padding: 1.5rem 1.25rem; }

  footer {
    flex-direction: column;
    text-align: center;
  }

  .hero-title { font-size: 2.3rem; }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .table-wrap { overflow-x: auto; }
}

/* ══════════════════════════════════════════════════════════
   UTILITY CLASSES
══════════════════════════════════════════════════════════ */
.text-gold   { color: var(--gold); }
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.gap-1 { gap: .5rem; }
.align-center { align-items: center; }
