:root {
  color-scheme: dark;
  --ink: #030303;
  --paper: #f5f6f4;
  --muted: rgba(245, 246, 250, 0.58);
  --line: rgba(200, 222, 255, 0.22);
  --line-strong: rgba(200, 222, 255, 0.34);
  --accent: #ffda47;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: Inter, "Inter Variable", "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.13;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button,
input {
  font: inherit;
}

.catalog-hero {
  position: relative;
  display: grid;
  grid-template-columns: 220px 1fr 170px;
  align-items: end;
  min-height: 390px;
  padding: 70px 42px 48px;
  border-bottom: 1px solid var(--line);
}

.section-code {
  align-self: start;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.section-code b {
  color: var(--accent);
  font-size: 14px;
}

.section-code span,
.catalog-stat span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  letter-spacing: 0.13em;
}

.catalog-title p {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.14em;
}

.catalog-title h1 {
  margin: 0;
  font-size: clamp(68px, 9vw, 132px);
  font-weight: 880;
  line-height: 0.78;
  letter-spacing: -0.065em;
}

.catalog-stat {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-self: end;
}

.catalog-stat strong {
  font-size: 38px;
  font-weight: 820;
  line-height: 0.8;
}

.catalog-stat span {
  text-align: right;
}

.hero-links {
  position: absolute;
  top: 50%;
  right: 42px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  transform: translateY(-50%);
}

.hero-links a {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-decoration: none;
  transition: color 0.18s ease;
}

.hero-links a:hover,
.hero-links a:focus-visible {
  color: var(--accent);
}

.hero-links .resume-link {
  padding: 11px 16px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 720;
  letter-spacing: 0.14em;
}

.hero-links .resume-link:hover,
.hero-links .resume-link:focus-visible {
  background: var(--accent);
  color: var(--ink);
}

.hero-links a span {
  color: rgba(245, 246, 244, 0.38);
}

.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 46px;
  max-width: none;
  margin: 0;
  padding: 0 42px 90px;
}

aside {
  position: sticky;
  top: 82px;
  align-self: start;
  max-height: calc(100vh - 106px);
  overflow: auto;
  padding: 42px 22px 42px 0;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}

aside button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: color 0.18s ease, transform 0.18s ease;
}

aside button:hover {
  color: var(--paper);
  transform: translateX(4px);
}

aside button.active {
  color: var(--accent);
}

aside button.active::before {
  content: "→";
  margin-right: 8px;
  color: var(--accent);
}

aside button span {
  font-size: 15px;
  font-weight: 720;
}

aside button b {
  color: inherit;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

aside > [data-filter-all] {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.nav-group {
  margin: 0 0 30px;
}

.nav-group > button span {
  color: var(--paper);
  font-size: 20px;
}

.nav-group > div {
  padding: 5px 0 0 18px;
}

.nav-group > div button {
  min-height: 36px;
  font-size: 13px;
}

main {
  min-width: 0;
  padding: 34px 28px 80px;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 16, 25, 0.93);
  backdrop-filter: blur(16px);
}

.toolbar input {
  width: min(100%, 440px);
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--paper);
  font-size: 13px;
}

.toolbar input:focus {
  border-color: var(--accent);
}

.toolbar input::placeholder {
  color: rgba(245, 246, 244, 0.35);
}

.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 24px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.result strong {
  color: var(--paper);
  font-size: 28px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: -0.04em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 18px;
  min-width: 0;
}

.work-card {
  overflow: hidden;
  padding-top: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: transparent;
  box-shadow: none;
  transition: transform 0.22s ease, border-color 0.22s ease;
}

.work-card[hidden] {
  display: none !important;
}

.work-card:hover {
  border-color: rgba(255, 218, 71, 0.7);
  transform: translateY(-4px);
}

.visual {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #111;
}

.visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.work-card:hover .visual img {
  transform: scale(1.025);
}

.portfolio-rank {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  min-width: 36px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(3, 3, 3, 0.72);
  color: var(--paper);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-align: center;
  backdrop-filter: blur(8px);
}

.portfolio-rank::before {
  content: "#";
  margin-right: 1px;
  opacity: 0.55;
}

.duration {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 4px 7px;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  font-size: 10px;
}

.copy {
  padding: 18px 18px 20px;
}

.copy p {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.copy h2 {
  margin: 0 0 8px;
  color: var(--paper);
  font-size: 17px;
  font-weight: 760;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.copy small {
  display: block;
  min-height: 34px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.work-card .play-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 15px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid rgba(255, 218, 71, 0.5);
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.work-card .play-button:hover {
  border-color: var(--accent);
}

.work-card .play-button span {
  font-size: 9px;
}

.empty {
  display: none;
  min-height: 330px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.empty b {
  color: var(--paper);
  font-size: 22px;
  letter-spacing: 0.05em;
}

.empty span {
  margin-top: 9px;
  font-size: 12px;
}

footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 28px 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.13em;
  text-align: center;
}

footer span:nth-child(2) {
  justify-self: center;
}

footer a {
  justify-self: end;
  color: var(--paper);
  text-decoration: none;
}

.player-overlay[hidden] {
  display: none;
}

.player-overlay {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(14px);
}

.player-shell {
  width: min(1120px, 96vw);
  max-height: 94vh;
  overflow: auto;
  border: 1px solid var(--line-strong);
  background: #030303;
}

.player-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.player-head span {
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.player-head h2 {
  margin: 6px 0 0;
  font-size: 18px;
}

.player-head button {
  border: 0;
  background: transparent;
  color: var(--paper);
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.player-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 280px;
  background: #000;
}

.player-stage video {
  display: block;
  width: 100%;
  max-height: 72vh;
  background: #000;
}

.player-status {
  position: absolute;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.player-status:empty {
  display: none;
}

.player-meta {
  margin: 0;
  padding: 13px 22px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

body.player-open {
  overflow: hidden;
}

.data-update {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  padding: 12px 14px;
  background: #111;
  color: #fff;
  border: 1px solid #ffd21a;
  box-shadow: 0 8px 24px #0005;
}

.data-update button {
  margin-left: 10px;
  padding: 5px 9px;
  border: 0;
  background: #ffd21a;
  font: inherit;
  cursor: pointer;
}

.stack-category-heading[hidden],
.project-stack-row[hidden] {
  display: none !important;
}

.stack-category-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 40px 0 2px;
  padding-top: 18px;
  border-top: 1px solid rgba(245, 246, 244, 0.25);
}

.stack-category-heading h2 {
  margin: 0;
  color: var(--paper);
  font-size: 25px;
  line-height: 1;
  letter-spacing: 0;
}

.stack-category-heading span {
  color: rgba(245, 246, 244, 0.5);
  font-size: 10px;
  letter-spacing: 0.11em;
  white-space: nowrap;
}

.project-stack-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(175px, 0.75fr) minmax(0, 3fr);
  gap: 28px;
  align-items: start;
  padding: 16px 0 20px;
  border-top: 1px solid rgba(245, 246, 244, 0.11);
  min-width: 0;
  max-width: 100%;
}

.project-stack-label {
  padding: 10px 0;
}

.project-stack-label h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--paper);
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.project-stack-label span {
  display: block;
  margin-top: 8px;
  color: rgba(245, 246, 244, 0.5);
  font-size: 10px;
  letter-spacing: 0.11em;
}

.stack-cards {
  position: relative;
  width: min(272px, 100%);
  padding: 0 14px 14px 0;
  outline: none;
  min-width: 0;
  max-width: 100%;
}

.stack-cards > .work-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.stack-cards:focus-visible > .work-card:first-child {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.stack-cards > .work-card:first-child {
  position: relative;
  z-index: 3;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.stack-cards > .work-card:not(:first-child) {
  position: absolute;
  inset: 5px 0 0 5px;
  z-index: 2;
  pointer-events: none;
  opacity: 0.82;
  background: #080808;
  transform: translate(4px, 4px);
}

.stack-cards > .work-card:nth-child(3) {
  z-index: 1;
  inset: 10px 0 0 10px;
  opacity: 0.6;
  transform: translate(8px, 8px);
}

.stack-cards > .work-card:nth-child(n + 4) {
  display: none;
}

.stack-cards > .work-card:not(:first-child) .copy {
  visibility: hidden;
}

.project-stack-row.is-stackable:not(.is-open):hover .stack-cards > .work-card:first-child {
  border-color: var(--accent);
  transform: translate(-3px, -3px);
}

.project-stack-row.is-open .stack-cards {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 18px;
  padding: 0;
}

.project-stack-row.is-open .stack-cards > .work-card {
  position: relative;
  inset: auto;
  z-index: auto;
  display: block;
  pointer-events: auto;
  opacity: 1;
  background: transparent;
  transform: none;
}

.project-stack-row.is-open .stack-cards > .work-card .copy {
  visibility: visible;
}

.project-stack-row.is-open .stack-cards > .work-card:first-child {
  transition: none;
}

.project-stack-row.is-open .stack-cards > .work-card:hover {
  border-color: var(--accent);
}

.stack-collapse-control {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 95;
  width: 58px;
  height: 58px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: #050505;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.48);
}

.stack-collapse-control:hover,
.stack-collapse-control:focus-visible {
  background: var(--accent);
  color: #050505;
}

.stack-collapse-control:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

.stack-collapse-control[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .catalog-hero {
    grid-template-columns: 170px 1fr 150px;
  }
}

@media (max-width: 900px) {
  .project-stack-row {
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 20px;
  }

  .project-stack-row.is-open .stack-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .catalog-hero {
    grid-template-columns: 1fr;
    row-gap: 20px;
    min-height: 300px;
    padding: 55px 20px 34px;
  }

  .section-code {
    grid-column: 1;
  }

  .catalog-title {
    grid-column: 1;
  }

  .catalog-title h1 {
    font-size: clamp(42px, 15vw, 64px);
  }

  .catalog-stat {
    grid-column: 1;
  }

  .hero-links {
    position: static;
    grid-column: 1;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 18px;
    transform: none;
    flex-direction: row;
  }

  .layout {
    display: block;
    padding: 0 20px 70px;
  }

  .player-overlay {
    padding: 16px;
  }

  .player-shell {
    width: 100%;
    max-height: calc(100vh - 32px);
  }

  .player-head {
    padding: 16px;
  }

  aside {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
    padding: 24px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-group > div {
    display: flex;
    gap: 12px;
    overflow: auto;
    padding-left: 0;
  }

  .nav-group > div button {
    width: auto;
    min-width: max-content;
  }

  main {
    padding-inline: 16px;
  }

  .grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .visual {
    height: auto;
  }

  .toolbar input {
    width: 100%;
  }

  footer {
    grid-template-columns: 1fr auto;
    padding: 24px 20px;
  }

  footer span:nth-child(2) {
    display: none;
  }
}

@media (max-width: 620px) {
  .stack-category-heading {
    margin-top: 28px;
  }

  .stack-category-heading h2 {
    font-size: 22px;
  }

  .project-stack-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 24px;
  }

  .project-stack-label {
    padding-top: 2px;
  }

  .project-stack-row.is-open .stack-cards {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .stack-collapse-control {
    right: 16px;
    bottom: 16px;
    width: 54px;
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .visual img,
  .stack-cards > .work-card:first-child {
    transition: none;
  }

  .project-stack-row.is-stackable:not(.is-open):hover .stack-cards > .work-card:first-child {
    transform: none;
  }
}

/* Tertiary groups use the saved manager order while the public page stays folded by default. */
.project-stack-row.is-open .stack-cards > .work-card {
  animation: tertiary-card-expand 0.34s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.project-stack-row.is-open .stack-cards > .work-card:nth-child(2) { animation-delay: 0.025s; }
.project-stack-row.is-open .stack-cards > .work-card:nth-child(3) { animation-delay: 0.05s; }
.project-stack-row.is-open .stack-cards > .work-card:nth-child(4) { animation-delay: 0.075s; }

.project-stack-row.is-closing .stack-cards {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 18px;
  padding: 0;
}

.project-stack-row.is-closing .stack-cards > .work-card {
  position: relative;
  inset: auto;
  z-index: auto;
  display: block;
  pointer-events: none;
  opacity: 1;
  background: transparent;
  transform: none;
  animation: tertiary-card-collapse 0.24s ease both;
}

.project-stack-row.is-closing .stack-cards > .work-card .copy { visibility: visible; }

@keyframes tertiary-card-expand {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes tertiary-card-collapse {
  from { opacity: 1; transform: none; }
  to { opacity: 0.86; transform: translateY(-4px) scale(0.99); }
}

@media (max-width: 900px) {
  .project-stack-row.is-closing .stack-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .project-stack-row.is-closing .stack-cards { grid-template-columns: 1fr; gap: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .project-stack-row.is-open .stack-cards > .work-card,
  .project-stack-row.is-closing .stack-cards > .work-card { animation: none; }
}

/* Works directly attached to a second-level category stay expanded. */
.project-stack-row.direct-section {
  grid-template-columns: 1fr;
}

.project-stack-row.direct-section .stack-cards {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 34px 18px;
  padding: 0;
}

.project-stack-row.direct-section .stack-cards > .work-card {
  position: relative;
  inset: auto;
  z-index: auto;
  display: block;
  pointer-events: auto;
  opacity: 1;
  background: transparent;
  transform: none;
}

.project-stack-row.direct-section .stack-cards > .work-card .copy {
  visibility: visible;
}

@media (max-width: 900px) {
  .project-stack-row.direct-section .stack-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .project-stack-row.direct-section .stack-cards { grid-template-columns: 1fr; gap: 22px; }
}
