:root {
    --ink: #171717;
    --muted: #626262;
    --soft: #f5f5f3;
    --line: #deded9;
    --accent: #9a6b00;
    --accent-strong: #765100;
    --accent-soft: #f6e7b0;
    --surface: #ffffff;
    --content-width: 1180px;
    --reading-width: 760px;
    --sans: "Aptos", "Segoe UI", Arial, sans-serif;
    --arabic: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
    --arabic-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--sans);
    line-height: 1.65;
    color: var(--ink);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

html[dir="rtl"] body,
[dir="rtl"] body {
    font-family: var(--arabic);
}

a {
    color: var(--accent);
    text-decoration-color: rgba(154, 107, 0, .45);
    text-underline-offset: .16em;
}

a:hover {
    color: var(--accent-strong);
    text-decoration-color: currentColor;
}

button,
select,
input {
    font: inherit;
}

/* Shared navigation */
.navbar {
    position: sticky;
    top: 0;
    min-height: 72px;
    padding: 0;
    z-index: 999;
    background:
        linear-gradient(rgba(25, 25, 25, .86), rgba(25, 25, 25, .86)),
        url('/static/img/beach-background.jpg') center 44% / cover;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .12);
    backdrop-filter: none;
}

.navbar-container {
    width: min(100%, var(--content-width));
    min-height: 72px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
}

.navbar-brand {
    min-width: 0;
    color: #fff;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.05;
    text-shadow: none;
}

.navbar-brand:hover {
    color: #fff;
}

.navbar-brand-title {
    font-size: 1.2rem;
    font-weight: 760;
    letter-spacing: 0;
    white-space: nowrap;
}

.navbar-brand-subtitle {
    margin-top: 4px;
    color: rgba(255, 255, 255, .72);
    font-size: .72rem;
    font-style: normal;
    font-weight: 450;
    line-height: 1.1;
    text-shadow: none;
    white-space: nowrap;
}

.navbar-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.navbar-item,
.nav-language-switcher {
    min-height: 38px;
    padding: 9px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, .88);
    font-size: .9rem;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    text-shadow: none;
    transition: background-color .18s ease, color .18s ease;
    white-space: nowrap;
}

.navbar-item:hover,
.navbar-item.active,
.nav-language-switcher:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
    transform: none;
    box-shadow: none;
}

.nav-language-switcher {
    margin-left: 5px;
    border: 1px solid rgba(255, 255, 255, .25);
}

[dir="rtl"] .nav-language-switcher {
    margin-right: 5px;
    margin-left: 0;
}

/* Editorial page introductions */
.hero-section,
.top-articles-hero {
    margin: 0;
    padding: 68px 24px;
    background: var(--soft);
    color: var(--ink);
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.hero-container {
    max-width: 900px;
    margin: 0 auto;
}

.hero-title,
.top-articles-title {
    max-width: 880px;
    margin: 0 auto 20px;
    color: var(--ink);
    font-size: 3.25rem;
    font-weight: 760;
    line-height: 1.08;
    letter-spacing: 0;
    text-wrap: balance;
}

.hero-subtitle,
.top-articles-subtitle {
    max-width: 760px;
    margin: 0 auto;
    color: #484848;
    font-family: var(--sans);
    font-size: 1.42rem;
    font-weight: 400;
    line-height: 1.55;
    opacity: 1;
    text-wrap: balance;
}

.hero-credit {
    max-width: 790px;
    margin: 22px auto 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.75;
}

.hero-credit a {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: rgba(118, 81, 0, .35);
}

/* Shared headings and controls */
.blog-section,
.category-section,
.top-articles-page {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: 54px 24px 72px;
}

.section-header {
    margin-bottom: 28px;
    gap: 12px;
}

.section-title,
.category-title,
.about-title {
    color: var(--ink);
    font-size: 2.45rem;
    font-weight: 750;
    line-height: 1.12;
    letter-spacing: 0;
}

.section-title {
    margin-bottom: 0;
}

.category-header {
    max-width: 760px;
    margin: 0 auto 42px;
}

.category-description,
.about-subtitle {
    color: var(--muted);
    font-family: var(--sans);
    font-size: 1.18rem;
    line-height: 1.65;
}

.text-size-btn,
.category-btn,
.filter-select,
.back-link {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: #333;
    box-shadow: none;
}

.text-size-btn:hover,
.category-btn:hover,
.back-link:hover {
    border-color: #b9994f;
    background: #fffaf0;
    color: var(--accent-strong);
    transform: none;
    box-shadow: none;
}

.category-filter {
    margin-bottom: 36px;
    gap: 8px;
}

.category-btn {
    padding: 9px 16px;
    font-size: .92rem;
}

.category-btn.active {
    color: #fff;
    background: var(--ink);
    border-color: var(--ink);
    box-shadow: none;
}

/* Post and listing cards */
.blog-roll,
.posts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}

.blog-card {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: none;
    overflow: hidden;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.blog-card:hover {
    border-color: #c2b89f;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .07);
    transform: none;
}

.blog-card-link {
    color: inherit;
    text-decoration: none;
}

.blog-card-image,
.blog-card-image-large {
    height: 230px;
    margin: 0;
    background: #ececea;
}

.blog-card-img,
.blog-card-img-large {
    object-fit: cover;
    transform: none;
}

.blog-card:hover .blog-card-img,
.blog-card-large:hover .blog-card-img-large {
    transform: none;
}

.blog-card-image-large::before {
    display: none;
}

.blog-card-content,
.blog-card-large .blog-card-content {
    padding: 22px;
}

.blog-card-title,
.blog-card-large .blog-card-title {
    margin-bottom: 10px;
    color: var(--ink);
    font-size: 1.38rem;
    font-weight: 720;
    line-height: 1.3;
}

.blog-card-excerpt,
.blog-card-large .blog-card-excerpt {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: .98rem;
    line-height: 1.65;
}

.blog-card-meta,
.post-meta-small {
    color: #747474;
    font-size: .82rem;
}

.blog-card-tag,
.blog-post-tag,
.blog-card-category-badge {
    border-radius: 4px;
    background: #efefec;
    color: #555;
    font-size: .76rem;
    font-weight: 650;
    text-transform: none;
    letter-spacing: 0;
}

.blog-card-large {
    grid-column: auto;
    min-height: 0;
}

/* Long-form articles */
.blog-post-container {
    width: min(100%, calc(var(--reading-width) + 48px));
    max-width: none;
    margin: 0 auto;
    padding: 60px 24px 72px;
}

.blog-post-header {
    margin-bottom: 38px;
}

.blog-post-title {
    margin: 0 auto 18px;
    color: var(--ink);
    font-size: 3rem;
    font-weight: 760;
    line-height: 1.12;
    letter-spacing: 0;
    text-wrap: balance;
}

.blog-post-meta,
.post-date {
    color: #777;
}

.blog-post-featured-image {
    margin: 28px 0 42px;
    border-radius: 6px;
    box-shadow: none;
    background: var(--soft);
}

.featured-image {
    max-height: 520px;
    object-fit: cover;
}

.blog-post-content {
    color: #262626;
    font-family: var(--sans);
    font-size: 1.18rem;
    line-height: 1.82;
}

[dir="rtl"] .blog-post-content,
[dir="rtl"] .blog-post-title {
    font-family: var(--arabic);
}

[dir="rtl"] .blog-post-content {
    font-family: var(--arabic-body);
}

.blog-post-content h1,
.blog-post-content h2,
.blog-post-content h3,
.blog-post-content h4,
.blog-post-content h5,
.blog-post-content h6 {
    color: var(--ink);
    font-family: var(--sans);
    font-weight: 740;
    line-height: 1.25;
}

[dir="rtl"] .blog-post-content h1,
[dir="rtl"] .blog-post-content h2,
[dir="rtl"] .blog-post-content h3,
[dir="rtl"] .blog-post-content h4,
[dir="rtl"] .blog-post-content h5,
[dir="rtl"] .blog-post-content h6 {
    font-family: var(--arabic);
}

.blog-post-content h1 { font-size: 2rem; }
.blog-post-content h2 { font-size: 1.65rem; }
.blog-post-content h3 { font-size: 1.35rem; }

.blog-post-content p {
    margin-bottom: 1.45rem;
}

.blog-post-content blockquote {
    margin: 30px 0;
    padding: 16px 22px;
    border-left: 3px solid var(--accent);
    background: var(--soft);
    color: #484848;
}

[dir="rtl"] .blog-post-content blockquote {
    border-right: 3px solid var(--accent);
    border-left: 0;
}

.blog-post-content img {
    border-radius: 4px;
    box-shadow: none;
}

.claps-container {
    margin: 42px 0;
    padding: 26px 0;
}

.claps-button {
    width: 64px;
    height: 64px;
    background: var(--accent-soft);
    border: 1px solid #d4b95f;
    box-shadow: none;
    font-size: 1.9rem;
}

.claps-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(116, 80, 0, .12);
}

.nav-link {
    border-radius: 6px;
    box-shadow: none;
}

.language-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--accent-strong);
    box-shadow: none;
    font-size: .88rem;
    font-weight: 700;
    text-decoration: none;
}

.language-switcher-btn:hover {
    border-color: #b9994f;
    background: #fffaf0;
    color: var(--accent-strong);
    transform: none;
    box-shadow: none;
}

/* Top articles */
.top-articles-controls {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
}

.top-articles-summary {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
}

.top-articles-grid {
    gap: 42px;
}

.section-heading {
    border-bottom: 2px solid var(--accent);
    color: var(--ink);
    font-size: 1.55rem;
}

.rank-number {
    border-radius: 4px;
    background: var(--ink);
    color: #fff;
}

.top-link:hover {
    color: var(--accent-strong);
    transform: none;
}

/* About pages */
.about-container {
    width: min(100%, 920px);
    margin: 0 auto;
    padding: 60px 24px 72px;
}

.about-header {
    margin-bottom: 36px;
}

.about-title {
    margin-bottom: 14px;
}

.author-photo {
    width: 168px;
    height: 168px;
    border: 3px solid #d4b34e;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .1);
}

.about-content {
    max-width: var(--reading-width);
    color: #2d2d2d;
    font-family: var(--sans);
    font-size: 1.1rem;
    line-height: 1.78;
}

[dir="rtl"] .about-content {
    font-family: var(--arabic);
}

.about-content h3 {
    font-family: var(--sans);
    font-weight: 740;
}

[dir="rtl"] .about-content h3 {
    font-family: var(--arabic);
}

.credibility {
    border-left: 3px solid var(--accent);
    background: var(--soft);
}

[dir="rtl"] .credibility {
    border-right: 3px solid var(--accent);
    border-left: 0;
}

.social-link {
    border: 1px solid var(--ink);
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    box-shadow: none;
}

/* Shared footer */
.footer {
    padding: 38px 24px 32px;
    background: var(--soft);
    color: var(--muted);
    border-top: 1px solid var(--line);
    text-align: center;
}

.footer-content {
    width: min(100%, var(--content-width));
    margin: 0 auto;
}

.footer-text {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: .9rem;
    opacity: 1;
}

.footer-links {
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 22px;
}

.footer-link {
    color: #555;
    font-size: .9rem;
    text-decoration: none;
}

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

@media (max-width: 768px) {
    .navbar {
        min-height: 104px;
        padding: 10px 0 8px;
    }

    .navbar-container {
        min-height: 0;
        padding: 0 14px;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 8px;
    }

    .navbar-brand {
        max-width: calc(100% - 10px);
    }

    .navbar-brand-title {
        font-size: 1.05rem;
    }

    .navbar-brand-subtitle {
        font-size: .66rem;
    }

    .navbar-menu {
        width: 100%;
        justify-content: flex-start;
        gap: 4px;
        overflow-x: auto;
        padding-bottom: 1px;
        scrollbar-width: none;
    }

    [dir="rtl"] .navbar-menu {
        justify-content: flex-start;
    }

    .navbar-menu::-webkit-scrollbar {
        display: none;
    }

    .navbar-item,
    .nav-language-switcher {
        flex: 0 0 auto;
        min-height: 32px;
        padding: 7px 9px;
        border-radius: 5px;
        border-color: rgba(255, 255, 255, .2);
        background: rgba(255, 255, 255, .07);
        font-size: .78rem;
        white-space: nowrap;
    }

    .hero-section,
    .top-articles-hero {
        padding: 46px 18px;
    }

    .hero-title,
    .top-articles-title {
        font-size: 2.15rem;
        line-height: 1.12;
    }

    .hero-subtitle,
    .top-articles-subtitle {
        font-size: 1.15rem;
    }

    .hero-credit {
        font-size: .93rem;
        line-height: 1.65;
    }

    .blog-section,
    .category-section,
    .top-articles-page {
        padding: 40px 16px 56px;
    }

    .section-title,
    .category-title,
    .about-title {
        font-size: 2rem;
    }

    .blog-roll,
    .posts-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .blog-card-image,
    .blog-card-image-large {
        height: 205px;
    }

    .blog-card-content,
    .blog-card-large .blog-card-content {
        padding: 18px;
    }

    .blog-card-title,
    .blog-card-large .blog-card-title {
        font-size: 1.12rem !important;
        line-height: 1.22;
    }

    .blog-card-large .blog-card-title {
        font-size: 1.45rem !important;
        line-height: 1.18;
    }

    .blog-post-container,
    .about-container {
        padding: 40px 18px 56px;
    }

    .blog-post-title {
        font-size: 2.1rem;
    }

    .blog-post-content {
        font-size: 1.08rem;
        line-height: 1.76;
    }

    .nav-links {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .top-articles-controls {
        grid-template-columns: 1fr;
    }

    .top-articles-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .about-content {
        font-size: 1.04rem;
    }

    .footer-links {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 20px;
    }
}

@media (max-width: 420px) {
    .hero-title,
    .top-articles-title,
    .blog-post-title {
        font-size: 1.85rem;
    }

    .blog-card-title,
    .blog-card-large .blog-card-title {
        font-size: 1rem !important;
        line-height: 1.18;
    }

    .blog-card-large .blog-card-title {
        font-size: 1.28rem !important;
    }

    .section-title,
    .category-title,
    .about-title {
        font-size: 1.75rem;
    }
}
