/* NCF — custom styles (beyond Tailwind utilities) */

:root {
  --font-primary: "Almarai", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-scale: 1;
  --focus-ring: 0 0 0 3px rgba(184, 137, 46, 0.55);
  --surface: #F7F1E6;
  --surface-elevated: #ffffff;
  --text: #18181B;
  --muted: #52525B;
  --border-gold: rgba(184, 137, 46, 0.42);
}

html.dark {
  --surface: #121A2E;
  --surface-elevated: #18223C;
  --text: #F5EFE3;
  --muted: #D5DCEB;
  --border-gold: rgba(201, 160, 74, 0.5);
}

html.high-contrast {
  --focus-ring: 0 0 0 3px #000, 0 0 0 6px #B8892E;
}


html {
  font-size: calc(100% * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background-color: var(--surface);
  color: var(--text);
  line-height: 1.8;
  letter-spacing: 0;
}

html[lang="en"] body {
  font-family: var(--font-primary);
}

/* Skip link */
.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -100%;
  z-index: 100;
  padding: 0.75rem 1.25rem;
  background: #1E2A4A;
  color: #F7F1E6;
  border-radius: 0.75rem;
  font-weight: 600;
}
.skip-link:focus {
  top: 1rem;
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Focus */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 0.25rem;
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #9E4526 transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: #9E4526;
  border-radius: 999px;
}

/* Textile pattern background */
.pattern-textile {
  background-image: url("../img/svg/pattern-textile.svg");
  background-size: 180px 180px;
  background-repeat: repeat;
  opacity: 0.07;
  pointer-events: none;
}
html.dark .pattern-textile {
  opacity: 0.12;
  filter: invert(1) sepia(1) saturate(2) hue-rotate(10deg);
}

.pattern-triangles {
  background-image: url("../img/svg/pattern-triangles.svg");
  background-size: 120px 120px;
  background-repeat: repeat;
  opacity: 0.08;
  pointer-events: none;
}

/* Paper grain for archive sections */
.paper-grain {
  position: relative;
}
.paper-grain::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("../img/svg/paper-grain.svg");
  background-size: 280px 280px;
  mix-blend-mode: multiply;
  border-radius: inherit;
}
html.dark .paper-grain::before {
  mix-blend-mode: soft-light;
  opacity: 0.25;
}

/* Arched image frames */
.arch-frame {
  border-radius: 50% 50% 1rem 1rem / 28% 28% 1rem 1rem;
  overflow: hidden;
  border: 1px solid var(--border-gold);
  box-shadow: 0 8px 32px -8px rgba(30, 42, 74, 0.18);
}

/* Gold hairline */
.hairline-gold {
  border: 1px solid var(--border-gold);
}

/* Card lift + gold glow */
.card-lift {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card-lift:hover,
.card-lift:focus-within {
  transform: translateY(-4px);
  box-shadow: 0 0 0 1px rgba(184, 137, 46, 0.5), 0 12px 36px -8px rgba(158, 69, 38, 0.28);
}

/* Button shine */
.btn-shine {
  position: relative;
  overflow: hidden;
}
.btn-shine::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
  transform: translateX(-120%);
  pointer-events: none;
}
.btn-shine:hover::after,
.btn-shine:focus-visible::after {
  animation: shine-sweep 0.8s ease-in-out;
}

@keyframes shine-sweep {
  to { transform: translateX(120%); }
}

/* Underline grow from start */
.link-underline {
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 100% 100%;
  background-repeat: no-repeat;
  background-size: 0% 2px;
  transition: background-size 0.3s ease;
}
html[dir="ltr"] .link-underline {
  background-position: 0% 100%;
}
.link-underline:hover,
.link-underline:focus-visible {
  background-size: 100% 2px;
}

/* Eyebrow labels */
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
}
html[lang="ar"] .eyebrow {
  letter-spacing: 0;
  text-transform: none;
  font-variant: normal;
}
html.dark .eyebrow {
  color: var(--accent-text);
}
/* An explicit gold eyebrow sits on dark bands in both themes */
.eyebrow.text-gold-400 { color: #C06A45; }

/* Scroll progress */
#scroll-progress {
  transform-origin: right center;
}
html[dir="ltr"] #scroll-progress {
  transform-origin: left center;
}

/* Chrome stacking: header above content; drawer only above chrome when open */
.site-header {
  z-index: 50;
  backdrop-filter: blur(18px) saturate(1.2);
  background-color: rgba(247, 241, 230, 0.88);
  border-bottom: 1px solid rgba(181, 83, 46, 0.22);
}
html.dark .site-header {
  background-color: rgba(12, 18, 31, 0.86);
  border-bottom-color: rgba(181, 83, 46, 0.28);
}

/* Header states */
.site-header.is-scrolled {
  box-shadow: 0 8px 32px -12px rgba(30, 42, 74, 0.22);
}
html.dark .site-header.is-scrolled {
  box-shadow: 0 8px 32px -12px rgba(0, 0, 0, 0.45);
}
.site-header.is-scrolled .header-inner {
  padding-block: 0.5rem;
}

/* Reveal animations */
.reveal {
  opacity: 0;
  transform: translateY(1.25rem);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-clip {
  clip-path: inset(8% 8% 8% 8%);
  transition: clip-path 0.9s ease;
}
.reveal-clip.is-visible {
  clip-path: inset(0 0 0 0);
}
.stagger > .reveal:nth-child(1) { transition-delay: 0.05s; }
.stagger > .reveal:nth-child(2) { transition-delay: 0.1s; }
.stagger > .reveal:nth-child(3) { transition-delay: 0.15s; }
.stagger > .reveal:nth-child(4) { transition-delay: 0.2s; }
.stagger > .reveal:nth-child(5) { transition-delay: 0.25s; }
.stagger > .reveal:nth-child(6) { transition-delay: 0.3s; }
.stagger > .reveal:nth-child(7) { transition-delay: 0.35s; }
.stagger > .reveal:nth-child(8) { transition-delay: 0.4s; }

/* Hero title: fade the whole line (inline-block per word clips Arabic glyphs) */
[data-hero-words] {
  overflow: visible;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(12, 18, 31, 0.5);
}
html[lang="ar"] [data-hero-words] {
  line-height: 1.45;
  padding-inline: 0.2em;
}
.hero-animate {
  opacity: 0;
  transform: translateY(0.6rem);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.hero-animate.is-shown,
.hero-word.is-shown {
  opacity: 1;
  transform: none;
}
.hero-word {
  display: inline;
}

/* Logo intro draw */
.logo-intro path,
.logo-intro polygon,
.logo-intro rect {
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: logo-draw 0.75s ease forwards;
}
@keyframes logo-draw {
  to { stroke-dashoffset: 0; }
}

/* Timeline stroke */
.timeline-path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.4s ease;
}
.timeline-path.is-drawn {
  stroke-dashoffset: 0;
}

/* Marquee */
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee-rtl 40s linear infinite;
}
html[dir="ltr"] .marquee-track {
  animation-name: marquee-ltr;
}
.marquee:hover .marquee-track,
.marquee:focus-within .marquee-track {
  animation-play-state: paused;
}
@keyframes marquee-rtl {
  from { transform: translateX(0); }
  to { transform: translateX(50%); }
}
@keyframes marquee-ltr {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Masonry */
.masonry {
  columns: 1;
  column-gap: 1rem;
}
@media (min-width: 640px) {
  .masonry { columns: 2; }
}
@media (min-width: 1024px) {
  .masonry { columns: 3; }
}
.masonry-item {
  break-inside: avoid;
  margin-bottom: 1rem;
}

/* Lightbox */
.lightbox[hidden] {
  display: none !important;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(12, 18, 31, 0.92);
}

/* Org chart connectors */
.org-branch::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: 50%;
  width: 1px;
  height: 1.25rem;
  background: rgba(181, 83, 46, 0.5);
}

/* Mobile drawer — hide toward inline-end (LTR right / RTL left) */
.drawer {
  visibility: hidden;
  pointer-events: none;
  transform: translateX(100%);
  transition: transform 0.3s ease, visibility 0.3s ease;
  background-color: #F7F1E6;
}
html.dark .drawer {
  background-color: #121A2E;
}
html[dir="rtl"] .drawer {
  transform: translateX(-100%);
}
.drawer.is-open,
html[dir="rtl"] .drawer.is-open,
html[dir="ltr"] .drawer.is-open {
  visibility: visible;
  pointer-events: auto;
  transform: translateX(0);
  z-index: 56;
}
.drawer-backdrop {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}
@media (min-width: 1024px) {
  .drawer,
  .drawer-backdrop {
    display: none !important;
  }
}

/* Dark-mode card / chip contrast */
html.dark .card-lift,
html.dark article.hairline-gold,
html.dark li.hairline-gold,
html.dark button.hairline-gold,
html.dark span.hairline-gold,
html.dark .arch-frame {
  color: #F7F1E6;
}
html.dark .card-lift.bg-white,
html.dark article.bg-white,
html.dark li.bg-white,
html.dark a.bg-white,
html.dark button.bg-white:not([data-theme-toggle]),
html.dark span.bg-white,
html.dark figure.bg-white,
html.dark .arch-frame.bg-white,
html.dark .hairline-gold[class*="bg-white"],
html.dark .card-lift[class*="bg-white"],
html.dark .arch-frame[class*="bg-white"],
html.dark article[class*="bg-white"],
html.dark li[class*="bg-white"] {
  background-color: #18223C !important;
}
.site-header nav > a,
.site-header [data-dropdown-btn] {
  color: #1E2A4A;
}
html.dark .site-header nav > a,
html.dark .site-header [data-dropdown-btn] {
  color: #F5EFE3;
}

/* Dropdown: never inherit hero/nav light text onto a white panel */
[data-dropdown-panel] {
  z-index: 70;
  min-width: 15rem;
  padding: 0.4rem;
  background: #ffffff !important;
  color: #1E2A4A !important;
  border: 1px solid rgba(181, 83, 46, 0.38);
  border-radius: 1rem;
  box-shadow: 0 22px 50px -16px rgba(18, 26, 46, 0.38);
}
html.dark [data-dropdown-panel] {
  background: #18223C !important;
  color: #F7F1E6 !important;
  border-color: rgba(181, 83, 46, 0.42);
  box-shadow: 0 22px 50px -16px rgba(0, 0, 0, 0.55);
}
[data-dropdown-panel] a {
  color: inherit !important;
  border-radius: 0.75rem;
  font-weight: 500;
}
[data-dropdown-panel] a:hover,
[data-dropdown-panel] a:focus-visible {
  background: rgba(181, 83, 46, 0.1) !important;
  color: #914226 !important;
}
html.dark [data-dropdown-panel] a:hover,
html.dark [data-dropdown-panel] a:focus-visible {
  background: rgba(181, 83, 46, 0.16) !important;
  color: #F0D7CB !important;
}

[data-theme-toggle]:not(.utility-tool) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.9rem;
  white-space: nowrap;
  overflow: visible;
  border-radius: 999px;
  background: #ffffff !important;
  color: #1E2A4A;
}
html.dark [data-theme-toggle]:not(.utility-tool) {
  background: #18223C !important;
  color: #F5EFE3;
}
[data-theme-label]:not(.sr-only) {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
}
.theme-icon {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
  display: block;
}
.utility-tools [data-theme-toggle].utility-tool {
  background: transparent !important;
  color: inherit;
  gap: 0;
  padding: 0 0.45rem;
}
.utility-tools .theme-icon {
  width: 1.05rem;
  height: 1.05rem;
}

.site-header input[type="search"] {
  border-radius: 999px;
  background: #ffffff;
  color: #1E2A4A;
  border-color: rgba(181, 83, 46, 0.35);
}
html.dark .site-header input[type="search"] {
  background: #18223C;
  color: #F5EFE3;
  border-color: rgba(181, 83, 46, 0.4);
}

/* Form error */
.field-error {
  color: #B91C1C;
  font-size: 0.875rem;
  margin-top: 0.35rem;
}
html.dark .field-error {
  color: #FCA5A5;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal,
  .reveal-clip,
  .hero-word,
  .hero-animate,
  .card-lift,
  .btn-shine::after,
  .logo-intro path,
  .logo-intro polygon,
  .logo-intro rect,
  .timeline-path,
  .marquee-track,
  .drawer,
  .drawer-backdrop {
    animation: none !important;
    transition: none !important;
  }
  .reveal,
  .hero-word,
  .hero-animate {
    opacity: 1 !important;
    transform: none !important;
  }
  .reveal-clip {
    clip-path: none !important;
  }
  .marquee-track {
    transform: none !important;
  }
  .logo-intro path,
  .logo-intro polygon,
  .logo-intro rect {
    stroke-dashoffset: 0 !important;
  }
  .timeline-path {
    stroke-dashoffset: 0 !important;
  }
}

/* =========================================================
   Official hero (home) — formal, editorial treatment
   ========================================================= */
.hero-search-strip {
  background: linear-gradient(90deg, #121A2E 0%, #1E2A4A 50%, #121A2E 100%);
  border-bottom: 1px solid rgba(181, 83, 46, 0.35);
  width: 100%;
  position: relative;
  z-index: 1;
}
.hero-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 36rem;
  margin-inline: auto;
  border-bottom: 1px solid rgba(233, 220, 196, 0.45);
}
@media (max-width: 1023px) {
  .hero-search { max-width: none; }
}
.hero-search:focus-within { border-bottom-color: #B5532E; }
.hero-search-icon {
  width: 1.1rem; height: 1.1rem; flex-shrink: 0;
  color: rgba(233, 220, 196, 0.7);
}
.hero-search input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  background: transparent;
  border: 0;
  padding-inline: 0.75rem;
  color: #FBF8F2;
  font-family: var(--font-primary);
  font-size: 1.15rem;
}
html[lang="en"] .hero-search input { font-family: var(--font-primary); font-size: 1rem; }
.hero-search input::placeholder { color: rgba(233, 220, 196, 0.65); }
.hero-search input:focus { outline: none; box-shadow: none; }
.hero-search input::-webkit-search-cancel-button { filter: invert(1); }
.hero-search button {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #E9DCC4;
}
.hero-search button svg { width: 1.25rem; height: 1.25rem; }
.hero-search button:hover { color: #B5532E; }

.hero-official {
  position: relative;
  color: #fff;
  background: #0C121F;
  min-height: clamp(34rem, 78vh, 46rem);
  display: flex;
  align-items: center;
  isolation: isolate;
}
.hero-media { position: absolute; inset: 0; overflow: hidden; z-index: -1; }
.hero-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 70% 60%;
  /* crop away the photo's corner watermark */
  transform: scale(1.3);
  transform-origin: 80% 95%;
}
.hero-scrim {
  position: absolute; inset: 0;
  background:
    linear-gradient(to left, rgba(12, 18, 31, 0.9) 0%, rgba(12, 18, 31, 0.72) 38%, rgba(12, 18, 31, 0.25) 72%, rgba(12, 18, 31, 0.1) 100%),
    linear-gradient(to top, rgba(12, 18, 31, 0.85) 0%, rgba(12, 18, 31, 0) 35%),
    linear-gradient(to bottom, rgba(12, 18, 31, 0.45) 0%, rgba(12, 18, 31, 0) 25%);
}
html[dir="ltr"] .hero-scrim {
  background:
    linear-gradient(to right, rgba(12, 18, 31, 0.9) 0%, rgba(12, 18, 31, 0.72) 38%, rgba(12, 18, 31, 0.25) 72%, rgba(12, 18, 31, 0.1) 100%),
    linear-gradient(to top, rgba(12, 18, 31, 0.85) 0%, rgba(12, 18, 31, 0) 35%),
    linear-gradient(to bottom, rgba(12, 18, 31, 0.45) 0%, rgba(12, 18, 31, 0) 25%);
}
.hero-inner { width: 100%; padding-top: 4.5rem; padding-bottom: 10rem; }
.hero-copy { max-width: 40rem; }

.hero-kicker {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; font-weight: 500;
  color: #E0AF97;
  padding-bottom: 0.35rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(181, 83, 46, 0.5);
}
.hero-title {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: clamp(2.5rem, 5.6vw, 4.5rem);
  line-height: 1.25;
  color: #FBF8F2;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.35);
  margin: 0;
}
html[lang="en"] .hero-title { font-family: var(--font-primary); }
.hero-title-pre {
  display: block;
  font-weight: 400;
  font-size: 0.5em;
  line-height: 1.4;
  color: #E9DCC4;
  margin-bottom: 0.15em;
}
.hero-rule {
  display: flex; align-items: center; gap: 0.6rem;
  width: 11rem;
  margin: 1.5rem 0 1rem;
}
.hero-rule span { flex: 1; height: 1px; background: linear-gradient(to left, #B5532E, rgba(181, 83, 46, 0.2)); }
.hero-rule span:last-child { background: linear-gradient(to right, #B5532E, rgba(181, 83, 46, 0.2)); }
.hero-rule i { width: 7px; height: 7px; background: #B5532E; transform: rotate(45deg); }
.hero-tagline {
  font-size: 0.95rem; font-weight: 600;
  letter-spacing: 0.02em;
  color: #B5532E;
}
.hero-lead {
  margin-top: 0.85rem;
  max-width: 34rem;
  font-size: 1.0625rem;
  line-height: 1.9;
  color: rgba(245, 239, 227, 0.9);
}
.hero-actions { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.hero-btn {
  min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  padding-inline: 1.75rem;
  border-radius: 2px;
  font-size: 0.95rem; font-weight: 600;
  letter-spacing: 0.02em;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.hero-btn--outline { border: 1px solid rgba(251, 248, 242, 0.75); color: #FBF8F2; }
.hero-btn--outline:hover { background: #FBF8F2; color: #121A2E; }
.hero-btn--solid { background: #B5532E; border: 1px solid #B5532E; color: #121A2E; }
.hero-btn--solid:hover { background: #C06A45; border-color: #C06A45; }

.hero-enter { animation: hero-in 0.9s ease-out both; }
@keyframes hero-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* Overlapping quick-link cards */
.hero-cards-wrap { position: relative; z-index: 2; margin-top: -7rem; }
.hero-cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .hero-cards { grid-template-columns: repeat(3, 1fr); } }
.hero-card {
  position: relative; display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 4px;
  background: #18223C;
  box-shadow: 0 18px 40px -18px rgba(12, 18, 31, 0.55);
  color: #fff;
}
.hero-card img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* crop away the photo's corner watermark */
  transform: scale(1.22);
  transform-origin: 75% 90%;
  transition: transform 0.6s ease;
}
.hero-card::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(12, 18, 31, 0.92) 0%, rgba(12, 18, 31, 0.35) 45%, rgba(12, 18, 31, 0.05) 75%);
}
.hero-card-body {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 1;
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.hero-card-title {
  font-size: 1.35rem; font-weight: 700; line-height: 1.35;
  padding-bottom: 0.4rem;
  background-image: linear-gradient(#B5532E, #B5532E);
  background-repeat: no-repeat;
  background-size: 2.5rem 2px;
  background-position: 100% 100%;
  transition: background-size 0.35s ease;
}
html[dir="ltr"] .hero-card-title { background-position: 0 100%; }
.hero-card-sub { font-size: 0.85rem; color: rgba(233, 220, 196, 0.85); }
.hero-card:hover img, .hero-card:focus-visible img { transform: scale(1.28); }
.hero-card:hover .hero-card-title, .hero-card:focus-visible .hero-card-title { background-size: 100% 2px; }
.hero-card:focus-visible { box-shadow: var(--focus-ring); }

@media (max-width: 767px) {
  .hero-inner { padding-top: 3rem; padding-bottom: 8rem; }
  .hero-cards-wrap { margin-top: -5rem; }
  .hero-card { aspect-ratio: 16 / 8; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-enter { animation: none !important; }
  .hero-card img { transition: none !important; }
}


/* =========================================================
   Quality pass — theme tokens, contrast, mobile layout
   ========================================================= */
:root {
  --accent-text: #9E4526;          /* clay text that passes AA on parchment */
  --band: #EFE6D4;                 /* alternate section surface */
  --card: #FFFFFF;
  --line: rgba(148, 123, 78, 0.28);
}
html.dark {
  --accent-text: #E0A283;          /* clay tint readable on navy */
  --band: #172039;
  --card: #1B2642;
  --line: rgba(181, 83, 46, 0.3);
}

/* Smooth colour change only while switching theme (never on load) */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, fill 0.3s ease !important;
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: clip; -webkit-tap-highlight-color: rgba(181, 83, 46, 0.2); }
img { max-width: 100%; }
::selection { background: rgba(181, 83, 46, 0.35); }

/* ---------- Accent text colours (AA in both themes) ---------- */
.text-clay-500 { color: var(--accent-text) !important; }
.bg-clay-500.text-white, .bg-clay-500 .text-white { color: #fff !important; }
.border-clay-500.text-clay-500 { border-color: currentColor; }
html:not(.dark) .text-gold-500 { color: #914226; }
html:not(.dark) .text-gold-600 { color: #7A5C24; }
html.dark .text-palm-500 { color: #81AF98; }
html.dark .text-ink-400,
html.dark .text-ink-500,
html.dark .text-ink-600 { color: #C9CFDD; }
html.dark .text-ink-700,
html.dark .text-ink-800 { color: #E9E3D6; }
html.dark .text-night-600,
html.dark .text-night-700 { color: #F5EFE3; }

/* ---------- Dark mode surfaces: give sections rhythm ---------- */
html.dark body { background-color: #111A2D; }
html.dark main > section[class*="bg-sand-100"],
html.dark main > section[class*="bg-parchment-200"] { background-color: var(--band) !important; }
html.dark .bg-parchment-50,
html.dark .bg-white:not([data-theme-toggle]) { background-color: var(--card) !important; }
html.dark .hairline-gold { border-color: var(--line); }
html.dark .shadow-card { box-shadow: 0 6px 24px -10px rgba(0, 0, 0, 0.55); }
html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea {
  background-color: #0F1728;
  border-color: rgba(169, 181, 209, 0.28);
  color: #F5EFE3;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: rgba(213, 220, 235, 0.55); }
html.dark .hero-search input[type="search"] { background: transparent; border: 0; }
html.dark .paper-grain::before { opacity: 0.08; }
html.dark img:not([src$=".svg"]) { filter: brightness(0.94); }
html.dark .hero-media img { filter: none; }

/* ---------- High contrast (no body filter: it breaks fixed elements) ---------- */
html.high-contrast { --line: rgba(30, 42, 74, 0.6); --accent-text: #7A3218; }
html.high-contrast.dark { --line: rgba(233, 220, 196, 0.7); --accent-text: #F0C3AA; }
html.high-contrast body { color: #09090B; }
html.high-contrast.dark body { color: #FFFFFF; }
html.high-contrast .hairline-gold { border-color: var(--line); border-width: 1.5px; }
html.high-contrast:not(.dark) [class*="text-ink-"],
html.high-contrast:not(.dark) .text-night-600 { color: #09090B !important; }
html.high-contrast.dark [class*="text-ink-"],
html.high-contrast.dark [class*="text-sand-2"],
html.high-contrast.dark [class*="text-sand-3"] { color: #FFFFFF !important; }
html.high-contrast main a:not([class*="bg-"]):not(.hero-card):not(.card-lift) { text-decoration: underline; text-underline-offset: 3px; }
html.high-contrast .hero-scrim { background: rgba(12, 18, 31, 0.85); }

/* ---------- Utility bar: one tidy row on phones ---------- */
.site-utility > div { row-gap: 0; }
@media (max-width: 639px) {
  .site-utility [data-site-dates] { display: none; }
  .site-utility > div { justify-content: flex-end; padding-block: 0; }
}

/* Compact icon toolbar (lang / type / contrast) */
.utility-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.125rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(230, 209, 154, 0.2);
}
.utility-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  min-width: 2.25rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  color: inherit;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.utility-tool:hover {
  background: rgba(255, 255, 255, 0.12);
}
.utility-tool:active { transform: scale(0.96); }
.utility-tool:focus-visible {
  outline: 2px solid rgba(230, 209, 154, 0.85);
  outline-offset: 2px;
}
.utility-tool[aria-pressed="true"] {
  background: rgba(184, 137, 46, 0.38);
  color: #F3E7C3;
}
.utility-lang {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.utility-type {
  font-weight: 700;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
}
.utility-type--sm { font-size: 0.72rem; opacity: 0.9; }
.utility-type--lg { font-size: 1.05rem; }
.utility-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}
@media (max-width: 639px) {
  .utility-tool {
    min-height: 2.5rem;
    min-width: 2.5rem;
  }
}

/* Home / section grids — keep pillar chips readable even if Tailwind purge misses utilities */
.m-grid {
  display: grid;
  gap: 0.75rem;
}
.m-grid > li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

/* ---------- Mobile layout ---------- */
@media (max-width: 639px) {
  :root { --gutter: 1rem; }
  main section.py-16 { padding-block: 3rem; }
  main section.py-14 { padding-block: 2.5rem; }
  main section.py-20 { padding-block: 3.5rem; }
  .text-display { font-size: 2rem; }

  /* 2-up grids (home: pillars, stats, archive tiles) */
  .m-grid > li, .m-grid > div, .m-grid > button, .m-grid > a { min-width: 0; }
  /* Only stretch a lone last item when the grid is 2 columns (not 3/5-up layouts). */
  .m-grid.grid-cols-2 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .m-grid > li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  .stat-card .text-display { font-size: 1.9rem; line-height: 1.2; }
  .stat-card .text-caption { font-size: 0.8rem; }
  .archive-tile { display: flex; flex-direction: column; justify-content: flex-start; }
  .archive-tile img { width: 1.6rem; height: 1.6rem; margin-bottom: 0.5rem; }
  .archive-tile span { font-size: 0.875rem; line-height: 1.5; }

  /* Gallery: two columns, compact captions */
  .masonry { columns: 2; column-gap: 0.625rem; }
  .masonry-item { margin-bottom: 0.625rem; border-radius: 0.875rem; }
  .masonry-item figcaption { padding: 0.6rem 0.7rem; }
  .masonry-item figcaption .eyebrow { font-size: 0.72rem; margin: 0; }
  .masonry-item figcaption .text-caption { display: none; }

  /* Horizontal scrollers keep a peek of the next card */
  [data-carousel] > * { width: 82%; }
  [data-carousel] { scroll-padding-inline: 1rem; }

  /* Tab / filter rows scroll instead of wrapping awkwardly */
  [role="tablist"] { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  [role="tablist"]::-webkit-scrollbar { display: none; }
  [role="tablist"] > * { flex-shrink: 0; }

  /* Lightbox fits the phone */
  .lightbox { padding: 0.5rem; }
  .lightbox > div { max-height: 94vh; padding: 0.875rem; }

  /* Footer: two link columns, tighter */
  footer .grid { gap: 2rem; }
  footer .py-12 { padding-block: 2.5rem; }
}

/* Safe areas (iPhone notch / home bar) */
@supports (padding: max(0px)) {
  footer > div:last-child > div { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
  .drawer { padding-bottom: env(safe-area-inset-bottom); }
}

@media (prefers-reduced-motion: reduce) {
  html.theme-switching, html.theme-switching * { transition: none !important; }
}

/* ---------- Filter pills & tabs: visible resting state in both themes ---------- */
[data-gallery-filter][aria-pressed="false"],
[role="tab"][aria-selected="false"] {
  background-color: var(--card) !important;
  border: 1px solid var(--line);
  color: inherit;
}
[data-gallery-filter][aria-pressed="false"]:hover,
[role="tab"][aria-selected="false"]:hover { border-color: #B5532E; }
@media (max-width: 639px) {
  :has(> [data-gallery-filter]) {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: -1rem;
    padding-inline: 1rem;
    padding-bottom: 0.25rem;
  }
  :has(> [data-gallery-filter])::-webkit-scrollbar { display: none; }
  [data-gallery-filter] { flex-shrink: 0; }
}

/* Decorative dune band: keep it from flashing light over dark heroes */
html.dark img[src*="dune-wave"] { opacity: 0.1 !important; }
