:root {
  --ink: #152028;
  --ink-soft: #2a3a45;
  --paper: #e4e8e2;
  --paper-deep: #cfd6cf;
  --mist: #9aaba8;
  --teal: #3a5f5e;
  --teal-deep: #2a4544;
  --brass: #a88955;
  --brass-soft: #c4ad7a;
  --seal: #6e3b3b;
  --white: #f7f8f5;
  --shadow: rgba(21, 32, 40, 0.18);
  --font-display: "Aref Ruqaa", "Noto Naskh Arabic", serif;
  --font-body: "Vazirmatn", Tahoma, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --nav-h: 4.25rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.8;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font-family: inherit;
}

.site-nav {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
  background: transparent;
  color: var(--white);
  transition: background 0.45s var(--ease), color 0.45s var(--ease), box-shadow 0.45s var(--ease);
}

.site-nav.is-solid {
  background: rgba(228, 232, 226, 0.92);
  color: var(--ink);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(21, 32, 40, 0.08);
}

.site-nav.is-solid .nav-brand {
  color: var(--ink);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  color: var(--white);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.95rem;
}

.nav-links a {
  opacity: 0.88;
  transition: opacity 0.25s;
}

.nav-links a:hover {
  opacity: 1;
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  opacity: 1 !important;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

.site-nav.is-solid .nav-cta {
  background: var(--teal);
  border-color: var(--teal);
  color: var(--white);
}

.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-items: end;
  color: var(--white);
  overflow: hidden;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  transform: scale(1.04);
  animation: heroDrift 18s var(--ease) infinite alternate;
  filter: contrast(1.08) brightness(0.92);
}

.hero-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(21, 32, 40, 0.22) 0%, rgba(21, 32, 40, 0.28) 38%, rgba(21, 32, 40, 0.86) 100%),
    radial-gradient(ellipse at 72% 18%, rgba(168, 137, 85, 0.14), transparent 50%);
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: calc(var(--nav-h) + 2rem) clamp(1.25rem, 5vw, 4.5rem) clamp(3rem, 8vh, 5.5rem);
  max-width: 42rem;
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 11vw, 6.5rem);
  line-height: 1.1;
  margin: 0 0 0.85rem;
  opacity: 0;
  transform: translateY(1.5rem);
  animation: riseIn 1.1s var(--ease) 0.15s forwards;
}

.hero-lead {
  margin: 0 0 1.75rem;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  max-width: 28rem;
  color: rgba(247, 248, 245, 0.9);
  opacity: 0;
  transform: translateY(1.2rem);
  animation: riseIn 1.1s var(--ease) 0.35s forwards;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  opacity: 0;
  transform: translateY(1rem);
  animation: riseIn 1.1s var(--ease) 0.55s forwards;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.85rem;
  padding: 0.65rem 1.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.98rem;
  cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease), border-color 0.25s var(--ease);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--brass);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--brass-soft);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(247, 248, 245, 0.45);
  color: var(--white);
}

.btn-ghost:hover {
  border-color: var(--white);
  background: rgba(247, 248, 245, 0.08);
}

.section {
  padding: clamp(3.5rem, 9vh, 6.5rem) clamp(1.25rem, 5vw, 4.5rem);
}

.section-inner {
  max-width: 68rem;
  margin: 0 auto;
}

.section-kicker {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--teal);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.25;
  margin: 0 0 1rem;
  color: var(--ink);
}

.section-text {
  margin: 0;
  max-width: 40rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.about {
  background:
    linear-gradient(135deg, rgba(58, 95, 94, 0.08), transparent 45%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
}

.about-grid {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  margin-top: 2.5rem;
  grid-template-columns: 1.2fr 0.8fr;
}

.about-copy p {
  margin: 0 0 1.1rem;
  color: var(--ink-soft);
  max-width: 38rem;
}

.about-aside {
  align-self: start;
  padding: 1.5rem 0;
  border-block: 1px solid rgba(21, 32, 40, 0.12);
}

.about-aside dt {
  font-size: 0.85rem;
  color: var(--teal);
  margin-top: 1rem;
}

.about-aside dt:first-child {
  margin-top: 0;
}

.about-aside dd {
  margin: 0.2rem 0 0;
  font-size: 1.05rem;
}

.family {
  position: relative;
  background: var(--ink);
  color: var(--white);
  overflow: hidden;
}

.family::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(168, 137, 85, 0.16), transparent 40%),
    radial-gradient(circle at 85% 70%, rgba(58, 95, 94, 0.22), transparent 45%);
  pointer-events: none;
}

.family .section-inner {
  position: relative;
}

.family .section-kicker {
  color: var(--brass-soft);
}

.family .section-title {
  color: var(--white);
}

.family .section-text,
.family p {
  color: rgba(247, 248, 245, 0.82);
}

.family-flow {
  display: grid;
  gap: 1.75rem;
  margin-top: 2.25rem;
  max-width: 44rem;
}

.family-flow p {
  margin: 0;
}

.family-names {
  margin-top: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
  color: var(--brass-soft);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.cta-band {
  background:
    linear-gradient(120deg, var(--teal-deep), var(--teal) 55%, #4a6f5d);
  color: var(--white);
  text-align: center;
}

.cta-band .section-title {
  color: var(--white);
}

.cta-band .section-text {
  margin-inline: auto;
  color: rgba(247, 248, 245, 0.88);
}

.cta-band .hero-actions {
  justify-content: center;
  margin-top: 1.75rem;
  opacity: 1;
  transform: none;
  animation: none;
}

.site-footer {
  padding: 1.5rem clamp(1.25rem, 5vw, 4.5rem);
  background: var(--ink);
  color: rgba(247, 248, 245, 0.65);
  font-size: 0.9rem;
  text-align: center;
}

.reveal {
  opacity: 0;
  transform: translateY(1.4rem);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Archive page */
.archive-body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, #dfe5df 0%, var(--paper) 35%, #d7ddd6 100%);
}

.archive-nav {
  color: var(--ink);
  background: rgba(228, 232, 226, 0.94);
  box-shadow: 0 1px 0 rgba(21, 32, 40, 0.08);
}

.archive-nav .nav-brand {
  color: var(--ink);
}

.gate {
  min-height: calc(100vh - var(--nav-h));
  display: grid;
  place-items: center;
  padding: calc(var(--nav-h) + 2rem) 1.25rem 3rem;
}

.gate-panel {
  width: min(100%, 26rem);
  text-align: center;
}

.gate-panel h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.6rem);
  margin: 0 0 0.75rem;
}

.gate-panel p {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
}

.gate-form {
  display: grid;
  gap: 0.85rem;
}

.gate-form input {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(21, 32, 40, 0.18);
  border-radius: 0.75rem;
  background: var(--white);
  color: var(--ink);
  font-size: 1rem;
  text-align: center;
}

.gate-form input:focus {
  outline: 2px solid rgba(58, 95, 94, 0.35);
  border-color: var(--teal);
}

.gate-error {
  min-height: 1.4rem;
  margin: 0;
  color: var(--seal);
  font-size: 0.92rem;
}

.archive-shell {
  display: none;
  padding: calc(var(--nav-h) + 1.5rem) clamp(1.25rem, 4vw, 3rem) 3rem;
}

.archive-shell.is-open {
  display: block;
}

.archive-header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.archive-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  margin: 0 0 0.35rem;
}

.archive-header p {
  margin: 0;
  color: var(--ink-soft);
}

.archive-toolbar {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.btn-secondary {
  background: var(--white);
  border: 1px solid rgba(21, 32, 40, 0.14);
  color: var(--ink);
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 1rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.85rem 1.25rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(21, 32, 40, 0.1);
}

.pagination[hidden] {
  display: none;
}

.pagination-status {
  margin: 0;
  min-width: 8rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.98rem;
}

.pagination .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.doc-tile {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  text-align: start;
  color: inherit;
}

.doc-frame {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #c8cfc8;
  box-shadow: 0 10px 28px var(--shadow);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.doc-tile:hover .doc-frame,
.doc-tile:focus-visible .doc-frame {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 36px rgba(21, 32, 40, 0.24);
}

.doc-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-label {
  margin-top: 0.55rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  box-sizing: border-box;
  width: 100%;
  max-width: 100vw;
  height: 100%;
  height: 100dvh;
  background: rgba(12, 18, 22, 0.92);
  padding:
    max(0.5rem, env(safe-area-inset-top, 0px))
    max(0.5rem, env(safe-area-inset-right, 0px))
    max(0.5rem, env(safe-area-inset-bottom, 0px))
    max(0.5rem, env(safe-area-inset-left, 0px));
  overflow: hidden;
}

.lightbox.is-open {
  display: flex;
  flex-direction: column;
}

.lightbox-inner {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: min(100%, 56rem);
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: hidden;
}

.lightbox-stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  overflow: auto;
  background: #111;
  overscroll-behavior: contain;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
}

.lightbox-canvas {
  position: relative;
  width: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

.lightbox-canvas img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  margin: 0;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.lightbox-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--white);
  background: rgba(12, 18, 22, 0.96);
  padding: 0.35rem 0.15rem 0.15rem;
  z-index: 2;
}

.lightbox-caption {
  display: block;
  font-size: 0.88rem;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: 0.25rem;
  color: rgba(247, 248, 245, 0.88);
}

.lightbox-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding-bottom: 0.15rem;
  scrollbar-width: thin;
}

.lightbox-nav .btn {
  flex: 0 0 auto;
  min-height: 2.4rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.88rem;
  touch-action: manipulation;
}

.lightbox-nav .btn-icon {
  min-width: 2.4rem;
  padding-inline: 0.55rem;
  font-size: 1.05rem;
  line-height: 1;
}

.zoom-level {
  flex: 0 0 auto;
  min-width: 2.8rem;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(247, 248, 245, 0.85);
}

.lightbox-nav .btn,
.lightbox-close {
  background: rgba(247, 248, 245, 0.12);
  color: var(--white);
  border: 1px solid rgba(247, 248, 245, 0.25);
}

.lightbox-nav .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 700px) {
  .lightbox-nav .btn {
    min-height: 2.55rem;
  }
}

@keyframes riseIn {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes heroDrift {
  from {
    transform: scale(1.06) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.12) translate3d(-1.5%, -1%, 0);
  }
}

@media (max-width: 800px) {
  .about-grid {
    grid-template-columns: 1fr;
  }

  .nav-links a:not(.nav-cta) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hero-media img,
  .hero-brand,
  .hero-lead,
  .hero-actions,
  .reveal {
    animation: none !important;
    transition: none !important;
    opacity: 1;
    transform: none;
  }
}
