/* ── Variables ── */
:root {
    --flux-primary: #ffffff;
    --flux-secondary: #0a0a0a;
    --flux-accent: #3b82f6;
    --glass: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.08);
}

* {
    selection-background-color: var(--flux-accent);
}

/* ── Base ── */
body {
    background-color: var(--flux-secondary);
    color: var(--flux-primary);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    margin: 0;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ── Mobile overrides ── */
@media (max-width: 768px) {
    html {
        background-color: var(--flux-secondary);
        color-scheme: dark;
    }

    :root {
        --flux-primary: #ffffff;
        --flux-secondary: #0a0a0a;
        --glass: rgba(255, 255, 255, 0.03);
        --border: rgba(255, 255, 255, 0.08);
    }

    body {
        background-color: var(--flux-secondary);
        color: var(--flux-primary);
    }
}

/* ── Custom Cursor ── */
@media (hover: hover) and (pointer: fine) {
    html, body { cursor: none; }
    a, button, [role='button'], input, textarea, select, summary, label {
        cursor: none !important;
    }

    .cursor-orb {
        position: fixed;
        top: 0;
        left: 0;
        width: 10px;
        height: 10px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.92);
        transform: translate(-50%, -50%) scale(1);
        transform-origin: center;
        pointer-events: none;
        z-index: 999999;
        opacity: 0;
        transition: transform .24s cubic-bezier(0.22, 1, 0.36, 1), opacity .2s ease;
        will-change: left, top, transform;
    }

    .cursor-orb.is-text {
        transform: translate(-50%, -50%) scale(3.1);
        mix-blend-mode: difference;
    }

    .cursor-orb.is-link {
        transform: translate(-50%, -50%) scale(3.4);
    }
}

/* ── Typography ── */
.mono { font-family: 'JetBrains Mono', monospace; }

.mar-gradient {
    background: linear-gradient(135deg, #fff 0%, #666 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Language Toggle */
.lang-toggle {
    min-width: 0;
    height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    line-height: 1;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.lang-toggle:hover {
    border-color: rgba(255, 255, 255, 0.34);
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.lang-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.lang-toggle:disabled {
    opacity: 0.55;
}

/* ── Background ── */
.flux-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #111, #000);
}

.flux-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    animation: drift 20s infinite alternate-reverse ease-in-out;
}

@keyframes drift {
    0% { transform: translate(-10%, -10%) scale(1); }
    100% { transform: translate(20%, 30%) scale(1.5); }
}

/* ── Glass Cards ── */
.vitreous-card {
    background: var(--glass);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid var(--border);
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.vitreous-card:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-5px);
}

/* ── Reveal Animation ── */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    animation: revealUp 0.8s forwards;
}

@keyframes revealUp {
    to { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ── Tags ── */
.tag {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 100px;
}

/* ── Accent Dot ── */
.flux-dot {
    height: 6px;
    width: 6px;
    background-color: var(--flux-accent);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 15px var(--flux-accent);
}

/* ── Sand Clock ── */
.sand-clock {
    position: relative;
    width: 16px;
    height: 22px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    overflow: hidden;
    flex: 0 0 auto;
}

.sand-clock .sand-top,
.sand-clock .sand-bottom {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 8px;
    background: rgba(255, 255, 255, 0.65);
}

.sand-clock .sand-top {
    top: 2px;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: center top;
    animation: sandTop 2.4s ease-in-out infinite;
}

.sand-clock .sand-bottom {
    bottom: 2px;
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
    transform-origin: center bottom;
    animation: sandBottom 2.4s ease-in-out infinite;
}

.sand-clock .sand-stream {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 1px;
    height: 6px;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.75);
    animation: sandStream 2.4s linear infinite;
}

@keyframes sandTop {
    0%, 45% { transform: scaleY(1); opacity: 0.75; }
    55%, 100% { transform: scaleY(0.2); opacity: 0.25; }
}

@keyframes sandBottom {
    0%, 45% { transform: scaleY(0.2); opacity: 0.25; }
    55%, 100% { transform: scaleY(1); opacity: 0.75; }
}

@keyframes sandStream {
    0%, 35%, 100% { opacity: 0; }
    45%, 85% { opacity: 0.9; }
}

/* ── Story Timeline ── */
.storyline {
    position: relative;
    padding-left: 3rem;
    transition: padding-left 0.45s cubic-bezier(0.22, 1, 0.36, 1), padding-right 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.storyline::before {
    content: "";
    position: absolute;
    left: 0.85rem;
    top: 0.6rem;
    bottom: 0.6rem;
    width: 1px;
    background: rgba(255, 255, 255, 0.13);
    transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1), right 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.story-chapter {
    position: relative;
}

.story-node {
    position: absolute;
    left: -3rem;
    top: 1rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.65);
    transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1), right 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.story-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.story-beat {
    font-size: 0.82rem;
    line-height: 1.6;
    color: #9ca3af;
}

.story-feature {
    border-color: rgba(59, 130, 246, 0.24);
    background: rgba(59, 130, 246, 0.06);
}

.story-feature > div:last-child {
    transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1), right 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Arabic Layout */
body.is-ar {
    font-family: 'Tajawal', 'Inter', sans-serif;
}

body.is-ar .mono {
    font-family: 'Tajawal', 'JetBrains Mono', sans-serif;
    letter-spacing: 0.02em;
}

body.is-ar .lang-toggle {
    letter-spacing: 0;
    font-family: 'Tajawal', 'Inter', sans-serif;
}

body.is-ar .storyline {
    padding-left: 0;
    padding-right: 3rem;
}

body.is-ar .storyline::before {
    left: auto;
    right: 0.85rem;
}

body.is-ar .story-node {
    left: auto;
    right: -3rem;
}

body.is-ar .story-feature > div:last-child {
    left: -18px;
    right: auto;
}

[data-i18n],
.lang-toggle {
    transition: opacity 0.26s ease, transform 0.26s ease;
}

body.is-language-switching [data-i18n],
body.is-language-switching .lang-toggle {
    opacity: 0;
    transform: translateY(4px);
}

@media (prefers-reduced-motion: reduce) {
    [data-i18n],
    .lang-toggle {
        transition: none;
    }

    body.is-language-switching [data-i18n],
    body.is-language-switching .lang-toggle {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 640px) {
    .header-controls {
        width: 100%;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .header-controls nav {
        gap: 1rem;
        flex-wrap: wrap;
    }

    .lang-toggle {
        height: 28px;
        padding: 0 9px;
    }
}
