:root {
  color-scheme: dark;
  --bg: #111111;
  --ink: #f2f2ee;
  --text-soft: #c9c9c4;
  --muted: #a3a3a0;
  --line: #2a2a2a;
  --line-strong: #55554f;
  --tile: #1c1c1c;
  --accent: #c8ff3d;
  --gutter: clamp(20px, 5vw, 64px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-curtain: cubic-bezier(0.76, 0, 0.24, 1);
  --serif: "Noto Serif KR", serif;
  --serif-scale: 1;
  --display-lh: 1.38;
  --prose-lh: 1.75;
}

/* Cormorant has a small x-height, so English display text runs larger and tighter. */
html[lang="en"] {
  --serif: "Cormorant Garamond", "Noto Serif KR", serif;
  --serif-scale: 1.18;
  --display-lh: 1.1;
  --prose-lh: 1.35;
}

html[lang="ko"] [lang="en"],
html[lang="en"] [lang="ko"] {
  display: none;
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  word-break: keep-all;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.2s, text-decoration-color 0.2s;
}

a:hover {
  text-decoration-color: var(--accent);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::selection {
  background: var(--accent);
  color: #111111;
}

img {
  display: block;
  max-width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Cover: same paper and type as the page, lifted away like a curtain */

.cover {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: var(--gutter);
  background: var(--bg);
  color: var(--ink);
  text-align: center;
  transition: transform 1s var(--ease-curtain), box-shadow 1s;
}

.show-cover .cover,
.cover.is-leaving {
  display: flex;
}

.cover.is-leaving {
  transform: translateY(-100%);
  box-shadow: 0 1px 0 var(--line);
}

.show-cover body,
.cover-lifting body {
  overflow: hidden;
}

.cover-name {
  margin: 0;
  overflow: hidden;
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * clamp(6rem, 24vw, 15rem));
  font-weight: 300;
  line-height: 1.1;
  /* room for the "y" descender inside the clipping box */
  padding-bottom: 0.12em;
}

.cover-name span {
  display: inline-block;
  animation: rise 1.2s var(--ease-out) 0.15s both;
}

.cover-line {
  width: min(320px, 60vw);
  height: 1px;
  background: var(--line-strong);
  animation: draw 1.1s var(--ease-out) 0.6s both;
}

.cover-text {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  letter-spacing: 0.02em;
  animation: fade-up 0.9s var(--ease-out) 0.9s both;
}

/* Styled like the page's other text links. */
.cover-enter {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  animation: fade-up 0.9s var(--ease-out) 1.15s both;
  transition: text-decoration-color 0.2s;
}

.cover-enter:hover {
  text-decoration-color: var(--accent);
}

@keyframes rise {
  from { transform: translateY(120%); }
}

@keyframes draw {
  from { transform: scaleX(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
}

/* Header */

/* Sits over the hero so the hero can fill exactly one screen whatever the header's height. */
.site-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 32px;
  min-height: 72px;
  padding: 0 var(--gutter);
}

.logo {
  color: var(--muted);
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * 1.6rem);
  font-weight: 300;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 28px;
  margin-left: auto;
  font-size: 0.95rem;
}

.nav-links a,
.lang-button {
  color: var(--muted);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active,
.lang-button:hover,
.lang-button.active {
  color: var(--ink);
}

.language-switcher {
  display: flex;
}

.lang-button {
  min-height: 40px;
  padding: 0 6px;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.lang-button + .lang-button::before {
  content: "/";
  margin-right: 12px;
  color: var(--line-strong);
}

/* Hero */

/* One full screen: nothing from the projects peeks in, the arrow points the way down. */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 120px var(--gutter) 140px;
  text-align: center;
}

.hero h1 {
  max-width: 15em;
  margin: 0 auto 28px;
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * clamp(2rem, 4.6vw, 3.75rem));
  font-weight: 300;
  line-height: var(--display-lh);
  letter-spacing: -0.015em;
}

.hero h1 a {
  text-decoration-color: var(--accent);
}

.hero-text {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-link {
  display: inline-block;
}

/* Hero lines use the scroll reveal below, one after another. */
.hero > .reveal:nth-child(2) {
  transition-delay: 0.15s;
}

.hero > .reveal:nth-child(3) {
  transition-delay: 0.3s;
}

.scroll-cue {
  position: absolute;
  bottom: clamp(24px, 5vh, 48px);
  left: 50%;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 300;
  text-decoration: none;
  animation: fade-up 0.9s var(--ease-out) 0.6s both, nudge 2.4s ease-in-out 1.5s infinite;
}

.scroll-cue:hover {
  color: var(--accent);
}

.show-cover .scroll-cue {
  animation-play-state: paused;
}

@keyframes nudge {
  50% { transform: translateY(8px); }
}

/* Sections */

.section {
  padding: clamp(80px, 11vw, 160px) var(--gutter);
}

.section h2 {
  margin-bottom: clamp(48px, 7vw, 96px);
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * clamp(1.75rem, 3vw, 2.5rem));
  font-weight: 300;
  line-height: 1.2;
}


/* Projects: one per row, alternating sides and widths */

/* A flex column, not a grid: grid auto-placement would pack two narrow items into one row. */
.project-list {
  display: flex;
  flex-direction: column;
  gap: clamp(96px, 12vw, 176px);
}

.project:nth-child(6n + 1) { width: 50%; margin-left: 50%; }
.project:nth-child(6n + 2) { width: 58%; }
.project:nth-child(6n + 3) { width: 50%; margin-left: 42%; }
.project:nth-child(6n + 4) { width: 42%; margin-left: 8%; }
.project:nth-child(6n + 5) { width: 58%; margin-left: 42%; }
.project:nth-child(6n + 6) { width: 50%; }

.project-media {
  margin: 0 0 28px;
  background: var(--tile);
}

/* Phone screenshots sit side by side, one column per visible image. */
.media-phone {
  display: grid;
  grid-auto-columns: minmax(0, 200px);
  grid-auto-flow: column;
  justify-content: center;
  gap: clamp(10px, 2vw, 20px);
  padding: clamp(24px, 4vw, 48px) clamp(16px, 3vw, 40px);
}

.media-phone img {
  width: 100%;
  height: auto;
  box-shadow: 0 14px 32px rgb(0 0 0 / 0.45);
}

/* Reveal uses `translate`, parallax `transform`, hover `scale`, so the three motions stack. */
@media (hover: hover) {
  .media-phone img,
  .media-gallery img {
    transition: scale 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out);
  }

  .media-phone img:hover,
  .media-gallery img:hover {
    scale: 1.04;
    box-shadow: 0 24px 48px rgb(0 0 0 / 0.6);
  }

  .media-gallery img:hover {
    scale: 1.02;
  }
}

.media-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: none;
}

.media-gallery img {
  width: 100%;
  height: auto;
  outline: 1px solid var(--line);
}

.media-gallery .wide {
  grid-column: 1 / -1;
}

.media-stats {
  display: flex;
  justify-content: center;
  gap: clamp(40px, 8vw, 96px);
  padding: clamp(48px, 8vw, 96px) 24px;
}

.media-stats p {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.media-stats strong {
  display: block;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * clamp(3.5rem, 7vw, 5.5rem));
  font-weight: 300;
  line-height: 1.1;
}

.project h3 {
  margin-bottom: 4px;
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * clamp(1.6rem, 2.4vw, 2.1rem));
  font-weight: 300;
  line-height: 1.25;
}

.project-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

.project-title h3 {
  margin-bottom: 0;
}

/* App icons keep the platform's rounded mask; everything else on the page stays square. */
.app-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 22%;
  box-shadow: 0 0 0 1px var(--line);
}

.project-meta {
  margin-bottom: 18px;
  color: var(--accent);
  font-size: 0.9rem;
}

.project > p:not(.project-meta) {
  color: var(--text-soft);
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
}

.project-tags li:not(:last-child)::after {
  content: ",\00a0";
}

.project-links {
  display: flex;
  gap: 20px;
}

.issues {
  margin-top: 32px;
}

.issues h4 {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.issues details {
  border-top: 1px solid var(--line);
}

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

.issues summary {
  position: relative;
  padding: 14px 32px 14px 0;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
}

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

.issues summary::after {
  content: "+";
  position: absolute;
  top: 12px;
  right: 2px;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 300;
}

.issues details[open] summary::after {
  content: "\2212";
}

.issues dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0 0 20px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.issues dt {
  color: var(--ink);
  font-weight: 600;
}

.issues dd {
  margin: 0;
}

/* About and contact: centered serif prose */

.about,
.contact {
  text-align: center;
}

.prose {
  max-width: 30em;
  margin: 0 auto 1.4em;
  font-family: var(--serif);
  font-size: calc(var(--serif-scale) * clamp(1.3rem, 2.2vw, 1.85rem));
  font-weight: 300;
  line-height: var(--prose-lh);
}

.skills {
  margin-top: clamp(64px, 8vw, 112px);
}

.skills h3 {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.skills dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  max-width: 900px;
  margin: 0 auto;
}

.skills dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.skills dd {
  margin: 0;
}

.contact {
  padding-bottom: clamp(120px, 16vw, 200px);
}

.footer {
  padding: 32px var(--gutter);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.footer p {
  margin: 0;
}

/* Scroll reveal, replayed every time an element comes back into view.
   Classes are added by script.js, so nothing is hidden without JS. */

.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}

/* Left through the top of the screen: come back down from above when scrolling up. */
.reveal[data-from="top"] {
  transform: translateY(-40px);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.reveal .media-phone img {
  opacity: 0;
  translate: 0 32px;
  transition: opacity 0.9s var(--ease-out), translate 0.9s var(--ease-out), scale 0.5s var(--ease-out),
    box-shadow 0.5s var(--ease-out);
  transition-delay: calc(0.2s + var(--i, 0) * 0.12s), calc(0.2s + var(--i, 0) * 0.12s), 0s, 0s;
}

.reveal.is-visible .media-phone img {
  opacity: 1;
  translate: none;
}

/* 1. Reading progress along the top edge, driven by scroll (hidden where unsupported). */
.scroll-progress {
  display: none;
}

@supports (animation-timeline: scroll()) {
  .scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    display: block;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform-origin: 0 50%;
    animation: progress linear both;
    animation-timeline: scroll(root);
  }
}

@keyframes progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* 2. Phone screenshots drift a little slower than the page while they pass through view. */
@supports (animation-timeline: view()) {
  .media-phone img {
    animation: parallax linear both;
    animation-timeline: view();
  }
}

@keyframes parallax {
  from { transform: translateY(28px); }
  to { transform: translateY(-28px); }
}

/* Troubleshooting panels slide open where ::details-content is supported, and snap elsewhere. */
:root {
  interpolate-size: allow-keywords;
}

.issues details::details-content {
  height: 0;
  overflow: hidden;
  transition: height 0.45s var(--ease-out), content-visibility 0.45s allow-discrete;
}

.issues details[open]::details-content {
  height: auto;
}

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

  .media-phone img {
    animation: none !important;
  }
}

@media (max-width: 860px) {
  .project-list > .project {
    width: auto;
    margin-left: 0;
  }

  .skills dl {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    row-gap: 0;
    padding-top: 12px;
  }

  .language-switcher {
    margin-left: auto;
  }

  .nav-links {
    order: 3;
    width: 100%;
    margin-left: 0;
    gap: 20px;
    padding-bottom: 8px;
  }

  .media-gallery {
    grid-template-columns: 1fr;
  }

  .issues dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .issues dd {
    margin-bottom: 8px;
  }
}
