/* ==========================================================================
   نظام التصميم المشترك — الأذكار
   ========================================================================== */

/* ---------- الخطوط ---------- */
@font-face {
    font-family: 'Lotus Shami';
    src: url('../fonts/louts%20shamy%20Regular.ttf') format('truetype');
    font-weight: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Uthman Taha';
    src: url('../fonts/KFGQPC%20Uthman%20Taha%20Naskh%20Regular.ttf') format('truetype');
    font-weight: normal;
    font-display: swap;
}

/* ---------- المتغيّرات: الوضع النهاري ---------- */
:root {
    /* الألوان الأساسية */
    --brand-900: #06342b;
    --brand-800: #0a4a3c;
    --brand-700: #0e6350;
    --brand-600: #117c64;
    --brand-500: #159a7c;
    --brand-400: #34b795;
    --brand-300: #6fd0b6;
    --brand-100: #d6f2e9;

    --gold-600: #a97e12;
    --gold-500: #c9a227;
    --gold-400: #e0be55;
    --gold-100: #f8eeca;

    /* الأسطح والنصوص */
    --bg: #f2f6f4;
    --bg-tint: radial-gradient(1200px 600px at 80% -10%, #d9efe7 0%, transparent 60%),
               radial-gradient(900px 500px at 0% 100%, #e6f0ea 0%, transparent 55%);
    --surface: #ffffff;
    --surface-2: #f7faf9;
    --surface-glass: rgba(255, 255, 255, .78);
    --border: rgba(9, 60, 48, .12);
    --border-strong: rgba(9, 60, 48, .22);

    --text: #10221d;
    --text-soft: #46605a;
    --text-mute: #7b918b;
    --on-brand: #ffffff;

    /* الظلال */
    --shadow-sm: 0 1px 2px rgba(6, 52, 43, .06), 0 2px 6px rgba(6, 52, 43, .05);
    --shadow-md: 0 4px 12px rgba(6, 52, 43, .08), 0 12px 28px rgba(6, 52, 43, .07);
    --shadow-lg: 0 10px 24px rgba(6, 52, 43, .10), 0 24px 60px rgba(6, 52, 43, .12);
    --shadow-brand: 0 10px 30px rgba(17, 124, 100, .28);

    /* القياسات */
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-xl: 30px;
    --r-full: 999px;

    --pad: clamp(14px, 3vw, 28px);
    --maxw: 900px;

    --ease: cubic-bezier(.22, 1, .36, 1);
    --dur: .28s;

    /* المناطق الآمنة (حواف الشاشة والنتوء في الهواتف) */
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-l: env(safe-area-inset-left, 0px);

    /* ارتفاع الشريط العلوي — يُحدَّث بالجافاسكربت */
    --topbar-h: 62px;
}

/* ---------- المتغيّرات: الوضع الليلي ---------- */
[data-theme="dark"] {
    --bg: #071a16;
    --bg-tint: radial-gradient(1100px 600px at 85% -10%, #0d3a30 0%, transparent 60%),
               radial-gradient(900px 500px at -10% 100%, #0a2c25 0%, transparent 55%);
    --surface: #0e2620;
    --surface-2: #123029;
    --surface-glass: rgba(14, 38, 32, .78);
    --border: rgba(150, 220, 202, .14);
    --border-strong: rgba(150, 220, 202, .26);

    --text: #e8f5f0;
    --text-soft: #a9c9c0;
    --text-mute: #7ea79c;

    --brand-100: rgba(52, 183, 149, .16);
    --gold-100: rgba(224, 190, 85, .16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .38);
    --shadow-lg: 0 14px 40px rgba(0, 0, 0, .5);
    --shadow-brand: 0 10px 30px rgba(0, 0, 0, .45);
}

/* ---------- إعادة الضبط ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: 'Lotus Shami', 'Segoe UI', Tahoma, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    background-image: var(--bg-tint);
    background-attachment: fixed;
    line-height: 1.6;
    overflow-x: hidden;
    overscroll-behavior-y: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
    padding-inline: var(--safe-l) var(--safe-r);
}

/* الخلفية الثابتة تسبّب تقطّعاً في متصفحات الجوال */
@media (hover: none) {
    body {
        background-attachment: scroll;
        background-size: 100% 100dvh;
    }
}

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

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

::selection {
    background: var(--brand-400);
    color: #fff;
}

/* شريط التمرير */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--brand-400) transparent;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-thumb {
    background: linear-gradient(var(--brand-500), var(--brand-700));
    border-radius: var(--r-full);
    border: 3px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- الزخرفة الإسلامية للخلفية ---------- */
.pattern-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: .5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='none' stroke='%23117c64' stroke-opacity='.16' stroke-width='1'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40 Z'/%3E%3Cpath d='M40 14 L66 40 L40 66 L14 40 Z'/%3E%3Ccircle cx='40' cy='40' r='8'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 80px 80px;
    mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
    -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 75%);
}

[data-theme="dark"] .pattern-overlay {
    opacity: .35;
}

/* ---------- الشريط العلوي ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px clamp(12px, 3vw, 24px);
    padding-top: calc(10px + var(--safe-t));
    background: var(--surface-glass);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: clamp(1.05rem, 3.4vw, 1.35rem);
    font-weight: 700;
    letter-spacing: .2px;
}

.topbar__brand .mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
    color: #fff;
    box-shadow: var(--shadow-brand);
    flex: none;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- الأزرار ---------- */
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease), color var(--dur) var(--ease),
                border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

@media (hover: hover) {
    .icon-btn:hover {
        color: var(--brand-600);
        border-color: var(--brand-300);
        transform: translateY(-2px);
    }
}

.icon-btn:active {
    transform: translateY(0) scale(.94);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-size: 1rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
                background var(--dur) var(--ease), color var(--dur) var(--ease),
                border-color var(--dur) var(--ease);
}

@media (hover: hover) {
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
        color: var(--brand-600);
        border-color: var(--brand-300);
    }

    .btn--primary:hover {
        color: #fff;
        border-color: transparent;
    }
}

.btn:active {
    transform: translateY(0) scale(.97);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn--primary {
    background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
    color: var(--on-brand);
    border-color: transparent;
    box-shadow: var(--shadow-brand);
}

/* التركيز — إتاحة الوصول */
:where(a, button, [tabindex]):focus-visible {
    outline: 3px solid var(--brand-400);
    outline-offset: 3px;
    border-radius: var(--r-sm);
}

/* ---------- زر الوضع الليلي ---------- */
/* تُعرض أيقونة واحدة فقط: الشمس نهاراً والقمر ليلاً */
#themeToggle .icon-moon { display: none; }
[data-theme="dark"] #themeToggle .icon-sun { display: none; }
[data-theme="dark"] #themeToggle .icon-moon { display: block; }

/* ---------- التنبيه العائم ---------- */
.toast {
    position: fixed;
    bottom: calc(24px + var(--safe-b));
    left: 50%;
    transform: translate(-50%, 20px);
    z-index: 120;
    padding: 11px 22px;
    border-radius: var(--r-full);
    background: var(--brand-800);
    color: #fff;
    font-size: .95rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.is-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 640px) {
    .toast {
        width: calc(100% - 32px);
        max-width: 420px;
    }
}

/* ---------- الحاشية القرآنية ---------- */
.footnote {
    margin: 0;
    text-align: center;
    font-family: 'Uthman Taha', serif;
    font-size: clamp(.96rem, 3vw, 1.1rem);
    line-height: 2;
    color: var(--text-soft);
    padding-inline: 6px;
}

/* ---------- عناصر مساعدة ---------- */
.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;
}

.chip {
    padding: 8px 16px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    font-size: .95rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all var(--dur) var(--ease);
}

@media (hover: hover) {
    .chip:hover {
        border-color: var(--brand-300);
        color: var(--brand-600);
    }
}

.chip:active { transform: scale(.96); }

.chip[aria-pressed="true"],
.chip.is-active {
    background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-brand);
}

/* ---------- الحركات ---------- */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

@keyframes pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.14); }
    100% { transform: scale(1); }
}

@keyframes float-up {
    0%   { opacity: 0; transform: translate(-50%, 0) scale(.8); }
    25%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -70px) scale(1.15); }
}

/* ---------- اللمس: مساحات ضغط مريحة ---------- */
@media (pointer: coarse) {
    .icon-btn {
        width: 46px;
        height: 46px;
    }

    .btn {
        min-height: 46px;
        padding-inline: 18px;
    }

    .chip {
        min-height: 42px;
        display: inline-flex;
        align-items: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
