@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../../../assets/fonts/playfair-display-v40-latin-700.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../../../assets/fonts/source-sans-3-v19-latin-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../../../assets/fonts/source-sans-3-v19-latin-600.woff2") format("woff2");
}

:root {
  color-scheme: dark;
  --bg: #09110f;
  --bg-soft: #101a17;
  --panel: rgba(18, 29, 25, 0.92);
  --panel-strong: #15231e;
  --surface: rgba(244, 247, 239, 0.045);
  --surface-strong: rgba(244, 247, 239, 0.075);
  --ink: #f2f4ed;
  --muted: rgba(226, 231, 219, 0.72);
  --dim: rgba(226, 231, 219, 0.64);
  --rule: rgba(169, 200, 163, 0.22);
  --rule-strong: rgba(169, 200, 163, 0.42);
  --sage: #a9c8a3;
  --gold: #dfb65d;
  --gold-deep: #9b7627;
  --tca: #79d5d4;
  --tca-deep: #3f999e;
  --pioneer: #e2b565;
  --boundary: #d08073;
  --danger: #e18a7a;
  --radius: 10px;
  --shadow: 0 26px 78px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  max-width: 100%;
  overflow-x: clip;
  background: var(--bg);
}

body {
  min-height: 100vh;
  max-width: 100%;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 5%, rgba(121, 213, 212, 0.09), transparent 28rem),
    radial-gradient(circle at 88% 12%, rgba(223, 182, 93, 0.08), transparent 31rem),
    linear-gradient(180deg, #101916 0%, var(--bg) 58%, #060b09 100%);
  font-family: "Source Sans 3", system-ui, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
label,
input {
  touch-action: manipulation;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

.handshake-shell {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 70px;
}

.topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.back-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover {
  color: var(--ink);
}

.back-link:focus-visible,
.source-list a:focus-visible,
.site-footer a:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.tag-row span {
  padding: 5px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--sage);
  background: rgba(9, 17, 15, 0.62);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.hero {
  max-width: 1050px;
  margin: 74px 0 40px;
}

.eyebrow,
.section-kicker,
.stage-overline,
.summary-label,
.card-number {
  margin: 0;
  color: var(--gold);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: "Playfair Display", Georgia, serif;
}

h1 {
  max-width: 1000px;
  margin: 12px 0 0;
  font-size: clamp(2.8rem, 7.2vw, 6.4rem);
  line-height: 0.94;
  letter-spacing: -0.025em;
}

.lede {
  max-width: 900px;
  margin: 24px 0 0;
  color: var(--sage);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  line-height: 1.42;
}

.hero-note {
  max-width: 850px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.12rem);
}

.experiment,
.evidence-section {
  padding-top: 18px;
}

.section-heading {
  max-width: 860px;
  margin-bottom: 20px;
}

.section-heading h2,
.limits-and-sources h2 {
  margin: 6px 0 0;
  font-size: clamp(1.65rem, 3.2vw, 2.7rem);
  line-height: 1.08;
}

.section-heading > p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.instrument-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.68fr) minmax(315px, 0.82fr);
  grid-template-areas:
    "stage conditions"
    "stage details";
  gap: 12px 18px;
  align-items: stretch;
}

.stage-card,
.condition-card,
.control-card,
.reading-card,
.evidence-section,
.limits-and-sources article {
  min-width: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stage-card {
  grid-area: stage;
  padding: 18px;
}

.condition-card {
  grid-area: conditions;
  min-width: 0;
  padding: 20px;
}

.stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.stage-heading h3 {
  margin: 3px 0 0;
  font-size: clamp(1.45rem, 2.6vw, 2.2rem);
  line-height: 1;
}

.stage-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.round-button {
  display: inline-grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(7, 14, 11, 0.78);
  cursor: pointer;
}

.round-button span {
  font-size: 1rem;
  line-height: 1;
}

.round-button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(169, 200, 163, 0.18);
  border-radius: 8px 8px 0 0;
  background: #08100e;
}

#handshake-canvas {
  display: block;
  width: 100%;
  height: clamp(460px, 43vw, 610px);
  background: #08100e;
}

.canvas-error {
  min-height: 300px;
  margin: 0;
  padding: 34px;
  color: var(--muted);
  background: linear-gradient(145deg, rgba(121, 213, 212, 0.06), rgba(223, 182, 93, 0.05));
}

.canvas-caption {
  min-height: 50px;
  margin: 0;
  padding: 13px 15px;
  border: 1px solid rgba(169, 200, 163, 0.18);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  color: var(--muted);
  background: rgba(6, 12, 10, 0.75);
  font-size: 0.92rem;
}

.phase-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-top: 14px;
}

.phase-track::before {
  position: absolute;
  top: 18px;
  right: 7%;
  left: 7%;
  height: 1px;
  content: "";
  background: var(--rule);
}

.phase-button {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 0;
  min-height: 67px;
  padding: 7px 5px 8px;
  place-items: start center;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--dim);
  background: transparent;
  cursor: pointer;
}

.phase-button span {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  color: var(--muted);
  background: var(--panel-strong);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.62rem;
}

.phase-button strong {
  align-self: end;
  font-size: 0.79rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.phase-button.is-active {
  border-color: rgba(223, 182, 93, 0.5);
  color: var(--ink);
  background: rgba(223, 182, 93, 0.08);
}

.phase-button.is-active span {
  border-color: var(--gold);
  color: #101812;
  background: var(--gold);
}

.step-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 13px;
}

.secondary-button,
.primary-button {
  min-height: 45px;
  padding: 10px 14px;
  border-radius: 7px;
  font-weight: 600;
  cursor: pointer;
}

.secondary-button {
  border: 1px solid var(--rule-strong);
  color: var(--muted);
  background: var(--surface);
}

.primary-button {
  border: 1px solid var(--gold);
  color: #101812;
  background: var(--gold);
}

.secondary-button:disabled,
.primary-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.round-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.phase-button:hover {
  border-color: var(--gold);
  color: var(--ink);
}

.primary-button:hover:not(:disabled) {
  border-color: #f3ca76;
  background: #f3ca76;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.glossary-term {
  display: inline-flex;
  min-height: 32px;
  margin: -4px -2px;
  padding: 4px 2px;
  align-items: center;
  border: 0;
  border-bottom: 1px dotted rgba(169, 200, 163, 0.72);
  color: inherit;
  background: transparent;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  vertical-align: middle;
  cursor: help;
}

.glossary-term:hover {
  border-bottom-color: var(--gold);
  color: var(--gold);
}

.glossary-term:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.glossary-term-copy {
  font-weight: inherit;
}

.glossary-popover {
  position: fixed;
  z-index: 40;
  top: var(--glossary-top, 12px);
  left: var(--glossary-left, 12px);
  display: grid;
  width: max-content;
  max-width: min(310px, calc(100% - 24px));
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #101a17;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.glossary-popover strong {
  color: var(--gold);
  font-size: 0.88rem;
}

.glossary-popover span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.control-card {
  grid-area: details;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}

.condition-picker {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.condition-picker legend {
  margin-bottom: 10px;
  color: var(--gold);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.condition-option {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 76px;
  padding: 12px 12px 12px 14px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
}

.condition-option:hover {
  border-color: var(--rule-strong);
  background: var(--surface-strong);
}

.condition-option.is-selected {
  border-color: rgba(223, 182, 93, 0.72);
  color: var(--ink);
  background: rgba(223, 182, 93, 0.1);
}

.condition-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.condition-option:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.condition-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.condition-copy strong {
  color: inherit;
  line-height: 1.16;
}

.condition-copy small,
.toggle-control small {
  color: var(--dim);
  font-size: 0.8rem;
  line-height: 1.3;
}

.condition-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  color: var(--dim);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.72rem;
  font-weight: 700;
}

.condition-option.is-selected .condition-mark {
  border-color: var(--gold);
  color: #101812;
  background: var(--gold);
}

.live-summary {
  padding: 14px;
  border-left: 3px solid var(--tca);
  border-radius: 0 7px 7px 0;
  background: rgba(121, 213, 212, 0.065);
}

.live-summary p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.42;
}

.readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
}

.readout div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: rgba(6, 12, 10, 0.37);
}

.readout dt {
  color: var(--dim);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.readout dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.toggle-control {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink);
  cursor: pointer;
}

.toggle-control > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.toggle-control input {
  flex: 0 0 auto;
  width: 46px;
  height: 27px;
  accent-color: var(--gold);
  cursor: pointer;
}

.legend {
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.legend ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
}

.legend li {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.legend-line {
  height: 3px;
  border-radius: 999px;
}

.legend-tca {
  background: var(--tca);
  box-shadow: 0 0 10px rgba(121, 213, 212, 0.4);
}

.legend-pioneer {
  background: var(--pioneer);
  box-shadow: 0 0 10px rgba(226, 181, 101, 0.4);
}

.legend-dots {
  height: 8px;
  background: radial-gradient(circle, var(--sage) 0 2px, transparent 2.5px) 0 50% / 9px 8px repeat-x;
}

.condition-note {
  margin: auto 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
}

.reading-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.reading-card {
  padding: 22px;
}

.reading-card h2 {
  margin: 7px 0 0;
  font-size: clamp(1.35rem, 2.1vw, 1.85rem);
  line-height: 1.1;
}

.reading-card p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.evidence-section {
  margin-top: 54px;
  padding: 26px;
}

.evidence-timeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--rule);
  list-style: none;
  counter-reset: evidence;
}

.evidence-timeline li {
  min-width: 0;
  padding: 20px;
  background: #101a17;
}

.evidence-timeline span {
  display: block;
  color: var(--gold);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.75rem;
  font-weight: 700;
}

.evidence-timeline strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.evidence-timeline p {
  margin: 8px 0 0;
  color: var(--muted);
}

.limits-and-sources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.limits-and-sources article {
  padding: 24px;
}

.limits-and-sources article > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.source-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.source-list a {
  color: var(--sage);
  text-decoration-color: rgba(169, 200, 163, 0.38);
  text-underline-offset: 3px;
}

.source-list a:hover {
  color: var(--gold);
}

.generation-note {
  width: min(100% - 28px, 1320px);
  margin: 34px auto 0;
  color: var(--dim);
  font-family: var(--mono, ui-monospace), monospace;
  font-size: 0.76rem;
  text-align: center;
}

.site-footer {
  display: grid;
  justify-items: center;
  gap: 15px;
  margin-top: 28px;
  padding: 50px 20px 42px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  text-align: center;
}

.footer-logo img {
  display: block;
  width: 138px;
  height: auto;
  opacity: 0.94;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
}

.site-footer nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer nav a:hover {
  color: var(--ink);
}

.site-footer p {
  margin: 0;
  color: var(--dim);
  font-size: 0.88rem;
}

@media (max-width: 1040px) {
  .instrument-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "conditions"
      "stage"
      "details";
  }

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

  .control-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

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

  .condition-picker legend {
    grid-column: 1 / -1;
  }

  .condition-note {
    grid-column: 1 / -1;
  }

  .condition-option {
    min-height: 104px;
    align-content: start;
  }

  .legend,
  .toggle-control {
    min-height: 100%;
  }
}

@media (max-width: 760px) {
  .instrument-grid.has-mobile-condition {
    grid-template-areas:
      "stage"
      "details";
  }

  .handshake-shell {
    width: min(100% - 28px, 1320px);
  }

  .hero {
    margin-top: 54px;
  }

  .reading-grid,
  .evidence-timeline,
  .limits-and-sources {
    grid-template-columns: 1fr;
  }

  .evidence-section {
    padding: 20px;
  }

  .control-card {
    grid-template-columns: 1fr;
  }

  .condition-note {
    grid-column: auto;
  }

  .condition-card {
    align-self: start;
    padding: 12px;
    background: rgba(18, 29, 25, 0.97);
  }

  .stage-card > .condition-card {
    margin: -5px -5px 14px;
  }

  .condition-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .condition-picker legend {
    grid-column: 1 / -1;
    margin-bottom: 5px;
  }

  .condition-option {
    display: flex;
    min-height: 88px;
    padding: 8px 5px;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
  }

  .condition-copy strong {
    font-size: 0.8rem;
    line-height: 1.12;
  }

  .condition-copy small {
    display: none;
  }

  .condition-mark {
    width: 28px;
    height: 28px;
  }

  #handshake-canvas {
    height: 450px;
  }
}

@media (max-width: 540px) {
  .handshake-shell {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .topline {
    align-items: flex-start;
  }

  .tag-row {
    max-width: 72%;
  }

  .hero {
    margin: 44px 0 30px;
  }

  h1 {
    font-size: clamp(2.55rem, 14vw, 4rem);
    overflow-wrap: break-word;
  }

  .lede {
    font-size: 1.12rem;
  }

  .stage-card,
  .condition-card,
  .control-card,
  .reading-card,
  .limits-and-sources article {
    padding: 15px;
  }

  .condition-card {
    padding: 10px;
  }

  #handshake-canvas {
    height: 390px;
  }

  .canvas-caption {
    min-height: 58px;
    font-size: 0.84rem;
  }

  .phase-track {
    gap: 3px;
  }

  .phase-button {
    min-height: 63px;
    padding-inline: 2px;
  }

  .phase-button strong {
    font-size: 0.67rem;
  }

  .step-actions {
    grid-template-columns: 1fr;
  }

  .readout dd {
    font-size: 0.78rem;
  }

  .evidence-section {
    padding: 16px;
  }

  .glossary-term {
    min-width: 44px;
    min-height: 44px;
    margin: -10px -4px;
    padding: 10px 4px;
    justify-content: center;
  }
}

@media (max-width: 390px) {
  #handshake-canvas {
    height: 365px;
  }

  .tag-row span:last-child {
    display: none;
  }

  .readout {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
