/* ==========================================================================
   AGOULMIM IZNAGUEN — Documentary Editorial Design System
   Colors strictly anchored to user specification:
   - Background: #fae9d5
   - Text: #1e2640 and #000000
   - Titles: #fae9d5 (set on #1e2640 architectural plaques for high contrast)
   ========================================================================== */

:root {
  --bg-sand: #fae9d5;
  --bg-sand-step: #f2dec4;
  --ink-navy: #1e2640;
  --ink-navy-hover: #141a2e;
  --ink-black: #000000;
  --title-cream: #fae9d5;

  --font-display: 'Franklin Gothic Heavy', 'Franklin Gothic Demi', 'Arial Black', 'Helvetica Neue', sans-serif;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --container-max: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
}

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

html {
  background-color: var(--bg-sand);
  color: var(--ink-black);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-sand);
  color: var(--ink-black);
  min-height: 100svh;
  overflow-wrap: anywhere;
  font-feature-settings: "kern" 1, "liga" 1;
}

/* Browser Surface Theming */
::selection {
  background-color: var(--ink-navy);
  color: var(--title-cream);
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-sand);
}

::-webkit-scrollbar-thumb {
  background: var(--ink-navy);
}

/* Media Reset */
img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
a {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: inherit;
}

a {
  color: var(--ink-navy);
  text-decoration: underline;
  text-underline-offset: 4px;
}

:focus-visible {
  outline: 3px solid var(--ink-navy);
  outline-offset: 3px;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  inset-inline-start: var(--gutter);
  background: var(--ink-navy);
  color: var(--title-cream);
  padding: 12px 20px;
  font-weight: 700;
  text-decoration: none;
  z-index: 1000;
  transition: top 180ms var(--ease-out);
}

.skip-link:focus {
  top: 12px;
  outline: 3px solid var(--ink-black);
}

/* Scroll Progress Bar */
.scroll-progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 4px;
  background-color: var(--ink-navy);
  transform-origin: 0% 50%;
  transform: scaleX(0);
  z-index: 200;
  pointer-events: none;
}

/* Layout Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-sand);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  padding-block: 10px;
}

.brand-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 0;
}

.brand-badge {
  background-color: var(--ink-navy);
  color: var(--title-cream);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(0.82rem, 2.5vw, 1.05rem);
  letter-spacing: 0.04em;
  padding: 10px 14px;
  line-height: 1.2;
}

.desktop-nav {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: 14px;
  color: var(--ink-navy);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out), color 150ms var(--ease-out);
}

.nav-link:active {
  transform: scale(0.97);
}

/* Mobile Menu Button */
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background-color: var(--ink-navy);
  color: var(--title-cream);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 150ms var(--ease-out);
}

.menu-toggle:active {
  transform: scale(0.95);
}

.menu-toggle .icon-close {
  display: none;
}

.menu-toggle[aria-expanded="true"] .icon-open {
  display: none;
}

.menu-toggle[aria-expanded="true"] .icon-close {
  display: block;
}

.mobile-menu {
  background-color: var(--ink-navy);
  color: var(--title-cream);
  padding-block: 16px 24px;
}

.mobile-nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding-inline: 14px;
  color: var(--title-cream);
  text-decoration: none;
  font-weight: 600;
  font-size: 1.05rem;
  background-color: rgba(250, 233, 213, 0.08);
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out);
}

.mobile-nav-link:active {
  transform: scale(0.98);
  background-color: rgba(250, 233, 213, 0.18);
}

/* ==========================================================================
   Architectural Title Plaques (Titles in #fae9d5 on #1e2640)
   ========================================================================== */
.title-plaque {
  display: inline-block;
  background-color: var(--ink-navy);
  color: var(--title-cream);
  padding: clamp(14px, 2.5vw, 22px) clamp(18px, 3.5vw, 36px);
  max-width: 100%;
}

.title-plaque h1,
.title-plaque h2,
.title-plaque h3 {
  color: var(--title-cream);
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hero-title-plaque {
  width: 100%;
  padding: clamp(18px, 3.5vw, 32px) clamp(18px, 4vw, 44px);
}

.hero-title-plaque h1 {
  font-size: clamp(1.75rem, 5.2vw, 4.25rem);
  letter-spacing: 0.01em;
}

.title-plaque h2 {
  font-size: clamp(1.35rem, 3.6vw, 2.5rem);
}

.title-plaque-sm {
  padding: 10px 18px;
  margin-bottom: 10px;
}

.title-plaque-sm h3 {
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  letter-spacing: 0.01em;
}

/* ==========================================================================
   Chapter Sections Rhythm
   ========================================================================== */
.chapter-section {
  padding-block: clamp(48px, 7vw, 110px);
}

.hero-section {
  padding-top: clamp(20px, 3.5vw, 48px);
}

.section-header {
  margin-bottom: clamp(24px, 3.5vw, 40px);
}

/* ==========================================================================
   Media Frames & Photography Grids
   ========================================================================== */
.single-media-showcase {
  margin-bottom: clamp(24px, 3.5vw, 36px);
}

.hero-emblem-frame {
  background-color: var(--bg-sand-step);
  padding: clamp(20px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-emblem-img {
  width: min(520px, 100%);
  aspect-ratio: 1 / 1;
  object-fit: contain;
  transition: transform 500ms var(--ease-out);
}

.dual-media-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(20px, 3vw, 32px);
  margin-bottom: clamp(24px, 3.5vw, 36px);
}

.media-frame {
  position: relative;
  background-color: var(--bg-sand-step);
  overflow: clip;
  cursor: zoom-in;
}

.landscape-frame img,
.dam-frame img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  transition: transform 500ms var(--ease-out);
}

.portrait-frame img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: top center;
  transition: transform 500ms var(--ease-out);
}

.sports-frame img {
  width: 100%;
  max-height: 700px;
  object-fit: cover;
  object-position: center;
  transition: transform 500ms var(--ease-out);
}

/* ==========================================================================
   Article Prose Bands (Under the Pictures)
   ========================================================================== */
.article-text-band {
  background-color: var(--bg-sand-step);
  padding: clamp(24px, 4vw, 44px);
}

.article-text-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.body-large {
  color: var(--ink-black);
  font-size: clamp(1.1rem, 1.65vw, 1.35rem);
  line-height: 1.68;
  max-width: 72ch;
}

.body-highlight {
  color: var(--ink-navy);
  font-weight: 700;
  font-size: clamp(1.15rem, 1.8vw, 1.4rem);
  line-height: 1.5;
  max-width: 68ch;
}

.body-regular {
  color: var(--ink-black);
  font-size: 1.08rem;
  line-height: 1.65;
  max-width: 68ch;
}

.body-regular + .body-regular {
  margin-top: 8px;
}

/* ==========================================================================
   Article 3: Tizgui Dam Construction & Financial Ledger
   ========================================================================== */
.dam-monograph-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(24px, 3.5vw, 40px);
  align-items: start;
}

.dam-narrative-col {
  background-color: var(--bg-sand-step);
  padding: clamp(24px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
}

.dam-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.stat-display {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2rem, 3.8vw, 2.8rem);
  color: var(--ink-navy);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.results-list {
  list-style: disc;
  padding-inline-start: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ink-black);
  font-size: 1.08rem;
}

.dam-ledger-col {
  min-width: 0;
}

.ledger-surface {
  background-color: var(--bg-sand-step);
  padding: clamp(24px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.ledger-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.ledger-row {
  width: 100%;
  background-color: var(--bg-sand);
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.ledger-name {
  color: var(--ink-black);
  font-size: 1.02rem;
  font-weight: 500;
}

.ledger-amount {
  color: var(--ink-navy);
  font-size: 1.12rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Footer / Last Paragraph Quote & Attribution
   ========================================================================== */
.site-footer {
  padding-top: clamp(40px, 6vw, 88px);
  padding-bottom: calc(clamp(48px, 7vw, 96px) + env(safe-area-inset-bottom, 0px));
}

.epilogue-card {
  background-color: var(--ink-navy);
  color: var(--title-cream);
  padding: clamp(32px, 6vw, 68px);
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4vw, 36px);
}

.epilogue-title-plaque {
  background-color: rgba(250, 233, 213, 0.1);
  padding: 12px 20px;
  align-self: flex-start;
}

.closing-quote {
  color: var(--title-cream);
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  line-height: 1.58;
  font-style: italic;
  max-width: 60ch;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
}

.powered-by {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  color: var(--title-cream);
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Lightbox Modal
   ========================================================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  overscroll-behavior: contain;
  touch-action: none;
}

.lightbox-modal[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(30, 38, 64, 0.94);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: min(1100px, 100%);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.lightbox-close {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  background-color: var(--bg-sand);
  color: var(--ink-navy);
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.lightbox-img {
  max-width: 100%;
  max-height: 75dvh;
  object-fit: contain;
  background-color: var(--bg-sand);
  padding: 8px;
}

.lightbox-caption {
  color: var(--title-cream);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
}

/* ==========================================================================
   404 Page & Primary Button
   ========================================================================== */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 12px 24px;
  background-color: var(--ink-navy);
  color: var(--title-cream);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out);
}

.primary-btn:active {
  transform: scale(0.97);
}

.not-found-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: var(--gutter);
}

.not-found-wrap {
  max-width: 600px;
  background-color: var(--bg-sand-step);
  padding: clamp(28px, 5vw, 56px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}

.not-found-text {
  font-size: 1.15rem;
  color: var(--ink-black);
}

/* ==========================================================================
   Hover Capabilities (Fine Pointer Only)
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
  .nav-link:hover {
    background-color: var(--bg-sand-step);
  }

  .primary-btn:hover {
    background-color: var(--ink-navy-hover);
  }

  .media-frame:hover img {
    transform: scale(1.025);
  }
}

/* ==========================================================================
   Tablet & Desktop Breakpoints (Mobile-First)
   ========================================================================== */
@media (min-width: 768px) {
  .dual-media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .desktop-nav {
    display: flex;
  }

  .menu-toggle,
  .mobile-menu {
    display: none !important;
  }

  .dam-monograph-layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@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;
  }
}
