/* ============================================================
   Sunghoon Baek — Portfolio Stylesheet
   Warm, engineering-grade aesthetic shared with oh-my-field.
   Light / dark theming, fluid type, motion on scroll.
   ============================================================ */

/* ---------- TOKENS ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f3ef;
  --surface: #f9f8f5;
  --surface-2: #ffffff;
  --surface-offset: #edeae5;
  --surface-dynamic: #e3e0da;
  --divider: #dcd9d5;
  --border: #ccc9c2;

  --ink: #1a1917;
  --muted: #63615c;
  --faint: #a3a19a;
  --inverse: #f9f8f4;

  --primary: #0f7a76;
  --primary-hover: #0a5a57;
  --primary-soft: #d8ebe7;
  --primary-line: rgb(15 122 118 / 0.32);

  --coral: #c25435;
  --coral-soft: #f1ddd2;
  --amber: #a9750f;
  --amber-soft: #f0e6c8;
  --blue: #0c5fa0;
  --blue-soft: #cfdef0;
  --green: #2f6f3f;
  --green-soft: #d3e3cf;

  /* Image / diagram backings stay light in both themes */
  --img-surface: #f8f7f3;
  --img-border: #e3e0d9;
  --code-bg: #1c1b19;
  --code-ink: #e9efe9;

  --shadow-sm: 0 1px 2px rgb(20 18 14 / 0.06);
  --shadow-md: 0 6px 20px rgb(20 18 14 / 0.09);
  --shadow-lg: 0 18px 44px rgb(20 18 14 / 0.14);

  --radius-sm: 0.375rem;
  --radius: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --radius-full: 9999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t: 220ms var(--ease);

  --font-sans: "DM Sans", "Pretendard Variable", Pretendard, -apple-system,
    BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Moderate, fluid type scale — display caps near 2.85rem so the
     gap between the largest and smallest text stays readable. */
  --fs-display: clamp(2rem, 1.42rem + 2vw, 2.85rem);
  --fs-h1: clamp(1.85rem, 1.4rem + 1.6vw, 2.55rem);
  --fs-h2: clamp(1.5rem, 1.28rem + 0.95vw, 1.95rem);
  --fs-h3: clamp(1.12rem, 1.05rem + 0.3vw, 1.28rem);
  --fs-lead: clamp(1.04rem, 0.99rem + 0.28vw, 1.18rem);
  --fs-body: 1.0rem;
  --fs-sm: 0.92rem;
  --fs-xs: 0.8rem;

  --max: 1120px;
  --nav-h: 66px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e0d0c;
  --surface: #161513;
  --surface-2: #1b1a18;
  --surface-offset: #1f1d1b;
  --surface-dynamic: #272522;
  --divider: #242220;
  --border: #322f2c;

  --ink: #e4e2de;
  --muted: #9a9792;
  --faint: #5b5853;
  --inverse: #1a1917;

  --primary: #2fa3ac;
  --primary-hover: #45b6bd;
  --primary-soft: #173033;
  --primary-line: rgb(47 163 172 / 0.4);

  --coral: #e07a52;
  --coral-soft: #36231a;
  --amber: #e0ad3a;
  --amber-soft: #322a14;
  --blue: #5298d6;
  --blue-soft: #162434;
  --green: #6aa84f;
  --green-soft: #1b2c16;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 6px 20px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 18px 44px rgb(0 0 0 / 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0e0d0c;
    --surface: #161513;
    --surface-2: #1b1a18;
    --surface-offset: #1f1d1b;
    --surface-dynamic: #272522;
    --divider: #242220;
    --border: #322f2c;
    --ink: #e4e2de;
    --muted: #9a9792;
    --faint: #5b5853;
    --inverse: #1a1917;
    --primary: #2fa3ac;
    --primary-hover: #45b6bd;
    --primary-soft: #173033;
    --primary-line: rgb(47 163 172 / 0.4);
    --coral: #e07a52;
    --coral-soft: #36231a;
    --amber: #e0ad3a;
    --amber-soft: #322a14;
    --blue: #5298d6;
    --blue-soft: #162434;
    --green: #6aa84f;
    --green-soft: #1b2c16;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 6px 20px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 18px 44px rgb(0 0 0 / 0.55);
  }
}

/* ---------- RESET / BASE ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 12px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.65;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t), color var(--t);
}

/* Hide the non-active language */
html[data-site-lang="ko"] [data-lang="en"],
html[data-site-lang="en"] [data-lang="ko"] {
  display: none !important;
}

/* Korean reads tighter than the default tracking — pull it in. */
html[data-site-lang="ko"] body {
  letter-spacing: -0.022em;
}

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

a {
  color: inherit;
  text-decoration-color: var(--primary-line);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
  transition: color var(--t);
}

a:hover {
  color: var(--primary);
}

::selection {
  background: var(--primary-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ---------- TYPOGRAPHY ---------- */
h1,
h2,
h3 {
  letter-spacing: -0.022em;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.hero h1,
.page-hero h1,
.project-hero h1,
.resume-hero h1 {
  letter-spacing: -0.032em;
}

/* Korean headings tighten further */
html[data-site-lang="ko"] :is(h1, h2, h3) {
  letter-spacing: -0.04em;
}

html[data-site-lang="ko"] :is(.hero, .page-hero, .project-hero, .resume-hero) h1 {
  letter-spacing: -0.05em;
}

.eyebrow {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
}

.hero .eyebrow {
  color: var(--primary);
}

code {
  font-family: var(--font-mono);
}

/* Inline code inside copy */
p code,
li code {
  font-size: 0.86em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
}

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

/* ---------- LAYOUT ---------- */
.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 60;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius);
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

.section,
.page-hero,
.project-hero {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
}

.section {
  padding: clamp(56px, 8vw, 88px) 0;
}

.section.tight {
  padding-top: clamp(28px, 4vw, 40px);
}

/* ---------- HEADER / NAV ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--bg), transparent 12%);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  transition: background var(--t), border-color var(--t), box-shadow var(--t);
}

.site-header.scrolled {
  background: color-mix(in oklab, var(--bg), transparent 4%);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.nav {
  width: min(100% - 32px, var(--max));
  min-height: var(--nav-h);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: grid;
  gap: 1px;
  text-decoration: none;
  min-width: max-content;
}

.brand strong {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.brand span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-links > a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t), background var(--t);
}

.nav-links > a:hover {
  color: var(--ink);
  background: var(--surface-offset);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
  transition: transform 180ms var(--ease), background 180ms var(--ease);
}

.nav-toggle span {
  position: relative;
}

.nav-toggle span::before,
.nav-toggle span::after {
  position: absolute;
  content: "";
  left: 0;
}

.nav-toggle span::before {
  transform: translateY(-6px);
}

.nav-toggle span::after {
  transform: translateY(6px);
}

.site-header.nav-open .nav-toggle span {
  background: transparent;
}

.site-header.nav-open .nav-toggle span::before {
  transform: rotate(45deg);
}

.site-header.nav-open .nav-toggle span::after {
  transform: rotate(-45deg);
}

/* Segmented controls (language + theme) */
.lang-toggle {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.lang-toggle button {
  min-width: 40px;
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: color var(--t), background var(--t);
}

.lang-toggle button:hover {
  color: var(--ink);
}

html[data-site-lang="ko"] [data-set-lang="ko"],
html[data-site-lang="en"] [data-set-lang="en"] {
  background: var(--primary);
  color: #fff;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--t), border-color var(--t), background var(--t);
}

.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* ---------- BUTTONS ---------- */
.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--t), background var(--t), border-color var(--t),
    color var(--t), box-shadow var(--t);
}

.button:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button.secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.button.compact {
  min-height: 36px;
  padding: 8px 13px;
  font-size: 0.86rem;
}

/* ---------- HERO ---------- */
.hero {
  position: relative;
  min-height: min(86vh, 780px);
  display: grid;
  align-items: end;
  overflow: hidden;
  background:
    linear-gradient(104deg, rgb(7 11 17 / 0.82), rgb(9 14 20 / 0.55) 46%, rgb(9 14 20 / 0.2)),
    url("/assets/banner.png") center / cover no-repeat;
  color: #fff;
}

/* Faint engineering grid layered over the banner */
.hero-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgb(120 220 210 / 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(120 220 210 / 0.16) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 75% 65% at 28% 70%, #000 10%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 28% 70%, #000 10%, transparent 78%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  padding: clamp(96px, 14vh, 150px) 0 58px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 7px 13px;
  border: 1px solid rgb(180 240 226 / 0.34);
  border-radius: var(--radius-full);
  background: rgb(13 30 30 / 0.42);
  backdrop-filter: blur(6px);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: #c4f3e6;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4fd6bb;
  box-shadow: 0 0 0 0 rgb(79 214 187 / 0.6);
  animation: pulse-dot 2.4s var(--ease) infinite;
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgb(79 214 187 / 0.5);
  }
  50% {
    opacity: 0.65;
    transform: scale(0.82);
    box-shadow: 0 0 0 6px rgb(79 214 187 / 0);
  }
}

.hero h1 {
  margin: 0;
  max-width: 16ch;
  font-size: var(--fs-display);
  font-weight: 800;
  line-height: 1.1;
}

.hero-title-line {
  display: block;
}

.hero .lead {
  max-width: 60ch;
  margin: 22px 0 0;
  color: rgb(255 255 255 / 0.86);
  font-size: var(--fs-lead);
  line-height: 1.62;
}

.hero-actions,
.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 30px;
}

.hero-actions .button.secondary {
  background: rgb(255 255 255 / 0.94);
  border-color: rgb(255 255 255 / 0.94);
  color: #15201d;
}

.hero-actions .button.secondary:hover {
  background: #fff;
  border-color: #fff;
  color: var(--primary-hover);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 40px;
}

.stat {
  min-height: 96px;
  padding: 16px;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 0.07);
  backdrop-filter: blur(4px);
  transition: border-color var(--t), background var(--t), transform var(--t);
}

.stat:hover {
  border-color: rgb(180 240 226 / 0.5);
  background: rgb(255 255 255 / 0.11);
  transform: translateY(-2px);
}

.stat strong {
  display: block;
  font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.stat span {
  display: block;
  margin-top: 7px;
  color: rgb(255 255 255 / 0.74);
  font-size: 0.82rem;
  line-height: 1.4;
}

.hero-scroll {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 1;
  display: grid;
  place-items: center;
  color: rgb(220 240 236 / 0.7);
  animation: scroll-hint 2.1s var(--ease) infinite;
}

@keyframes scroll-hint {
  0%,
  100% {
    opacity: 0.35;
    transform: translate(-50%, 0);
  }
  50% {
    opacity: 0.85;
    transform: translate(-50%, 6px);
  }
}

/* ---------- SECTION HEADERS ---------- */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.section-header h2,
.split-copy h2 {
  margin: 0;
  font-size: var(--fs-h2);
  line-height: 1.14;
}

.section-header p:not(.eyebrow),
.page-hero p:not(.eyebrow),
.project-hero p:not(.eyebrow),
.split-copy p:not(.eyebrow) {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 70ch;
}

.capability-header {
  display: block;
}

.capability-header h2,
.capability-header p {
  max-width: none;
}

/* ---------- GRIDS ---------- */
.capability-grid,
.project-grid,
.resume-grid,
.archive-grid,
.evidence-grid,
.metrics-grid {
  display: grid;
  gap: 16px;
}

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

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

.resume-grid {
  grid-template-columns: 0.9fr 1.3fr;
}

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

.evidence-grid,
.metrics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ---------- CARD SURFACES ---------- */
.capability,
.project-card,
.resume-panel,
.archive-item,
.metric,
.timeline-item,
.note-panel,
.link-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

/* Interactive lift on the card families that are scannable lists */
.capability,
.project-card,
.archive-item,
.note-panel,
.timeline-item {
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}

.capability:hover,
.note-panel:hover,
.timeline-item:hover {
  transform: translateY(-3px);
  border-color: var(--primary-line);
  box-shadow: var(--shadow-md);
}

.project-card:hover,
.archive-item:hover {
  transform: translateY(-3px);
  border-color: var(--primary-line);
  box-shadow: var(--shadow-lg);
}

.capability {
  min-height: 176px;
  padding: 20px;
}

.capability span,
.project-card span,
.archive-item span,
.metric span,
.timeline-item time,
.project-meta span,
.case-summary > span {
  display: inline-block;
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.capability span {
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.capability h3,
.project-card h3,
.archive-item h3,
.metric h3,
.timeline-item h3,
.note-panel h2,
.link-panel h2 {
  margin: 9px 0 0;
  font-size: var(--fs-h3);
  line-height: 1.22;
}

.capability p,
.project-card p,
.archive-item p,
.timeline-item p,
.note-panel p,
.link-panel p,
.metric p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ---------- PROJECT CARDS ---------- */
.project-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.project-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
  background: var(--img-surface);
}

.project-card img[src*="architecture"],
.project-card img[src*="english-learning-ai"],
.project-card img[src*="factory"],
.project-card img[src*="oh-my-field"] {
  object-fit: contain;
  padding: 16px;
  background: var(--img-surface);
}

.project-card-visual {
  min-height: 190px;
  aspect-ratio: 16 / 10;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--primary-soft), transparent 55%),
    var(--surface);
}

.project-card-visual code {
  display: block;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-ink);
  font-size: 0.76rem;
  line-height: 1.5;
}

.project-card-body {
  padding: 20px;
}

.project-card .button {
  justify-self: start;
  margin: 0 20px 20px;
}

/* ---------- ARCHIVE ITEMS ---------- */
.archive-item {
  overflow: hidden;
}

.archive-media {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

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

.archive-media.triple {
  grid-template-columns: 1.1fr 0.95fr 0.95fr;
}

.archive-media img {
  width: 100%;
  height: 178px;
  object-fit: contain;
  padding: 8px;
  border: 1px solid var(--img-border);
  border-radius: var(--radius-sm);
  background: var(--img-surface);
}

.archive-media.single img {
  height: 224px;
}

.archive-content {
  padding: 20px;
}

.archive-content ul,
.split-copy ul,
.project-body ul,
.resume-panel ul {
  margin: 14px 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.archive-content ul {
  font-size: var(--fs-sm);
}

.archive-content li,
.split-copy li,
.project-body li,
.resume-panel li {
  margin: 7px 0;
}

.split-copy li,
.project-body li,
.resume-panel li {
  color: var(--ink);
}

/* ---------- SPLIT / VISUALS ---------- */
.split {
  display: grid;
  grid-template-columns: 0.94fr 1.06fr;
  gap: 40px;
  align-items: center;
}

.visual-frame {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--img-surface);
  box-shadow: var(--shadow-md);
}

.visual-frame img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: var(--img-surface);
}

.diagram-viewer {
  position: relative;
  overflow: hidden;
  background: var(--img-surface);
}

.diagram-scroll {
  max-height: min(70vh, 640px);
  overflow: auto;
  padding: 34px 24px 24px;
  background: var(--img-surface);
}

.diagram-viewer .diagram-scroll img {
  width: var(--diagram-width, 165%);
  max-width: none;
  height: auto;
  aspect-ratio: auto;
  object-fit: initial;
  background: var(--img-surface);
}

.diagram-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--img-border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 0.92);
  box-shadow: var(--shadow-md);
}

.diagram-toolbar button {
  min-width: 34px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #1a1917;
  font: inherit;
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t);
}

.diagram-toolbar button:hover {
  background: #eceae3;
}

/* ---------- CASE FEATURE (resume) ---------- */
.case-feature {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 24px;
  align-items: stretch;
}

.article-visual {
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--img-surface);
}

.article-visual img {
  width: 100%;
  height: 100%;
  min-height: 360px;
  aspect-ratio: auto;
  object-fit: contain;
  background: var(--img-surface);
}

.article-visual figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid var(--img-border);
  color: #4a4845;
  font-size: 0.82rem;
  line-height: 1.4;
  background: var(--surface);
}

.case-summary {
  display: grid;
  align-content: center;
}

.case-summary .button {
  justify-self: start;
  margin-top: 18px;
}

/* ---------- PAGE / PROJECT HEROES ---------- */
.page-hero,
.project-hero {
  padding: clamp(80px, 12vh, 116px) 0 30px;
}

.page-hero h1,
.project-hero h1,
.resume-hero h1 {
  margin: 0;
  max-width: 20ch;
  font-size: var(--fs-h1);
  font-weight: 800;
  line-height: 1.1;
}

.page-hero .lead,
.project-hero .lead {
  max-width: 72ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: var(--fs-lead);
}

.project-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 24px 0 0;
}

.project-meta span {
  padding: 6px 11px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  letter-spacing: 0.04em;
  text-transform: none;
}

/* ---------- PROJECT DETAIL LAYOUT ---------- */
.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  grid-template-areas:
    "problem side-primary"
    "design side-secondary"
    "contribution contribution";
  gap: 24px 28px;
  align-items: stretch;
}

.project-layout:has(.side-stack > :only-child) {
  grid-template-areas:
    "problem side-primary"
    "design design"
    "contribution contribution";
}

.project-layout .project-body,
.project-layout .side-stack {
  display: contents;
}

.project-layout .project-body .resume-panel:nth-of-type(1) {
  grid-area: problem;
}

.project-layout .project-body .resume-panel:nth-of-type(2) {
  grid-area: design;
}

.project-layout .project-body .resume-panel:nth-of-type(3) {
  grid-area: contribution;
}

.project-layout .side-stack > :first-child {
  grid-area: side-primary;
}

.project-layout .side-stack > :nth-child(2) {
  grid-area: side-secondary;
}

.project-body {
  display: grid;
  gap: 24px;
}

.project-body section,
.resume-panel {
  padding: 24px;
}

.project-body h2,
.resume-panel h2 {
  margin: 0;
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.7rem);
  line-height: 1.2;
}

.project-body p {
  margin: 11px 0 0;
  color: var(--muted);
}

.side-stack {
  display: grid;
  gap: 16px;
  position: sticky;
  top: calc(var(--nav-h) + 22px);
}

.note-panel,
.link-panel,
.metric {
  padding: 20px;
}

.link-panel p {
  margin-top: 12px;
}

.metric strong {
  display: block;
  margin-top: 9px;
  color: var(--coral);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* ---------- TIMELINE ---------- */
.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  padding: 20px;
  position: relative;
}

.timeline-item time {
  letter-spacing: 0.06em;
}

/* ---------- CONTACT STRIP ---------- */
.contact-strip {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.contact-inner {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  padding: 36px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.contact-inner strong {
  font-size: var(--fs-h3);
}

.contact-inner p {
  margin: 6px 0 0;
  color: var(--muted);
}

.contact-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- FOOTER ---------- */
.site-footer {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  padding: 40px 0 56px;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.site-footer p {
  margin: 0;
}

/* ---------- 404 ---------- */
.not-found {
  min-height: calc(100dvh - var(--nav-h));
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

.not-found-inner {
  width: min(100%, 720px);
}

.not-found h1 {
  margin: 0;
  font-size: clamp(3rem, 12vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.not-found p {
  color: var(--muted);
}

/* ---------- MOTION: SCROLL REVEAL ---------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}

.reveal.in {
  opacity: 1;
  transform: none;
}

/* ---------- MOTION: HERO LOAD ---------- */
.hero-rise {
  animation: hero-rise 0.85s var(--ease) backwards;
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1040px) {
  .capability-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 940px) {
  .nav {
    position: relative;
    min-height: 60px;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
  }

  .nav-toggle {
    display: grid;
    order: 3;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in oklab, var(--bg), transparent 2%);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(14px);
    justify-content: flex-start;
  }

  .site-header.nav-open .nav-links {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .nav-links > a {
    width: 100%;
  }

  .nav-links .lang-toggle,
  .nav-links .theme-toggle {
    width: 100%;
  }

  .nav-links .theme-toggle {
    justify-content: flex-start;
    gap: 10px;
    padding-left: 11px;
  }

  .hero {
    min-height: auto;
  }

  .hero-inner {
    padding-top: 104px;
  }

  .hero-stats,
  .capability-grid,
  .project-grid,
  .resume-grid,
  .archive-grid,
  .evidence-grid,
  .metrics-grid,
  .split,
  .case-feature,
  .project-layout {
    grid-template-columns: 1fr;
  }

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

  .project-layout,
  .project-layout:has(.side-stack > :only-child) {
    grid-template-areas:
      "problem"
      "side-primary"
      "design"
      "side-secondary"
      "contribution";
  }

  .project-layout:has(.side-stack > :only-child) {
    grid-template-areas:
      "problem"
      "side-primary"
      "design"
      "contribution";
  }

  .side-stack {
    position: static;
  }

  .contact-inner,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .article-visual img {
    min-height: 260px;
  }
}

@media (max-width: 560px) {
  .nav-links > a,
  .hero-actions .button,
  .page-actions .button,
  .contact-links .button,
  .section-header > .button {
    width: 100%;
  }

  .nav-links,
  .hero-actions,
  .page-actions,
  .contact-links {
    width: 100%;
  }

  .lang-toggle {
    width: 100%;
  }

  .lang-toggle button {
    flex: 1;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .section {
    padding: 50px 0;
  }

  .project-body section,
  .resume-panel {
    padding: 18px;
  }

  .article-visual figcaption {
    align-items: flex-start;
    flex-direction: column;
  }

  .archive-media,
  .archive-media.triple {
    grid-template-columns: 1fr;
  }

  .archive-media img,
  .archive-media.single img {
    height: auto;
    max-height: 260px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
