:root {
  color-scheme: light;
  --paper: #f6f1e8;
  --paper-warm: #fffaf0;
  --ink: #17211d;
  --muted: #66736d;
  --line: #d8d0bf;
  --green: #1f6b53;
  --green-dark: #123d34;
  --moss: #89a05d;
  --coral: #c85f4a;
  --gold: #c9993c;
  --blue: #2f6f92;
  --shadow: 0 22px 60px rgba(31, 42, 35, 0.16);
  --radius: 8px;
  --max: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 8%, rgba(201, 153, 60, 0.13), transparent 28rem),
    linear-gradient(180deg, var(--paper-warm), var(--paper));
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.6;
}

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

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(23, 33, 29, 0.1);
  background: rgba(255, 250, 240, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--green-dark);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  background: url("assets/phylogeny-icon.svg") center / contain no-repeat;
}

nav {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 3vw, 1.5rem);
  color: #304239;
  font-size: 0.95rem;
  font-weight: 700;
}

nav a {
  text-decoration: none;
}

nav a:hover {
  color: var(--coral);
}

.hero {
  position: relative;
  min-height: 92vh;
  display: grid;
  align-items: center;
  overflow: hidden;
  padding: clamp(5rem, 10vw, 8rem) clamp(1rem, 5vw, 4rem) clamp(2rem, 5vw, 4rem);
}

.hero-media,
.hero-overlay {
  position: absolute;
  inset: 0;
}

.hero-media {
  background-image: url("assets/phylo-hero.png");
  background-position: center;
  background-size: cover;
  transform: scale(1.02);
}

.hero-overlay {
  background:
    linear-gradient(90deg, rgba(246, 241, 232, 0.98) 0%, rgba(246, 241, 232, 0.86) 38%, rgba(246, 241, 232, 0.24) 72%),
    linear-gradient(180deg, rgba(23, 33, 29, 0.08), rgba(23, 33, 29, 0.18));
}

.hero-content,
.hero-stat {
  position: relative;
  z-index: 1;
}

.hero-content {
  width: min(710px, 100%);
}

.eyebrow,
.section-kicker,
.note-label {
  margin: 0 0 0.8rem;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 12ch;
  margin-bottom: 1rem;
  color: #14251d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.25rem, 8vw, 7.35rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 1rem;
  color: #17241f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0.45rem;
  font-size: 1.05rem;
  line-height: 1.25;
}

.hero-content p {
  max-width: 62ch;
  color: #2d3e36;
  font-size: clamp(1.05rem, 1.5vw, 1.28rem);
}

.hero-content .byline {
  margin: -0.35rem 0 1.1rem;
  color: var(--coral);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  font-weight: 900;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.8rem;
}

.button,
button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  text-decoration: none;
}

.button.primary {
  background: var(--green-dark);
  color: #fffdf7;
  box-shadow: 0 12px 30px rgba(18, 61, 52, 0.22);
}

.button.ghost {
  border-color: rgba(18, 61, 52, 0.28);
  background: rgba(255, 250, 240, 0.64);
  color: var(--green-dark);
}

.hero-stat {
  align-self: end;
  width: min(430px, 100%);
  margin-top: clamp(3rem, 10vw, 6rem);
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--coral);
  background: rgba(255, 250, 240, 0.78);
  box-shadow: var(--shadow);
}

.hero-stat strong,
.hero-stat span {
  display: block;
}

.hero-stat strong {
  margin-bottom: 0.25rem;
  color: var(--green-dark);
}

.hero-stat span {
  color: #34473f;
}

.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(4rem, 8vw, 7rem) clamp(1rem, 4vw, 2rem);
}

.intro-grid,
.method-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

.intro-grid > div:first-child p,
.split-heading p,
.method-layout > div p {
  max-width: 66ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.principles,
.evidence-grid,
.concept-grid,
.quiz-grid,
.specimen-layout {
  display: grid;
  gap: 1rem;
}

.principles {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.principles article,
.evidence-grid article,
.quiz-card,
.lab-notes {
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.78);
  box-shadow: 0 14px 34px rgba(38, 48, 42, 0.08);
}

.principles article,
.evidence-grid article,
.quiz-card {
  padding: 1.15rem;
}

.principles p,
.evidence-grid p,
.concept-grid p,
.quiz-card p,
.method-steps li,
.glossary dd {
  color: var(--muted);
}

.number {
  display: inline-block;
  margin-bottom: 2rem;
  color: var(--gold);
  font-weight: 900;
}

.tree-lab {
  max-width: 1320px;
}

.split-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.split-heading h2 {
  max-width: 12ch;
  margin-bottom: 0;
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 380px);
  gap: 1rem;
  align-items: stretch;
}

.tree-panel {
  position: relative;
  min-height: 420px;
  overflow: visible;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 250, 240, 0.92), rgba(255, 250, 240, 0.92)),
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(31, 107, 83, 0.08) 34px 35px),
    repeating-linear-gradient(90deg, transparent 0 33px, rgba(31, 107, 83, 0.08) 34px 35px);
  box-shadow: var(--shadow);
}

.phylo-svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.branch {
  fill: none !important;
  stroke: #31564b;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 7;
  transition: stroke 180ms ease, stroke-width 180ms ease, opacity 180ms ease;
}

.node {
  pointer-events: none;
  fill: var(--paper-warm);
  stroke: var(--green);
  stroke-width: 4;
  transition: fill 180ms ease, stroke 180ms ease, transform 180ms ease;
  transform-box: fill-box;
  transform-origin: center;
}

.node-hit {
  cursor: pointer;
  fill: transparent;
  stroke: transparent;
  outline: none;
  pointer-events: all;
  touch-action: manipulation;
}

.node-hit:focus-visible + .node,
.node.active-node {
  fill: var(--coral);
  stroke: var(--coral);
  transform: scale(1.25);
}

.tip-labels text {
  fill: #20342d;
  font-size: 25px;
  font-weight: 800;
}

.trait-labels text {
  fill: var(--coral);
  font-size: 14px;
  font-weight: 900;
}

.phylo-svg.focus-mammals [data-group="mammals"],
.phylo-svg.focus-amniotes [data-group="amniotes"],
.phylo-svg.focus-amniotes [data-group="mammals"],
.phylo-svg.focus-amniotes [data-group="sauropsids"],
.phylo-svg.focus-lamprey [data-group="lamprey"],
.phylo-svg.focus-traits .trait-labels text,
.phylo-svg.focus-traits .node {
  stroke: var(--coral);
  fill: var(--coral);
  color: var(--coral);
}

.phylo-svg.focus-mammals .branch[data-group="mammals"],
.phylo-svg.focus-amniotes .branch[data-group="amniotes"],
.phylo-svg.focus-amniotes .branch[data-group="mammals"],
.phylo-svg.focus-amniotes .branch[data-group="sauropsids"],
.phylo-svg.focus-lamprey .branch[data-group="lamprey"],
.phylo-svg.focus-traits .branch {
  stroke: var(--coral);
  stroke-width: 9;
}

.phylo-svg.focus-traits .trait-labels text,
.phylo-svg.focus-mammals .tip-labels [data-group="mammals"],
.phylo-svg.focus-amniotes .tip-labels [data-group="mammals"],
.phylo-svg.focus-amniotes .tip-labels [data-group="sauropsids"],
.phylo-svg.focus-lamprey .tip-labels [data-group="lamprey"] {
  fill: var(--coral);
}

.phylo-svg .node-hit {
  fill: transparent !important;
  stroke: transparent !important;
}

.node-overlay {
  position: absolute;
  left: var(--overlay-x, 50%);
  top: var(--overlay-y, 50%);
  z-index: 3;
  width: min(310px, calc(100% - 2rem));
  padding: 1rem 1rem 1.05rem;
  border: 1px solid rgba(23, 33, 29, 0.16);
  border-left: 4px solid var(--coral);
  border-radius: var(--radius);
  background: rgba(255, 250, 240, 0.96);
  box-shadow: var(--shadow);
  transform: translate(-12%, -108%);
}

.node-overlay.align-left {
  transform: translate(-88%, -108%);
}

.node-overlay.below {
  transform: translate(-12%, 18%);
}

.node-overlay.below.align-left {
  transform: translate(-88%, 18%);
}

.node-overlay[hidden] {
  display: none;
}

.node-overlay-close {
  position: absolute;
  right: 0.45rem;
  top: 0.35rem;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green-dark);
  font-size: 1.25rem;
  line-height: 1;
}

.node-overlay-label {
  margin-bottom: 0.35rem;
  color: var(--coral);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.node-overlay h3 {
  margin-right: 1.4rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.node-overlay p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.lab-notes {
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.choice,
.reveal {
  padding: 0.65rem 0.75rem;
  background: #fffaf0;
  color: var(--green-dark);
  border-color: rgba(18, 61, 52, 0.18);
}

.choice:hover,
.reveal:hover,
.choice.active {
  background: var(--green-dark);
  color: #fffdf7;
}

.note-copy {
  padding: 1rem 0.2rem 0.2rem;
}

.note-copy h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  line-height: 1.05;
}

.note-copy p:last-child {
  color: var(--muted);
}

.specimen {
  padding-top: clamp(2rem, 4vw, 3rem);
}

.specimen-layout {
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
}

.specimen figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 29, 0.12);
  border-radius: var(--radius);
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.specimen img {
  display: block;
  width: 100%;
  background: #fff;
}

.specimen figcaption {
  padding: 0.95rem 1rem 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.specimen p {
  max-width: 62ch;
  color: var(--muted);
}

.concept-band {
  max-width: none;
  background: #16372f;
  color: #fffaf0;
}

.concept-band > * {
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
}

.concept-band h2 {
  color: #fffaf0;
}

.concept-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.3rem;
}

.concept-grid article {
  padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 250, 240, 0.28);
}

.concept-grid p {
  color: rgba(255, 250, 240, 0.78);
}

.evidence-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.evidence-icon {
  display: block;
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  color: var(--green);
  background: #fffdf7;
}

.evidence-icon.dna {
  background:
    radial-gradient(circle at 50% 22%, var(--coral) 0 3px, transparent 4px),
    radial-gradient(circle at 50% 78%, var(--coral) 0 3px, transparent 4px),
    linear-gradient(135deg, transparent 43%, currentColor 44% 47%, transparent 48% 52%, currentColor 53% 56%, transparent 57%);
}

.evidence-icon.bone {
  border-radius: 22px;
  background:
    radial-gradient(circle at 30% 34%, var(--gold) 0 6px, transparent 7px),
    radial-gradient(circle at 70% 66%, var(--gold) 0 6px, transparent 7px),
    linear-gradient(135deg, transparent 38%, currentColor 39% 49%, transparent 50%);
}

.evidence-icon.vestigial {
  background:
    radial-gradient(circle at 36% 55%, var(--gold) 0 5px, transparent 6px),
    radial-gradient(circle at 62% 42%, var(--coral) 0 4px, transparent 5px),
    linear-gradient(115deg, transparent 39%, currentColor 40% 47%, transparent 48%),
    linear-gradient(65deg, transparent 48%, currentColor 49% 55%, transparent 56%);
}

.evidence-icon.fossil {
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 54% 50%, transparent 0 11px, currentColor 12px 14px, transparent 15px),
    linear-gradient(90deg, transparent 47%, var(--coral) 48% 52%, transparent 53%);
}

.evidence-icon.map {
  background:
    radial-gradient(circle at 35% 35%, var(--blue) 0 7px, transparent 8px),
    radial-gradient(circle at 64% 62%, var(--gold) 0 5px, transparent 6px),
    linear-gradient(90deg, transparent 46%, currentColor 47% 52%, transparent 53%);
}

.method-steps {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.method-steps li {
  position: relative;
  padding: 1rem 1rem 1rem 3.4rem;
  border-left: 4px solid var(--moss);
  background: rgba(255, 250, 240, 0.68);
}

.method-steps li::before {
  position: absolute;
  left: 1rem;
  top: 1rem;
  counter-increment: step;
  content: counter(step);
  color: var(--coral);
  font-weight: 900;
}

.quiz-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quiz-card {
  min-height: 270px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.quiz-card h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.reveal {
  margin-top: auto;
}

.answer {
  display: none;
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.quiz-card.open .answer {
  display: block;
}

.glossary dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 0;
}

.glossary dl > div {
  padding: 1rem;
  border-top: 3px solid var(--gold);
  background: rgba(255, 250, 240, 0.66);
}

.glossary dt {
  margin-bottom: 0.3rem;
  color: var(--green-dark);
  font-weight: 900;
}

.glossary dd {
  margin: 0;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.3rem clamp(1rem, 4vw, 3rem);
  border-top: 1px solid rgba(23, 33, 29, 0.12);
  background: #17211d;
  color: rgba(255, 250, 240, 0.8);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: #fffaf0;
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 980px) {
  .hero {
    min-height: 84vh;
  }

  .hero-overlay {
    background:
      linear-gradient(180deg, rgba(246, 241, 232, 0.98) 0%, rgba(246, 241, 232, 0.86) 56%, rgba(246, 241, 232, 0.4) 100%);
  }

  .intro-grid,
  .method-layout,
  .lab-grid,
  .specimen-layout,
  .split-heading {
    grid-template-columns: 1fr;
    display: grid;
  }

  .principles,
  .evidence-grid,
  .concept-grid,
  .quiz-grid,
  .glossary dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-heading h2 {
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  .site-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 0.85rem 1rem;
  }

  .brand {
    white-space: normal;
  }

  nav {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  nav a {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding-right: 0.45rem;
  }

  h1 {
    max-width: 10ch;
  }

  .hero {
    min-height: 760px;
    padding-top: 3rem;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: min(100%, 360px);
  }

  .principles,
  .evidence-grid,
  .concept-grid,
  .quiz-grid,
  .glossary dl {
    grid-template-columns: 1fr;
  }

  .tree-panel,
  .phylo-svg {
    min-height: 360px;
  }

  .tip-labels text {
    font-size: 31px;
  }

  .trait-labels text {
    font-size: 16px;
  }

  .node-overlay {
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    width: auto;
    transform: none;
  }

  .choice-row {
    grid-template-columns: 1fr;
  }

  .site-footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
