/* Jamaliya — lapis & gilt, after the palette of illuminated Arabic manuscripts. */

:root {
    --paper: #fbfbfe;
    --wash: #eef0f7;
    --ink: #1a1f3d;
    --lapis: #26357f;
    --lapis-soft: #4a58a8;
    --saffron: #c98c12;
    --muted: #5f6584;
    --line: #dcdfec;

    --font-ruqaa: "Aref Ruqaa", "Noto Naskh Arabic", serif;
    --font-naskh: "Noto Naskh Arabic", "Source Serif 4", "Times New Roman", serif;

    /* Modular scale, ratio 1.25 */
    --step--1: 0.875rem;
    --step-0: 1.0625rem;
    --step-1: 1.3rem;
    --step-2: 1.625rem;
    --step-3: 2.05rem;
    --step-4: clamp(2.2rem, 1.6rem + 2.4vw, 3.2rem);

    --wrap: 76rem;
    --gutter: clamp(1rem, 3vw, 2.25rem);
    --measure: 40rem;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #121528;
        --wash: #1b2040;
        --ink: #e6e8f4;
        --lapis: #a9b5ff;
        --lapis-soft: #c4ccff;
        --saffron: #e9b54a;
        --muted: #9aa0c0;
        --line: #2b3157;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #121528;
    --wash: #1b2040;
    --ink: #e6e8f4;
    --lapis: #a9b5ff;
    --lapis-soft: #c4ccff;
    --saffron: #e9b54a;
    --muted: #9aa0c0;
    --line: #2b3157;
    color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-naskh);
    font-size: var(--step-0);
    line-height: 1.85;
    text-rendering: optimizeLegibility;
    overflow-x: clip;
}

a { color: var(--lapis); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: var(--saffron); text-underline-offset: 0.3em; }

:focus-visible {
    outline: 2px solid var(--saffron);
    outline-offset: 3px;
    border-radius: 2px;
}

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

h1, h2, h3, h4 { line-height: 1.45; margin: 0; font-weight: 700; }

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    inset-inline-start: 1rem;
    top: -3rem;
    background: var(--lapis);
    color: var(--paper);
    padding: 0.5rem 1rem;
    z-index: 10;
}
.skip-link:focus { top: 1rem; }

/* ------------------------------------------------------------------ masthead */

.masthead { padding-block: 1.75rem 0; }

.masthead__row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    flex-direction: column;
    color: var(--lapis);
}
.brand:hover { text-decoration: none; }

.brand__word {
    font-family: var(--font-ruqaa);
    font-size: clamp(3rem, 2.2rem + 3.5vw, 4.75rem);
    line-height: 1.1;
    font-weight: 700;
}

/* The gilt stroke under the name, like a ruling in a manuscript margin. */
.brand__word::after {
    content: "";
    display: block;
    width: 62%;
    height: 0.32rem;
    margin-top: 0.2rem;
    background: var(--saffron);
    border-radius: 0.2rem;
}

.brand__tag {
    margin-top: 0.6rem;
    font-size: var(--step--1);
    color: var(--muted);
}

.search {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    background: var(--paper);
    min-width: min(100%, 20rem);
}
.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: var(--step--1);
    padding: 0.55rem 0.85rem;
}
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--lapis); }
.search button {
    border: 0;
    background: var(--lapis);
    color: var(--paper);
    font: inherit;
    font-size: var(--step--1);
    padding-inline: 1rem;
    border-start-end-radius: 0.35rem;
    border-end-end-radius: 0.35rem;
    cursor: pointer;
}

.nav {
    margin-top: 1.5rem;
    border-block: 1px solid var(--line);
}
.nav ul {
    display: flex;
    gap: 0.25rem 1.6rem;
    list-style: none;
    margin: 0;
    padding: 0.7rem 0;
    overflow-x: auto;
    scrollbar-width: thin;
    white-space: nowrap;
}
.nav a { color: var(--ink); font-size: var(--step--1); font-weight: 600; }
.nav a[aria-current="page"] { color: var(--lapis); text-decoration: underline; text-decoration-color: var(--saffron); text-decoration-thickness: 2px; text-underline-offset: 0.45em; }
.nav li.nav__more { margin-inline-start: auto; }
.nav li.nav__more a { color: var(--lapis); }

main { padding-block: 2.5rem 4rem; }

/* ------------------------------------------------------------ shared pieces */

.ruqaa { font-family: var(--font-ruqaa); font-weight: 700; color: var(--lapis); }

.block-title {
    font-family: var(--font-ruqaa);
    font-size: var(--step-3);
    font-weight: 700;
    color: var(--lapis);
    line-height: 1.3;
    margin-bottom: 1.25rem;
}

.block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.block-head .block-title { margin-bottom: 0; }
.block-head a { font-size: var(--step--1); }

.meta {
    color: var(--muted);
    font-size: var(--step--1);
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.9rem;
}
.meta a { color: inherit; }
.meta a:hover { color: var(--lapis); }

.kicker {
    display: inline-block;
    font-size: var(--step--1);
    font-weight: 600;
    color: var(--saffron);
    margin-bottom: 0.35rem;
}

.excerpt { color: var(--muted); margin: 0.4rem 0 0; }

.section-band {
    /* Full-bleed band from inside the centred content column. */
    margin-inline: calc(50% - 50vw);
    background: var(--wash);
    padding-block: 2.75rem;
    margin-block: 3.5rem;
}

/* -------------------------------------------------------------------- home */

.front {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 3rem;
    align-items: start;
}

.lead {
    padding-inline-start: 1.5rem;
    border-inline-start: 0.35rem solid var(--saffron);
}
.lead h1 { font-size: var(--step-4); line-height: 1.4; margin-block: 0.25rem 0.9rem; }
.lead h1 a { color: var(--ink); }
.lead .excerpt { font-size: var(--step-1); line-height: 1.9; max-width: var(--measure); }
.lead .meta { margin-top: 1.1rem; font-size: var(--step-0); }

.ranked { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranked li {
    counter-increment: rank;
    display: grid;
    grid-template-columns: 2.1rem 1fr;
    gap: 0.6rem;
    padding-block: 0.7rem;
}
.ranked li + li { border-top: 1px solid var(--line); }
.ranked li::before {
    content: counter(rank);
    font-family: var(--font-ruqaa);
    font-size: var(--step-2);
    line-height: 1.2;
    color: var(--saffron);
}
.ranked a { color: var(--ink); font-weight: 600; line-height: 1.6; }
.ranked .meta { margin-top: 0.15rem; }

.latest {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.25rem 2.5rem;
    margin-top: 3.5rem;
}

.item h3 { font-size: var(--step-1); line-height: 1.6; font-weight: 600; }
.item h3 a { color: var(--ink); }
.item .excerpt { font-size: var(--step--1); line-height: 1.8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.item .meta { margin-top: 0.5rem; }
.item__image { display: block; margin-bottom: 0.8rem; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 0.3rem; background: var(--wash); }
.item__image img { width: 100%; height: 100%; object-fit: cover; }

/* Writer platforms: Ruqaa monograms stand in for the lost portraits. */
.platforms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 1.75rem 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.platform { text-align: center; }
.platform a { color: var(--ink); display: block; }
.platform a:hover { text-decoration: none; }
.platform a:hover .platform__name { color: var(--lapis); }
.platform__name { display: block; font-weight: 600; line-height: 1.5; margin-top: 0.7rem; }
.platform .meta { justify-content: center; }

.monogram {
    --size: 5.25rem;
    width: var(--size);
    height: var(--size);
    margin-inline: auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--paper);
    box-shadow: 0 0 0 2px var(--saffron), 0 0 0 6px var(--paper), 0 0 0 7px var(--line);
    font-family: var(--font-ruqaa);
    font-size: calc(var(--size) * 0.46);
    color: var(--lapis);
    overflow: hidden;
}
.monogram img { width: 100%; height: 100%; object-fit: cover; }
.monogram--lg { --size: 8rem; }

.sections-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.75rem 2.5rem;
}
.section-card h2 { font-family: var(--font-ruqaa); font-size: var(--step-2); color: var(--lapis); font-weight: 700; line-height: 1.3; }
.section-card h2 a { color: inherit; }
.section-card .meta { margin-block: 0.2rem 0.75rem; }
.section-card ul { list-style: none; margin: 0; padding: 0; }
.section-card li { padding-block: 0.35rem; line-height: 1.65; }
.section-card li a { color: var(--ink); }

.features {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2.5rem;
    margin-top: 3.5rem;
}
.feature {
    padding: 2rem;
    border-radius: 0.5rem;
    background: var(--lapis);
    color: #f3f4fb;
}
.feature h2 { font-family: var(--font-ruqaa); font-size: var(--step-3); font-weight: 700; color: #fff; line-height: 1.3; }
.feature p { margin: 0.6rem 0 1.2rem; color: #d7dbf3; }
.feature a.button { color: var(--ink); background: var(--saffron); }

.button {
    display: inline-block;
    padding: 0.5rem 1.15rem;
    border-radius: 0.35rem;
    font-weight: 600;
    font-size: var(--step--1);
    background: var(--lapis);
    color: var(--paper);
}
.button:hover { text-decoration: none; filter: brightness(1.08); }

/* ------------------------------------------------------------ listing pages */

.page-head { margin-bottom: 2.25rem; max-width: 52rem; }
.page-head h1 { font-family: var(--font-ruqaa); font-size: var(--step-4); color: var(--lapis); line-height: 1.3; }
.page-head p { color: var(--muted); margin: 0.5rem 0 0; }
.page-head .crumbs { margin-bottom: 0.5rem; }

.crumbs { font-size: var(--step--1); color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.4rem; }
.crumbs a { color: var(--muted); }
.crumbs span[aria-hidden] { color: var(--saffron); }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 2.25rem; padding: 0; list-style: none; }
.chips a {
    display: inline-block;
    padding: 0.25rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: var(--step--1);
}
.chips a:hover { border-color: var(--lapis); text-decoration: none; }
.chips a[aria-current="true"] { background: var(--lapis); border-color: var(--lapis); color: var(--paper); }
.chips small { color: var(--muted); margin-inline-start: 0.3rem; }
.chips a[aria-current="true"] small { color: inherit; opacity: 0.8; }

.list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.25rem 3rem; }

.profile {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    align-items: center;
    margin-bottom: 2.75rem;
}
.profile h1 { font-family: var(--font-ruqaa); font-size: var(--step-4); color: var(--lapis); line-height: 1.3; }
.profile p { color: var(--muted); margin: 0.4rem 0 0; }

.bio { max-width: var(--measure); margin-bottom: 2.75rem; }

.writers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
    gap: 0.25rem 2rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.writers-grid li { display: flex; justify-content: space-between; gap: 1rem; padding-block: 0.6rem; border-bottom: 1px solid var(--line); }
.writers-grid a { color: var(--ink); font-weight: 600; }
.writers-grid small { color: var(--muted); white-space: nowrap; }

/* Alphabet index: each letter set in Ruqaa, like the tabs of a dictionary. */
.letters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 1.75rem;
}
.letters a,
.letters span {
    min-width: 2.6rem;
    height: 2.6rem;
    display: inline-grid;
    place-items: center;
    padding-inline: 0.5rem;
    border-radius: 0.35rem;
    font-family: var(--font-ruqaa);
    font-size: var(--step-1);
    line-height: 1;
}
.letters a { color: var(--lapis); background: var(--wash); }
.letters a:hover { text-decoration: none; outline: 2px solid var(--lapis); outline-offset: -2px; }
.letters a[aria-current="true"] { background: var(--lapis); color: var(--paper); box-shadow: inset 0 -3px 0 var(--saffron); }
.letters span { color: var(--muted); opacity: 0.45; }
.letters .letters__word { font-family: var(--font-naskh); font-size: var(--step--1); font-weight: 600; }

.years { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 1rem; list-style: none; margin: 0; padding: 0; }
.years a { display: block; padding: 1rem 1.2rem; border-radius: 0.4rem; background: var(--wash); color: var(--ink); }
.years a:hover { text-decoration: none; outline: 2px solid var(--lapis); }
.years strong { display: block; font-family: var(--font-ruqaa); font-size: var(--step-3); color: var(--lapis); line-height: 1.2; }
.years small { color: var(--muted); }

.empty { padding: 2.5rem 0; color: var(--muted); max-width: var(--measure); }

.searchbox { max-width: 36rem; margin-bottom: 2.5rem; }
.searchbox .search { min-width: 0; }
.searchbox .search input { font-size: var(--step-0); padding: 0.75rem 1rem; }

/* -------------------------------------------------------------------- forms */

.form { max-width: var(--measure); }
.form__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.field label small { color: var(--muted); font-weight: 400; }
.field input,
.field textarea {
    width: 100%;
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    padding: 0.6rem 0.85rem;
}
.field input:focus,
.field textarea:focus { outline: none; border-color: var(--lapis); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lapis) 18%, transparent); }
.field [aria-invalid="true"] { border-color: #b3261e; }
.field__error { color: #b3261e; font-size: var(--step--1); margin: 0.35rem 0 0; }
.form__trap { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form__note { color: var(--muted); font-size: var(--step--1); margin-top: 1rem; }
.form .button { border: 0; cursor: pointer; font: inherit; font-weight: 600; padding: 0.65rem 1.6rem; }

.notice {
    max-width: var(--measure);
    padding: 1.25rem 1.5rem;
    border-radius: 0.5rem;
    background: var(--wash);
    border-inline-start: 0.3rem solid var(--saffron);
}
.notice a { display: block; margin-top: 0.5rem; }

@media (max-width: 640px) {
    .form__row { grid-template-columns: 1fr; }
}

/* --------------------------------------------------------------- pagination */

.pager { margin-top: 3rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; justify-content: center; }
.pager a, .pager span {
    min-width: 2.4rem;
    padding: 0.3rem 0.7rem;
    border-radius: 0.35rem;
    text-align: center;
    font-size: var(--step--1);
}
.pager a { color: var(--ink); border: 1px solid var(--line); }
.pager a:hover { border-color: var(--lapis); text-decoration: none; }
.pager [aria-current="page"] { background: var(--lapis); color: var(--paper); }
.pager .disabled { color: var(--muted); opacity: 0.6; }

/* ------------------------------------------------------------------ article */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: 4rem;
    align-items: start;
}

.article-head { max-width: 48rem; margin-bottom: 2.25rem; }
.article-head h1 { font-size: var(--step-4); line-height: 1.45; margin-block: 0.6rem 1rem; }
.article-head .meta { font-size: var(--step-0); gap: 0.3rem 1.2rem; }
.article-head .meta strong { color: var(--ink); font-weight: 600; }

.article-figure { margin: 0 0 2rem; max-width: var(--measure); }
.article-figure img { border-radius: 0.4rem; }

.prose {
    max-width: var(--measure);
    font-size: var(--step-1);
    line-height: 2.1;
    overflow-wrap: anywhere;
}
.prose p, .prose div { margin: 0 0 1.05em; }
.prose h2, .prose h3, .prose h4 { font-size: var(--step-2); margin: 1.6em 0 0.6em; }
.prose img { display: block; margin: 1.5rem auto; border-radius: 0.3rem; }
.prose a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.3em; }
.prose blockquote { margin: 1.5rem 0; padding-inline-start: 1.25rem; border-inline-start: 0.25rem solid var(--saffron); color: var(--muted); }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1.5rem 0; }
.prose td, .prose th { padding: 0.35rem 0.6rem; vertical-align: top; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2rem 0; }
.prose [style*="center"] { text-align: center; }
.prose:lang(en), .prose[dir="ltr"] { font-size: var(--step-0); line-height: 1.75; }

.attachment { margin-top: 2rem; }

.comments { max-width: var(--measure); margin-top: 3.5rem; }
.comments ol { list-style: none; padding: 0; margin: 0; }
.comment { padding-block: 1.1rem; border-top: 1px solid var(--line); }
.comment header { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; align-items: baseline; }
.comment header strong { font-weight: 600; }
.comment p { margin: 0.4rem 0 0; white-space: pre-line; }

.aside-block + .aside-block { margin-top: 2.75rem; }
.aside-block h2 { font-family: var(--font-ruqaa); font-size: var(--step-2); color: var(--lapis); font-weight: 700; margin-bottom: 0.75rem; line-height: 1.3; }
.aside-block ul { list-style: none; margin: 0; padding: 0; }
.aside-block li { padding-block: 0.6rem; }
.aside-block li + li { border-top: 1px solid var(--line); }
.aside-block li a { color: var(--ink); font-weight: 600; line-height: 1.6; }
.aside-writer { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.aside-writer .monogram { --size: 3.75rem; margin: 0; flex-shrink: 0; }
.aside-writer a { font-weight: 600; }

/* ------------------------------------------------------------------- footer */

.footer {
    background: var(--wash);
    padding-block: 3rem 2rem;
    font-size: var(--step--1);
    color: var(--muted);
}
.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2.5rem; }
.footer .brand__word { font-size: 2.6rem; }
.footer h2 { font-size: var(--step-0); color: var(--ink); margin-bottom: 0.6rem; }
.footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--lapis); }
.footer__note { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }

.theme-toggle {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    border-radius: 0.35rem;
    padding: 0.3rem 0.8rem;
    font: inherit;
    cursor: pointer;
    margin-top: 1rem;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 960px) {
    .front, .article-layout { grid-template-columns: 1fr; gap: 2.75rem; }
    .latest, .sections-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .footer__grid { grid-template-columns: 1fr 1fr; }
    .footer__grid > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .masthead__row { align-items: stretch; flex-direction: column; }
    .search { min-width: 0; }
    .latest, .sections-grid, .list, .features { grid-template-columns: 1fr; }
    .lead { padding-inline-start: 1rem; }
    .profile { grid-template-columns: 1fr; text-align: center; }
    .profile .monogram { margin-inline: auto; }
    .footer__grid { grid-template-columns: 1fr; }
    .prose { font-size: var(--step-0); line-height: 2; }
    .section-band { margin-block: 2.5rem; padding-block: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
