/* ------------------------------------------------------------------
   Illuminated-manuscript palette: lapis ground, bone text, gold leaf.
   Verdigris for quiet actions, rubric red only for removal.
   ------------------------------------------------------------------ */

@font-face {
  font-family: "Amiri Quran";
  src: url("fonts/amiri-quran.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --ink: #0a1322;
  --ink-deep: #060d18;
  --leaf: #101d33;
  --leaf-raised: #16273f;
  --vellum: #ece3d2;
  --vellum-dim: #a3a595;
  --gold: #cfa54a;
  --gold-bright: #e8c877;
  --gold-dim: #705a2c;
  --verdigris: #5b9d8c;
  --rubric: #c4614a;
  --rule: rgba(207, 165, 74, 0.24);

  /* The site is Arabic throughout — mushaf and chrome are set in one face. */
  --quran: "Amiri Quran", "Amiri", "Traditional Arabic", serif;

  /* An installed app is served viewport-fit=cover, so the page is drawn under
     the clock and the battery rather than below them. These name that strip so
     the chrome can be held clear of it — and so a test, which has no notch to
     read, can set one and see the layout answer. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Turned on its side, the same cutout eats into one margin; the gutter is
     every page's horizontal padding, so widening it here covers all of them. */
  --gutter: max(clamp(1.25rem, 4vw, 3rem), var(--safe-left), var(--safe-right));
  --radius: 3px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--vellum);
  font-family: var(--quran);
  font-size: 17px;
  /* Amiri's marks sit high and its descenders run deep; ordinary prose needs
     more room between lines than a Latin face would. */
  line-height: 1.9;
  /* A faint gold vignette, as if the page were lit from above. */
  background-image:
    radial-gradient(120% 70% at 50% -10%, rgba(207, 165, 74, 0.10), transparent 60%);
  background-attachment: fixed;
}

/* Nothing is laid out in the status bar's strip, but a sticky bar pinned below
   it would still let the mushaf scroll through the gap above. This fills it. */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-top);
  background: var(--ink);
  /* Over the settings page's control bar (20) and its pool sheet (30). */
  z-index: 40;
  pointer-events: none;
}

a { color: var(--gold); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--gold-bright); }

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

/* Quiet labels. Arabic has no case to play with, so they step back by size
   and colour instead. */
.label {
  font-size: 0.9rem;
  color: var(--vellum-dim);
}

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

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(clamp(1rem, 3vw, 2rem) + var(--safe-top)) var(--gutter) 0;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}
.wordmark .ar {
  font-size: 1.5rem;
  color: var(--gold);
  line-height: 1;
}
.masthead nav { display: flex; gap: 1.25rem; align-items: baseline; }

@media (max-width: 640px) {
  .masthead { padding-top: calc(0.85rem + var(--safe-top)); }
  .wordmark .ar { font-size: 1.25rem; }
  .masthead nav { font-size: 0.92rem; }
}

/* ---------------------------------------------- buttons */

button, .btn {
  font-family: var(--quran);
  touch-action: manipulation;
  font-size: 1rem;
  color: var(--vellum);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
button:hover, .btn:hover {
  border-color: var(--gold);
  background: rgba(207, 165, 74, 0.08);
  color: var(--vellum);
}
button:disabled { opacity: 0.4; cursor: default; }
button:disabled:hover { border-color: var(--rule); background: transparent; }

/* No tracking on any of these: Arabic letters join, and spacing them out
   pulls the joins apart. */
.btn-gold {
  border-color: var(--gold);
  color: var(--gold-bright);
  padding: 0.7rem 2rem;
}
.btn-gold:hover { background: rgba(207, 165, 74, 0.16); color: var(--gold-bright); }

.btn-quiet {
  border-color: transparent;
  color: var(--vellum-dim);
  padding: 0.3rem 0.5rem;
  font-size: 0.9rem;
}
.btn-quiet:hover { color: var(--vellum); background: rgba(236, 227, 210, 0.06); }

/* ---------------------------------------------- mushaf text */

.ayah-flow {
  font-family: var(--quran);
  direction: rtl;
  text-align: justify;
  line-height: 2.45;
  color: var(--vellum);
}

.ayah-mark {
  color: var(--gold);
  font-size: 0.95em;
  padding: 0 0.12em;
  white-space: nowrap;
}

/* Applied by fadeWhenScrollable(): a soft bottom edge that says "more below",
   present only while there is in fact more below. */
.fade-end {
  mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
