/* v6 · Impeccable + Taste · Modern editorial — the diwan opened on the web */

html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; line-height: 1.35; }
::selection { background: #6b1f2a; color: #fbf8f2; }
html { scrollbar-color: var(--rule) var(--bg); }
body { background: var(--bg); }
.nav__logo { font-weight: 700; letter-spacing: 0; } /* Amiri Bold is the brand's cut; Arabic takes no negative tracking */

/* ——— the cover (hero): bookcloth, gold blind-stamping, the binding edge ——— */
.cover { position: relative; isolation: isolate; overflow: hidden; color: #fbf8f2; background: #4a121c; }
.cover__cloth { position: absolute; inset: 0; z-index: -1; overflow: hidden;
  background:
    url("brand/pattern/star-tile.svg") 0 0 / 57px 99px repeat,
    radial-gradient(80% 70% at 30% 35%, #7b2f34 0%, transparent 70%),
    linear-gradient(160deg, #6b1f2a, #4a121c 60%, #3d0f16);
}
.cover__cloth::before { /* tame the lattice to a blind stamp */
  content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, #6b1f2a, #4a121c 60%, #3d0f16); opacity: .9; mix-blend-mode: multiply;
}
/* the poster's free-hand letters, each one set loose on the cloth: placed in % of the cover so every screen
   keeps them, sized by --u (0.85px a unit on a phone, 1.5px on a wide screen), stroked 1.15px at any size */
.cover__letters { position: absolute; inset: 0; pointer-events: none; color: #ba9242; --u: clamp(.85px, .6px + .065vw, 1.5px);
  --amp: 1.9; --turn: 1.6; --pace: .5; } /* travel x1.9, tilt x1.6, loops twice as quick as the per-letter values */
.ltr { position: absolute; left: var(--x); top: var(--y); width: calc(var(--w) * var(--u)); height: calc(var(--h) * var(--u));
  overflow: visible; opacity: var(--o, .3); rotate: var(--r0, 0deg);
  fill: none; stroke: currentColor; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; } /* the sprite's paths inherit their ink from here */
@keyframes ltr-sway { to { translate: calc(var(--dx, 10px) * var(--amp, 1)) 0; } }
@keyframes ltr-lift { to { transform: translateY(calc(var(--dy, -12px) * var(--amp, 1))) rotate(calc(var(--rot, 3deg) * var(--turn, 1))); } }
@media (prefers-reduced-motion: no-preference) {
  html:not([data-motion="off"]) .ltr {
    animation: ltr-sway calc(var(--tx, 13s) * var(--pace, 1)) ease-in-out var(--d, 0s) infinite alternate, ltr-lift calc(var(--ty, 11s) * var(--pace, 1)) ease-in-out var(--d, 0s) infinite alternate;
  }
  .cover.is-away .ltr { animation-play-state: paused; }
}
.cover::after { /* the spine: a double gold rule at the binding edge */
  content: ""; position: absolute; inset-block: 0; inset-inline-end: 14px; width: 7px;
  border-inline: 1px solid rgb(186 146 66 / .75); pointer-events: none;
}
main > .hero.cover { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 1fr; height: auto; min-height: 100vh; min-height: 100svh; }
.hero.cover > .wrap.cover__wrap {
  display: grid; flex-direction: initial;
  min-height: 0; height: auto; padding-block: 0 24px;
  padding-inline-end: 22px; /* clear the gold spine at the binding edge */
  display: grid; align-content: center; gap: 28px;
  grid-template-columns: 1fr; position: relative;
}
.cover__art { display: grid; justify-items: start; align-content: start; gap: 14px; }
.cover__seal { width: 72px; height: 72px; border-radius: 50%; box-shadow: 0 0 0 2px #ba9242, 0 10px 24px rgb(0 0 0 / .4); }
.cover__title { width: min(100%, 560px); height: auto; display: block; }
.cover__edition { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: #f3ecdd; }
.cover__figure { position: relative; min-height: 0; } /* holds the poet without adding its height to the cover */
.cover__poet { display: block; filter: drop-shadow(0 12px 18px rgb(0 0 0 / .4)); }
.cover__text { display: grid; gap: 16px; justify-items: start; align-content: start; padding-top: 22px; border-top: 1px solid rgb(186 146 66 / .55); }
.cover__text h1 { margin: 0; font-size: clamp(30px, 4.2vw, 52px); color: #fbf8f2; text-wrap: balance; }
.cover__lead { margin: 0; color: #ead9b8; font-size: 1.0625rem; max-width: 46ch; }
.cover .btn--primary { background: #e2c27a; color: #3d0f16; }
html:not([data-motion="off"]) .cover .btn.btn--primary:hover { background: #ecd196; color: #3d0f16; }

/* ——— rhythm: after the cover, a section is as tall as what it holds, not a full screen ———
   --sec is the one section interval (40 on a phone, 72 on a wide screen); two neighbours on the same
   paper add up to one clear gap, and the footer keeps room for the phone's action bar. */
:root { --sec: clamp(40px, 5.2vw, 72px); --head-gap: clamp(20px, 2.6vw, 32px); }
main > .section:not(.hero), footer.closing { height: auto; min-height: 0; padding-block: var(--sec); }
main > .section.leaf { padding-top: calc(var(--sec) + 8px); }
main > .section { scroll-margin-top: var(--nav); } /* a jump to a section lands under the fixed header, not behind it */
main > .section.statement { padding-block: calc(var(--sec) + 8px); }
footer.closing { padding-bottom: calc(28px + env(safe-area-inset-bottom)); } /* the phone action bar hides itself at the close */
footer.closing > .wrap { row-gap: clamp(28px, 4vw, 44px); }
footer.closing .closing__cta { gap: 24px; }

/* ——— the leaf: where the verse is written ——— */
.leaf { position: relative; background: var(--bg); }
.leaf::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: url("brand/pattern/star-tile.svg") 0 0 / 57px 99px repeat; opacity: .13; }
.leaf > .wrap { position: relative; }
.leaf__head { font-family: "Aref Ruqaa", var(--font-display); color: #5d1d24; }
.bayt { margin-top: 8px; display: grid; gap: 6px; }
.hemi { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.hemi label { grid-row: 1; grid-column: 1; }
.hemi input { grid-row: 2; grid-column: 1; }
.hemi .err { grid-row: 3; grid-column: 1; }
.hemi::after { /* the ink line that draws under the field you are writing in */
  content: ""; grid-row: 2; grid-column: 1; align-self: end; height: 2.5px; background: #6b1f2a; pointer-events: none;
  transform: scaleX(0); transform-origin: 100% 50%; transition: transform .45s var(--ease-out);
}
.hemi:focus-within::after { transform: scaleX(1); }
.hemi[data-invalid]::after { background: #a3261b; transform: scaleX(1); }
.hemi label { font-weight: 800; font-size: 14px; color: var(--gold-ink); }
.hemi input {
  width: 100%; font-family: var(--font-display); font-weight: 700; font-size: 1.66rem; line-height: 1.5; color: var(--ink);
  background: transparent; border: 0; border-radius: 0; border-bottom: 1.5px solid var(--rule);
  padding: 6px 2px 8px; min-height: 56px; caret-color: #6b1f2a;
  transition: border-color .2s;
}
.hemi input:hover { border-bottom-color: #6b1f2a; }
.hemi input:focus { outline: 2px solid transparent; }
.hemi input:focus-visible { outline: 2px solid #6b1f2a; outline-offset: 4px; }
.hemi input::placeholder { color: rgb(93 29 36 / .7); font-family: var(--font-text); font-weight: 400; font-size: 1.25rem; letter-spacing: 0; } /* an example, in the label face so it never reads as a written name; 4.8:1 on the leaf paper */
.hemi input[dir="ltr"] { font-family: var(--font-text); font-size: 1.33rem; letter-spacing: .06em; text-align: right; font-variant-numeric: tabular-nums; }
.hemi input:-webkit-autofill { -webkit-text-fill-color: var(--ink); -webkit-box-shadow: 0 0 0 40px var(--bg) inset; }
.hemi[data-invalid] input { border-bottom-color: #a3261b; }
.err { margin: 0; font-weight: 700; font-size: 14px; color: #a3261b; }
.err:empty { display: none; }
.sep { display: grid; place-items: center; height: 34px; color: var(--rule); }
.sep svg { width: 26px; height: 26px; }
.leaf form .btn-row { margin-top: 28px; }
.leaf .btn { height: 52px; }
.noscript { margin: 16px 0 0; font-weight: 700; color: #a3261b; }

/* the written verse and its plate */

.verse { margin: 18px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.66rem, 3.4vw, 2.6rem); line-height: 1.4; color: var(--ink); }
.verse svg { width: 20px; height: 20px; color: var(--rule); flex: none; }
.verse__num { font-family: var(--font-text); font-size: .7em; direction: ltr; letter-spacing: .06em; font-variant-numeric: tabular-nums; color: #5d1d24; }
.leaf__side { display: grid; place-items: center; }
.plate { margin-top: 24px; width: min(100%, 300px); aspect-ratio: 1; background: #fbf8f2; padding: 12px;
  box-shadow: 0 0 0 1px var(--rule), 0 0 0 6px var(--bg), 0 0 0 7px rgb(184 149 79 / .7), 0 18px 30px -16px rgb(61 15 22 / .55); }
.plate canvas { width: 100%; height: 100%; display: block; }
/* the plate holds only the issued QR: until then its column is closed and the form takes the whole leaf */
.leaf__side:has(> .plate:empty) { display: none; }
.leaf__grid:has(.plate:empty) > .leaf__text { grid-column: 1 / -1; }
.plate__note { margin: 16px 0 0; }
.verse-view .btn-row { margin-top: 18px; }
.verse-view:focus { outline: none; } /* focused by script so a screen reader lands on the pass; it is not a control, so no ring */
.again { margin-top: 10px; background: none; border: 0; font: inherit; font-weight: 700; color: #5d1d24; padding: 10px 0; min-height: 44px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--rule); }
@keyframes leaf-turn { from { opacity: 0; transform: perspective(1400px) rotateY(-24deg) translateX(-5%); transform-origin: 100% 50%; } to { opacity: 1; transform: none; transform-origin: 100% 50%; } }
@keyframes ink-in { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
.verse-view.is-new { animation: leaf-turn .8s var(--ease-out) both; }
.verse-view.is-new .verse { animation: ink-in 1.1s .25s var(--ease-out) both; }

/* the statement */
.statement .mo-wh__text { font-size: clamp(30px, 3.3vw, 50px); line-height: 1.8; max-width: 22em; }
.statement .t-label { margin: 0 0 20px; color: var(--gold-ink); }

/* the index (fihris): what ........ where */
.toc { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 4px 20px; padding: 14px 0; border-top: 1px solid rgb(61 15 22 / .13); }
.toc li:last-child { border-bottom: 1px solid rgb(61 15 22 / .13); }
.toc__day { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: #5d1d24; grid-row: span 2; }
.toc__what { font-weight: 700; font-size: 1.0625rem; display: flex; align-items: baseline; gap: 10px; }
.toc__what::after { content: ""; flex: 1; border-bottom: 2px dotted rgb(184 149 79 / .7); transform: translateY(-4px); }
.toc__where { color: var(--muted); }

.closing .partners { display: flex; gap: 12px; flex-wrap: wrap; list-style: none; margin: 0 0 24px; padding: 0; }
.closing .partners li { margin: 0; }
.closing .partners img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 50%; padding: 3px; box-shadow: 0 0 0 1px rgb(61 15 22 / .14); }
[hidden] { display: none !important; }
body > .actionbar.is-idle { transform: translateY(100%); visibility: hidden; transition: transform 240ms var(--ease-out), visibility 0s 240ms; }

@media (prefers-reduced-motion: reduce) {
  .verse-view.is-new, .verse-view.is-new .verse { animation: none; }
  .hemi::after { transition: none; }
}

/* phone and tablet: the title, then the poet standing on the gold rule at the binding edge, then the words */
@media (max-width: 959.98px) {
  .hero.cover > .wrap.cover__wrap { grid-template-rows: auto minmax(132px, 1fr) auto; align-content: stretch; gap: 0; }
  .cover__art { padding-bottom: 12px; }
  .cover__figure { grid-row: 2; }
  .cover__poet { position: absolute; bottom: 0; left: 0; height: 100%; max-height: 460px; width: auto; max-width: 70%; object-fit: contain; object-position: left bottom; }
  .cover__text { grid-row: 3; }
}
/* a phone held sideways: no room for the figure above the words, so it stands beside them */
@media (max-width: 959.98px) and (max-height: 520px) {
  .hero.cover > .wrap.cover__wrap { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 24px; row-gap: 20px; align-content: center; }
  .cover__art { grid-column: 1; grid-row: 1; padding-bottom: 0; }
  .cover__text { grid-column: 1; grid-row: 2; }
  .cover__figure { grid-column: 2; grid-row: 1 / span 2; align-self: end; }
  .cover__poet { position: static; height: auto; width: auto; max-width: none; max-height: min(78svh, 340px); }
}

/* desktop: an open spread, the cover's poet at the binding edge, the verse across the leaf */
@media (min-width: 960px) {
  .hero.cover > .wrap.cover__wrap { grid-template-columns: minmax(0, 700px); justify-content: start; align-content: center; gap: 24px; }
  .cover__title { width: min(100%, 470px); }
  .cover__seal { width: 60px; height: 60px; }
  .cover__art { gap: 10px; }
  .cover__text { padding-top: 18px; gap: 12px; max-width: 640px; }
  .cover__text h1 { font-size: clamp(30px, 3.2vw, 46px); }
  .cover__figure { display: contents; }
  .cover__poet { position: absolute; left: 4%; bottom: 0; width: clamp(240px, 22vw, 330px); height: auto; filter: drop-shadow(0 24px 34px rgb(0 0 0 / .45)); }
  .bayt { grid-template-columns: 1fr auto 1fr; align-items: start; gap: 0 22px; }
  .sep { height: auto; padding-top: 38px; }
  .leaf form .btn-row .btn { min-width: 300px; }
  .leaf__side { align-self: stretch; }
  .leaf .plate { width: min(100%, 360px); margin-top: 0; }
  .toc li { grid-template-columns: 10rem 1fr 1fr; align-items: baseline; }
  .toc__day { grid-row: auto; }
}
@media (min-width: 640px) and (max-width: 1023px) {
  html[dir="rtl"] .nav.nav--split .nav__bar > .nav__actions { margin-left: 0; margin-right: auto; }
}
