/*
 * YE JUN Portfolio v13 — "Topology Installation" shell.
 * Layered on top of portfolio.css (which keeps the v11–v12.5 typography, line-breaking and
 * text-zoom rules). Only pages whose <html> carries the .v13 class load this file.
 *
 * Text never depends on the canvas: every text block sits on an opaque-enough panel, so the
 * contrast holds over the brightest geometry because the dark green panel remains opaque enough.
 */

html.v13 {
  color-scheme: dark;
  --paper: #07100c;
  --paper-deep: #10251a;
  --ink: #e8f0e9;
  --muted: #a5b9aa;
  --line: rgba(82, 185, 128, 0.2);
  --line-dark: rgba(82, 185, 128, 0.46);
  --accent: #52b980;
  --accent-bright: #83e3aa;
  --accent-geo: #00e83f;
  --dark: #030705;
  --dark-muted: #aebeb3;
  --panel: rgba(7, 20, 12, 0.9);
  --panel-edge: rgba(82, 185, 128, 0.22);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --stage: 100svh;
  background: var(--paper);
}

html.v13 body {
  background: transparent;
}

html.v13 ::selection {
  background: var(--accent-geo);
  color: #fff;
}

/* Initial #hash navigation jumps instead of animating: a long smooth scroll computes its end point
   before web fonts swap, so the target would drift by the swap delta. In-page links become smooth
   once the page has settled (v13-ui.js adds .v13-ready after load + fonts). */
html.v13 {
  scroll-behavior: auto;
}

html.v13.v13-ready {
  scroll-behavior: smooth;
}

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

/* ------------------------------------------------------------------ stage layers */

.v13-backdrop,
.v13-scene {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  pointer-events: none;
}

.v13-backdrop {
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 70% 40%, rgba(82, 185, 128, 0.1), transparent 70%),
    linear-gradient(180deg, #07100c 0%, #0b1b12 58%, #10251a 100%);
  transition: opacity 900ms ease;
}

/* Static fallback (no JavaScript / no WebGL): a drafting floor in perspective. */
.v13-backdrop::after {
  position: absolute;
  right: -50%;
  bottom: -12%;
  left: -50%;
  height: 62%;
  background-image:
    linear-gradient(rgba(82, 185, 128, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 185, 128, 0.13) 1px, transparent 1px);
  background-size: 64px 64px;
  content: "";
  transform: perspective(520px) rotateX(64deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, #000 8%, transparent 86%);
  mask-image: linear-gradient(to top, #000 8%, transparent 86%);
}

.v13-scene {
  display: block;
  opacity: 0;
  transition: opacity 1100ms ease;
}

html.scene-live .v13-scene {
  opacity: 1;
}

html.scene-live .v13-backdrop {
  opacity: 0;
}

html.scene-live.scene-still .v13-scene {
  opacity: 0.86;
}

html.v13 .site-header,
html.v13 main,
html.v13 .site-footer {
  position: relative;
}

html.v13 main {
  z-index: 1;
}

html.v13 .site-footer {
  z-index: 1;
}

/* ------------------------------------------------------------------ header */

html.v13 .site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 16, 12, 0.94), rgba(7, 16, 12, 0.72));
}

html.v13 .identity strong {
  letter-spacing: 0.2em;
}

html.v13 .lang-switch {
  border-color: var(--line-dark);
}

html.v13 .lang-switch:hover {
  border-color: var(--accent);
}

html.v13 .header-contact {
  min-width: 44px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  padding-inline: 8px;
  border: 1px solid var(--accent);
  color: var(--ink);
  text-decoration: none;
  font: 700 11px/1 var(--label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html.v13 .header-contact:hover,
html.v13 .header-contact:focus-visible {
  background: var(--accent);
  color: var(--dark);
}

/* ------------------------------------------------------------------ shared pieces */

html.v13 .panel {
  position: relative;
  border: 1px solid var(--panel-edge);
  background:
    linear-gradient(var(--accent-geo), var(--accent-geo)) left top / 18px 2px no-repeat,
    linear-gradient(var(--accent-geo), var(--accent-geo)) left top / 2px 18px no-repeat,
    var(--panel);
  transition: background-size 420ms cubic-bezier(0.2, 0.7, 0.2, 1), border-color 320ms ease;
}

html.v13 .is-active .panel,
html.v13 .panel.is-active {
  border-color: rgba(82, 185, 128, 0.34);
  background-size: 42px 2px, 2px 42px, auto;
}

html.v13 .eyebrow::before {
  width: 26px;
  height: 1px;
}

.specimen {
  display: grid;
  gap: 2px;
  margin: 0;
  color: rgba(232, 240, 233, 0.72);
  font: 500 12px/1.5 var(--mono);
  letter-spacing: 0.02em;
  text-transform: none;
  pointer-events: none;
}

.specimen > span:first-child {
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html.v13 .section {
  border-top: 0;
}

html.v13 .section-heading p {
  color: var(--muted);
}

html.v13 .hero-note {
  color: var(--muted);
  border-top-color: var(--line-dark);
}

html.v13 .fact-list,
html.v13 .practice-grid,
html.v13 .work-list,
html.v13 .statement-list,
html.v13 .case-facts {
  border-top-color: var(--line-dark);
}

html.v13 img {
  background: #0c1a11;
}

/* ------------------------------------------------------------------ home: hero */

.v13-hero {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: calc(var(--stage) - 89px);
}

.hero-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(28px, 5vw, 80px);
  align-items: start;
  padding-block: clamp(40px, 6vw, 88px) clamp(24px, 3vw, 40px);
}

html.v13 .hero-copy .home-title {
  margin: 24px 0 28px;
  text-shadow: 0 2px 28px rgba(7, 16, 12, 0.6);
}

html.v13 .hero-copy .lead {
  max-width: 30em;
  font-size: clamp(17px, 1.45vw, 21px);
  color: #d4e2d7;
  text-shadow: 0 1px 18px rgba(7, 16, 12, 0.85);
}

html.v13 .role-line {
  color: var(--ink);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  margin-top: 32px;
}

html.v13 .hero-cta {
  margin-top: 0;
  border-color: var(--ink);
  background: rgba(7, 16, 12, 0.6);
}

html.v13 .hero-cta:hover {
  background: var(--ink);
  color: var(--paper);
}

.hero-mail {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 100%;
  color: var(--ink);
  font: 500 15px/1.4 var(--mono);
  text-decoration-color: var(--accent);
  overflow-wrap: anywhere;
}

/* The real photograph is a small evidence plate leaning in front of the generated lattice. */
html.v13 .hero-visual {
  z-index: 1;
  align-self: end;
  justify-self: end;
  width: min(100%, 10.5rem);
  margin-bottom: clamp(0px, 2vw, 24px);
}

html.v13 .hero-visual::before {
  top: -14px;
  right: -14px;
  border-color: var(--accent-geo);
}

html.v13 .hero-visual img {
  aspect-ratio: 4 / 5;
  filter: saturate(0.78) contrast(1.04);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

html.v13 .hero-caption {
  padding: 10px 0 8px;
  border-bottom-color: var(--line-dark);
  color: var(--muted);
  font-size: 10.5px;
}

.specimen-hero {
  position: absolute;
  right: 0;
  top: clamp(40px, 6vw, 88px);
  text-align: right;
}

.hero-index {
  position: relative;
  padding-bottom: clamp(20px, 3vw, 36px);
}

.hero-index ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-dark);
}

.hero-index li {
  min-width: 0;
}

.hero-index li + li {
  border-left: 1px solid var(--line);
}

.hero-index a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 64px;
  height: 100%;
  padding: 16px 18px 16px 0;
  color: var(--ink);
  font: 600 15px/1.35 var(--label);
  letter-spacing: 0.04em;
  text-decoration: none;
  background: linear-gradient(90deg, rgba(82, 185, 128, 0.18), rgba(82, 185, 128, 0)) left / 0 100% no-repeat;
  transition: background-size 320ms ease, color 200ms ease;
}

.hero-index li + li a {
  padding-left: 18px;
}

.hero-index a:hover,
.hero-index a:focus-visible {
  background-size: 100% 100%;
}

.index-no {
  flex: 0 0 auto;
  color: var(--accent);
  font: 500 12px/1 var(--mono);
}

/* ------------------------------------------------------------------ home: work */

.v13-work {
  padding-bottom: 0;
}

html.v13 .work-intro .section-heading {
  margin-bottom: 0;
  padding: clamp(24px, 3vw, 44px);
}

html.v13 .work-list {
  border-top: 0;
}

.work-station {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--stage);
  padding-block: clamp(48px, 9vh, 120px);
}

.work-station > .shell {
  position: relative;
  width: min(100%, var(--max));
}

html.v13 .work-row {
  isolation: isolate;
  width: min(100%, 36rem);
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 20px 16px;
  align-items: start;
  min-height: 0;
  padding: clamp(22px, 2.4vw, 34px);
  border-bottom: 1px solid var(--panel-edge);
}

html.v13 .work-row > * {
  min-width: 0;
}

html.v13 .work-row::after {
  background: rgba(15, 31, 21, 0.96);
}

html.v13 .work-row .work-number {
  grid-column: 1;
  padding-top: 2px;
  font: 500 13px/1.4 var(--mono);
  letter-spacing: 0.04em;
}

html.v13 .work-row .work-title {
  grid-column: 2;
}

html.v13 .work-row .work-image,
html.v13 .work-row .work-meta {
  grid-column: 1 / -1;
}

html.v13 .work-title h3 {
  font-size: clamp(30px, 3vw, 46px);
}

html.v13 .work-image {
  background: #0c1a11;
}

html.v13 .work-image-tall img {
  object-position: 50% 28%;
}

html.v13 .work-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.work-station:nth-child(even) .work-row {
  margin-left: auto;
}

.work-station .specimen {
  position: absolute;
  right: var(--gutter);
  bottom: calc(-1 * clamp(24px, 6vh, 64px));
  text-align: right;
}

.work-station:nth-child(even) .specimen {
  right: auto;
  left: var(--gutter);
  text-align: left;
}

/* ------------------------------------------------------------------ home: practice, profile, notes */

.v13-practice,
.v13-profile,
.v13-notes {
  padding-block: clamp(96px, 16vh, 200px);
}

html.v13 .v13-practice .section-heading,
html.v13 .v13-notes .section-heading {
  padding: clamp(24px, 3vw, 44px);
}

html.v13 .practice-grid {
  gap: clamp(14px, 1.6vw, 24px);
  margin-top: clamp(14px, 1.6vw, 24px);
  border-top: 0;
}

html.v13 .practice-item,
html.v13 .practice-item + .practice-item {
  min-height: 0;
  padding: clamp(22px, 2.6vw, 38px);
  border-left: 1px solid var(--panel-edge);
}

html.v13 .practice-item .work-number {
  margin-bottom: clamp(28px, 4vw, 56px);
}

html.v13 .profile-grid {
  padding: clamp(24px, 3.4vw, 52px);
}

html.v13 .notes-panel {
  padding: clamp(24px, 3vw, 44px);
}

html.v13 .notes-panel .section-heading {
  margin-bottom: clamp(24px, 3vw, 44px);
  padding: 0;
}

html.v13 .contact-band {
  background: transparent;
  color: var(--ink);
}

html.v13 .contact-band .shell {
  padding-block: clamp(96px, 14vh, 180px) clamp(64px, 10vh, 120px);
}

html.v13 .contact-inner {
  min-height: 0;
  padding: clamp(28px, 4vw, 64px);
}

html.v13 .contact-copy {
  border-top-color: var(--line-dark);
}

html.v13 .contact-copy strong {
  color: var(--ink);
}

html.v13 .site-footer {
  border-top: 1px solid var(--line);
  background: rgba(3, 7, 5, 0.94);
}

html.v13 .footer-inner strong {
  color: var(--ink);
}

/* ------------------------------------------------------------------ station rail */

.v13-rail {
  position: fixed;
  top: 50%;
  right: 12px;
  z-index: 5;
  display: none;
  margin: 0;
  padding: 0;
  list-style: none;
  color: rgba(232, 240, 233, 0.4);
  font: 500 10px/1 var(--mono);
  letter-spacing: 0.06em;
  pointer-events: none;
  transform: translateY(-50%);
}

.v13-rail li {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 22px;
  font-size: 0;
}

.v13-rail li span {
  font-size: 10px;
}

.v13-rail li::after {
  width: 8px;
  height: 1px;
  background: currentColor;
  content: "";
  transition: width 320ms ease, background-color 320ms ease;
}

.v13-rail li.is-active {
  color: var(--ink);
}

.v13-rail li.is-active::after {
  width: 18px;
  background: var(--accent-geo);
}

@media (min-width: 65.625em) and (min-height: 37.5em) {
  html.js .v13-rail {
    display: block;
  }
}

/* ------------------------------------------------------------------ case page */

html.v13 .v13-case-hero {
  position: relative;
}

html.v13 .v13-case-hero .case-hero-top {
  grid-template-columns: minmax(0, 1fr);
  width: min(100%, 46rem);
  padding: clamp(24px, 3vw, 44px);
}

html.v13 .case-title .subtitle {
  color: #cbd9ce;
}

html.v13 .case-facts .fact {
  border-bottom-color: var(--line);
}

.case-model-note {
  max-width: 34em;
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.case-stage-gap {
  height: clamp(120px, 34vh, 360px);
}

html.v13 .case-cover {
  border-color: var(--panel-edge);
  background: var(--panel);
}

html.v13 .case-section {
  border-top: 0;
}

html.v13 .case-section-grid {
  padding: clamp(24px, 3vw, 44px);
}

html.v13 .gallery-item {
  padding: 12px;
}

html.v13 .metric-band {
  background: transparent;
  color: var(--ink);
}

html.v13 .metric-grid {
  padding: clamp(18px, 2.4vw, 32px);
  border-top: 0;
}

html.v13 .metric,
html.v13 .metric + .metric {
  border-color: var(--line);
}

html.v13 .metric strong {
  color: var(--ink);
}

/* Scrollytelling steps: each rule is one stop of the camera around the same vessel.
   The steps sit in the left column with no backdrop, so the vessel stays visible on the right. */
html.v13 .v13-steps-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding-block: 0;
}

html.v13 .v13-steps-grid > div:first-child {
  width: fit-content;
  padding: 10px 14px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
}

html.v13 .v13-steps {
  border-top: 0;
}

html.v13 .v13-steps li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  min-height: 72vh;
  padding: 0;
  border-bottom: 0;
}

html.v13 .v13-steps li > div.step-card {
  display: grid;
  grid-template-columns: 3.625rem minmax(0, 1fr);
  gap: 18px;
  width: min(100%, 30rem);
  padding: clamp(20px, 2.4vw, 32px);
}

html.v13 .v13-steps strong {
  font: 500 clamp(26px, 2.6vw, 38px)/1.1 var(--serif);
}

html.v13 .v13-steps p {
  font-size: 15px;
}

html.v13 .case-next {
  border-top-color: var(--line-dark);
}

/* ------------------------------------------------------------------ medium */

@media (max-width: 65.625em) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  }

  html.v13 .work-row {
    width: min(100%, 32rem);
  }

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

  .hero-index li:nth-child(3) {
    border-left: 0;
  }

  .hero-index li:nth-child(3) a {
    padding-left: 0;
  }

  .hero-index li:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

/* ------------------------------------------------------------------ compact (same em breakpoint as the scene) */

@media (max-width: 48.75em) {
  html.v13 {
    --stage: 100svh;
  }

  html.v13 .header-inner {
    gap: 12px;
  }

  html.v13 .header-actions {
    gap: 4px;
  }

  html.js.v13 .header-contact {
    display: inline-flex;
  }

  .v13-hero {
    min-height: 0;
  }

  /* The first screen opens on a stage band where the generated lattice stands; the copy then
     slides over it like a curtain (opaque enough to keep the text contrast on any frame). */
  /* The band height never depends on scene state: a late class change would move every anchor
     below it after the browser has already scrolled to an initial #hash. */
  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding-top: clamp(180px, 33svh, 300px);
  }

  html.v13 .hero-copy {
    margin: 0 calc(-1 * var(--gutter));
    padding: 24px var(--gutter) 28px;
    background: linear-gradient(180deg, rgba(7, 16, 12, 0) 0, rgba(7, 16, 12, 0.9) 24px, rgba(7, 16, 12, 0.92) 100%);
  }

  html.v13 .hero-visual {
    justify-self: end;
    width: min(48%, 13rem);
    margin: 0;
  }

  .hero-index ol {
    background: var(--panel);
  }

  .specimen-hero {
    top: clamp(16px, 4svh, 40px);
    right: var(--gutter);
    text-align: right;
  }

  .work-station {
    display: block;
    min-height: 0;
    padding-block: clamp(240px, 44svh, 420px) 32px;
  }

  html.v13 .work-row,
  .work-station:nth-child(even) .work-row {
    width: 100%;
    margin-left: 0;
  }

  .work-station .specimen,
  .work-station:nth-child(even) .specimen {
    top: calc(-1 * clamp(240px, 44svh, 420px) + 24px);
    right: auto;
    bottom: auto;
    left: var(--gutter);
    text-align: left;
  }

  .v13-practice,
  .v13-profile,
  .v13-notes {
    padding-block: clamp(120px, 30svh, 260px) 0;
  }

  html.v13 .contact-band .shell {
    padding-block: clamp(160px, 36svh, 320px) 56px;
  }

  html.v13 .v13-case-hero .case-hero-top {
    width: 100%;
  }

  .case-stage-gap {
    height: clamp(220px, 44svh, 400px);
  }

  html.v13 .v13-steps li {
    min-height: 0;
    padding-top: clamp(200px, 40svh, 360px);
  }

  html.v13 .v13-steps li > div.step-card {
    width: 100%;
  }
}

@media (max-width: 30em) {
  .hero-actions {
    gap: 8px 20px;
    margin-top: 24px;
  }

  .hero-mail {
    font-size: 14px;
  }

  html.v13 .hero-visual {
    width: min(62%, 14rem);
  }

  html.v13 .work-row {
    grid-template-columns: 2.5rem minmax(0, 1fr);
    gap: 16px 10px;
    padding: 20px;
  }

  html.v13 .work-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-index ol {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-index li + li,
  .hero-index li:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .hero-index li + li a,
  .hero-index li:nth-child(3) a {
    padding-left: 0;
  }

  .hero-index a {
    min-height: 52px;
    padding-block: 14px;
  }

  html.v13 .practice-item,
  html.v13 .practice-item + .practice-item {
    padding: 22px;
  }

  html.v13 .v13-steps li > div.step-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
}

/* Text-only zoom extremes (em follows the text size) — keep the same single-column rules as v12.5. */
@media (max-width: 15em) {
  html.v13 .header-contact,
  html.v13 .lang-switch,
  html.v13 .menu-toggle {
    min-width: 44px;
    padding-inline: 3px;
    font-size: 0.5rem;
    letter-spacing: 0.02em;
  }

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

  html.v13 .hero-visual {
    width: 100%;
  }

  html.v13 .work-row {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
  }

  html.v13 .work-row .work-number,
  html.v13 .work-row .work-title {
    grid-column: 1;
  }

  html.v13 .work-title h3 {
    font-size: 1.25rem;
  }

  .hero-index a {
    font-size: 0.75rem;
  }

  .hero-mail {
    font-size: 0.6875rem;
  }

  .specimen {
    display: none;
  }

  html.v13 .panel,
  html.v13 .work-intro .section-heading,
  html.v13 .profile-grid,
  html.v13 .notes-panel,
  html.v13 .contact-inner,
  html.v13 .case-section-grid,
  html.v13 .v13-case-hero .case-hero-top {
    padding: 14px;
  }
}

/* ------------------------------------------------------------------ reduced motion */

@media (prefers-reduced-motion: reduce) {
  html.v13 .panel,
  .hero-index a,
  .v13-rail li::after,
  .v13-scene,
  .v13-backdrop {
    transition: none;
  }
}

@media print {
  .v13-scene,
  .v13-backdrop,
  .v13-rail,
  .specimen {
    display: none !important;
  }

  html.v13,
  html.v13 body {
    background: #fff;
  }

  html.v13 .panel {
    border-color: #999;
    background: #fff;
    color: #000;
  }
}
