/* Afaq palette (from the Afaq app's tailwind config) */
:root {
  --navy: #0f2b48;
  --navy-dark: #071727;
  --navy-hover: #183d63;
  --gold: #d4a373;
  --gold-hover: #bc8a5f;
  --gold-ink: #8a5a2b;
  --paper: #f8fafc;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --shadow: 0 4px 20px -2px rgba(15, 43, 72, .08);
  --sans: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  --serif: "Amiri", "Traditional Arabic", Georgia, serif;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 1rem; top: -3rem; background: var(--gold); color: #fff; padding: .4rem .9rem; border-radius: 6px; z-index: 99; text-decoration: none; font-weight: 700; }
.skip:focus { top: .5rem; }

.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: 1.25rem; }
@media (max-width: 520px) { .wrap { padding-inline: 1rem; } }

/* Top bar */
.topbar { background: var(--navy-dark); color: #94a3b8; font-size: .85rem; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 36px; }
.topbar-tag { display: inline-flex; align-items: center; gap: .5rem; }
.topbar-tag svg { width: 16px; height: 16px; fill: var(--gold); flex: none; }
.lang {
  font: 500 .8rem var(--sans); color: #fff; background: rgba(30, 41, 59, .8);
  border: 1px solid #334155; border-radius: 6px; padding: .15rem .75rem; cursor: pointer;
}
.lang:hover { border-color: var(--gold); color: var(--gold); }

/* Header */
.site-head { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(0, 0, 0, .03); }
.head-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: .85rem; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--navy); min-width: 0; }
.brand-tile {
  width: 46px; height: 46px; flex: none; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--gold));
}
.brand-tile svg { width: 28px; height: 28px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.3rem; font-weight: 800; line-height: 1.25; }
.brand-text small { color: var(--muted); font-size: .8rem; }
.issue-nav { display: flex; align-items: center; gap: .25rem; }
.issue-nav .nav-label { font-size: .85rem; color: var(--muted); font-weight: 700; margin-inline-end: .35rem; white-space: nowrap; }
.issue-nav a {
  text-decoration: none; font-weight: 500; font-size: .92rem; color: var(--ink);
  padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; min-width: 2.4rem; text-align: center;
}
.issue-nav a:hover { color: var(--gold-ink); border-color: var(--gold); }
@media (max-width: 760px) {
  .head-in { flex-wrap: wrap; }
  .issue-nav { width: 100%; overflow-x: auto; padding-bottom: .1rem; }
  .brand-text strong { font-size: 1.1rem; }
}

/* Hero */
.hero { background: var(--navy); color: #e2e8f0; overflow: hidden; position: relative; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(60rem 30rem at 85% 120%, rgba(212, 163, 115, .18), transparent 60%);
}
.hero-in { position: relative; display: grid; grid-template-columns: 1.05fr 1fr; gap: 2.5rem; align-items: center; padding-block: 3.5rem 4rem; }
.hero-kicker { margin: 0 0 .5rem; color: var(--gold); font-weight: 700; font-size: .95rem; }
.journal-name { margin: 0; display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; line-height: 1; }
.jn-ar { font-family: var(--serif); font-weight: 700; font-size: clamp(4rem, 10vw, 6.5rem); color: #fff; }
.jn-fr { font-family: var(--sans); font-weight: 800; font-size: clamp(1.1rem, 2.4vw, 1.5rem); letter-spacing: .5em; color: var(--gold); }
.hero-desc { max-width: 34em; font-size: 1.08rem; color: #cbd5e1; margin: 1.25rem 0 1.25rem; }
.free-note {
  display: inline-flex; align-items: center; gap: .5rem; margin: 0; padding: .45rem .9rem; border-radius: 8px;
  background: rgba(212, 163, 115, .14); color: #f3dcc4; font-weight: 500;
}
.free-note svg { width: 18px; height: 18px; fill: var(--gold); flex: none; }
.issn { margin: .9rem 0 0; font-size: .85rem; color: #94a3b8; }

/* Cover fan: the one bold element */
.cover-fan { position: relative; height: 400px; }
.fan-cover {
  position: absolute; top: 50%; inset-inline-start: 50%; width: 210px; aspect-ratio: 640 / 980;
  border-radius: 4px; overflow: hidden; text-decoration: none;
  box-shadow: 0 24px 40px -12px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .08);
  transition: transform .35s ease, box-shadow .35s ease;
}
.fan-cover img { width: 100%; height: 100%; object-fit: cover; }
.fan-cover:hover, .fan-cover:focus-visible { z-index: 5; }
[dir="rtl"] .fan-cover { transform: translate(50%, -50%) translateX(var(--x)) rotate(var(--r)); }
[dir="ltr"] .fan-cover { transform: translate(-50%, -50%) translateX(var(--x)) rotate(var(--r)); }
[dir="rtl"] .fan-cover:hover, [dir="rtl"] .fan-cover:focus-visible { transform: translate(50%, -54%) translateX(var(--x)) rotate(0deg) scale(1.04); }
[dir="ltr"] .fan-cover:hover, [dir="ltr"] .fan-cover:focus-visible { transform: translate(-50%, -54%) translateX(var(--x)) rotate(0deg) scale(1.04); }
.fan-cover .tag {
  position: absolute; bottom: .5rem; inset-inline-start: .5rem; background: var(--navy-dark); color: #fff;
  font-size: .78rem; font-weight: 700; padding: .1rem .6rem; border-radius: 999px;
}
@media (max-width: 900px) {
  .hero-in { grid-template-columns: 1fr; padding-block: 2.5rem 1rem; }
  .cover-fan { height: 300px; }
  .fan-cover { width: 150px; }
}
@media (max-width: 420px) {
  .cover-fan { height: 250px; }
  .fan-cover { width: 120px; }
}

/* Generated cover for issue 1 (no cover file supplied) */
.made-cover {
  text-decoration: none;
  width: 100%; height: 100%; background: #cdc4b5; color: var(--navy-dark); position: relative;
  display: flex; flex-direction: column; padding: 12% 10%; font-family: var(--serif); text-align: center;
  background-image: radial-gradient(circle at 30% 20%, rgba(255,255,255,.35), transparent 55%);
}
.made-cover .mc-name { font-size: 3.2em; font-weight: 700; line-height: 1; margin-top: 8%; }
.made-cover .mc-sub { font-family: var(--sans); font-size: .62em; font-weight: 700; margin-top: .6em; }
.made-cover .mc-num {
  position: absolute; top: 7%; inset-inline-start: 9%; width: 1.9em; height: 1.9em; border-radius: 50%;
  background: #8b1e23; color: #fff; display: grid; place-items: center; font-family: var(--sans); font-weight: 800; font-size: 1.05em;
}
.made-cover .mc-dossier { margin-top: auto; color: #8b1e23; font-weight: 700; font-size: 1.05em; line-height: 1.5; }
.made-cover .mc-label { font-family: var(--sans); font-size: .6em; font-weight: 700; color: var(--navy); }
.fan-cover .made-cover { font-size: 11px; }
@media (max-width: 900px) { .fan-cover .made-cover { font-size: 8px; } }
@media (max-width: 420px) { .fan-cover .made-cover { font-size: 6.5px; } }

/* Issues */
.issues { padding-block: 3rem 4rem; }
.issues-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.issues-head h2 { margin: 0; font-size: 1.6rem; color: var(--navy); font-weight: 800; }
.search { position: relative; flex: 0 1 380px; }
.search svg { position: absolute; top: 50%; inset-inline-start: .8rem; width: 18px; height: 18px; fill: var(--muted); transform: translateY(-50%); }
.search input {
  width: 100%; font: 1rem var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; padding-inline-start: 2.5rem;
}
.search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 163, 115, .25); }
@media (max-width: 640px) { .search { flex-basis: 100%; } }
.search-empty { background: var(--surface); border: 1px dashed var(--line); padding: 1rem 1.25rem; border-radius: 10px; color: var(--muted); }

.issue {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 240px 1fr; gap: 2rem; padding: 1.75rem; margin-bottom: 1.75rem;
  scroll-margin-top: 90px;
}
.issue-cover { align-self: start; position: sticky; top: 96px; }
.issue-cover .main-cover { text-decoration: none; display: block; border-radius: 4px; overflow: hidden; box-shadow: 0 12px 24px -10px rgba(15, 43, 72, .45); aspect-ratio: 640 / 980; }
.issue-cover img { width: 100%; height: 100%; object-fit: cover; }
.issue-cover .made-cover { font-size: 12.5px; }
.alt-cover { display: flex; align-items: center; gap: .6rem; margin-top: .8rem; font-size: .85rem; color: var(--muted); text-decoration: none; }
.issue-cover .alt-cover img { width: 44px; height: auto; object-fit: contain; border-radius: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.alt-cover:hover { color: var(--gold-ink); }

.issue-meta { margin: 0; color: var(--muted); font-size: .95rem; }
.issue h3 { margin: .1rem 0 .9rem; font-size: 1.9rem; color: var(--navy); font-weight: 800; line-height: 1.3; }
.dossier { border-inline-start: 4px solid var(--gold); padding-inline-start: 1rem; margin-bottom: 1.5rem; }
.dossier .label { font-size: .85rem; color: var(--gold-ink); font-weight: 700; }
.dossier .ar { font-family: var(--serif); font-size: 1.55rem; font-weight: 700; color: var(--ink); line-height: 1.5; margin: 0; }
[dir="rtl"] .dossier .fr { text-align: right; }
.dossier .fr { font-family: var(--serif); font-size: 1.15rem; color: var(--muted); margin: .2rem 0 0; }

/* Files */
.files { list-style: none; margin: 0 0 1.75rem; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.file { display: flex; align-items: center; gap: 1rem; padding: .85rem 1rem; }
.file + .file { border-top: 1px solid var(--line); }
.file-icon { width: 40px; height: 48px; flex: none; position: relative; }
.file-icon svg { width: 100%; height: 100%; }
.file-icon b { position: absolute; bottom: 5px; inset-inline: 0; text-align: center; font-size: .85rem; line-height: 1.2; color: #fff; font-family: var(--sans); font-weight: 800; }
.file-info { flex: 1; min-width: 0; }
.file-info strong { display: block; font-size: 1.02rem; color: var(--navy); }
.file-info span { font-size: .85rem; color: var(--muted); }
.file-actions { display: flex; gap: .5rem; flex: none; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; font: 700 .9rem var(--sans);
  padding: .5rem 1rem; border-radius: 8px; border: 1px solid transparent; white-space: nowrap; cursor: pointer;
}
.btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.btn-view { color: var(--navy); border-color: var(--line); background: var(--surface); }
.btn-view:hover { border-color: var(--navy); }
.btn-dl { color: #fff; background: var(--gold); }
.btn-dl:hover { background: var(--gold-hover); }
@media (max-width: 640px) {
  .file { flex-wrap: wrap; }
  .file-actions { width: 100%; }
  .file-actions .btn { flex: 1; justify-content: center; }
}

/* Contents */
.contents h4 { margin: 0 0 .5rem; font-size: 1.05rem; color: var(--navy); font-weight: 800; }
.part + .part { margin-top: 1.25rem; }
.part-title { font-size: .9rem; color: var(--muted); font-weight: 700; margin: 0 0 .25rem; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc li { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; padding: .7rem 0; border-bottom: 1px solid var(--soft); }
.toc li:last-child { border-bottom: 0; }
.toc .t { font-family: var(--serif); font-size: 1.12rem; line-height: 1.55; color: var(--ink); }
.toc [lang="fr"] .t, .toc [lang="en"] .t { font-size: 1.05rem; }
.toc .sec { display: inline-block; font-family: var(--sans); font-size: .78rem; font-weight: 700; color: var(--gold-ink); background: rgba(212, 163, 115, .16); border-radius: 999px; padding: 0 .55rem; margin-inline-end: .4rem; vertical-align: 2px; }
.toc .a { grid-column: 1; font-size: .9rem; color: var(--muted); }
.toc .p { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.toc mark { background: rgba(212, 163, 115, .35); color: inherit; border-radius: 2px; }

@media (max-width: 860px) {
  .issue { grid-template-columns: 1fr; padding: 1.25rem; gap: 1.25rem; }
  .issue-cover { position: static; display: flex; gap: 1rem; align-items: flex-end; }
  .issue-cover .main-cover { width: 130px; flex: none; }
  .issue-cover .made-cover { font-size: 6.8px; }
  .alt-cover { margin-top: 0; }
  .issue h3 { font-size: 1.5rem; }
}

/* Footer */
.site-foot { background: var(--navy-dark); color: #94a3b8; border-top: 4px solid var(--gold); padding-top: 2.5rem; }
.foot-in { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
.site-foot h3 { color: #fff; font-size: 1.05rem; margin: 0 0 .5rem; }
.site-foot p { margin: 0; font-size: .92rem; max-width: 40em; }
.foot-base { border-top: 1px solid #1e293b; margin-top: 2rem; padding-block: 1rem; font-size: .82rem; }
@media (max-width: 700px) { .foot-in { grid-template-columns: 1fr; } }
