/* ================================================================
   style.css — Kadim Kitap Design System
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Cinzel+Decorative:wght@400;700&family=IM+Fell+English:ital@0;1&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  --void:       #050505;
  --deep:       #0a0604;
  --wood:       #1a120c;
  --wood-light: #2d1f14;
  --parchment:  #d4c4a8;
  --parch-dark: #b8a882;
  --parch-aged: #c9b48a;
  --fire:       #ff6600;
  --fire-dim:   #cc4400;
  --gold:       #ffcc00;
  --gold-dim:   #cc9900;
  --blood:      #8b0000;
  --crimson:    #dc143c;

  --f-epic:    'Cinzel Decorative', 'Cinzel', serif;
  --f-heading: 'Cinzel', serif;
  --f-body:    'IM Fell English', serif;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--f-body); -webkit-font-smoothing: antialiased; }

/* ── Font helpers ───────────────────────────────────────────────── */
.font-epic    { font-family: var(--f-epic); }
.font-heading { font-family: var(--f-heading); }
.font-body    { font-family: var(--f-body); }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; }
::-webkit-scrollbar-track { background: var(--wood); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ═════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═════════════════════════════════════════════════════════════════ */
.login-body {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 60%, #150808 0%, var(--void) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Pulsing glow orb */
#glowOrb {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(139,0,0,.55) 0%, rgba(80,0,0,.28) 40%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
}

/* Embers */
#emberContainer { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.ember {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  pointer-events: none;
}

/* Glassmorphism panel */
.glass-panel {
  background: rgba(26,18,12,.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,204,0,.15);
  box-shadow: 0 0 40px rgba(139,0,0,.3), inset 0 1px 0 rgba(255,204,0,.1);
}

.login-panel {
  position: relative;
  z-index: 10;
  width: min(440px, 92vw);
  padding: 52px 44px 40px;
  border-radius: 4px;
  opacity: 0; /* animated in by JS */
}

.login-ornament {
  text-align: center;
  color: var(--gold);
  font-size: 26px;
  margin-bottom: 8px;
}

.login-title {
  text-align: center;
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,204,0,.4);
  margin-bottom: 6px;
  opacity: 0;
}

.login-subtitle {
  text-align: center;
  font-size: .9rem;
  font-style: italic;
  color: var(--parchment);
  opacity: 0;
  margin-bottom: 32px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.divider-line  { flex: 1; height: 1px; background: linear-gradient(to right, transparent, rgba(255,204,0,.3)); }
.divider-line:last-child { background: linear-gradient(to left, transparent, rgba(255,204,0,.3)); }
.divider-glyph { color: var(--gold); font-size: 13px; opacity: .6; }

.form-group   { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.field-label  {
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}
.field-input  {
  padding: 13px 15px;
  background: rgba(5,5,5,.7);
  border: 1px solid rgba(255,204,0,.18);
  border-radius: 2px;
  color: var(--parchment);
  font-size: 1rem;
  outline: none;
  transition: border-color .28s, box-shadow .28s;
}
.field-input:focus {
  border-color: rgba(255,204,0,.6);
  box-shadow: 0 0 12px rgba(255,204,0,.14);
}
.field-input::placeholder { color: rgba(212,196,168,.3); }

.login-error {
  padding: 11px 15px;
  background: rgba(139,0,0,.25);
  border: 1px solid rgba(220,20,60,.4);
  border-radius: 2px;
  color: #ff9999;
  font-size: .88rem;
  font-style: italic;
  margin-bottom: 14px;
  animation: fadeUp .3s ease;
}

.fire-btn {
  width: 100%;
  padding: 15px 24px;
  background: linear-gradient(135deg, #cc3300 0%, #ff6600 50%, #cc4400 100%);
  border: none;
  border-radius: 2px;
  color: #fff5e6;
  font-size: .82rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform .15s, opacity .2s;
  box-shadow: 0 0 20px rgba(255,102,0,.5);
}
.fire-btn:hover:not(:disabled) { transform: scale(1.02); }
.fire-btn:disabled { opacity: .5; cursor: not-allowed; }

.login-hint {
  margin-top: 26px;
  text-align: center;
  font-size: .72rem;
  color: rgba(212,196,168,.3);
  font-style: italic;
}

/* ── GSAP fire-text animation ───────────────────────────────────── */
@keyframes fireFlicker {
  0%,100% { text-shadow: 0 0 8px #ff6600, 0 0 20px #ff3300, 0 0 40px #cc2200; }
  25%      { text-shadow: 0 0 12px #ffaa00, 0 0 30px #ff6600, 0 0 50px #ff3300; }
  50%      { text-shadow: 0 0 6px #ff4400, 0 0 15px #cc2200, 0 0 35px #990000; }
  75%      { text-shadow: 0 0 15px #ffcc00, 0 0 35px #ff9900, 0 0 60px #ff6600; }
}
.fire-text { animation: fireFlicker 1.8s ease-in-out infinite; color: #ffaa55; }

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

/* ═════════════════════════════════════════════════════════════════
   REALM PAGE
   ═════════════════════════════════════════════════════════════════ */
.realm-body {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 20%, #150a04 0%, var(--void) 70%);
  display: flex;
  flex-direction: column;
  color: var(--parchment);
}

/* ── Book Opening Overlay ───────────────────────────────────────── */
#bookOverlay {
  position: fixed; inset: 0;
  z-index: 100;
  background: var(--void);
  display: flex; align-items: center; justify-content: center;
}
#particleContainer { position: fixed; inset: 0; z-index: 200; pointer-events: none; }

#bookWrap {
  position: relative;
  width: min(700px, 88vw);
  height: min(500px, 70vh);
  perspective: 1200px;
  opacity: 0;
}

#bookPages {
  position: absolute; inset: 0;
  display: flex;
  border-radius: 4px 12px 12px 4px;
  box-shadow: 0 30px 80px rgba(0,0,0,.8), 0 0 40px rgba(255,102,0,.08);
  overflow: hidden;
}
.book-page-half {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 30px;
  position: relative;
}
.book-page-half + .book-page-half { border-left: 2px solid rgba(107,74,26,.4); }

.parchment-bg {
  background-color: var(--parch-aged);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
.page-lines {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: repeating-linear-gradient(transparent, transparent 35px, rgba(107,74,26,.07) 35px, rgba(107,74,26,.07) 36px);
}

#bookCover {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #1a0c06 0%, #2d1a0a 40%, #1a0c06 100%);
  border-radius: 4px 12px 12px 4px;
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  box-shadow: inset -4px 0 12px rgba(0,0,0,.5), 4px 0 20px rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px;
}
.cover-line { width: 60%; height: 1px; background: linear-gradient(to right, transparent, rgba(255,204,0,.3), transparent); }
.cover-title { color: rgba(255,204,0,.7); font-size: clamp(.9rem,2.5vw,1.4rem); letter-spacing: .2em; text-align: center; padding: 0 20px; }

#bookOpenTitle {
  font-size: clamp(1rem, 3.5vw, 1.8rem);
  text-align: center;
  letter-spacing: .1em;
  line-height: 1.4;
  position: relative; z-index: 2;
  opacity: 0;
}

/* ── TopBar ─────────────────────────────────────────────────────── */
#topBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px clamp(16px,4vw,48px);
  background: rgba(5,5,5,.6);
  border-bottom: 1px solid rgba(255,204,0,.1);
  backdrop-filter: blur(10px);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-glyph { color: var(--gold); font-size: 20px; }
.topbar-name  { color: var(--gold); font-size: .82rem; letter-spacing: .15em; }
.topbar-user  { color: rgba(212,196,168,.5); font-size: .73rem; font-style: italic; }

.danger-btn {
  padding: 8px 18px;
  background: rgba(139,0,0,.2);
  border: 1px solid rgba(139,0,0,.4);
  border-radius: 2px;
  color: #ff9999;
  font-size: .65rem;
  letter-spacing: .15em;
  cursor: pointer;
  text-transform: uppercase;
  transition: background .2s;
}
.danger-btn:hover { background: rgba(139,0,0,.45); }

/* ── Main content area ──────────────────────────────────────────── */
#mainContent {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 48px) clamp(12px, 3vw, 48px) 68px;
  opacity: 0;
}

/* ── Book Spread (Writer) ───────────────────────────────────────── */
#bookSpreadWrapper { position: relative; width: min(860px, 96vw); }
#bookSpread {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: min(600px, 78vh);
  box-shadow: 0 40px 100px rgba(0,0,0,.7), 0 0 60px rgba(255,102,0,.04);
  border-radius: 4px 12px 12px 4px;
  overflow: hidden;
}

/* Left lore page */
#leftPage {
  padding: clamp(18px,3vw,36px);
  position: relative;
  overflow: hidden;
}
#leftPageContent {
  position: relative; z-index: 2;
  height: 100%; display: flex; flex-direction: column;
}
.lore-chapter-tag {
  font-size: .6rem; letter-spacing: .2em;
  color: rgba(107,74,26,.5);
  text-transform: uppercase;
  margin-bottom: 12px; flex-shrink: 0;
}
.lore-fire-title {
  font-size: clamp(.9rem,2.2vw,1.2rem);
  letter-spacing: .08em;
  margin-bottom: 14px;
  line-height: 1.4; flex-shrink: 0;
}
.lore-divider { height: 1px; background: rgba(107,74,26,.25); margin-bottom: 14px; flex-shrink: 0; }
.lore-text {
  color: #3a2010;
  font-size: clamp(.8rem,1.4vw,.92rem);
  line-height: 1.95;
  font-style: italic;
  flex: 1;
  overflow: hidden;
  white-space: pre-wrap;
}
.page-indicator {
  font-size: .58rem; letter-spacing: .13em;
  color: rgba(107,74,26,.35);
  text-align: center;
  margin-top: 10px; flex-shrink: 0;
  text-transform: uppercase;
}
.page-corner { position: absolute; color: rgba(107,74,26,.22); font-size: 18px; }
.page-corner.br { bottom: 14px; right: 14px; }
.page-corner.bl { bottom: 14px; left: 14px; }

/* Right writer page */
#rightPage {
  padding: clamp(18px,3vw,36px);
  position: relative;
  border-left: 2px solid rgba(107,74,26,.35);
  overflow: hidden;
}
#rightPageContent { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; gap: 14px; }

/* Writer identity */
.writer-id { display: flex; align-items: center; gap: 10px; }
.writer-id-glyph { color: var(--gold); font-size: 17px; }
.writer-id-label  { font-size: .63rem; letter-spacing: .18em; color: var(--gold); text-transform: uppercase; margin-bottom: 2px; }
.writer-id-name   { font-size: .88rem; color: #6b4a1a; font-style: italic; }

/* Textarea */
.parchment-area {
  flex: 1; position: relative;
}
.parchment-textarea {
  width: 100%; height: 100%; min-height: 160px;
  padding: 17px 15px;
  background: transparent;
  border: 1px solid rgba(107,74,26,.38);
  border-radius: 2px;
  color: #2a1a0a;
  font-size: 1rem; line-height: 1.82;
  font-style: italic; resize: vertical; outline: none;
  transition: border-color .28s, box-shadow .28s;
}
.parchment-textarea:focus {
  border-color: rgba(107,74,26,.7);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.08);
}
.parchment-textarea::placeholder { color: rgba(42,26,10,.35); }
.text-lines-overlay {
  position: absolute; inset: 0; pointer-events: none; border-radius: 2px;
  background-image: repeating-linear-gradient(transparent, transparent 35px, rgba(107,74,26,.07) 35px, rgba(107,74,26,.07) 36px);
}

.char-count { font-size: .72rem; color: rgba(107,74,26,.45); font-style: italic; text-align: right; margin-top: -8px; }

/* Seal button */
.seal-btn {
  padding: 13px 22px;
  background: linear-gradient(135deg, #8b1a00 0%, #cc3300 50%, #8b1a00 100%);
  border: 1px solid rgba(255,102,0,.28);
  border-radius: 2px; color: #fff5e6;
  font-size: .78rem; letter-spacing: .18em;
  text-transform: uppercase; cursor: pointer;
  transition: background .28s, transform .15s;
  box-shadow: 0 0 14px rgba(255,102,0,.35);
}
.seal-btn:hover:not(:disabled) { transform: scale(1.02); }
.seal-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Floating toast */
#toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(26,18,12,.96);
  border: 1px solid rgba(255,204,0,.4);
  border-radius: 3px; padding: 13px 26px;
  color: var(--gold); font-style: italic; font-size: 1rem;
  box-shadow: 0 0 30px rgba(255,102,0,.25);
  z-index: 1000; white-space: nowrap;
  display: none;
}

/* ── Page navigation arrows ─────────────────────────────────────── */
#pageNav {
  position: absolute; bottom: -50px; left: 0; right: 0;
  display: none; /* shown when totalPages > 1 */
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}
#pageNav.visible { display: flex; }

.nav-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  background: rgba(26,18,12,.75);
  border: 1px solid rgba(255,204,0,.2);
  border-radius: 2px;
  color: rgba(255,204,0,.7);
  font-size: .63rem; letter-spacing: .18em;
  text-transform: uppercase; cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
  backdrop-filter: blur(8px);
}
.nav-btn:hover:not(:disabled) {
  background: rgba(26,18,12,.96); color: var(--gold);
  box-shadow: 0 0 12px rgba(255,204,0,.2);
}
.nav-btn:disabled { opacity: .2; cursor: not-allowed; }
.nav-divider { color: rgba(212,196,168,.22); font-size: .6rem; }

/* ═════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ═════════════════════════════════════════════════════════════════ */
#adminPanel {
  max-width: 1100px; margin: 0 auto;
  padding: clamp(24px, 4vw, 60px);
  opacity: 0;
}
.admin-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 36px; }
.admin-meta   { font-size: .63rem; letter-spacing: .28em; color: var(--gold); text-transform: uppercase; margin-bottom: 6px; }
.admin-h1     { font-size: clamp(1.4rem,3vw,2.1rem); color: var(--gold); text-shadow: 0 0 20px rgba(255,204,0,.28); letter-spacing: .1em; }
.admin-sub    { margin-top: 6px; color: var(--parchment); opacity: .55; font-style: italic; font-size: .88rem; }
.admin-stats  { display: flex; gap: 14px; }
.stat-card    { padding: 13px 18px; background: rgba(26,18,12,.6); border-radius: 3px; text-align: center; min-width: 86px; }
.stat-val     { font-size: 1.75rem; line-height: 1; }
.stat-lbl     { font-size: .58rem; letter-spacing: .2em; color: rgba(212,196,168,.5); text-transform: uppercase; margin-top: 4px; }

.admin-divider { height: 1px; background: linear-gradient(to right, transparent, rgba(255,204,0,.28), transparent); margin-bottom: 36px; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 36px; }

.section-heading {
  font-size: .72rem; letter-spacing: .22em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px;
}

.card-list { display: flex; flex-direction: column; gap: 14px; }

.sub-card {
  padding: 18px 18px 14px;
  background: rgba(26,18,12,.7);
  border: 1px solid rgba(212,196,168,.1);
  border-radius: 3px;
  transition: border-color .25s;
  overflow: hidden;
}
.sub-card:hover { border-color: rgba(212,196,168,.24); }
.sub-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sub-author { font-size: .68rem; letter-spacing: .12em; color: var(--gold); text-transform: uppercase; }
.sub-date   { font-size: .68rem; color: rgba(212,196,168,.38); font-style: italic; }
.sub-text   { font-size: .9rem; color: rgba(212,196,168,.78); line-height: 1.8; font-style: italic; margin-bottom: 12px; }
.sub-textarea {
  width: 100%; min-height: 72px; padding: 8px 12px;
  background: rgba(0,0,0,.5); border: 1px solid rgba(255,204,0,.15);
  border-radius: 2px; color: var(--parchment);
  font-size: .88rem; line-height: 1.6; resize: vertical; outline: none;
  margin-bottom: 10px; transition: border-color .25s;
}
.sub-textarea:focus { border-color: rgba(255,204,0,.4); }

.pub-label { font-size: .58rem; letter-spacing: .14em; color: rgba(255,204,0,.45); text-transform: uppercase; display: block; margin-bottom: 6px; }

.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.act-btn {
  padding: 6px 13px;
  border-radius: 2px; cursor: pointer; font-size: .68rem;
  letter-spacing: .1em; text-transform: uppercase;
  transition: background .2s, box-shadow .2s;
}
.act-btn:hover { box-shadow: 0 0 10px currentColor; opacity: .85; }

.pub-entry {
  padding: 18px 22px; background: rgba(212,196,168,.05);
  border: 1px solid rgba(255,204,0,.1);
  border-left: 3px solid var(--gold); border-radius: 3px;
}
.pub-entry-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pub-entry-label  { font-size: .63rem; letter-spacing: .13em; color: var(--gold); text-transform: uppercase; opacity: .8; }
.pub-entry-meta   { font-size: .7rem; color: rgba(212,196,168,.38); font-style: italic; }
.pub-entry-text   { font-size: .93rem; color: var(--parchment); line-height: 1.82; font-style: italic; opacity: .82; }

.empty-state {
  padding: 40px 22px; text-align: center;
  border: 1px dashed rgba(255,204,0,.1);
  border-radius: 3px;
}
.empty-state p { color: rgba(212,196,168,.33); font-style: italic; font-size: .88rem; }
