@font-face {
  font-family: "Scheherazade New";
  src: url("assets/fonts/ScheherazadeNew-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ivory: #f5efdf;
  --paper: #fffaf0;
  --olive: #263c31;
  --olive-soft: #52685a;
  --gold: #9b7a3d;
  --gold-pale: #d9c9a6;
  --rule: #ded2b8;
  --quran-size: 36px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ivory);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.72), transparent 26rem),
    var(--ivory);
  color: var(--olive);
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.6;
}

button {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
.quran-text:focus-visible {
  outline: 3px solid #b5842d;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  z-index: 20;
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--olive);
  color: #fff;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(100%, 48rem);
  margin-inline: auto;
  padding: calc(1.25rem + env(safe-area-inset-top, 0px)) 1rem calc(2.5rem + var(--safe-bottom));
}

.site-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  background: rgba(255, 250, 240, 0.76);
}

.site-navigation a {
  display: grid;
  min-height: 3rem;
  place-items: center;
  padding: 0.55rem 0.7rem;
  border-radius: 0.65rem;
  color: var(--olive);
  font-size: 0.94rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.site-navigation a.is-current {
  background: #eee3ca;
  box-shadow: inset 0 0 0 1px var(--gold-pale);
  color: var(--olive);
}

.masthead {
  padding: 1.4rem 0 1.9rem;
  text-align: center;
}

.identity,
.eyebrow,
.surah-meta,
.memorial-dedication,
.masthead h1 {
  margin: 0;
}

.identity {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.ornament {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: min(13rem, 58vw);
  margin: 0.7rem auto 1rem;
  color: var(--gold);
}

.ornament::before,
.ornament::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--gold-pale);
}

.ornament span {
  font-size: 0.7rem;
  transform: rotate(45deg);
}

.eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.masthead h1 {
  margin-top: 0.2rem;
  font-family: "Scheherazade New", serif;
  font-size: clamp(2.4rem, 11vw, 4rem);
  font-weight: 400;
  line-height: 1.25;
}

.surah-meta {
  margin-top: 0.3rem;
  color: var(--olive-soft);
  font-size: 1rem;
}

.memorial-dedication {
  margin-top: 0.85rem;
  color: var(--olive-soft);
  font-size: 0.88rem;
  line-height: 1.7;
}

.surah-browser,
.reader-controls {
  position: relative;
  z-index: 2;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 1rem;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 0.45rem 1.4rem rgba(38, 60, 49, 0.07);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.08rem;
}

.section-kicker {
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.06em;
}

.surah-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.surah-option {
  display: grid;
  min-width: 0;
  min-height: 4.25rem;
  grid-template-columns: 2rem 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 0.75rem;
  background: #fbf6e9;
  color: var(--olive);
  text-align: start;
  cursor: pointer;
}

.surah-option.is-selected {
  border-color: var(--gold);
  background: #f2e8d1;
  box-shadow: inset 0 0 0 1px var(--gold);
}

.surah-order {
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  grid-row: 1 / 3;
  place-items: center;
  border: 1px solid var(--gold-pale);
  border-radius: 50%;
  color: var(--gold);
  font-size: 0.7rem;
  line-height: 1;
}

.surah-label {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.surah-count {
  color: var(--olive-soft);
  font-size: 0.69rem;
  line-height: 1.3;
}

.reader-controls {
  margin-top: 0.75rem;
}

.controls-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.controls-heading h2,
.controls-heading p {
  margin: 0;
}

.controls-heading h2 {
  font-size: 1.06rem;
  line-height: 1.45;
}

.controls-heading p {
  margin-top: 0.1rem;
  color: var(--olive-soft);
  font-size: 0.82rem;
}

.size-control {
  display: grid;
  grid-template-columns: 3.1rem 2.6rem 3.1rem;
  align-items: center;
  flex: none;
  direction: ltr;
  border: 1px solid var(--gold-pale);
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--paper);
}

.size-control button {
  min-width: 3.1rem;
  min-height: 3.1rem;
  border: 0;
  background: transparent;
  color: var(--olive);
  font-size: 1rem;
  font-weight: 750;
  cursor: pointer;
}

.size-control button:not(:disabled):active {
  background: #eee3ca;
}

.size-control button:disabled {
  color: #9a9a8e;
  cursor: not-allowed;
}

.size-control output {
  display: grid;
  min-height: 3.1rem;
  place-items: center;
  border-inline: 1px solid var(--gold-pale);
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 700;
}

.quran-card {
  margin-top: 1rem;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1.25rem, 5vw, 2.75rem);
  border: 1px solid var(--rule);
  border-radius: 1.25rem;
  background: rgba(255, 250, 240, 0.76);
  box-shadow: 0 0.5rem 2rem rgba(38, 60, 49, 0.055);
}

.quran-text,
.basmala {
  color: var(--olive);
  font-family: "Scheherazade New", serif;
  font-size: var(--quran-size);
  font-weight: 400;
  line-height: 2.25;
  text-align: justify;
  text-align-last: center;
  text-justify: inter-word;
  direction: rtl;
  max-width: 40rem;
  margin-inline: auto;
  overflow-wrap: normal;
  word-break: normal;
  word-spacing: normal;
  letter-spacing: normal;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  font-synthesis: none;
}

.basmala {
  margin: 0 0 0.7em;
  text-align: center;
}

.load-status {
  margin: 0;
  padding: 2rem 0;
  color: var(--olive-soft);
  font-size: 1rem;
  text-align: center;
}

.ayah {
  display: inline;
}

.ayah-marker {
  display: inline-grid;
  width: 1.72em;
  height: 1.72em;
  margin-inline: 0.18em 0.1em;
  place-items: center;
  transform: translateY(-0.03em);
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-family: "Scheherazade New", serif;
  font-size: 0.42em;
  line-height: 1;
  vertical-align: middle;
  white-space: nowrap;
  break-inside: avoid;
}

.review-note {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 1rem;
  border-inline-start: 3px solid var(--gold);
  border-radius: 0.25rem 0.75rem 0.75rem 0.25rem;
  background: rgba(228, 215, 184, 0.42);
}

.review-note p {
  margin: 0;
  color: var(--olive-soft);
  font-size: 0.92rem;
}

.review-icon {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  flex: none;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-weight: 750;
}

footer {
  padding: 2.2rem 0 0.7rem;
  color: var(--olive-soft);
  font-size: 0.78rem;
  text-align: center;
}

footer p {
  margin: 0.18rem 0;
}

footer a {
  color: var(--olive);
  text-underline-offset: 0.2em;
}

.prototype-label {
  margin-top: 0.65rem;
  color: var(--gold);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript {
  display: block;
  padding: 1rem;
  background: #fff1c8;
  color: #442f16;
  text-align: center;
}

@supports (text-wrap: pretty) {
  .quran-text {
    text-wrap: pretty;
  }
}

@supports selector(body:has(#increase-size:disabled)) {
  body:has(#increase-size:disabled) .quran-text {
    text-align: center;
    text-align-last: center;
  }
}

@media (max-width: 440px) {
  .page-shell {
    padding-inline: clamp(0.55rem, 2.7vw, 0.75rem);
  }

  .quran-card {
    padding-block: clamp(1.4rem, 6vw, 2rem);
    padding-inline: clamp(0.75rem, 3.8vw, 1rem);
    border-radius: 1rem;
  }

}

@media (max-width: 390px) {

  .controls-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .size-control {
    width: 100%;
    grid-template-columns: 1fr 3.4rem 1fr;
  }

}

@media (min-width: 44rem) {
  .surah-browser,
  .reader-controls {
    padding: 1.25rem;
  }

  .surah-selector {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
