/* ---------- tokens ---------- */
:root {
  --bg: #fdf8ef;
  --bg-soft: #f4ecdc;
  --ink: #16181d;
  --muted: #5d6470;
  --line: #e3d8c3;
  --water: #cfe9e6;
  --water-deep: #9fd3cf;
  --fish: #111418;
  --fish-stroke: #111418;
  --accent: #0e7c86;

  --font-display: "Bricolage Grotesque", ui-rounded, system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
}

.section-scientist, .card-scientist, .nav-scientist { --accent: #0b7a75; }
.section-enginerd, .card-enginerd, .nav-enginerd { --accent: #c2410c; }
.section-teacher, .card-teacher, .nav-teacher { --accent: #6d28d9; }
.section-wanderer, .card-wanderer, .nav-wanderer { --accent: #2f7d32; }


@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1520;
    --bg-soft: #122131;
    --ink: #e6edf3;
    --muted: #9aa7b4;
    --line: #223446;
    --water: #11293b;
    --water-deep: #1c4560;
    --fish: #04070a;
    --fish-stroke: #7fd4e0;
    --accent: #5ccfd9;
  }
  .section-scientist, .card-scientist, .nav-scientist { --accent: #4fd1c5; }
  .section-enginerd, .card-enginerd, .nav-enginerd { --accent: #fb923c; }
  .section-teacher, .card-teacher, .nav-teacher { --accent: #b69cff; }
  .section-wanderer, .card-wanderer, .nav-wanderer { --accent: #7bd88f; }
  
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 var(--font-body);
  overflow-x: hidden;
}

main { flex: 1; width: 100%; }

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 600px) { .wrap { padding: 0 24px; } }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 .5em;
}

a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

img { max-width: 100%; height: auto; display: block; }

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 10;
  background: var(--ink);
  color: var(--bg);
  padding: .5em 1em;
  border-radius: 8px;
}
.skip:focus { top: 12px; }

.squiggle {
  color: var(--accent);
  text-decoration: underline wavy var(--accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .2em;
  text-decoration-skip-ink: none;
}

/* ---------- fish ---------- */
.fish { display: block; overflow: visible; }
.fish path { fill: var(--fish); stroke: var(--fish-stroke); stroke-width: 1.5; stroke-linejoin: round; }
.fish-eye { fill: var(--bg); }
.fish-tail { transform-origin: 47px 20px; }

/* ---------- header ---------- */
.site-header {
  position: relative;
  background: var(--water);
  padding: 18px 0 56px;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  color: var(--ink);
  text-decoration: none;
  font: 700 1.3rem/1 var(--font-display);
  letter-spacing: -0.02em;
}
.brand .fish { width: 36px; }
.brand:hover .fish-tail { animation: wag .35s ease-in-out 3; }
.brand-dot { color: var(--accent); }

.site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-header nav a {
  position: relative;
  display: inline-block;
  padding: 4px 0;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.site-header nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--bounce);
}
.site-header nav a:hover::after,
.site-header nav a[aria-current="page"]::after { transform: scaleX(1); }

.wave {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 40px;
  fill: var(--bg);
  z-index: 1;
}

@keyframes wag { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(10deg); } }
@keyframes bob { 0%, 100% { transform: translateY(-2px); } 50% { transform: translateY(3px); } }

/* ---------- home ---------- */
.sections h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}
.cards li:nth-child(4n+1) { --tilt: -1.6deg; }
.cards li:nth-child(4n+2) { --tilt: 1.2deg; }
.cards li:nth-child(4n+3) { --tilt: 1.8deg; }
.cards li:nth-child(4n+4) { --tilt: -1deg; }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 22px 22px 26px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  box-shadow: 5px 5px 0 var(--accent);
  color: var(--ink);
  text-decoration: none;
  transform: rotate(var(--tilt, 0));
  transition: transform .35s var(--bounce), box-shadow .35s var(--bounce);
}
.card:hover, .card:focus-visible {
  transform: rotate(0) translateY(-5px);
  box-shadow: 8px 10px 0 var(--accent);
}
.card-title { font: 600 1.25rem/1.2 var(--font-display); }
.card-title b { color: var(--accent); font-weight: 800; }
.card-tagline { color: var(--muted); }
.card-go {
  position: absolute;
  right: 18px;
  bottom: 14px;
  color: var(--accent);
  font-size: 1.4rem;
  transition: transform .35s var(--bounce);
}
.card:hover .card-go { transform: translateX(5px); }

/* ---------- section pages ---------- */
.section-hero { padding: 28px 0 12px; }
.section-hero h1 { font-size: clamp(2.2rem, 6.5vw, 3.8rem); font-weight: 800; }
.tagline { margin: 0; color: var(--muted); font-size: 1.2rem; }

.prose { max-width: 68ch; padding: 16px 0 24px; }
.prose h2 { margin-top: 1.8em; font-size: 1.6rem; }
.prose h2::before {
  content: "";
  display: inline-block;
  width: .45em;
  height: .45em;
  margin-right: .4em;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: .12em;
}
.prose h3 { margin-top: 1.5em; font-size: 1.25rem; }
.prose figure { margin: 1.5em 0; }
.prose figure img { border-radius: var(--radius); box-shadow: 8px 8px 0 color-mix(in srgb, var(--accent) 35%, var(--bg)); }
.prose hr { margin: 2em 0; border: 0; border-top: 2px dashed var(--line); }

.backlinks {
  margin-top: 16px;
  padding-top: 24px;
  border-top: 2px dashed var(--line);
}
.backlinks h2 { font-size: 1.2rem; }
.backlinks ul { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.chip {
  display: inline-block;
  padding: .35em .95em;
  border: 2px solid var(--accent);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition: transform .3s var(--bounce), background .2s;
}
.chip:hover { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); transform: translateY(-2px) rotate(-2deg); }

/* ---------- RSVP reader (see assets/js/rsvp.js) ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rsvp {
  margin: 1.6em 0;
  border-radius: 12px;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.rsvp:focus-visible { outline-offset: 6px; }

.rsvp-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 4.6em;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  transition: border-color .3s;
}
.rsvp.playing .rsvp-stage, .rsvp.peek .rsvp-stage { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
/* Spritz's reticle: a notch above and below the pivot letter. */
.rsvp-stage::before, .rsvp-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 2px;
  height: .6em;
  background: var(--line);
  transform: translateX(-50%);
}
.rsvp-stage::before { top: 0; }
.rsvp-stage::after { bottom: 0; }

.rsvp-word {
  grid-area: 1 / 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  width: 100%;
  color: var(--ink);
  font: 500 1.7rem/1 var(--font-display);
  white-space: pre;
  visibility: hidden;
}
.rsvp.playing .rsvp-word, .rsvp.peek .rsvp-word { visibility: visible; }
.rsvp.gap .rsvp-word { visibility: hidden; }
.rsvp-l { text-align: right; }
.rsvp-p { color: var(--accent); font-weight: 800; }
.rsvp-r { text-align: left; }
.rsvp-word.strong { font-weight: 800; }
.rsvp-word.em { font-style: italic; }
.rsvp-word.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.45rem; }
.rsvp-word.link .rsvp-l, .rsvp-word.link .rsvp-r { color: var(--accent); }
.rsvp-word.link { text-decoration: underline wavy color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: .25em; text-decoration-thickness: 2px; }

.rsvp-hint {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  text-align: center;
}
.rsvp-title {
  color: var(--ink);
  font: 700 1.45rem/1.15 var(--font-display);
  letter-spacing: -0.02em;
}
.rsvp-when {
  color: var(--muted);
  font: 600 .85rem/1 var(--font-display);
  letter-spacing: .04em;
}
.rsvp.playing .rsvp-hint, .rsvp.peek .rsvp-hint { visibility: hidden; }

.rsvp-meta, .rsvp-speed {
  position: absolute;
  top: 6px;
  color: var(--muted);
  font: 600 .72rem/1 var(--font-display);
  letter-spacing: .05em;
  opacity: 0;
  transition: opacity .2s;
}
.rsvp-meta { left: 0; }
.rsvp-speed { right: 0; display: flex; align-items: center; gap: 6px; }
.rsvp:hover .rsvp-speed, .rsvp:focus-within .rsvp-speed, .rsvp.playing .rsvp-meta, .rsvp.peek .rsvp-meta { opacity: 1; }
.rsvp-speed button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font: 700 .85rem/1 var(--font-body);
  cursor: pointer;
}
.rsvp-speed button:hover { border-color: var(--accent); color: var(--accent); }
@media (hover: none) { .rsvp.playing .rsvp-speed, .rsvp.peek .rsvp-speed { opacity: 1; } }

.rsvp-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 14px;
  cursor: pointer;
}
.rsvp-bar span {
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(var(--p, 0));
  transform-origin: left;
  transition: transform .2s linear;
}

/* Quotes read bigger, with the accent rule. */
.rsvp-quote .rsvp-stage { border-left: 4px solid var(--accent); }
.rsvp-quote .rsvp-word { font-size: 1.9rem; font-style: italic; }

/* Links surface as chips once their words have gone by. */
.rsvp-links { display: flex; flex-wrap: wrap; gap: 8px; }
.rsvp-links:not(:empty) { margin-top: 14px; }
.rsvp-links a {
  padding: .25em .8em;
  border: 2px solid var(--accent);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  animation: pop .4s var(--bounce);
}
.rsvp-links a::after { content: " →"; color: var(--accent); }
.rsvp-links a:hover { background: color-mix(in srgb, var(--accent) 16%, var(--bg)); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.rsvp-error { color: var(--muted); font-style: italic; }

/* ![[note]] embeds: the other note's readers, framed, with a link to it. */
.embed {
  margin: 1.6em 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.embed .rsvp { margin: 1em 0; }
.embed-source {
  color: var(--muted);
  font: 600 .8rem/1 var(--font-display);
  letter-spacing: .04em;
  text-decoration: none;
}
.embed-source::before { content: "↪ "; color: var(--accent); }
.embed-source:hover { color: var(--accent); }
.intro { max-width: 68ch; padding-top: 16px; }

/* ---------- 404 ---------- */
.lost-at-sea { padding: 40px 0 24px; text-align: center; }
.big-404 { margin: 0; font: 800 clamp(5rem, 22vw, 9rem)/1 var(--font-display); color: var(--accent); }
.big-404 span { display: inline-block; font-size: .7em; animation: bob 2.8s ease-in-out infinite; }
.button {
  display: inline-block;
  margin-top: .5em;
  padding: .6em 1.3em;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .3s var(--bounce), box-shadow .3s var(--bounce);
}
.button:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 64px;
  padding: 28px 0 40px;
  border-top: 2px dashed var(--line);
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.social { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; padding: 0; list-style: none; }
.social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  text-decoration: none;
  transition: background .2s, color .2s, transform .3s var(--bounce);
}
.social a:hover { background: var(--accent); color: var(--bg); transform: translateY(-2px); }
.social svg { width: 20px; height: 20px; fill: currentColor; }
.social .email { padding: 0 16px; font-weight: 600; }
.nospam { display: none; }
.fineprint { margin: 0; color: var(--muted); font-size: .9rem; }
.fineprint a { color: inherit; }

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