/* ---------- Tokens ---------- */
:root {
  --bg: #eceee8;
  --ink: #1e2430;
  --muted: #5b6370;
  --rule: #cbd0cb;
  --accent: #2b4acb;
  --accent-deep: #1f37a0;

  /* character */
  --pen: #1e2430;
  --coat: #1e2430;
  --belly: #f4f5f0;
  --beak: #e0a02e;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gutter: clamp(1.25rem, 5vw, 3rem);
}

html[data-theme="dark"] {
  --bg: #12151c;
  --ink: #e9e7e0;
  --muted: #98a0ad;
  --rule: #2a303b;
  --accent: #8196ff;
  --accent-deep: #5468d6;
  --coat: #333947;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

.link {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
  transition: color 0.15s ease;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.container {
  width: min(68rem, calc(100% - 2 * var(--gutter)));
  margin-inline: auto;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  transition: background-color 0.3s ease;
}

.bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 4rem;
}

.brand {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.site-nav {
  display: flex;
  gap: 2rem;
  margin-left: auto;
  font-size: 0.95rem;
  color: var(--muted);
}

.site-nav a {
  transition: color 0.15s ease;
}

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

.bar-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.theme-glyph {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
  transition: transform 0.4s ease;
}

.theme-toggle:hover .theme-glyph {
  transform: rotate(180deg);
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  padding: 0.4rem 0;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
}

/* ---------- Hero ---------- */
.hero {
  padding-top: clamp(3.5rem, 9vw, 7rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3rem;
  align-items: end;
  border-bottom: 2px solid var(--ink);
}

.hero-copy {
  padding-bottom: clamp(2.5rem, 5vw, 4rem);
}

.where {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero h1 {
  margin: 0;
  max-width: 15em;
  font-family: var(--serif);
  font-weight: 350;
  font-size: clamp(2.4rem, 5.4vw, 4.25rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
}

.lede {
  max-width: 34rem;
  margin: 1.75rem 0 0;
  color: var(--muted);
  font-size: 1.1rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin: 1.75rem 0 0;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
}

/* Single page-load sequence: the hero text settles in, then the character waves. */
.js .intro > * {
  opacity: 0;
  animation: settle 0.7s ease forwards;
}
.js .intro > *:nth-child(1) { animation-delay: 0.05s; }
.js .intro > *:nth-child(2) { animation-delay: 0.2s; }
.js .intro > *:nth-child(3) { animation-delay: 0.4s; }
.js .intro > *:nth-child(4) { animation-delay: 0.55s; }
.js .intro > *:nth-child(5) { animation-delay: 0.7s; }

@keyframes settle {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Sections ---------- */
.row {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 2rem;
  padding-top: clamp(4.5rem, 10vw, 7.5rem);
}

.row-title {
  margin: 0.35rem 0 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.row-body {
  max-width: 40rem;
}

.prose {
  margin: 0 0 1.5rem;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 2.2vw, 1.55rem);
  font-weight: 380;
  line-height: 1.45;
  letter-spacing: -0.005em;
}

.plain {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.mini-title {
  margin: 2.75rem 0 0.9rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}

.cares {
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}

.cares li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.6rem;
}

.cares li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05em;
  width: 0.8rem;
  height: 2px;
  background: var(--accent);
}

.langs {
  margin: 0;
}

/* Jobs and education */
.job + .job {
  margin-top: 3rem;
}

.job-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1.5rem;
}

.job h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.4rem, 2.4vw, 1.8rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.when {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.role {
  margin: 0.25rem 0 0.8rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
}

.desc {
  margin: 0;
  color: var(--muted);
}

/* Stack */
.stack {
  margin: 0;
}

.stack > div {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0 0 1.75rem;
}

.stack dt {
  padding-top: 0.3rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.stack dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.5;
}

/* ---------- Contact ---------- */
.contact {
  padding-top: clamp(5rem, 11vw, 8.5rem);
}

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3rem;
  align-items: end;
  border-bottom: 2px solid var(--ink);
}

.contact-copy {
  padding-bottom: clamp(2.5rem, 5vw, 3.5rem);
}

.contact h2 {
  margin: 0 0 1.25rem;
  max-width: 12em;
  font-family: var(--serif);
  font-weight: 350;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.contact .plain {
  max-width: 32rem;
}

.mail {
  margin: 0 0 1.25rem;
  font-family: var(--serif);
  font-size: clamp(1.2rem, 2.6vw, 1.6rem);
  word-break: break-word;
}

.other-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer {
  padding: 1.25rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0;
}

/* ---------- Character ---------- */
.figure {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 1.1rem;
  justify-self: end;
  min-width: 0;
}

.mo-btn {
  display: block;
  flex: none;
  width: 250px;
  padding: 0;
  background: none;
  border: 0;
  line-height: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.figure-small .mo-btn {
  width: 200px;
}

.mo {
  display: block;
  width: 100%;
  height: auto;
}

/* drawing vocabulary */
.mo .o {
  stroke: var(--pen);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mo .os {
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
}
.mo .f-coat { fill: var(--coat); }
.mo .f-belly { fill: var(--belly); }
.mo .f-beak { fill: var(--beak); }
.mo .f-accent { fill: var(--accent); }
.mo .pupil { fill: var(--pen); }
.mo .lid { fill: var(--coat); }
.mo .cable {
  fill: none;
  stroke: var(--belly);
  stroke-width: 2;
  stroke-linecap: round;
}
.mo .fl-o,
.mo .fl-i {
  fill: none;
  stroke-linecap: round;
}
.mo .fl-o { stroke: var(--pen); stroke-width: 26; }
.mo .fl-i { stroke: var(--coat); stroke-width: 21; }

/* idle breathing, anchored at the feet so they stay on the line */
.mo-bob {
  transform-box: view-box;
  transform-origin: 130px 290px;
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe {
  50% { transform: scaleY(1.012); }
}

.mo-pupils,
.mo-head {
  transition: transform 0.12s ease-out;
}

/* eyelids: deadpan at rest, lower when you get close, shut when blinking */
.mo .lid {
  transform: translateY(4px);
  transition: transform 0.14s ease;
}
.mo.narrow .lid,
.mo.stern .lid {
  transform: translateY(10px);
}
.mo.blink .lid {
  transform: translateY(27px);
}

/* the right flipper lifts into a "halt" and lowers again */
.mo-arm {
  transform-box: view-box;
  transform-origin: 198px 138px;
}
.mo.halting .mo-arm {
  animation: mo-halt 2.2s ease-in-out 1;
}
@keyframes mo-halt {
  0%   { transform: rotate(0deg); }
  22%  { transform: rotate(-210deg); }
  78%  { transform: rotate(-210deg); }
  100% { transform: rotate(0deg); }
}

/* placard: a small sign standing on the line next to the character */
.placard {
  flex: 0 1 11.5rem;
  min-width: 0;
  padding: 0.6rem 0.85rem 0.7rem;
  background: var(--bg);
  border: 1.5px solid var(--ink);
  border-bottom: 0;
}

.placard-title {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.placard-line {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.35;
}

.placard-line.swap {
  animation: line-in 0.3s ease;
}
@keyframes line-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hero-grid,
  .contact-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 3rem;
  }

  .hero-copy,
  .contact-copy {
    padding-bottom: 0;
  }

  .mo-btn {
    width: 200px;
  }

  .figure-small .mo-btn {
    width: 170px;
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .row-title {
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .nav-toggle {
    display: block;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0.5rem var(--gutter) 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    font-size: 1.05rem;
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav a {
    padding: 0.6rem 0;
  }

  .bar-tools {
    margin-left: auto;
  }

  .stack > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .intro > * {
    opacity: 1;
    animation: none;
  }

  .mo-bob,
  .mo.halting .mo-arm,
  .placard-line.swap {
    animation: none;
  }

  .mo-pupils,
  .mo-head,
  .mo .lid {
    transition: none;
  }
}
