@font-face {
    font-family: 'Kitab';
    src: url('../assets/fonts/kitab-base.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+200?, U+60C, U+618-61B, U+61F, U+621-63A, U+640-655, U+65C, U+660-66C, U+670-671, U+6CC, U+6D4, U+6D6-6DD, U+6DF-6E8, U+6EA-6ED, U+8F0-8F3, U+FD3E-FD3F, U+FDF2;
}

@font-face {
    font-family: 'Kitab';
    src: url('../assets/fonts/kitab-base-bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+200?, U+60C, U+618-61B, U+61F, U+621-63A, U+640-655, U+65C, U+660-66C, U+670-671, U+6CC, U+6D4, U+6D6-6DD, U+6DF-6E8, U+6EA-6ED, U+8F0-8F3, U+FD3E-FD3F, U+FDF2;
}

@font-face {
    font-family: 'Kitab';
    src: url('../assets/fonts/kitab-phrases.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+6DE, U+6E9, U+E100-E103, U+FD3E-FD45, U+FD47-FD4F, U+FDFA-FDFB, U+FDFD-FDFF;
}

@font-face {
    font-family: 'Kitab';
    src: url('../assets/fonts/kitab-phrases.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+6DE, U+6E9, U+E100-E103, U+FD3E-FD45, U+FD47-FD4F, U+FDFA-FDFB, U+FDFD-FDFF;
}

:root {
    --bg-color: #121212;
    --bg-elevated: #1a1a1a;
    --sidebar-bg: #161616;
    --text-color: #e0e0e0;
    --text-muted: #b0b0b0;
    --accent-color: #3ea6ff;
    --accent-weak: rgba(62, 166, 255, 0.16);
    --danger-color: #ff8d8d;
    --hover-color: #1f1f1f;
    --border-color: #2a2a2a;
    --font-main: 'Kitab', serif;
    --font-ui: 'Kitab', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --header-height: 78px;
    --text-xs: 0.88rem;
    --text-sm: 0.98rem;
    --text-base: 1.06rem;
    --text-md: 1.16rem;
    --text-lg: 1.28rem;
    --text-xl: 1.52rem;
    --text-2xl: 2rem;
    --radius-sm: 4px;
    --radius-md: 6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
}

html {
    font-size: 15.75px;
}

body {
    min-height: 100vh;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: var(--text-base);
    direction: rtl;
    line-height: 1.8;
    overflow-x: hidden;
}

body,
body :where(h1, h2, h3, h4, h5, h6, p, a, span, li, label, input, select, button, textarea, option, dt, dd, div) {
    font-size: 15.75px !important;
    line-height: 21px !important;
}

img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.25s ease;
}

:where(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    inset-inline-start: 0.8rem;
    top: -100px;
    background: #111;
    color: #fff;
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-sm);
    z-index: 2000;
}

.skip-link:focus-visible {
    top: 0.8rem;
}

.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;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5d5d5d;
}

.site-header {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.8rem 1.1rem;
    min-height: var(--header-height);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    height: 38px;
    width: auto;
    color: var(--text-color);
    font-size: var(--text-lg);
    font-weight: 700;
    min-width: 0;
}

.logo a {
    color: inherit;
}

.site-logo {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    font-weight: 700;
    line-height: 1.05 !important;
}

.site-logo span {
    display: block;
    line-height: 1.05 !important;
    white-space: nowrap;
}

.back-link {
    color: var(--text-color);
    font-size: var(--text-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.back-link:hover {
    color: var(--accent-color);
}

.primary-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.primary-nav a {
    font-family: var(--font-ui);
    color: var(--text-muted);
}

.primary-nav a:hover,
.primary-nav a[aria-current='page'] {
    color: var(--accent-color);
}

.site-header.site-header-nav {
    grid-template-columns: auto minmax(0, 1fr);
    min-height: auto;
    padding: 0.62rem 0.9rem 0.52rem;
    gap: 0.9rem;
    align-items: center;
}

.site-header.site-header-nav .logo {
    justify-self: start;
    display: flex;
    align-items: center;
    height: 38px;
    font-size: var(--text-sm);
    font-weight: 700;
}

.site-header.site-header-nav .logo a {
    color: var(--text-color);
}

.site-header.site-header-nav .logo a[aria-current='page'] {
    color: var(--text-color);
}

.site-header.site-header-nav .primary-nav {
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    min-width: 0;
    gap: 0.82rem;
    scrollbar-width: thin;
    scrollbar-color: #4a4a4a transparent;
    padding-bottom: 0.1rem;
}

.site-header.site-header-nav .reader-title,
.site-header.site-header-nav .nav-icons {
    justify-self: center;
}

.site-header.site-header-nav .nav-icons {
    justify-content: center;
}

.site-header.site-header-nav .primary-nav::-webkit-scrollbar {
    height: 4px;
}

.site-header.site-header-nav .primary-nav::-webkit-scrollbar-track {
    background: transparent;
}

.top-nav-link {
    min-width: 4.55rem;
    min-height: 2.95rem;
    padding: 0.34rem 0.3rem;
    border: 0;
    border-radius: 0;
    background: transparent;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.22rem;
    line-height: 1.1 !important;
    text-align: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.site-header.site-header-nav .top-nav-link[href='search.html'] {
    order: 1;
}

.site-header.site-header-nav .top-nav-link[href='index.html'] {
    order: 2;
}

.site-header.site-header-nav .top-nav-link[href='authors.html'] {
    order: 3;
}

.site-header.site-header-nav .top-nav-link[href='categories.html'] {
    order: 4;
}

.top-nav-link span {
    display: block;
    font-size: 14px !important;
    line-height: 1.1 !important;
    white-space: nowrap;
    text-align: center;
    font-weight: 400;
}

.top-nav-link svg {
    width: 21px;
    height: 21px;
    stroke: currentColor;
    fill: none;
    stroke-width: 0.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    display: block;
    margin: 0 auto;
}

.top-nav-link:hover {
    color: var(--text-color);
}

.top-nav-link[aria-current='page'] {
    color: var(--accent-color);
}

.reader-title {
    font-weight: 400;
    font-size: var(--text-lg);
    text-align: center;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-icons {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.icon {
    cursor: pointer;
    font-size: var(--text-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 2rem;
    color: var(--text-color);
    transition: transform 0.2s ease, color 0.2s ease;
    background: transparent;
    border: 0;
    padding: 0;
}

.icon:hover {
    color: var(--accent-color);
    transform: scale(1.05);
}

.icon:disabled {
    opacity: 0.45;
    pointer-events: none;
}

.icon.is-active {
    color: var(--accent-color);
}

.back-link svg,
.icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 0.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    display: block;
    margin: 0 auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.4rem;
    width: 100%;
}

.status-ok,
.status-error {
    font-size: var(--text-sm);
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
}

.status-ok {
    color: var(--text-color);
}

.status-error {
    color: var(--danger-color);
}

.noscript-notice {
    margin: 0.8rem auto 0;
    max-width: 900px;
    border: 1px solid var(--border-color);
    background: rgba(208, 126, 126, 0.15);
    color: #ffd9d9;
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem;
    font-size: var(--text-sm);
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@media (max-width: 1100px) {
    :root {
        --header-height: 74px;
    }

    .site-header:not(.site-header-nav) {
        grid-template-columns: 1fr auto;
    }

    .site-header:not(.site-header-nav) .primary-nav {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 900px) {
    :root {
        --header-height: 64px;
        --text-xs: 0.84rem;
        --text-sm: 0.93rem;
        --text-base: 1rem;
        --text-md: 1.08rem;
        --text-lg: 1.2rem;
        --text-xl: 1.34rem;
        --text-2xl: 1.78rem;
    }

    .site-header {
        padding: 0.68rem 0.9rem;
        gap: 0.7rem;
    }

    .site-header.site-header-nav {
        padding: 0.54rem 0.64rem 0.48rem;
        gap: 0.7rem;
    }

    .top-nav-link {
        min-width: 4.05rem;
        min-height: 2.75rem;
        padding: 0.28rem 0.2rem;
    }

    .top-nav-link svg {
        width: 20px;
        height: 20px;
    }

    .nav-icons {
        gap: 0.45rem;
    }

    .container {
        padding: 2rem 1rem;
    }
}

@media (max-width: 640px) {
    :root {
        --header-height: 56px;
    }

    .site-header {
        min-height: auto;
        padding: 0.5rem 0.65rem;
        gap: 0.45rem;
    }

    .logo {
        font-size: var(--text-md);
    }

    .site-header.site-header-nav .logo {
        height: 37px;
        font-size: var(--text-xs);
    }

    .site-header.site-header-nav .primary-nav {
        justify-content: center;
        gap: 0.5rem;
        padding-bottom: 0.18rem;
    }

    .site-header.site-header-nav .primary-nav::-webkit-scrollbar {
        height: 3px;
    }

    .top-nav-link {
        min-width: 3.75rem;
        min-height: 2.6rem;
        padding: 0.26rem 0.14rem;
    }

    .icon {
        min-width: 1.74rem;
        min-height: 1.74rem;
    }

    .container {
        padding: 1.4rem 0.8rem;
    }

    .fade-in {
        animation: none;
    }
}

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