:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #0a0a0a;
  --muted: #6f6f6f;
  --faint: #a0a0a0;
  --line: rgba(10, 10, 10, 0.13);
  --line-strong: rgba(10, 10, 10, 0.28);
  --glass: rgba(248, 248, 248, 0.76);
  --glass-edge: rgba(255, 255, 255, 0.72);
  --accent-a: #1d6fff;
  --accent-b: #00a879;
  --accent-c: #ff6a3d;
  --font-ui: "Space Grotesk", "Avenir Next", sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-nav: "Lato", "Avenir Next", sans-serif;
  --shell: min(1120px, calc(100vw - 48px));
  --nav-height: 58px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080808;
  --text: #f6f6f3;
  --muted: #9d9d9a;
  --faint: #6c6c69;
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.3);
  --glass: rgba(28, 28, 28, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.12);
  --accent-a: #1d6fff;
  --accent-b: #00a879;
  --accent-c: #ff6a3d;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 38px);
}

body {
  min-width: 280px;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
  transition: background-color 320ms ease, color 320ms ease;
}

body::selection {
  background: var(--text);
  color: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

img,
svg {
  display: block;
}

.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;
}

.ambient-flow {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.32;
  background:
    radial-gradient(ellipse 36% 24% at 75% 4%, color-mix(in srgb, var(--accent-a) 13%, transparent), transparent 75%),
    radial-gradient(ellipse 30% 18% at 90% 58%, color-mix(in srgb, var(--accent-b) 9%, transparent), transparent 78%),
    radial-gradient(ellipse 28% 22% at 12% 91%, color-mix(in srgb, var(--accent-c) 8%, transparent), transparent 78%);
  filter: blur(20px);
  transform: translateZ(0);
  animation: ambient-drift 18s ease-in-out infinite alternate;
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 0;
}

.glass-nav {
  position: relative;
  top: 16px;
  width: min(620px, calc(100vw - 32px));
  height: var(--nav-height);
  margin-inline: auto;
  padding: 7px 9px 7px 11px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  border: 1px solid var(--glass-edge);
  border-radius: 22px;
  background: var(--glass);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.09),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  transition: background-color 320ms ease, border-color 320ms ease, box-shadow 320ms ease;
}

:root[data-theme="dark"] .glass-nav {
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-nav);
  font-size: 0.72rem;
  font-weight: 600;
  transition: transform 200ms ease, border-radius 200ms ease;
}

.brand:hover {
  transform: rotate(-4deg);
  border-radius: 10px 14px 10px 14px;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: clamp(1.1rem, 5vw, 2.4rem);
  font-family: var(--font-nav);
}

.nav-links a {
  position: relative;
  padding: 0.35rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  transition: color 180ms ease;
}

.nav-links a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  content: "";
  background: currentColor;
  transform: scaleX(0);
  transition: transform 220ms ease;
}

.nav-links a:hover,
.nav-links a.is-current {
  color: var(--text);
}

.nav-links a:hover::after,
.nav-links a.is-current::after {
  transform: scaleX(1);
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 13px;
  background: transparent;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.icon-button:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  transform: rotate(8deg);
}

.icon-button svg {
  grid-area: 1 / 1;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  transition: opacity 220ms ease, transform 300ms ease;
}

.moon-icon,
:root[data-theme="dark"] .sun-icon {
  opacity: 0;
  transform: scale(0.6) rotate(-25deg);
}

:root[data-theme="dark"] .moon-icon {
  opacity: 1;
  transform: scale(1) rotate(0);
}

.intro {
  min-height: min(580px, 70svh);
  padding-top: clamp(135px, 18vh, 175px);
  padding-bottom: clamp(68px, 9vh, 92px);
}

.intro-main {
  max-width: 760px;
}

.intro h1,
.section-head h2,
.about h2,
.contact h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0;
}

.intro h1 {
  max-width: 12ch;
  font-size: clamp(2.75rem, 4.4vw, 4rem);
  line-height: 1.02;
}

.gradient-text {
  display: inline;
  color: transparent;
  background: linear-gradient(105deg, var(--text) 5%, var(--accent-a) 35%, var(--accent-b) 60%, var(--accent-c) 82%, var(--text) 98%);
  background-size: 240% 100%;
  background-clip: text;
  -webkit-background-clip: text;
  font-style: italic;
  animation: gradient-flow 8s ease-in-out infinite;
}

.intro-copy {
  max-width: 610px;
  margin: 1.35rem 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.4vw, 1.08rem);
}

.role-line {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.role-mask {
  display: inline-block;
  height: 1.5em;
  overflow: hidden;
  vertical-align: bottom;
}

.role-mask span {
  display: inline-block;
  width: 8ch;
  color: transparent;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b), var(--accent-c));
  background-clip: text;
  -webkit-background-clip: text;
  font-weight: 600;
}

.work,
.about,
.contact {
  padding-block: clamp(90px, 12vw, 150px);
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
}

.section-label {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.section-head h2,
.about h2,
.contact h2 {
  font-size: clamp(2.35rem, 4.5vw, 4.35rem);
  line-height: 1;
}

.work-count {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.work-tools {
  margin: clamp(2.5rem, 6vw, 4.5rem) 0 1.3rem;
  padding-bottom: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line-strong);
}

.search-control {
  width: min(270px, 32vw);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--muted);
}

.search-control svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.search-control input {
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.84rem;
}

.search-control input::placeholder {
  color: var(--faint);
}

.filter-list {
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2.4vw, 1.6rem);
}

.filter {
  position: relative;
  padding: 0.2rem 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 180ms ease;
}

.filter::after {
  position: absolute;
  right: 0;
  bottom: -0.35rem;
  left: 0;
  height: 1px;
  content: "";
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 200ms ease;
}

.filter:hover,
.filter.is-active {
  color: var(--text);
}

.filter.is-active::after {
  transform: scaleX(1);
}

.work-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: clamp(3rem, 7vw, 6rem);
}

.project-group {
  margin-top: 4.6rem;
}

.project-group:first-child {
  margin-top: 0;
}

.project-group[hidden],
.project-row[hidden] {
  display: none;
}

.project-group > h3 {
  margin: 0 0 1.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
}

.project-row {
  border-top: 1px solid var(--line);
}

.project-row:last-child {
  border-bottom: 1px solid var(--line);
}

.project-row summary {
  min-height: 78px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 90px 18px;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  row-gap: 0.24rem;
  align-items: center;
  list-style: none;
  cursor: pointer;
  transition: color 180ms ease;
}

.project-row summary::-webkit-details-marker {
  display: none;
}

.project-row summary:hover .project-title,
.project-row[open] .project-title {
  color: var(--text);
}

.project-type,
.project-year {
  min-height: 28px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.71rem;
  line-height: 1.2;
}

.project-title {
  position: relative;
  min-width: 0;
  width: fit-content;
  max-width: 100%;
  justify-self: start;
  align-self: center;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.25;
  transition: color 180ms ease;
  grid-column: 2;
  grid-row: 1;
}

.project-title::after {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b), var(--accent-c));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms linear;
}

.project-row:hover .project-title::after,
.project-row[open] .project-title::after {
  transform: scaleX(1);
}

.project-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  align-self: center;
  grid-column: 1;
  grid-row: 1 / 3;
}

.project-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.project-icon--wide {
  overflow: hidden;
  border-radius: 7px;
}

.project-icon--wide img {
  object-fit: cover;
}

.project-year {
  grid-column: 3;
  grid-row: 1 / 3;
  justify-content: flex-end;
  text-align: right;
}

.project-type {
  min-height: auto;
  grid-column: 2;
  grid-row: 2;
  color: var(--faint);
}

.disclosure {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  align-self: center;
  grid-column: 4;
  grid-row: 1 / 3;
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.project-row[open] .disclosure {
  transform: rotate(180deg);
}

.project-detail {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  overflow: hidden;
  padding: 0 3.2rem 0 3.15rem;
  transition: grid-template-rows 300ms ease, opacity 250ms ease, padding 300ms ease;
}

.project-row[open] .project-detail {
  grid-template-rows: 1fr;
  opacity: 1;
  padding-bottom: 1.4rem;
}

.project-detail > * {
  min-height: 0;
}

.project-detail p {
  max-width: 600px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.project-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.4rem;
  color: var(--faint);
  font-size: 0.7rem;
}

.project-actions a {
  color: var(--text);
  border-bottom: 1px solid var(--line-strong);
}

.project-actions a:hover {
  border-color: var(--text);
}

.project-preview {
  position: sticky;
  top: 110px;
  align-self: start;
}

.preview-visual {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: transparent;
  mask-image: linear-gradient(to bottom, #000 0%, #000 82%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 82%, transparent 100%);
}

.preview-visual::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(135deg, transparent 45%, color-mix(in srgb, var(--accent-b) 12%, transparent));
  mix-blend-mode: color;
}

.preview-visual img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(1) contrast(0.96);
  transition: opacity 180ms ease, transform 500ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 250ms ease;
}

.project-preview:hover img {
  filter: grayscale(0.35) contrast(0.96);
  transform: scale(1.015);
}

.project-preview p {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.project-preview.is-changing img {
  opacity: 0;
  transform: translateY(8px) scale(0.99);
}

.empty-state {
  margin: 3rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.about {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(300px, 0.75fr);
  gap: clamp(4rem, 10vw, 10rem);
}

.about h2 {
  max-width: 10ch;
}

.about-copy > p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.stack-list {
  margin-top: 2.2rem;
  padding-top: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 2rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
}

.stack-heading {
  margin: 2.2rem 0 -1.2rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.stack-list span {
  min-height: 32px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: var(--muted);
  line-height: 1.2;
}

.stack-list img {
  width: 20px;
  height: 20px;
  justify-self: center;
  object-fit: contain;
}

:root[data-theme="dark"] img[src$="/flask.svg"],
:root[data-theme="dark"] img[src$="/rust.svg"],
:root[data-theme="dark"] img[src$="/apple.svg"] {
  filter: invert(1);
}

.contact {
  text-align: center;
}

.contact h2 {
  margin-inline: auto;
}

.contact > p:not(.section-label) {
  max-width: 520px;
  margin: 1.15rem auto 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.contact-actions {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
}

.contact-link {
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--line-strong);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  transition: border-color 180ms ease;
}

.contact-link:hover {
  border-color: var(--text);
}

.copy-button {
  padding: 0.45rem 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease;
}

.copy-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.site-footer {
  min-height: 100px;
  padding-block: 1.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
}

.site-footer p {
  margin: 0;
}

.copy-toast {
  position: fixed;
  right: 50%;
  bottom: 22px;
  z-index: 30;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--glass-edge);
  border-radius: 14px;
  background: var(--glass);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(18px) saturate(150%);
  color: var(--text);
  font-size: 0.72rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0);
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 650ms ease, transform 650ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes gradient-flow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes ambient-drift {
  from { transform: translate3d(-1%, -1%, 0) scale(1); }
  to { transform: translate3d(1%, 1.5%, 0) scale(1.04); }
}

@media (max-width: 880px) {
  :root {
    --shell: min(100% - 34px, 700px);
  }

  .intro {
    min-height: auto;
    padding-top: 155px;
  }

  .intro h1 {
    max-width: 13ch;
  }

  .work-layout {
    grid-template-columns: 1fr;
  }

  .project-preview {
    display: none;
  }

  .about {
    grid-template-columns: 1fr;
    gap: 3rem;
  }
}

@media (max-width: 620px) {
  :root {
    --shell: calc(100% - 28px);
    --nav-height: 54px;
  }

  .glass-nav {
    top: 10px;
    width: calc(100vw - 20px);
    height: var(--nav-height);
    border-radius: 19px;
  }

  .nav-links {
    gap: 1.25rem;
  }

  .nav-links a {
    font-size: 0.75rem;
  }

  .intro {
    padding-top: 128px;
    padding-bottom: 66px;
  }

  .intro h1 {
    font-size: clamp(2.5rem, 11.5vw, 3.35rem);
  }

  .intro-copy {
    font-size: 0.92rem;
  }

  .work,
  .about,
  .contact {
    padding-block: 82px;
  }

  .section-head {
    align-items: start;
  }

  .work-count {
    padding-top: 1.75rem;
    white-space: nowrap;
  }

  .work-tools {
    align-items: stretch;
    flex-direction: column;
    gap: 1.25rem;
  }

  .search-control {
    width: 100%;
  }

  .filter-list {
    width: 100%;
    gap: 0;
    justify-content: space-between;
    overflow-x: auto;
  }

  .filter {
    flex: 0 0 auto;
  }

  .project-group {
    margin-top: 3.2rem;
  }

  .project-row summary {
    min-height: 76px;
    grid-template-columns: 28px minmax(0, 1fr) auto 16px;
    gap: 0.65rem;
  }

  .project-type {
    display: flex;
  }

  .project-year {
    max-width: 68px;
    line-height: 1.25;
  }

  .project-detail,
  .project-row[open] .project-detail {
    padding-inline: 2.15rem 1.5rem;
  }

  .stack-list {
    gap: 0.45rem 1rem;
  }

  .contact-actions {
    flex-direction: column;
    gap: 0.8rem;
  }
}

@media (max-width: 360px) {
  .glass-nav {
    grid-template-columns: 38px 1fr 38px;
  }

  .nav-links {
    gap: 0.8rem;
  }

  .nav-links a {
    font-size: 0.69rem;
  }

  .project-row summary {
    grid-template-columns: 28px minmax(0, 1fr) auto 16px;
  }

  .project-detail,
  .project-row[open] .project-detail {
    padding-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
