:root {
  --bg-dark: #07060e;
  --bg-dark-soft: #0e0b1a;
  --text-light: #e2e8f0;
  --text-dark: #0f172a;
}

html,
body {
  min-height: 100%;
}

body {
  color: var(--text-light);
  background: radial-gradient(circle at top, #16112b 0%, var(--bg-dark) 55%);
}

.glass-header {
  background: rgba(7, 6, 14, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand-gradient {
  background: linear-gradient(135deg, #7c3aed 0%, #d946ef 48%, #f97316 100%);
}

.brand-gradient-text {
  background: linear-gradient(135deg, #d946ef 0%, #f97316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.fade-overlay-left,
.fade-overlay-right {
  position: absolute;
  pointer-events: none;
}

.fade-overlay-left {
  background: linear-gradient(to left, rgba(7, 6, 14, 0), rgba(7, 6, 14, 0.95));
}

.fade-overlay-right {
  background: linear-gradient(to right, rgba(7, 6, 14, 0), rgba(7, 6, 14, 0.95));
}

.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 44s linear infinite;
}

.marquee-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-inline: 0.5rem;
}

@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(50%); }
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #d946ef;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .marquee-track { animation: none; }
}

html:not(.dark) body {
  color: var(--text-dark);
  background: #f8fafc;
}

html:not(.dark) .glass-header {
  background: rgba(248, 250, 252, 0.9);
  border-color: rgba(15, 23, 42, 0.08);
}

html:not(.dark) .fade-overlay-left {
  background: linear-gradient(to left, rgba(248, 250, 252, 0), rgba(248, 250, 252, 0.98));
}

html:not(.dark) .fade-overlay-right {
  background: linear-gradient(to right, rgba(248, 250, 252, 0), rgba(248, 250, 252, 0.98));
}

/* ============================================
   Text Overflow Utilities (Phase 1)
   ============================================ */
.overflow-wrap-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.break-words-safe {
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  min-width: 0;
  max-width: 100%;
}

.overflow-safe-card {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.overflow-safe-card h1,
.overflow-safe-card h2,
.overflow-safe-card h3,
.overflow-safe-card h4,
.overflow-safe-card p,
.overflow-safe-card span,
.overflow-safe-card a,
.overflow-safe-card div {
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   Media Gallery & Lightbox
   ============================================ */
.media-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.media-gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: zoom-in;
  transition: transform 0.2s ease, border-color 0.2s ease;
  background: rgba(255, 255, 255, 0.02);
}

.media-gallery-item:hover {
  transform: scale(1.02);
  border-color: rgba(217, 70, 239, 0.5);
}

.media-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-gallery-item .media-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font-size: 1.5rem;
  pointer-events: none;
}

.video-embed-wrapper {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #000;
}

.video-embed-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ============================================
   Toast Enhancements
   ============================================ */
.toast-slide-in {
  animation: toastSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ============================================
   Filter Buttons
   ============================================ */
.filter-chip {
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-chip:hover {
  color: white;
  border-color: rgba(217, 70, 239, 0.5);
}

.filter-chip.active {
  background: linear-gradient(135deg, #7c3aed 0%, #d946ef 48%, #f97316 100%);
  color: white;
  border-color: transparent;
}

/* ============================================
   Mobile Responsive Fixes
   ============================================ */
@media (max-width: 640px) {
  .overflow-safe-card {
    padding: 1rem !important;
  }
  .media-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
}

/* ============================================
   Fancybox RTL tweaks
   ============================================ */
.fancybox__caption {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  direction: rtl;
}



/* ============================================
   Quill Editor RTL Styling
   ============================================ */
.ql-toolbar.ql-snow {
  border-color: rgba(255, 255, 255, 0.1) !important;
  background: rgba(255, 255, 255, 0.02);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  direction: ltr;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.ql-container.ql-snow {
  border-color: rgba(255, 255, 255, 0.1) !important;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  font-size: 14px;
  direction: rtl;
  min-height: 400px;
}

.ql-editor {
  color: #e2e8f0;
  min-height: 400px;
  line-height: 1.9;
  padding: 20px 22px;
}

.ql-editor.ql-blank::before {
  color: rgba(148, 163, 184, 0.6);
  font-style: normal;
  right: 22px;
  left: auto;
}

.ql-editor h2,
.ql-editor h3,
.ql-editor h4 {
  color: #ffffff;
  font-weight: 700;
  margin: 1.2em 0 0.5em;
}

.ql-editor h2 { font-size: 1.5em; }
.ql-editor h3 { font-size: 1.25em; }
.ql-editor h4 { font-size: 1.1em; }

.ql-editor p {
  margin-bottom: 0.8em;
}

.ql-editor a {
  color: #ec4899;
  text-decoration: underline;
}

.ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1em 0;
}

.ql-editor iframe.ql-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  margin: 1em 0;
}

.ql-editor blockquote {
  border-right: 4px solid #d946ef;
  border-left: none;
  padding-right: 16px;
  padding-left: 0;
  color: #cbd5e1;
  font-style: italic;
  margin: 1em 0;
}

.ql-editor pre.ql-syntax,
.ql-editor .ql-code-block-container {
  background: #0a0a14;
  color: #f472b6;
  border-radius: 12px;
  padding: 16px;
  font-family: 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ql-editor ul,
.ql-editor ol {
  padding-right: 24px;
  padding-left: 0;
  margin-bottom: 0.8em;
}

.ql-editor li {
  margin-bottom: 0.4em;
}

.ql-snow .ql-stroke {
  stroke: #94a3b8;
}

.ql-snow .ql-fill,
.ql-snow .ql-stroke.ql-fill {
  fill: #94a3b8;
}

.ql-snow .ql-picker {
  color: #cbd5e1;
}

.ql-snow .ql-picker-options {
  background: #0E0B1A;
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.ql-snow .ql-tooltip {
  background: #0E0B1A;
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.ql-snow .ql-tooltip input[type=text] {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

.ql-snow .ql-active .ql-stroke,
.ql-snow .ql-active .ql-fill {
  stroke: #d946ef;
  fill: #d946ef;
}

.ql-snow button:hover .ql-stroke,
.ql-snow button:focus .ql-stroke {
  stroke: #ec4899;
}

.ql-snow button:hover .ql-fill {
  fill: #ec4899;
}

.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-item:hover {
  color: #ec4899 !important;
}

/* SERP Preview */
#serpPreview {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}
