/* ===========================================================
   meta_legend - Personal Website
   Theme: editorial / typography-first.
   Warm paper, ink text, serif display (Fraunces),
   mono micro-labels, hairline rules, one accent.
   =========================================================== */

:root {
  /* Palette: #DDD8C4 #A3C9A8 #84B59F #69A297 #50808E */
  --paper:      #ddd8c4;
  --paper-soft: #d0ccb4;
  --ink:        #22363c;
  --ink-soft:   #41585f;
  --ink-faint:  #67797d;
  --line:       #c2bda4;
  --line-dark:  #22363c;
  --accent:     #50808e;
  --sage:       #a3c9a8;
  --cambridge:  #84b59f;
  --verdigris:  #69a297;

  /* Aliases for legacy pages (leaderboard.html) built on old token names */
  --bg-soft:      var(--paper-soft);
  --border-lit:   var(--line);
  --muted:        var(--ink-soft);
  --accent-2:     var(--verdigris);
  --font-display: var(--font-disp);

  --max: 980px;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-disp: 'Fraunces', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; color-scheme: only light; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
strong { color: var(--ink); font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.grad { font-style: italic; color: var(--accent); }

::selection { background: var(--verdigris); color: var(--paper); }

/* ---------- Background: none. Paper is the design. ---------- */
.bg-grid, .bg-glow { display: none; }

/* ---------- Navbar ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 24px;
  padding: 20px clamp(20px, 5vw, 56px);
  border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s, padding .3s;
}
.nav.scrolled {
  background: rgba(251, 249, 244, 0.94);
  backdrop-filter: blur(8px);
  border-bottom-color: var(--line);
  padding-top: 14px; padding-bottom: 14px;
}
.nav__brand { font-family: var(--font-mono); font-size: .88rem; display: flex; align-items: center; gap: 8px; }
.nav__logo { font-size: .85rem; }
.nav__name { letter-spacing: .02em; }
.nav__links { display: flex; gap: 30px; margin-left: auto; }
.nav__links a {
  font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-soft);
  transition: color .15s;
}
.nav__links a:hover { color: var(--accent); }
.nav__cta {
  font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em;
  padding: 8px 16px; border: 1px solid var(--ink); border-radius: 4px; color: var(--ink);
  transition: background .15s, color .15s;
}
.nav__cta:hover { background: var(--ink); color: var(--paper); }
.nav__burger {
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  width: 44px; height: 44px; margin-left: auto; background: none; border: 0; cursor: pointer;
}
.nav__burger span { width: 22px; height: 1.5px; background: var(--ink); transition: .3s; }
.nav__burger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav__burger.open span:nth-child(2) { opacity: 0; }
.nav__burger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; font-family: var(--font-mono); font-size: .82rem;
  text-transform: uppercase; letter-spacing: .12em;
  padding: 14px 28px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--ink);
  transition: background .18s, color .18s, border-color .18s;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--verdigris); border-color: var(--verdigris); }
.btn--ghost { color: var(--ink); background: transparent; }
.btn--ghost:hover { background: var(--ink); color: var(--paper); }
.btn--lg { padding: 17px 36px; }

/* ---------- Hero ---------- */
.hero {
  min-height: 94vh; display: grid; grid-template-columns: .95fr 1.05fr;
  align-items: center; gap: 36px; position: relative;
  padding: 120px clamp(20px, 5vw, 56px) 60px;
  max-width: 1280px; margin: 0 auto;
}
.hero__art svg { width: 100%; height: auto; display: block; }
.hero__art .ship {
  animation: ship-bob 7s ease-in-out infinite;
  transform-box: fill-box; transform-origin: center 80%;
}
@keyframes ship-bob {
  0%, 100% { transform: translate(-16px, 0) rotate(-1.8deg); }
  50%      { transform: translate(18px, -10px) rotate(1.8deg); }
}
.hero__art .wave { animation: wave-drift 6s ease-in-out infinite alternate; }
.hero__art .wave-b { animation-duration: 8s; animation-direction: alternate-reverse; }
.hero__art .wave-c { animation-duration: 10s; }
@keyframes wave-drift {
  from { transform: translateX(-22px); }
  to   { transform: translateX(22px); }
}
.hero__art .birds { animation: birds-fly 12s ease-in-out infinite alternate; }
@keyframes birds-fly {
  from { transform: translate(-46px, 14px); }
  to   { transform: translate(58px, -20px); }
}
.hero__eyebrow {
  font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .18em; color: var(--accent); margin-bottom: 28px;
}
.hero__title {
  font-family: var(--font-disp); font-weight: 500; white-space: nowrap;
  font-size: clamp(2.4rem, 6.5vw, 4.7rem); line-height: 1.0; letter-spacing: -.015em;
}
.hero__subtitle {
  font-family: var(--font-disp); font-weight: 400; font-style: italic; color: var(--ink-soft);
  font-size: clamp(1.6rem, 5.4vw, 3.1rem); line-height: 1.15; margin-top: 18px; letter-spacing: -.01em;
}
.hero__subtitle .grad { color: var(--accent); font-style: italic; }
.hero__lead { max-width: 560px; color: var(--ink-soft); font-size: 1.06rem; margin-top: 34px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 44px; }
.hero__socials {
  display: flex; align-items: center; gap: 16px; margin-top: 38px;
  font-family: var(--font-mono); font-size: .8rem; color: var(--ink-faint);
}
.hero__socials a {
  color: var(--ink-soft); text-decoration: underline;
  text-decoration-color: var(--line); text-underline-offset: 4px;
  transition: color .15s, text-decoration-color .15s;
}
.hero__socials a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.hero__scroll { display: none; }

/* ---------- Sections ---------- */
.section { max-width: var(--max); margin: 0 auto; padding: 96px clamp(20px, 5vw, 56px); }
.section__head { display: flex; align-items: baseline; gap: 18px; margin-bottom: 56px; }
.section__num { font-family: var(--font-mono); color: var(--accent); font-size: .78rem; letter-spacing: .1em; }
.section__title {
  font-family: var(--font-disp); font-weight: 500;
  font-size: clamp(1.9rem, 4.6vw, 2.8rem); letter-spacing: -.01em; white-space: nowrap;
}
.section__line { height: 1px; flex: 1; background: var(--line); align-self: center; }

/* ---------- About ---------- */
.page--about { max-width: 1360px; }
.page--about .section { max-width: 1360px; }
.page--about .section--first { padding-top: 34px; }
.about {
  display: grid; grid-template-columns: minmax(0, 3.35fr) minmax(250px, .8fr);
  gap: 58px; align-items: start;
}
.notebook {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  --pencil-travel: 240px;
  position: relative; transform: translate(-30px, 22px);
  perspective: 1200px;
}
.notebook__page {
  min-height: 610px; position: relative; z-index: 15; padding: 88px 48px 88px;
  border: 0; color: var(--ink-soft);
  background: transparent;
}
.notebook__paper {
  position: absolute; z-index: 14; inset: 0; width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
.notebook__paper { filter: drop-shadow(7px 9px 0 var(--paper-soft)); }
.notebook__paper path { fill: #f6f3e7; }
.notebook__outline {
  position: absolute; z-index: 18; inset: 0; width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
.notebook__outline path { fill: none; stroke: var(--ink); stroke-width: 3; vector-effect: non-scaling-stroke; }
.notebook__rules {
  position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
.notebook__rules path {
  fill: none; stroke: rgba(194, 189, 164, .82); stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.notebook__curved-copy, .notebook__curved-writing {
  position: absolute; z-index: 3; inset: 0; width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
.notebook__curved-writing,
.notebook__pencil { visibility: hidden; }
.notebook--ready .notebook__curved-writing,
.notebook--ready .notebook__pencil { visibility: visible; }
.notebook__curved-copy text {
  fill: var(--ink-soft); font-family: var(--font-body); font-size: 14px;
  transform: translateY(-7px);
}
.notebook__curved-copy .notebook__curve-label {
  fill: var(--accent); font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; letter-spacing: 2px;
}
.notebook__curved-copy .notebook__curve-mono { font-family: var(--font-mono); font-size: 12px; }
.notebook__curved-writing {
  clip-path: inset(0 100% 0 0);
  animation: notebook-curved-writing 4.2s ease-in-out 2.95s infinite backwards;
}
.notebook__curved-writing text {
  fill: var(--ink); font-family: var(--font-disp); font-size: 16px; font-style: italic;
  transform: translateY(-11px);
}
.notebook__cover, .notebook__turn {
  position: absolute; z-index: 22; left: 50%; top: 0; bottom: 0; width: 50%;
  transform-origin: left center; transform-style: preserve-3d; pointer-events: none;
}
.notebook__cover svg, .notebook__turn svg {
  display: block; position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible;
  backface-visibility: hidden;
}
.notebook__turn-back {
  transform: rotateY(180deg);
  -webkit-backface-visibility: hidden;
}
.notebook__turn-copy text {
  fill: var(--ink-soft); font-family: var(--font-body); font-size: 14px;
  transform: translateY(-7px);
}
.notebook__turn-copy .notebook__curve-label {
  fill: var(--accent); font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; letter-spacing: 2px;
}
.notebook__page--left .notebook__curved-copy { visibility: hidden; }
.notebook--final-spread .notebook__page--left .notebook__curved-copy { visibility: visible; }
.notebook__page--right .notebook__curved-copy { visibility: hidden; }
.notebook--pages-visible .notebook__page--right .notebook__curved-copy { visibility: visible; }
.notebook__sheet-fill { fill: #f6f3e7; }
.notebook__cover .notebook__sheet-fill { fill: var(--sage); }
.notebook__sheet-edge {
  fill: none; stroke: var(--ink); stroke-width: 3; vector-effect: non-scaling-stroke;
}
.notebook__sheet-rules {
  fill: none; stroke: rgba(194, 189, 164, .7); stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}
.notebook__cover {
  color: var(--ink); text-align: center;
  font-family: var(--font-disp); font-size: clamp(1.5rem, 2.4vw, 2.4rem);
  font-weight: 500; font-style: italic; line-height: 1.25;
  opacity: 0; animation: notebook-cover-open 1.7s ease-in-out forwards;
}
.notebook__cover-title {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 40px;
  transform: translateX(3%); backface-visibility: hidden; -webkit-backface-visibility: hidden;
  animation: notebook-cover-title 1.7s step-end forwards;
}
.notebook__cover-title::before {
  content: ''; position: absolute; inset: 0; z-index: -1; transform: translateZ(-1px);
}
.notebook__turn {
  opacity: 0; animation: notebook-page-turn .68s ease-in-out forwards;
}
.notebook__closed-mask {
  position: absolute; z-index: 21; inset: 0;
  background: var(--paper); pointer-events: none;
}
.notebook__turn--1 { animation-delay: 1.55s; }
.notebook__turn--2 { animation-delay: 1.78s; }
.notebook__turn--3 { animation-delay: 2.01s; }
.notebook__turn--4 { display: none; }
.notebook__page p {
  position: relative; z-index: 1; margin: 0; font-size: .92rem; line-height: 33px;
}
.notebook__page > :is(.notebook__label, .notebook__copy, .about__tech),
.notebook__writing { display: none; }
.notebook__copy > span { display: block; height: 33px; white-space: nowrap; }
.notebook__page--left > .notebook__label,
.notebook__page--left .notebook__copy > span,
.notebook__page--left .about__tech li {
  transform: rotate(1.5deg); transform-origin: right center;
}
.notebook__page--right > .notebook__label,
.notebook__page--right .notebook__copy > span,
.notebook__page--right .about__tech li {
  transform: rotate(-1.5deg); transform-origin: left center;
}
.notebook__page p + p { margin-top: 33px; }
.notebook__label {
  position: relative; z-index: 1; display: block;
  height: 33px; font-family: var(--font-mono); font-size: .72rem; font-weight: 600;
  line-height: 33px; color: var(--accent); text-transform: uppercase; letter-spacing: .17em;
}
.notebook__label--tech { margin-top: 33px; }
.notebook .about__tech { position: relative; z-index: 1; gap: 0 20px; margin-top: 0; }
.notebook__writing {
  position: absolute; z-index: 2; left: 64px; bottom: 64px;
  display: block; width: 240px; height: 29px; padding-bottom: 5px;
  overflow: hidden; white-space: nowrap; line-height: 22px;
  border-bottom: 2px solid var(--accent);
  font-family: var(--font-disp); font-size: 1rem; font-style: italic; color: var(--ink);
  animation: notebook-writing 4.2s ease-in-out 4.9s infinite backwards;
}
.notebook__pencil {
  position: absolute; z-index: 4; left: 0; top: 0;
  width: 126px; height: 17px; background: var(--sage); border: 2px solid var(--ink);
  offset-path: path('M 32 521 C 102 488 220 486 312 511');
  offset-anchor: 0 50%; offset-rotate: 0deg;
  animation: notebook-pencil 4.2s ease-in-out 2.95s infinite backwards;
}
.notebook__pencil::before {
  content: ''; position: absolute; right: 100%; top: -2px;
  border-top: 8.5px solid transparent; border-bottom: 8.5px solid transparent;
  border-right: 20px solid #f0d3a6; filter: drop-shadow(-2px 0 0 var(--ink));
}
.notebook__pencil::after {
  content: ''; position: absolute; right: 0; top: 0;
  width: 18px; height: 100%; background: var(--accent); border-left: 2px solid var(--ink);
}
@keyframes notebook-cover-open {
  0% { opacity: 0; transform: rotateY(0deg); }
  28%, 48% { opacity: 1; transform: rotateY(0deg); }
  99% { opacity: 1; transform: rotateY(-180deg); }
  100% { opacity: 0; visibility: hidden; transform: rotateY(-180deg); }
}
@keyframes notebook-cover-title {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}
@keyframes notebook-page-turn {
  0% { opacity: 1; transform: rotateY(0deg); }
  99% { opacity: 1; transform: rotateY(-180deg); }
  100% { opacity: 0; visibility: hidden; transform: rotateY(-180deg); }
}
@keyframes notebook-writing {
  0%, 12% { clip-path: inset(0 100% 0 0); }
  62%, 100% { clip-path: inset(0); }
}
@keyframes notebook-curved-writing {
  0%, 12% { clip-path: inset(0 100% 0 0); }
  62%, 100% { clip-path: inset(0); }
}
@keyframes notebook-pencil {
  0%, 12% { offset-distance: 0%; transform: rotate(-5deg); }
  62% { offset-distance: 100%; transform: rotate(-5deg); }
  78%, 100% { offset-distance: 100%; transform: translateY(-3px) rotate(-1deg); }
}
@keyframes notebook-pencil-mobile {
  0%, 12% { transform: translateX(0) rotate(-5deg); }
  62% { transform: translateX(var(--pencil-travel)) rotate(-5deg); }
  78%, 100% { transform: translate(var(--pencil-travel), -3px) rotate(-1deg); }
}
.about__tech { list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin-top: 12px; }
.about__tech li {
  position: relative; padding-left: 22px;
  font-family: var(--font-mono); font-size: .82rem; line-height: 33px; color: var(--ink-soft);
}
.about__tech li::before { content: '—'; position: absolute; left: 0; color: var(--accent); }
.about__story {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line-dark); background: rgba(246, 243, 231, .48);
  box-shadow: 8px 9px 0 var(--paper-soft);
}
.about__story > :is(.notebook__cover, .notebook__turn, .notebook__closed-mask, .notebook__paper, .notebook__outline) {
  display: none;
}
.about__story .notebook__page {
  min-height: 0; padding: 42px 44px 46px; background: transparent;
}
.about__story .notebook__page + .notebook__page { border-left: 1px solid var(--line); }
.about__story .notebook__rules,
.about__story .notebook__curved-copy,
.about__story .notebook__curved-writing,
.about__story .notebook__pencil,
.about__story .notebook__writing {
  display: none;
}
.about__story .notebook__page > :is(.notebook__label, .notebook__copy, .about__tech) { display: block; }
.about__story .notebook__page :is(.notebook__label, .notebook__copy > span, .about__tech li) {
  transform: none;
}
.about__story .notebook__label {
  height: auto; margin-bottom: 18px; line-height: 1.5;
}
.about__story .notebook__label--tech { margin-top: 30px; }
.about__story .notebook__copy {
  margin: 0; font-size: 1rem; line-height: 1.85;
}
.about__story .notebook__copy + .notebook__copy { margin-top: 24px; }
.about__story .notebook__copy > span {
  display: inline; height: auto; white-space: normal;
}
.about__story .notebook__copy > span::after { content: ' '; }
.about__story .about__tech { margin-top: 4px; }
.about__card { border-top: 1px solid var(--line-dark); padding-top: 32px; }
.about__avatar {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-disp); font-weight: 600; font-size: 1.85rem;
  background: var(--sage); border: 2px solid var(--ink); color: var(--ink);
  box-shadow: 4px 5px 0 var(--paper-soft); margin-bottom: 38px;
}
.about__stats { list-style: none; display: flex; flex-direction: column; gap: 28px; }
.about__stats li { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.about__stats li:last-child { border-bottom: 0; }
.about__stats .num { font-family: var(--font-disp); font-size: 3rem; font-weight: 500; line-height: 1; }
.about__stats .label {
  font-family: var(--font-mono); font-size: .72rem; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .14em; margin-top: 8px;
}
.about__skills-link {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 30px;
  padding: 11px 16px; border: 1px solid var(--ink); border-radius: 4px;
  font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--ink); transition: background .15s, color .15s;
}
.about__skills-link span { font-size: 1rem; line-height: 1; transition: transform .2s; }
.about__skills-link:hover { background: var(--ink); color: var(--paper); }
.about__skills-link:hover span { transform: translateY(3px); }

/* ---------- Projects: editorial index rows ---------- */
.projects { display: flex; flex-direction: column; border-top: 1px solid var(--line-dark); }
.projects .card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 34px 0 38px;
  border-bottom: 1px solid var(--line);
  transition: padding-left .25s ease;
  position: relative;
}
.projects .card:hover { padding-left: 14px; }
.projects .card::before {
  content: ''; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px;
  background: var(--accent); transform: scaleY(0); transform-origin: top;
  transition: transform .25s ease;
}
.projects .card:hover::before { transform: scaleY(1); }
.card__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card__icon { font-size: 1.8rem; line-height: 1; }
.card__icon--img { width: 40px; height: 40px; border-radius: 4px; object-fit: contain; }
.card__links { display: flex; gap: 18px; }
.card__links a {
  font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-faint); transition: color .15s;
}
.card__links a:hover { color: var(--accent); }
.card__title {
  font-family: var(--font-disp); font-weight: 500; font-size: 1.65rem; letter-spacing: -.01em;
  transition: color .2s;
}
.projects .card:hover .card__title { color: var(--accent); }
.card__desc { color: var(--ink-soft); font-size: .98rem; max-width: 62ch; }
.card__tags { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.card__tags span {
  font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-faint);
}
.card__tags span::before { content: '#'; color: var(--accent); margin-right: 1px; }
.projects__more { text-align: center; margin-top: 52px; }
.projects__more p { color: var(--ink-soft); margin-bottom: 20px; font-style: italic; font-family: var(--font-disp); }

/* ---------- Skills constellation ---------- */
#skills { scroll-margin-top: -56px; }
.skills__intro {
  max-width: 680px; margin: -28px 0 32px; color: var(--ink-soft); line-height: 1.75;
}
.skills__layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 136px; gap: 18px; align-items: center;
}
.skills__return { display: flex; justify-content: center; }
.skills__return .about__skills-link { margin-top: 0; }
.skills {
  position: relative; min-height: 680px; overflow: hidden;
  border: 1px solid var(--line-dark); background: rgba(246, 243, 231, .38);
  box-shadow: 8px 9px 0 var(--paper-soft);
}
.constellation__stars {
  position: absolute; z-index: 0; inset: 0; opacity: .35; pointer-events: none;
  background-image:
    radial-gradient(circle at 8% 24%, var(--ink) 0 1px, transparent 1.5px),
    radial-gradient(circle at 18% 72%, var(--ink) 0 1px, transparent 1.5px),
    radial-gradient(circle at 34% 38%, var(--ink) 0 1px, transparent 1.5px),
    radial-gradient(circle at 57% 58%, var(--ink) 0 1px, transparent 1.5px),
    radial-gradient(circle at 75% 32%, var(--ink) 0 1px, transparent 1.5px),
    radial-gradient(circle at 92% 62%, var(--ink) 0 1px, transparent 1.5px);
}
.constellation__lines {
  position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%;
  overflow: hidden; pointer-events: none;
}
.constellation__line {
  stroke: var(--line-dark); stroke-width: 1; stroke-dasharray: 3 6;
  transition: opacity .25s, stroke .25s, stroke-width .25s;
}
.constellation__node {
  position: absolute; z-index: 2; left: var(--x); top: var(--y);
  display: flex; align-items: center; gap: 7px; padding: 6px;
  border: 0; background: transparent; color: var(--ink); cursor: pointer;
  transform: translate(-50%, -50%); transition: opacity .25s, transform .25s;
}
.constellation__star {
  width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 4px rgba(20, 49, 58, .08), 0 0 12px rgba(20, 49, 58, .28);
}
.constellation__node--language .constellation__star {
  width: 15px; height: 15px; background: var(--sage); border: 2px solid var(--ink);
  box-shadow: 0 0 0 6px rgba(137, 181, 156, .2), 0 0 18px rgba(20, 49, 58, .35);
}
.constellation__node--tool .constellation__star { background: var(--accent); }
.constellation__node--concept .constellation__star { width: 5px; height: 5px; }
.constellation__label {
  position: relative; z-index: 1; padding: 2px 4px;
  background: rgba(239, 237, 224, .94); box-shadow: 0 0 0 2px rgba(239, 237, 224, .7);
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em;
  white-space: nowrap; text-transform: uppercase;
}
.constellation__node--language .constellation__label {
  font-family: var(--font-disp); font-size: 1.12rem; font-weight: 600;
  letter-spacing: 0; text-transform: none;
}
.constellation__detail {
  position: absolute; left: 50%; bottom: calc(100% + 8px); width: max-content; max-width: 220px;
  padding: 8px 10px; border: 1px solid var(--line-dark); background: var(--paper);
  box-shadow: 3px 4px 0 var(--paper-soft); color: var(--ink-soft);
  font-family: var(--font-body); font-size: .76rem; line-height: 1.4; text-align: left;
  opacity: 0; pointer-events: none; transform: translate(-50%, 5px);
  transition: opacity .18s, transform .18s;
}
.constellation__node:hover, .constellation__node:focus-visible { z-index: 5; transform: translate(-50%, -50%) scale(1.07); outline: none; }
.constellation__node:hover .constellation__detail,
.constellation__node:focus-visible .constellation__detail { opacity: 1; transform: translate(-50%, 0); }
.constellation__node--left-edge .constellation__detail {
  left: 0; transform: translate(0, 5px);
}
.constellation__node--left-edge:hover .constellation__detail,
.constellation__node--left-edge:focus-visible .constellation__detail { transform: translate(0, 0); }
.constellation__node--right-edge .constellation__detail {
  left: auto; right: 0; transform: translate(0, 5px);
}
.constellation__node--right-edge:hover .constellation__detail,
.constellation__node--right-edge:focus-visible .constellation__detail { transform: translate(0, 0); }
.constellation__node--top-edge .constellation__detail {
  top: calc(100% + 8px); bottom: auto;
}
.constellation__line.is-active { stroke: var(--accent); stroke-width: 2; stroke-dasharray: none; }
.constellation__node.is-muted, .constellation__line.is-muted { opacity: .16; }
.constellation__node.is-active .constellation__star { box-shadow: 0 0 0 5px rgba(137, 181, 156, .24), 0 0 18px var(--sage); }
@media (prefers-reduced-motion: no-preference) {
  .constellation__star { animation: constellation-twinkle 3.8s ease-in-out infinite alternate; }
  .constellation__node:nth-of-type(3n) .constellation__star { animation-delay: -1.7s; }
}
@keyframes constellation-twinkle {
  to { opacity: .62; transform: scale(.82); }
}

/* ---------- Projects: ferris wheel ---------- */
.wheel { margin: 0 0 24px; position: relative; padding-top: 30px; }
.wheel__frame {
  width: 880px; height: 830px; margin: 0 auto -130px; position: relative;
  transform: scale(.84); transform-origin: top center;
  transition: transform .55s ease, opacity .55s ease;
}
.wheel.launching .wheel__frame { transform: scale(.9); opacity: 0; }
.wheel__legs { position: absolute; inset: 0; }
.wheel__rot {
  position: absolute; left: 110px; top: 30px; width: 660px; height: 660px;
  animation: wheel-spin 55s linear infinite;
}
.wheel__rot:has(.cab:hover) { z-index: 10; }
.wheel__rot > svg { position: absolute; inset: 0; }
@keyframes wheel-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
@keyframes cab-counter {
  from { transform: translate(-50%, 0) rotate(0); }
  to   { transform: translate(-50%, 0) rotate(-360deg); }
}
.cab { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.cab__inner {
  display: block; position: absolute; left: 0; top: 0;
  transform-origin: 50% 0;
  animation: cab-counter 55s linear infinite;
  animation-delay: var(--d, 0s);
}
.cab__body {
  display: block; width: 96px; padding: 13px 8px 11px; margin-top: 15px;
  background: #f6f3e7; border: 1.5px solid var(--ink); border-radius: 8px;
  text-align: center; position: relative;
  transform-origin: 50% -15px;
  animation: cab-sway 4.5s ease-in-out infinite alternate;
  animation-delay: var(--sd, 0s);
  box-shadow: 3px 4px 0 0 var(--paper-soft);
  transition: border-color .2s, box-shadow .2s;
}
.cab__body::before {
  content: ''; position: absolute; left: 50%; top: -15px;
  width: 2px; height: 15px; background: var(--ink); transform: translateX(-50%);
}
@keyframes cab-sway { from { rotate: -3deg; } to { rotate: 3deg; } }
.cab__icon { display: block; font-size: 1.7rem; line-height: 1; }
.cab__icon img { width: 36px; height: 36px; object-fit: contain; display: block; margin: 0 auto; }
.cab__name {
  display: block; font-family: var(--font-mono); font-size: .66rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin-top: 7px;
}
/* Language tag: hangs by a wire from the spoke, just inward of its cabin */
.cab__tagpos { display: block; position: absolute; left: 0; top: 102px; width: 0; height: 0; }
.cab__minihang {
  display: block; position: absolute; left: 0; top: 0;
  transform-origin: 50% 0;
  animation: cab-counter 55s linear infinite;
  animation-delay: var(--d, 0s);
}
.cab__mini {
  display: block; position: relative; margin-top: 12px;
  font-family: var(--font-mono); font-size: .6rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-soft); white-space: nowrap;
  background: #f6f3e7; border: 1.5px solid var(--ink); border-radius: 5px;
  padding: 5px 9px; box-shadow: 2px 3px 0 0 var(--paper-soft);
}
.cab__mini::before {
  content: ''; position: absolute; left: 50%; top: -12px;
  width: 2px; height: 12px; background: var(--ink); transform: translateX(-50%);
}
.cab:hover .cab__body { border-color: var(--accent); box-shadow: 3px 4px 0 0 var(--sage); }
.wheel__rot:has(.cab:hover),
.wheel__rot:has(.cab:hover) .cab__inner,
.wheel__rot:has(.cab:hover) .cab__minihang { animation-play-state: paused; }
.wheel__hub {
  position: absolute; left: 423px; top: 343px; width: 34px; height: 34px;
  background: var(--ink); border: 3px solid #f6f3e7; border-radius: 50%;
  box-shadow: 0 0 0 3px var(--ink); z-index: 5;
}

/* Hover card */
.cab:hover { z-index: 40; }
.cab__card {
  display: block; position: absolute; left: 108px; top: -10px;
  width: 264px; padding: 18px 18px 16px;
  background: #f6f3e7; border: 1.5px solid var(--ink); border-radius: 8px;
  transform: translateX(8px) scale(.94);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  box-shadow: 4px 5px 0 0 var(--paper-soft);
  text-align: left;
}
.cab:hover .cab__card { opacity: 1; transform: translateX(0) scale(1); }
.cab__card.side-left {
  left: auto; right: 108px;
  transform: translateX(-8px) scale(.94);
}
.cab:hover .cab__card.side-left { transform: translateX(0) scale(1); }
.cab__card-title {
  display: block; font-family: var(--font-disp); font-weight: 500;
  font-size: 1.05rem; color: var(--ink); margin-bottom: 7px;
}
.cab__card-desc {
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  overflow: hidden; font-family: var(--font-body); font-size: .8rem;
  line-height: 1.55; color: var(--ink-soft); margin-bottom: 11px;
}
.cab__card-tags { display: flex; flex-wrap: wrap; gap: 12px; }
.cab__card-tags span {
  font-family: var(--font-mono); font-size: .66rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-faint);
}
.cab__card-tags span::before { content: '#'; color: var(--accent); }

/* Flappy Bird sprite flap animation */
.flap {
  display: block; width: 30px; height: 22px; margin: 0 auto;
  background: url('assets/yellowbird-midflap.png') center / contain no-repeat;
  image-rendering: pixelated;
  animation: flap .4s steps(1) infinite;
}
@keyframes flap {
  0%   { background-image: url('assets/yellowbird-upflap.png'); }
  33%  { background-image: url('assets/yellowbird-midflap.png'); }
  66%  { background-image: url('assets/yellowbird-downflap.png'); }
  100% { background-image: url('assets/yellowbird-upflap.png'); }
}
.proj__icon--flap { width: 60px; height: 44px; margin: 0; }
.proj__splash { height: 88px; width: auto; display: block; image-rendering: pixelated; }
.wheel__hint {
  position: absolute; top: 0; right: 0; margin: 0;
  font-family: var(--font-mono); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .12em; color: var(--ink-faint);
}
.card__title a { transition: color .2s; }
.projects .card:hover .card__title a { color: var(--accent); }

/* ---------- Project detail pages ---------- */
.proj__head-row { display: flex; align-items: center; gap: 20px; }
.proj__icon { width: 56px; height: 56px; object-fit: contain; }
.proj__icon--emoji { font-size: 2.6rem; line-height: 1; }
.proj__meta {
  font-family: var(--font-mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-faint); margin-top: 16px;
}
.proj__grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 56px; align-items: start; }
.proj__grid p { color: var(--ink-soft); margin-bottom: 18px; max-width: 60ch; }
.proj__grid strong { font-weight: 400; color: inherit; }
.proj__list { list-style: none; margin: 6px 0 18px; }
.proj__list li { position: relative; padding-left: 20px; color: var(--ink-soft); margin-bottom: 10px; }
.proj__list li::before { content: '•'; position: absolute; left: 2px; color: var(--accent); font-size: 1.15em; line-height: 1.45; }
.proj__sub {
  font-family: var(--font-disp); font-weight: 500; font-size: 1.4rem;
  letter-spacing: -.01em; margin: 28px 0 12px;
}
.facts { border-top: 1px solid var(--line-dark); padding-top: 10px; }
.facts > div { border-bottom: 1px solid var(--line); padding: 14px 0; }
.facts dt {
  font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase;
  letter-spacing: .14em; color: var(--ink-faint);
}
.facts dd { font-family: var(--font-disp); font-size: 1.15rem; margin: 4px 0 0; }
.proj__links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 36px; }

/* ---------- Contact ---------- */
.section--contact { text-align: center; padding-top: 190px; padding-bottom: 110px; min-height: 72vh; }
.contact { max-width: 660px; margin: 0 auto; }
.contact .section__num { display: block; margin-bottom: 20px; }
.contact__title {
  font-family: var(--font-disp); font-weight: 500; font-style: italic;
  font-size: clamp(2.4rem, 7vw, 4rem); letter-spacing: -.015em;
}
.contact__lead { color: var(--ink-soft); font-size: 1.05rem; margin: 26px auto 40px; max-width: 48ch; }
.contact__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 30px; margin-top: 44px; }
.contact__links a {
  font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-soft); text-decoration: underline;
  text-decoration-color: var(--line); text-underline-offset: 5px;
  transition: color .15s, text-decoration-color .15s;
}
.contact__links a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---------- Footer ---------- */
.footer {
  text-align: center; padding: 44px 20px;
  border-top: 1px solid var(--line-dark);
  color: var(--ink-soft); font-size: .92rem;
}
.footer__sub { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; color: var(--ink-faint); margin-top: 8px; }

/* ---------- Entrance animations (one-time, on load, every page) ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.nav { animation: fade .5s ease backwards; }
main, .hero { animation: rise .6s ease .08s backwards; }
.footer { animation: fade .6s ease .25s backwards; }
.anim { animation: rise .7s ease backwards; }
.anim-1 { animation-delay: .15s; }
.anim-2 { animation-delay: .3s; }
.anim-3 { animation-delay: .45s; }
.anim-4 { animation-delay: .6s; }
.anim-5 { animation-delay: .75s; }

.caret {
  display: inline-block; width: 9px; height: 1em; margin-left: 3px;
  background: var(--accent); vertical-align: text-bottom;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

#cycle-word {
  display: inline-block;
  transition: opacity .28s ease, transform .28s ease;
}
#cycle-word.swap { opacity: 0; transform: translateY(8px); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Subpages ---------- */
.page { max-width: var(--max); margin: 0 auto; }
.page__head {
  padding: 78px clamp(20px, 5vw, 56px) 0;
}
.page__title {
  font-family: var(--font-disp); font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 3.2rem); letter-spacing: -.015em;
  border-bottom: 1px solid var(--line-dark); padding-bottom: 12px;
}
.section--first { padding-top: 8px; }
.nav__links a[aria-current="page"] { color: var(--accent); }

.back-home {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-soft); margin-bottom: 14px;
  transition: color .15s;
}
.back-home .arr { transition: transform .2s ease; }
.back-home:hover { color: var(--accent); }
.back-home:hover .arr { transform: translateX(-4px); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 12px; padding-top: 124px; }
  .hero__art { max-width: 330px; margin: 0 auto; }
  .proj__grid { grid-template-columns: 1fr; }
  .about { grid-template-columns: 1fr; }
  .skills__layout { grid-template-columns: 1fr; }
  .skills__return { margin-top: 8px; }
  .notebook { transform: translateY(20px); }
  .nav__links, .nav__cta { display: none; }
  .nav__burger { display: flex; }
  .nav.open .nav__links {
    display: flex; flex-direction: column; gap: 22px;
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--paper); border-bottom: 1px solid var(--line);
    padding: 28px clamp(20px,5vw,56px);
  }
}
@media (max-width: 620px) {
  .about__story { grid-template-columns: 1fr; }
  .about__story .notebook__page { padding: 32px 26px 36px; border: 0; border-radius: 0; }
  .about__story .notebook__page + .notebook__page {
    border-left: 0; border-top: 1px solid var(--line);
  }
  .notebook {
    --pencil-travel: 175px;
    grid-template-columns: 1fr;
  }
  .notebook__cover, .notebook__turn, .notebook__closed-mask, .notebook__outline, .notebook__paper { display: none; }
  .notebook__page, .notebook__outline, .notebook__paper { animation: none; opacity: 1; }
  .notebook__page { min-height: auto; padding: 46px 26px 78px; }
  .notebook__page--left {
    background: #f6f3e7; border: 2px solid var(--ink);
    border-radius: 28px 28px 4px 4px;
    border-right-width: 2px; border-bottom-width: 1px;
  }
  .notebook__page--right {
    background: #f6f3e7; border: 2px solid var(--ink);
    min-height: 560px; border-radius: 4px 4px 28px 28px;
    border-left-width: 2px; border-top-width: 1px;
  }
  .notebook__page :is(.notebook__label, .notebook__copy > span, .about__tech li) { transform: none; }
  .notebook__curved-copy, .notebook__curved-writing { display: none; }
  .notebook__page > :is(.notebook__label, .notebook__copy, .about__tech),
  .notebook__writing { display: block; }
  .notebook__writing { left: 26px; width: 175px; font-size: .9rem; }
  .notebook__pencil {
    left: 46px; top: auto; bottom: 84px;
    offset-path: none; transform-origin: 8px 50%;
    animation-name: notebook-pencil-mobile;
  }
  .skills__intro { margin-top: -18px; }
  .skills {
    display: grid; grid-template-columns: 1fr; gap: 0; min-height: 0;
    overflow: visible; box-shadow: 5px 6px 0 var(--paper-soft);
  }
  .constellation__lines, .constellation__stars { display: none; }
  .constellation__node {
    position: relative; left: auto; top: auto; min-height: 54px; width: 100%;
    padding: 13px 16px; border-bottom: 1px solid var(--line);
    transform: none; text-align: left;
  }
  .constellation__node:last-child { border-bottom: 0; }
  .constellation__node--language { background: rgba(137, 181, 156, .18); }
  .constellation__node--tool { padding-left: 30px; }
  .constellation__node--concept { padding-left: 48px; }
  .constellation__node:hover, .constellation__node:focus-visible { transform: none; }
  .constellation__detail {
    position: static; display: block; width: auto; max-width: none; margin-left: auto; padding: 0 0 0 14px;
    border: 0; background: transparent; box-shadow: none; font-size: .7rem; text-align: right;
    opacity: 1; transform: none;
  }
  .constellation__node.is-muted { opacity: .3; }
}
@media (max-width: 1020px) {
  .wheel { display: none; }
}
@media (max-width: 480px) {
  .nav { padding-left: 16px; padding-right: 16px; }
  .hero { padding-left: 16px; padding-right: 16px; }
  .hero__title { white-space: normal; }
  .section { padding: 72px 16px; }
  .page__head { padding-left: 16px; padding-right: 16px; }
  .section__head { gap: 10px; margin-bottom: 40px; }
  .section__title { white-space: normal; }
  .section__line { display: none; }
  .about__tech { grid-template-columns: 1fr; }
  .hero__socials { flex-wrap: wrap; }
  .card__top { align-items: flex-start; flex-direction: column; gap: 14px; }
  .card__links { flex-wrap: wrap; gap: 12px 18px; }
  .proj__head-row { align-items: flex-start; flex-direction: column; }
  .proj__splash { width: 100%; max-width: 280px; height: auto; }
  .proj__links .btn, .lb__actions .btn { width: 100%; text-align: center; }
  .section--contact { padding-top: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto; }
  .anim { opacity: 1; transform: none; }
  .caret { display: none; }
  .wheel { display: none; }
  .notebook__cover, .notebook__turn, .notebook__closed-mask { display: none; }
  .notebook__page, .notebook__outline, .notebook__paper { opacity: 1; }
  .notebook__page--left .notebook__curved-copy { visibility: visible; }
  .notebook__page--right .notebook__curved-copy { visibility: visible; }
  .notebook__writing { clip-path: inset(0); }
  .notebook__pencil { offset-distance: 100%; transform: translateY(-3px) rotate(-1deg); }
}
