/*
 * Scarab Rust design tokens.
 * Single source of truth for the brand palette so retheming is one place
 * (the old build hard-coded every hex). Scarab keeps GOLD as the accent but
 * pairs it with a cool JEWEL tone (lapis / faience turquoise) so the identity
 * reads distinct from a warm-only desert, especially at night, when the
 * time-of-day background goes obsidian + lapis. --time-horizon / --time-glow
 * are updated live by scarab-sky.js from the visitor's local clock.
 */
:root {
    --gold: #d4af37;
    --gold-bright: #e6c15a;
    --copper: #d97536;
    --jewel: #2bb3a3;         /* faience turquoise, cool accent / online state */
    --lapis: #1c4e8a;         /* deep Egyptian blue */
    --ink: #0f0a08;           /* near-black ground */
    --panel: #1a1510;         /* warm-dark panel */
    --panel-2: #2a1f15;
    --text: #f5f3e8;          /* cream */
    --line: rgba(212, 175, 55, 0.2);
    --time-horizon: #12141a;  /* live-updated by scarab-scene.js */
    --time-glow: #d4af37;     /* live-updated by scarab-scene.js */

    /*
     * Day/night theme tokens. scarab-scene.js overwrites these on :root every
     * frame from the visitor's local clock, so the page shifts light <-> dark
     * with the sky. These defaults are the night values, so the page looks
     * right before the script runs and on pages not yet converted to tokens.
     */
    --page-bg: #12121a;       /* page background  */
    --page-panel: #191921;    /* card / panel     */
    --page-text: #eef0f6;     /* primary text     */
    --page-muted: #9aa0b0;    /* secondary text   */
    --page-border: rgba(230, 193, 90, 0.16);
    --sky-top: #05070f;
}

/* Base Styles */
/* Paint the document root dark from the very first frame so navigations never
   flash a white screen before body/canvas lay out (the default --page-bg is the
   night value; the pre-paint script in base.html overrides it for a stored phase). */
html { background: var(--page-bg); }
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Mada', sans-serif;
    background: var(--page-bg);
    color: var(--page-text);
    transition: background-color 900ms ease, color 900ms ease;
}

/*
 * Day/night helpers. Any element that opts into the theme uses these instead
 * of a hardcoded hex, so it flips light <-> dark with the sky. Panels get a
 * soft glass fill over whatever the sky is doing behind them.
 */
.tod-text { color: var(--page-text); transition: color 900ms ease; }
.tod-muted { color: var(--page-muted); transition: color 900ms ease; }
.tod-panel {
    background: color-mix(in srgb, var(--page-panel) 96%, transparent);
    color: var(--page-text);
    border: 1px solid var(--page-border);
    transition: background-color 900ms ease, color 900ms ease, border-color 900ms ease;
}
.tod-border { border-color: var(--page-border); transition: border-color 900ms ease; }

/* ---------------------------------------------------------------------------
   Shared wide content container (used by every page agent). Keeps pages from
   collapsing into a thin centre column: content fills the screen up to a
   comfortable reading cap with responsive side padding. Defined here once;
   other files only USE it, never redefine it.
   --------------------------------------------------------------------------- */
.wrap-wide {
    max-width: 1180px;
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2.5rem);
    width: 100%;
}

/* Optional page top-spacing helper so content clears the fixed nav without
   each page hardcoding its own top padding. Purely opt-in. */
.content-top { padding-top: clamp(4.5rem, 9vh, 7rem); }

/* Wider variant of .wrap-wide for pages that want to fill more of the screen
   (comparison tables, dashboards, two-column layouts). Same responsive side
   padding, higher reading cap. Defined once here; other files only USE it. */
.wrap-wider {
    max-width: 1320px;
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2.5rem);
    width: 100%;
}

/* Smooth-scroll anchor helper. A target with .scroll-target lands below the
   fixed navbar (h-16 = 4rem) instead of hiding under it after a smooth scroll
   or an in-page #anchor jump. The extra ~1rem is breathing room. */
.scroll-target { scroll-margin-top: 5rem; }

/* Reusable gold button + signup field (global so the signup include works on
   any page, not just ones that define their own .cta-* styles). */
/* border:1px solid transparent + background-clip:padding-box keeps the gradient
   from fringing past the rounded corner (the "bleed"); the hover glow is kept
   tight (short blur, low opacity) so gold does not halo far past the button. */
.btn-gold { background: linear-gradient(90deg, var(--gold), var(--copper)); color: #1a1510; font-weight: 600; border: 1px solid transparent; background-clip: padding-box; transition: transform .18s ease, box-shadow .24s ease; }

/* Site-wide gold-CTA corner-bleed fix. Root cause: a rule that sets the
   `background` SHORTHAND (e.g. `background: linear-gradient(...)`) resets
   background-clip back to border-box, so the gradient fills to the sharp
   corner and fringes past the border-radius. A 1px transparent border plus
   background-clip:padding-box (marked important so it survives any later
   shorthand reset in a per-page <style> block that loads after this file)
   insets the fill so no gold ever bleeds at the corner. Outer hover glows
   (box-shadow) are untouched. box-sizing:border-box (Tailwind preflight)
   keeps the 1px border from changing the button size. */
.btn-gold, .cta-gold, .cta-primary, .cta-gold-lg, .creator-btn-gold,
.cookie-btn-accept, .btn-manage, .srv-cta, .srv-cta-gold, .sp-cta,
.sp-tab.active, .rk-cta, .ea-cta, .signup-btn, .cta-band-btn,
[class*="cta-gold"], [class*="btn-gold"] {
    border: 1px solid transparent;
    background-clip: padding-box !important;
    box-sizing: border-box;
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--gold) 42%, transparent); }
.signup-input {
    background: color-mix(in srgb, var(--page-panel) 88%, transparent);
    border: 1px solid var(--page-border); color: var(--page-text);
    outline: none; transition: border-color .18s ease, background-color .9s ease, color .9s ease;
}
.signup-input:focus { border-color: var(--gold); }
.signup-input::placeholder { color: var(--page-muted); }
@supports not (background: color-mix(in srgb, red, blue)) {
    .tod-panel { background: var(--page-panel); }
}

/* ---------------------------------------------------------------------------
   Arabic reads right-to-left at the TEXT level only. The document stays dir=ltr
   so the nav, grids, cards and footer never mirror (that whole-layout flip was
   the old bug). Here we flow prose containers RTL so Arabic sentences align
   naturally, without touching structural layout.
   --------------------------------------------------------------------------- */
html[data-lang-rtl] .main-content p,
html[data-lang-rtl] .main-content h1,
html[data-lang-rtl] .main-content h2,
html[data-lang-rtl] .main-content h3,
html[data-lang-rtl] .main-content h4,
html[data-lang-rtl] .main-content li,
html[data-lang-rtl] .main-content blockquote,
html[data-lang-rtl] [dir="rtl"] { direction: rtl; }

/* HARD no-flip guarantee. Some Arabic pages wrap their whole content in a
   dir="rtl" container, which would mirror every flex row and grid inside it
   (cards reorder, icons jump sides). The document root is always dir=ltr so
   the navbar and footer never flip; here we also stop structural layout from
   mirroring inside any rtl container: text still reads right-to-left, but
   horizontal flex rows and grid tracks keep their left-to-right visual order.
   Vertical stacks (flex-col) stay rtl so column text aligns correctly. */
[dir="rtl"] .flex:not(.flex-col),
[dir="rtl"] [class*="grid-cols-"] { direction: ltr; }
[dir="rtl"] .flex-col { direction: rtl; }

/* Time-of-day sky canvas + no-JS/reduced-motion fallback gradient. */
#scarab-sky {
    display: block;
    width: 100%;
    height: 100%;
}

.desert-bg {
    background: linear-gradient(to bottom, var(--ink) 0%, var(--time-horizon) 100%);
}

.main-content {
    flex: 1;
    min-height: 100vh;
    position: relative;
}

/* ---------------------------------------------------------------------------
   Footer. Deliberately not Falcon's four-column SaaS grid: a horizon rule the
   scarab rolls the sun-disc along (Khepri), a wide brand block, and a tight
   three-column link cluster. Fixed dark ink (its own --foot-* tokens) so it
   stays readable in every sky phase instead of washing out at day/sunrise.
   --------------------------------------------------------------------------- */
.scarab-footer {
    /*
     * Fixed dark ink footer. Deliberately does NOT track the day/night
     * --page-* tokens: at sunrise and midday the light panel tokens washed the
     * footer out to an unreadable pale slab. Locking it to dark ink with its
     * own cream / warm-grey text keeps it readable in every sky phase.
     */
    --foot-text: #f2e8d8;      /* cream link/idle text */
    --foot-muted: #b3a894;     /* light warm grey secondary */
    --foot-border: rgba(212, 175, 55, 0.14);
    background: #17140f;
    border-top: 1px solid var(--foot-border);
    color: var(--foot-text);
}
.scarab-shell { max-width: 1440px; margin: 0 auto; padding: 2.4rem clamp(1rem, 4vw, 3rem) 1.8rem; }

/* Horizon: a hairline with a gradient sun glow the scarab rolls along it. */
.scarab-horizon {
    position: relative; height: 2px; margin: 0 auto; max-width: 1440px;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 55%, transparent) 30%, color-mix(in srgb, var(--jewel) 45%, transparent) 70%, transparent);
}
.scarab-sun {
    position: absolute; top: 50%; left: 14%; width: 10px; height: 10px; border-radius: 50%;
    transform: translateY(-50%);
    background: var(--gold);
    box-shadow: 0 0 16px 3px color-mix(in srgb, var(--gold) 70%, transparent);
}
.scarab-roller {
    position: absolute; top: 50%; left: calc(14% + 16px); width: 22px; height: 22px;
    transform: translateY(-50%); opacity: .9;
}

.scarab-foot-top {
    display: grid; grid-template-columns: 1.5fr 2fr; gap: clamp(2rem, 6vw, 5rem);
    padding-top: 2rem;
}
@media (max-width: 820px) { .scarab-foot-top { grid-template-columns: 1fr; gap: 2rem; } }

.scarab-foot-mark { display: inline-flex; align-items: center; gap: .6rem; }
.scarab-foot-mark span { font-size: 1.15rem; font-weight: 700; color: var(--gold); letter-spacing: -.01em; }
.scarab-foot-line {
    margin-top: 1rem; max-width: 42ch; font-size: .9rem; line-height: 1.65;
    color: var(--foot-muted);
}
.scarab-social { display: flex; gap: .55rem; margin-top: 1.25rem; }
.scarab-social a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    color: var(--foot-text); opacity: .82;
    background: rgba(242, 232, 216, 0.06);
    border: 1px solid var(--foot-border);
    transition: color .16s ease, opacity .16s ease, background-color .16s ease, transform .16s ease;
}
.scarab-social a:hover { color: var(--gold); opacity: 1; transform: translateY(-2px); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.scarab-social svg { width: 18px; height: 18px; }

.scarab-foot-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
@media (max-width: 480px) { .scarab-foot-cols { grid-template-columns: repeat(2, 1fr); gap: 1.75rem 1rem; } }
.scarab-foot-cols h4 {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
    color: var(--gold); opacity: .85; margin-bottom: .9rem;
}
.scarab-foot-cols a {
    display: block; font-size: .9rem; color: var(--foot-muted); padding: .28rem 0;
    transition: color .16s ease, padding-inline-start .16s ease;
}
.scarab-foot-cols a:hover { color: var(--gold-bright); padding-inline-start: .3rem; }

.scarab-foot-base {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .75rem 1.5rem; margin-top: 2.25rem; padding-top: 1.25rem;
    border-top: 1px solid var(--foot-border);
    font-size: .82rem; color: var(--foot-muted);
}
.scarab-foot-legal { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.scarab-foot-legal a { color: var(--foot-muted); transition: color .16s ease; }
.scarab-foot-legal a:hover { color: var(--gold-bright); }
@media (prefers-reduced-motion: reduce) {
    .scarab-footer, .scarab-social a, .scarab-foot-cols a { transition: none; }
}

/*
 * Keep page content above the fixed scene WITHOUT depending on Tailwind's
 * z-20 utility loading first. If the (slow, render-blocking) Tailwind runtime
 * is late, the fixed canvas must never paint over the content.
 */
#main-content {
    position: relative;
    z-index: 20;
}

/*
 * The scene is a FIXED viewport background so the day/night dunes stay put
 * while content scrolls over them (rather than stretching down a long page and
 * pushing the horizon off-screen). Content sits in #main-content at z-20.
 */
.desert-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 0;
    pointer-events: none;
}

/* Alpine.js Cloak */
[x-cloak] {
    display: none !important;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

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

@keyframes glowShift {
    0%, 100% {
        filter: drop-shadow(0 8px 24px rgba(212, 175, 55, 0.4));
    }
    33% {
        filter: drop-shadow(0 8px 24px rgba(217, 117, 54, 0.4));
    }
    66% {
        filter: drop-shadow(0 8px 24px rgba(245, 243, 232, 0.3));
    }
}

/* Animation Classes */
.dune-bg-layer {
    animation: duneSlideUp 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
}

.dune-bg-1 {
    animation-delay: 0.1s;
}

.dune-bg-2 {
    animation-delay: 0.2s;
}

.dune-bg-3 {
    animation-delay: 0.3s;
}

.dune-bg-4 {
    animation-delay: 0.4s;
}

.logo-glow {
    animation: glowShift 4s ease-in-out infinite;
}

.fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.pulse-badge {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Utility Classes */
.gradient-text {
    background: linear-gradient(135deg, var(--gold) 0%, var(--copper) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Content Gradient Overlay */
.main-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(to bottom, transparent 0%, var(--ink) 100%);
    z-index: 5;
    pointer-events: none;
}

/* Scroll Reveal Animations */
@keyframes fadeInUpScroll {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scroll-reveal {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Tooltip Styles */
.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(212, 175, 55, 0.95);
    color: #1a1510;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(212, 175, 55, 0.95);
}

/* Button Ripple Effect */
.ripple-container {
    position: relative;
    overflow: hidden;
}

@keyframes ripple {
    from {
        opacity: 1;
        transform: scale(0);
    }
    to {
        opacity: 0;
        transform: scale(4);
    }
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    animation: ripple 0.6s ease-out;
}

/* Loading Spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(26, 21, 16, 0.3);
    border-top-color: #1a1510;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Enhanced Logo Animation */
@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(2deg);
    }
}

.logo-float {
    animation: logoFloat 3s ease-in-out infinite;
}

/* Smooth Transitions */
.transition-smooth {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stagger Animation Delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
