/* ============================================================
   مثال — misal · fifteen poems
   Home palette derived from mnihal22.org:
   navy 212 44% 14% · gold 38 60% 65% · cream 36 85% 84%
   ============================================================ */

:root {
  --navy: hsl(212 44% 12%);
  --navy-2: hsl(213 40% 9%);
  --gold: hsl(38 60% 65%);
  --gold-deep: hsl(38 62% 42%);
  --cream: hsl(36 85% 84%);
  --parchment: hsl(40 35% 94%);
  --muted: hsl(214 22% 72%);
  --hairline: hsl(212 30% 27%);
  --serif-display: "Marcellus", "Amiri", serif;
  --serif-body: "Cormorant Garamond", "Amiri", serif;
  --ar-nastaliq: "Noto Nastaliq Urdu", "Amiri", serif;
  --ar-gulzar: "Gulzar", "Noto Nastaliq Urdu", serif;
  --ar-ruqaa: "Aref Ruqaa", "Amiri", serif;
  --ar-kufi: "Reem Kufi", "Amiri", sans-serif;
  --ar-amiri: "Amiri", serif;
  --ar-scheherazade: "Scheherazade New", "Amiri", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  background: var(--navy);
  color: var(--parchment);
  font-family: var(--serif-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* manuscript grain + vignette */
#grain {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
#grain::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.42) 100%);
}

a { color: inherit; text-decoration: none; }
::selection { background: hsl(38 60% 65% / .3); }

/* ======================= HOME ======================= */

.home { position: relative; min-height: 100vh; }

/* calligraphy bleeding through the home page */
.calli-field { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.calli {
  position: absolute; white-space: nowrap; line-height: 1;
  color: var(--gold); user-select: none;
}
.calli.outline {
  color: transparent;
  -webkit-text-stroke: 1px hsl(38 60% 65% / .22);
}
.calli.drift { animation: drift 26s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translate(var(--dx0, 0), var(--dy0, 0)) rotate(var(--rot, 0deg)); }
  to   { transform: translate(var(--dx1, 12px), var(--dy1, -10px)) rotate(var(--rot, 0deg)); }
}

.home-inner { position: relative; z-index: 2; max-width: 880px; margin: 0 auto; padding: 7vh 28px 14vh; }

/* وما توفيقي إلا بالله — above everything, even the name */
.tawfiq {
  display: flex; align-items: center; justify-content: center; gap: 26px;
  margin-bottom: 5vh;
}
.tawfiq::before, .tawfiq::after {
  content: ""; width: 90px; height: 1px;
  background: linear-gradient(90deg, transparent, hsl(38 60% 65% / .55));
}
.tawfiq::after { transform: scaleX(-1); }
.tawfiq .ar {
  font-family: var(--ar-amiri);
  font-size: clamp(19px, 2.6vw, 24px);
  color: var(--gold); letter-spacing: .02em; white-space: nowrap;
}

.colophon {
  font-family: var(--serif-display);
  font-size: 12px; letter-spacing: .42em; text-transform: uppercase;
  color: var(--gold); opacity: .85; text-align: center;
  margin-top: 4.5vh;
}
.colophon .ar { font-family: var(--ar-kufi); letter-spacing: .2em; }

.brand { text-align: center; margin: 0; }
.brand .ar-main {
  font-family: var(--ar-nastaliq);
  font-size: clamp(88px, 17vw, 190px);
  line-height: 1.35;
  color: var(--gold);
  text-shadow: 0 0 60px hsl(38 60% 65% / .25);
  display: block;
}
.brand .latin {
  font-family: var(--serif-display);
  font-size: clamp(19px, 2.7vw, 26px);
  letter-spacing: .85em; text-indent: .85em;
  color: var(--cream);
  margin-top: .45em; display: block;
}
.brand-rule {
  width: 220px; height: 1px; margin: 4.5vh auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  position: relative;
}
.brand-rule::after {
  content: "•"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: var(--gold); font-size: 12px; background: var(--navy); padding: 0 12px;
}
.tagline {
  text-align: center; font-style: italic;
  font-size: clamp(17px, 2.4vw, 21px);
  color: var(--muted); margin-top: 3.2vh; letter-spacing: .04em;
}
.tagline .ar { font-family: var(--ar-amiri); font-style: normal; color: var(--gold); opacity: .8; }

.toc-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 9vh 0 0; padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline);
}
.toc-head h2 {
  font-family: var(--serif-display); font-weight: 400;
  font-size: 13px; letter-spacing: .38em; text-transform: uppercase; color: var(--cream);
}
.toc-head span { font-family: var(--ar-ruqaa); color: var(--gold); font-size: 15px; }

.toc { list-style: none; }
.toc li a {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: baseline; gap: 18px;
  padding: 26px 6px 24px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
  transition: padding-left .45s cubic-bezier(.22,1,.36,1), background .45s;
}
.toc li a::before {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 0;
  background: var(--gold); transition: width .55s cubic-bezier(.22,1,.36,1);
}
.toc li a:hover { padding-left: 18px; background: linear-gradient(90deg, hsl(38 60% 65% / .05), transparent 60%); }
.toc li a:hover::before { width: 100%; }
.toc .num {
  font-family: var(--serif-display); font-size: 13px; color: var(--gold);
  letter-spacing: .08em; opacity: .9;
}
.toc .name { font-family: var(--serif-display); font-size: clamp(20px, 3vw, 27px); color: var(--parchment); }
.toc .gist {
  grid-column: 2; font-style: italic; color: var(--muted);
  font-size: 16.5px; margin-top: 6px; line-height: 1.45;
}
.toc .swatch {
  grid-row: 1 / span 2; grid-column: 3; align-self: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid hsl(0 0% 100% / .18);
  box-shadow: inset 0 0 12px rgba(0,0,0,.35);
}

.home-foot {
  text-align: center; margin-top: 12vh;
  color: var(--muted); font-style: italic; font-size: 15px; line-height: 2.1;
}
.home-foot .ar {
  display: block; font-family: var(--ar-ruqaa); font-style: normal;
  font-size: 38px; color: var(--gold); opacity: .9; margin-top: 12px;
}

/* ======================= POEM PAGE ======================= */

.poem-page {
  position: relative; min-height: 100vh;
  overflow-x: clip;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--bg2) 0%, var(--bg) 62%);
  color: var(--ink);
  transition: background .6s;
}
.poem-calli {
  position: absolute; z-index: 0; pointer-events: none; user-select: none;
  color: var(--accent); opacity: var(--calli-op, .07);
  line-height: 1.2; white-space: nowrap;
}
.poem-calli.o2 { opacity: calc(var(--calli-op, .07) * .6); }

.poem-top {
  position: relative; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1060px; margin: 0 auto; padding: 34px 28px 0;
}
.backlink {
  font-family: var(--serif-display); font-size: 12px;
  letter-spacing: .3em; text-transform: uppercase;
  color: var(--accent); opacity: .85;
  border-bottom: 1px solid transparent; padding-bottom: 4px;
  transition: border-color .3s, opacity .3s;
}
.backlink:hover { border-color: var(--accent); opacity: 1; }
.poem-top .ar-mark { font-family: var(--ar-nastaliq); font-size: 26px; color: var(--accent); opacity: .7; }

.poem-head { position: relative; z-index: 2; text-align: center; padding: 7vh 24px 0; }
.poem-num {
  font-family: var(--serif-display); font-size: 12px;
  letter-spacing: .5em; text-transform: uppercase; color: var(--accent);
}
.poem-title {
  font-family: var(--serif-display); font-weight: 400;
  font-size: clamp(34px, 6vw, 62px);
  margin-top: 18px; letter-spacing: .02em;
}
.poem-sub {
  font-style: italic; color: var(--accent);
  opacity: .85; font-size: 17px; margin-top: 14px;
}
.head-rule {
  width: 150px; height: 1px; margin: 4vh auto 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  position: relative;
}
.head-rule::after {
  content: "•"; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent); font-size: 11px; padding: 0 10px;
  background: var(--bg);
}

.artwork {
  position: relative; z-index: 2;
  max-width: 620px; margin: 6vh auto 0; padding: 0 24px;
}
.artwork svg { width: 100%; height: auto; display: block; }

.poem-body {
  position: relative; z-index: 2;
  max-width: 660px; margin: 7vh auto 0; padding: 0 26px 4vh;
  font-size: var(--poem-size, 21px);
  line-height: 1.75;
}

/* every poem signed by its author */
.signature {
  position: relative; z-index: 2; text-align: center;
  margin: 0 auto 9vh; font-style: italic;
  color: var(--accent); opacity: .85; font-size: 18px;
}
.signature .ar { font-style: normal; font-size: 22px; opacity: .9; }
.poem-body.center { text-align: center; }
.poem-body p { margin: 0 0 2.1em; }
.poem-body p:last-child { margin-bottom: 0; }
.poem-body .ln { display: block; white-space: nowrap; }
.poem-body .orn {
  text-align: center; color: var(--accent);
  letter-spacing: 1.2em; text-indent: 1.2em;
  font-size: .8em; margin: 3em 0;
}
.poem-body .chapter {
  display: flex; align-items: center; gap: 18px;
  margin: 4.5em 0; color: var(--accent);
}
.poem-body .chapter::before, .poem-body .chapter::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.poem-body .chapter span {
  font-family: var(--serif-display); font-size: 11px;
  letter-spacing: .45em; text-transform: uppercase;
}
.poem-body .coda { font-style: italic; color: var(--accent); }
/* faint banknote guilloché behind everything */
.guilloche {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  color: var(--accent); opacity: .07;
}
.guilloche svg { width: 100%; height: 100%; display: block; }

.poem-body.gradtext {
  background: var(--text-grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.poem-body p.serene { color: var(--accent2); }
.poem-body p.shaded { color: var(--ink2); }

.poem-foot {
  position: relative; z-index: 2;
  max-width: 1060px; margin: 0 auto; padding: 0 28px 8vh;
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding-top: 30px;
}
.poem-foot a {
  font-family: var(--serif-display); font-size: 12px;
  letter-spacing: .25em; text-transform: uppercase;
  color: var(--accent); opacity: .8; transition: opacity .3s;
}
.poem-foot a:hover { opacity: 1; }
.poem-foot .ar-mark { font-family: var(--ar-nastaliq); font-size: 22px; color: var(--accent); opacity: .6; }

/* page fade */
.view { animation: viewIn .55s ease-out both; }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 640px) {
  .toc li a { grid-template-columns: 34px 1fr auto; gap: 12px; }
  .toc .swatch { width: 26px; height: 26px; }
  .poem-body { --poem-size: 19px; }
  .brand .latin { margin-top: 1em; }
  .poem-top { padding: 24px 20px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .calli.drift, .view { animation: none; }
  html { scroll-behavior: auto; }
}
