/* Base and shared dimensions */
@font-face {
  font-family: Poppins;
  src: url("fonts/Poppins-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* Night is also the fallback palette before JavaScript initializes. */
  --color-background: #080d1b;
  --color-text: #edf2ff;
  --color-muted: #8fa5d0;
  --color-description: #bdc9e1;
  --color-panel: #101a30;
  --color-border: #26385a;
  --page-gutter: clamp(12px, 2.1vw, 32px);
  --hero-expanded: max(440px, calc(100svh - 2 * var(--page-gutter)));
  --navbar-height: 80px;
  --content-width: 1160px;
  --hero-radius: 24px;
  --content-top: calc(var(--page-gutter) + var(--navbar-height) + 24px);
  --content-padding: clamp(24px, 4vw, 48px);
  font-family: Poppins, sans-serif;
}

/* Palettes follow the peach, blue, pink and midnight tones of the hero images. */
:root[data-theme="day"] {
  --color-background: #181316;
  --color-text: #fff0e7;
  --color-muted: #c39c94;
  --color-description: #d8c1b9;
  --color-panel: #241d22;
  --color-border: #513a3e;
}
:root[data-theme="afternoon"] {
  --color-background: #101923;
  --color-text: #eef6ff;
  --color-muted: #94b5d0;
  --color-description: #c0d1e2;
  --color-panel: #192736;
  --color-border: #334c63;
}
:root[data-theme="evening"] {
  --color-background: #1a1223;
  --color-text: #fff0fa;
  --color-muted: #c49bbd;
  --color-description: #ddc2d6;
  --color-panel: #281d34;
  --color-border: #513450;
}

* {
  box-sizing: border-box;
}
html {
  background: var(--color-background);
  scroll-padding-top: var(--content-top);
}
body {
  margin: 0;
}
/* Keep outgoing content out of the navbar's rounded corners and top gutter. */
body::before {
  content: "";
  position: fixed;
  z-index: 9;
  inset: 0 0 auto;
  height: calc(var(--content-top) - 12px);
  background: var(--color-background);
  pointer-events: none;
}

/* Hero */
.hero {
  --hero-text-inset: clamp(28px, 5vw, 80px);
  --hero-text-bottom: clamp(88px, 8svh, 96px);
  --avatar-compact: calc(var(--navbar-height) - 24px);
  --avatar-inset: 20px;
  --avatar-current-top: calc(var(--avatar-top, var(--avatar-inset)) + (12px - var(--avatar-top, var(--avatar-inset))) * var(--hero-progress, 0));
  --avatar-current-size: calc(var(--avatar-expanded, 144px) + (var(--avatar-compact) - var(--avatar-expanded, 144px)) * var(--hero-progress, 0));
  position: fixed;
  z-index: 10;
  top: var(--page-gutter);
  left: var(--hero-inset, var(--page-gutter));
  right: var(--hero-inset, var(--page-gutter));
  height: var(--hero-height, var(--hero-expanded));
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
  border-radius: var(--current-radius, var(--hero-radius));
  background: var(--color-panel);
}

.hero__image {
  position: absolute;
  width: 100%;
  height: var(--hero-expanded);
  max-width: none;
  object-fit: cover;
  object-position: 60% 54%;
  transform: translateY(var(--image-offset, 0px));
  filter: blur(var(--image-blur, 0px));
}

.hero__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--color-background) 33%, transparent), transparent 75%),
    linear-gradient(0deg, color-mix(in srgb, var(--color-background) 85%, transparent), transparent 85%);
}

.hero__intro,
.hero__status {
  position: absolute;
  bottom: var(--hero-text-bottom);
  overflow-wrap: anywhere;
  opacity: var(--intro-opacity, 1);
  transform: translateY(var(--intro-offset, 0px));
}

.hero__intro {
  left: var(--hero-text-inset);
  right: 28px;
}

.hero__identity {
  --avatar-start-left: calc(100% - var(--avatar-inset) - var(--avatar-expanded, 144px));
  position: absolute;
  top: var(--avatar-current-top);
  left: calc(var(--avatar-start-left) + (12px - var(--avatar-start-left)) * var(--hero-progress, 0));
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
}
.hero__avatar {
  display: block;
  flex-shrink: 0;
  width: var(--avatar-current-size);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid #ffffff40;
  border-radius: 50%;
  box-shadow: 0 4px 20px #0003;
}

.hero__title {
  margin: 0;
  color: var(--color-text);
  font: 400 clamp(56px, 7.6vw, 116px) / 1.12 Poppins, sans-serif;
  letter-spacing: -.055em;
}

.hero__greeting {
  color: var(--color-muted);
}

.hero__name {
  --name-compact-size: clamp(24px, 2.4vw, 30px);
  color: var(--color-text);
  font-size: var(--name-compact-size);
  opacity: var(--navbar-opacity, 0);
  line-height: 1.12;
  letter-spacing: -.055em;
  pointer-events: none;
}

.hero__description,
.hero__status {
  color: var(--color-description);
  font-size: clamp(15px, 1.3vw, 19px);
  line-height: 1.75;
}

.hero__description {
  max-width: 440px;
  margin: 24px 0 0;
}

.hero__status {
  right: var(--hero-text-inset);
  display: grid;
  text-align: right;
  pointer-events: none;
}

.hero__nav {
  --nav-right: 20px;
  position: absolute;
  top: calc(var(--navbar-height) / 2);
  right: calc(var(--nav-right) + var(--compact-inset, var(--page-gutter)) - var(--hero-inset, var(--page-gutter)));
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.5vw, 24px);
  transform: translate(calc(-64px * (1 - var(--navbar-opacity, 0))), -50%);
  opacity: var(--navbar-opacity, 0);
  visibility: hidden;
}
.hero[data-nav-visible] .hero__nav {
  visibility: visible;
}
.hero__nav a {
  padding: 10px 6px;
  border-radius: 8px;
  color: var(--color-text);
  font-size: clamp(13px, 1.3vw, 17px);
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 180ms ease;
}
.hero__nav a:hover {
  background: #ffffff14;
}
.hero__nav a:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Page layout and section headings */
/* Reserve the expanded hero's height while it gradually collapses on scroll. */
.scroll-space {
  height: calc(var(--hero-expanded) + 2 * var(--page-gutter));
}
.content {
  --section-gap: clamp(48px, 7vw, 88px);
  width: min(var(--content-width), calc(100% - 2 * var(--page-gutter)));
  margin-inline: auto;
  padding-block: var(--content-padding);
  min-width: 0;
  opacity: var(--content-opacity, 0.05);
}
.section-title {
  margin: 0 0 8px;
  color: var(--color-text);
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 400;
  text-align: center;
}
.section-description {
  margin: 0 0 24px;
  color: var(--color-description);
  font-size: clamp(15px, 1.3vw, 18px);
  line-height: 1.75;
  text-align: center;
}
.content > * + * {
  margin-top: var(--section-gap);
}
.content section {
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Leave enough scroll range to align even the final section below the navbar. */
.content > section:last-child {
  min-height: calc(100svh - var(--content-top) - var(--content-padding));
}

/* Wrapping rows keep every row, including an incomplete last row, centered. */
.projects__list {
  --project-gap: clamp(16px, 2.5vw, 32px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--project-gap);
}
.project-card {
  flex: 0 1 calc((100% - var(--project-gap)) / 2);
  display: flow-root;
  padding: clamp(18px, 2.5vw, 28px);
  min-width: min(100%, 320px);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--hero-radius);
  background: var(--color-panel);
}
.project-card__image {
  float: right;
  display: block;
  width: 44%;
  margin: 0 0 12px 18px;
  height: auto;
  aspect-ratio: 12 / 7;
  object-fit: cover;
  border-radius: 12px;
}
.project-card__image--violet {
  filter: hue-rotate(55deg);
}
.project-card__image--green {
  filter: hue-rotate(-65deg);
}
.project-card__image--warm {
  filter: hue-rotate(170deg);
}
.project-card__title {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
  color: var(--color-text);
  font-size: clamp(20px, 2vw, 26px);
  font-weight: 400;
}
.project-card__description {
  margin: 0;
  color: var(--color-description);
  font-size: clamp(14px, 1.2vw, 16px);
  line-height: 1.75;
  overflow-wrap: anywhere;
}
/* Shared icon tiles */
.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--tile-gap, 16px);
  flex-shrink: 0;
  padding: var(--tile-padding, 14px 16px);
  border: 1px solid var(--color-border);
  border-radius: var(--hero-radius);
  background: var(--color-panel);
  color: var(--color-text);
  font-size: var(--tile-font-size, 20px);
  white-space: nowrap;
}
.tile__icon {
  font-size: var(--tile-icon-size, 32px);
  width: var(--tile-icon-width, 36px);
  flex-shrink: 0;
  text-align: center;
  color: var(--color-muted);
}

/* Skills */
.skills__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(12px, 2vw, 20px);
}

/* About */
.about__columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: clamp(24px, 4vw, 48px);
  margin-top: 24px;
}
.about__column {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-description);
  font-size: clamp(18px, 1.8vw, 22px);
  line-height: 1.8;
}
.about__column strong,
.about__column b {
  color: var(--color-text);
  font-weight: 700;
}

.social-links-label {
  margin-bottom: 0;
}
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.social-links__item {
  --tile-gap: 10px;
  --tile-padding: 8px 12px;
  --tile-font-size: 14px;
  --tile-icon-width: 20px;
  --tile-icon-size: 20px;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-decoration: none;
  line-height: 1.5;
}
.social-links__item span {
  min-width: 0;
}
.social-links__item:hover {
  border-color: var(--color-muted);
}
.social-links__item:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 4px;
}

/* A stable hover area prevents the moving photos from toggling the swap. */
.about-photos {
  --photo-swap-duration: 650ms;
  position: relative;
  isolation: isolate;
  width: min(100%, 440px);
  aspect-ratio: 1;
  margin-inline: auto;
  border-radius: var(--hero-radius);
  overflow: clip;
}
.about-photos:focus-visible {
  outline: 2px solid var(--color-muted);
  outline-offset: 4px;
}
.about-photos__image {
  position: absolute;
  display: block;
  width: 45%;
  height: auto;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border: 1px solid var(--color-border);
  border-radius: var(--hero-radius);
  box-shadow: 0 12px 32px #0005;
  transition: left var(--photo-swap-duration) ease,
    top var(--photo-swap-duration) ease,
    rotate var(--photo-swap-duration) ease,
    z-index 0s calc(var(--photo-swap-duration) / 2);
}
.about-photos__image--back,
.about-photos[data-swapped] .about-photos__image--front {
  z-index: 1;
  left: 16%;
  top: 4%;
  rotate: -24deg;
}
.about-photos__image--front,
.about-photos[data-swapped] .about-photos__image--back {
  z-index: 2;
  left: 34%;
  top: 7%;
  rotate: 28deg;
}
.about-photos__image--back {
  object-position: 30% center;
}
.about-photos__image--front {
  object-position: 75% center;
}

/* Repeatable viewport reveals; translation preserves the normal text layout. */
.scroll-reveal {
  opacity: 0;
  translate: 0 24px;
  transition: none;
}
.scroll-reveal.is-visible {
  opacity: 1;
  translate: 0 0;
  transition: opacity 600ms ease, translate 600ms ease;
}

/* Accessibility and responsive overrides */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

@media (prefers-reduced-motion: reduce) {
  .about-photos__image {
    transition: none;
  }
  .scroll-reveal,
  .scroll-reveal.is-visible {
    opacity: 1;
    translate: none;
    transition: none;
  }
}

@media (max-width: 600px) {
  :root {
    --navbar-height: 68px;
    --hero-radius: 20px;
  }
  .hero {
    --hero-text-bottom: 88px;
  }
  .hero__status {
    display: none;
  }
  .hero__title {
    font-size: clamp(48px, 10vw, 60px);
  }
  .hero__description {
    margin-top: 20px;
    max-width: 320px;
  }
  .project-card {
    flex-basis: 100%;
    padding: 16px;
  }
  .project-card__image {
    float: none;
    width: 100%;
    max-height: 160px;
    margin: 0 0 12px;
    aspect-ratio: 16 / 7;
  }
  .project-card__title {
    margin-bottom: 8px;
    font-size: 18px;
  }
  .project-card__description {
    line-height: 1.6;
  }
  .skill {
    --tile-gap: 12px;
    --tile-padding: 12px 14px;
    --tile-font-size: 16px;
    --tile-icon-width: 28px;
    --tile-icon-size: 26px;
  }
  .about__columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 400px) {
  .hero__name {
    --name-compact-size: 20px;
  }
  .hero__nav {
    --nav-right: 12px;
    gap: 2px;
  }
  .hero__nav a {
    padding-inline: 4px;
    font-size: 11px;
  }
}

@media (max-height: 600px) {
  .hero__title {
    font-size: clamp(44px, 7vw, 76px);
  }
}
