/* ==========================================================================
   Fonts: self-hosted, axis-pinned subsets + metric-matched fallbacks so the
   swap from Georgia/Menlo to the real faces causes no layout shift.
   ========================================================================== */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("/fonts/fraunces-normal-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("/fonts/fraunces-normal-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url("/fonts/fraunces-italic-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 300 600;
  font-display: swap;
  src: url("/fonts/fraunces-italic-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/martian-mono-normal-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Martian Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/martian-mono-normal-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Fallbacks scaled to Fraunces / Martian Mono advance widths (measured). */
@font-face {
  font-family: "Fraunces Fallback";
  font-style: normal;
  src: local("Georgia");
  size-adjust: 83.6%;
  ascent-override: 117%;
  descent-override: 30.5%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Fraunces Fallback";
  font-style: italic;
  src: local("Georgia Italic"), local("Georgia-Italic");
  size-adjust: 77.2%;
  ascent-override: 126.7%;
  descent-override: 33%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Martian Mono Fallback";
  src: local("Menlo"), local("Consolas"), local("Courier New");
  size-adjust: 116.3%;
  ascent-override: 86%;
  descent-override: 17.2%;
  line-gap-override: 0%;
}

/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  color-scheme: light;

  /* Lichen (day) */
  --paper: #e7ebdc;
  --ink: #1f2c22;
  --ink-soft: #56685a;
  --rule: #c9d0bb;
  --heart: #c9502f;

  /* Crayons, retuned for sage paper */
  --c-blue: #335d99;
  --c-orange: #b4561f;
  --c-green: #2c7660;
  --c-purple: #775294;
  --c-grass: #63802f;
  --c-marigold: #b0701a;

  --serif: "Fraunces", "Fraunces Fallback", Georgia, serif;
  --mono: "Martian Mono", "Martian Mono Fallback", ui-monospace, monospace;

  /* Outer frame: every corner element rests on it. */
  --frame: clamp(20px, 4.5vw, 64px);
  --chrome-line: 16px;
  --reserve-top: calc(var(--frame) + var(--chrome-line) + 32px);
  --reserve-bottom: calc(var(--frame) + var(--chrome-line) + 32px);
  /* Optical centre: content sits slightly above the geometric middle. */
  --lift: 4vh;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.32, 0.64, 1);
}

@supports (width: round(1.5px, 1px)) {
  :root {
    --frame: round(clamp(20px, 4.5vw, 64px), 1px);
  }
}

/* Moss (night, opt-in via the footer toggle): chalk-bright crayons on deep moss. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #18201a;
  --ink: #e4e9d8;
  --ink-soft: #9caf9a;
  --rule: #2f3b30;
  --heart: #ef7d5c;
  --c-blue: #86a9e3;
  --c-orange: #e3925a;
  --c-green: #6fc3a3;
  --c-purple: #b99ad9;
  --c-grass: #a2be66;
  --c-marigold: #e4b04f;
}
/* ==========================================================================
   Base
   ========================================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  background-color: var(--paper);
  background-image: url("/paper.svg?v=2");
  background-size: 93px 93px;
}

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--serif);
  font-kerning: normal;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

::selection {
  background: color-mix(in srgb, var(--heart) 22%, transparent);
}

:focus-visible {
  outline: 1.5px solid var(--heart);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ==========================================================================
   Chrome: menu, footer, skip link (mono, small, uppercase)
   ========================================================================== */

.chrome {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: var(--chrome-line);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.skip {
  position: absolute;
  z-index: 30;
  top: var(--frame);
  left: var(--frame);
  padding: 8px 10px;
  margin: -8px -10px;
  background: var(--paper);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--frame) - 8px));
}
.skip:focus-visible {
  transform: none;
}

/* Header and footer sit outside the flow so they never push content off
   centre; their text boxes rest exactly on the frame lines. */
.site-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  justify-content: flex-end;
  padding: var(--frame) var(--frame) 0;
  pointer-events: none;
  view-transition-name: site-header;
}

.site-footer {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px 24px;
  padding: 0 var(--frame) var(--frame);
  color: var(--ink-soft);
  view-transition-name: site-footer;
}

.footer-tools {
  display: flex;
  gap: 24px;
}

.menu {
  position: relative;
  pointer-events: auto;
}

/* Hit areas ≥ 32px tall without moving the visible labels. */
.menu-toggle,
.site-footer a,
.theme-toggle {
  display: block;
  padding: 8px 10px;
  margin: -8px -10px;
  text-decoration: none;
}

.menu-toggle,
.theme-toggle {
  appearance: none;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.menu-toggle {
  color: var(--ink);
}

.menu-list {
  position: absolute;
  top: calc(var(--chrome-line) + 10px);
  right: 0;
  list-style: none;
  text-align: right;
  white-space: nowrap;
}

.menu-list li {
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 260ms var(--ease),
    transform 260ms var(--ease);
}
.menu[data-open="true"] .menu-list li {
  opacity: 1;
  transform: none;
}
.menu[data-open="true"] .menu-list li:nth-child(2) {
  transition-delay: 40ms;
}
.menu[data-open="true"] .menu-list li:nth-child(3) {
  transition-delay: 80ms;
}
.menu[data-open="false"] .menu-list {
  visibility: hidden;
}

.menu-list a {
  position: relative;
  display: inline-block;
  padding: 4px 0;
  text-decoration: none;
}
.menu-list a[aria-current="page"]::after {
  content: "+";
  position: absolute;
  left: calc(100% + 0.6em);
  transition: transform 260ms var(--spring);
}
.menu-list a[aria-current="page"]:hover::after {
  transform: rotate(90deg);
}

.menu-list a:hover,
.menu-toggle:hover,
.site-footer a:hover,
.theme-toggle:hover {
  color: var(--heart);
}

.menu-toggle:focus-visible,
.site-footer a:focus-visible,
.theme-toggle:focus-visible,
.skip:focus-visible {
  outline-offset: -4px;
}

/* ==========================================================================
   Page body: every page centres its content optically
   ========================================================================== */

main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--reserve-top) var(--frame)
    calc(var(--reserve-bottom) + var(--lift));
}

/* ---------- Home ---------- */

.hero {
  align-items: center;
  gap: clamp(28px, 20px + 1.5vw, 44px);
}

.drawing-btn {
  appearance: none;
  display: block;
  width: min(100%, 566px);
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
}
.drawing-btn:focus-visible {
  outline-offset: 8px;
}

.drawing {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  opacity: 0;
  animation: rise 1400ms var(--ease) 100ms forwards;
}

#grass-scribbles {
  stroke: var(--c-grass);
}
#skipping-child {
  stroke: var(--c-blue);
}
#tall-neighbor {
  stroke: var(--c-orange);
}
#green-neighbor {
  stroke: var(--c-green);
}
#waving-neighbor {
  stroke: var(--c-purple);
}
#one-more {
  stroke: var(--c-marigold);
}
#little-heart {
  stroke: var(--heart);
  transform-box: fill-box;
  transform-origin: center;
  animation: float 4.5s ease-in-out 1.5s infinite;
}

/* "Room for one more": the four shuffle over and a fifth skips in to take
   the free hand. Hover on pointer devices, tap/press anywhere. */
.crew {
  transform: translateX(39px);
  transition: transform 900ms var(--spring);
}
#one-more {
  opacity: 0;
  transform: translateX(56px);
  transition:
    opacity 420ms var(--ease),
    transform 900ms var(--spring);
}
.drawing-btn[aria-pressed="true"] .crew,
.drawing-btn:focus-visible .crew {
  transform: none;
}
.drawing-btn[aria-pressed="true"] #one-more,
.drawing-btn:focus-visible #one-more {
  opacity: 1;
  transform: none;
  transition-delay: 120ms;
}
@media (hover: hover) {
  .drawing-btn:hover .crew {
    transform: none;
  }
  .drawing-btn:hover #one-more {
    opacity: 1;
    transform: none;
    transition-delay: 120ms;
  }
}

.tagline {
  max-width: 34ch;
  text-align: center;
  font-weight: 350;
  font-style: italic;
  font-size: clamp(1.0625rem, 0.95rem + 0.45vw, 1.375rem);
  font-variation-settings:
    "SOFT" 100,
    "WONK" 1;
  line-height: 1.4;
  text-wrap: balance;
  opacity: 0;
  animation: rise 1400ms var(--ease) 450ms forwards;
}

.tagline span {
  display: block;
  margin-top: 6px;
  font-size: 0.875em;
  color: var(--ink-soft);
}

/* ---------- About / Works ---------- */

.prose {
  width: 100%;
  max-width: calc(40rem + 2 * var(--frame));
  margin-inline: auto;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  font-weight: 350;
  line-height: 1.65;
  opacity: 0;
  animation: rise 1000ms var(--ease) 100ms forwards;
}

.lede {
  font-weight: inherit;
  font-style: italic;
  font-size: 1.125em;
  font-variation-settings:
    "SOFT" 100,
    "WONK" 1;
  line-height: 1.5;
  margin-bottom: 2.5rem;
  text-wrap: pretty;
}
.lede em {
  font-style: normal;
}

.prose a {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition:
    color 200ms var(--ease),
    text-underline-offset 200ms var(--ease);
}
.prose a:hover {
  color: var(--heart);
  text-underline-offset: 5px;
}

/* Credits (About) and index (Works) share one ruled two-column grid. */
.credits,
.index {
  list-style: none;
  border-top: 1px solid var(--rule);
}

.person,
.work-link {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  align-items: baseline;
  gap: 6px 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}

.person h2,
.work-name {
  font-size: 1.25em;
  font-weight: 500;
  font-style: italic;
  font-variation-settings:
    "SOFT" 100,
    "WONK" 1;
  line-height: 1.3;
}

.role {
  list-style: none;
  color: var(--ink-soft);
  line-height: 20px;
}

.prose .work-link {
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) auto;
  text-decoration: none;
}
.work-meta {
  color: var(--ink-soft);
}
.work-meta span {
  display: inline-block;
  transition: transform 260ms var(--spring);
}
.work-link:hover .work-name,
.work-link:hover .work-meta {
  color: var(--heart);
}
.work-link:hover .work-meta span {
  transform: translate(2px, -2px);
}

.nowrap {
  white-space: nowrap;
}

/* ---------- 404 ---------- */

.lost {
  align-items: center;
  text-align: center;
  gap: 28px;
}
.lost svg {
  width: 72px;
  height: auto;
  overflow: visible;
}
.lost .lede {
  margin: 0;
}
.lost .lede span {
  display: block;
  font-size: 0.875em;
  color: var(--ink-soft);
}

/* ==========================================================================
   Narrow screens
   ========================================================================== */

@media (max-width: 640px) {
  .person,
  .prose .work-link {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  :root {
    --reserve-bottom: calc(var(--frame) + 2 * var(--chrome-line) + 12px + 32px);
  }
  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   Motion
   ========================================================================== */

@view-transition {
  navigation: auto;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 280ms;
  animation-timing-function: var(--ease);
}

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

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-7px) rotate(-3deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
  .drawing,
  .tagline,
  .prose {
    animation: none;
    opacity: 1;
  }
  #little-heart {
    animation: none;
  }
  .menu-list li,
  .crew,
  #one-more,
  .work-meta span,
  .prose a {
    transition: none;
  }
}

.one-more-grass {
  stroke: var(--c-grass);
}
