/* ================================================================
   ناس الغيوان - الپاروليير
   Moroccan flipbook design — 3D CSS page turn
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&display=swap');

:root {
  --maroc-ocre: #C17A3F;
  --maroc-ocre-light: #E8A86A;
  --maroc-ocre-dark: #8B5E2F;
  --maroc-vert: #2E5C2E;
  --maroc-vert-light: #4A7C4A;
  --maroc-rouge: #9C2A2A;
  --maroc-rouge-light: #C43A3A;
  --bois: #5C3311;
  --bois-clair: #7A4A1E;
  --bois-fonce: #3C1F0A;
  --parchemin: #F5E6C8;
  --parchemin-fonce: #E8D5A8;
  --text-dark: #2C1E12;
  --text-gold: #D4A533;
  --zellige-blue: #2A5C8A;
  --zellige-teal: #2A7A6A;
}

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

body {
  font-family: 'Amiri', serif;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(44,30,18,0.95) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(60,42,31,0.9) 0%, transparent 60%),
    linear-gradient(180deg, #1A140F, #2C1E12 30%, #3C2A1F 60%, #1A140F);
  color: #F5E8C7;
  margin: 0; padding: 20px;
  direction: rtl;
  min-height: 100vh;
}

.container { max-width: 1100px; margin: 0 auto; position: relative; z-index: 1; }

/* ===== ZELLIGE TOP ===== */
.zellige-top {
  height: 12px;
  background: repeating-linear-gradient(90deg,
    var(--maroc-ocre) 0px, var(--maroc-ocre) 20px,
    var(--maroc-vert) 20px, var(--maroc-vert) 40px,
    var(--maroc-rouge) 40px, var(--maroc-rouge) 60px,
    var(--zellige-blue) 60px, var(--zellige-blue) 80px,
    var(--text-gold) 80px, var(--text-gold) 100px);
  border-radius: 6px; margin-bottom: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* ===== OPEN BUTTON ===== */
.open-btn {
  background: linear-gradient(145deg, var(--maroc-ocre), var(--maroc-ocre-dark));
  color: #FFF; font-size: 1.8rem; font-family: inherit;
  padding: 25px 70px; border: 3px solid var(--text-gold);
  border-radius: 15px; cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
  display: flex; align-items: center; justify-content: center; gap: 15px;
  margin: 80px auto; position: relative; overflow: hidden;
}
.open-btn:hover {
  transform: scale(1.08);
  background: linear-gradient(145deg, var(--maroc-ocre-light), var(--maroc-ocre));
  box-shadow: 0 15px 40px rgba(193,122,63,0.4), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-icon { font-size: 2rem; }

/* ===== BOOK CONTAINER ===== */
.book-container {
  background: linear-gradient(135deg, var(--bois-fonce), var(--bois), var(--bois-clair));
  padding: 20px; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.9), inset 0 1px 0 rgba(255,255,255,0.05);
  border: 12px solid #2C1E12; position: relative;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.book-container::before {
  content: ''; position: absolute; top:0; left:0; right:0; bottom:0;
  background: repeating-linear-gradient(90deg,
    transparent 0px, transparent 40px, rgba(0,0,0,0.03) 40px, rgba(0,0,0,0.03) 42px);
  border-radius: 8px; pointer-events: none; z-index: 0;
}
.book-container.hidden { display: none; }

/* ===== BOOK HEADER ===== */
.book-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 15px; border-bottom: 3px solid var(--maroc-rouge);
  padding-bottom: 10px; position: relative; z-index: 1;
}
.book-header h1 {
  font-size: 1.4rem; color: var(--text-gold);
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.header-right { display: flex; align-items: center; gap: 15px; }
.page-indicator {
  color: var(--parchemin); font-size: 0.9rem; opacity: 0.8;
}
.header-ornament { display: flex; align-items: center; gap: 8px; color: var(--maroc-ocre-light); }
.ornament-line {
  width: 40px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--maroc-ocre-light), transparent);
}
.ornament-diamond { font-size: 0.7rem; }

/* ===== CLOSE BUTTON ===== */
.close-btn {
  background: var(--maroc-rouge); color: white;
  border: 2px solid var(--maroc-rouge-light);
  width: 38px; height: 38px; border-radius: 50%; font-size: 1rem;
  cursor: pointer; transition: all 0.3s;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.close-btn:hover {
  background: var(--maroc-rouge-light); transform: rotate(90deg);
  box-shadow: 0 6px 15px rgba(156,42,42,0.5);
}

/* ===== BOOK WRAPPER ===== */
.book-wrapper {
  position: relative;
  width: 100%;
}

/* ===== BOOK VIEWPORT (3D container) ===== */
.book-viewport {
  position: relative;
  width: 100%;
  height: 560px;
  perspective: 2500px;
  perspective-origin: center center;
  overflow: hidden;
  border-radius: 4px;
  background: #2C1E12;
}

/* ===== SPREAD ===== */
.spread {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease;
  z-index: 1;
}
.spread.active {
  opacity: 1;
  visibility: visible;
  z-index: 2;
}

/* ===== PAGE SIDES ===== */
.page-side {
  flex: 1;
  height: 100%;
  background: linear-gradient(135deg, var(--parchemin), var(--parchemin-fonce));
  color: var(--text-dark);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.06);
}

/* Cover pages */
.cover-content {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; height: 100%; padding: 30px;
  text-align: center; position: relative;
  background: linear-gradient(145deg, var(--bois), #6B3A1F, var(--bois));
  color: var(--text-gold);
}
.cover-content.back { background: linear-gradient(145deg, var(--bois), var(--bois-fonce)); }

.cover-zellige {
  width: 80%; max-width: 300px; height: 60px; margin-bottom: 25px;
  background: repeating-conic-gradient(var(--maroc-ocre) 0% 25%, var(--maroc-vert) 0% 50%,
    var(--maroc-rouge) 0% 75%, var(--zellige-blue) 0% 100%) 0 0 / 40px 40px;
  border-radius: 8px; border: 3px solid var(--text-gold); opacity: 0.9;
  position: relative; overflow: hidden;
}
.cover-zellige::after {
  content: ''; position: absolute; top:0; left:0; right:0; bottom:0;
  background:
    repeating-linear-gradient(0deg, transparent 0px, transparent 8px, rgba(0,0,0,0.1) 8px, rgba(0,0,0,0.1) 10px),
    repeating-linear-gradient(90deg, transparent 0px, transparent 8px, rgba(0,0,0,0.1) 8px, rgba(0,0,0,0.1) 10px);
}
.cover-title { font-size: 2.8rem; text-shadow: 0 0 20px rgba(212,165,51,0.3), 0 4px 8px rgba(0,0,0,0.5); }
.cover-subtitle { font-size: 1.3rem; color: var(--parchemin); margin: 10px 0; opacity: 0.9; }
.cover-year { font-size: 1rem; color: var(--maroc-ocre-light); letter-spacing: 3px; }
.cover-ornament { font-size: 1.3rem; margin: 12px 0; letter-spacing: 10px; }
.cover-quote { font-size: 1.1rem; color: var(--parchemin); line-height: 1.8; opacity: 0.85; font-style: italic; }
.back-quote { font-size: 1.5rem; line-height: 2; margin-bottom: 20px; }

/* ===== PAGE INNER CONTENT ===== */
.page-inner {
  padding: 25px 30px;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-ornament-top, .page-ornament-bottom {
  text-align: center; color: var(--maroc-ocre);
  font-size: 0.85rem; letter-spacing: 8px; opacity: 0.5;
}
.page-ornament-top { margin-bottom: 15px; }
.page-ornament-bottom { margin-top: 20px; }

.page-title {
  text-align: center; font-size: 1.5rem;
  color: var(--maroc-vert); margin: 15px 0;
}
.page-divider {
  text-align: center; color: var(--maroc-ocre);
  font-size: 0.9rem; letter-spacing: 6px; margin: 10px 0; opacity: 0.6;
}
.dedication {
  text-align: center; font-size: 1.1rem;
  line-height: 2; color: var(--bois-fonce); margin: 20px 0;
}

.song-title {
  text-align: center; font-size: 1.5rem;
  color: var(--maroc-rouge); margin-bottom: 3px;
}
.song-subtitle {
  text-align: center; color: var(--maroc-ocre);
  font-size: 0.85rem; margin-bottom: 15px; opacity: 0.7;
}
.lyrics {
  font-size: 1rem; line-height: 2.1; text-align: center;
  flex: 1; display: flex; flex-direction: column; justify-content: center;
}
.lyrics p { margin-bottom: 6px; }
.history-text { text-align: right; }
.history-text p { margin-bottom: 10px; }
.history-inner { justify-content: flex-start !important; }
.history-inner .lyrics { justify-content: flex-start; padding-top: 10px; }

/* ===== PAGE WITH PHOTO ===== */
.photo-page {
  background: var(--bois-fonce) !important;
  display: flex; align-items: center; justify-content: center;
}
.photo-embed {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 15px;
}
.photo-embed img {
  width: 100%; height: auto; max-height: 70%;
  object-fit: cover; border-radius: 8px;
  border: 3px solid var(--maroc-ocre);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
}
.photo-caption {
  color: var(--parchemin); margin-top: 10px;
  font-size: 0.9rem; text-align: center;
}
.photo-embed.large img { max-height: 85%; }
.photo-embed.small img { border-width: 2px; }

/* ===== PHOTO GRID ===== */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 15px 0;
}
.photo-grid .photo-embed {
  padding: 5px;
}
.photo-grid .photo-embed img {
  max-height: 120px;
  border-width: 2px;
}
.photo-grid-caption {
  text-align: center; font-size: 0.85rem;
  color: var(--maroc-ocre); margin-top: 5px;
}

/* ===== TURN ZONES ===== */
.turn-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  z-index: 30;
  cursor: pointer;
}
.turn-prev { left: 0; }
.turn-next { right: 0; }
.turn-zone::after {
  content: '';
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(193,122,63,0.12);
  transition: all 0.3s;
}
.turn-prev::after { left: 12px; }
.turn-next::after { right: 12px; }
.turn-zone:hover::after {
  background: rgba(193,122,63,0.3);
  width: 44px; height: 44px;
}
.turn-zone.disabled { pointer-events: none; }
.turn-zone.disabled::after { opacity: 0; }

/* ===== FLIP OVERLAY (3D animation) ===== */
.flip-overlay {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.flip-overlay.animating {
  opacity: 1;
  visibility: visible;
}
.flip-overlay.flip-forward {
  left: 50%;
  transform-origin: left center;
  transform: rotateY(0deg);
}
.flip-overlay.flip-forward.flipping {
  transform: rotateY(-180deg);
}
.flip-overlay.flip-backward {
  left: 0;
  transform-origin: right center;
  transform: rotateY(0deg);
}
.flip-overlay.flip-backward.flipping {
  transform: rotateY(180deg);
}

.flip-front, .flip-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  overflow: hidden;
  background: linear-gradient(135deg, var(--parchemin), var(--parchemin-fonce));
}
.flip-front { z-index: 2; }
.flip-back {
  z-index: 1;
  transform: rotateY(180deg);
  background: linear-gradient(135deg, var(--parchemin), var(--parchemin-fonce));
}

/* Shadow effect during flip */
.flip-overlay.flip-forward::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 5;
  background: linear-gradient(90deg, rgba(0,0,0,0.15), transparent 60%);
  pointer-events: none;
}
.flip-overlay.flip-forward.flipping::before {
  background: linear-gradient(270deg, rgba(0,0,0,0.15), transparent 60%);
}

/* ===== HISTORY SECTION (below book) ===== */
.history-section, .discography-section {
  margin-top: 80px;
  background: rgba(44,30,18,0.85);
  padding: 50px 40px; border-radius: 15px;
  border: 6px double var(--maroc-ocre);
  backdrop-filter: blur(10px);
}
.section-zellige-header {
  display: flex; justify-content: center; gap: 12px;
  margin-bottom: 15px; font-size: 1.5rem; color: var(--maroc-ocre-light);
}
.section-title { text-align: center; font-size: 2rem; color: var(--text-gold); margin-bottom: 10px; }
.section-underline {
  width: 120px; height: 3px;
  background: linear-gradient(90deg, transparent, var(--maroc-ocre), transparent);
  margin: 0 auto 30px;
}
.history-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 40px; align-items: start;
}
.history-text-block p { margin-bottom: 16px; line-height: 2; font-size: 1rem; }
.history-text-block strong { color: var(--text-gold); }

.history-photos-block { display: flex; flex-direction: column; gap: 12px; }
.photo-frame {
  background: linear-gradient(145deg, var(--bois), var(--bois-fonce));
  border: 3px solid var(--maroc-ocre); border-radius: 10px; padding: 6px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(212,165,51,0.2);
}
.photo-frame.main .photo-embed img {
  max-height: 300px; width: 100%; object-fit: cover;
  border-radius: 5px;
}
.photo-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.photo-row .photo-embed img {
  width: 100%; height: 150px; object-fit: cover; border-radius: 5px;
}

/* ===== DISCOGRAPHY ===== */
.discography-section { margin-top: 50px; }
.album-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.album-card {
  background: linear-gradient(145deg, rgba(193,122,63,0.2), rgba(60,42,31,0.5));
  border: 2px solid var(--maroc-ocre); border-radius: 12px;
  padding: 20px; text-align: center;
  transition: all 0.3s ease;
}
.album-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(193,122,63,0.3);
  border-color: var(--text-gold);
}
.album-art { font-size: 2.5rem; margin-bottom: 10px; }
.album-card h3 { font-size: 1rem; color: var(--parchemin); margin-bottom: 5px; }
.album-card p { font-size: 0.85rem; color: var(--maroc-ocre-light); }

/* ===== FOOTER ===== */
.footer {
  text-align: center; padding: 50px 20px 30px;
  margin-top: 60px; border-top: 2px solid rgba(193,122,63,0.3);
}
.footer-ornament { color: var(--maroc-ocre); font-size: 1.2rem; letter-spacing: 8px; margin: 10px 0; }
.footer p { font-size: 1.1rem; color: var(--parchemin); margin: 8px 0; }
.footer-small { font-size: 0.85rem !important; color: var(--maroc-ocre-light) !important; opacity: 0.8; }

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
  .book-viewport { height: 450px; }
  .page-inner { padding: 18px 20px; }
  .song-title { font-size: 1.3rem; }
  .lyrics { font-size: 0.9rem; line-height: 1.9; }
  .cover-title { font-size: 2.2rem; }
  .book-header h1 { font-size: 1.1rem; }
  .album-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  body { padding: 10px; }
  .book-container { border-width: 8px; padding: 12px; border-radius: 15px; }
  .book-viewport { height: 380px; }
  .book-header h1 { font-size: 0.95rem; }
  .page-inner { padding: 12px 15px; }
  .song-title { font-size: 1.1rem; }
  .lyrics { font-size: 0.78rem; line-height: 1.7; }
  .cover-title { font-size: 1.6rem; }
  .cover-subtitle { font-size: 1rem; }
  .open-btn { font-size: 1.2rem; padding: 15px 35px; }
  .turn-zone { width: 30%; }
  .history-grid { grid-template-columns: 1fr; }
  .history-section, .discography-section { padding: 25px 15px; margin-top: 40px; }
  .section-title { font-size: 1.4rem; }
  .album-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .album-card { padding: 12px; }
  .photo-row { grid-template-columns: 1fr; }
  .page-indicator { font-size: 0.75rem; }
  .header-ornament { display: none; }
  .close-btn { width: 32px; height: 32px; font-size: 0.85rem; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bois-fonce); }
::-webkit-scrollbar-thumb { background: var(--maroc-ocre); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--maroc-ocre-light); }

/* ===== PRINT ===== */
@media print {
  .open-btn, .close-btn, .zellige-top, .footer,
  .history-section, .discography-section { display: none !important; }
  .book-container.hidden { display: block !important; }
}
