/* =========================================================
   PossumLogic.dev
   Palette: a possum's night out
   ========================================================= */
:root {
  --night: #191636;      /* page */
  --dusk: #2B2557;       /* raised surfaces */
  --moon: #F3EBD3;       /* text */
  --fog: #A9A3C9;        /* secondary text, strings */
  --porch: #FFB547;      /* porch light: actions */
  --snout: #F49AB0;      /* possum pink: highlights */
  --fur: #9C97B5;

  --line: rgba(169, 163, 201, .2);
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --nav-h: 72px;
  --branch-top: 92px;     /* where the branch svg starts inside the hero */
  --branch-y: calc(var(--branch-top) + 44px); /* the branch line itself */
  --pw: 220px;            /* possum width */

  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-optical-sizing: auto;
  color: var(--moon);
  background: var(--night);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--nav-h); }
body { margin: 0; font-size: 1.0625rem; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.05; font-variation-settings: "wdth" 82; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--porch); outline-offset: 4px; border-radius: 6px; }

.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: fixed; top: 1rem; left: 1rem; z-index: 50; background: var(--porch); color: var(--night); padding: .5rem 1rem; border-radius: 999px; }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto; z-index: 20; height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--gutter);
  transition: background-color .3s, box-shadow .3s;
}
.nav.is-scrolled {
  background: rgba(25, 22, 54, .82);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
}
.nav__brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav__brand svg { width: 30px; height: 30px; flex-shrink: 0; }
.nav__tld { color: var(--fog); font-weight: 400; }
.nav nav { display: flex; gap: clamp(1rem, 3vw, 2.25rem); }
.nav nav a { text-decoration: none; color: var(--fog); font-weight: 500; transition: color .2s; }
.nav nav a:hover { color: var(--moon); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; padding: .85rem 1.45rem; border-radius: 999px;
  font-weight: 600; text-decoration: none; line-height: 1;
  transition: transform .25s var(--spring), box-shadow .25s, border-color .2s, background-color .2s;
}
.btn--porch { background: var(--porch); color: var(--night); }
.btn--porch:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .6); }
.btn--ghost { border: 1.5px solid rgba(243, 235, 211, .3); }
.btn--ghost:hover { border-color: var(--moon); transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.97); }

/* =========================================================
   HERO
   ========================================================= */
.hero {
  position: relative; overflow: hidden;
  padding: 0 var(--gutter) clamp(3rem, 7vw, 6rem);
}
/* sky sits at z-index -2 so the site-wide fireflies (-1) fly in front of it but behind all content */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(60rem 40rem at 82% 10%, rgba(243, 235, 211, .08), transparent 60%),
    linear-gradient(180deg, #1D1940 0%, var(--night) 70%);
}

.moon {
  position: absolute; top: 40px; left: calc(78% - 130px);
  width: 300px; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #FBF5E3 0%, #EDE3C6 55%, #DCD0AE 100%);
  box-shadow: 0 0 120px 30px rgba(243, 235, 211, .14);
  opacity: .92;
}
.moon::before, .moon::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(170, 155, 120, .18);
}
.moon::before { width: 54px; height: 54px; top: 58%; left: 22%; }
.moon::after { width: 30px; height: 30px; top: 30%; left: 64%; }

/* branch */
.branch { position: absolute; left: 0; top: var(--branch-top); width: 100%; height: 80px; overflow: visible; }
.branch path { fill: none; stroke: #4A3A4E; stroke-linecap: round; }
.branch__line { stroke-width: 9; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1s var(--ease-out) .15s forwards; }
.branch__twig { stroke-width: 4; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .6s var(--ease-out) .7s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.leaf {
  position: absolute; top: calc(var(--branch-y) - 12px); left: var(--x);
  width: 22px; height: 12px; border-radius: 0 100% 0 100%;
  background: #5E7A5A; transform: rotate(var(--r)) scale(0);
  animation: leaf .5s var(--spring) calc(.8s + var(--d, 0s)) forwards;
}
@keyframes leaf { to { transform: rotate(var(--r)) scale(1); } }

/* wordmark: each letter hangs from the branch on its own string */
.wordmark {
  position: relative; z-index: 2;
  --drop: 38px;           /* shortest string: branch to the tallest glyph */
  padding-top: calc(var(--branch-y) + var(--drop));
  font-size: clamp(2.75rem, 10.5vw, 9.5rem);
  font-weight: 800; letter-spacing: .02em; line-height: .8;
  font-variation-settings: "wdth" 78;
  white-space: nowrap;
}
.wordmark__word { display: inline-block; }
.wordmark__word + .wordmark__word { margin-left: .02em; }
.wordmark__letter {
  position: relative; display: inline-block;
  /* pivot at the branch end of the string */
  transform-origin: 50% calc(-1 * var(--drop));
  opacity: 0; transform: translateY(-160%);
  animation: drop .8s var(--spring) calc(.55s + var(--i) * 45ms) forwards;
}
.wordmark__letter::before {
  /* --gap (set in main.js from the font's real metrics) runs the string down to the top of the ink */
  content: ""; position: absolute; left: 50%; bottom: calc(100% - var(--gap, .1em));
  width: 2px; height: calc(var(--drop) + var(--gap, .1em)); margin-left: -1px;
  background: linear-gradient(var(--fog), rgba(169, 163, 201, .45));
}
.wordmark__letter.is-swinging { animation: swing 1.1s ease-out; opacity: 1; transform: rotate(var(--tilt, 0deg)); }
@keyframes drop { to { opacity: 1; transform: rotate(var(--tilt, 0deg)); } }
@keyframes swing {
  0% { transform: rotate(var(--tilt, 0deg)); }
  20% { transform: rotate(calc(var(--tilt, 0deg) + 8deg)); }
  45% { transform: rotate(calc(var(--tilt, 0deg) - 5deg)); }
  70% { transform: rotate(calc(var(--tilt, 0deg) + 2deg)); }
  100% { transform: rotate(var(--tilt, 0deg)); }
}

.hero__copy {
  position: relative; z-index: 2;
  max-width: min(32rem, 56vw);
  margin-top: 3.5rem;
  opacity: 0; animation: fade .8s var(--ease-out) 1.5s forwards;
}
.hero__lede { font-size: clamp(1.15rem, 1.6vw, 1.35rem); line-height: 1.5; color: var(--moon); }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* fireflies: one fixed layer behind the whole site (dots are generated in main.js) */
.fireflies { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.fireflies i {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--size, 5px); height: var(--size, 5px); border-radius: 50%;
  background: #FFD27A; box-shadow: 0 0 10px 3px rgba(255, 196, 90, .5);
  opacity: 0;
  animation: drift var(--t, 14s) ease-in-out var(--dl, 0s) infinite, flicker var(--f, 2.6s) ease-in-out var(--dl, 0s) infinite;
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(var(--dx1), var(--dy1)); }
  66% { transform: translate(var(--dx2), var(--dy2)); }
}
@keyframes flicker { 0%, 100% { opacity: 0; } 40%, 60% { opacity: var(--glow, .9); } }

/* possum */
.possum {
  position: absolute; z-index: 3;
  width: var(--pw);
  left: calc(78% - var(--pw) / 2);
  top: calc(var(--branch-top) + 37px - var(--pw) * 20 / 180);
  padding: 0; border: 0; background: none; cursor: pointer; color: inherit; font: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 0; transform: translateY(-80px);
  animation: possum-in .9s var(--spring) 1.15s forwards;
}
@keyframes possum-in { to { opacity: 1; transform: none; } }
.possum:focus-visible { outline-offset: 0; border-radius: 30px; }
.possum svg { overflow: visible; }

.possum__swing { transform-origin: 0 0; animation: sway 5s ease-in-out 2s infinite; }
.possum__limp { transform-origin: 0 0; transition: transform .5s var(--spring); }
.possum:hover .possum__limp { transform: rotate(-3deg); }
@keyframes sway { 0%, 100% { transform: rotate(-3.5deg); } 50% { transform: rotate(3.5deg); } }

.possum__tail { fill: none; stroke: #E9A3B4; stroke-width: 7; stroke-linecap: round; }
.possum__limb { fill: none; stroke: #6E6890; stroke-width: 9; stroke-linecap: round; }
.possum__whiskers path { stroke: rgba(26, 23, 51, .35); stroke-width: 1.2; stroke-linecap: round; }
.possum__eye { transform-box: fill-box; transform-origin: center; transition: transform .09s; }
.possum.is-blinking .possum__eye { transform: scaleY(.1); }
.possum__dead { opacity: 0; }
.possum__dead path { stroke: #1A1733; stroke-width: 3; stroke-linecap: round; }

.possum.is-dead .possum__limp { transform: rotate(14deg) translateY(6px); }
.possum.is-dead .possum__alive { opacity: 0; }
.possum.is-dead .possum__dead { opacity: 1; }
.possum.is-dead .possum__arms { transform: translateY(5px); }

.possum__hint {
  position: absolute; left: 50%; top: 93%; transform: translateX(-50%);
  font-size: .85rem; color: var(--fog); white-space: nowrap;
  transition: opacity .3s;
}
.possum__hint::before { content: "↑ "; }
.possum.was-poked .possum__hint { opacity: 0; }

/* =========================================================
   SECTIONS
   ========================================================= */
.section {
  max-width: 1160px; margin: 0 auto;
  padding: clamp(5rem, 10vw, 8rem) var(--gutter);
}
.section h2 { font-size: clamp(2.5rem, 6vw, 4rem); font-weight: 750; }
.section__intro { margin-top: 1rem; max-width: 36rem; color: var(--fog); font-size: 1.15rem; }

/* status chips */
.status {
  display: inline-block; padding: .45rem .85rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--fog); background: rgba(169, 163, 201, .12);
}
.status--live { color: var(--snout); background: rgba(244, 154, 176, .14); }
.status--wip { color: var(--porch); background: rgba(255, 181, 71, .13); }
.status--sketch { color: #B9D3B2; background: rgba(185, 211, 178, .12); }

/* featured project */
.featured {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(2rem, 4vw, 3.5rem);
  align-items: center; margin-top: 3.5rem;
}
.featured__shot {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 10;
  border-radius: 24px; overflow: hidden; text-decoration: none;
  background: var(--dusk);
  border: 1.5px solid var(--line);
  transition: transform .45s var(--spring), border-color .3s;
}
.featured__shot:hover { transform: rotate(-1deg) scale(1.015); border-color: rgba(255, 181, 71, .55); }
.phone {
  position: absolute; top: 12%; left: 50%; width: 30%; height: auto;
  border-radius: 18px; border: 3px solid #0F0D24;
  box-shadow: 0 18px 30px -14px rgba(0, 0, 0, .7);
  transition: transform .5s var(--spring);
}
.phone--back { transform: translateX(-95%) rotate(-7deg); }
.phone--front { transform: translateX(-10%) translateY(6%) rotate(5deg); }
.featured__shot:hover .phone--back { transform: translateX(-102%) rotate(-10deg); }
.featured__shot:hover .phone--front { transform: translateX(-4%) translateY(3%) rotate(8deg); }
.doodles { position: absolute; inset: 8%; width: 84%; height: 84%; }
.doodles path, .doodles circle {
  fill: none; stroke: var(--porch); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .5;
  stroke-dasharray: 1; stroke-dashoffset: 0;
}
.featured__shot:hover .doodles path,
.featured__shot:hover .doodles circle { animation: redraw 1.2s var(--ease-out); }
@keyframes redraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.featured__placeholder {
  position: relative; padding: .5rem 1rem; border-radius: 999px;
  background: rgba(25, 22, 54, .75); color: var(--fog); font-size: .9rem;
}
.featured__body h3 { font-size: clamp(2.25rem, 4.5vw, 3.25rem); font-weight: 750; margin: 1rem 0 .9rem; }
.featured__body > p { color: var(--fog); max-width: 30rem; }

.facts { display: flex; flex-wrap: wrap; gap: 1.5rem 2.25rem; margin: 1.75rem 0 0; }
.facts dt, .now dt { font-size: .85rem; color: var(--fog); }
.facts dd, .now dd { margin: 0; font-weight: 600; }

.featured + .featured { margin-top: clamp(5rem, 9vw, 7rem); }
.featured--flip { grid-template-columns: 1fr 1.3fr; }
.featured--flip .featured__shot { order: 2; }

/* how to keep a game on your phone */
.keep {
  margin-top: clamp(5rem, 9vw, 7rem); max-width: 44rem;
  padding: clamp(1.5rem, 4vw, 2.5rem); border-radius: 24px;
  background: var(--dusk);
}
.keep h3 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 750; }
.keep > p { margin-top: .75rem; color: var(--fog); }
.steps { margin: 1.25rem 0 1.25rem; border-top: 1px solid var(--line); }
.steps div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.steps dt { color: var(--snout); font-weight: 600; }
.steps dd { margin: 0; }

/* the rest of the projects */
.burrow { list-style: none; margin: 4rem 0 0; padding: 0; border-bottom: 1px solid var(--line); }
.burrow__row { border-top: 1px solid var(--line); }
.burrow__row > a, .burrow__row--empty {
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr) auto; align-items: center; gap: 1rem;
  padding: 1.5rem .75rem; text-decoration: none;
  transition: background-color .25s;
}
.burrow__row > a:hover { background: rgba(243, 235, 211, .035); }
.burrow__name {
  font-size: clamp(1.35rem, 2.5vw, 1.85rem); font-weight: 650; font-variation-settings: "wdth" 85;
  transition: transform .35s var(--spring), color .2s;
}
.burrow__row > a:hover .burrow__name { transform: translateX(10px); color: var(--porch); }
.burrow__what { color: var(--fog); }
.burrow__row--empty { color: var(--fog); }
.burrow__row--empty .burrow__name { font-weight: 400; font-style: normal; opacity: .75; }

/* about */
.about { display: grid; grid-template-columns: minmax(200px, 320px) 1fr; gap: clamp(2.5rem, 6vw, 5rem); align-items: start; }
.about__portrait {
  aspect-ratio: 1; border-radius: 40% 40% 48% 48%;
  display: grid; place-items: center; align-content: center; gap: 1rem;
  background: var(--dusk); border: 2px dashed rgba(169, 163, 201, .3);
  color: var(--fog); font-size: .9rem;
}
.about__portrait svg { width: 42%; }
.about__text > p { margin-top: 1.25rem; max-width: 38rem; color: var(--fog); font-size: 1.15rem; }
.about__text > p:first-of-type { color: var(--moon); }
.now { margin: 2.5rem 0 0; display: grid; gap: 0; max-width: 38rem; border-top: 1px solid var(--line); }
.now div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
.now dd { font-weight: 500; }

/* contact */
.contact__mail {
  display: inline-block; margin-top: 2.5rem;
  font-size: clamp(1.6rem, 5.5vw, 3.5rem); font-weight: 750; font-variation-settings: "wdth" 82;
  text-decoration: underline; text-decoration-color: var(--porch); text-decoration-thickness: 3px; text-underline-offset: .18em;
  transition: color .2s;
  overflow-wrap: anywhere;
}
.contact__mail:hover { color: var(--porch); }
.contact__links { list-style: none; padding: 0; margin: 2.5rem 0 0; display: flex; flex-wrap: wrap; gap: .75rem; }
.contact__links a {
  display: inline-block; padding: .6rem 1.1rem; border-radius: 999px; text-decoration: none;
  border: 1.5px solid var(--line); color: var(--fog); font-weight: 500;
  transition: color .2s, border-color .2s;
}
.contact__links a:hover { color: var(--moon); border-color: var(--fog); }

/* footer */
.footer {
  max-width: 1160px; margin: 0 auto; padding: 2.5rem var(--gutter) 3rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-top: 1px solid var(--line); color: var(--fog); font-size: .95rem;
}
.footer a { color: var(--fog); }
.footer a:hover { color: var(--moon); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
  :root { --pw: 170px; }
  .featured, .featured--flip { grid-template-columns: 1fr; }
  .featured--flip .featured__shot { order: 0; }
  .about { grid-template-columns: 1fr; }
  .about__portrait { width: min(240px, 70%); }
}
@media (max-width: 640px) {
  :root { --pw: 104px; --branch-top: 76px; }
  .possum { left: calc(87% - var(--pw) / 2); }
  .moon { width: 170px; left: calc(87% - 95px); top: 50px; }
  .hero__copy { max-width: none; margin-top: 5rem; }
  .possum__hint { display: none; }
  .nav__tld { display: none; }
  .burrow__row > a, .burrow__row--empty { grid-template-columns: 1fr auto; }
  .burrow__what { grid-column: 1; grid-row: 2; font-size: .95rem; }
  .burrow__row .status { grid-column: 2; grid-row: 1 / span 2; }
  .steps div { grid-template-columns: 1fr; gap: .1rem; }
}

@media (max-width: 480px) {
  .nav__brand > span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .fireflies { display: none; }
  .possum__swing { animation: none; }
}
