/* ==========================================================================
   Manivannan Subramanian — The Human Impact Archive
   global.css · tokens, base typography, header, footer, layout primitives
   ========================================================================== */

:root {
  /* Palette */
  --forest: #183c35;
  --forest-deep: #102924;
  --forest-night: #0f2622;
  --forest-soft: #23504a;
  --mineral: #52766b;
  --mineral-ink: #3d5c53;
  --sienna: #b66e4d;
  --sienna-ink: #8c4b2f;
  --sienna-light: #e3a584;
  --almond: #ede2d1;
  --almond-soft: #f5eee3;
  --paper: #fbf8f2;
  --bluegrey: #b9c8cc;
  --bluegrey-soft: #dde6e8;
  --charcoal: #252a29;
  --charcoal-soft: #4a514f;
  --white: #ffffff;

  --rule: rgba(37, 42, 41, 0.16);
  --rule-strong: rgba(37, 42, 41, 0.42);
  --rule-light: rgba(237, 226, 209, 0.22);

  /* Type */
  --font-display: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --font-body: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Spline Sans Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: clamp(0.8rem, 0.78rem + 0.1vw, 0.86rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.09rem);
  --step-1: clamp(1.15rem, 1.08rem + 0.35vw, 1.32rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.7rem, 1.4rem + 1.3vw, 2.45rem);
  --step-4: clamp(2.1rem, 1.6rem + 2.2vw, 3.4rem);
  --step-5: clamp(2.5rem, 1.7rem + 3.4vw, 4.6rem);

  /* Space & layout */
  --gutter: clamp(1rem, 0.6rem + 2vw, 2.5rem);
  --section: clamp(4rem, 3rem + 5vw, 7.5rem);
  --max: 1320px;
  --measure: 66ch;
  --header-h: 72px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--charcoal);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.7;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4, p, figure, blockquote, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; }

a { color: inherit; }

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

::selection { background: var(--sienna); color: var(--white); }

:focus-visible {
  outline: 3px solid var(--sienna);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 200;
  padding: 0.7rem 1.1rem;
  background: var(--almond);
  color: var(--forest);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

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

/* ---------- Typography ---------- */
.display,
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--forest);
  text-wrap: balance;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); line-height: 1.25; }
h4 {
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 650;
  line-height: 1.4;
  color: var(--forest);
}

em, i { font-style: italic; }
h1 em, h2 em, h3 em { font-style: italic; font-weight: 400; color: var(--sienna-ink); }

p + p { margin-top: 1.1em; }

.lede {
  font-size: var(--step-1);
  line-height: 1.6;
  color: var(--charcoal);
  max-width: 58ch;
}

.prose { max-width: var(--measure); }
.prose p { color: var(--charcoal); }
.prose a,
.text-link {
  color: var(--sienna-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease);
}
.prose a:hover,
.text-link:hover { color: var(--forest); }

/* Archival label: small mono caps */
.label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mineral-ink);
}
.label::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
}
.label--plain::before { display: none; }
.on-dark .label { color: var(--bluegrey); }

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

.section { padding-block: var(--section); }
.section--tight { padding-block: calc(var(--section) * 0.6); }

.on-dark {
  background: var(--forest);
  color: var(--almond-soft);
}
.on-dark h1, .on-dark h2, .on-dark h3, .on-dark h4 { color: var(--white); }
.on-dark h1 em, .on-dark h2 em, .on-dark h3 em { color: var(--sienna-light); }
.on-dark p { color: var(--almond-soft); }
.on-dark .text-link, .on-dark .prose a { color: var(--sienna-light); }
.on-dark .text-link:hover, .on-dark .prose a:hover { color: var(--white); }
.on-dark :focus-visible { outline-color: var(--sienna-light); }

.bg-almond { background: var(--almond); }
.bg-almond-soft { background: var(--almond-soft); }
.bg-bluegrey { background: var(--bluegrey-soft); }

/* ==========================================================================
   Header — sticky forest bar with tab-marked active page
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--forest);
  color: var(--almond-soft);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  transition: box-shadow 0.3s var(--ease);
}
.site-header.is-scrolled { box-shadow: 0 10px 30px -18px rgba(8, 20, 17, 0.7); }

.site-header__bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.wordmark {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-decoration: none;
  color: var(--white);
  line-height: 1.1;
  padding-block: 0.6rem;
  flex-shrink: 0;
}
.wordmark__name {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 500;
  letter-spacing: 0;
}
.wordmark__name i { color: var(--sienna-light); font-weight: 400; }
.wordmark__tag {
  margin-top: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bluegrey);
}

.primary-nav { display: flex; }
.primary-nav__list {
  display: flex;
  align-items: stretch;
  list-style: none;
  gap: 0.15rem;
}
.primary-nav__list li { display: flex; }

.primary-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 0.62rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--almond-soft);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.primary-nav__link::before {
  content: "";
  position: absolute;
  left: 0.62rem;
  right: 0.62rem;
  top: 0;
  height: 4px;
  background: var(--sienna);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.25s var(--ease);
}
.primary-nav__link:hover { color: var(--white); background: rgba(255, 255, 255, 0.05); }
.primary-nav__link:hover::before { transform: scaleY(0.5); }
.primary-nav__link[aria-current="page"] { color: var(--white); }
.primary-nav__link[aria-current="page"]::before { transform: scaleY(1); }
.primary-nav__link:focus-visible { outline-offset: -4px; outline-color: var(--sienna-light); }

.primary-nav__desc { display: none; }

.menu-toggle {
  display: none;
  align-self: center;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  padding: 0.5rem 0.95rem;
  background: transparent;
  border: 1px solid var(--rule-light);
  color: var(--white);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.menu-toggle:hover { border-color: var(--sienna-light); }
.menu-toggle__icon {
  position: relative;
  width: 18px;
  height: 10px;
}
.menu-toggle__icon::before,
.menu-toggle__icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  transition: transform 0.3s var(--ease), top 0.3s var(--ease);
}
.menu-toggle__icon::before { top: 0; }
.menu-toggle__icon::after { top: 8px; width: 70%; }
.menu-toggle[aria-expanded="true"] .menu-toggle__icon::before { top: 4px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__icon::after { top: 4px; width: 100%; transform: rotate(-45deg); }
.menu-toggle:focus-visible { outline-color: var(--sienna-light); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--forest-night);
  color: var(--almond-soft);
  padding-top: clamp(3.5rem, 2.5rem + 4vw, 6rem);
}
.site-footer a { color: var(--almond-soft); }
.site-footer :focus-visible { outline-color: var(--sienna-light); }

.footer-top {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 1rem + 3vw, 4rem);
  padding-bottom: clamp(2.5rem, 2rem + 2vw, 4rem);
  border-bottom: 1px solid var(--rule-light);
}

.footer-sig__name {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 500;
  line-height: 1.1;
  color: var(--white);
}
.footer-sig__name i { color: var(--sienna-light); font-weight: 400; }
.footer-sig p:not(.footer-sig__name) {
  margin-top: 1rem;
  max-width: 40ch;
  color: var(--bluegrey);
  font-size: 0.95rem;
}

.footer-col h2 {
  margin-bottom: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sienna-light);
}

.footer-links {
  list-style: none;
  columns: 2;
  column-gap: 1.5rem;
}
.footer-links li { break-inside: avoid; }
.footer-links a {
  display: inline-block;
  padding: 0.3rem 0;
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.footer-links a:hover { color: var(--white); border-color: var(--sienna-light); }

.footer-contact { font-style: normal; font-size: 0.95rem; }
.footer-contact p { color: var(--almond-soft); }
.footer-contact p + p { margin-top: 0.35rem; }
.footer-contact .who { color: var(--white); font-weight: 600; }
.footer-contact a {
  text-decoration: underline;
  text-decoration-color: rgba(227, 165, 132, 0.5);
  text-underline-offset: 0.22em;
  overflow-wrap: anywhere;
}
.footer-contact a:hover { color: var(--white); text-decoration-color: var(--sienna-light); }

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.5rem;
  list-style: none;
}
.social__item {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--rule-light);
  background: transparent;
  color: var(--almond-soft);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.social__item svg { width: 18px; height: 18px; fill: currentColor; }
.social__item:hover,
.social__item:focus-visible { background: var(--almond); border-color: var(--almond); color: var(--forest); }
.social__item[aria-disabled="true"] { cursor: help; }
.social-note {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: var(--bluegrey);
  min-height: 1.3em;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem 2rem;
  padding-block: 1.6rem;
  font-size: 0.86rem;
  color: var(--bluegrey);
}
.footer-bottom p { color: var(--bluegrey); margin: 0; }
.footer-bottom a { color: var(--almond-soft); text-underline-offset: 0.2em; }
.footer-bottom a:hover { color: var(--white); }
.footer-bottom__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.4rem; }

.lock-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.3rem 0.75rem;
  background: transparent;
  border: 1px solid var(--rule-light);
  color: var(--almond-soft);
  font-size: 0.82rem;
  cursor: pointer;
}
.lock-button:hover { border-color: var(--sienna-light); color: var(--white); }
.lock-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ==========================================================================
   Reveal motion — only when JS is active and motion is allowed
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  }
  .js .reveal.is-visible { opacity: 1; transform: none; }
  .js .reveal[data-delay="1"] { transition-delay: 0.08s; }
  .js .reveal[data-delay="2"] { transition-delay: 0.16s; }
  .js .reveal[data-delay="3"] { transition-delay: 0.24s; }

  main { animation: page-in 0.6s var(--ease) both; }
  @keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
}

@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;
  }
}

/* ---------- Spacing utilities ---------- */
.mt-1 { margin-top: 1.1rem; }
.mt-2 { margin-top: 1.5rem; }
.mt-3 { margin-top: 2.2rem; }
.mt-4 { margin-top: 3rem; }
.small-print { font-size: 0.92rem; }
