/* ============================================================
   Miftah Arabic — Topic Storyline booklet
   Palette taken from the poster artwork so the shell and the
   detail pages sit in the same world as the pages themselves.
   ============================================================ */

:root{
  --navy:#002347;
  --navy-2:#013a6b;
  --ink:#12315F;
  --teal:#0B6B7F;
  --teal-2:#0E7F8C;
  --gold:#C8963E;
  --gold-2:#E3C48E;
  --gold-3:#F3E6CD;
  --cream:#FCF8F3;
  --card:#FFFDF9;
  --card-2:#FBF6EE;
  --line:#E9DFCF;
  --body:#2C3A4C;
  --muted:#61708A;

  --desk:#E7DECF;
  --desk-ink:#4A3F31;
  --shadow:0 6px 28px rgba(0,35,71,.22);
  --radius:14px;
}

@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --desk:#12181F; --desk-ink:#C8D2E0; --shadow:0 6px 34px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"]{
  --desk:#12181F; --desk-ink:#C8D2E0; --shadow:0 6px 34px rgba(0,0,0,.6);
}

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

body{
  margin:0;
  background:var(--desk);
  color:var(--body);
  font-family:"Nunito Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  -webkit-text-size-adjust:100%;
}

.ar{font-family:"Noto Naskh Arabic","Amiri",serif; color:var(--teal)}

a{color:var(--teal-2)}
:focus-visible{outline:3px solid var(--gold); outline-offset:2px; border-radius:4px}

/* ---------------------------------------------------- top bar */

.bar{
  position:sticky; top:0; z-index:30;
  display:flex; align-items:center; gap:.9rem; flex-wrap:nowrap;
  padding:.55rem 1rem;
  background:var(--navy);
  border-bottom:2px solid var(--gold);
}
.bar-brand{
  display:flex; align-items:center; gap:.6rem;
  font-family:"Playfair Display",Georgia,serif; font-weight:700;
  color:#FBF6EC; font-size:1rem; letter-spacing:.04em;
  text-decoration:none; flex:0 0 auto;
}
.bar-brand svg{width:auto; height:24px; color:var(--gold-2)}
.bar-topic{
  color:var(--gold-2); font-size:.8rem; font-weight:600;
  border-inline-start:1px solid rgba(255,255,255,.25); padding-inline-start:1rem;
}
.bar-sp{display:none}   /* the tab strip now fills the middle */
.bar-controls{display:flex; align-items:center; gap:.5rem; flex:0 0 auto}
.bar-btn{
  font:inherit; font-size:.76rem; font-weight:700;
  color:var(--navy); background:var(--gold-2);
  border:0; border-radius:999px; padding:.35rem .85rem;
  cursor:pointer; text-decoration:none; display:inline-block;
}
.bar-btn:hover{background:var(--gold-3)}
.bar-btn.ghost{background:transparent; color:#E8EEF6; border:1px solid rgba(255,255,255,.35)}
.bar-btn.ghost:hover{background:rgba(255,255,255,.12)}

.size-ctl{
  display:flex; align-items:center; flex:0 0 auto;
  border:1px solid rgba(255,255,255,.35); border-radius:999px;
  overflow:hidden;
}
.size-ctl button{
  font:inherit; font-size:.72rem; font-weight:700;
  color:#E8EEF6; background:transparent; border:0;
  padding:.32rem .62rem; cursor:pointer; white-space:nowrap;
}
.size-ctl button + button{border-inline-start:1px solid rgba(255,255,255,.22)}
.size-ctl button:hover{background:rgba(255,255,255,.12)}
.size-ctl button[aria-pressed="true"]{background:var(--gold-2); color:var(--navy)}


/* ---------------------------------------------------- page size
   Three settings, chosen in the bar and remembered per reader.
   'fit' sizes the sheet so the whole page is visible without scrolling;
   the subtrahend is the chrome above and below it (bar, strip, hint). */

/* Set on <html> by an inline script in the head, so the sheet is the right
   size on first paint rather than jumping after the page loads. */
:root              {--page-w:min(88vw, 860px)}                          /* large */
:root.size-fit     {--page-w:min(94vw, calc((100dvh - 172px) * 0.7076))}
:root.size-full    {--page-w:min(96vw, 1180px)}

/* ---------------------------------------------------- reader */

.reader{
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  align-items:center; gap:clamp(.4rem,2vw,1.6rem);
 /* padding:clamp(.8rem,2.5vw,2rem) clamp(.5rem,2vw,1.5rem) 1rem;*/
   padding:.6rem 1rem .5rem;
 max-width:1500px; margin:0 auto;
}
/*
.page-wrap{
  position:relative; justify-self:center;
  width:min(100%, calc((100dvh - 196px) * 0.7076));
  aspect-ratio:1241 / 1754;
  background:var(--cream);
  border-radius:6px;
  box-shadow:var(--shadow);
  overflow:hidden;
}


.page-wrap{
  position:relative;
  justify-self:center;
  width:min(94vw, 600px, calc((100dvh - 115px) * 0.7076));
  aspect-ratio:1241 / 1754;
  background:var(--cream);
  border-radius:6px;
  box-shadow:var(--shadow);
  overflow:hidden;
}

.page-wrap img{
  position:absolute; inset:0;
  width:100%; height:100%; display:block; object-fit:contain;
}*/
.page-wrap{
  position:relative; justify-self:center;
  width:var(--page-w);
  aspect-ratio:1241 / 1754;
  container-type:inline-size;
  background:var(--cream);
  border-radius:6px;
  box-shadow:var(--shadow);
  overflow:hidden;
  isolation:isolate;
}
.page-wrap img{
  position:absolute; inset:0;
  width:100%; height:100%; display:block;
  object-fit:fill;
  user-select:none; -webkit-user-drag:none;
}

/* click zones */
.hot{
  position:absolute; display:block;
  border-radius:8px;
  border:2px solid transparent;
  background:transparent;
  transition:background .14s ease, border-color .14s ease, box-shadow .14s ease;
  cursor:pointer;
  text-indent:-9999px; overflow:hidden;
}
.hot:hover,.hot:focus-visible{
  background:rgba(200,150,62,.20);
  border-color:var(--gold);
  box-shadow:0 0 0 3px rgba(200,150,62,.22);
}
.hot.is-page:hover,.hot.is-page:focus-visible{
  background:rgba(11,107,127,.18);
  border-color:var(--teal-2);
  box-shadow:0 0 0 3px rgba(11,107,127,.2);
}
body.show-hot .hot{border-color:rgba(200,150,62,.75); background:rgba(200,150,62,.12)}
body.show-hot .hot.is-page{border-color:rgba(11,107,127,.7); background:rgba(11,107,127,.12)}

/* arrows */
.nav-arrow{
  flex:0 0 auto;
  width:clamp(42px,5vw,60px); height:clamp(42px,5vw,60px);
  border-radius:50%;
  border:2px solid var(--gold);
  background:var(--navy); color:var(--gold-2);
  display:grid; place-items:center; cursor:pointer;
  text-decoration:none;
  transition:transform .12s ease, background .12s ease;
}
.nav-arrow:hover{background:var(--navy-2); transform:scale(1.07)}
.nav-arrow svg{width:45%; height:45%; fill:none; stroke:currentColor; stroke-width:2.4;
  stroke-linecap:round; stroke-linejoin:round}
.nav-arrow[aria-disabled="true"]{opacity:.28; pointer-events:none}

/* page strip */
.strip{
  display:flex; align-items:center; justify-content:center; gap:.5rem;
  flex-wrap:wrap; 
  /*padding:0 1rem 2.5rem;*/
  padding:0 1rem 1rem;
}
.strip-n{
  width:30px; height:30px; border-radius:50%;
  display:grid; place-items:center;
  font-size:.78rem; font-weight:800; text-decoration:none;
  color:var(--desk-ink); border:1.5px solid transparent;
  font-variant-numeric:tabular-nums;
}
.strip-n:hover{border-color:var(--gold)}
.strip-n[aria-current="page"]{background:var(--navy); color:var(--gold-2); border-color:var(--gold)}
.strip-label{
  font-size:.78rem; color:var(--desk-ink); opacity:.75;
  margin-inline-start:.6rem; padding-inline-start:.8rem;
  border-inline-start:1px solid currentColor;
}

.hint{
  text-align:center; font-size:.76rem; color:var(--desk-ink);
  opacity:.7; 
  /* padding:0 1rem .5rem;*/
    padding:0 1rem .25rem;
}
.hint kbd{
  font:inherit; font-size:.72rem; background:rgba(0,0,0,.08);
  border-radius:4px; padding:.05rem .35rem; border:1px solid rgba(0,0,0,.12);
}

@media (max-width:820px){
  .reader{grid-template-columns:1fr; gap:.8rem}
  /* the sheet always fills the width here, so the size control has nothing
     to change and is hidden rather than left inert */
  .size-ctl{display:none}
  .page-wrap{width:100%; order:-1}
  .nav-arrow{position:fixed; bottom:1rem; z-index:25;
    box-shadow:0 4px 14px rgba(0,0,0,.35)}
  .nav-arrow.prev{left:1rem}
  .nav-arrow.next{right:1rem}
  .bar-topic{display:none}
}

/* ============================================================
   Detail pages
   ============================================================ */

.sheet{
  max-width:860px; margin:0 auto; padding:0 1.2rem 4rem;
}
.crumb{
  display:flex; align-items:center; gap:.5rem; flex-wrap:wrap;
  padding:1.2rem 0 .8rem; font-size:.8rem; color:var(--desk-ink);
}
.crumb a{color:inherit; text-decoration:none; border-bottom:1px solid var(--gold)}
.crumb a:hover{color:var(--teal-2)}
.crumb span{opacity:.5}

.entry-head{
  background:var(--navy);
  border-radius:var(--radius) var(--radius) 0 0;
  border-bottom:3px solid var(--gold);
  padding:1.5rem 1.6rem 1.3rem;
  display:flex; align-items:center; gap:1.2rem; flex-wrap:wrap;
}
.entry-head .en{
  margin:0; font-family:"Playfair Display",Georgia,serif;
  font-size:clamp(1.6rem,4vw,2.3rem); color:#FBF6EC; line-height:1.1;
}
.entry-head .ar{
  margin:0; font-family:"Amiri",serif; font-weight:700;
  font-size:clamp(1.8rem,4.5vw,2.6rem); color:var(--gold-2); line-height:1.3;
}
.entry-head .tr{
  flex:1 0 100%; margin:.2rem 0 0;
  font-size:.9rem; letter-spacing:.03em; font-style:italic;
  color:var(--gold-2); opacity:.9;
}

.entry-body{
  background:var(--cream);
  border-radius:0 0 var(--radius) var(--radius);
  box-shadow:var(--shadow);
  padding:1.6rem;
  display:flex; flex-direction:column; gap:1.6rem;
}
.lede{
  margin:0; font-size:1.02rem; color:var(--ink); line-height:1.5;
}
.lede .ar{display:block; font-size:1.15rem; margin-top:.35rem}

.blk{display:flex; flex-direction:column; gap:.7rem}
.blk-h{
  display:flex; align-items:baseline; gap:.6rem; flex-wrap:wrap;
  margin:0; padding-bottom:.4rem; border-bottom:2px solid var(--gold-2);
  font-family:"Playfair Display",Georgia,serif; font-size:1.12rem; color:var(--ink);
}
.blk-h .ar{font-family:"Amiri",serif; font-size:1.25rem}

.tbl-wrap{overflow-x:auto; border:1px solid var(--line); border-radius:10px; background:var(--card)}
table{border-collapse:collapse; width:100%; font-size:.92rem}
th,td{padding:.55rem .8rem; text-align:start; border-bottom:1px solid var(--line)}
thead th{
  background:var(--card-2); color:var(--ink);
  font-size:.72rem; letter-spacing:.08em; text-transform:uppercase;
}
tbody tr:last-child td{border-bottom:0}
tbody tr:nth-child(even){background:var(--card-2)}
td.a{font-family:"Noto Naskh Arabic","Amiri",serif; font-size:1.15rem; color:var(--teal);
  font-weight:500; text-align:right; line-height:1.6}
td.t{white-space:nowrap}
td.t{font-style:italic; color:var(--muted); font-size:.85rem}
td.n{font-variant-numeric:tabular-nums; font-weight:700; color:var(--ink); width:1%; white-space:nowrap}

.pairs{display:grid; gap:.5rem; margin:0; padding:0; list-style:none}
.pairs li{
  display:grid; grid-template-columns:1fr auto; gap:1rem; align-items:baseline;
  padding:.6rem .85rem; background:var(--card); border:1px solid var(--line);
  border-radius:9px;
}
.pairs .e{color:var(--ink); font-weight:600; font-size:.93rem}
.pairs .ar{font-size:1.15rem; text-align:end}

.chips{display:flex; flex-wrap:wrap; gap:.5rem; margin:0; padding:0; list-style:none}
.chips li{
  padding:.4rem .8rem; border-radius:999px;
  background:var(--gold-3); border:1px solid var(--gold-2);
  font-size:.86rem; color:var(--ink);
}
.chips .ar{font-size:1.05rem; margin-inline-start:.5rem;
  padding-inline-start:.5rem; border-inline-start:1px solid var(--gold-2)}

.note{
  display:flex; gap:.9rem; align-items:flex-start;
  padding:.9rem 1.1rem; border-radius:10px;
  background:var(--gold-3); border:1px solid var(--gold-2);
}
.note .k{
  flex:0 0 auto; font-family:"Playfair Display",Georgia,serif;
  font-weight:700; color:var(--navy);
}
.note p{margin:0; font-size:.92rem; color:var(--ink)}
.note .ar{display:block; font-size:1.08rem; margin-top:.3rem}

.stub{
  padding:1.5rem; border:2px dashed var(--gold-2); border-radius:10px;
  background:var(--card); text-align:center;
}
.stub h3{margin:0 0 .4rem; font-family:"Playfair Display",Georgia,serif; color:var(--ink)}
.stub p{margin:0; font-size:.9rem; color:var(--muted)}
.stub code{
  display:inline-block; margin-top:.7rem; font-size:.82rem;
  background:var(--cream); border:1px solid var(--line);
  border-radius:6px; padding:.25rem .6rem; color:var(--ink);
}

.siblings{display:flex; flex-wrap:wrap; gap:.45rem; margin:0; padding:0; list-style:none}
.siblings a{
  display:inline-block; padding:.35rem .7rem; border-radius:999px;
  background:var(--card); border:1px solid var(--line);
  font-size:.83rem; color:var(--ink); text-decoration:none;
}
.siblings a:hover{border-color:var(--gold); background:var(--gold-3)}
.siblings .ar{font-size:1.02rem; margin-inline-start:.5rem;
  padding-inline-start:.5rem; border-inline-start:1px solid var(--line)}
.siblings a[aria-current]{background:var(--navy); color:#FBF6EC; border-color:var(--navy)}
.siblings a[aria-current] .ar{color:var(--gold-2)}

@media print{
  .bar,.nav-arrow,.strip,.hint,.crumb{display:none}
  body{background:#fff}
  .page-wrap{box-shadow:none; width:100%}
  .entry-body{box-shadow:none}
}
@media (prefers-reduced-motion:reduce){
  *{animation:none !important; transition:none !important}
}

/* ---------------------------------------------------- narrow screens */

@media screen and (max-width:560px){
  .bar{gap:.5rem; padding:.5rem .65rem; flex-wrap:wrap}
  .bar-brand{font-size:.82rem; letter-spacing:.02em}
  .bar-brand svg{height:19px}
  .bar-btn{font-size:.68rem; padding:.3rem .6rem; white-space:nowrap}
  .hint{font-size:.72rem; padding-bottom:5rem}
  .strip{padding-bottom:1rem}
  .strip-n{width:26px; height:26px; font-size:.72rem}
  .entry-body{padding:1.1rem}
  .entry-head{padding:1.2rem 1.1rem 1rem; gap:.8rem}
  .pairs li{grid-template-columns:1fr; gap:.2rem}
  .pairs .ar{text-align:start}
  table{font-size:.8rem}
  th,td{padding:.45rem .5rem}
  thead th{font-size:.62rem; letter-spacing:.04em}
  td.a{font-size:1rem}
  td.t{font-size:.75rem; white-space:normal}
  .blk-h{font-size:1rem}
  .lede{font-size:.95rem}
}

/* ---------------------------------------------------- topic tabs */

.topic-tabs{
  display:flex; gap:.3rem; align-items:center; flex-wrap:nowrap;
  flex:1 1 auto; min-width:0;
  padding-inline-start:1rem;
  border-inline-start:1px solid rgba(255,255,255,.25);
  overflow-x:auto;
  scrollbar-width:none;              /* the strip scrolls, quietly */
  scroll-behavior:smooth;
  /* fade the cut edge so it reads as "there is more", not "it is broken" */
  -webkit-mask-image:linear-gradient(to right, #000 calc(100% - 28px), transparent);
          mask-image:linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.topic-tabs::-webkit-scrollbar{display:none}
.topic-tabs.is-end{-webkit-mask-image:none; mask-image:none}
.topic-tabs a{
  display:inline-flex; align-items:baseline; gap:.4rem;
  padding:.28rem .7rem; border-radius:999px;
  font-size:.76rem; font-weight:700; text-decoration:none;
  color:#C8D4E4; border:1px solid transparent; white-space:nowrap;
}
.topic-tabs a:hover{background:rgba(255,255,255,.1); color:#fff}
.topic-tabs a[aria-current]{
  background:var(--gold-2); color:var(--navy); border-color:var(--gold);
}
.tt-n{
  font-family:"Playfair Display",Georgia,serif; font-size:.8rem;
  opacity:.75; font-variant-numeric:tabular-nums;
}
.topic-tabs a[aria-current] .tt-n{opacity:1}

@media screen and (max-width:1300px){
  .topic-tabs{padding-inline-start:.7rem}
  .topic-tabs a{padding:.26rem .6rem; font-size:.73rem}
}
@media screen and (max-width:560px){
  .topic-tabs a{padding:.24rem .5rem; font-size:.7rem}
  .topic-tabs .tt-name{display:none}   /* only here is there truly no room */
}

/* ============================================================
   Page banner — the shared masthead, footer band and page ring
   Overlays the poster artwork's own bands so the brand reads the
   same on every page. Geometry lives in partials/banner.php.
   ============================================================ */

.pg-head,
.pg-foot,
.pg-footmark{
  position:absolute; left:0; right:0;
  pointer-events:none;              /* never swallow a hotspot click */
}
.pg-head{top:0; z-index:1}

/* the band: bottom-anchored, its top edge set per page */
.pg-foot{
  bottom:0; z-index:1;
  background:var(--navy);
  border:0.24cqw solid var(--gold-2);
  border-bottom:0;
  border-radius:1.2cqw 1.2cqw 0 0;
}

/* the ring and its ornaments: fixed size, centred on a fixed line, so the
   part a reader actually looks at is identical on every page */
.pg-footmark{
  z-index:2;
  transform:translateY(-50%);
  line-height:0;
}
.pg-mark{width:100%; height:auto; display:block; overflow:visible}
.pg-mark .pg-num{
  font-family:"Playfair Display",Georgia,serif;
  font-weight:700; font-size:48px;
  fill:#FBF6EC;
  font-variant-numeric:tabular-nums;
}

.pg-head-shape{
  position:absolute; inset:0;
  width:100%; height:100%; display:block;
}

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

.pg-lockup{
  position:absolute; left:3.4cqw; top:0; height:72%;
  display:flex; align-items:center; gap:2.3cqw;
}
.pg-key{
  height:74%; width:auto; display:block;
  color:var(--gold-2);
}
.pg-word{
  display:flex; flex-direction:column; justify-content:center;
  font-family:"Playfair Display",Georgia,serif;
  font-weight:700;
  font-size:2.55cqw; line-height:1.16;
  letter-spacing:.09em;
  color:#FBF6EC;
  white-space:nowrap;
}
.pg-word span:last-child{letter-spacing:.17em}
