/*
Theme Name: Sarah Novel Theme
Theme URI: https://example.com
Author: صفية — المرأة التي غيّرت التاريخ
Description: قالب روائي أنيق لعرض رواية سارة — المرأة التي غيّرت التاريخ، بتصميم عربي كلاسيكي راقٍ مع قائمة فصول جانبية وتجربة قراءة سينمائية.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: sarah-novel
Tags: rtl-language, arabic, novel, book, custom-colors, custom-menu, full-width-template, sticky-post
*/

/* =========================================
   GOOGLE FONTS
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Scheherazade+New:wght@400;500;600;700&display=swap');

:root {
  --bg: #faf7f2;
  --surface: #fff9f0;
  --text: #2c1a0e;
  --text-secondary: #6b4226;
  --accent: #8b1a1a;
  --accent2: #c17f24;
  --border: #d4b896;
  --sidebar-bg: #1e0e06;
  --sidebar-text: #e8d5b7;
  --sidebar-hover: #3d1f0e;
  --sidebar-active: #8b1a1a;
  --font-main: 'Scheherazade New', 'Amiri', 'Traditional Arabic', serif;
  --sidebar-width: 310px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 18px;
  line-height: 2;
  direction: rtl;
}

/* =========================================
   WORDPRESS ALIGNMENT CLASSES
   ========================================= */
.alignleft { float: right; margin-left: 1.5em; margin-bottom: 1em; }
.alignright { float: left; margin-right: 1.5em; margin-bottom: 1em; }
.aligncenter { display: block; margin: 1em auto; }
.wp-caption { max-width: 100%; }
.wp-caption-text { font-size: 0.85em; text-align: center; color: var(--text-secondary); }

/* =========================================
   SIDEBAR
   ========================================= */
#sarah-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  height: 100vh;
  position: fixed;
  right: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}

.sidebar-header {
  padding: 22px 18px 14px;
  border-bottom: 1px solid rgba(212,184,150,0.2);
  background: linear-gradient(180deg, rgba(139,26,26,0.4), rgba(62,15,6,0.2));
}

.sidebar-book-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffd89b;
  line-height: 1.4;
  margin-bottom: 3px;
  text-decoration: none;
  display: block;
}

.sidebar-book-title:hover { color: #ffa040; }

.sidebar-subtitle {
  font-size: 12px;
  color: rgba(212,184,150,0.6);
  font-style: italic;
}

.sidebar-search {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(212,184,150,0.12);
}

.sidebar-search input {
  width: 100%;
  padding: 7px 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(212,184,150,0.25);
  border-radius: 8px;
  color: var(--sidebar-text);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  text-align: right;
  direction: rtl;
}

.sidebar-search input::placeholder { color: rgba(212,184,150,0.35); }
.sidebar-search input:focus { border-color: #8b1a1a; }

#sarah-toc { overflow-y: auto; flex: 1; padding: 6px 0; }
#sarah-toc::-webkit-scrollbar { width: 4px; }
#sarah-toc::-webkit-scrollbar-thumb { background: rgba(212,184,150,0.25); border-radius: 2px; }

#sarah-toc ul { list-style: none; padding: 0; margin: 0; }

.toc-link {
  display: block;
  padding: 8px 18px;
  color: rgba(212,184,150,0.72);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.5;
  transition: all 0.18s;
  border-right: 3px solid transparent;
  direction: rtl;
}

.toc-link:hover {
  background: var(--sidebar-hover);
  color: #f0dbb5;
  border-right-color: var(--accent2);
  text-decoration: none;
}

.toc-link.active {
  background: rgba(139,26,26,0.45);
  color: #ffd89b;
  border-right-color: #8b1a1a;
  font-weight: 600;
}

.sidebar-reading-stats {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: rgba(212,184,150,0.4);
  border-top: 1px solid rgba(212,184,150,0.1);
}

/* =========================================
   MAIN CONTENT
   ========================================= */
#sarah-main {
  margin-right: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

/* =========================================
   BOOK COVER
   ========================================= */
.sarah-book-cover {
  background: linear-gradient(160deg, #0d0503 0%, #1e0e06 30%, #3d1f0e 60%, #6b2020 85%, #8b1a1a 100%);
  color: white;
  text-align: center;
  padding: 90px 40px 70px;
  position: relative;
  overflow: hidden;
}

.sarah-book-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(193,127,36,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139,26,26,0.15) 0%, transparent 50%);
}

.sarah-book-cover::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40Z' fill='none' stroke='%23c17f24' stroke-width='0.3' opacity='0.15'/%3E%3Ccircle cx='40' cy='40' r='28' fill='none' stroke='%23c17f24' stroke-width='0.2' opacity='0.1'/%3E%3C/svg%3E");
  background-size: 80px 80px;
  opacity: 0.5;
}

.cover-ornament {
  font-size: 24px;
  color: var(--accent2);
  letter-spacing: 20px;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.sarah-book-cover h1,
.sarah-book-cover .cover-title {
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 700;
  color: #ffd89b;
  margin-bottom: 8px;
  line-height: 1.25;
  text-shadow: 0 3px 12px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
  border: none !important;
  padding: 0 !important;
}

.cover-subtitle {
  font-size: clamp(16px, 2.5vw, 22px);
  color: rgba(255,216,155,0.7);
  font-style: italic;
  margin-bottom: 32px;
  position: relative;
  z-index: 1;
}

.cover-line {
  width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent2), transparent);
  margin: 0 auto 28px;
  position: relative;
  z-index: 1;
}

.cover-meta {
  font-size: 15px;
  color: rgba(212,184,150,0.55);
  position: relative;
  z-index: 1;
  line-height: 2;
}

/* =========================================
   PROGRESS BAR
   ========================================= */
#sarah-progress {
  position: fixed;
  top: 0; left: 0;
  right: var(--sidebar-width);
  height: 3px;
  background: linear-gradient(90deg, #8b1a1a, #c17f24);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 200;
  transition: transform 0.08s linear;
}

/* =========================================
   NOVEL SECTIONS
   ========================================= */
.novel-section {
  max-width: 800px;
  margin: 0 auto;
  padding: 64px 48px;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.novel-section.visible { opacity: 1; transform: translateY(0); }
.novel-section:last-child { border-bottom: none; padding-bottom: 100px; }

.section-intro { background: linear-gradient(180deg, #fff9f0, #faf7f2); }
.section-chapter { background: var(--bg); }
.section-poem { background: #fdf5e6; }
.section-appendix { background: #f8f4ee; }

.section-divider {
  background: linear-gradient(180deg, #1e0e06, #3d1f0e);
  color: white !important;
  text-align: center;
  padding: 60px 48px;
}

.section-divider .section-content { color: rgba(255,216,155,0.9); }
.section-divider .section-content h1,
.section-divider .section-content h2,
.section-divider .section-content h3 {
  color: #ffd89b !important;
  border-bottom-color: rgba(193,127,36,0.3) !important;
}
.section-divider .section-content p { color: rgba(212,184,150,0.85) !important; text-align: center !important; }

/* =========================================
   SECTION TYPOGRAPHY
   ========================================= */
.section-content { direction: rtl; }

.section-content h1,
.section-content h2,
.section-content h3 {
  color: var(--accent);
  font-weight: 700;
  line-height: 1.45;
  border-bottom: 1px solid rgba(212,184,150,0.6);
  padding-bottom: 12px;
  margin-bottom: 28px;
  margin-top: 48px;
}

.section-content h1:first-child,
.section-content h2:first-child,
.section-content h3:first-child { margin-top: 0; }

.section-content h3 { font-size: 22px; }
.section-content h2 { font-size: 26px; }
.section-content h1 { font-size: 30px; }

.section-content p {
  margin-bottom: 22px;
  text-align: justify;
  font-size: 20px;
  line-height: 2.15;
  color: var(--text);
}

.section-content strong { color: var(--accent); font-weight: 700; }
.section-content em { color: var(--text-secondary); font-style: italic; }

.section-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px auto;
  width: 50%;
}

.section-content blockquote {
  border-right: 4px solid var(--accent2);
  padding: 16px 22px;
  margin: 28px 0;
  background: rgba(193,127,36,0.06);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-secondary);
  font-size: 21px;
  line-height: 2.2;
}

.section-content ul,
.section-content ol {
  padding-right: 28px;
  margin-bottom: 22px;
}

.section-content li { margin-bottom: 10px; line-height: 2; }

.section-poem .section-content p {
  text-align: center;
  line-height: 2.6;
  font-size: 21px;
  font-style: italic;
  color: #3a2008;
}

/* =========================================
   WORDPRESS ADMIN BAR FIX
   ========================================= */
.admin-bar #sarah-sidebar { top: 32px; height: calc(100vh - 32px); }
.admin-bar #sarah-progress { top: 32px; }

/* =========================================
   SCROLL TO TOP
   ========================================= */
#sarah-scroll-top {
  position: fixed;
  bottom: 28px;
  left: 28px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 46px; height: 46px;
  font-size: 22px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 150;
  transition: background 0.2s;
  text-decoration: none;
  line-height: 1;
}

#sarah-scroll-top:hover { background: var(--accent2); color: white; }
#sarah-scroll-top.visible { display: flex; }

/* =========================================
   SIDEBAR TOGGLE (MOBILE)
   ========================================= */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 300;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
  font-family: inherit;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }
  #sarah-sidebar {
    width: 300px;
    transform: translateX(100%);
  }
  #sarah-sidebar.open { transform: translateX(0); }
  #sarah-main { margin-right: 0; }
  #sarah-progress { right: 0; }
  #sidebar-toggle { display: flex; align-items: center; }
  .novel-section { padding: 40px 20px; }
  .sarah-book-cover { padding: 70px 22px 50px; }
}

@media (max-width: 480px) {
  .novel-section { padding: 30px 16px; }
  .section-content p { font-size: 18px; }
  .section-content h3 { font-size: 19px; }
}
