/* Antique Arabic Manuscript Styling & Multi-Page Aesthetics (Abaq Adabi True Identity) */

:root {
  --ink-primary: #141E2E;
  --ink-secondary: #26354A;
  --parchment-bg: #F8F5EE;
  --parchment-card: #F4EEDD;
  --gold-accent: #C5A059;
  --gold-light: #DFC07D;
  --gold-dark: #8C6D2D;
  --emerald-accent: #214320;
}

body {
  background-color: var(--parchment-bg);
  background-image: 
    radial-gradient(#DECFA8 0.8px, transparent 0.8px), 
    radial-gradient(#DECFA8 0.8px, #F8F5EE 0.8px);
  background-size: 32px 32px;
  background-position: 0 0, 16px 16px;
  -webkit-font-smoothing: antialiased;
}

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #EBE3CF;
}
::-webkit-scrollbar-thumb {
  background: #C5A059;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #8C6D2D;
}

/* Utility to hide scrollbars */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Extended Typography Utilities for Card Studio & Readers */
.font-\[\'Cairo\'\] {
  font-family: 'Cairo', 'Noto Kufi Arabic', sans-serif;
}
.font-\[\'Tajawal\'\] {
  font-family: 'Tajawal', 'Noto Kufi Arabic', sans-serif;
}
.font-\[\'Almarai\'\] {
  font-family: 'Almarai', 'Noto Kufi Arabic', sans-serif;
}
.font-\[\'Scheherazade_New\'\] {
  font-family: 'Scheherazade New', 'Amiri', serif;
}

/* Arabic Poetry Classical Two-Hemistich (الصدر والعجز) Layout */
.verse-bayt {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem 1.15rem;
  border-radius: 0.9rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  background-color: #FFFFFF;
}

.verse-bayt:hover {
  background-color: #FAF6ED;
  border-color: var(--gold-accent);
}

.verse-active {
  background-color: #FAF4E4 !important;
  border-right: 4px solid var(--gold-accent) !important;
  box-shadow: 0 2px 8px rgba(197, 160, 89, 0.2);
}

/* Authentic Poetic Divider */
.bayt-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--gold-dark);
  font-size: 0.85rem;
  user-select: none;
}
.bayt-divider::before,
.bayt-divider::after {
  content: "";
  height: 1px;
  width: 28px;
  background: linear-gradient(to right, transparent, var(--gold-accent));
}
.bayt-divider::after {
  background: linear-gradient(to left, transparent, var(--gold-accent));
}

/* Nav Tab Active State */
.nav-tab {
  color: #5C677D;
}
.nav-tab:hover {
  background-color: #EBE3CF;
  color: #1B263B;
}
.nav-tab.active {
  background-color: #1B263B;
  color: #F4EEDD;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Mobile Bottom Nav Bar Active State */
.mobile-nav-btn.active {
  color: #C5A059;
  border-top: 2px solid #C5A059;
}

/* Parchment Glow Effect */
.parchment-glow {
  box-shadow: 0 10px 30px -10px rgba(27, 38, 59, 0.25), 0 0 0 1px rgba(197, 160, 89, 0.3);
}

/* Site-Wide Custom Background Engine from Studio */
#siteCustomBgLayer {
  position: fixed;
  inset: 0;
  background-image: url('assets/site-bg.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  z-index: -2;
  transition: opacity 0.3s ease, filter 0.3s ease;
  pointer-events: none;
}

#siteCustomBgOverlay {
  position: fixed;
  inset: 0;
  background-color: rgba(248, 245, 238, 0.88);
  backdrop-filter: blur(2px);
  z-index: -1;
  transition: background-color 0.3s ease, backdrop-filter 0.3s ease;
  pointer-events: none;
}

/* Dark mode / Low-transparency overlay options */
body.site-bg-dark #siteCustomBgOverlay {
  background-color: rgba(18, 27, 42, 0.88);
}
body.site-bg-subtle #siteCustomBgOverlay {
  background-color: rgba(248, 245, 238, 0.72);
}
body.site-bg-intense #siteCustomBgOverlay {
  background-color: rgba(248, 245, 238, 0.94);
}

/* Hero Custom Cover Styling from Studio */
.hero-cover-layer {
  position: absolute;
  inset: 0;
  background-image: url('assets/hero-cover.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.4s ease, background-image 0.3s ease;
  z-index: 1;
}

.hero-cover-overlay {
  position: absolute;
  inset: 0;
  transition: background 0.3s ease, backdrop-filter 0.3s ease;
  z-index: 2;
}

/* Three distinct cover clarity & reading modes */
.hero-cover-overlay.cover-clear,
#modalCoverPreviewOverlay.cover-clear {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.42) 0%, rgba(27, 38, 59, 0.50) 50%, rgba(37, 55, 78, 0.62) 100%);
  backdrop-filter: blur(0px);
}

.hero-cover-overlay.cover-balanced,
#modalCoverPreviewOverlay.cover-balanced {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.66) 0%, rgba(27, 38, 59, 0.72) 50%, rgba(37, 55, 78, 0.80) 100%);
  backdrop-filter: blur(1px);
}

.hero-cover-overlay.cover-focused,
#modalCoverPreviewOverlay.cover-focused {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(27, 38, 59, 0.86) 50%, rgba(37, 55, 78, 0.92) 100%);
  backdrop-filter: blur(1.5px);
}

/* Portal Cards */
.portal-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.portal-card:hover {
  transform: translateY(-2px);
}
.portal-card:active {
  transform: scale(0.98);
}

/* Story Card Enhancements */
.story-card {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.story-card:hover {
  transform: translateY(-3px);
  border-color: #C5A059;
  box-shadow: 0 8px 20px -4px rgba(140, 109, 45, 0.15);
}

/* Meter Card Rhythm Box */
.meter-card {
  transition: all 0.18s ease;
}
.meter-card:hover {
  border-color: #C5A059;
  box-shadow: 0 4px 12px rgba(197, 160, 89, 0.15);
}

/* Button & interactive feedback */
button:active {
  transform: scale(0.98);
}

/* Membership Card Canvas Crisp Render */
#memberCardCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
}

/* Instagram Story & Quote Template Chips & Cards */
.story-template-card {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.story-template-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold-accent);
  box-shadow: 0 6px 16px -2px rgba(140, 109, 45, 0.18);
}
.story-template-card.active {
  border-color: var(--gold-dark) !important;
  background-color: #FFFDF9 !important;
  box-shadow: 0 0 0 2px var(--gold-accent);
}
.story-template-card.active::after {
  content: "✓ مفعل";
  position: absolute;
  top: 4px;
  left: 6px;
  background: var(--gold-dark);
  color: #FFFFFF;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
}

/* Category Filter Pills Active State */
.template-cat-btn {
  transition: all 0.15s ease;
  cursor: pointer;
  user-select: none;
}
.template-cat-btn:hover {
  border-color: var(--gold-accent);
}
.template-cat-btn.active {
  background-color: #1B263B !important;
  color: #FFFFFF !important;
  border-color: #1B263B !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Motif Buttons Active State */
.motif-btn {
  transition: all 0.15s ease;
  cursor: pointer;
}
.motif-btn.active {
  border-color: var(--gold-accent) !important;
  background-color: #F4EEDD !important;
  border-width: 2px !important;
  box-shadow: 0 1px 2px rgba(197, 160, 89, 0.25);
}

/* Safe Zone Indicator Glow */
#canvasWrapper.safe-zones-active {
  outline: 2px solid #C5A059;
}

/* Reciter Persona Selection Pills & Buttons */
.reciter-pill {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(197, 160, 89, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #D9CEB4;
}
.reciter-pill:hover {
  background: rgba(197, 160, 89, 0.2);
  color: #FFFFFF;
  border-color: #C5A059;
}
.reciter-pill.active {
  background: #C5A059 !important;
  color: #121B2A !important;
  font-weight: 700;
  border-color: #DFC07D !important;
  box-shadow: 0 0 10px rgba(197, 160, 89, 0.4);
}

/* Subtle texture pattern for readers */
.bg-pattern-parchment {
  background-color: #FDFBF7;
  background-image: radial-gradient(#E5DBC5 0.5px, transparent 0.5px);
  background-size: 16px 16px;
}

/* Official Abaq Logo image enhancement */
.abaq-logo-img {
  image-rendering: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

/* Classical Literary Book Feature Artwork */
.hero-book-img {
  image-rendering: auto;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.hero-book-img:hover {
  transform: translateY(-3px) scale(1.04);
}

/* User Identity Avatar Styling & Medallion Glow */
.user-avatar-img {
  image-rendering: auto;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.user-avatar-img:hover {
  transform: scale(1.04);
}

/* Header External App Icon Custom Styling */
#headerAppBrandIcon {
  image-rendering: auto;
  transition: transform 0.2s ease, filter 0.2s ease;
}
#headerAppBrandIcon:hover {
  transform: scale(1.05);
}

.external-app-icon-preview {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Islamic Geometric decorative corners */
.islamic-box-border {
  border: 1px solid #D9CEB4;
  position: relative;
}
.islamic-box-border::before {
  content: "❖";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  color: #C5A059;
}

/* PWA App Platform Tabs Active Styling */
.install-platform-tab {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.install-platform-tab.active {
  box-shadow: 0 2px 6px rgba(197, 160, 89, 0.25);
}

/* Owner Passcode & Creator Hub Security Styling */
#ownerPasscodeInput {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.25em;
}
#ownerPasscodeInput:focus {
  box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}