:root {
  color-scheme: dark;
  /* Text & links */
  --white:     #ffffff;
  --fg-muted:  #CCCCCC;
  --link:      #008FFF;

  /* Surfaces */
  --surface-page:   #101010;  /* page bg, nav tint */
  --surface-frame:  #202020;  /* project media fallback bg */

  /* Button states (nav links + copy-email) */
  --button-hover:         #303030;  /* hovered pill */
  --button-selected:      #ffffff;  /* active/current page pill */
  --button-selected-text: #101010;  /* text on active pill */

  /* Layout grid: 8 cols / 40 margins / 20 gutters on desktop */
  --grid-cols: 8;
  --grid-margin: 40px;
  --grid-gutter: 20px;

  /* ---------- Typography ---------- */
  --ff-sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Type scale — desktop defaults; mobile values overridden in the media query below */
  --fs-display: 40px;  /* hero intro, section headlines, about heading, footer heading */
  --fs-body:    24px;  /* body, about body, find-me links, project desc, project year, footer body, footer link */
  --fs-ui:      16px;  /* nav links, copy-email button */
  --fs-meta:    15px;  /* project tags, hero scroll cue */

  /* Line-heights */
  --lh-display: 1.25;
  --lh-body:    1.5;

  /* Weights */
  --fw-regular:  400;
  --fw-semibold: 600;

  /* ---------- Vertical rhythm ---------- */
  --space-hero-to-section:     200px;  /* hero scroll cue → first heading */
  --space-heading-to-project:  80px;  /* heading → first project of group */
  --space-project:             300px;  /* project → next heading */
  --space-between-projects:     80px;  /* project → next project (same group) */
  --space-project-to-footer:   300px;  /* last project → footer */
  --space-footer-body-to-bye:   80px;  /* footer body → bye image */
}

@media (max-width: 899.98px) {
  :root {
    --grid-cols: 5;
    --grid-margin: 20px;

    /* Mobile type scale */
    --fs-display: 30px;
    --fs-body:    16px;
    --fs-meta:    14px;

    /* Mobile vertical rhythm */
    --space-hero-to-section:     120px;
    --space-heading-to-project:   60px;
    --space-project:             100px;
    --space-between-projects:     60px;
    --space-project-to-footer:   200px;
    --space-footer-body-to-bye:   40px;
  }
}

/* Grid container — apply to the inner wrapper of any section */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  column-gap: var(--grid-gutter);
  padding-left: var(--grid-margin);
  padding-right: var(--grid-margin);
  width: 100%;
}

/* Spans */
.col-full   { grid-column: 1 / -1; }
.col-narrow { grid-column: 2 / span 6; } /* cols 2-7 on the 8-col desktop grid */

@media (max-width: 899.98px) {
  .col-narrow { grid-column: 1 / -1; } /* collapse to full width on 5-col layout */
}

/* ---------------- DEBUG OVERLAY (press `g` to toggle) ---------------- */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), 1fr);
  column-gap: var(--grid-gutter);
  padding-left: var(--grid-margin);
  padding-right: var(--grid-margin);
  opacity: 0;
  transition: opacity 150ms ease;
}

.grid-overlay > div {
  background: rgba(255, 0, 68, 0.12);
  border-left: 1px solid rgba(255, 0, 68, 0.5);
  border-right: 1px solid rgba(255, 0, 68, 0.5);
}

/* Mobile/tablet grid has 5 cols — hide the extra column markers */
@media (max-width: 899.98px) {
  .grid-overlay > div:nth-child(n+6) { display: none; }
}

body.debug .grid-overlay { opacity: 1; }

/* Red outlines on layout-relevant elements */
body.debug .hello-wrap,
body.debug .hero-intro,
body.debug .hero-scroll,
body.debug .panel-title,
body.debug .project-media,
body.debug .project-meta,
body.debug .project-tags,
body.debug .footer-block {
  outline: 1px solid #ff0044;
  outline-offset: 0;
}

/* Vertical-spacing visualization:
   - cyan band  = section top/bottom padding (gap between section edge and grid container)
   - orange band = grid row-gaps between consecutive elements
   - the existing red item outlines and grid-overlay (red columns) cover horizontal spacing */

body.debug .hero,
body.debug .panel,
body.debug .footer {
  background-color: rgba(80, 180, 255, 0.16);
  outline: 1px dashed rgba(80, 180, 255, 0.7);
  outline-offset: -1px;
}

body.debug .hero-inner,
body.debug .panel-inner,
body.debug .footer-inner {
  background-color: rgba(255, 165, 0, 0.22);
  outline: 1px dashed rgba(255, 165, 0, 0.85);
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--surface-page); /* fills iOS Safari's safe-area chrome zones */
}

body {
  font-family: var(--ff-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  letter-spacing: 0;
  color: var(--white);
  background-color: var(--surface-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ---------------- NAV ---------------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 80px;
  z-index: 100;
  /* iOS safe-area handled by inner padding instead of nav padding so the 80px height is exact */

  /* Backdrop blur lives on the nav itself (not on ::before) so it isn't
     attenuated by the tint layer's opacity transition. */
  -webkit-backdrop-filter: blur(0px);
          backdrop-filter: blur(0px);
  transition:
    -webkit-backdrop-filter 300ms ease,
            backdrop-filter 300ms ease;
}

.nav.is-tinted {
  -webkit-backdrop-filter: blur(20px);
          backdrop-filter: blur(20px);
}

/* Color tint overlay (opacity tweens independently of the blur) */
.nav::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--surface-page);
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
  z-index: -1;
}

.nav.is-tinted::before { opacity: 0.3; }

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: var(--grid-margin);
  padding-right: var(--grid-margin);
  padding-top: env(safe-area-inset-top, 0);
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  pointer-events: none;
}

.nav-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: translateY(100%);
  transition:
    opacity 400ms ease,
    transform 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav.is-tinted .nav-logo {
  pointer-events: auto;
}

.nav.is-tinted .nav-logo img {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 899.98px) {
  .nav-logo { width: 32px; height: 32px; }
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links a,
.nav-actions .copy-email {
  color: var(--white);
  background: transparent;
  text-decoration: none;
  font-size: var(--fs-ui);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
  padding: 10px 20px;
  border-radius: 999px;
  transition: background 200ms ease, color 200ms ease;
}

.nav-links a:hover,
.nav-actions .copy-email:hover {
  background: var(--button-hover);
}

.nav-links a.active,
.nav-links a[aria-current="page"] {
  background: var(--button-selected);
  color: var(--button-selected-text);
}

.nav-links a.active:hover,
.nav-links a[aria-current="page"]:hover {
  background: var(--button-selected);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* ---------------- BUTTONS ---------------- */
.btn {
  font-family: inherit;
  letter-spacing: 0;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Label swap: "copy email" on desktop, "email me" on mobile */
.copy-email .lbl-mobile {
  display: none;
}
@media (max-width: 899.98px) {
  .copy-email .lbl-desktop { display: none; }
  .copy-email .lbl-mobile { display: inline; }

  /* Tighter nav button padding on mobile/tablet */
  .nav-links a,
  .nav-actions .copy-email {
    padding: 8px 12px;
  }
}

/* ---------------- HERO ---------------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 80px 0 var(--space-hero-to-section); /* top = nav height; bottom controls gap to first heading */
  position: relative;
}

.hero-inner {
  width: 100%;
  text-align: left;
  row-gap: 20px;
}

.hello-wrap {
  display: flex;
  justify-content: center;
}

/* Tablet/mobile: bleed the hello image past the 20px grid margins
   so it sits flush against the viewport edges */
@media (max-width: 899.98px) {
  .hello-wrap {
    margin-left: calc(-1 * var(--grid-margin));
    margin-right: calc(-1 * var(--grid-margin));
  }
}

.hello {
  display: block;
  width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
}

.bye-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.bye {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

@media (max-width: 899.98px) {
  .bye { max-height: 60vh; }
}

.hero-intro {
  font-size: var(--fs-display);
  line-height: 1.35;
  color: var(--white);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
}

.hero-scroll {
  position: absolute;
  /* Anchor 20px above the viewport bottom even when the hero overflows 100vh
     (top: 100vh + translateY(-100%) puts the cue's bottom at viewport bottom;
      margin-top: -20px lifts it another 20px) */
  top: 100vh;
  margin-top: -20px;
  left: var(--grid-margin);
  right: var(--grid-margin);
  font-size: var(--fs-meta);
  letter-spacing: 0;
  color: var(--fg-muted);
  text-align: center;
}

/* Hide the scroll cue on mobile only (landscape phones or any short
   mobile viewport) — desktop keeps the cue regardless of orientation. */
@media (max-width: 899.98px) and (orientation: landscape),
       (max-width: 899.98px) and (max-height: 710px) {
  .hero-scroll { display: none; }
}

.hero-scroll .arrow {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-meta);
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(8px); }
}

/* ---------------- TEXT ANIMATIONS ---------------- */

/* Scroll-triggered fade-up (applied via JS) */
.fade-up {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 700ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--delay, 0ms);
}
.fade-up.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Scroll-triggered scale-in (for images / media) */
.scale-in {
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 700ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-delay: var(--delay, 0ms);
}
.scale-in.in-view {
  opacity: 1;
  transform: scale(1);
}

/* Hero entrance on load */
.hello-wrap,
.hero-intro {
  opacity: 0;
  transform: translateY(12px);
  animation: hero-enter 900ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.hello-wrap   { animation-delay: 80ms; }
.hero-intro   { animation-delay: 260ms; }

@keyframes hero-enter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-scroll {
  opacity: 0;
  transform: translateY(calc(-100% + 12px));
  animation: hero-scroll-enter 900ms cubic-bezier(0.2, 0.8, 0.2, 1) 520ms forwards;
}

@keyframes hero-scroll-enter {
  to {
    opacity: 1;
    transform: translateY(-100%);
  }
}

/* Bouncing arrow runs after the hero-scroll fade-in finishes */
.hero-scroll .arrow {
  animation: arrow-bounce 1.6s ease-in-out 1.6s infinite;
}

/* About page on-load entrance — avatar scales in, text staggers up */
.about-avatar img {
  opacity: 0;
  transform: scale(0.96);
  animation: scale-in-load 700ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.about-block .about-heading,
.about-block .about-body {
  opacity: 0;
  transform: translateY(16px);
  animation: fade-up-load 700ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
.about-block:nth-child(2) .about-heading { animation-delay: 100ms; }
.about-block:nth-child(2) .about-body:nth-of-type(1) { animation-delay: 200ms; }
.about-block:nth-child(2) .about-body:nth-of-type(2) { animation-delay: 300ms; }
.about-block:nth-child(3) .about-heading { animation-delay: 400ms; }
.about-block:nth-child(3) .about-body { animation-delay: 500ms; }

/* Hobby row staggers in left-to-right after about-inner finishes.
   Desktop only — on mobile it's far below the fold, handled by the JS observer. */
@media (min-width: 901px) {
  .hobby-row img {
    opacity: 0;
    transform: scale(0.96);
    animation: scale-in-load 700ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }
  .hobby-row img:nth-child(1) { animation-delay: 800ms; }
  .hobby-row img:nth-child(2) { animation-delay: 950ms; }
  .hobby-row img:nth-child(3) { animation-delay: 1100ms; }
  .hobby-row img:nth-child(4) { animation-delay: 1250ms; }
  .hobby-row img:nth-child(5) { animation-delay: 1400ms; }
  .hobby-row img:nth-child(6) { animation-delay: 1550ms; }
}

@keyframes scale-in-load {
  to { opacity: 1; transform: scale(1); }
}
@keyframes fade-up-load {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .fade-up,
  .scale-in { opacity: 1; transform: none; transition: none; }
  .hello-wrap, .hero-intro, .hero-scroll .arrow {
    opacity: 1; transform: none; animation: none;
  }
  .hero-scroll { opacity: 1; transform: translateY(-100%); animation: none; }
  .about-avatar img,
  .about-block .about-heading,
  .about-block .about-body,
  .hobby-row img {
    opacity: 1; transform: none; animation: none;
  }
}

/* ---------------- PANELS ---------------- */
.panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.panel-inner {
  text-align: left;
  row-gap: 0;
}

.panel-title {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
}

.project-media > .media-mobile { display: none; }
.project-media > .media-desktop { display: block; }

/* ---------------- PANEL: HEADING (intro before a project group) ---------------- */
.panel-heading {
  padding: 0 0 var(--space-heading-to-project);
}

/* First heading after the hero needs explicit top padding —
   the hero's min-height: 100vh absorbs its own padding-bottom,
   so we add the space here to match --space-project (project → next heading). */
.hero + .panel-heading {
  padding-top: min(var(--space-project), 25vh);
}

/* ---------------- PANEL: PROJECT ---------------- */
.panel-project {
  padding: 0 0 var(--space-project);
}

/* When two projects are adjacent (same group), tighten the gap between them */
.panel-project:has(+ .panel-project) {
  padding-bottom: var(--space-between-projects);
}

.panel-project .panel-inner {
  row-gap: 16px;
  text-align: left;
}

.project-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 40px;
  overflow: hidden;
  background: var(--surface-frame);
}

.project-media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-top: 4px;
}

.project-desc {
  flex: 0 1 auto;
  /* 4 of 8 grid cols within the 6-col col-narrow container:
     (4 col widths + 3 gutters) / (6 col widths + 5 gutters) */
  width: calc((4 * (100% - 5 * var(--grid-gutter)) / 6) + 3 * var(--grid-gutter));
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  color: var(--white);
  margin: 0;
}

.project-link {
  color: var(--link);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  white-space: nowrap;
  margin-left: 4px;
  transition: opacity 0.15s ease;
}
.project-link .arrow { display: inline-block; font-size: 0.95em; line-height: 1; }
.project-link:hover { opacity: 0.7; }

.project-year {
  flex: 0 0 auto;
  font-size: var(--fs-body);
  color: var(--fg-muted);
  white-space: nowrap;
  text-align: left;
  line-height: var(--lh-body);
}

.project-tags {
  font-size: var(--fs-meta);
  color: var(--white);
  margin: 0;
  letter-spacing: 0;
}

@media (max-width: 899.98px) {
  .panel-project .panel-inner { row-gap: 20px; }

  .project-media { border-radius: 20px; aspect-ratio: 3 / 5; }

  /* Reset desktop width constraint — desc spans full width on mobile */
  .project-desc { width: auto; flex: 1 1 auto; }

  /* Stack year above description on mobile */
  .project-meta {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 8px;
    margin-top: 0;
  }
  .project-year { text-align: left; }
}

/* ---------------- PHONES ROW ---------------- */
.project-media.phones-wrap { background: transparent; }

.project-media > .phones {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  width: 100%;
  height: 100%;
}

.phones img {
  height: 100%;
  width: auto;
  max-width: none;
  border-radius: 36px;
}

/* ---------------- ABOUT PAGE ---------------- */
.about {
  width: 100%;
  padding: 180px 0 0; /* 80px nav + 100px gap to avatar */
}

.about-inner {
  row-gap: 80px;
}

.about-avatar img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
}

.about-heading {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: var(--fw-regular);
  letter-spacing: 0;
  color: var(--white);
  margin-bottom: 16px;
}

.about-body {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  color: var(--white);
  margin-bottom: 18px;
}

.about-body:last-child { margin-bottom: 0; }

.about-link {
  color: var(--link);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.about-link:hover { opacity: 0.7; }

.hobby-row {
  margin-top: 100px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: 100%;
}

.hobby-row img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.find-me {
  margin-top: 160px;
}

.find-me-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  width: 100%;
}

.find-me-text { flex: 1; }

.find-me-links {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.find-me-links li { margin-bottom: 4px; }

.find-me-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--link);
  text-decoration: none;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  transition: opacity 0.15s ease;
}

.find-me-links a:hover { opacity: 0.7; }

.find-me-links .arrow {
  font-size: 0.9em;
  line-height: 1;
}

.find-me-stamp img {
  width: 120px;
  height: 120px;
  display: block;
}

@media (max-width: 899.98px) {
  .about { padding: 120px 0 0; } /* 80px nav + 40px gap */
  .about-inner { row-gap: 40px; }
  .about-avatar img { width: 80px; height: 80px; }
  .find-me-stamp img { width: 88px; height: 88px; }
  .hobby-row {
    margin-top: 64px;
    grid-template-columns: repeat(2, 1fr);
  }
  .find-me { margin-top: 80px; }
}

@media (max-width: 599.98px) {
  .find-me-inner { gap: 24px; }
  .find-me-stamp img { width: 72px; height: 72px; }
}

/* ---------------- FOOTER ---------------- */
.footer {
  /* The previous .panel-project's bottom padding already provides --space-project
     of gap; footer-top adds the remainder to reach --space-project-to-footer. */
  padding: calc(var(--space-project-to-footer) - var(--space-project)) 0 0;
  text-align: left;
}

.footer-heading {
  font-size: var(--fs-display);
  font-weight: var(--fw-regular);
  line-height: var(--lh-display);
  color: var(--white);
  margin: 0 0 6px;
}

.footer-body {
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  color: var(--white);
  margin: 0 0 18px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--link);
  font-family: inherit;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.footer-link:hover { opacity: 0.7; }
.footer-link .arrow { display: inline-block; font-size: 0.95em; line-height: 1; }

.footer .bye-wrap { margin-top: var(--space-footer-body-to-bye); }

.footer-slim { padding-top: 0; }

.footer-inner {
  row-gap: 0;
}

/* ---------------- RESPONSIVE ---------------- */
/* Mobile + tablet type scale and vertical rhythm are handled by the token
   overrides in :root above. This file otherwise scales by the same breakpoint. */

@media (max-width: 899.98px) {
  .phones { gap: 12px; }
  .phones img { border-radius: 22px; }

  /* Swap landscape screenshots for portrait thumbnails */
  .project-media > .media-desktop { display: none; }
  .project-media > .media-mobile { display: block; }
}

/* Narrow phones — shrink the nav so the hero fits better */
@media (max-width: 640px) {
  .nav { height: 64px; }
  .hero { padding-top: 64px; min-height: 90vh; }
  .hero-intro { line-height: 1.4; }
  .about { padding: 104px 0 0; } /* 64px nav + 40px gap */
}

