:root {
  --paper: #EEF0EA;
  --paper-2: #E2E6DD;
  --white: #FFFFFF;
  --ink: #1C2A29;
  --ink-soft: #4A5856;
  --turq: #12807A;
  --turq-deep: #0C5E5A;
  --pollen: #E0AC2E;
  --dusk: #2D3550;
  --dusk-2: #252C44;
  --mesa-far: #7A3B26;
  --mesa: #A8492A;
  --ground: #C46A3E;
  --line: #C9D0C6;
  --context: #A3ABA6;

  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.9rem;
  --step-0: 1.1875rem;
  --step-1: 1.375rem;
  --step-2: 1.75rem;
  --step-3: clamp(1.75rem, 3.4vw, 2.3rem);
  --step-4: clamp(2.75rem, 8vw, 5.6rem);

  --wrap: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
  --bar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar-h) + 12px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums;
  overflow-x: hidden;
}
@media (max-width: 480px) { body { font-size: 1.125rem; } }

img, svg { max-width: 100%; }
img { height: auto; display: block; }
a { color: var(--turq-deep); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--pollen); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.15; margin: 0; text-wrap: balance; }
p { margin: 0 0 1em; }
.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; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 50;
  background: var(--ink); color: #fff; padding: 8px 14px; font-family: var(--sans);
}
.skip:focus { left: 8px; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 40;
  background: var(--dusk);
  color: #F2F0E8;
  font-family: var(--sans);
  transition: box-shadow .2s ease;
}
.bar.is-scrolled { box-shadow: 0 1px 0 rgba(255,255,255,.08), 0 6px 18px rgba(20,24,40,.25); }
.bar__inner {
  max-width: var(--wrap); margin: 0 auto;
  min-height: var(--bar-h);
  padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.bar__name { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
.bar__nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 22px; }
.bar__nav a { color: #D9DCE6; text-decoration: none; font-size: 1.02rem; padding: 6px 0; display: inline-block; }
.bar__nav a:hover, .bar__nav a.is-current { color: #fff; text-decoration: underline; text-decoration-color: var(--pollen); text-decoration-thickness: 2px; }

.bar__toggle {
  display: none;
  align-items: center; gap: 10px;
  background: transparent; color: #fff;
  border: 1.5px solid rgba(255,255,255,.45); border-radius: 999px;
  font: 500 1rem var(--sans);
  padding: 7px 14px; min-height: 40px; cursor: pointer;
}
.bar__toggle-lines, .bar__toggle-lines::before, .bar__toggle-lines::after {
  display: block; width: 16px; height: 2px; background: currentColor; border-radius: 2px;
  position: relative; transition: transform .2s ease, background .2s ease;
}
.bar__toggle-lines::before, .bar__toggle-lines::after { content: ""; position: absolute; left: 0; }
.bar__toggle-lines::before { top: -5px; }
.bar__toggle-lines::after { top: 5px; }
.bar__toggle[aria-expanded="true"] .bar__toggle-lines { background: transparent; }
.bar__toggle[aria-expanded="true"] .bar__toggle-lines::before { transform: translateY(5px) rotate(45deg); }
.bar__toggle[aria-expanded="true"] .bar__toggle-lines::after { transform: translateY(-5px) rotate(-45deg); }

@media (max-width: 860px) {
  .js .bar__toggle { display: inline-flex; }
  .js .bar__nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--dusk-2);
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 6px var(--gutter) 16px;
    display: none;
  }
  .js .bar.is-open .bar__nav { display: block; }
  .js .bar__nav ul { flex-direction: column; gap: 0; }
  .js .bar__nav a { display: block; padding: 12px 0; font-size: 1.15rem; border-bottom: 1px solid rgba(255,255,255,.08); }
  .js .bar__nav li:last-child a { border-bottom: 0; }
  /* no-JS fallback: links wrap under the name */
  html:not(.js) .bar__inner { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  html:not(.js) .bar__nav ul { flex-wrap: wrap; gap: 4px 16px; }
}

/* ---------- Hero ---------- */
.hero { position: relative; background: var(--dusk); color: #F2F0E8; overflow: hidden; }
.hero__inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(32px, 6vw, 80px) var(--gutter) clamp(130px, 19vw, 250px);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  position: relative; z-index: 2;
}
.hero h1 { font-size: var(--step-4); font-weight: 500; letter-spacing: -0.01em; line-height: 0.98; margin-bottom: 0.35em; }
.hero__role { font-family: var(--sans); font-size: var(--step-1); line-height: 1.3; color: var(--pollen); max-width: 30ch; margin-bottom: 1.1em; }
.hero__lede { font-size: var(--step-1); line-height: 1.45; max-width: 34ch; color: #E4E3DC; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 1.6em 0 0; }

.hero__photo { margin: 0; justify-self: end; width: min(100%, 380px); }
.hero__photo img {
  width: 100%;
  border-radius: 50% 50% 8px 8px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 30%;
  border: 6px solid var(--pollen);
}
.hero__land { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: clamp(110px, 18vw, 260px); z-index: 1; display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  font-family: var(--sans); font-weight: 700; font-size: 1.05rem;
  padding: 0.6em 1.25em;
  border-radius: 999px;
  border: 2px solid var(--turq);
  background: var(--turq); color: #fff;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--turq-deep); border-color: var(--turq-deep); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--light { background: var(--pollen); border-color: var(--pollen); color: var(--ink); }
.btn--light:hover { background: #EDC25A; border-color: #EDC25A; }
.btn--ghost { background: transparent; border-color: #C9CCD8; color: #fff; }
.btn--ghost:hover { background: rgba(255,255,255,0.08); border-color: #fff; }
.btn--small { font-size: 0.95rem; min-height: 40px; padding: 0.45em 1em; }

/* ---------- Sections ---------- */
.section {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: clamp(48px, 8vw, 104px) var(--gutter) 0;
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 24px clamp(24px, 5vw, 64px);
}
.section > h2 {
  font-size: var(--step-2);
  font-weight: 500;
  color: var(--turq-deep);
  padding-top: 0.5rem;
  border-top: 3px solid var(--pollen);
  align-self: start;
}
.section__body { min-width: 0; }
.prose { max-width: 66ch; }
.prose p:last-child { margin-bottom: 0; }
.sub-h { font-size: var(--step-2); font-weight: 500; margin: 2.2em 0 0.8em; }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.facts { background: var(--paper-2); padding: 22px 24px; border-radius: 6px; font-family: var(--sans); font-size: 1.05rem; line-height: 1.45; }
.facts h3 { font-size: 1.05rem; color: var(--ink-soft); font-weight: 500; margin-bottom: 0.4em; }
.facts h3 + ul { margin-bottom: 1.2em; }
.facts ul:last-child { margin-bottom: 0; }
.facts ul { list-style: none; margin: 0; padding: 0; }
.facts li { padding: 0.3em 0; border-bottom: 1px solid var(--line); }
.facts li:last-child { border-bottom: 0; }

/* Research */
.study-title { font-size: var(--step-3); font-weight: 500; max-width: 24ch; }
.study-sub { font-size: var(--step-1); font-style: italic; color: var(--ink-soft); margin: 0.35em 0 0.6em; max-width: 40ch; }
.study-meta { font-family: var(--sans); color: var(--ink-soft); margin-bottom: 2em; }
.research-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 48px); align-items: start; }

.figure { margin: 0; }
.figure figcaption { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); line-height: 1.4; margin-top: 0.7em; }
.spiro { width: 100%; height: auto; display: block; }

.question { margin: 2.5em 0; padding: 0 0 0 clamp(16px, 3vw, 32px); border-left: 6px solid var(--turq); max-width: 34ch; }
.question p { font-size: var(--step-2); font-style: italic; line-height: 1.3; margin-bottom: 0.4em; }
.question footer { font-family: var(--sans); color: var(--ink-soft); font-size: 1rem; }

/* Chart */
.chart { margin: 0; background: var(--white); border-radius: 8px; padding: clamp(16px, 3vw, 32px); max-width: 860px; }
.chart__title { font-size: var(--step-1); font-weight: 500; }
.chart__sub { font-family: var(--sans); color: var(--ink-soft); font-size: 1rem; margin: 0.2em 0 1em; }
.chart__plot { position: relative; width: 100%; min-height: 240px; }
.chart__plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__plot text { font-family: var(--sans); font-variant-numeric: lining-nums tabular-nums; }
.chart__tip {
  position: absolute; top: 0; pointer-events: none;
  background: var(--ink); color: #fff;
  font-family: var(--sans); font-size: 0.9rem; line-height: 1.35;
  padding: 8px 10px; border-radius: 6px;
  min-width: 150px;
  opacity: 0; transition: opacity .12s ease;
  font-variant-numeric: lining-nums tabular-nums;
}
.chart__tip.is-on { opacity: 1; }
.chart__tip b { display: block; margin-bottom: 4px; }
.chart__tip .row { display: flex; justify-content: space-between; gap: 14px; }
.chart__tip .row.is-hl { color: #8FE0D6; font-weight: 700; }
.chart__table { margin-top: 1em; font-family: var(--sans); font-size: 0.98rem; }
.chart__table summary { cursor: pointer; color: var(--turq-deep); font-weight: 500; min-height: 32px; display: inline-flex; align-items: center; }
.table-wrap { overflow-x: auto; margin-top: 0.6em; -webkit-overflow-scrolling: touch; }
.chart__table table { border-collapse: collapse; width: 100%; min-width: 420px; font-variant-numeric: lining-nums tabular-nums; }
.chart__table th, .chart__table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.chart__table th:first-child, .chart__table td:first-child { text-align: left; }
.chart__table thead th { color: var(--ink-soft); font-weight: 500; }
.chart__table tr.is-hl td { font-weight: 700; color: var(--turq-deep); }
.chart__note { color: var(--ink-soft); font-size: 0.9rem; margin: 0.8em 0 0; }
.chart__source { font-family: var(--sans); font-size: var(--step--1); color: var(--ink-soft); margin-top: 1em; }

/* History */
.history { list-style: none; margin: 0; padding: 0; max-width: 760px; }
.history li { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 16px; padding: 0.7em 0; border-top: 1px solid var(--line); }
.history li:last-child { border-bottom: 1px solid var(--line); }
.history__year { font-size: var(--step-1); color: var(--mesa); line-height: 1.3; font-variant-numeric: lining-nums; }
.history p { margin: 0; }
.history li:last-child .history__year { color: var(--turq-deep); font-weight: 700; }

/* Hypotheses + methods */
.hypotheses, .methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(20px, 3vw, 40px); max-width: 900px; }
.hypotheses h4, .methods h4 { font-size: var(--step-1); font-weight: 500; margin-bottom: 0.35em; }
.hypotheses p, .methods p { margin: 0; }
.methods > div { padding-top: 0.8em; border-top: 2px solid var(--turq); }

/* Phases */
.phases-intro { color: var(--ink-soft); margin: -0.4em 0 1.4em; }
.phases { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); counter-reset: phase; }
.phases li { counter-increment: phase; padding: 44px 18px 0 0; position: relative; }
.phases li::before {
  content: counter(phase);
  position: absolute; top: 0; left: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--turq); color: #fff;
  font-family: var(--sans); font-weight: 700; font-size: 0.95rem;
  display: grid; place-items: center;
  font-variant-numeric: lining-nums;
}
.phases li::after { content: ""; position: absolute; top: 14px; left: 36px; right: 6px; height: 2px; background: var(--line); }
.phases li:last-child::after { display: none; }
.phase__dine { display: block; font-size: var(--step-1); font-weight: 700; color: var(--turq-deep); line-height: 1.2; overflow-wrap: anywhere; }
.phase__en { display: block; font-style: italic; color: var(--ink-soft); margin-bottom: 0.4em; }
.phases p { font-size: 1.05rem; line-height: 1.45; margin: 0; }

/* Projects */
.project { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 20px; padding: 0 0 1.8em; margin-bottom: 1.8em; border-bottom: 1px solid var(--line); max-width: 860px; }
.project:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.project__year { font-size: var(--step-2); color: var(--mesa); line-height: 1.1; margin: 0; font-variant-numeric: lining-nums; }
.project__body { min-width: 0; }
.project h3 { font-size: var(--step-1); font-weight: 500; margin-bottom: 0.25em; }
.project__meta { font-family: var(--sans); color: var(--ink-soft); font-size: 1.02rem; margin-bottom: 0.8em; }
.project__body > p:last-child { margin-bottom: 0; }
.project__facts { margin: 1.2em 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.project__facts > div { padding: 0.7em 0; border-top: 1px solid var(--line); }
.project__facts dt { font-family: var(--sans); font-weight: 700; color: var(--turq-deep); font-size: 1rem; }
.project__facts dd { margin: 0.15em 0 0; font-size: 1.05rem; line-height: 1.45; }

/* Background */
.background { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px clamp(24px, 3.5vw, 44px); }
.background__more { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px clamp(24px, 3.5vw, 44px); }
.background h3 { font-size: var(--step-1); font-weight: 500; margin: 0 0 0.6em; }
.timeline, .plain { list-style: none; margin: 0; padding: 0; font-size: 1.05rem; line-height: 1.4; }
.timeline li { display: grid; grid-template-columns: 4.4rem minmax(0, 1fr); gap: 10px; padding: 0.6em 0; border-top: 1px solid var(--line); }
.timeline span { font-family: var(--sans); color: var(--mesa-far); font-variant-numeric: lining-nums; }
.timeline p { margin: 0; }
.timeline b { font-weight: 500; }
.plain li { padding: 0.6em 0; border-top: 1px solid var(--line); }

/* Collaborators */
.people { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 0 32px; max-width: 900px; }
.people li { padding: 0.8em 0; border-top: 1px solid var(--line); }
.people b { display: block; font-size: var(--step-1); font-weight: 500; }
.people span { font-family: var(--sans); color: var(--ink-soft); font-size: 1.02rem; line-height: 1.4; display: block; margin-top: 0.15em; }

/* Home */
.home { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
.home .prose p { font-size: var(--step-1); line-height: 1.5; }
.pending {
  aspect-ratio: 4 / 3; border: 2px dashed var(--line); border-radius: 6px;
  display: grid; place-items: center; text-align: center; padding: 20px;
  font-family: var(--sans); color: var(--ink-soft); background: var(--paper-2);
}

/* Contact */
.section--contact { padding-bottom: clamp(56px, 8vw, 104px); }
.contact { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
.contact__email { font-size: var(--step-2); margin-bottom: 0.5em; overflow-wrap: anywhere; }
.contact address { font-style: normal; color: var(--ink-soft); margin-bottom: 2em; }
.qr { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 20px; align-items: center; font-family: var(--sans); font-size: 1.02rem; line-height: 1.4; }
.qr__code { width: 140px; height: 140px; background: #fff; padding: 8px; border-radius: 6px; }
.qr__code svg { width: 100%; height: 100%; display: block; }

.note { background: var(--white); padding: clamp(18px, 3vw, 32px); border-radius: 8px; border-top: 6px solid var(--turq); font-family: var(--sans); min-width: 0; }
.note h3 { font-family: var(--serif); font-size: var(--step-2); font-weight: 500; margin-bottom: 0.3em; }
.note > p { color: var(--ink-soft); }
.note label { display: block; font-weight: 500; margin: 1em 0 0.3em; }
.note input[type="text"], .note input[type="email"], .note textarea {
  width: 100%; font: inherit; font-size: 1.05rem;
  min-height: 44px;
  padding: 0.6em 0.75em; border: 1.5px solid #B9C2B8; border-radius: 6px; background: var(--paper);
  color: var(--ink);
}
.note input:focus, .note textarea:focus { outline: 3px solid var(--pollen); outline-offset: 0; border-color: var(--turq); }
.note textarea { resize: vertical; }
.note .btn { margin-top: 1.2em; }
.note__status { margin: 0.8em 0 0; min-height: 1.4em; }
.note__status.is-ok { color: var(--turq-deep); }
.note__status.is-err { color: #A3341C; }
.hp { position: absolute; left: -9999px; }

/* Footer */
.foot {
  background: var(--dusk); color: #D9DCE6;
  padding: 22px max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter)));
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-family: var(--sans);
}
.foot p { margin: 0; }
.foot a { color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .section { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .section > h2 { justify-self: start; padding-right: 1.5rem; }
  .background__more { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phases { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 28px; }
  .phases li:nth-child(2)::after { display: none; }
}
@media (max-width: 720px) {
  .hero__inner { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .hero__photo { justify-self: start; width: min(62%, 240px); grid-row: 1; }
  .hero__photo img { border-width: 5px; }
  .hero__actions .btn { flex: 1 1 auto; }
  .about, .research-grid, .hypotheses, .methods, .home, .contact, .background, .background__more, .project__facts { grid-template-columns: minmax(0, 1fr); }
  .figure--spiro { max-width: 260px; }
  .phases { grid-template-columns: minmax(0, 1fr); row-gap: 22px; }
  .phases li { padding: 0 0 0 46px; }
  .phases li::after { top: 36px; bottom: -18px; left: 14px; right: auto; width: 2px; height: auto; display: block; }
  .phases li:nth-child(2)::after { display: block; }
  .phases li:last-child::after { display: none; }
  .project { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .history li { grid-template-columns: 3.6rem minmax(0, 1fr); gap: 12px; }
  .chart { border-radius: 6px; margin-left: calc(var(--gutter) * -0.5); margin-right: calc(var(--gutter) * -0.5); }
}
@media (max-width: 400px) {
  .qr { grid-template-columns: minmax(0, 1fr); }
  .qr__code { width: 150px; height: 150px; }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media print {
  .bar, .hero__land, .hero__actions, .note, .skip, .chart__table summary { display: none; }
  .hero { background: none; color: var(--ink); }
  .hero__role, .hero__lede { color: var(--ink); }
}
