/*
  Good Way: editorial / research-institute design system.
  Tokens ported 1:1 from the global-warming-api reference (src/index.css):
  warm paper + ink in light mode, deep slate in dark mode,
  one restrained accent (deep teal); ochre only as a tiny detail.
*/

/* ---------- Tokens ---------- */
:root {
  --font-sans: 'Manrope', ui-sans-serif, system-ui, sans-serif;
  --font-serif: 'Source Serif 4', ui-serif, Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --background: oklch(0.985 0.004 85);
  --foreground: oklch(0.2 0.015 250);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.2 0.015 250);
  --primary: oklch(0.36 0.06 195);
  --primary-foreground: oklch(0.985 0.004 85);
  --secondary: oklch(0.955 0.008 85);
  --muted: oklch(0.95 0.007 85);
  --muted-foreground: oklch(0.48 0.015 250);
  --accent: oklch(0.94 0.02 195);
  --accent-foreground: oklch(0.3 0.06 195);
  --border: oklch(0.9 0.008 85);
  --ring: oklch(0.55 0.06 195);
  --chart-2: oklch(0.68 0.13 70); /* ochre: detail only */

  --radius: 0.5rem;
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-md: calc(var(--radius) * 0.8);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) * 1.4);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 4rem;
}

.dark {
  --background: oklch(0.17 0.012 250);
  --foreground: oklch(0.94 0.006 85);
  --card: oklch(0.21 0.014 250);
  --card-foreground: oklch(0.94 0.006 85);
  --primary: oklch(0.8 0.08 190);
  --primary-foreground: oklch(0.18 0.02 250);
  --secondary: oklch(0.25 0.014 250);
  --muted: oklch(0.24 0.012 250);
  --muted-foreground: oklch(0.7 0.012 250);
  --accent: oklch(0.28 0.03 195);
  --accent-foreground: oklch(0.9 0.04 190);
  --border: oklch(1 0 0 / 10%);
  --ring: oklch(0.65 0.06 190);
  --chart-2: oklch(0.8 0.13 75);
}

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

html {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: clip;
}

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

h1,
h2,
h3,
p,
ul,
dl,
dd {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

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

main:focus {
  outline: none;
}

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

.icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-xs {
  width: 0.75rem;
  height: 0.75rem;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 80rem; /* max-w-7xl */
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 640px) {
  .container {
    padding-inline: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-inline: 2rem;
  }
}

/* ---------- Typography helpers ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.section-title {
  margin-top: 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.875rem;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

@media (min-width: 768px) {
  .section-title {
    font-size: 2.25rem;
  }
  .section-title-lg {
    font-size: 3rem;
  }
}

.prose {
  max-width: 65ch;
  font-size: 1.0625rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.prose > * + * {
  margin-top: 1.25rem;
}

.prose-lead {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.5;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding-inline: 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: color-mix(in oklch, var(--primary) 90%, transparent);
}

.btn-outline {
  background: var(--background);
  border-color: var(--border);
  color: var(--foreground);
}

.dark .btn-outline {
  background: color-mix(in oklch, var(--foreground) 3%, transparent);
}

.btn-outline:hover {
  background: var(--muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--foreground);
  transition: background-color 0.15s;
}

.icon-btn:hover {
  background: var(--muted);
}

.cta-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .cta-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 60;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--foreground);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 70%, transparent);
  background: color-mix(in oklch, var(--background) 85%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .site-header {
    background: color-mix(in oklch, var(--background) 70%, transparent);
  }
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-h);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-logo {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: 0.125rem;
}

.nav-desktop a,
.nav-mobile a {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}

.nav-desktop a:hover,
.nav-mobile a:hover {
  color: var(--foreground);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.header-cta {
  display: none;
  height: 2.25rem;
  padding-inline: 1rem;
  margin-left: 0.5rem;
  font-size: 0.875rem;
}

/* Theme toggle: show the icon of the mode you would switch to */
.icon-sun,
.dark .icon-moon {
  display: none;
}
.dark .icon-sun {
  display: block;
}

/* Mobile menu */
.menu-toggle .icon-close,
.menu-toggle[aria-expanded='true'] .icon-open {
  display: none;
}
.menu-toggle[aria-expanded='true'] .icon-close {
  display: block;
}

.nav-mobile {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.nav-mobile a {
  display: flex;
  width: 100%;
  padding-block: 0.625rem;
  font-size: 1rem;
  white-space: normal;
}

.nav-mobile[hidden] {
  display: none;
}

/* Without JavaScript: no toggle buttons; the mobile list is always visible
   and the header scrolls away instead of covering half the screen. */
html:not(.js) .theme-toggle,
html:not(.js) .menu-toggle {
  display: none;
}
html:not(.js) .site-header {
  position: static;
}

@media (min-width: 1120px) {
  .nav-desktop {
    display: flex;
  }
  .header-cta {
    display: inline-flex;
  }
  .menu-toggle,
  .nav-mobile {
    display: none !important;
  }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
}

/* Twinkling stars: four-point sparkles echoing the logo's star */
.hero-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero-stars span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--s) * 1.6);
  height: calc(var(--s) * 1.6);
  background: var(--primary);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  opacity: 0.15;
  animation: twinkle var(--p, 4s) ease-in-out var(--t, 0s) infinite;
}

@media (max-width: 767.98px) {
  .hero-stars span:nth-child(odd) {
    display: none;
  }
}

.hero-stars span.warm {
  background: var(--chart-2);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.12; transform: scale(0.7) rotate(0deg); }
  50% { opacity: 0.75; transform: scale(1.2) rotate(20deg); }
}

.hero-grid {
  position: relative;
  display: grid;
  gap: 3rem;
  padding-top: 4rem;
  padding-bottom: 3.5rem;
}

@media (min-width: 768px) {
  .hero-grid {
    padding-top: 6rem;
  }
}

@media (min-width: 1024px) {
  .hero-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: end;
    padding-bottom: 5rem;
  }
  .hero-copy {
    grid-column: span 7 / span 7;
  }
  .hero-media {
    grid-column: 9 / span 4;
  }
}

.hero-title {
  margin-top: 1.25rem;
  font-family: var(--font-serif);
  font-size: 2.4rem;
  line-height: 1.05;
  font-weight: 600;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

@media (min-width: 640px) {
  .hero-title {
    font-size: 3rem;
  }
}

@media (min-width: 1024px) {
  .hero-title {
    font-size: 4.25rem;
  }
}

.lead {
  margin-top: 1.5rem;
  max-width: 42rem;
  font-size: 1.125rem;
  line-height: 1.625;
  color: var(--muted-foreground);
  text-wrap: pretty;
}

.lead-secondary {
  margin-top: 1rem;
  font-family: var(--font-serif);
  font-style: italic;
}

@media (min-width: 768px) {
  .lead {
    font-size: 1.25rem;
  }
}

.hero .cta-row {
  margin-top: 2.25rem;
}

.portrait {
  width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  object-fit: cover;
  object-position: 50% top;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--muted);
}

@media (max-width: 1023.98px) {
  .hero-media {
    max-width: 26rem;
  }
}

/* ---------- Quick facts (hairline gap-px grid) ---------- */
.facts {
  padding-bottom: 4rem;
}

.facts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--border);
}

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

.fact {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--card);
}

@media (min-width: 1024px) {
  .fact {
    padding: 1.5rem;
  }
}

.fact-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.fact-label::before {
  /* the one ochre detail */
  content: '';
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  margin-right: 0.5rem;
  border-radius: 999px;
  background: var(--chart-2);
  vertical-align: 0.1em;
}

.fact > dd {
  margin-top: 0.75rem;
}

.fact-value {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.fact-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.tags li {
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.25rem;
}

/* ---------- Content bands ---------- */
.band {
  border-top: 1px solid var(--border);
  scroll-margin-top: 5rem;
}

.band-muted {
  background: color-mix(in oklch, var(--muted) 30%, transparent);
}

.band-grid {
  display: grid;
  gap: 2rem;
  padding-block: 5rem;
}

@media (min-width: 768px) {
  .band-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 2.5rem;
    padding-block: 7rem;
  }
  .band-aside {
    grid-column: span 4 / span 4;
  }
  .band-body {
    grid-column: span 8 / span 8;
  }
}

@media (min-width: 1024px) {
  .band-aside {
    position: sticky;
    top: 6rem;
    align-self: start;
  }
}

/* Qualifications: clean two-column hairline list */
.prose .quals {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 2rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.5;
}

@media (min-width: 560px) and (max-width: 767.98px), (min-width: 1024px) {
  .prose .quals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.quals li {
  padding: 0.75rem 0 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.quals li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1.35rem;
  width: 0.375rem;
  height: 1px;
  background: var(--primary);
}

.prose .quals + p {
  margin-top: 1.5rem;
}

/* ---------- Contact ---------- */
.contact .band-body {
  align-self: end;
}

.location {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.location b {
  font-weight: 600;
  color: var(--foreground);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: color-mix(in oklch, var(--muted) 30%, transparent);
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
}

.credit a {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem; /* 24px minimum tap target */
  text-decoration: none;
}

.credit a:hover {
  color: var(--foreground);
  text-decoration: underline;
}

.heart {
  color: var(--chart-2); /* the ochre accent */
}

@media (min-width: 640px) {
  .credit::before {
    content: '·';
    margin-right: 0.75rem;
  }
}

.footer-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-block: 2rem;
}

@media (min-width: 640px) {
  .footer-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.5rem; /* 24px minimum tap target */
  text-decoration: none;
  overflow-wrap: anywhere;
}

.footer-links a:hover {
  color: var(--foreground);
  text-decoration: underline;
}

/* ---------- Reveal (fade + 12px rise, 0.5s, once) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.5s var(--ease-out) var(--d, 0s),
    transform 0.5s var(--ease-out) var(--d, 0s);
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .js [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero-stars span {
    animation: none;
    opacity: 0.25;
  }
}
