/**
 * CZAR Theme - Base Styles
 *
 * Reset, typography, and global element styles.
 * Swiss Design: vast negative space, sharp type hierarchy.
 *
 * @package Czar_Theme
 * @since   1.0.0
 */

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    /* MASTER OVERFLOW SEAL — must stay on html, not just body.
       Without this rule browsers promote horizontal scrolling to the html
       element, bypassing the body overflow-x:hidden entirely (iOS Safari
       is the most common offender). This single rule permanently prevents
       any element anywhere on the page from making the viewport
       horizontally scrollable. Do NOT remove. */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: var(--czar-font-primary);
    font-weight: var(--czar-fw-regular);
    font-size: var(--czar-fs-base);
    line-height: var(--czar-leading-normal);
    color: var(--czar-black);
    background-color: var(--czar-white);
    overflow-x: hidden;
}

/* Arabic body font override */
body.czar-lang-ar {
    font-family: var(--czar-font-arabic);
}

/* ─── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--czar-fw-bold);
    line-height: var(--czar-leading-tight);
    letter-spacing: var(--czar-tracking-tight);
    color: var(--czar-black);
}

h1 { font-size: var(--czar-h1-size, var(--czar-fs-3xl)); }
h2 { font-size: var(--czar-h2-size, var(--czar-fs-2xl)); }
h3 { font-size: var(--czar-h3-size, var(--czar-fs-xl)); }
h4 { font-size: var(--czar-h4-size, var(--czar-fs-lg)); }

p {
    margin-bottom: var(--czar-space-sm);
    line-height: var(--czar-leading-relaxed);
    color: var(--czar-grey-dark);
}

a {
    color: var(--czar-black);
    text-decoration: none;
    transition: color var(--czar-transition-fast);
}

a:hover {
    color: var(--czar-grey-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ─── Selection ────────────────────────────────────────────────────────────── */
::selection {
    background-color: var(--czar-black);
    color: var(--czar-white);
}

/* ─── Scrollbar (WebKit) ───────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--czar-white);
}

::-webkit-scrollbar-thumb {
    background: var(--czar-grey-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--czar-grey-mid);
}

/* ─── Utility: Screen Reader Only ──────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Body Lock (when modal is open) ───────────────────────────────────────── */
body.czar-modal-open {
    overflow: hidden;
}

/* ─── Preloader: Full-Screen Logo Overlay ──────────────────────────────────── */
body.czar-preloader-active {
    overflow: hidden;
}

.czar-preloader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--czar-white);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.czar-preloader__logo {
    max-width: 120px;
    height: auto;
    animation: czar-pulse 1.8s ease-in-out infinite;
}

.czar-preloader__text {
    font-family: var(--czar-font-primary);
    font-size: var(--czar-fs-xl);
    font-weight: var(--czar-fw-light);
    letter-spacing: var(--czar-tracking-widest);
    text-transform: uppercase;
    color: var(--czar-black);
    animation: czar-pulse 1.8s ease-in-out infinite;
}

@keyframes czar-pulse {
    0%, 100% {
        opacity: 0.35;
        transform: scale(0.96);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

.czar-preloader--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@media screen and (max-width: 768px) {
    .czar-preloader__logo {
        max-width: 90px;
    }
}

/* ─── Global Scroll-to-top Arrow ───────────────────────────────────────────── */
.czar-scroll-top {
    position: fixed;
    bottom: 32px;
    right: 32px;
    background: #fff;
    border: 1px solid var(--czar-grey-light, #e5e5e5);
    cursor: pointer;
    color: #000;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    padding: 0;
    line-height: 1;
    font-family: inherit;
    z-index: 999;
    /* Hidden by default — JS adds .is-visible when scrolled */
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease,
                color 0.15s ease, background-color 0.15s ease;
}

.czar-scroll-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.czar-scroll-top:hover {
    color: #fff;
    background: #000;
    border-color: #000;
}

.czar-scroll-top:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.czar-scroll-top svg {
    display: block;
    flex-shrink: 0;
}

/* RTL: flip to bottom-left */
[dir="rtl"] .czar-scroll-top,
body.czar-lang-ar .czar-scroll-top {
    right: auto;
    left: 32px;
}

@media screen and (max-width: 768px) {
    .czar-scroll-top {
        bottom: 24px;
        right: 24px;
        width: 40px;
        height: 40px;
    }
    .czar-scroll-top svg {
        width: 18px;
        height: 18px;
    }
    [dir="rtl"] .czar-scroll-top,
    body.czar-lang-ar .czar-scroll-top {
        right: auto;
        left: 24px;
    }
}

@media screen and (max-width: 480px) {
    .czar-scroll-top {
        bottom: 20px;
        right: 20px;
        width: 36px;
        height: 36px;
    }
    [dir="rtl"] .czar-scroll-top,
    body.czar-lang-ar .czar-scroll-top {
        right: auto;
        left: 20px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   GLOBAL SCROLL-DOWN HINT
   Gradient fade + bouncing down-chevron at the bottom of the viewport.
   Tells the user there is more content to scroll.  Hidden by default;
   JS adds .is-visible when the page overflows and the user is near the top.
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes czar-bounce-hint {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(6px); }
}

.czar-scroll-hint {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 10px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.85) 50%, #fff 100%);
    pointer-events: none;
    z-index: 998;
    /* Hidden by default */
    opacity: 0;
    transition: opacity 0.25s ease;
}

.czar-scroll-hint.is-visible {
    opacity: 1;
}

.czar-scroll-hint svg {
    display: block;
    color: var(--czar-grey-mid, #999);
    animation: czar-bounce-hint 1.5s ease-in-out infinite;
}
