/* Base reset + typography + utilities */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--foreground);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* Reicon: avoid svg{max-width:100%} collapsing icons to 0 in flex/inline contexts */
re-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: inherit;
  line-height: 0;
  vertical-align: middle;
}

re-icon svg {
  display: block;
  max-width: none;
  width: 100%;
  height: 100%;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: 700;
  margin: 0 0 var(--space-4);
  color: var(--primary-deep);
}

h1 {
  font-size: var(--text-5xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-xl);
}

p {
  margin: 0 0 var(--space-4);
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100%;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--primary-deep);
  color: var(--primary-foreground);
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: var(--space-4);
}

.container {
  width: min(100% - var(--space-8), var(--container));
  margin-inline: auto;
}

.container--wide {
  width: min(100% - var(--space-8), var(--container-wide));
  margin-inline: auto;
}

.container--narrow {
  width: min(100% - var(--space-8), 36rem);
  margin-inline: auto;
}

.error-page {
  min-height: calc(70vh - var(--header-h));
  display: flex;
  align-items: center;
}

.error-page__inner {
  text-align: center;
  padding-block: var(--space-10);
}

.error-page__code {
  margin: var(--space-2) 0 var(--space-3);
  font-family: var(--font-heading);
  font-size: clamp(3.5rem, 12vw, 6rem);
  font-weight: 700;
  line-height: 1;
  color: color-mix(in srgb, var(--primary) 22%, var(--background));
  letter-spacing: -0.04em;
}

.error-page h1 {
  margin-bottom: var(--space-3);
}

.error-page .lede {
  margin-inline: auto;
  margin-bottom: var(--space-8);
}

.error-page .cta-group {
  justify-content: center;
  margin-bottom: var(--space-8);
}

.error-page__links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  justify-content: center;
}

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

/* Islamic geometric pattern — reserved; use sparingly (not on every section) */
.pattern-islamic {
  position: relative;
  background-color: var(--muted);
  isolation: isolate;
}

.pattern-islamic::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.06;
  background-color: var(--primary-deep);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1' d='M28 4 L32 16 L44 16 L34 24 L38 36 L28 28 L18 36 L22 24 L12 16 L24 16 Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1' d='M28 4 L32 16 L44 16 L34 24 L38 36 L28 28 L18 36 L22 24 L12 16 L24 16 Z'/%3E%3C/svg%3E");
  -webkit-mask-size: 56px 56px;
  mask-size: 56px 56px;
}

.kicker {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

.lede {
  font-size: var(--text-lg);
  color: var(--muted-foreground);
  max-width: 38rem;
}

.section {
  padding-block: var(--section-y);
}

.section--tight {
  padding-block: var(--section-y-sm);
}

.section--muted {
  background: var(--muted);
}

/* Match page chrome: space below page-hero border = space above footer */
.page-hero + .section,
.page-hero + .section--tight,
.page-hero + .section--muted {
  padding-top: var(--section-y);
  padding-bottom: var(--section-y);
}

/* Last main section: same bottom step before footer (profil-consistent) */
main > .section:last-of-type,
main > .section--tight:last-of-type,
main > .section--muted:last-of-type,
main > *:last-child > .section:last-of-type {
  padding-bottom: var(--section-y);
}

/* Avoid stacking prose h2 margin on top of that shared step */
.page-hero + .section .prose > h2:first-child,
.page-hero + .section .prose > h2:first-of-type {
  margin-top: 0;
}

.section-heading {
  margin-bottom: var(--space-6);
}

.section-heading__row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-4);
}

.section-heading h2 {
  margin-bottom: var(--space-2);
}

.section-heading p {
  color: var(--muted-foreground);
  max-width: 36rem;
  margin: 0;
}

.link-more {
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.link-more:hover {
  color: var(--primary-deep);
}

/* Scroll reveal — gated by .js so no-JS stays visible */
.reveal {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: no-preference) {
  .js .reveal:not(.reveal-stagger) {
    opacity: 0;
    transform: translateY(1.5rem);
    transition:
      opacity 700ms var(--ease),
      transform 700ms var(--ease);
  }

  .js .reveal:not(.reveal-stagger).is-visible {
    opacity: 1;
    transform: none;
  }

  /* Stagger children when parent enters viewport */
  .js .reveal-stagger > * {
    opacity: 0;
    transform: translateY(1.35rem);
  }

  .js .reveal-stagger.is-visible > * {
    animation: fade-up 680ms var(--ease) forwards;
  }

  .js .reveal-stagger.is-visible > *:nth-child(1) {
    animation-delay: 40ms;
  }
  .js .reveal-stagger.is-visible > *:nth-child(2) {
    animation-delay: 110ms;
  }
  .js .reveal-stagger.is-visible > *:nth-child(3) {
    animation-delay: 180ms;
  }
  .js .reveal-stagger.is-visible > *:nth-child(4) {
    animation-delay: 250ms;
  }
  .js .reveal-stagger.is-visible > *:nth-child(5) {
    animation-delay: 320ms;
  }
  .js .reveal-stagger.is-visible > *:nth-child(6) {
    animation-delay: 390ms;
  }
  .js .reveal-stagger.is-visible > *:nth-child(n + 7) {
    animation-delay: 450ms;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(1.35rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin: 0;
  padding-top: var(--space-6);
  padding-bottom: 0;
}

.breadcrumb a {
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb [aria-current="page"] {
  max-width: min(36ch, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-hero {
  padding-block: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.page-hero h1 {
  margin-bottom: var(--space-3);
}

.page-hero--center {
  text-align: center;
}

.page-hero--center .lede {
  margin-inline: auto;
}

.page-hero .lede {
  margin-bottom: 0;
}

.page-hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.page-hero__meta re-icon {
  flex-shrink: 0;
}

.page-hero__date {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.page-hero h1 + .page-hero__meta {
  margin-top: 0;
}

.cta-group--hero {
  margin-top: var(--space-6);
}

.prose {
  max-width: 42rem;
}

.prose > * + * {
  margin-top: var(--space-5);
}

.prose p {
  margin-top: 0;
  margin-bottom: 0;
  text-wrap: pretty;
}

.prose > * + p {
  margin-top: var(--space-5);
}

.prose h2 {
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  font-size: var(--text-2xl);
}

.prose h3 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

.prose h2 + p,
.prose h3 + p,
.prose h2 + ul,
.prose h3 + ul,
.prose h2 + ol,
.prose h3 + ol {
  margin-top: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
  margin: 0;
}

.prose li {
  margin-bottom: var(--space-2);
}

.prose li:last-child {
  margin-bottom: 0;
}

.prose li > p {
  margin: 0;
}

.prose a {
  color: var(--primary-deep);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

.prose a:hover {
  color: var(--primary);
}

.prose strong {
  font-weight: 700;
}

.prose em {
  font-style: italic;
}

.prose u {
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.prose s {
  text-decoration: line-through;
}

.prose sub,
.prose sup {
  font-size: 0.75em;
  line-height: 0;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: var(--space-6) 0;
  border-radius: var(--radius-sm, 4px);
  background: var(--muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-8) 0;
}

.prose blockquote,
.prose-quote {
  margin: var(--space-8) 0;
  padding: var(--space-5) 0 var(--space-5) var(--space-5);
  border-left: 3px solid var(--primary);
  background: transparent;
}

.prose blockquote p,
.prose-quote p {
  margin: 0;
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.45;
  color: var(--primary-deep);
  text-wrap: balance;
}

.prose blockquote footer,
.prose-quote__cite {
  margin-top: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  font-style: normal;
  color: var(--muted-foreground);
}

.prose pre,
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

.prose code {
  padding: 0.1em 0.35em;
  background: var(--muted);
  border-radius: var(--radius-sm, 4px);
}

.prose pre {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
  font-size: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-6) 0;
  font-size: var(--text-sm);
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

.prose thead {
  background: var(--muted);
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: top;
}

.prose th {
  font-weight: 600;
  font-family: var(--font-heading);
}

.prose [style*="text-align: center"],
.prose [style*="text-align:center"] {
  text-align: center;
}

.prose [style*="text-align: right"],
.prose [style*="text-align:right"],
.prose [style*="text-align: end"],
.prose [style*="text-align:end"] {
  text-align: end;
}

.prose-callout {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  background: var(--muted);
  border-left: 3px solid var(--accent);
}

.prose-callout p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--foreground);
}

.grid-2 {
  display: grid;
  gap: var(--space-8);
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.grid-3 {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}
