/* =============================================================================
   Base: reset, typography, layout primitives, utilities
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
p, li { overflow-wrap: break-word; }
ul[class], ol[class] { list-style: none; padding: 0; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
:target { scroll-margin-top: calc(var(--header-h) + 1.5rem); }

/* ------------------------------------------------------------- headings -- */

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--ink-900);
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }

p { text-wrap: pretty; }

a {
  color: var(--primary-strong);
  text-decoration-color: color-mix(in srgb, var(--primary) 35%, transparent);
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--primary); }

strong, b { font-weight: 700; }
small { font-size: var(--text-sm); }

code, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }

.arabic {
  font-family: var(--font-arabic);
  direction: rtl;
  line-height: 1.9;
  font-size: 1.4em;
}

/* --------------------------------------------------------------- focus --- */

:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

.skip-link {
  position: fixed;
  top: -100px;
  left: var(--space-4);
  z-index: 200;
  padding: 0.7rem 1.1rem;
  background: var(--primary-deep);
  color: var(--text-invert);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus-visible { top: var(--space-4); color: var(--text-invert); }

/* ------------------------------------------------------------- layout ---- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}
.container-narrow { max-width: var(--container-narrow); }

.section { padding-block: var(--section-y); }
.section-tight { padding-block: clamp(2.5rem, 1.5rem + 3vw, 4rem); }
.section-alt { background: var(--bg-alt); }
.section-sunken { background: var(--surface-sunken); }
.section-deep {
  background:
    radial-gradient(1100px 520px at 82% -10%, rgba(217, 174, 56, 0.14), transparent 60%),
    linear-gradient(165deg, var(--green-900) 0%, var(--green-950) 100%);
  color: var(--text-invert);
}
.section-deep h1, .section-deep h2, .section-deep h3, .section-deep h4 { color: #fff; }
.section-deep p { color: rgba(255, 255, 255, 0.82); }

.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }

.grid { display: grid; gap: clamp(1.1rem, 0.6rem + 1.4vw, 2rem); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); }
.grid-auto-lg { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }

.row { display: flex; gap: var(--space-3); align-items: center; }
.row-between { display: flex; gap: var(--space-4); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-wrap { flex-wrap: wrap; }
.row-start { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.spacer { flex: 1 1 auto; }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------- utilities --- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent-strong);
}
.eyebrow::before {
  content: '';
  width: 1.6rem;
  height: 2px;
  background: linear-gradient(90deg, var(--gold-600), transparent);
  border-radius: 2px;
}
.section-deep .eyebrow { color: var(--gold-400); }

.section-head { max-width: 62ch; margin-bottom: clamp(2rem, 1.2rem + 2vw, 3.25rem); }
.section-head h2 { font-size: var(--text-section); margin-top: var(--space-3); }
.section-head p { margin-top: var(--space-3); color: var(--text-muted); font-size: var(--text-md); }
.section-deep .section-head p { color: rgba(255, 255, 255, 0.8); }
.section-head-center { margin-inline: auto; text-align: center; }
.section-head-center .eyebrow::before { display: none; }

.lead { font-size: var(--text-lg); color: var(--text-muted); line-height: 1.62; }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.tiny { font-size: var(--text-xs); }
.small { font-size: var(--text-sm); }
.strong { font-weight: 700; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.nums { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--text-xs); font-weight: 700; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.full { width: 100%; }
.gold { color: var(--accent-strong); }
.green { color: var(--primary); }
.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;
}

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }

.divider { height: 1px; background: var(--border); border: 0; margin-block: var(--space-5); }
.divider-ornament {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  color: var(--gold-500); margin-block: var(--space-6);
}
.divider-ornament::before, .divider-ornament::after {
  content: ''; height: 1px; flex: 1 1 auto; max-width: 140px;
  background: linear-gradient(90deg, transparent, var(--line-strong));
}
.divider-ornament::after { background: linear-gradient(270deg, transparent, var(--line-strong)); }

/* -------------------------------------------------- scroll reveal ------- */

.reveal { opacity: 0; transform: translateY(18px); transition: opacity 620ms var(--ease-out), transform 620ms var(--ease-out); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}
/* Never let a scroll-reveal hide content on a printed page. */
@media print {
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* --------------------------------------------------------------- print -- */

@media print {
  .site-header, .site-footer, .portal-sidebar, .portal-topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .panel { box-shadow: none; border: 1px solid #ddd; }
}
