/* ==========================================================================
   د. المهدي بن محمد السعيدي — site styles
   Fixed side rail, alternating light sections, amber accent.
   Written as one system rather than layered overrides.
   ========================================================================== */

:root {
    /* ink */
    --ink:        #0C0C17;
    --ink-2:      #3A3A48;
    --body:       #6B6B6B;   /* was #828282 — 3.84:1, below AA */

    /* the rail and hero share one deep ground */
    --rail:       #0C1424;
    --rail-2:     #121D33;
    --rail-line:  rgba(255, 255, 255, .09);
    --rail-text:  rgba(255, 255, 255, .74);

    /* surfaces */
    --surface:    #FFFFFF;
    --tint:       #F5F8FD;
    --line:       #E7ECF4;

    --amber:      #FEBD01;
    --amber-2:    #FAC23E;
    --amber-soft: rgba(254, 189, 1, .14);
    --amber-ink:  #6B4E00;   /* chip text that clears AA on amber-soft */

    --font-ui:      'Cairo', system-ui, -apple-system, sans-serif;
    --font-display: 'Amiri', Georgia, serif;

    --rail-w: 250px;
    --radius: 10px;
    --radius-lg: 16px;

    --shadow-1: 0 1px 2px rgba(12, 20, 36, .05);
    --shadow-2: 0 6px 24px rgba(12, 20, 36, .08);
    --shadow-3: 0 16px 48px rgba(12, 20, 36, .14);

    --ease: cubic-bezier(.22, .61, .36, 1);
    --dur: 240ms;
}

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

/* The hidden attribute must beat any component's display rule. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.9;
    color: var(--body);
    background: var(--surface);
    direction: rtl;
    text-align: right;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.35; }
p { margin: 0 0 1em; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 32px;
}

/* ===================================================================
   Side rail
   =================================================================== */
.sidebar {
    position: fixed;
    top: 0;
    inset-inline-start: 0;      /* RTL: the right edge */
    width: var(--rail-w);
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px 24px;
    background: var(--rail);
    border-inline-end: 1px solid var(--rail-line);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.sidebar-portrait img {
    width: 96px;
    height: 96px;
    background: var(--rail-2);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, .14);
}

.sidebar .nav-brand {
    margin: 16px 0 24px;
    text-align: center;
}

/* The rail name is a paragraph, not a heading: each page keeps a single h1
   (the hero name, or the page title on a sub-page). */
.rail-name {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.5;
}

.sidebar-role {
    margin: 6px 0 0;
    font-size: .78rem;
    color: rgba(255, 255, 255, .5);
    line-height: 1.6;
}

.sidebar-nav { width: 100%; }

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

.nav-menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--rail-text);
    font-size: .9rem;
    font-weight: 600;
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.nav-menu a svg {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    opacity: .75;
}

.nav-menu a:hover,
.nav-menu a.is-active {
    color: var(--amber);
    background: rgba(255, 255, 255, .05);
}

.nav-menu a:hover svg,
.nav-menu a.is-active svg { opacity: 1; }

.sidebar-social {
    margin-top: auto;
    padding-top: 24px;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.sidebar-social a {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    border: 1px solid var(--rail-line);
    color: rgba(255, 255, 255, .66);
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.sidebar-social a svg { width: 15px; height: 15px; }

.sidebar-social a:hover {
    color: var(--amber);
    border-color: rgba(254, 189, 1, .5);
}

/* Mobile trigger — hidden until the rail collapses */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 14px;
    inset-inline-start: 14px;
    z-index: 120;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--rail-line);
    border-radius: 10px;
    background: var(--rail);
    cursor: pointer;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
    transition: transform 200ms var(--ease), opacity 140ms linear;
}

.hamburger { position: relative; }
.hamburger::before, .hamburger::after { content: ''; position: absolute; left: 0; }
.hamburger::before { top: -6px; }
.hamburger::after  { top: 6px; }

.mobile-menu-toggle.open .hamburger { opacity: 0; }
.mobile-menu-toggle.open .hamburger::before { top: 0; transform: rotate(45deg); }
.mobile-menu-toggle.open .hamburger::after  { top: 0; transform: rotate(-45deg); }

.sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(12, 20, 36, .55);
}

/* Keyboard users would otherwise tab the whole rail on every page. */
.skip-link {
    position: absolute;
    inset-inline-start: -9999px;
    top: 12px;
    z-index: 300;
    padding: 12px 20px;
    border-radius: 8px;
    background: var(--amber);
    color: #1B1400;
    font-weight: 700;
}

.skip-link:focus {
    inset-inline-start: 12px;
}

/* ===================================================================
   Main column
   =================================================================== */
.main { margin-inline-start: var(--rail-w); }

.section { padding: 96px 0; }
.section-plain { background: var(--surface); }
.section-tint  { background: var(--tint); }

h1.section-title, .section-title {
    position: relative;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    color: var(--ink);
    padding-bottom: 16px;
    margin-bottom: 14px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    inset-inline-start: 0;
    width: 46px;
    height: 3px;
    border-radius: 3px;
    background: var(--amber);
}

.section-description {
    max-width: 68ch;
    margin: 0 0 56px;
    font-size: 1rem;
    color: var(--body);
}

.lead {
    font-size: 1.05rem;
    line-height: 2.05;
    color: var(--body);
    max-width: 74ch;
}

/* ===================================================================
   Hero
   =================================================================== */
.hero {
    position: relative;
    min-height: min(100vh, 820px);
    display: flex;
    align-items: center;
    padding: 96px 0;
    background: var(--rail);
    overflow: hidden;
}

/* Portrait bleeds off the far edge and dissolves into the ground. */
.hero-media {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-end: 0;
    width: 44%;
    pointer-events: none;
}

/* The portrait's bright areas reached under the headline, leaving white type on
   near-white pencil. This scrim keeps the ground dark where the two meet. */
.hero-media::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right,
        transparent 0%,
        transparent 38%,
        rgba(12, 20, 36, .55) 68%,
        rgba(12, 20, 36, .95) 90%,
        var(--rail) 100%);
}

.hero-media .hero-image-frame,
.hero-media img { height: 100%; width: 100%; }

.hero-media img {
    object-fit: cover;
    object-position: center top;
    filter: grayscale(.25) contrast(1.03);
    /* The panel sits on the far (left) edge in RTL, so it stays solid there and
       dissolves rightwards into the ground where the headline begins. */
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 40%, transparent 88%);
    mask-image: linear-gradient(to right, #000 0%, #000 40%, transparent 88%);
}

.hero .container { position: relative; z-index: 1; }
.hero-content { display: block; }
.hero-text { max-width: 620px; }

.hero-eyebrow {
    font-size: .92rem;
    font-weight: 600;
    color: var(--amber);
    letter-spacing: .3px;
    margin-bottom: 10px;
}

.hero-text h1, .hero-text h2 {
    font-family: var(--font-display);
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
    margin-bottom: 14px;
}

.hero-subtitle {
    font-size: clamp(1rem, 1.6vw, 1.2rem);
    font-weight: 600;
    color: rgba(255, 255, 255, .9);
    margin-bottom: 6px;
}

.hero-description {
    font-size: .96rem;
    color: rgba(255, 255, 255, .72);
    max-width: 46ch;
    margin-bottom: 40px;
}

.hero-image-mobile { display: none; }

.hero-buttons { display: flex; gap: 12px; flex-wrap: wrap; }

/* ===================================================================
   Buttons
   =================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 26px;
    border: 1px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    font-size: .93rem;
    cursor: pointer;
    transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
                color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.btn-primary { background: var(--amber); color: #1B1400; }
.btn-primary:hover { background: var(--amber-2); transform: translateY(-2px); }

.btn-secondary {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, .3);
}
.btn-secondary:hover { border-color: var(--amber); color: var(--amber); transform: translateY(-2px); }

.btn:active { transform: none; }

.btn-count {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .16);
    font-size: .78rem;
}

/* ===================================================================
   About
   =================================================================== */
/* ===================================================================
   Cards — books and research
   =================================================================== */
.books-grid,
.research-grid {
    display: grid;
    gap: 24px;
}

.books-grid    { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.research-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.book-card,
.research-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.book-card:hover,
.research-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

/* books ---------------------------------------------------------- */
.book-card { display: flex; flex-direction: column; cursor: pointer; }

.book-cover {
    height: 230px;
    contain: paint;
    background: linear-gradient(160deg, #EEF2F8, #E2E9F4);
    overflow: hidden;
}

/* Half the bibliography has no cover art; those get a quiet band rather
   than a placeholder pattern holding full cover height for nothing. */
.book-cover:empty {
    height: 72px;
    background: linear-gradient(160deg, var(--rail), var(--rail-2));
}

.book-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms var(--ease);
}

.book-card:hover .book-cover-img { transform: scale(1.04); }

.book-info { padding: 22px; display: flex; flex-direction: column; flex: 1; }

.book-title {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.6;
    margin-bottom: 8px;
}

.book-subject { font-size: .85rem; line-height: 1.75; color: var(--body); margin: 0; }

/* Series kicker above the title, with its volume number as a small counter.
   Quieter than the amber year pill so the title still leads the card. */
.book-series {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    align-self: flex-start;   /* a flex child would otherwise stretch */
    margin: 0 0 7px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--tint);
    color: var(--ink-2);
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.7;
}

.book-series-no {
    display: grid;
    place-items: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--rail);
    color: #fff;
    font-size: .66rem;
    font-variant-numeric: tabular-nums;
}

.book-year {
    align-self: flex-start;
    margin: 18px 0 0;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--amber-soft);
    color: var(--amber-ink);
    font-size: .78rem;
    font-weight: 700;
}

.book-menu-btn {
    position: absolute;
    bottom: 12px;
    inset-inline-end: 12px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.book-menu-btn:hover { background: var(--amber); color: #1B1400; border-color: transparent; }

.books-cta { display: flex; justify-content: center; margin-top: 48px; }
.books-cta .btn-primary { color: #1B1400; }

/* research ------------------------------------------------------- */
.research-card { padding: 32px; }

.research-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    font-size: 1.35rem;
    border-radius: 12px;
    background: var(--amber-soft);
    filter: saturate(.7);
}

.research-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; }
.research-card p { font-size: .93rem; line-height: 1.85; margin: 0; }

/* ===================================================================
   Tabs — writings (المقالات / العروض)
   =================================================================== */
.tabs { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }

.tab {
    padding: 9px 22px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--body);
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
                background var(--dur) var(--ease);
}

.tab:hover { border-color: var(--amber); color: var(--ink); }
.tab.is-active { background: var(--amber); border-color: transparent; color: #1B1400; }

/* Theme filter, one level below the tabs: lighter weight so the tabs stay
   the primary control and the chips read as a refinement of them. */
.chips { display: flex; gap: 8px; margin: -14px 0 26px; flex-wrap: wrap; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--body);
    font: inherit;
    font-size: .82rem;
    line-height: 1.5;
    cursor: pointer;
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
                background var(--dur) var(--ease);
}

.chip:hover { border-color: var(--amber); color: var(--ink); }
.chip.is-active { background: var(--rail); border-color: transparent; color: #FFF; }

/* On touch the compact chip is under the 44px target, so grow it there only. */
@media (pointer: coarse) {
    .chip { padding-block: 11px; }
}

/* Label text for screen readers only — the magnifier carries the meaning
   visually, but an unlabelled input is not navigable without sight. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ===================================================================
   Search (the bibliography is long enough to need it)
   =================================================================== */
/* Search and the theme dropdown share one row; they stack on narrow screens. */
.filters {
    display: flex;
    align-items: stretch;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 4px;
}

.filters .search-field { flex: 1 1 300px; }

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 460px;
}

.search-icon {
    position: absolute;
    inset-inline-start: 14px;
    width: 17px;
    height: 17px;
    color: var(--body);
    opacity: .7;
    pointer-events: none;
}

.search-field input {
    width: 100%;
    /* room for the icon at the start and the clear button at the end */
    padding: 12px 44px 12px 42px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .92rem;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}

.search-field input::placeholder { color: var(--body); opacity: .8; }

.search-field input:focus-visible {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

/* The UA's own clear affordance would sit alongside ours. */
.search-field input::-webkit-search-cancel-button { display: none; }

.search-clear {
    position: absolute;
    inset-inline-end: 6px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--body);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.search-clear:hover { color: var(--ink); background: var(--tint); }

.search-count {
    margin: 10px 2px 0;
    font-size: .85rem;
    color: var(--body);
    min-height: 1.4em;    /* hold the line so results do not jump as it fills */
}

.search-count b { color: var(--ink); font-weight: 700; }

.search-count a {
    color: var(--amber-ink);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ===================================================================
   Theme dropdown — sits beside the search field
   =================================================================== */
.dropdown { position: relative; flex: 0 1 300px; }

.dropdown-toggle {
    width: 100%;
    height: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.dropdown-toggle:hover { border-color: var(--amber); }

.dropdown-toggle:focus-visible {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

.dropdown-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-caret {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: var(--body);
    transition: transform var(--dur) var(--ease);
}

.dropdown-toggle[aria-expanded="true"] {
    border-color: var(--amber);
}

.dropdown-toggle[aria-expanded="true"] .dropdown-caret { transform: rotate(180deg); }

/* Slides down on open. Driven by a class and `visibility` rather than the
   hidden attribute: [hidden] is display:none, which cannot transition, and
   fading in from display:none needs a rAF that is suspended in a hidden tab.
   visibility also keeps the closed panel out of tab order and the a11y tree. */
.dropdown-panel {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    width: 100%;
    min-width: 260px;
    max-height: 340px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 160ms var(--ease), transform 160ms var(--ease),
                visibility 0s linear 160ms;
}

.dropdown-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity 160ms var(--ease), transform 160ms var(--ease),
                visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {
    .dropdown-panel, .dropdown-panel.is-open { transition: none; }
}

.dropdown-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: .88rem;
    text-align: start;
    cursor: pointer;
}

.dropdown-option:hover,
.dropdown-option:focus-visible {
    outline: none;
    background: var(--tint);
    color: var(--ink);
}

.dropdown-option[aria-selected="true"] {
    background: var(--rail);
    color: #fff;
    font-weight: 700;
}

.dropdown-option[aria-selected="true"] .chip-count { opacity: .75; }

.dropdown-option[aria-disabled="true"] {
    opacity: .4;
    cursor: default;
}

.dropdown-option[aria-disabled="true"]:hover { background: transparent; color: var(--ink-2); }

.dropdown-option-label { flex: 1; }

.dropdown-sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--line);
}

.chip[disabled] { opacity: .38; cursor: default; }
.chip[disabled]:hover { border-color: var(--line); color: var(--body); }

.chip-count {
    font-size: .74rem;
    font-variant-numeric: tabular-nums;
    color: inherit;
    opacity: .6;
}

/* ===================================================================
   Row lists — writings and interviews
   =================================================================== */
.writings-list, .interviews-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.writing-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease);
}

a.writing-row:hover {
    transform: translateY(-2px);
    border-color: var(--amber);
    box-shadow: var(--shadow-2);
}

.writing-main { flex: 1; min-width: 0; }
.writing-main h3 { font-size: 1.02rem; font-weight: 700; margin-bottom: 4px; line-height: 1.6; }
.writing-venue { margin: 0; font-size: .88rem; color: var(--body); }

.writing-year {
    flex-shrink: 0;
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--amber-soft);
    color: #8A6400;
    font-size: .8rem;
    font-weight: 700;
}

/* ===================================================================
   Gallery — صور وفيديو
   =================================================================== */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.media-item {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.media-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms var(--ease);
}

.media-item:hover img { transform: scale(1.05); }

.media-caption {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    padding: 30px 14px 12px;
    /* Captions sit over arbitrary photos, so the scrim has to carry the
       contrast on its own rather than relying on the image being dark. */
    background: linear-gradient(to top, rgba(8, 13, 24, .94) 0%, rgba(8, 13, 24, .78) 45%, transparent 100%);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
    color: #fff;
    font-size: .82rem;
    font-weight: 600;
    text-align: start;
    line-height: 1.5;
}

.media-play {
    position: absolute;
    top: 50%;
    inset-inline-start: 50%;
    transform: translate(50%, -50%);
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: var(--rail);
    font-size: 15px;
}

/* Photo row / video row inside صور وفيديو */
.media-block + .media-block { margin-top: 56px; }

.block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.block-head h3 {
    font-size: 1.1rem;
    font-weight: 700;
    position: relative;
    padding-inline-start: 14px;
}

.block-head h3::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 18px;
    border-radius: 2px;
    background: var(--amber);
}

/* A single row that scrolls sideways rather than wrapping on small screens. */
.media-row { grid-template-columns: repeat(4, 1fr); }

.btn-ghost {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
    font-size: .88rem;
    padding: 9px 18px;
}

.btn-ghost:hover { border-color: var(--amber); transform: translateY(-2px); }
.btn-ghost .btn-count { background: var(--amber-soft); color: var(--amber-ink); }

/* ===================================================================
   Video cards
   =================================================================== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.video-item {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: start;
    cursor: pointer;
}

.video-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--rail);
    overflow: hidden;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-item:hover .video-thumb { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.video-caption {
    display: block;
    margin-top: 12px;
    font-size: .92rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.6;
}

/* ===================================================================
   Video lightbox
   =================================================================== */
.video-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    place-items: center;
    padding: 24px;
}

.video-modal.active { display: grid; }

.video-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 20, 36, .84);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.video-modal-content {
    position: relative;
    width: min(94vw, 960px);
}

.video-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-3);
}

.video-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

.video-modal-close {
    position: absolute;
    top: -46px;
    inset-inline-end: 0;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.video-modal-close:hover { background: rgba(255, 255, 255, .26); }

/* ===================================================================
   News — مستجدات
   =================================================================== */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.news-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

a.news-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }

.news-image { height: 180px; overflow: hidden; background: var(--tint); }
.news-image img { width: 100%; height: 100%; object-fit: cover; }

.news-body { padding: 22px; }

.news-date {
    display: inline-block;
    margin-bottom: 10px;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--amber-soft);
    color: var(--amber-ink);
    font-size: .76rem;
    font-weight: 700;
}

.news-body h3 { font-size: 1.04rem; font-weight: 700; line-height: 1.6; margin-bottom: 8px; }
.news-body p { margin: 0; font-size: .9rem; line-height: 1.8; color: var(--body); }

/* ===================================================================
   Blog post
   =================================================================== */
.post { max-width: 74ch; }

.post-title {
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 3.4vw, 2.5rem);
    font-weight: 700;
    line-height: 1.35;
    margin: 14px 0 18px;
}

.post-lead {
    font-size: 1.08rem;
    line-height: 1.95;
    color: var(--ink-2);
    margin-bottom: 28px;
}

.post-image {
    margin: 0 0 32px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--tint);
}

.post-image img { width: 100%; height: auto; }

.post-body {
    font-size: 1.02rem;
    line-height: 2.1;
    color: var(--body);
}

.post-body strong { color: var(--ink); font-weight: 700; }
.post-body a { color: var(--amber-ink); text-decoration: underline; }
.post-link { margin-top: 36px; }

/* card affordance now that every post has its own page */
.news-more {
    display: inline-block;
    margin-top: 14px;
    color: var(--amber-ink);
    font-size: .86rem;
    font-weight: 700;
}

a.news-card:hover .news-more { text-decoration: underline; }

/* ===================================================================
   Timeline
   =================================================================== */
.timeline { position: relative; }

.timeline::before {
    content: '';
    position: absolute;
    top: 6px;
    bottom: 6px;
    inset-inline-start: 116px;
    width: 1px;
    background: var(--line);
}

.timeline-item {
    position: relative;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 40px;
    padding-bottom: 32px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    top: 22px;
    inset-inline-start: 111px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 0 4px var(--tint);
}

.section-plain .timeline-item::before { box-shadow: 0 0 0 4px var(--surface); }

.timeline-year {
    padding-top: 18px;
    font-size: .9rem;
    font-weight: 700;
    color: var(--ink);
    text-align: start;
}

.timeline-content {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 28px;
    align-items: center;
    padding: 24px 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.timeline-content:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }

.timeline-content h3 { font-size: 1.06rem; font-weight: 700; margin-bottom: 6px; }
.timeline-text p { margin: 0 0 3px; font-size: .92rem; }
.timeline-institution { color: var(--ink-2); }
.timeline-specialty, .timeline-grade { color: var(--body); }
.timeline-duration { color: var(--body); font-size: .85rem; }

.timeline-image {
    flex-shrink: 0;
    display: grid;
    place-items: center;
}

/* The logo sits against the card's leading edge as a plain mark — it used to be
   boxed on its own tinted panel, a card inside a card. */
.timeline-img {
    width: 84px;
    height: 84px;
    object-fit: contain;
    border: 0;
    padding: 0;
    background: none;
    border-radius: 0;
}

/* ===================================================================
   Contact + footer
   =================================================================== */
.contact-info { display: flex; flex-wrap: wrap; gap: 14px; }

.contact-button {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    padding: 14px 26px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    font-size: .93rem;
    transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease);
}

.contact-button svg { width: 18px; height: 18px; }
.contact-button:hover { transform: translateY(-2px); border-color: var(--amber); box-shadow: var(--shadow-1); }

.footer { background: var(--rail); color: rgba(255, 255, 255, .62); padding: 56px 0 28px; }

.footer-content {
    display: grid;
    grid-template-columns: 1.4fr 1fr auto;
    gap: 32px;
    align-items: center;
    padding-bottom: 28px;
}

.footer-info h3 { color: #fff; font-size: 1.05rem; margin-bottom: 6px; }
.footer-info p { margin: 0; font-size: .9rem; }

.footer-links { display: flex; flex-wrap: wrap; gap: 6px; font-size: .9rem; }
.footer-links a { padding: 10px 12px; }
.footer-links a { transition: color var(--dur) var(--ease); }
.footer-links a:hover { color: var(--amber); }

.footer-social { display: flex; gap: 9px; }

.footer-social a {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid var(--rail-line);
    border-radius: 8px;
    color: rgba(255, 255, 255, .7);
    transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.footer-social a svg { width: 16px; height: 16px; }
.footer-social a:hover { color: var(--amber); border-color: rgba(254, 189, 1, .5); }

.footer-copyright {
    border-top: 1px solid var(--rail-line);
    padding-top: 22px;
    text-align: center;
    font-size: .85rem;
    color: rgba(255, 255, 255, .58);
}

.footer-copyright p { margin: 0; }

/* ===================================================================
   /books page
   =================================================================== */
.books-page,
.writings-page,
.family-page { padding-top: 64px; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 26px;
    padding: 9px 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-size: .89rem;
    font-weight: 600;
    transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.back-link:hover { border-color: var(--amber); transform: translateY(-2px); }

/* ===================================================================
   404
   =================================================================== */
.notfound { display: grid; place-items: center; min-height: 78vh; text-align: center; }
.notfound .container { max-width: 640px; }

.notfound-code {
    font-family: var(--font-display);
    font-size: clamp(4.5rem, 16vw, 9rem);
    font-weight: 700;
    line-height: 1;
    margin: 0 0 8px;
    color: var(--amber);
    /* Arabic-Indic numerals, so it reads as part of the page rather than a
       stray Latin string in an otherwise Arabic layout. */
    letter-spacing: .06em;
}

.notfound-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3.4vw, 2.1rem);
    font-weight: 700;
    margin-bottom: 14px;
}

.notfound-lead {
    font-size: 1.02rem;
    line-height: 2;
    color: var(--body);
    margin: 0 auto 32px;
    max-width: 52ch;
}

.notfound-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.notfound-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    justify-content: center;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.notfound-links a {
    color: var(--body);
    font-size: .92rem;
    font-weight: 600;
    transition: color var(--dur) var(--ease);
}

.notfound-links a:hover { color: var(--amber-ink); }

/* ===================================================================
   Legal pages
   =================================================================== */
.legal-page .container { max-width: 760px; }

.legal-updated {
    margin: -4px 0 36px;
    font-size: .88rem;
    color: var(--body);
}

.legal-body { font-size: 1rem; line-height: 2.05; color: var(--body); }

.legal-body h2 {
    font-family: var(--font-display);
    font-size: 1.22rem;
    font-weight: 700;
    color: var(--ink);
    margin: 40px 0 12px;
}

.legal-body p { margin: 0 0 16px; }
.legal-body strong { color: var(--ink); font-weight: 700; }

.legal-body a {
    color: var(--amber-ink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.legal-body ul { margin: 0 0 16px; padding-inline-start: 22px; }
.legal-body li { margin-bottom: 8px; }
.legal-body li::marker { color: var(--amber); }

/* Legal links sit under the copyright line on every page. */
.footer-legal {
    display: flex;
    gap: 22px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 10px 0 0;
    font-size: .84rem;
}

.footer-legal a {
    color: rgba(255, 255, 255, .58);
    transition: color var(--dur) var(--ease);
}

.footer-legal a:hover { color: var(--amber); }

/* ===================================================================
   Image modals
   =================================================================== */
.book-modal, .book-details-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    place-items: center;
    padding: 24px;
}

.book-modal.active, .book-details-modal.active { display: grid; }

.book-modal-overlay, .book-details-overlay {
    position: absolute;
    inset: 0;
    background: rgba(12, 20, 36, .78);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.book-modal-content, .book-details-content {
    position: relative;
    max-width: min(90vw, 720px);
    max-height: 88vh;
}

.book-modal-img, .book-details-img {
    max-width: 100%;
    max-height: 88vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow-3);
}

.book-modal-close, .book-details-close {
    position: absolute;
    top: -46px;
    inset-inline-end: 0;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.book-modal-close:hover, .book-details-close:hover { background: rgba(255, 255, 255, .26); }

/* ===================================================================
   Loading / error / reveal
   =================================================================== */
body.is-loading .main { opacity: 0; }
.main { opacity: 1; transition: opacity 240ms var(--ease); }

body.is-loading::after {
    content: '';
    position: fixed;
    top: 50%;
    inset-inline-start: calc(50% + (var(--rail-w) / 2));
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border: 3px solid rgba(12, 20, 36, .12);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    z-index: 50;
}

@keyframes spin { to { transform: rotate(360deg); } }

.load-error {
    max-width: 620px;
    margin: 120px auto;
    padding: 32px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    color: var(--ink);
}

.load-error-hint { font-size: .9rem; color: var(--body); }

.reveal { opacity: 0; transform: translateY(14px); }
.reveal.is-visible {
    opacity: 1;
    transform: none;
    transition: opacity 560ms var(--ease), transform 560ms var(--ease);
}

/* ===================================================================
   Focus — keyboard users need to see where they are
   =================================================================== */
:where(a, button, input, textarea, select, [tabindex]):focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
    border-radius: 6px;
}

.sidebar :where(a, button):focus-visible { outline-color: var(--amber); }

/* The active rail entry gets a marker, not just a colour shift. */
.nav-menu a { position: relative; }

.nav-menu a.is-active::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--amber);
}

/* ===================================================================
   Responsive
   =================================================================== */
@media (max-width: 1024px) {
    :root { --rail-w: 0px; }

    .mobile-menu-toggle { display: flex; }

    .sidebar {
        width: 280px;
        transform: translateX(100%);   /* RTL: parks off the right edge */
        transition: transform 260ms var(--ease);
    }

    .sidebar.open { transform: none; }

    .main { margin-inline-start: 0; }

    body.is-loading::after { inset-inline-start: 50%; }

    .hero-media { display: none; }
    .hero { min-height: 0; padding: 104px 0 72px; text-align: center; }
    .hero-text { max-width: none; }
    .hero-description { margin-inline: auto; }
    .hero-buttons { justify-content: center; }
    .section-title::after { inset-inline-start: 0; }

    .hero-image-mobile { display: block; margin: 0 auto 26px; }

    .hero-image-mobile img {
        width: min(230px, 60vw);
        height: min(230px, 60vw);
        object-fit: cover;
        border-radius: 20px;
        margin: 0 auto;
        box-shadow: var(--shadow-3);
    }

    .footer-content { grid-template-columns: 1fr; text-align: center; justify-items: center; }
    .footer-links { justify-content: center; }

    .media-row  { grid-template-columns: repeat(3, 1fr); }
    .video-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .container { padding: 0 20px; }
    .section { padding: 64px 0; }
    .section-description { margin-bottom: 36px; }

    .timeline::before,
    .timeline-item::before { display: none; }

    .timeline-item { grid-template-columns: 1fr; gap: 10px; }
    .timeline-year { padding-top: 0; color: var(--amber); }
    .timeline-content { grid-template-columns: 1fr; }
    .timeline-image { display: none; }

    .research-card { padding: 26px; }

    .writing-row { flex-direction: column; align-items: flex-start; gap: 12px; padding: 18px; }
    .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .media-row  { grid-template-columns: repeat(2, 1fr); }
    .video-grid { grid-template-columns: 1fr; }
    .block-head { gap: 10px; }
    .media-block + .media-block { margin-top: 40px; }
    .news-image { height: 150px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    .reveal, .reveal.is-visible { opacity: 1; transform: none; }
}

/* ===================================================================
   Line of descent (/family) — a vertical chain, one node per generation
   =================================================================== */
.lineage {
    list-style: none;
    margin: 28px 0 32px;
    padding: 0;
    max-width: 460px;
}

.lineage-step {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 0;
}

/* The connector runs from each node to the next, so it is drawn on every
   step but the last. RTL: the rail sits on the right. */
.lineage-step:not(.is-last)::before {
    content: '';
    position: absolute;
    top: 34px;
    inset-inline-start: 13px;
    width: 2px;
    height: calc(100% - 16px);
    background: var(--line);
}

.lineage-gen {
    position: relative;
    z-index: 1;
    flex: 0 0 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--tint);
    border: 1px solid var(--line);
    color: var(--body);
    font-size: .72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.lineage-name {
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.6;
}

/* The living end of the chain — the professor himself. */
.lineage-step.is-last .lineage-gen {
    background: var(--amber);
    border-color: transparent;
    color: #1B1400;
}

.lineage-step.is-last .lineage-name { color: var(--ink); }

/* ===================================================================
   حوارات
   =================================================================== */
.interview-row { align-items: flex-start; }

.interview-link { display: block; }
.interview-link:hover h3 { color: var(--amber-ink); }

.interview-topic {
    margin: 2px 0 0;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--body);
}

/* role · medium · language · episode. Plain text, so a row does not fill up
   with pills. */
.interview-meta {
    margin: 6px 0 0;
    font-size: .78rem;
    line-height: 1.8;
    color: var(--body);
}

.interview-meta { font-weight: 600; color: var(--ink-2); }

/* The Latin-script name and the English/French affiliation. Real visible text —
   he is searched for in three languages, and the page itself is Arabic only. */
.footer-latin {
    margin: 10px 0 0;
    max-width: 62ch;
    font-size: .76rem;
    line-height: 1.75;
    color: rgba(255, 255, 255, .42);
    direction: ltr;
    text-align: start;
}
