/* ==========================================================================
 * assets/css/theme.css
 * Dark / light mode theming tokens, surfaces, scrollbars, base typography.
 * Loaded BEFORE effects.css. Works with Tailwind `darkMode:'class'`.
 * ========================================================================== */

/* ---------- Base reset ---------- */
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  overscroll-behavior: none;
  background: #ffffff;
  color: #1e293b;
  transition: background-color .5s ease, color .5s ease;
}
html.dark body {
  background: #050810;
  color: #cbd5e1;
}
main > :first-child { margin-top: 0 !important; }
main > :last-child { margin-bottom: 0 !important; }

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Smooth theme transition */
.th, .th * {
  transition: background-color .35s ease, border-color .35s ease, color .35s ease;
}

/* ---------- Anchor offset (compensate fixed header) ---------- */
main section[id] { scroll-margin-top: 6rem; }
@media (min-width: 768px) {
  main section[id] { scroll-margin-top: 7rem; }
}
@media (min-width: 1280px) {
  main section[id] { scroll-margin-top: 10rem; }
}

/* ---------- Modern pill navigation ---------- */
.nav-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .45rem .7rem;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: rgb(51 65 85); /* ink-700 */
  border-radius: 9999px;
  transition: background-color .3s ease, color .3s ease, transform .25s ease, box-shadow .3s ease;
  white-space: nowrap;
}
@media (min-width: 1360px) {
  .nav-pill { padding: .5rem .9rem; font-size: .82rem; gap: .35rem; }
}
@media (min-width: 1536px) {
  .nav-pill { padding: .55rem 1.05rem; font-size: .875rem; }
}
html.dark .nav-pill { color: rgb(203 213 225); }
.nav-pill .material-symbols-outlined {
  font-size: 16px;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), color .3s ease;
}
.nav-pill:hover {
  color: rgb(220 38 38);
  background: rgba(239, 68, 68, .08);
  transform: translateY(-1px);
}
html.dark .nav-pill:hover {
  color: rgb(248 113 113);
  background: rgba(239, 68, 68, .12);
}
.nav-pill:hover .material-symbols-outlined {
  transform: scale(1.15) rotate(-6deg);
}
.nav-pill.active {
  color: #fff;
  background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
  box-shadow: 0 6px 18px -8px rgba(239, 68, 68, .55), 0 0 0 1px rgba(239, 68, 68, .1) inset;
}
.nav-pill.active .material-symbols-outlined { color: #fff; }

/* ---------- Header scroll state ---------- */
.utility-bar {
  max-height: 40px;
  transition: max-height .4s cubic-bezier(.2,.8,.2,1), opacity .3s ease, transform .3s ease;
  opacity: 1;
}
.main-bar {
  transition: background-color .3s ease, box-shadow .3s ease, backdrop-filter .3s ease;
}
#site-header .main-bar > div {
  transition: height .35s cubic-bezier(.2,.8,.2,1);
}
#site-header.is-scrolled .utility-bar {
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
}
#site-header.is-scrolled .main-bar {
  box-shadow: 0 8px 32px -12px rgba(15, 23, 42, .18);
}
html.dark #site-header.is-scrolled .main-bar {
  box-shadow: 0 8px 32px -12px rgba(0, 0, 0, .55);
  background: rgba(15, 23, 42, .8);
}
@media (min-width: 1280px) {
  #site-header.is-scrolled .main-bar > div { height: 76px !important; }
}

/* ---------- Glass surface (used by header + panels) ---------- */
.glass {
  background: rgba(255, 255, 255, .7);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(226, 232, 240, .9);
}
html.dark .glass {
  background: rgba(15, 23, 42, .55);
  border-color: rgba(51, 65, 85, .7);
}

/* ---------- Grid backgrounds ---------- */
.dot-grid {
  background-image: radial-gradient(rgba(148, 163, 184, 0.25) 1px, transparent 1px);
  background-size: 24px 24px;
}
html.dark .dot-grid {
  background-image: radial-gradient(rgba(248, 113, 113, 0.18) 1px, transparent 1px);
}

.blue-grid {
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, .12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, .12) 1px, transparent 1px);
  background-size: 60px 60px;
}
html.dark .blue-grid {
  background-image:
    linear-gradient(to right, rgba(248, 113, 113, .10) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(248, 113, 113, .10) 1px, transparent 1px);
}

/* ---------- Gradient text ---------- */
.text-grad {
  background: linear-gradient(90deg, #ef4444, #f97316, #ef4444);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 4s linear infinite;
}
html.dark .text-grad {
  background: linear-gradient(90deg, #f87171, #fb923c, #f87171);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 4s linear infinite;
}

/* ---------- Divider ---------- */
.divider-wave {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(148, 163, 184, .35), transparent);
}
html.dark .divider-wave {
  background: linear-gradient(90deg, transparent, rgba(248, 113, 113, .35), transparent);
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(#ef4444, #b91c1c);
  border-radius: 8px;
}
html.dark ::-webkit-scrollbar-track { background: #0f172a; }
html.dark ::-webkit-scrollbar-thumb {
  background: linear-gradient(#7f1d1d, #dc2626);
}

/* ---------- Theme toggle (sun/moon switch) ---------- */
.switch {
  position: relative;
  width: 58px;
  height: 30px;
  border-radius: 9999px;
  background: #e2e8f0;
  transition: background .35s;
  cursor: pointer;
  border: none;
  padding: 0;
  flex-shrink: 0;
}
html.dark .switch { background: #1e293b; }
.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 6, 23, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .45s cubic-bezier(.2, .8, .2, 1), background .35s;
  color: #f59e0b;
}
html.dark .switch .knob {
  transform: translateX(28px);
  background: #0f172a;
  color: #f87171;
  box-shadow: 0 0 12px rgba(248, 113, 113, .4);
}

/* ---------- Hero blobs (theme aware opacity) ---------- */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
  pointer-events: none;
  transition: opacity .4s ease;
}
.blob-b1 { width: 520px; height: 520px; background: #dc2626; top: -10%; right: -8%; }
.blob-b2 { width: 420px; height: 420px; background: #f97316; bottom: -12%; right: 20%; opacity: .35; }
.blob-b3 { width: 380px; height: 380px; background: #1d4ed8; top: 30%; left: -10%; opacity: .25; }
html.dark .blob { opacity: .35; }
html.dark .blob-b3 { opacity: .35; }

/* ---------- Cursor glow ---------- */
#cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 480px; height: 480px;
  pointer-events: none;
  border-radius: 50%;
  z-index: 1;
  mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(239, 68, 68, .16), transparent 60%);
  transform: translate(-50%, -50%);
  transition: opacity .3s;
  opacity: 0;
}
html.dark #cursor-glow {
  background: radial-gradient(circle, rgba(248, 113, 113, .20), transparent 60%);
  mix-blend-mode: plus-lighter;
}
body.cursor-live #cursor-glow { opacity: 1; }
@media (hover: none) { #cursor-glow { display: none; } }

/* ---------- Scroll progress ---------- */
#scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #ef4444, #f97316);
  z-index: 60;
  box-shadow: 0 0 12px rgba(239, 68, 68, .7);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal, .reveal-l, .reveal-r, .stagger > * {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------- Arabic RTL support ---------- */
html[dir="rtl"] body,
html[dir="rtl"] .font-display,
html[dir="rtl"] .font-body {
  font-family: 'Cairo', 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
}
html[dir="rtl"] .font-mono {
  /* keep JetBrains Mono for numbers/latin codes even in Arabic */
  font-family: 'JetBrains Mono', 'Cairo', ui-monospace, monospace;
}
html[dir="rtl"] .uppercase { letter-spacing: 0; }
html[dir="rtl"] .tracking-tight,
html[dir="rtl"] .tracking-wider,
html[dir="rtl"] .tracking-widest { letter-spacing: 0; }
html[dir="rtl"] input,
html[dir="rtl"] textarea,
html[dir="rtl"] select { text-align: right; }
html[dir="rtl"] .rtl\:flip svg[dir="auto"] { transform: scaleX(-1); }
/* Mirror reveal-l / reveal-r slide directions in RTL */
html[dir="rtl"] .reveal-l { transform: translateX(24px); }
html[dir="rtl"] .reveal-r { transform: translateX(-24px); }

/* ---------- Legal information modal ---------- */
#legal-modal-body h4 {
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b91c1c;
  margin: 1.75rem 0 .5rem;
}
#legal-modal-body h4:first-child { margin-top: 0; }
#legal-modal-body p { margin-bottom: .8rem; line-height: 1.7; }
#legal-modal-body ul { margin: 0 0 .9rem; padding: 0; list-style: none; display: grid; gap: .4rem; }
#legal-modal-body li { position: relative; padding-left: 1.15rem; line-height: 1.65; }
#legal-modal-body li::before {
  content: '';
  position: absolute;
  left: 0;
  top: .6em;
  width: .4rem;
  height: .4rem;
  border-radius: 2px;
  background: #dc2626;
}
#legal-modal-body strong { font-weight: 700; color: #0f172a; }
#legal-modal-body a { font-weight: 600; color: #dc2626; text-decoration: underline; text-underline-offset: 2px; }
html.dark #legal-modal-body h4 { color: #f87171; }
html.dark #legal-modal-body strong { color: #fff; }
html[dir="rtl"] #legal-modal-body li { padding-left: 0; padding-right: 1.15rem; }
html[dir="rtl"] #legal-modal-body li::before { left: auto; right: 0; }
html[dir="rtl"] #legal-modal-body h4 { letter-spacing: 0; }

