:root {
  --bg: #000;
  --surface: #121214;
  --surface-2: #1a1a1d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f1ef;
  --muted: #a19b97;
  --accent: #e39a76; /* sampled from the scene's terracotta floor */
  --radius: 18px;
  --display: "Poppins", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

html.is-loading {
  overflow: hidden;
}

body {
  background: var(--bg);
  overflow-x: hidden;
  overflow-x: clip;
}

a {
  color: inherit;
}

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

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

/* ---------------------------------------------------------------- Loader */

#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #baafac;
  transition: opacity 0.9s ease;
}

#loader.done {
  opacity: 0;
  pointer-events: none;
}

#loader > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.loader-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 18px;
}

.loader-label {
  font-family: var(--display);
  font-weight: 200;
  font-size: clamp(28px, 5vw, 56px);
  letter-spacing: 0.04em;
  color: #fff;
}

.loader-bar {
  width: 180px;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.loader-bar span {
  display: block;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s linear;
}

/* ----------------------------------------------------------------- Intro */

#intro {
  /* Spacer: 300vh of scroll distance drives the camera move. */
  height: 400vh;
}

/* Fixed rather than sticky: sticky is unreliable in mobile Safari. The
   page content after the intro scrolls up over this layer. */
.stage {
  --ar: 1.7778;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
  background: #baafac;
}

/* "Cover" sizing done by hand so it behaves the same in every browser. */
#scene {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 100lvh * var(--ar));
  min-height: 100%; /* guards against sub-pixel rounding gaps */
  aspect-ratio: var(--ar);
  transform: translate(-50%, -50%);
}

#hero {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  text-align: center;
  white-space: nowrap;
  color: #fff;
  will-change: transform, opacity;
  pointer-events: none;
}

#hero h1 {
  font-family: var(--display);
  font-size: min(9vh, 9vw);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
}

#hero p {
  font-family: var(--display);
  font-size: 2.7vh;
  font-weight: 200;
  margin-top: 1vh;
}

.socials {
  display: flex;
  gap: 12px;
}

.socials a {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.25s var(--ease-out), background-color 0.25s ease;
}

.socials a:hover {
  transform: translateY(-2px);
  background: rgba(0, 0, 0, 0.45);
}

.socials img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

#intro-socials {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 112px;
  width: 1px;
  height: 40px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.scroll-hint span {
  position: absolute;
  inset: 0;
  background: #fff;
  animation: hint 2s var(--ease-out) infinite;
}

@keyframes hint {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

/* --------------------------------------------------------------- Content */

.page {
  position: relative;
  z-index: 1;
  background: var(--bg);
  padding-bottom: 1px;
}

#content {
  width: min(1120px, 100% - 48px);
  margin: 0 auto;
  padding: 12vh 0 6vh;
}

.section + .section {
  margin-top: 120px;
}

.section-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: -0.01em;
  padding-bottom: 20px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}


.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 20px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.25s ease, transform 0.35s var(--ease-out), background-color 0.25s ease;
}

.card.has-details {
  cursor: pointer;
}

.card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: translateY(-3px);
}

.card-media {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  height: 200px;
  padding: 24px;
  background: radial-gradient(120% 100% at 50% 0%, #2a2220 0%, #141213 70%);
  border-bottom: 1px solid var(--border);
}

.card-media img {
  max-height: 100%;
  width: auto;
  object-fit: contain;
}

.card-media img.pixel {
  image-rendering: pixelated;
  height: 100%;
}

.card-media.multi img.pixel {
  height: 72%;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  padding: 24px;
}

.card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.card h3,
#detail h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.date {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.role {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.award {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: rgba(227, 154, 118, 0.1);
  border: 1px solid rgba(227, 154, 118, 0.3);
  border-radius: 999px;
}

.summary {
  font-size: 15px;
  line-height: 1.6;
  color: #d6d1cd;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
}

.tags li {
  padding: 3px 9px;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: auto;
  padding-top: 6px;
}

.link {
  font: 500 14px var(--body);
  color: var(--text);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.link:hover {
  color: var(--accent);
  border-color: currentColor;
}

/* About */
.about {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: start;
}

.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.avatar {
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(120% 120% at 30% 20%, #3a2b25 0%, #171314 80%);
  border: 1px solid rgba(227, 154, 118, 0.35);
  font: 600 20px var(--display);
  color: var(--accent);
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font: 600 18px var(--display);
}

.profile .role {
  margin-top: 2px;
}

.about-intro {
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.6;
}

.edu {
  margin-top: 32px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.edu h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
}

.edu-detail {
  margin-top: 8px;
  font-size: 14px;
  color: #d6d1cd;
}

.skills {
  display: grid;
  gap: 24px;
}

.skills dt {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.highlights {
  display: grid;
  gap: 10px;
  list-style: none;
}

.highlights li {
  position: relative;
  padding-left: 20px;
  font-size: 15px;
  line-height: 1.6;
  color: #d6d1cd;
}

.highlights li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.7em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

@media (max-width: 860px) {
  .about {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ------------------------------------------------- Projects (showcase) */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.project {
  position: relative;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-title {
  margin-top: 14px;
  font: 600 26px/1.15 var(--body);
  letter-spacing: -0.02em;
}

.project-role {
  margin-top: 6px;
  font-size: 15px;
  color: var(--muted);
}

/* Awards: a small accent label with a hairline lead-in, not a badge. */
.project-award {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  font: 500 12px/1.4 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.project-award::before {
  content: "";
  flex-shrink: 0;
  width: 16px;
  height: 1px;
  background: currentColor;
}

.project-summary {
  max-width: 62ch;
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.65;
  color: #cfc9c5;
}

.project-tech {
  margin-top: 16px;
  font: 400 12px/1.6 var(--mono);
  color: #8a8480;
}

.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 20px;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font: 500 14px var(--body);
  color: var(--text);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 0.2s ease;
}

.project-link .arrow {
  transition: transform 0.2s var(--ease-out);
}

/* Stretch the first action over the project so the whole area is clickable. */
.project .project-actions > .project-link:first-child::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 10px;
}

.project .project-actions > .project-link:not(:first-child) {
  position: relative;
  z-index: 1;
}

.project .project-actions > .project-link:first-child:focus-visible {
  outline: none;
}

.project .project-actions > .project-link:first-child:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.project-link:hover,
.project.is-linked:hover .project-actions > .project-link:first-child {
  color: var(--accent);
}

.project.is-linked:hover .project-actions > .project-link:first-child .arrow,
.project-link:hover .arrow {
  transform: translateX(3px);
}

/* Media */
.project-media {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
  border-radius: 8px;
  background: #121011;
}

.project-media img {
  transition: transform 0.25s var(--ease-out);
}

.project.is-linked:hover .project-media img {
  transform: scale(1.03);
}

.project-media.is-pixel {
  align-items: center;
  gap: 8%;
  background: #0e0e10;
}

.project-media.is-pixel img {
  image-rendering: pixelated;
  min-width: 0;
}

/* Featured */
.project--featured {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 56px;
  padding-bottom: 72px;
}

.project--featured .project-body {
  padding-top: 4px;
}

.project--featured .project-title {
  margin-top: 20px;
  font-size: clamp(38px, 4.6vw, 56px);
  line-height: 1;
  letter-spacing: -0.035em;
}

.project--featured .project-summary {
  font-size: 16px;
}

/* A real result, set as type, in place of a screenshot. */
.project-figure {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  min-height: 320px;
  padding: 36px;
  border-radius: 8px;
  background: #0f0e0e;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.figure-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  font: 300 clamp(40px, 5.4vw, 72px)/1 var(--body);
  letter-spacing: -0.04em;
}

.figure-from {
  color: #6f6a67;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.2);
}

.figure-arrow {
  font-size: 0.5em;
  color: var(--muted);
}

.figure-caption {
  max-width: 38ch;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.figure-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.figure-stats dt {
  font: 500 20px var(--body);
  letter-spacing: -0.01em;
}

.figure-stats dd {
  margin-top: 6px;
  font: 400 11px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Two-column block: standard projects stack on the left, a tall one sits right. */
.showcase-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 64px;
  border-top: 1px solid var(--border);
}

.showcase-grid > .project {
  padding: 44px 0;
}

.project--standard + .project--standard {
  border-top: 1px solid var(--border);
}

.project--tall {
  grid-column: 2;
  /* Spans every project stacked beside it (set from script.js). */
  grid-row: 1 / span var(--rows, 2);
  /* Hug the content instead of stretching to the taller column beside it. */
  align-self: start;
}

.project--tall .project-media {
  height: 360px;
  margin-bottom: 32px;
  background: #141112;
}

/* Phone rises out of the panel; its bottom edge crops the screen just
   above the app badge, so only the phone itself shows. */
.project--tall .project-media img {
  width: 240px;
  max-width: 62%;
  margin-bottom: -170px;
}

.project--standard .project-media {
  height: 220px;
  margin-bottom: 28px;
  align-items: center;
}

.project--standard .project-media img {
  max-height: 100%;
}

/* Games: a compact subsection that lets the pixel art lead. */
.showcase-group {
  margin-top: 64px;
}

.group-title {
  padding-bottom: 16px;
  font: 500 12px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.group-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 64px;
}

.project--compact {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 32px 0;
}

/* Text-only: the body takes the whole row instead of the image column. */
.project--compact.no-media {
  grid-template-columns: minmax(0, 1fr);
}

.project--compact .project-media {
  aspect-ratio: 1;
  padding: 16px;
}

.project--compact .project-media img {
  max-height: 100%;
  max-width: 100%;
}

.project--compact .project-media img + img {
  max-width: 42%;
}

.project--compact .project-title {
  margin-top: 10px;
  font-size: 20px;
}

.project--compact .project-award {
  margin-top: 10px;
}

.project--compact .project-summary {
  margin-top: 10px;
  font-size: 14px;
}

.project--compact .project-actions {
  margin-top: 14px;
}

/* Detail view for projects */
#detail .project-media,
#detail .project-figure {
  border-radius: 0;
  border: 0;
}

#detail .project-media {
  height: 340px;
}

#detail .project-media img {
  max-height: 100%;
  width: auto;
}

#detail .project-figure {
  min-height: 0;
}

.project-video {
  aspect-ratio: 16 / 9;
  background: #000;
}

.project-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.detail-project .project-title {
  margin-top: 12px;
  font-size: 30px;
}

@media (max-width: 860px) {
  .project--featured {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-bottom: 56px;
  }

  .showcase-grid,
  .group-grid {
    grid-template-columns: 1fr;
  }

  .project--tall {
    grid-column: auto;
    grid-row: auto;
  }

  .showcase-grid > .project + .project,
  .group-grid > .project + .project {
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 600px) {
  .project-figure {
    min-height: 0;
    padding: 24px;
  }

  .project--tall .project-media {
    height: 300px;
  }

  .project--tall .project-media img {
    width: 200px;
    margin-bottom: -140px;
  }

  .project--compact {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 18px;
  }

  .project--compact.no-media {
    grid-template-columns: minmax(0, 1fr);
  }

  .project--compact .project-media {
    padding: 10px;
  }

  #detail .project-media {
    height: 240px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .project-media img,
  .project-link .arrow {
    transition: none;
  }

  .project.is-linked:hover .project-media img,
  .project.is-linked:hover .project-link .arrow,
  .project-link:hover .arrow {
    transform: none;
  }
}

/* Scroll-in reveal */
.reveal,
.section-title,
.card {
  opacity: 0;
  translate: 0 24px;
  transition: opacity 0.8s var(--ease-out), translate 0.8s var(--ease-out), border-color 0.25s ease,
    transform 0.35s var(--ease-out), background-color 0.25s ease;
}

.reveal.in,
.section-title.in,
.card.in {
  opacity: 1;
  translate: 0 0;
}

.grid .card:nth-child(3n + 2) { transition-delay: 0.06s, 0.06s, 0s, 0s, 0s; }
.grid .card:nth-child(3n + 3) { transition-delay: 0.12s, 0.12s, 0s, 0s, 0s; }

/* ---------------------------------------------------------------- Detail */

#detail {
  width: min(760px, 100% - 32px);
  max-height: min(88vh, 900px);
  margin: auto;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  overflow: auto;
  overscroll-behavior: contain;
}

#detail[open] {
  animation: pop 0.35s var(--ease-out);
}

#detail::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
}

#detail .card-media {
  height: 340px;
}

.detail-text {
  display: grid;
  gap: 16px;
  padding: 32px;
}

#detail h3 {
  font-size: 30px;
}

/* Keep the date clear of the close button. */
.detail-text .card-heading {
  padding-right: 44px;
}

.detail-text > p {
  font-size: 16px;
  line-height: 1.7;
  color: #d6d1cd;
}

.detail-text a:not(.link) {
  color: var(--accent);
}

.dialog-close {
  position: sticky;
  top: 14px;
  float: right;
  margin: 14px 14px -54px 0;
  z-index: 1;
  width: 40px;
  height: 40px;
  font-size: 24px;
  line-height: 1;
  color: var(--text);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.dialog-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* ---------------------------------------------------------------- Footer */

#footer {
  display: grid;
  justify-items: center;
  gap: 20px;
  width: min(1120px, 100% - 48px);
  margin: 80px auto 0;
  padding: 48px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

#footer .socials a {
  background: var(--surface);
  border-color: var(--border);
  backdrop-filter: none;
}

#footer .socials a:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

#footer a:not(.socials a) {
  text-decoration: none;
}

#footer a:not(.socials a):hover {
  color: var(--text);
}

/* ------------------------------------------------------------ Responsive */

@media (orientation: portrait) {
  #hero {
    top: 45%;
  }

  #hero h1 {
    font-size: min(8vh, 10vw);
  }

  #hero p {
    font-size: 2.6vh;
  }
}

@media (max-width: 600px) {
  .socials a {
    width: 44px;
    height: 44px;
  }

  #content {
    width: calc(100% - 32px);
  }

  .section + .section {
    margin-top: 80px;
  }

  #detail .card-media {
    height: 240px;
  }

  .detail-text {
    padding: 24px;
  }

  #detail h3 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .section-title,
  .card {
    opacity: 1;
    translate: none;
  }

  .scroll-hint span,
  #detail[open] {
    animation: none;
  }
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 10px;
}

/* Scroll progress: a hairline track on the left edge with an accent fill. */
#scroll-progress {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 14px;
  width: 2px;
  z-index: 40;
  background: var(--border);
  pointer-events: none;
}

#scroll-progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
}

@media (max-width: 600px) {
  #scroll-progress {
    left: 4px;
  }
}
