/**
 * IAG Design System — Base / Reset
 * RTL body defaults, typography, scrollbar, global utilities.
 */

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

/* ── Root Body ───────────────────────────────────────────────────── */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-base);
    font-size: var(--text-base);
    color: var(--color-text-2);
    background: var(--color-bg);

    /* RTL defaults */
    direction: rtl;
    unicode-bidi: embed;
    text-align: right;

    /* iOS */
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;

    min-height: 100vh;
    line-height: 1.5;
}

/* Bottom Nav padding — mobile only */
@media (max-width: 768px) {
    body {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    }
}

/* ── Typography ──────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-base);
    font-weight: var(--font-black);
    line-height: 1.3;
    color: var(--color-text-1);
}

a {
    color: var(--brand-primary-teal);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

button, input, select, textarea {
    font-family: var(--font-base);
    font-size: var(--text-base);
}

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

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar           { width: 5px; height: 5px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: var(--color-border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-5); }

/* ── Focus Ring (WCAG AA §1.4.11 / §2.4.7) ──────────────────────── */
/* Provides visible keyboard focus on all interactive elements.
   Uses :focus-visible so mouse clicks do not show the outline.    */
:focus-visible {
    outline: 2px solid var(--brand-primary-teal, #0a5c56);
    outline-offset: 2px;
}
/* Override for elements that already define their own focus style */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none; /* These elements use box-shadow focus in their own CSS */
}

/* ── Selection ───────────────────────────────────────────────────── */
::selection {
    background: var(--brand-primary-light);
    color: var(--brand-primary-teal);
}

/* ── Global Animations ───────────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Global Utilities ────────────────────────────────────────────── */
.hidden      { display: none !important; }
.invisible   { visibility: hidden; }
.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; }

.spin        { animation: spin 1s linear infinite; }
.fade-in     { animation: fadeIn 0.25s ease; }

.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

.w-full      { width: 100%; }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.gap-2       { gap: var(--space-2); }
.gap-3       { gap: var(--space-3); }

/* Content max-width wrapper */
.content-wrapper {
    max-width: var(--content-max);
    margin-inline: auto;
    padding-inline: 1rem;
}

/* prefers-reduced-motion support */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-delay: -1ms !important;
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        background-attachment: initial !important;
        scroll-behavior: auto !important;
        transition-duration: 0s !important;
        transition-delay: 0s !important;
    }
}
