/* ============================================================
   Haneen v2 — "Midnight Neon" modern SaaS layer
   Design language per modern-web-design skill:
   dark neutrals, neon glows, glass surfaces, inertia scroll,
   scroll-triggered reveals, GPU transforms, reduced-motion safe.
   Loaded only by the public layouts (default.php, academy.php).
   ============================================================ */

/* Decorative bleed guard — absolutely positioned ornaments
   (glow orbs, ambient shapes) may extend past the viewport edge
   by design; clip them at the body level so they never create
   horizontal page scroll. `clip` (unlike `hidden`) does not
   create a scroll container, so position:sticky keeps working. */
body { overflow-x: clip }

/* ---------- Theme-aware card surface -----------------------
   Views hardcode Tailwind's bg-white on cards/modals. Under the
   midnight theme we remap those utilities to the --card-rgb
   token so every existing card becomes a dark glass surface
   without touching view markup. Print sheets keep real white. */
[data-theme="midnight"] .bg-white          { background-color: rgb(var(--card-rgb)) }
[data-theme="midnight"] .bg-white\/5       { background-color: rgb(var(--card-rgb) / .05) }
[data-theme="midnight"] .bg-white\/10      { background-color: rgb(var(--card-rgb) / .10) }
[data-theme="midnight"] .bg-white\/20      { background-color: rgb(var(--card-rgb) / .20) }
[data-theme="midnight"] .bg-white\/30      { background-color: rgb(var(--card-rgb) / .30) }
[data-theme="midnight"] .bg-white\/40      { background-color: rgb(var(--card-rgb) / .40) }
[data-theme="midnight"] .bg-white\/50      { background-color: rgb(var(--card-rgb) / .50) }
[data-theme="midnight"] .bg-white\/60      { background-color: rgb(var(--card-rgb) / .60) }
[data-theme="midnight"] .bg-white\/70      { background-color: rgb(var(--card-rgb) / .70) }
[data-theme="midnight"] .bg-white\/80      { background-color: rgb(var(--card-rgb) / .80) }
[data-theme="midnight"] .bg-white\/90      { background-color: rgb(var(--card-rgb) / .90) }
[data-theme="midnight"] .bg-white\/95      { background-color: rgb(var(--card-rgb) / .95) }
[data-theme="midnight"] .hover\:bg-white:hover { background-color: rgb(var(--card-rgb)) }
[data-theme="midnight"] .print-sheet.bg-white,
[data-theme="midnight"] .bg-white.print-sheet { background-color: #ffffff }

/* Timetable print sheets must stay paper-white in every theme. */
@media print {
    [data-theme="midnight"] .bg-white,
    [data-theme="midnight"] [class*="bg-white/"] { background-color: #ffffff !important }
}

/* ---------- Ambient neon backdrop (midnight only) ---------- */
[data-theme="midnight"] body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(42rem 30rem at 82% -8%, rgb(var(--glow-rgb) / .16), transparent 62%),
        radial-gradient(38rem 30rem at 8% 108%, rgb(var(--glow2-rgb) / .10), transparent 60%),
        radial-gradient(50rem 40rem at 50% 50%, rgb(var(--primary-rgb) / .05), transparent 70%);
}
[data-theme="midnight"] .paper-texture {
    background-image: none; /* flat deep base — glows come from body::before */
}
[data-theme="midnight"] ::selection {
    background: rgb(var(--primary-rgb) / .45);
    color: #fff;
}
[data-theme="midnight"] ::-webkit-scrollbar { width: 10px; height: 10px }
[data-theme="midnight"] ::-webkit-scrollbar-track { background: rgb(var(--surface-rgb)) }
[data-theme="midnight"] ::-webkit-scrollbar-thumb {
    background: rgb(var(--uiline-rgb));
    border-radius: 8px;
    border: 2px solid rgb(var(--surface-rgb));
}
[data-theme="midnight"] ::-webkit-scrollbar-thumb:hover { background: rgb(var(--muted-rgb)) }

/* Midnight swaps serif display type for tight-tracking sans. */
[data-theme="midnight"] h1,
[data-theme="midnight"] h2,
[data-theme="midnight"] h3,
[data-theme="midnight"] .font-serif {
    font-family: 'Outfit', 'Noto Sans Arabic', sans-serif;
    letter-spacing: -0.02em;
}
[dir="rtl"][data-theme="midnight"] h1,
[dir="rtl"][data-theme="midnight"] h2,
[dir="rtl"][data-theme="midnight"] h3,
[dir="rtl"][data-theme="midnight"] .font-serif {
    font-family: 'Noto Sans Arabic', 'Outfit', sans-serif;
    letter-spacing: 0;
}

/* Theme-aware logo: black wordmark for light themes, white for midnight. */
.theme-logo-dark { display: none }
[data-theme="midnight"] .theme-logo-light { display: none }
[data-theme="midnight"] .theme-logo-dark  { display: block }

/* ---------- Glass + glow primitives ---------- */
.glass {
    background: rgb(var(--card-rgb, 255 255 255) / .55);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    backdrop-filter: blur(14px) saturate(1.4);
    border: 1px solid rgb(var(--uiline-rgb) / .8);
}
.glass-hover { transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease }
.glass-hover:hover {
    border-color: rgb(var(--primary-rgb) / .5);
    box-shadow: 0 8px 40px -12px rgb(var(--primary-rgb) / .35);
    transform: translateY(-3px);
}
.text-gradient {
    background: linear-gradient(92deg,
        rgb(var(--primary-light-rgb)) 0%,
        rgb(var(--glow-rgb, var(--accent-rgb))) 45%,
        rgb(var(--glow2-rgb, var(--primary-rgb))) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.btn-glow {
    box-shadow:
        0 0 0 1px rgb(var(--primary-light-rgb) / .35) inset,
        0 4px 24px -4px rgb(var(--primary-rgb) / .55),
        0 0 56px -8px rgb(var(--primary-rgb) / .4);
    transition: box-shadow .25s ease, transform .15s ease, background-color .2s ease;
}
.btn-glow:hover {
    box-shadow:
        0 0 0 1px rgb(var(--primary-light-rgb) / .55) inset,
        0 6px 32px -4px rgb(var(--primary-rgb) / .7),
        0 0 80px -8px rgb(var(--primary-rgb) / .55);
}
/* Decorative glow orb — absolutely positioned inside .relative parents */
.glow-orb {
    position: absolute;
    border-radius: 9999px;
    filter: blur(72px);
    pointer-events: none;
    z-index: -1;
}
.glow-orb-a { background: rgb(var(--glow-rgb, var(--primary-rgb)) / .35) }
.glow-orb-b { background: rgb(var(--glow2-rgb, var(--accent-rgb)) / .22) }

/* Soft pulse used sparingly on the hero badge dot */
@keyframes rv-pulse {
    0%, 100% { opacity: 1; transform: scale(1) }
    50%       { opacity: .55; transform: scale(.78) }
}
.rv-dot-pulse { animation: rv-pulse 2.2s ease-in-out infinite }

/* ---------- Glass header that intensifies on scroll ---------- */
.site-header {
    transition: background-color .3s ease, box-shadow .3s ease, border-color .3s ease;
    -webkit-backdrop-filter: blur(16px) saturate(1.5);
    backdrop-filter: blur(16px) saturate(1.5);
}
[data-theme="midnight"] .site-header {
    background: rgb(var(--surface-rgb) / .72);
    border-bottom-color: rgb(255 255 255 / .06);
}
[data-theme="midnight"] .site-header.is-scrolled {
    background: rgb(var(--surface-rgb) / .88);
    border-bottom-color: rgb(255 255 255 / .1);
    box-shadow: 0 12px 40px -18px rgb(0 0 0 / .8);
}
/* Light themes: header keeps a subtle blur veil */
.site-header:not(.is-scrolled) { box-shadow: none }

/* ---------- Scroll-reveal engine (Framer-Motion parity) ----
   <html class="rv"> is added by an inline script in the layout
   <head>, so no-JS visitors always see fully-rendered content. */
html.rv [data-rv] {
    opacity: 0;
    transform: translate3d(0, 40px, 0);
    transition:
        opacity .7s cubic-bezier(.21, .47, .32, .98),
        transform .7s cubic-bezier(.21, .47, .32, .98);
    transition-delay: var(--rv-delay, 0ms);
    will-change: opacity, transform;
}
html.rv [data-rv="down"]  { transform: translate3d(0, -40px, 0) }
html.rv [data-rv="left"]  { transform: translate3d(40px, 0, 0) }
html.rv [data-rv="right"] { transform: translate3d(-40px, 0, 0) }
html.rv [data-rv="zoom"]  { transform: scale(.92) }
html.rv [data-rv].rv-in {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

/* ---------- 3D laptop showcase (scroll-driven) ---------- */
.laptop-showcase {
    position: relative;
    height: 300vh;
    margin: 0 -1rem 2rem;
}
.laptop-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.laptop-scene {
    position: relative;
    perspective: 1500px;
    perspective-origin: 50% 42%;
    padding-bottom: 22%; /* reserves space for the 3D base's projection */
}
.laptop3d {
    /* Defaults = fully open, frontal: correct for no-JS / reduced-motion. */
    --rx: 6deg;
    --ry: 0deg;
    --lid: 4deg;
    position: relative;
    width: min(620px, 84vw);
    aspect-ratio: 16 / 10;
    transform-style: preserve-3d;
    transform: rotateX(var(--rx)) rotateY(var(--ry));
}
/* Lid = screen half, hinged at its bottom edge; --lid ≈ -88° = shut,
   ~+5° = open leaning slightly back. */
.laptop-lid {
    position: absolute;
    inset: 0;
    transform-origin: 50% 100%;
    transform: rotateX(var(--lid));
    transform-style: preserve-3d;
    border-radius: 14px;
    background: linear-gradient(165deg, #2b2b34 0%, #17171d 60%, #101015 100%);
    padding: 2.4% 2.4% 5.5%;
    box-shadow:
        inset 0 0 0 1px rgb(255 255 255 / .08),
        0 40px 90px -25px rgb(0 0 0 / .75);
}
/* Lid back cover — visible when viewed from behind mid-rotation. */
.laptop-lid::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(150deg, #23232c, #131318);
    transform: translateZ(-2px);
}
.laptop-camera {
    position: absolute;
    top: 1.1%;
    left: 50%;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #3d3d49;
    box-shadow: inset 0 0 2px rgb(56 189 248 / .6);
    transform: translateX(-50%);
}
.laptop-screen {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #050508;
    box-shadow: 0 0 0 1px rgb(255 255 255 / .06);
}
.screen-shot {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: top;
    opacity: 0;
    transition: opacity 1s ease;
}
.screen-shot.on { opacity: 1 }
/* Base = keyboard deck folding out toward the viewer from the lid hinge. */
.laptop-base {
    position: absolute;
    top: 100%;
    left: -3.5%;
    width: 107%;
    height: 44%;
    transform-origin: 50% 0;
    transform: rotateX(78deg);
    border-radius: 0 0 12px 12px;
    background: linear-gradient(180deg, #2e2e38 0%, #1b1b22 55%, #121218 100%);
    box-shadow:
        inset 0 1px 0 rgb(255 255 255 / .1),
        0 30px 70px -18px rgb(0 0 0 / .85);
}
.laptop-base::before { /* keyboard well */
    content: "";
    position: absolute;
    top: 14%; left: 6%; right: 6%;
    height: 46%;
    border-radius: 6px;
    background:
        repeating-linear-gradient(0deg, rgb(255 255 255 / .055) 0 3px, transparent 3px 8px),
        repeating-linear-gradient(90deg, rgb(255 255 255 / .05) 0 3px, transparent 3px 12px);
    opacity: .6;
}
.laptop-base::after { /* trackpad */
    content: "";
    position: absolute;
    bottom: 9%;
    left: 50%;
    transform: translateX(-50%);
    width: 26%;
    height: 24%;
    border-radius: 6px;
    background: rgb(255 255 255 / .045);
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / .07);
}
/* Palm-rest notch on the front lip */
.laptop-notch {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 16%;
    height: 7px;
    border-radius: 0 0 10px 10px;
    background: rgb(0 0 0 / .45);
}
.laptop-glow {
    position: absolute;
    bottom: -12%;
    left: 50%;
    transform: translateX(-50%);
    width: 75%;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgb(var(--glow-rgb, 139 92 246) / .4), transparent 72%);
    filter: blur(22px);
    pointer-events: none;
}
/* Slideshow progress dots — flow item below .laptop-scene; the scene's
   padding-bottom keeps the 3D base's projection clear of them. */
.laptop-dots {
    display: flex;
    gap: 8px;
}
.laptop-dots span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgb(var(--muted-rgb) / .35);
    transition: background .4s ease, transform .4s ease;
}
.laptop-dots span.on {
    background: rgb(var(--primary-light-rgb));
    transform: scale(1.35);
}
@media (max-width: 640px) {
    .laptop-showcase { height: 220vh }
    .laptop3d { width: min(420px, 92vw) }
}
/* Reduced-motion fallback is JS-gated via html.rm (set by laptop3d.js)
   so a ?motion=on preview override can bypass it. */
html.rm .laptop-showcase { height: auto }
html.rm .laptop-sticky { position: static; height: auto; padding: 3rem 0 }

/* ---------- Lenis smooth-scroll niceties ---------- */
html.lenis, html.lenis body { height: auto }
.lenis.lenis-smooth { scroll-behavior: auto !important }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain }
.lenis.lenis-stopped { overflow: hidden }

/* ---------- Accessibility: reduced motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
    html.rv [data-rv] {
        transition: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .rv-dot-pulse { animation: none !important }
    .glass-hover, .glass-hover:hover { transition: none; transform: none }
    * { scroll-behavior: auto !important }
}
@media print {
    html.rv [data-rv] { opacity: 1 !important; transform: none !important }
    [data-theme="midnight"] body::before { display: none }
}
