/* nathanasfaw.com — scrapbook redesign
   Fonts: Instrument Serif (italic) for names/titles, Instrument Sans for small UI text,
   Mona Sans for paragraphs. */

:root {
  --ink: #2b1c14;
  --grey: #736e66;
  --line: #dbd6cf;
  --green: #2f6b3f;
  --paper: #ffffff;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Mona Sans", "Instrument Sans", system-ui, sans-serif;
  --shadow: drop-shadow(0 3px 2px rgb(0 0 0 / 0.16)) drop-shadow(0 12px 12px rgb(0 0 0 / 0.12));
  --card-shadow: 0 2px 4px rgb(0 0 0 / 0.10), 0 14px 30px rgb(0 0 0 / 0.12);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 1rem; top: -3rem; padding: .5rem .75rem;
  background: var(--ink); color: #fff; border-radius: 6px; text-decoration: none; z-index: 10;
}
.skip-link:focus { top: 1rem; }

.back {
  display: inline-block;
  font: 500 15px/1 var(--sans);
  color: var(--grey);
  text-decoration: none;
}
.back:hover { color: var(--ink); }

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

.home {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.stage {
  position: relative;
  width: min(100vw, 1440px, calc(100svh * 1.6));
  aspect-ratio: 1440 / 900;
  container-type: inline-size;
}
.obj {
  position: absolute;
  left: calc(var(--x) / 1440 * 100%);
  top: calc(var(--y) / 900 * 100%);
  width: calc(var(--w) / 1440 * 100%);
  transform: translate(-50%, -50%) rotate(var(--r));
  text-decoration: none;
  transition: transform .25s ease;
  z-index: 1;
}
.obj img { width: 100%; height: auto; filter: var(--shadow); }
.obj:hover, .obj:focus-visible { transform: translate(-50%, -50%) rotate(calc(var(--r) * -0.4)) scale(1.06); z-index: 2; }
.obj .tag {
  position: absolute; left: 50%; top: 100%;
  transform: translate(-50%, 6px) rotate(calc(var(--r) * -1));
  font: 500 11px/1 var(--sans); letter-spacing: .06em;
  color: var(--ink); white-space: nowrap;
  opacity: 0; transition: opacity .2s ease;
}
.obj:hover .tag, .obj:focus-visible .tag { opacity: 1; }
@media (hover: none) { .obj .tag { opacity: 1; } }

.name {
  position: absolute; left: 50%; top: calc(455 / 900 * 100%);
  transform: translate(-50%, -50%);
  text-align: center; text-decoration: none; z-index: 1;
}
.name h1 {
  margin: 0;
  font: italic 400 7.2cqw/1 var(--serif);
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: transform .25s ease;
}
/* Name: turns green with an underline that grows from the center (adapted from Uiverse.io by WhiteNervosa) */
.name h1 {
  position: relative;
  display: inline-block;
  transition: color 450ms ease, transform 500ms ease;
}
.name h1::after {
  content: "";
  pointer-events: none;
  position: absolute;
  left: 50%;
  bottom: -0.04em;
  width: 0%;
  height: max(2px, 0.035em);
  border-radius: 999px;
  background-color: var(--green);
  transition: width 400ms cubic-bezier(0.25, 0.8, 0.25, 1), left 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
}
.name:hover h1, .name:focus-visible h1 { color: var(--green); }
.name:hover h1::after, .name:focus-visible h1::after { width: 100%; left: 0%; }
.name p { margin: .9em 0 0; font: 400 1.1cqw/1.3 var(--sans); color: var(--grey); letter-spacing: .04em; }

/* Desktop positions (from the 1440×900 Figma frame) */
.o-osmo     { --x: 250;  --y: 200; --w: 118; --r: -6deg; }
.o-laptop   { --x: 690;  --y: 180; --w: 290; --r: 3deg; }
.o-passport { --x: 1130; --y: 200; --w: 175; --r: 7deg; }
.o-phone    { --x: 170;  --y: 480; --w: 225; --r: 8deg; }
.o-vinyl    { --x: 1240; --y: 470; --w: 210; --r: -12deg; }
.o-folder   { --x: 400;  --y: 720; --w: 245; --r: -6deg; }
.o-acai     { --x: 960;  --y: 700; --w: 275; --r: 8deg; }

/* Mobile (from the 390×844 Figma frame) */
@media (max-width: 720px) {
  .stage { width: 100vw; aspect-ratio: 390 / 844; }
  .obj {
    left: calc(var(--mx) / 390 * 100%);
    top: calc(var(--my) / 844 * 100%);
    width: calc(var(--mw) / 390 * 100%);
    --r: var(--mr);
  }
  .name { top: calc(432 / 844 * 100%); }
  .name h1 { font-size: 13.4cqw; }
  .name p { font-size: 3.1cqw; white-space: nowrap; }
  .obj .tag { font-size: 9.5px; }
  .o-osmo     { --mx: 85;  --my: 150; --mw: 62;  --mr: -6deg; }
  .o-laptop   { --mx: 262; --my: 130; --mw: 150; --mr: 3deg; }
  .o-phone    { --mx: 100; --my: 305; --mw: 115; --mr: 8deg; }
  .o-passport { --mx: 298; --my: 290; --mw: 88;  --mr: 7deg; }
  .o-folder   { --mx: 108; --my: 575; --mw: 125; --mr: -6deg; }
  .o-vinyl    { --mx: 290; --my: 565; --mw: 108; --mr: -12deg; }
  .o-acai     { --mx: 200; --my: 725; --mw: 146; --mr: 8deg; }
}

/* ---------------------------------------------------------------- Shared page shell */

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 64px 120px 96px;
}
.page-title {
  margin: 0;
  font: italic 400 96px/1 var(--serif);
  letter-spacing: -0.02em;
}
.label {
  font: 500 13px/1 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--grey);
}

/* Polaroids */
.polaroid {
  margin: 0;
  background: #fff;
  padding: 14px 14px 18px;
  box-shadow: var(--card-shadow);
  transform: rotate(var(--r, 0deg));
}
.polaroid img { width: 100%; height: auto; aspect-ratio: var(--ar, 1); object-fit: cover; object-position: var(--pos, 50% 50%); background: #eee; }
.polaroid figcaption { margin-top: 12px; font: italic 400 20px/1.15 var(--serif); }

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

.about-head { margin: 56px 0; }
.about-head p { margin: 6px 0 0; font: 400 19px/1.4 var(--sans); color: var(--grey); }

.about-main {
  display: grid;
  grid-template-columns: 514px 1fr;
  gap: 96px;
  align-items: start;
}
.collage { position: relative; height: 920px; }
.collage .polaroid { position: absolute; }
.c-beach   { left: 14px;  top: 8px;   width: 318px; --ar: 290/360; --r: -3deg; }
.c-arsenal { left: 294px; top: 250px; width: 208px; --ar: 180/230; --r: 5deg; }
.c-kayak   { left: 30px;  top: 470px; width: 208px; --ar: 180/230; --r: 4deg; }
.c-steak   { left: 276px; top: 600px; width: 228px; --ar: 1; --r: -4deg; --pos: 50% 81%; }

.bio h2 { margin: 0 0 28px; font: italic 400 44px/1.1 var(--serif); }
.bio p { margin: 0 0 28px; font: 400 18px/1.65 var(--body); max-width: 62ch; }
.links { display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 0; margin: 4px 0 0; list-style: none; }
.links a { font: 500 17px/1.2 var(--sans); }
.links a:hover { color: var(--grey); }

.prints {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
  gap: 72px; margin-top: 48px;
}
.p-tfs  { width: 468px; --ar: 440/293; --r: -2deg; }
.p-nest { width: 478px; --ar: 450/300; --r: 2deg; }

@media (max-width: 1100px) {
  .page { padding: 48px 40px 80px; }
  .about-main { grid-template-columns: 1fr; gap: 48px; }
  .collage { width: 514px; max-width: 100%; margin: 0 auto; }
}

@media (max-width: 720px) {
  .page { padding: 28px 24px 56px; }
  .page-title { font-size: 56px; }
  .about-head { margin: 28px 0; }
  .about-head p { font-size: 14px; line-height: 1.45; }
  .about-main { gap: 28px; }
  .bio h2 { font-size: 36px; margin-bottom: 20px; }
  .bio p { font-size: 16px; margin-bottom: 22px; }
  .links a { font-size: 15px; }
  .collage { display: contents; }
  .collage .polaroid { position: static; }
  .c-beach { grid-row: 1; width: min(290px, 92%); margin: 0 auto; }
  .bio { grid-row: 2; }
  .scatter-mobile { grid-row: 3; position: relative; height: 560px; }
  .scatter-mobile figcaption { font-size: 16px; }
  .scatter-mobile .polaroid { position: absolute; width: 156px; }
  .c-arsenal { left: auto; right: 0; top: 0; }
  .c-kayak { left: 0; top: 40px; }
  .scatter-mobile .c-steak { left: 28%; top: 300px; width: 170px; }
  .prints { gap: 28px; margin-top: 28px; }
  .p-tfs, .p-nest { width: 100%; }
}
@media (min-width: 721px) { .scatter-mobile { display: contents; } }

/* ---------------------------------------------------------------- Projects */

.center-head { text-align: center; margin: 32px 0 48px; }
.center-head .page-title { font-size: 56px; }
.center-head .label { display: block; margin-top: 14px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 330px));
  justify-content: center;
  gap: 64px;
  padding: 0; margin: 0; list-style: none;
}
.tile { text-align: center; }
.tile .art { height: 330px; display: grid; place-items: center; }
.tile .art img { height: auto; filter: var(--shadow); transform: rotate(var(--r)); transition: transform .25s ease; }
.tile:hover .art img { transform: rotate(calc(var(--r) * -0.4)) scale(1.04); }
.a-bag   { width: 190px; --r: 4deg; }
.a-tenk  { width: 216px; --r: 2deg; }
.a-shoes { width: 290px; --r: -3deg; }
.tile h2 { margin: 18px 0 14px; font: italic 400 30px/1.1 var(--serif); }
.tile p { margin: 0 auto 14px; max-width: 290px; font: 400 15px/1.5 var(--body); color: var(--grey); }
.tile .stack { font: 500 12px/1.4 var(--sans); letter-spacing: .04em; }
.tile .gh { display: inline-block; margin-top: 14px; font: 500 14px/1 var(--sans); text-decoration: none; }
.tile .gh:hover { text-decoration: underline; }

.more { text-align: center; margin: 56px 0 0; }
.cards { display: flex; justify-content: center; flex-wrap: wrap; gap: 24px; margin-top: 24px; }
.card {
  display: flex; justify-content: space-between; align-items: center; gap: 40px;
  width: 300px; padding: 22px 24px;
  border: 1px solid var(--line); border-radius: 16px;
  font: 400 17px/1.2 var(--sans); text-decoration: none;
  transition: border-color .2s ease;
}
.card:hover { border-color: var(--ink); }
.card span { color: var(--grey); }

.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px 28px;
  margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line);
  font: 500 12px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase;
}
.footer ul { display: flex; gap: 28px; padding: 0; margin: 0; list-style: none; }
.footer a { text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer .made { color: var(--grey); }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: minmax(0, 330px); gap: 40px; }
}
@media (max-width: 720px) {
  .center-head .page-title { font-size: 44px; }
  .tile .art { height: 270px; }
  .tile .art img { scale: .82; }
  .tile h2 { font-size: 28px; }
  .cards { flex-direction: column; align-items: center; }
  .card { width: 100%; }
  .footer, .footer ul { flex-direction: column; }
}

/* ---------------------------------------------------------------- Coming soon */

.soon {
  min-height: calc(100vh - 200px);
  min-height: calc(100svh - 200px);
  display: grid; place-content: center; text-align: center; gap: 16px;
  padding-bottom: 80px;
}
.soon .page-title { font-size: clamp(56px, 9vw, 96px); }
.soon p { margin: 0; font: 400 19px/1.45 var(--sans); color: var(--grey); padding: 0 8px; }
.soon .dots { letter-spacing: .4em; }
.soon .links { justify-content: center; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Rotating typewriter subtitle (see typing.js) */
.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;
}
.name p { min-height: 1.3em; }
.caret {
  display: inline-block;
  width: 1px; height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: currentColor;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { display: none; } }

/* Name "nudge" after the welcome line types out (see typing.js):
   a slow, springy pop that turns green and tilts like the objects. No underline. */
.name.nudge h1 {
  color: var(--green);
  transform: rotate(-2.5deg) scale(1.06);
  transition: color 450ms ease, transform 600ms cubic-bezier(0.34, 1.35, 0.64, 1);
}

/* Intro: each object is set down on the table, clockwise around the name, then the name appears.
   Only on the first homepage visit per session (see the inline script in index.html). */
.o-osmo { --i: 0; } .o-laptop { --i: 1; } .o-passport { --i: 2; } .o-vinyl { --i: 3; }
.o-acai { --i: 4; } .o-folder { --i: 5; } .o-phone { --i: 6; }
@media (prefers-reduced-motion: no-preference) {
  .intro .obj img {
    animation: place-down 700ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    animation-delay: calc(150ms + var(--i) * var(--step, 120ms));
  }
  .intro .name h1, .intro .name p {
    animation: name-in 650ms ease backwards;
    animation-delay: 1050ms;
  }
  .intro .name p { animation-delay: 1200ms; }
  @media (max-width: 720px) { .intro .obj img { --step: 90ms; } }
}
@keyframes place-down {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(1.12);
    filter: drop-shadow(0 18px 14px rgb(0 0 0 / 0.08)) drop-shadow(0 42px 36px rgb(0 0 0 / 0.14));
  }
  70% {
    opacity: 1;
    transform: translateY(1px) scale(0.985);
    filter: drop-shadow(0 3px 2px rgb(0 0 0 / 0.16)) drop-shadow(0 12px 12px rgb(0 0 0 / 0.12));
  }
  100% {
    transform: none;
    filter: drop-shadow(0 3px 2px rgb(0 0 0 / 0.16)) drop-shadow(0 12px 12px rgb(0 0 0 / 0.12));
  }
}
@keyframes name-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* Name on torn paper: the name is an object like everything else on the table.
   Hover and the post-welcome nudge both lift and straighten it, like the other objects. */
.name h1 {
  background: url("/img/objects/paper.webp") center / 100% 100% no-repeat;
  padding: 0.42em 0.95em 0.5em;
  color: var(--ink);
  font-size: 5.6cqw;
  transform: rotate(-3deg);
  filter: drop-shadow(0 3px 2px rgb(0 0 0 / 0.16)) drop-shadow(0 12px 12px rgb(0 0 0 / 0.12));
}
.name h1::after { display: none; }
.name:hover h1, .name:focus-visible h1, .name.nudge h1 {
  color: var(--ink);
  transform: rotate(1deg) scale(1.06);
}
.name p { margin-top: 1.4em; }
@media (max-width: 720px) {
  .name h1 { font-size: 10.6cqw; }
}

/* Let the paper's grain show through the letters, like printed ink */
.name .ink { color: #33261f; opacity: 0.9; mix-blend-mode: multiply; }

/* Name paper as an object: the name is printed into the paper image.
   The h1 holds the tilt (like .obj), the image holds the shadow and the intro (like .obj img). */
.name h1 {
  background: none; padding: 0; filter: none; color: inherit;
  transform: rotate(-3deg);
  transition: transform .25s ease;
}
.name h1::after { display: none; }
.name .name-paper { width: 29.2cqw; height: auto; filter: var(--shadow); }
.name:hover h1, .name:focus-visible h1 { transform: rotate(1.2deg) scale(1.06); }
.name.nudge h1 { transform: rotate(-3deg); animation: paper-flutter 950ms cubic-bezier(0.3, 0.7, 0.4, 1); }
@keyframes paper-flutter {
  0%   { transform: rotate(-3deg); }
  22%  { transform: translateY(-6px) scale(1.04) rotate(-3deg); }
  42%  { transform: translateY(-3px) scale(1.03) rotate(-1deg); }
  58%  { transform: translateY(-1px) scale(1.01) rotate(-4.6deg); }
  74%  { transform: rotate(-2.2deg); }
  88%  { transform: rotate(-3.4deg); }
  100% { transform: rotate(-3deg); }
}
.name p { margin-top: 1.1em; }
@media (prefers-reduced-motion: no-preference) {
  .intro .name h1 { animation: none; }
  .intro .name .name-paper {
    animation: place-down 700ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    animation-delay: calc(150ms + 7 * var(--step, 120ms));
  }
}
@media (max-width: 720px) {
  .name .name-paper { width: 64cqw; }
  .intro .name .name-paper { --step: 90ms; }
}
@media (prefers-reduced-motion: reduce) { .name.nudge h1 { animation: none; } }

/* 'about me' hover label on the name paper, same style as the object labels */
.name h1 { position: relative; display: inline-block; }
.name .name-tag {
  position: absolute; left: 50%; top: 100%;
  transform: translate(-50%, 2px) rotate(3deg);
  font: 500 11px/1 var(--sans); letter-spacing: .06em;
  color: var(--ink); white-space: nowrap;
  opacity: 0; transition: opacity .2s ease;
}
.name:hover .name-tag, .name:focus-visible .name-tag { opacity: 1; }
.name:hover p, .name:focus-visible p { opacity: 0; }
.name p { transition: opacity .2s ease; }
@media (max-width: 720px) { .name .name-tag { font-size: 9.5px; } }

/* Fixes: let the shimmy play during the first-visit intro too, keep the name paper's
   landing gentle on phones, and don't let a tap leave the hover "lift" stuck on touch screens. */
.intro .name.nudge h1 { animation: paper-flutter 950ms cubic-bezier(0.3, 0.7, 0.4, 1); }
@keyframes place-down-soft {
  0%   { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: none; }
}
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  .intro .name .name-paper { animation-name: place-down-soft; animation-duration: 600ms; }
}
@media (hover: none) {
  .name:hover h1 { transform: rotate(-3deg); }
  .name:hover .name-tag { opacity: 0; }
  .name:hover p { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .intro .name.nudge h1 { animation: none; } }

/* Phones: no growing at all. The shimmy is just a small tilt wiggle, and every object
   (including the name paper) lands with a soft fade and settle instead of scaling down. */
@keyframes paper-flutter-phone {
  0%   { transform: rotate(-3deg); }
  25%  { transform: translateY(-2px) rotate(-1.4deg); }
  50%  { transform: translateY(-1px) rotate(-4.4deg); }
  75%  { transform: rotate(-2.4deg); }
  100% { transform: rotate(-3deg); }
}
@media (max-width: 720px) {
  .name.nudge h1, .intro .name.nudge h1 { animation-name: paper-flutter-phone; }
}
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  .intro .obj img { animation-name: place-down-soft; animation-duration: 600ms; }
}
@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .name.nudge h1, .intro .name.nudge h1 { animation: none; }
}

/* Phones: green 'click me!' note with a squiggly arrow pointing at the name paper */
.click-me { display: none; }
@media (max-width: 720px) {
  .click-me {
    display: flex; flex-direction: column; align-items: flex-start;
    position: absolute; left: 88%; top: 74%;
    color: var(--green);
    font: italic 400 19px/1 var(--serif);
    white-space: nowrap;
    transform: rotate(3deg);
    pointer-events: none;
  }
  .click-me .squiggle { width: 40px; height: auto; transform: scaleY(-1) rotate(4deg); margin: 0 0 -2px -18px; }
  .click-me span { transform: rotate(-4deg); margin-left: 6px; }
  .name p { margin-top: 2.4em; }
}
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  .click-me { animation: click-me-bob 2.4s ease-in-out infinite; }
  .intro .click-me { animation: click-me-in 500ms ease 1.9s backwards, click-me-bob 2.4s ease-in-out 2.4s infinite; }
}
@keyframes click-me-bob {
  0%, 100% { transform: rotate(3deg) translate(0, 0); }
  50%      { transform: rotate(3deg) translate(2px, -3px); }
}
@keyframes click-me-in { from { opacity: 0; transform: rotate(3deg) translate(6px, -6px); } }

/* Keep the name paper a fixed size: without this, the global img max-width: 100% let the
   shrink-to-fit name block (sized by the typing subtitle) squeeze the paper on phones. */
.name { width: max-content; }
.name .name-paper { max-width: none; }

/* Phones: smaller name paper so it clears the passport's label, and a smaller, still 'click me!' note */
@media (max-width: 720px) {
  .name .name-paper { width: 54cqw; }
  .click-me { font-size: 15px; left: 86%; top: 70%; }
  .click-me .squiggle { width: 30px; margin: 0 0 -2px -14px; }
  .name p { margin-top: 2em; }
}
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) {
  .click-me { animation: none; }
  .intro .click-me { animation: click-me-fade 400ms ease 1.9s backwards; }
}
@keyframes click-me-fade { from { opacity: 0; } }

/* Arrow drawn pointing the right way in the SVG itself: no CSS flips or rotations */
@media (max-width: 720px) {
  .click-me .squiggle { transform: none; width: 30px; height: 33px; margin: 0 0 1px -10px; }
}
