:root {
  --ink: #0b0b0b;
  --paper: #f2f0e9;
  --red: #ed1c24;
  --blue: #0d5fa8;
  --yellow: #ffd91a;
  --line: 3px solid var(--ink);
  --max: 1500px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
}

a {
  color: inherit;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.18em;
}

a:focus-visible,
button:focus-visible {
  outline: 4px solid var(--yellow);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  left: 1rem;
  top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--yellow);
  border: var(--line);
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: stretch;
  border-bottom: var(--line);
  background: var(--paper);
}

.identity,
.language {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem;
  text-decoration: none;
}

.identity {
  flex-wrap: wrap;
}

.identity span {
  font-family: "Courier New", monospace;
}

.language {
  justify-content: center;
  min-width: 64px;
  border-left: var(--line);
  background: var(--yellow);
  font-weight: 800;
}

.main-nav {
  display: flex;
  overflow-x: auto;
  border-left: var(--line);
}

.main-nav a {
  display: grid;
  place-items: center;
  min-width: max-content;
  padding: 1rem 0.75rem;
  border-right: 1px solid var(--ink);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.main-nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper);
}

.mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  padding: 0.5rem 1rem;
  border-bottom: var(--line);
  background: white;
  font: 700 0.72rem "Courier New", monospace;
  text-transform: uppercase;
}

.mode-switch a.is-context {
  background: var(--yellow);
  text-decoration: none;
}

main,
footer {
  max-width: var(--max);
  margin: auto;
}

main > section,
.case-detail {
  padding: clamp(2rem, 5vw, 6rem) clamp(1rem, 4vw, 4rem);
  border-bottom: var(--line);
}

.hero,
.page-hero {
  min-height: 68vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow,
.meta {
  margin: 0 0 1rem;
  font: 700 0.78rem/1.4 "Courier New", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  max-width: 70rem;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 8.5vw, 9.5rem);
  line-height: 0.88;
  letter-spacing: -0.07em;
  text-wrap: balance;
}

h2 {
  margin: 0 0 2rem;
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

h3 {
  margin: 0 0 1rem;
  font-size: clamp(1.6rem, 2.5vw, 3rem);
  line-height: 0.95;
}

p {
  line-height: 1.55;
}

.lede {
  margin: 2rem 0 0;
  max-width: 56rem;
  font-size: clamp(1.2rem, 2.2vw, 2rem);
  line-height: 1.25;
}

.availability {
  align-self: flex-start;
  margin-top: 3rem;
  padding: 0.65rem 0.8rem;
  border: var(--line);
  background: var(--yellow);
  font: 700 0.8rem "Courier New", monospace;
  text-transform: uppercase;
}

.door-grid,
.case-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  border-top: var(--line);
  border-left: var(--line);
}

.door,
.case-card,
.info-block {
  grid-column: span 4;
  min-height: 300px;
  padding: clamp(1rem, 2.5vw, 2.5rem);
  border-right: var(--line);
  border-bottom: var(--line);
}

.door {
  display: flex;
  min-height: 410px;
  flex-direction: column;
  justify-content: space-between;
}

.door a,
.arrow-link,
.source-link {
  font-weight: 800;
}

.red,
.tone-1 {
  background: var(--red);
  color: white;
}

.yellow,
.tone-2 {
  background: var(--yellow);
}

.blue,
.tone-3 {
  background: var(--blue);
  color: white;
}

.tone-4 {
  background: white;
}

.case-card:nth-child(1) {
  grid-column: span 5;
}

.case-card:nth-child(2) {
  grid-column: span 3;
}

.case-card:nth-child(3) {
  grid-column: span 4;
}

.case-card:nth-child(n + 4) {
  grid-column: span 6;
}

.case-detail dl {
  margin-top: 4rem;
  border-top: var(--line);
}

.case-detail dl div {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 3fr;
  gap: 2rem;
  padding: 1.5rem 0;
  border-bottom: var(--line);
}

dt {
  font: 800 0.78rem "Courier New", monospace;
  text-transform: uppercase;
}

dd {
  margin: 0;
  max-width: 55rem;
  font-size: 1.15rem;
  line-height: 1.5;
}

.cta {
  background: var(--ink);
  color: var(--paper);
}

.button {
  display: inline-block;
  padding: 1rem 1.2rem;
  border: 3px solid currentColor;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.prose p {
  max-width: 55rem;
  font-size: 1.2rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem 1rem;
  background: var(--paper);
  font: 700 0.76rem "Courier New", monospace;
  text-transform: uppercase;
}

footer div {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.portal {
  min-height: 100vh;
  background:
    linear-gradient(90deg, var(--red) 0 58%, transparent 58%),
    linear-gradient(var(--yellow) 0 38%, var(--blue) 38% 100%);
}

.portal main {
  min-height: 100vh;
  padding: clamp(2rem, 8vw, 8rem);
  border: 12px solid var(--ink);
}

.portal h1 {
  max-width: 12ch;
}

.portal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 4rem;
}

body[data-context="systems"] .door[data-door="systems"],
body[data-context="works"] .door[data-door="works"],
body[data-context="lab"] .door[data-door="lab"] {
  box-shadow: inset 0 0 0 8px white;
}

@media (max-width: 900px) {
  header {
    position: static;
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    border-top: var(--line);
    border-left: 0;
  }

  .door,
  .case-card,
  .case-card:nth-child(n),
  .info-block {
    grid-column: span 12;
    min-height: auto;
  }

  .door {
    min-height: 280px;
  }

  footer {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: clamp(2.8rem, 15vw, 5rem);
  }

  .case-detail dl div {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .identity span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
