:root {
  color-scheme: dark;
  --page-bg: #181818;
  --section-bg: #111111;
  --card-bg: #202020;
  --text-primary: #ededed;
  --text-accent-placeholder: #808080;
  --line: #303030;
  --content-max: 1540px;
  --page-gutter: clamp(18px, 3.5vw, 64px);
  --grid-gap: clamp(10px, 1.15vw, 20px);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-bg);
  color: var(--text-primary);
  font-family:
    "Arial Narrow", "Roboto Condensed", "Noto Sans SC", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: geometricPrecision;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, #151515 0, var(--page-bg) 260px),
    var(--page-bg);
}

body.has-open-project {
  overflow: hidden;
}

a {
  color: inherit;
}

.portfolio-shell {
  width: min(100%, calc(var(--content-max) + var(--page-gutter) * 2));
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(38px, 6vw, 96px) var(--page-gutter) 120px;
}

.profile {
  display: block;
  margin-bottom: clamp(48px, 6vw, 88px);
  padding-bottom: 0;
}

.profile__role,
.profile__summary p {
  margin: 0;
}

.profile__name {
  display: grid;
  grid-template-columns: 108px max-content;
  gap: clamp(18px, 2vw, 34px);
  align-items: center;
  margin: 0;
  font-size: clamp(22px, 2.1vw, 34px);
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 1;
  text-transform: uppercase;
}

.profile__name > span:first-child {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.profile__name-en {
  color: var(--text-primary);
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 1em;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.profile__role {
  display: grid;
  grid-template-columns: 108px max-content;
  gap: clamp(18px, 2vw, 34px);
  margin-top: 18px;
  color: #b7b7b7;
  font-size: clamp(11px, 0.9vw, 14px);
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.profile__summary {
  max-width: 1120px;
  margin-top: clamp(28px, 4vw, 52px);
  color: #bdbdbd;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(13px, 1vw, 16px);
  line-height: 1.9;
}

.profile__summary-item + .profile__summary-item {
  margin-top: 22px;
}

.profile__summary-item p[lang="en"] {
  margin-top: 6px;
  color: #8f8f8f;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 0.82em;
  letter-spacing: 0.035em;
  line-height: 1.65;
  white-space: nowrap;
}

.profile__contact {
  display: flex;
  flex-wrap: wrap;
  gap: 14px clamp(24px, 3vw, 48px);
  margin: clamp(24px, 3vw, 40px) 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.profile__contact div {
  display: flex;
  gap: 10px;
}

.profile__contact dt {
  color: var(--text-accent-placeholder);
  text-transform: uppercase;
}

.profile__contact dd {
  margin: 0;
  color: #c8c8c8;
}

.profile__contact a {
  text-decoration: none;
}

.profile__contact a:hover,
.profile__contact a:focus-visible {
  color: var(--text-primary);
}

.work-section + .work-section {
  margin-top: clamp(72px, 10vw, 150px);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: clamp(14px, 1.7vw, 25px);
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.section-header h1,
.section-header h2 {
  margin: 0;
  font-size: clamp(18px, 1.55vw, 25px);
  font-stretch: condensed;
  font-weight: 600;
  letter-spacing: 0.075em;
  line-height: 1;
  text-transform: uppercase;
}

.section-count {
  color: var(--text-accent-placeholder);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gap);
}

.work-card {
  min-width: 0;
}

.work-card__link {
  display: block;
  text-decoration: none;
}

.work-card__image-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--card-bg);
  isolation: isolate;
}

.work-card__image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1);
  transition:
    opacity 260ms ease,
    filter 420ms ease,
    transform 700ms cubic-bezier(0.2, 0.68, 0.25, 1);
}

.work-card__image.is-loaded {
  opacity: 1;
}

.work-card__placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, transparent 49.85%, #2b2b2b 50%, transparent 50.15%),
    linear-gradient(45deg, transparent 49.85%, #2b2b2b 50%, transparent 50.15%),
    var(--card-bg);
  color: #696969;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.work-card__caption {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  padding: 42px clamp(12px, 1.1vw, 18px) clamp(13px, 1.2vw, 19px);
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgb(0 0 0 / 0.22) 25%,
    rgb(0 0 0 / 0.86) 100%
  );
}

.work-card__title,
.work-card__year {
  margin: 0;
  text-transform: uppercase;
}

.work-card__title {
  max-width: 95%;
  font-size: clamp(13px, 1.12vw, 18px);
  font-weight: 600;
  letter-spacing: 0.025em;
  line-height: 1.18;
}

.work-card__title .title-secondary {
  color: #b5b5b5;
  font-size: 0.78em;
  font-weight: 500;
  letter-spacing: 0.045em;
}

.work-card__year {
  margin-top: 6px;
  color: var(--text-accent-placeholder);
  font-size: clamp(9px, 0.7vw, 11px);
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1;
}

.work-card__link:hover .work-card__image,
.work-card__link:focus-visible .work-card__image {
  filter: brightness(1.08);
  transform: scale(1.018);
}

.work-card__link:focus-visible {
  outline: 1px solid var(--text-primary);
  outline-offset: 5px;
}

.project-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 32px);
  visibility: hidden;
  opacity: 0;
  transition:
    visibility 0s linear 320ms,
    opacity 320ms ease;
}

.project-overlay.is-open {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.project-overlay__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgb(5 5 5 / 0.72);
  backdrop-filter: blur(9px);
  cursor: zoom-out;
}

.project-stage {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(96vw, 1760px);
  height: 94vh;
  opacity: 0;
  transform: scale(0.975);
  transition:
    opacity 280ms ease,
    transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.project-viewer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #101010;
  box-shadow: 0 30px 100px rgb(0 0 0 / 0.5);
}

.project-overlay.is-open .project-stage {
  opacity: 1;
  transform: scale(1);
}

.project-stage.has-description {
  transform: translateX(clamp(-180px, -9vw, -80px)) scale(0.975);
}

.project-overlay.is-open .project-stage.has-description {
  transform: translateX(clamp(-180px, -9vw, -80px)) scale(1);
}

.project-stage.has-description .project-viewer {
  width: 100%;
  flex: none;
}

.project-description {
  position: absolute;
  top: 0;
  left: 100%;
  display: none;
  width: clamp(260px, 18vw, 360px);
  flex: 0 0 clamp(260px, 18vw, 360px);
  height: 100%;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #161616;
}

.project-stage.has-description .project-description--desktop {
  display: block;
}

.project-description--mobile {
  display: none;
}

.project-description__label {
  margin: 0;
  padding: 28px 26px 17px;
  border-bottom: 1px solid var(--line);
  color: var(--text-accent-placeholder);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.17em;
  line-height: 1;
  text-transform: uppercase;
}

.project-description__body {
  padding: 30px 30px 48px;
  color: #c8c8c8;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.025em;
  line-height: 2;
}

.project-description__body p {
  margin: 0;
}

.project-description__body p + p {
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.project-description__body p[lang="en"] {
  color: #a9a9a9;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 0.88em;
  letter-spacing: 0.025em;
  line-height: 1.8;
}

.project-viewer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 16px clamp(18px, 2.2vw, 38px);
  border-bottom: 1px solid var(--line);
  background: #101010;
}

.project-viewer__title,
.project-viewer__year {
  margin: 0;
  text-transform: uppercase;
}

.project-viewer__title {
  font-size: clamp(16px, 1.4vw, 23px);
  font-weight: 600;
  letter-spacing: 0.045em;
  line-height: 1.1;
}

.project-viewer__year {
  margin-top: 5px;
  color: var(--text-accent-placeholder);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
}

.project-viewer__close {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.project-viewer__close span {
  position: absolute;
  top: 20px;
  left: 10px;
  width: 22px;
  height: 1px;
  background: var(--text-primary);
  transition: background 180ms ease;
}

.project-viewer__close span:first-child {
  transform: rotate(45deg);
}

.project-viewer__close span:last-child {
  transform: rotate(-45deg);
}

.project-viewer__close:hover span,
.project-viewer__close:focus-visible span {
  background: var(--text-accent-placeholder);
}

.project-viewer__close:focus-visible {
  outline: 1px solid var(--text-primary);
}

.project-viewer__content {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: #555 #171717;
  scrollbar-width: thin;
}

.project-image {
  width: 100%;
  margin: 0;
  background: #080808;
}

.project-image + .project-image {
  margin-top: 1px;
}

.project-image img {
  display: block;
  width: 100%;
  height: auto;
}

.project-page-button {
  position: absolute;
  z-index: 2;
  bottom: clamp(32px, 7vh, 76px);
  display: grid;
  width: clamp(68px, 6vw, 96px);
  height: clamp(42px, 3.2vw, 52px);
  place-items: center;
  padding: 0;
  border: 0;
  background: var(--text-accent-placeholder);
  color: #111111;
  cursor: pointer;
  opacity: 1;
  transition:
    background 180ms ease,
    opacity 180ms ease,
    visibility 180ms ease;
}

.project-page-button--previous {
  left: clamp(8px, 3.6vw, 72px);
}

.project-page-button--next {
  right: clamp(8px, 3.6vw, 72px);
}

.project-page-button span {
  width: 13px;
  height: 13px;
  border-top: 3px solid currentColor;
  border-left: 3px solid currentColor;
}

.project-page-button--previous span {
  transform: rotate(-45deg);
}

.project-page-button--next span {
  transform: rotate(135deg);
}

.project-page-button:hover,
.project-page-button:focus-visible {
  background: #9a9a9a;
}

.project-page-button:focus-visible {
  outline: 1px solid var(--text-primary);
  outline-offset: 4px;
}

.project-page-button.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .profile__summary-item p[lang="en"] {
    white-space: normal;
  }

  .work-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  :root {
    --page-gutter: 12px;
    --grid-gap: 8px;
  }

  .portfolio-shell {
    padding-top: 28px;
    padding-bottom: 72px;
  }

  .profile {
    grid-template-columns: 1fr;
    align-items: start;
    margin-bottom: 58px;
  }

  .profile__role {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .profile__name {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .work-section + .work-section {
    margin-top: 58px;
  }

  .work-card__caption {
    padding: 35px 9px 10px;
  }

  .work-card__title {
    font-size: 11px;
  }

  .work-card__year {
    margin-top: 5px;
    font-size: 8px;
  }

  .project-overlay {
    padding: 6px;
  }

  .project-viewer {
    width: 100%;
    height: calc(100dvh - 12px);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .project-stage,
  .project-stage.has-description {
    width: 100%;
    height: calc(100dvh - 12px);
    transform: scale(0.975);
  }

  .project-overlay.is-open .project-stage,
  .project-overlay.is-open .project-stage.has-description {
    transform: scale(1);
  }

  .project-stage.has-description .project-viewer {
    width: 100%;
    flex: 1 1 auto;
  }

  .project-description--desktop,
  .project-stage.has-description .project-description--desktop {
    display: none;
  }

  .project-stage.has-description .project-viewer {
    display: block;
    overflow-y: auto;
  }

  .project-stage.has-description .project-viewer__header {
    position: sticky;
    top: 0;
    z-index: 3;
  }

  .project-stage.has-description .project-viewer__content {
    overflow: visible;
  }

  .project-stage.has-description .project-description--mobile {
    position: static;
    display: block;
    width: 100%;
    height: auto;
    min-height: 55vh;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .project-viewer__header {
    min-height: 60px;
    padding: 11px 13px;
  }

  .project-page-button {
    bottom: 18px;
    width: 64px;
    height: 42px;
  }

  .project-page-button--previous {
    left: 14px;
  }

  .project-page-button--next {
    right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
    .work-card__image,
    .project-overlay,
    .project-stage {
      transition: none;
    }
  }
