@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/images/ibm-plex-mono-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/images/ibm-plex-mono-medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/images/ibm-plex-mono-italic.ttf") format("truetype");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --background: #ffffff;
  --text: #000000;
  --muted: #8794aa;
  --surface: #f4f4f4;
  --border: #d9dee4;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: #ffffff;
}

html[data-theme="dark"] { background: #151719; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  transition: background-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

body.page-leaving {
  opacity: 0;
  pointer-events: none;
}

body.dark,
html[data-theme="dark"] body {
  color-scheme: dark;
  --background: #151719;
  --text: #f4f5f6;
  --muted: #929fb2;
  --surface: #25282b;
  --border: #3a3f45;
}

a, button {
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}
a { text-underline-position: from-font; }
button { border: 0; }
h1, h2, p, ul, blockquote { margin: 0; }

.project-page {
  --frame-edge: max(60px, calc((100vw - 1320px) / 2));
  width: 100%;
  min-height: 100vh;
  padding: 60px var(--frame-edge);
  position: relative;
}

.project-main,
.project-back-desktop,
.project-options--desktop {
  animation: page-enter 240ms ease both;
}

.project-main {
  width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.project-main h1 {
  font-size: 28px;
  line-height: 32px;
  font-weight: 400;
  letter-spacing: -0.5px;
}

.project-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-margin-top: 40px;
}

.project-section h2 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 500;
  letter-spacing: -0.5px;
}

.project-section > p,
.project-list,
.project-panel,
.project-quote {
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.5px;
}

.project-list {
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-list li { position: relative; padding-left: 12px; }
.project-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text);
}

.project-media {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 4;
  flex: 0 0 auto;
  border-radius: 20px;
  background: var(--surface);
  overflow: hidden;
  contain: paint;
  clip-path: inset(0 round 20px);
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

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

.project-media video {
  position: absolute;
  inset: -1px;
  display: block;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  object-fit: cover;
  border: 0;
  pointer-events: none;
}

.project-quote,
.project-panel {
  padding: 20px;
  border-radius: 20px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.project-quote { font-style: italic; }
.project-quote img {
  display: block;
  width: 33.906px;
  height: 22.309px;
}

.project-panel > div { display: flex; flex-direction: column; }
.project-panel span { color: var(--muted); }
.project-panel--finding > div { gap: 8px; }

.project-contacts {
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -1px;
}

.project-contacts nav { display: flex; gap: 20px; white-space: nowrap; }

.project-button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background-color 180ms ease, opacity 180ms ease;
}

.project-button:active { transform: scale(0.94); }
.project-button:focus-visible,
.project-contacts a:focus-visible {
  outline: 2px solid #5d8ef7;
  outline-offset: 2px;
}

.project-button > img { display: block; width: 24px; height: 24px; }
.project-lang { font-size: 14px; line-height: 16px; letter-spacing: 0.1px; }

.project-back-desktop {
  position: fixed;
  z-index: 5;
  top: 60px;
  left: var(--frame-edge);
}

.project-options {
  height: 40px;
  display: flex;
  gap: 20px;
}

.project-options--desktop {
  position: absolute;
  z-index: 5;
  top: 60px;
  right: var(--frame-edge);
}

.project-topbar,
.floating-back { display: none; }

.error-main {
  min-height: calc(100vh - 120px);
  justify-content: center;
}

.error-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

.error-code,
.error-description {
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.5px;
}

.error-code {
  color: var(--muted);
}

.error-home {
  min-height: 48px;
  margin-top: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 120ms ease, background-color 180ms ease;
}

.error-home:active {
  transform: scale(0.96);
}

.error-home:focus-visible {
  outline: 2px solid #5d8ef7;
  outline-offset: 2px;
}

.error-topbar {
  justify-content: flex-end;
}

.theme-icon {
  position: relative;
  display: block;
  width: 24px;
  height: 24px;
}

.theme-icon__glyph {
  position: absolute;
  inset: 0;
  width: 24px;
  height: 24px;
  transition: opacity 220ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: center;
}

.theme-icon__moon { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-icon__sun { opacity: 0; transform: rotate(-90deg) scale(0.55); }

body.dark .theme-toggle img,
body.dark .project-button > img,
html[data-theme="dark"] .theme-toggle img,
html[data-theme="dark"] .project-button > img { filter: invert(1); }

body.dark .theme-icon__moon,
html[data-theme="dark"] .theme-icon__moon { opacity: 0; transform: rotate(90deg) scale(0.55); }
body.dark .theme-icon__sun,
html[data-theme="dark"] .theme-icon__sun { opacity: 1; transform: rotate(0deg) scale(1); }

@media (max-width: 1223px) {
  .project-page {
    --frame-edge: 20px;
    padding: 20px;
  }

  .project-main {
    width: 100%;
    max-width: 600px;
  }

  .error-main {
    min-height: calc(100vh - 40px);
  }

  .error-content {
    flex: 1;
    justify-content: center;
  }

  .error-description {
    font-size: 14px;
    line-height: 20px;
  }

  .project-back-desktop,
  .project-options--desktop { display: none; }

  .project-topbar {
    width: 100%;
    height: 40px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
  }

  .error-topbar {
    justify-content: flex-end;
  }

  .project-main h1 {
    font-size: 24px;
    line-height: 28px;
  }

  .project-section > p,
  .project-list,
  .project-panel,
  .project-quote {
    font-size: 14px;
    line-height: 20px;
  }

  .project-list { gap: 4px; }
  .project-list li::before { top: 8px; }

  .floating-back {
    position: fixed;
    z-index: 20;
    top: 20px;
    left: max(20px, calc((100vw - 600px) / 2));
    display: flex;
    border: 1px solid var(--border);
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
  }

  .floating-back.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
}

@keyframes page-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .project-main,
  .project-back-desktop,
  .project-options--desktop { animation: none; }
}
