@font-face {
  font-family: "Alte Haas Grotesk";
  src: url("../fonts/AlteHaasGroteskRegular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Alte Haas Grotesk";
  src: url("../fonts/AlteHaasGroteskBold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Amiri Quran";
  src: url("../fonts/AmiriQuran-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

:root {
  --font-latin: "Alte Haas Grotesk", "Helvetica Neue", Helvetica, sans-serif;
  --font-arabic: "Amiri Quran", "Alte Haas Grotesk", serif;
  --font-ui: "Alte Haas Grotesk", "Helvetica Neue", Helvetica, sans-serif;
  --measure: 38rem;
  --page-pad: clamp(1.25rem, 4vw, 2.5rem);
}

:root[data-theme="paper"] {
  --bg: #f7f4ef;
  --bg-muted: #efeae2;
  --text: #2a2622;
  --text-muted: #5c564e;
  --accent: #8b7355;
  --accent-soft: color-mix(in srgb, #8b7355 18%, var(--bg));
  --border: #d4cdc3;
  --link: #6b5638;
  --link-hover: #4a3d28;
}

:root[data-theme="ink"] {
  --bg: #1c1b19;
  --bg-muted: #262522;
  --text: #e6e1d9;
  --text-muted: #b8b0a4;
  --accent: #c4a574;
  --accent-soft: color-mix(in srgb, #c4a574 15%, var(--bg));
  --border: #3d3a35;
  --link: #d4b88a;
  --link-hover: #e8d4b0;
}

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

html {
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-latin), var(--font-arabic), sans-serif;
  font-size: 1.05rem;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.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;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-main {
  flex: 1;
  width: min(100%, calc(var(--measure) + 2 * var(--page-pad)));
  margin: 0 auto;
  padding: clamp(3.5rem, 8vh, 5.5rem) var(--page-pad) 4rem;
}

.page-main--narrow {
  padding-top: 30vh;
  text-align: center;
}

.booklet-header {
  text-align: center;
  margin-bottom: clamp(2.5rem, 6vh, 4rem);
}

.booklet-title {
  margin: 0;
  font-family: var(--font-latin);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.75rem);
  letter-spacing: 0.02em;
  line-height: 1.15;
}

.booklet-subtitle {
  margin: 0.85rem 0 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text-muted);
  font-weight: 400;
}

.page-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.page-content .am-block,
.page-content .am-paragraph,
.page-content p {
  margin: 0 0 1.1rem;
}

/* Full Arabic lines only — inline Arabic in Latin lines keeps parent LTR align. */
.page-content .arabic-line {
  display: block;
  direction: rtl;
  text-align: start;
  font-family: var(--font-arabic);
  font-size: 1.2em;
  line-height: 1.8;
}

/* Automad delimiter → three asterisks */
.page-content hr {
  border: 0 !important;
  border-top: 0 !important;
  margin: 2.25rem 0 !important;
  height: 0 !important;
  padding: 0 !important;
  text-align: center;
  background: transparent !important;
  overflow: visible;
  color: transparent;
}

.page-content hr::before {
  content: "* * *";
  display: block;
  letter-spacing: 0.55em;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
}

/* Page controls (from meshpot, minimal) */
.page-controls-anchor {
  position: fixed;
  top: 0.85rem;
  right: 1rem;
  z-index: 100;
}

@media (min-width: 56rem) {
  .page-controls-anchor {
    padding: 0.85rem;
    margin: -0.85rem;
  }
}

.page-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.page-controls.is-auto-hidden {
  opacity: 0;
  transform: translateY(-0.35rem);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .page-controls {
    transition: none;
  }

  .page-controls.is-auto-hidden {
    transform: none;
  }
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.12rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-muted);
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0.18rem 0.42rem;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  transition: color 0.15s ease, background 0.15s ease;
}

.lang-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.lang-btn:hover:not(.is-active):not(:disabled) {
  color: var(--text);
}

.lang-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 6px);
  height: calc(1.25rem - 6px);
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s ease, background 0.15s ease;
  z-index: 1;
}

.theme-switch-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.15s ease, opacity 0.15s ease;
  z-index: 2;
}

.theme-switch-icon--light {
  left: 0.28rem;
}

.theme-switch-icon--dark {
  right: 0.28rem;
  opacity: 0.45;
}

.theme-switch-input:checked + .theme-switch-track {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.theme-switch-input:checked + .theme-switch-track::after {
  transform: translateX(calc(2.25rem - 1.25rem));
  background: var(--accent);
}

.theme-switch-input:checked + .theme-switch-track .theme-switch-icon--light {
  opacity: 0.45;
}

.theme-switch-input:checked + .theme-switch-track .theme-switch-icon--dark {
  opacity: 1;
  color: var(--accent);
}

.theme-switch-input:focus-visible + .theme-switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-switch:hover .theme-switch-track {
  border-color: var(--accent);
}

/* Dormant site chrome (activated via checkboxShowSiteChrome) */
.site-chrome {
  width: min(100%, calc(var(--measure) + 2 * var(--page-pad)));
  margin: 0 auto;
  padding: 1rem var(--page-pad);
}

.site-header {
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

.site-brand__logo {
  display: block;
  max-height: 2rem;
  width: auto;
}

.site-nav__list {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

@media print {
  .page-controls,
  .page-controls-anchor {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}
