/* 8-bit theme. Hard edges, hard shadows, no rounded corners. */
:root {
  --bg: #fbf3dc;
  --surface: #fffaf0;
  --ink: #2b2640;
  --muted: #5d5676;
  --line: #d9cfb4;
  --accent: #b8381a;
  --accent-ink: #fffaf0;
  --green: #1f7a50;
  --blue: #2f5fc0;
  --yellow: #f2c14e;
  --grid: rgba(43, 38, 64, 0.045);
  --pixel: "Press Start 2P", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --wrap: 68rem;
  --gutter: 1.25rem;
  --px: 3px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1830;
    --surface: #262245;
    --ink: #f4eedb;
    --muted: #b8b1cf;
    --line: #3d3768;
    --accent: #ff8a66;
    --accent-ink: #1b1830;
    --green: #6fdc9f;
    --blue: #8ec5ff;
    --yellow: #f2c14e;
    --grid: rgba(244, 238, 219, 0.04);
  }
}

:root[data-theme="dark"] {
  --bg: #1b1830;
  --surface: #262245;
  --ink: #f4eedb;
  --muted: #b8b1cf;
  --line: #3d3768;
  --accent: #ff8a66;
  --accent-ink: #1b1830;
  --green: #6fdc9f;
  --blue: #8ec5ff;
  --yellow: #f2c14e;
  --grid: rgba(244, 238, 219, 0.04);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { image-rendering: pixelated; max-width: 100%; height: auto; }

a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.25em; }
a:hover { color: var(--accent); }

:focus-visible { outline: var(--px) dashed var(--blue); outline-offset: 3px; }

code {
  font-family: var(--mono);
  background: var(--line);
  padding: 0.05em 0.35em;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip:focus { left: 0; }

/* Top bar */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: var(--px) solid var(--ink);
}

.top-inner { display: flex; align-items: center; gap: 1rem; min-height: 3.75rem; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  font-weight: 700;
  margin-right: auto;
  min-width: 0;
}

.brand-mark {
  font-family: var(--pixel);
  font-size: 0.65rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 0.5rem 0.4rem;
}

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

.nav { display: flex; gap: 1.1rem; }

.nav a {
  font-family: var(--pixel);
  font-size: 0.6rem;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--muted);
  padding: 0.5rem 0;
  border-bottom: var(--px) solid transparent;
}
.nav a:hover, .nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme {
  font: inherit;
  width: 2.4rem;
  height: 2.4rem;
  border: var(--px) solid var(--ink);
  background: var(--yellow);
  color: #2b2640;
  cursor: pointer;
  flex: none;
  box-shadow: 3px 3px 0 var(--ink);
}
.theme:active { transform: translate(3px, 3px); box-shadow: none; }

/* Hero */
.hero { padding-block: clamp(2.5rem, 7vw, 5rem) clamp(2.5rem, 6vw, 4rem); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.85rem;
  color: var(--ink);
  border: var(--px) solid var(--ink);
  background: var(--surface);
  padding: 0.35rem 0.8rem;
  box-shadow: 3px 3px 0 var(--ink);
}
.status img { flex: none; }

h1 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(1rem, 2.5vw, 1.55rem);
  line-height: 1.75;
  margin-top: 1.75rem;
  text-wrap: balance;
}

.lede { max-width: 62ch; margin-top: 1.5rem; color: var(--muted); font-size: 1.05rem; }

.cta { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }

.btn {
  display: inline-block;
  padding: 0.85rem 1rem 0.75rem;
  border: var(--px) solid var(--ink);
  background: var(--surface);
  text-decoration: none;
  font-family: var(--pixel);
  font-size: 0.7rem;
  text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--ink);
}
.btn:hover { color: inherit; background: var(--yellow); color: #2b2640; }
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--green); color: var(--accent-ink); }

/* The robot */
.buddy { text-align: center; }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem 0.5rem;
  border-bottom: var(--px) solid var(--ink);
}

.star { position: absolute; }
.s1 { top: 0.25rem; left: 1rem; animation: twinkle 1.6s steps(2) infinite; }
.s2 { top: 2rem; right: 1.25rem; animation: twinkle 1.6s steps(2) 0.8s infinite; }

.bubble {
  position: relative;
  margin-top: 1.25rem;
  padding: 0.75rem 0.9rem;
  border: var(--px) solid var(--ink);
  background: var(--surface);
  font-size: 0.875rem;
  text-align: left;
  box-shadow: 4px 4px 0 var(--ink);
}
.bubble::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: var(--ink);
  clip-path: polygon(0 100%, 33% 100%, 33% 66%, 66% 66%, 66% 33%, 100% 33%, 100% 100%);
}
.bubble.small { display: inline-block; margin: 0; padding: 0.35rem 0.6rem; font-size: 0.8rem; box-shadow: 3px 3px 0 var(--ink); }
.bubble.small::before { top: 50%; left: -12px; margin: -6px 0 0; transform: rotate(-90deg); }

.sidekick { display: flex; align-items: center; gap: 1.1rem; margin-top: 1.5rem; }
.sidekick img { flex: none; }

.cursor { animation: blink 1s steps(1) infinite; }
.blink { animation: blink 1.4s steps(1) infinite; }
.bob { animation: bob 1s steps(2) infinite; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes twinkle { 50% { transform: scale(0.6); opacity: 0.5; } }

/* High scores */
.scores-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  font-family: var(--pixel);
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--accent);
}

.numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 0.9rem;
  border: var(--px) solid var(--ink);
  background: var(--surface);
  box-shadow: 6px 6px 0 var(--ink);
}

.numbers > div { padding: 1.25rem 1.1rem; }
.numbers > div + div { border-left: var(--px) solid var(--ink); }

.numbers dt {
  font-family: var(--pixel);
  font-size: clamp(1rem, 2vw, 1.35rem);
  line-height: 1.4;
  color: var(--green);
  white-space: nowrap;
}

.numbers dd { margin-top: 0.7rem; color: var(--muted); font-size: 0.875rem; line-height: 1.5; }

/* Critters: a fixed layer over the page. Positions come from assets/critters.js. */
.critters { position: fixed; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.critter { position: absolute; left: 0; top: 0; max-width: none; will-change: transform; }
.critter-bolt { width: 8px; height: 8px; background: var(--yellow); border: 2px solid #2b2640; }
.critter-ladder {
  position: absolute;
  right: 12px;
  bottom: 0;
  width: 40px;
  border-inline: 5px solid var(--ink);
  background: repeating-linear-gradient(to bottom, transparent 0 13px, var(--ink) 13px 18px);
  opacity: 0;
  transition: opacity 0.4s steps(4);
}
.critter-ladder.up { opacity: 0.85; }

.critters-toggle {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 6;
  font-family: var(--pixel);
  font-size: 0.55rem;
  text-transform: uppercase;
  color: #2b2640;
  background: var(--yellow);
  border: 2px solid var(--ink);
  padding: 0.6rem 0.6rem 0.5rem;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}
.critters-toggle:active { transform: translate(3px, 3px); box-shadow: none; }

/* Sprites have dark outlines. On the dark theme, give them a light rim so they stay visible. */
:root[data-theme="dark"] :is(.critter, .buddy img, .sidekick img, .nap img, .status img, .scores-title img, .lost img) {
  filter: drop-shadow(1px 0 0 #f4eedb) drop-shadow(-1px 0 0 #f4eedb) drop-shadow(0 1px 0 #f4eedb) drop-shadow(0 -1px 0 #f4eedb);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.critter, .buddy img, .sidekick img, .nap img, .status img, .scores-title img, .lost img) {
    filter: drop-shadow(1px 0 0 #f4eedb) drop-shadow(-1px 0 0 #f4eedb) drop-shadow(0 1px 0 #f4eedb) drop-shadow(0 -1px 0 #f4eedb);
  }
}

/* Sections */
.section { padding-block: clamp(3rem, 7vw, 5rem); border-top: var(--px) dashed var(--line); }

.section-head { margin-bottom: 2.5rem; }

.eyebrow {
  display: inline-block;
  font-family: var(--pixel);
  font-size: 0.65rem;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 0.6rem 0.4rem;
}

h2 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(0.95rem, 2vw, 1.3rem);
  line-height: 1.7;
  margin-top: 1.1rem;
  max-width: 34ch;
  text-wrap: balance;
}

.section-note { margin-top: 0.9rem; color: var(--muted); max-width: 64ch; }

/* Quest cards */
.case {
  background: var(--surface);
  border: var(--px) solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  padding: clamp(1.25rem, 3vw, 2rem);
}
.case + .case { margin-top: 2rem; }

.case-meta { font-size: 0.8rem; color: var(--muted); }

.case h3 {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(0.8rem, 1.5vw, 1rem);
  line-height: 1.7;
  margin-top: 0.6rem;
}
.case h3::before { content: "▶ "; color: var(--accent); }

.case-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-top: 1.5rem; }

.case h4 {
  font-family: var(--pixel);
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--green);
  padding-top: 0.75rem;
  border-top: var(--px) solid var(--green);
  margin-bottom: 0.7rem;
}
.case-grid > div:first-child h4 { color: var(--accent); border-color: var(--accent); }
.case-grid > div:nth-child(2) h4 { color: var(--blue); border-color: var(--blue); }

.case-grid p { font-size: 0.925rem; }

.tradeoff {
  margin-top: 1.5rem;
  padding: 0.9rem 1rem;
  border: var(--px) dashed var(--line);
  background: var(--bg);
  font-size: 0.9rem;
  color: var(--muted);
}
.tradeoff strong { color: var(--ink); }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }

.tags li {
  font-size: 0.75rem;
  border: 2px solid var(--ink);
  padding: 0.1rem 0.5rem;
  background: var(--bg);
}

/* Levels */
.timeline { counter-reset: lv 6; }

.timeline > li {
  counter-increment: lv -1;
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 1.5rem;
  padding-block: 1.75rem;
  border-top: var(--px) dashed var(--line);
}
.timeline > li:first-child { border-top: var(--px) solid var(--ink); }

.when { font-size: 0.85rem; color: var(--muted); }
.when::before {
  content: "LV " counter(lv);
  display: block;
  width: max-content;
  font-family: var(--pixel);
  font-size: 0.65rem;
  color: #2b2640;
  background: var(--yellow);
  border: 2px solid var(--ink);
  padding: 0.4rem 0.5rem 0.3rem;
  margin-bottom: 0.6rem;
}

.what h3 { font-size: 1.05rem; line-height: 1.4; }
.org { color: var(--accent); }
.org::before { content: "@ "; color: var(--muted); }

.role-note { font-size: 0.875rem; color: var(--muted); margin-top: 0.2rem; }

.what ul { margin-top: 0.85rem; display: grid; gap: 0.6rem; max-width: 74ch; }

.what li { position: relative; padding-left: 1.3rem; font-size: 0.925rem; }
.what li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 7px;
  height: 7px;
  background: var(--green);
}

.edu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-top: 1rem;
  padding-top: 1.75rem;
  border-top: var(--px) dashed var(--line);
}
.edu h3, .skills dt {
  font-family: var(--pixel);
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 0.7rem;
  line-height: 1.6;
}
.edu p { font-size: 0.925rem; }

/* Inventory */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.skills > div {
  padding: 1.1rem;
  border: var(--px) solid var(--ink);
  background: var(--surface);
  box-shadow: 4px 4px 0 var(--ink);
}
.skills dd { font-size: 0.9rem; }

/* Side quests */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.75rem; }

.cards a {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.3rem;
  background: var(--surface);
  border: var(--px) solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  text-decoration: none;
}
.cards a:hover { color: inherit; transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--accent); }
.cards a:active { transform: translate(6px, 6px); box-shadow: none; }

.cards h3 { font-family: var(--pixel); font-weight: 400; font-size: 0.75rem; line-height: 1.6; }
.cards h3::after { content: " ↗"; color: var(--accent); }
.cards p { margin-top: 0.7rem; color: var(--muted); font-size: 0.9rem; flex: 1; }
.stack { margin-top: 1rem; font-size: 0.75rem; color: var(--green); }

/* Contact */
.links { border: var(--px) solid var(--ink); background: var(--surface); box-shadow: 6px 6px 0 var(--ink); }

.links li {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
  align-items: baseline;
  padding: 0.9rem 1.1rem;
}
.links li + li { border-top: var(--px) dashed var(--line); }
.links span { font-family: var(--pixel); font-size: 0.6rem; text-transform: uppercase; color: var(--muted); }
.links a { font-size: 1rem; }

/* Footer */
.foot { border-top: var(--px) solid var(--ink); padding-block: 1.5rem; color: var(--muted); font-size: 0.85rem; }
.foot-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 2rem; }
.nap { display: flex; align-items: center; gap: 0.75rem; }
.nap img { flex: none; }

/* 404 */
.lost { min-height: 80vh; display: grid; align-content: center; justify-items: start; gap: 1rem; }

/* Responsive */
@media (max-width: 56rem) {
  .top-inner { flex-wrap: wrap; row-gap: 0; padding-top: 0.6rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; gap: 1.25rem; padding-block: 0.4rem 0.2rem; }
  .nav a { white-space: nowrap; padding: 0.6rem 0; }
  html { scroll-padding-top: 7.5rem; }
  .hero-grid { grid-template-columns: 1fr; }
  .buddy { max-width: 17rem; }
  .numbers { grid-template-columns: repeat(2, 1fr); }
  .numbers > div + div { border-left: 0; }
  .numbers > div:nth-child(even) { border-left: var(--px) solid var(--ink); }
  .numbers > div:nth-child(n+3) { border-top: var(--px) solid var(--ink); }
  .case-grid, .edu, .skills, .cards { grid-template-columns: 1fr; }
  .timeline > li, .links li { grid-template-columns: 1fr; gap: 0.5rem; }
}

@media (max-width: 26rem) {
  .brand-name { display: none; }
  .numbers { grid-template-columns: 1fr; }
  .numbers > div:nth-child(even) { border-left: 0; }
  .numbers > div + div { border-top: var(--px) solid var(--ink); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bob, .blink, .cursor, .star { animation: none; }
}

/* Print: the page doubles as a resume */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #333; --line: #bbb; --accent: #000; --green: #000; --blue: #000; }
  body { font-size: 9.5pt; background-image: none; }
  .top, .cta, .skip, .buddy, .sidekick, .nap, .critters, .critters-toggle, .scores-title img { display: none; }
  .hero, .section { padding-block: 0.8rem; }
  .case, .cards a, .skills > div, .numbers, .links, .status { box-shadow: none; }
  .case { break-inside: avoid; }
  .case + .case { margin-top: 0.8rem; }
  .timeline > li { break-inside: avoid; padding-block: 0.6rem; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}

/* One-line summary under a case title */
.case-sum { margin-top: 0.9rem; max-width: 70ch; }
.section > .cta { margin-top: 2rem; }
