/* =========================================================
   JAMES GOLD — style.css  (cleaned & fixed)
   Structure: Tokens → Reset → Preloader → Topbar → Buttons
              → Lang Dropdown → TOC → Layout → Hero → Book
              → Edition Switcher → Cover Stage → Reader Modal
              → Contact → Footer → Animations → RTL → Responsive
   ========================================================= */

/* ─── 1. Design Tokens ─────────────────────────────────── */
:root {
  --bg: #080808;
  --paper: #faf6ee;
  --ink: #221a10;
  --gold: #c9a84c;
  --gold-light: #e2c46d;
  --gold-deep: #9e7422;
  --gold-glow: rgba(201, 168, 76, .35);
  --muted: #7a6a52;
  --radius-card: 18px;
  --radius-btn: 12px;
  --shadow-card: 0 18px 48px rgba(0, 0, 0, .55);
  --shadow-btn: 0 8px 24px rgba(201, 168, 76, .4);
  --transition: .28s cubic-bezier(.4, 0, .2, 1);
  --font-display: 'Cinzel', Georgia, serif;
  --font-body: 'Montserrat', system-ui, sans-serif;
  --font-ar: 'Cairo', sans-serif;
  --font-reader: Georgia, 'Cambria', 'Times New Roman', serif;
  --topbar-h: 64px;
  --kindle-bg: #f5efe3;
  --kindle-ink: #1e150a;
}

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

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

body {
  background-color: var(--bg);
  background-image: url("https://transparenttextures.com/patterns/black-orchid.png");
  background-attachment: fixed;
  color: #e8e4dc;
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

a {
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ─── 3. Preloader ─────────────────────────────────────── */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #070707, #0e0e12);
}

#preloader.fade-out {
  opacity: 0;
  visibility: hidden;
  transition: opacity .9s ease, visibility .9s ease;
}

.preload-wrap {
  display: grid;
  place-items: center;
  gap: 22px;
}

.preload-book {
  width: 240px;
  height: 160px;
  position: relative;
  perspective: 1200px;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .7));
}

.preload-book .cover {
  position: absolute;
  top: 0;
  width: 120px;
  height: 100%;
  background: linear-gradient(135deg, #161616, #0c0c0c);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
}

.preload-book .cover.left {
  left: 0;
  transform-origin: right center;
}

.preload-book .cover.right {
  right: 0;
  transform-origin: left center;
  box-shadow: inset 0 0 0 1px rgba(201, 168, 76, .3);
}

.preload-book .sheets {
  position: absolute;
  left: 120px;
  top: 8px;
  height: 144px;
  width: 0;
}

.preload-book .sheet {
  position: absolute;
  top: 0;
  left: -2px;
  width: 120px;
  height: 144px;
  background: var(--paper);
  border-left: 1px solid #e8dfcf;
  border-right: 1px solid #e8dfcf;
  transform-origin: left center;
  border-radius: 2px;
  box-shadow: 6px 0 16px rgba(0, 0, 0, .3);
  animation: preFlip 1.6s ease-in-out infinite;
}

.s2 {
  animation-delay: .22s;
}

.s3 {
  animation-delay: .44s;
}

.preload-text h1 {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 6px;
  font-weight: 900;
}

.preload-text p {
  color: #999;
  margin-top: 6px;
  font-size: .9rem;
}

@keyframes preFlip {
  0% {
    transform: rotateY(0);
  }

  45% {
    transform: rotateY(-170deg);
  }

  55% {
    transform: rotateY(-170deg);
  }

  100% {
    transform: rotateY(0);
  }
}

/* ─── 4. Topbar ────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--topbar-h);
  background: rgba(6, 6, 8, .75);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid rgba(201, 168, 76, .22);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  gap: 12px;
}

.brand {
  font-family: var(--font-display);
  color: var(--gold);
  letter-spacing: 3px;
  font-size: 1.05rem;
  font-weight: 900;
  flex-shrink: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(255, 255, 255, .05);
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), #8f5fff);
  transition: width .1s linear;
}

/* ─── 5. Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  font-size: .875rem;
  font-weight: 700;
  border: none;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}

.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .35), transparent);
  transition: .45s;
}

.btn:hover::after {
  left: 100%;
}

.btn-ghost {
  background: transparent;
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, .2);
}

.btn-ghost:hover {
  border-color: rgba(255, 255, 255, .6);
  color: #fff;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  color: #1a1000;
  box-shadow: var(--shadow-btn);
}

.btn-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(201, 168, 76, .6);
  filter: brightness(1.08);
}

.btn-gold:active {
  transform: translateY(1px) scale(.97);
  filter: brightness(.9);
}

.btn-outline {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(201, 168, 76, .5);
}

.btn-outline:hover {
  background: rgba(201, 168, 76, .1);
  border-color: var(--gold);
  transform: translateY(-2px);
}

.btn-store {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #ccc;
  font-size: .82rem;
  padding: 8px 14px;
  border-radius: 10px;
  transition: var(--transition);
  cursor: pointer;
}

.btn-store:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-color: rgba(255, 255, 255, .3);
  transform: translateY(-2px);
}

.btn-store.active-store {
  background: rgba(201, 168, 76, .12);
  border-color: rgba(201, 168, 76, .45);
  color: var(--gold-deep);
}

.btn-store .store-name {
  font-weight: 700;
  display: block;
  line-height: 1.4;
}

.btn-store.is-disabled {
  opacity: .38;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(.4);
}

.btn-close {
  background: transparent;
  color: #aaa;
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 8px;
}

.btn-close:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, .4);
}

/* ─── 6. Language Dropdown ─────────────────────────────── */
.lang-dropdown {
  position: relative;
  user-select: none;
}

.lang-selected {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: .35rem .75rem .35rem .65rem;
  background: rgba(0, 0, 0, .5);
  color: #ddd;
  font: 700 .8rem/1 var(--font-body);
  cursor: pointer;
  transition: var(--transition);
  min-width: 76px;
}

.lang-selected:hover {
  border-color: rgba(201, 168, 76, .5);
  color: #fff;
  background: rgba(201, 168, 76, .08);
}

.lang-dropdown[aria-expanded="true"] .lang-selected {
  border-color: rgba(201, 168, 76, .55);
  background: rgba(201, 168, 76, .1);
}

.lang-flag {
  width: 18px;
  height: 14px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  flex-shrink: 0;
}

.lang-label {
  font-size: .78rem;
  letter-spacing: .5px;
}

.lang-chevron {
  margin-left: auto;
  opacity: .7;
  flex-shrink: 0;
  transition: transform .22s ease;
}

.lang-dropdown[aria-expanded="true"] .lang-chevron {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(12, 12, 16, .97);
  border: 1px solid rgba(201, 168, 76, .25);
  border-radius: 14px;
  padding: 6px;
  min-width: 160px;
  list-style: none;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(.97);
  transform-origin: top right;
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  z-index: 200;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.lang-dropdown[aria-expanded="true"] .lang-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  color: #ccc;
  font-size: .85rem;
  font-weight: 600;
  transition: var(--transition);
}

.lang-option:hover {
  background: rgba(201, 168, 76, .12);
  color: #fff;
}

.lang-option[aria-selected="true"] {
  background: rgba(201, 168, 76, .15);
  color: var(--gold-light);
}

.lang-option[aria-selected="true"]::after {
  content: '✓';
  margin-left: auto;
  font-size: .75rem;
  color: var(--gold);
  opacity: .9;
}

/* ─── 7. TOC Panel ─────────────────────────────────────── */
.toc-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(400px, 92vw);
  background: rgba(10, 10, 14, .96);
  border-left: 1px solid rgba(201, 168, 76, .22);
  transform: translateX(105%);
  transition: transform .36s cubic-bezier(.4, 0, .2, 1);
  z-index: 80;
  display: flex;
  flex-direction: column;
}

.toc-panel.open {
  transform: translateX(0);
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 14px;
  border-bottom: 1px solid rgba(201, 168, 76, .15);
}

.toc-header h3 {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1rem;
  letter-spacing: 2px;
}

.toc-inner {
  padding: 18px 22px 30px;
  overflow-y: auto;
  flex: 1;
}

.toc-inner ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc-inner li a {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  color: #ccc;
  font-weight: 600;
  font-size: .92rem;
  transition: var(--transition);
  border: 1px solid transparent;
}

.toc-inner li a:hover {
  color: var(--gold);
  background: rgba(201, 168, 76, .08);
  border-color: rgba(201, 168, 76, .2);
}

.toc-panel.lang-switching {
  visibility: hidden;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  opacity: 0;
  pointer-events: none;
  z-index: 70;
  transition: opacity .28s ease;
}

.scrim.show {
  opacity: 1;
  pointer-events: auto;
}

/* ─── 8. Layout ────────────────────────────────────────── */
#content {
  padding: 24px 0 60px;
}

.page {
  width: min(1080px, 92vw);
  margin: 36px auto;
  background:
    linear-gradient(90deg, rgba(201, 168, 76, .05), transparent 12%, transparent 88%, rgba(201, 168, 76, .05)),
    var(--paper);
  color: var(--ink);
  border-radius: var(--radius-card);
  border: 1px solid rgba(0, 0, 0, .06);
  box-shadow: var(--shadow-card);
  padding: 48px 52px;
  position: relative;
  overflow: hidden;
}

.decor-corner {
  position: absolute;
  width: 64px;
  height: 64px;
  border: 1.5px solid rgba(201, 168, 76, .45);
  border-radius: 10px;
  opacity: .4;
}

.decor-corner.tl {
  top: 14px;
  left: 14px;
  border-right: none;
  border-bottom: none;
}

.decor-corner.tr {
  top: 14px;
  right: 14px;
  border-left: none;
  border-bottom: none;
}

.decor-corner.bl {
  bottom: 14px;
  left: 14px;
  border-right: none;
  border-top: none;
}

.decor-corner.br {
  bottom: 14px;
  right: 14px;
  border-left: none;
  border-top: none;
}

/* ─── 9. Hero ──────────────────────────────────────────── */
.page-hero {
  text-align: center;
  padding: 72px 52px;
}

.page-hero .hero-title {
  font-family: var(--font-display);
  color: var(--gold);
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  letter-spacing: 5px;
  line-height: 1.1;
  margin-bottom: 10px;
}

.page-hero .hero-subtitle {
  color: #6a5e4e;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: .9rem;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.page-hero .bio {
  max-width: 780px;
  margin: 0 auto 32px;
  color: #3d3020;
  line-height: 1.8;
  font-size: 1rem;
}

.page-hero .bio .bio-quote {
  display: block;
  margin-top: 14px;
  color: var(--gold-deep);
  font-style: italic;
  font-weight: 600;
  border-left: 3px solid var(--gold);
  padding-left: 14px;
  text-align: left;
}

.hero-cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ─── 10. Chapter Head ─────────────────────────────────── */
.chapter-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chapter-head h2 {
  font-family: var(--font-display);
  color: var(--gold) !important;
  font-size: clamp(1.3rem, 3vw, 2rem);
  letter-spacing: .5px;
  font-weight: 900;
  text-transform: uppercase;
}

.ribbon {
  background: linear-gradient(90deg, rgba(201, 168, 76, .2), rgba(201, 168, 76, .04));
  border: 1px solid rgba(201, 168, 76, .28);
  color: #7b6930;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  white-space: nowrap;
}

.lang-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(34, 26, 16, .08);
  border: 1px solid rgba(34, 26, 16, .2);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 5px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ─── 11. Book Grid ────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: 1.25fr .95fr;
  gap: 32px;
  align-items: start;
  margin-top: 14px;
}

.col-text .lead {
  font-size: 1.12rem;
  font-weight: 600;
  color: #3a2c1c;
  margin-bottom: 14px;
}

.col-text p {
  color: #4a3c2a;
  margin-bottom: 12px;
  line-height: 1.8;
}

.col-text strong {
  color: var(--gold-deep);
}

/* ─── 12. Edition Switcher & Stores ───────────────────── */
.store-group {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.store-note {
  font-size: .76rem;
  color: var(--muted);
  font-style: italic;
  letter-spacing: .2px;
  line-height: 1.5;
  margin: 0;
}

.preview-trigger {
  margin: 14px 0 6px;
}

.preview-trigger-icon {
  display: inline-flex;
  opacity: .85;
}

.edition-switcher {
  display: inline-flex;
  gap: 4px;
  margin: 22px 0 16px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(34, 26, 16, .06);
  border: 1px solid rgba(0, 0, 0, .08);
}

.edition-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #6d5b42;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .3px;
  transition: var(--transition);
}

.edition-toggle-icon {
  display: inline-flex;
  opacity: .75;
}

.edition-toggle:hover {
  color: var(--ink);
}

.edition-toggle.active {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  color: #1a1000;
  box-shadow: 0 6px 18px rgba(201, 168, 76, .4);
}

.edition-toggle.active .edition-toggle-icon {
  opacity: 1;
}

.book-lang-switcher {
  margin-top: -8px;
}

.book-lang-switcher .fi {
  border-radius: 3px;
}

/* ─── 13. Cover Stage ──────────────────────────────────── */
.cover-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4.4;
}

.cover-frame {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .55s cubic-bezier(.4, 0, .2, 1);
}

.cover-frame.is-active {
  opacity: 1;
  pointer-events: auto;
}

.cover-card {
  position: relative;
  width: 100%;
  height: 100%;
  background: #fff;
  padding: 12px;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
}

.cover-card img {
  border-radius: 8px;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-badge {
  position: absolute;
  top: -10px;
  right: 4px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-deep));
  color: #1a0f00;
  font-size: .68rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(201, 168, 76, .5);
  letter-spacing: .5px;
  text-transform: uppercase;
  z-index: 2;
}

/* ─── 14. Reader Modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .32s ease, visibility .32s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 6, .85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* The reader panel */
.kindle-reader {
  position: relative;
  z-index: 1;
  width: min(740px, 96vw);
  height: min(88vh, 820px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--kindle-bg);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, .15);
  box-shadow: 0 32px 80px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .06);
  overflow: hidden;
  transform: scale(.97) translateY(12px);
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
}

.modal-overlay.open .kindle-reader {
  transform: scale(1) translateY(0);
}

/* Kindle Top Bar */
.kindle-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 48px;
  background: rgba(30, 21, 10, .94);
  border-bottom: 1px solid rgba(201, 168, 76, .2);
  gap: 12px;
  flex-shrink: 0;
}

.kindle-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  min-width: 0;
}

.kindle-book-title {
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kindle-sep {
  color: rgba(201, 168, 76, .4);
  font-size: .9rem;
  flex-shrink: 0;
}

.kindle-chapter {
  font-size: .7rem;
  color: #b09a6a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  letter-spacing: .5px;
}

.kindle-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.kindle-badge {
  font-family: var(--font-display);
  font-size: .6rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(201, 168, 76, .35);
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
}

.kindle-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #aaa;
  display: grid;
  place-items: center;
  transition: var(--transition);
  flex-shrink: 0;
  cursor: pointer;
}

.kindle-close:hover {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border-color: rgba(255, 255, 255, .3);
}

/* Reading Viewport */
.kindle-viewport {
  position: relative;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .012) 0 1px, transparent 1px 28px),
    var(--kindle-bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Each page */
.kindle-page {
  position: absolute;
  inset: 0;
  padding: 44px 60px 36px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateX(28px);
  transition: opacity .38s ease, transform .38s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 76, .25) transparent;
}

.kindle-page::-webkit-scrollbar {
  width: 5px;
}

.kindle-page::-webkit-scrollbar-track {
  background: transparent;
}

.kindle-page::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 76, .25);
  border-radius: 3px;
}

.kindle-page.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  position: relative;
  inset: auto;
}

.kindle-page.is-leaving-back {
  transform: translateX(-28px);
}

.kindle-page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
}

.kindle-page-head .kp-chapter {
  font-family: var(--font-display);
  font-size: .65rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.kindle-page-head .kp-folio {
  font-size: .68rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.kindle-page-body {
  color: var(--kindle-ink);
  font-family: var(--font-reader);
  font-size: 1.06rem;
  line-height: 1.9;
}

.kindle-page-body p {
  margin-bottom: 1em;
}

.kindle-page-body p:last-child {
  margin-bottom: 0;
}

.kindle-page-body .rp-firstline {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--gold-deep);
  margin-bottom: .25em;
}

.kindle-page-body .rp-dossier-block {
  border-left: 3px solid var(--gold-deep);
  background: rgba(201, 168, 76, .07);
  padding: 14px 16px;
  margin: 18px 0;
  font-family: 'Courier New', Courier, monospace;
  font-size: .88rem;
  line-height: 1.7;
  color: #3a2c1c;
  border-radius: 0 6px 6px 0;
}

.kindle-page-body .rp-sign {
  display: block;
  font-size: .8rem;
  letter-spacing: .5px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--muted);
  margin: 16px 0 4px;
  text-transform: uppercase;
}

/* Watermark */
.kindle-page::after {
  content: 'PREVIEW';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 3rem;
  letter-spacing: 8px;
  color: rgba(34, 26, 16, .028);
  transform: rotate(-22deg) scale(1.4);
  pointer-events: none;
  white-space: nowrap;
}

/* Edge nav buttons */
.kindle-edge {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(30, 21, 10, .72);
  border: 1px solid rgba(201, 168, 76, .3);
  color: var(--gold-light);
  display: grid;
  place-items: center;
  transition: var(--transition);
  z-index: 10;
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.kindle-edge:hover:not(:disabled) {
  background: rgba(201, 168, 76, .22);
  border-color: var(--gold);
  transform: translateY(-50%) scale(1.08);
}

.kindle-edge:disabled {
  opacity: .25;
  cursor: default;
}

.kindle-edge-prev {
  left: 12px;
}

.kindle-edge-next {
  right: 12px;
}

/* Bottom bar */
.kindle-bottombar {
  background: rgba(30, 21, 10, .94);
  border-top: 1px solid rgba(201, 168, 76, .15);
  padding: 10px 20px 12px;
  flex-shrink: 0;
}

.kindle-progress-wrap {
  margin-bottom: 8px;
}

.kindle-progress-track {
  height: 2px;
  background: rgba(255, 255, 255, .1);
  border-radius: 2px;
  overflow: hidden;
}

.kindle-progress-fill {
  height: 100%;
  width: 14.28%;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-light));
  border-radius: 2px;
  transition: width .35s ease;
}

.kindle-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kindle-pageno {
  font-size: .75rem;
  font-weight: 700;
  color: #b09a6a;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
}

.kindle-footnote {
  font-size: .68rem;
  color: rgba(176, 154, 106, .6);
  font-style: italic;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-dots {
  display: flex;
  gap: 5px;
}

.reader-dots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  transition: var(--transition);
}

.reader-dots .dot.is-active {
  background: var(--gold);
  width: 16px;
  border-radius: 3px;
}

body.modal-locked {
  overflow: hidden;
}

@media print {
  .kindle-reader {
    visibility: hidden;
  }
}

/* ─── 15. Contact ──────────────────────────────────────── */
.contact-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 14px;
  padding: 22px;
  margin-top: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .2);
}

.contact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 1px dashed rgba(0, 0, 0, .1);
}

.contact-row:last-child {
  border-bottom: 0;
}

.contact-row .label {
  color: #6d5b42;
  font-weight: 700;
  font-size: .9rem;
}

.contact-row a {
  color: var(--gold-deep);
  font-weight: 700;
}

.contact-row a:hover {
  color: var(--gold);
}

.kofi-wrap {
  display: flex;
  justify-content: center;
  margin: 8px auto 0;
  width: min(1080px, 92vw);
}

/* ─── 16. Footer ───────────────────────────────────────── */
.site-footer {
  width: min(1080px, 92vw);
  margin: 16px auto 0;
  color: #c0a870;
  text-align: center;
  padding: 20px 0 12px;
  border-top: 1px solid rgba(201, 168, 76, .22);
  font-size: .85rem;
}

/* ─── 17. Scroll Reveal ────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(22px) scale(.985);
  transition: opacity .6s ease, transform .6s ease;
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ─── 18. RTL Support ──────────────────────────────────── */
body.rtl {
  direction: rtl;
}

/* RTL Topbar: keep brand on left, controls on right */
/* RTL Topbar: keep original LTR layout (do not reverse header order) */
/* Ensure header layout remains consistent across languages */
body.rtl .topbar {
  flex-direction: row;
}

body.rtl .topbar-right {
  flex-direction: row;
}

/* TOC slides from left in RTL */
body.rtl .toc-panel {
  inset: 0 auto 0 0;
  border-left: none;
  border-right: 1px solid rgba(201, 168, 76, .22);
  transform: translateX(-105%);
}

body.rtl .toc-panel.open {
  transform: translateX(0);
}

/* TOC inner: always LTR layout, only text changes */
body.rtl .toc-header {
  flex-direction: row-reverse;
}

body.rtl .toc-inner li a {
  text-align: right;
}

/* Lang menu opens left in RTL */
body.rtl .lang-menu {
  right: auto;
  left: 0;
  transform-origin: top left;
}

body.rtl .page-hero .bio .bio-quote {
  border-left: none;
  border-right: 3px solid var(--gold);
  padding-left: 0;
  padding-right: 14px;
  text-align: right;
}

body.rtl .cover-badge {
  right: auto;
  left: 4px;
}

body.rtl .store-group {
  align-items: flex-end;
}

body.rtl .chapter-head {
  flex-direction: row-reverse;
  align-items: center;
}

body.rtl .edition-switcher {
  flex-direction: row-reverse;
}

body.rtl .contact-row {
  flex-direction: row-reverse;
}

/* Reader always LTR regardless of page direction */
body.rtl .kindle-reader,
body.rtl .kindle-viewport,
body.rtl .kindle-page,
body.rtl .kindle-page-body,
body.rtl .kindle-page-head,
body.rtl .kindle-topbar {
  direction: ltr;
  text-align: left;
}

body.rtl .kindle-edge-prev {
  left: 12px;
  right: auto;
}

body.rtl .kindle-edge-next {
  right: 12px;
  left: auto;
}

body.rtl .kindle-footnote {
  text-align: left;
}

body.rtl .kindle-topbar-right {
  flex-direction: row;
}

/* Arabic font */
body[lang="ar"],
body[lang="ar"] * {
  font-family: var(--font-ar) !important;
}

body[lang="ar"] .kindle-page-body {
  font-size: 1.08rem;
  line-height: 2.1;
}

body[lang="ar"] .page-hero .hero-title,
body[lang="ar"] .chapter-head h2 {
  font-family: 'Cairo', sans-serif !important;
  letter-spacing: 0;
}

/* ─── 19. Responsive — tablet ≤900px ──────────────────── */
@media (max-width: 900px) {
  .book-grid {
    grid-template-columns: 1fr;
  }

  .col-cover {
    order: -1;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    display: block;
  }

  .cover-stage {
    width: 100%;
    aspect-ratio: 3 / 4.4;
    position: relative;
  }

  .page {
    padding: 32px 24px;
  }
}

/* ─── 20. Mobile ≤768px ────────────────────────────────── */
@media only screen and (max-width: 768px) {

  /* Topbar */
  .topbar {
    height: auto;
    min-height: 52px;
    padding: 8px 12px;
    gap: 8px;
  }

  .brand {
    font-size: .82rem;
    letter-spacing: 1.5px;
  }

  .topbar-right {
    gap: 6px;
  }

  .btn-ghost {
    padding: 7px 10px;
    font-size: .78rem;
  }

  /* Pages */
  .page {
    padding: 22px 14px;
  }

  .page-hero {
    padding: 34px 14px;
  }

  .hero-cta {
    flex-direction: column;
    align-items: center;
  }

  .chapter-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .store-group {
    gap: 8px;
  }

  .btn-store {
    font-size: .76rem;
    padding: 7px 11px;
  }

  .edition-switcher {
    width: 100%;
  }

  .edition-toggle {
    flex: 1;
    justify-content: center;
    padding: 10px;
  }

  /* Cover */
  .col-cover {
    order: -1;
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
  }

  .cover-stage {
    aspect-ratio: 3 / 4.4;
    width: 100%;
  }

  /* TOC fixed */
  .toc-panel {
    position: fixed;
    z-index: 80;
  }

  /* ── READER — full-screen mobile ── */
  .modal-overlay {
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }

  .modal-overlay .modal-backdrop {
    position: fixed;
    inset: 0;
  }

  .kindle-reader {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    z-index: 96;
    border-radius: 0;
    border: none;
    transform: none !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-overlay.open .kindle-reader {
    transform: none !important;
  }

  /* Topbar: compact, fixed close btn handled inside */
  .kindle-topbar {
    height: 48px;
    padding: 0 52px 0 14px;
    flex-shrink: 0;
    width: 100%;
  }

  .kindle-topbar-left {
    gap: 4px;
    overflow: hidden;
    min-width: 0;
  }

  .kindle-book-title {
    font-size: .72rem;
  }

  .kindle-chapter,
  .kindle-sep,
  .kindle-badge {
    display: none;
  }

  /* Close button: fixed top-right, always visible */
  .kindle-close {
    position: fixed;
    top: 8px;
    right: 10px;
    z-index: 9999;
    width: 36px;
    height: 36px;
    background: rgba(20, 14, 6, .95);
    border: 1.5px solid rgba(201, 168, 76, .6);
    color: var(--gold-light);
    border-radius: 50%;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .5);
  }

  /* Viewport: scrollable */
  .kindle-viewport {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    position: relative;
    direction: ltr;
  }

  /* Mobile scroll mode: all pages stacked */
  .kindle-reader.mobile-scroll-mode .kindle-page {
    position: relative;
    inset: auto;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    display: block;
    width: 100%;
    padding: 24px 18px 20px;
    overflow: visible;
    border-bottom: 1px solid rgba(0, 0, 0, .07);
    direction: ltr;
    text-align: left;
  }

  .kindle-reader.mobile-scroll-mode .kindle-page:last-child {
    border-bottom: none;
    padding-bottom: 48px;
  }

  .kindle-reader.mobile-scroll-mode .kindle-page::after {
    display: none;
  }

  .kindle-reader.mobile-scroll-mode .kindle-edge {
    display: none;
  }

  .kindle-reader.mobile-scroll-mode .reader-dots,
  .kindle-reader.mobile-scroll-mode .kindle-pageno {
    display: none;
  }

  /* Page body */
  .kindle-page-body {
    font-size: .96rem;
    line-height: 1.9;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    direction: ltr;
    text-align: left;
    color: var(--kindle-ink);
  }

  .kindle-page-head {
    direction: ltr;
    margin-bottom: 14px;
  }

  /* Bottom bar */
  .kindle-bottombar {
    flex-shrink: 0;
    padding: 8px 16px 10px;
    direction: ltr;
  }
}

/* ─── Extra small ≤400px ───────────────────────────────── */
@media only screen and (max-width: 400px) {
  .col-cover {
    max-width: 220px;
  }

  .kindle-page-body {
    font-size: .9rem;
  }

  .kindle-reader.mobile-scroll-mode .kindle-page {
    padding: 18px 14px 16px;
  }
}