/* ============================================================
   tokens
   ============================================================ */
:root {
  --bg:      #F4F0E8;   /* warm linen */
  --card:    #FAF7F1;   /* a card lifted off the linen */
  --fg:      #1E1B16;   /* deep ink: headline and body */
  --muted:   #625B51;   /* 5.1:1 on the label fill, the darkest place it sits */
  --accent:  #3F6B4A;   /* the frog's green, deep enough for text */
  --line:    rgba(30, 27, 22, .14);
  --line-strong: rgba(30, 27, 22, .32);
  --hover:   rgba(30, 27, 22, .05);
  --sel:     rgba(63, 107, 74, .18);
  --label:   #E8E1D3;   /* woven label fill */
  --patch:   #FBF8F1;   /* rim of the avatar patch, like the avatar's own backing */

  /* A seam. Dividers on the site are drawn with this. */
  --stitch: 1.5px dashed var(--line-strong);

  --serif: 'Roboto Serif', Charter, 'Iowan Old Style', Georgia, serif;
  --mono:  'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gutter: 24px;
  --col: 720px;    /* reading column: case studies */
  --wide: 1080px;  /* home sections, top bar, footer */
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--sel); }

a { color: inherit; }

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

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

.wrap {
  max-width: var(--col);
  margin: 0 auto;
  padding-inline: var(--gutter);
}
.wrap.wide { max-width: var(--wide); }

/* The top bar and footer run at the wide measure on every page, so they sit
   in the same place whether you are on the home page or in a case study. */
.topbar .wrap,
footer .wrap { max-width: var(--wide); }

/* ============================================================
   top bar
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease;
}
.topbar.stuck { border-bottom-color: var(--line); }

.topbar .wrap {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.01em;
  text-decoration: none;
}

/* Elsewhere: GitHub and LinkedIn, on the right of every top bar */
.toplinks {
  display: flex;
  align-items: center;
  gap: 22px;
  font-family: var(--mono);
  font-size: 13px;
}
.toplinks a { text-decoration: none; }
.toplinks a:hover { text-decoration: underline dashed; text-underline-offset: 4px; }
@media (max-width: 600px) {
  .brand { font-size: 18px; }
  .toplinks { gap: 12px; font-size: 12px; }
  .toplinks .ext { display: none; }
}



/* ============================================================
   letter controls (a single Pause under the name on About)
   ============================================================ */
.letter-controls:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}
.letter-controls button {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: none;
  font: inherit;
  color: var(--fg);
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease;
}
.letter-controls button:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  border-bottom-style: dashed;
}

/* ============================================================
   letters (assets/letters.js)
   ============================================================ */
/* Two rows share one box. The .letter row draws the name and holds the
   images; a transparent copy of the same letters sits on top and takes the
   pointer. Both get the same padding, so hit areas follow the push. */
.words {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.3em;
  touch-action: pan-y pinch-zoom;   /* sideways drags play the letters, vertical ones still scroll */
}

.letter {
  position: relative;
  display: inline-grid;
  align-items: center;
  height: 1.08em;
  pointer-events: none;
  transition: padding-inline .55s cubic-bezier(.22, 1, .36, 1);
}
.letter .char { grid-area: 1 / 1; justify-self: center; line-height: 1; }
.letter.active .char,
.letter.pending .char { visibility: hidden; }
.letter.returning .char {
  animation: letter-return var(--letter-exit, 620ms) cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes letter-return {
  0%, 20% { opacity: 0; transform: scale(.88); }
  65%     { opacity: 1; transform: scale(1.035); }
  100%    { opacity: 1; transform: scale(1); }
}

.sticker {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  z-index: 1;
  pointer-events: none;
}
/* height is set per image by letters.js; max-width matches its MAX_W. */
.sticker img {
  display: block;
  width: auto;
  max-width: 1.38em;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.hit-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  user-select: none;
  pointer-events: none;
}
.hit {
  display: inline-flex;
  align-items: center;
  height: 1.35em;
  line-height: 1;
  pointer-events: auto;
  transition: padding-inline .55s cubic-bezier(.22, 1, .36, 1);
}

/* ============================================================
   footer (case pages)
   ============================================================ */
footer {
  border-top: var(--stitch);
  padding: 26px 0 40px;
}
.colophon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.colophon .soc { display: flex; gap: 16px; }
.colophon a {
  text-decoration: none;
  transition: color .18s ease;
}
.colophon a:hover { color: var(--accent); }

/* ============================================================
   case studies
   ============================================================ */
.case-body { padding-block: 56px 64px; }

.back {
  display: inline-flex;
  align-items: baseline;
  gap: .45em;
  margin-bottom: 40px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: color .18s ease;
}
.back:hover { color: var(--accent); }
.back .arr { transition: transform .18s ease; }
.back:hover .arr { transform: translateX(-3px); }

.case-label {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Page-level, well under the hero name so the hierarchy still reads. */
.case-title {
  margin: 12px 0 0;
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.08;
}

/* A data table, so it keeps solid hairlines rather than seams. */
.facts {
  margin: 24px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.facts .f {
  display: flex;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
}
.facts dt { width: 68px; flex: none; color: var(--muted); }
.facts dd { margin: 0; }

.case-prose { margin-top: 40px; }
.case-prose p { margin: 0; font-size: 17px; line-height: 1.75; }
.case-prose p + p { margin-top: 22px; }

.case-fig { margin: 32px 0; }
.case-fig img {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line);
}
.case-fig figcaption {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

/* A case study's outbound link (repo, live demo), when there is one. A bare
   text link here reads as a footnote to the prose above it, so the seam
   separates it and the border gives it a real target to aim at. */
.case-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
  padding-top: 30px;
  border-top: var(--stitch);
}
/* An optional heading over the links, on a line of its own. */
.case-cta .case-label { flex-basis: 100%; }
.case-cta a {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--fg);
  text-decoration: none;
  transition: color .18s ease, border-color .18s ease, background-color .18s ease;
}
.case-cta a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--hover);
}
.case-cta svg { width: 17px; height: 17px; flex: none; }
.case-cta .arr { transition: transform .18s ease; }
.case-cta a:hover .arr { transform: translateX(3px); }

/* prev / next between case studies */
.pager {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding-block: 26px 56px;
  border-top: var(--stitch);
}
.pager a {
  flex: 1;
  max-width: 48%;
  text-decoration: none;
  transition: color .18s ease;
}
.pager a.next { text-align: right; }
/* Keeps a lone "next" pinned right when there is no previous entry. */
.pager a.next:only-child { margin-left: auto; }
.pager .dir {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.pager .name {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.015em;
}
.pager a:hover .name { color: var(--accent); }

/* ============================================================
   motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
