/* =============================================================================
   Jaeho Cho — portfolio
   Aesthetic: "lab notebook meets signal trace"
   Warm paper/ink · single vermilion accent · Fraunces + IBM Plex · faint grid
============================================================================= */

/* ----------------------------------- Tokens ------------------------------- */
:root {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* warm paper / ink — light */
  --bg:       #f5f1ea;
  --bg-2:     #efe9df;
  --surface:  #fbf9f4;
  --ink:      #1c1813;
  --muted:    #6c6356;
  --faint:    #a99e8d;
  --line:     #ddd4c5;
  --line-2:   #e7dfd2;
  --accent:   #c4452a;
  --accent-2: #a63920;
  --accent-ink: #fdf6f0;
  --grid-line: rgba(28, 24, 19, 0.045);
  --shadow: 0 1px 2px rgba(28,24,19,.04), 0 12px 28px -16px rgba(28,24,19,.28);
  --shadow-lg: 0 1px 2px rgba(28,24,19,.05), 0 40px 80px -36px rgba(28,24,19,.45);

  --maxw: 72rem;
  --measure: 38rem;
  --radius: 12px;
  --radius-sm: 7px;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --speed: .5s;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #15120e;
    --bg-2:     #1b1712;
    --surface:  #1f1a14;
    --ink:      #ece4d7;
    --muted:    #a59a89;
    --faint:    #6f6556;
    --line:     #2c261e;
    --line-2:   #332c23;
    --accent:   #f06a43;
    --accent-2: #f4815f;
    --accent-ink: #1a130e;
    --grid-line: rgba(236, 228, 215, 0.04);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 16px 36px -18px rgba(0,0,0,.7);
    --shadow-lg: 0 1px 2px rgba(0,0,0,.4), 0 50px 90px -40px rgba(0,0,0,.85);
  }
}

/* explicit dark (when toggled) — duplicated so it wins regardless of OS */
:root[data-theme="dark"] {
  --bg:#15120e; --bg-2:#1b1712; --surface:#1f1a14; --ink:#ece4d7;
  --muted:#a59a89; --faint:#6f6556; --line:#2c261e; --line-2:#332c23;
  --accent:#f06a43; --accent-2:#f4815f; --accent-ink:#1a130e;
  --grid-line:rgba(236,228,215,.04);
  --shadow:0 1px 2px rgba(0,0,0,.3),0 16px 36px -18px rgba(0,0,0,.7);
  --shadow-lg:0 1px 2px rgba(0,0,0,.4),0 50px 90px -40px rgba(0,0,0,.85);
}

/* ----------------------------------- Reset -------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--font-body);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video { display: block; max-width: 100%; }
img, video { height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* ------------------------------- Typography ------------------------------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.08; letter-spacing: -0.01em; }
.eyebrow, .k, .section-head__idx { font-family: var(--font-mono); }

.eyebrow {
  font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); font-weight: 500;
}

/* --------------------------------- Layout --------------------------------- */
section { padding-inline: clamp(1.25rem, 5vw, 4rem); }
.hero__inner, .work, .about, .site-footer__inner, #featured, .section-head {
  max-width: var(--maxw); margin-inline: auto;
}

/* --------------------------------- Header --------------------------------- */
.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: .5rem .9rem; border-radius: var(--radius-sm); transition: top .2s;
}
.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .85rem clamp(1.25rem, 5vw, 4rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid transparent; transition: border-color .3s, background .3s;
}
.site-header.is-stuck { border-bottom-color: var(--line); }

.wordmark { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; }
.wordmark__mark { width: 1.9rem; height: auto; color: var(--accent); }
.wordmark__name { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: -0.01em; }

.site-nav { display: flex; align-items: center; gap: clamp(.85rem, 2.5vw, 1.7rem); }
.site-nav a {
  font-size: .92rem; color: var(--muted); position: relative; padding: .2rem 0;
  transition: color .2s;
}
.site-nav a::after {
  content: ""; position: absolute; left: 0; bottom: -2px; height: 1.5px; width: 100%;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .28s var(--ease);
}
.site-nav a:hover, .site-nav a.is-active { color: var(--ink); }
.site-nav a:hover::after, .site-nav a.is-active::after { transform: scaleX(1); }

.theme-toggle {
  display: grid; place-items: center; width: 2.2rem; height: 2.2rem;
  border: 1px solid var(--line); border-radius: 50%; color: var(--muted);
  transition: color .2s, border-color .2s, transform .4s var(--ease);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--faint); transform: rotate(18deg); }
.theme-toggle__icon { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; }
.theme-toggle__icon--moon { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
:root[data-theme="dark"] .theme-toggle__icon--moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon--sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle__icon--moon { display: block; }
}

/* ---------------------------------- Hero ---------------------------------- */
.hero { padding-top: clamp(3rem, 9vh, 6rem); padding-bottom: clamp(3rem, 8vh, 5.5rem); }
.hero__inner {
  display: grid; grid-template-columns: 1.55fr .9fr; gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}
.hero__title {
  font-size: clamp(3.2rem, 9vw, 6.5rem); font-weight: 600;
  letter-spacing: -0.03em; margin: .4rem 0 1.1rem;
  font-variation-settings: "opsz" 144;
}
.hero__lead {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.25rem, 1rem + 1.3vw, 1.85rem); line-height: 1.34;
  max-width: 30ch; margin-bottom: 1.1rem;
}
.hero__lead em { font-style: italic; color: var(--accent); }
.hero__sub { color: var(--muted); max-width: var(--measure); margin-bottom: 1.8rem; }

.hero__meta { list-style: none; padding: 0; display: grid; gap: .5rem; margin-bottom: 1.8rem; }
.hero__meta li { font-size: .92rem; color: var(--ink); display: flex; gap: .8rem; align-items: baseline; }
.hero__meta .k {
  font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
  min-width: 4.2rem;
}

.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.6rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.25rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  font-size: .92rem; font-weight: 500; color: var(--ink);
  transition: transform .25s var(--ease), border-color .2s, background .2s, box-shadow .25s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--faint); box-shadow: var(--shadow); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { background: var(--accent-2); border-color: var(--accent-2); }

.hero__links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1.3rem; }
.hero__links a, .site-footer__links a {
  font-family: var(--font-mono); font-size: .85rem; color: var(--muted);
  position: relative; transition: color .2s;
}
.hero__links a::before {
  content: "↳"; color: var(--accent); margin-right: .45rem; opacity: .7;
}
.hero__links a:hover, .site-footer__links a:hover { color: var(--ink); }

.spike-train { width: 100%; height: 44px; color: var(--accent); margin-top: 2rem; opacity: .85; }
.spike-train__path { stroke-dasharray: 1400; stroke-dashoffset: 1400;
  animation: spike-draw 1.7s var(--ease) .5s forwards; }
@keyframes spike-draw { to { stroke-dashoffset: 0; } }

.hero__portrait {
  aspect-ratio: 4 / 5; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--bg-2); box-shadow: var(--shadow);
  position: relative;
}
.hero__portrait img { width: 100%; height: 100%; object-fit: cover; }
.hero__portrait--ph { display: grid; place-items: center;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--bg-2); }
.hero__portrait--ph .monogram { font-family: var(--font-display); font-size: 4rem;
  color: var(--accent); opacity: .55; letter-spacing: -.02em; }

/* ------------------------------ Section heads ----------------------------- */
.section-head {
  display: grid; grid-template-columns: auto 1fr auto; align-items: baseline;
  gap: 1rem; padding-top: clamp(2.5rem, 6vh, 4.5rem); padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--line); margin-bottom: 2.5rem;
}
.section-head__idx { color: var(--accent); font-size: .85rem; font-weight: 500; }
.section-head__title { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); }
.section-head__note { color: var(--muted); font-size: .9rem; text-align: right; }

/* ------------------------------- Featured --------------------------------- */
.featured { display: grid; gap: clamp(3rem, 7vh, 5.5rem); margin-bottom: 1.5rem; }
.feat {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(1.5rem, 4vw, 3.25rem);
  align-items: center;
}
.feat__gallery { display: grid; gap: .8rem; }
.feat__gallery .media { box-shadow: var(--shadow); }
.feat__gallery .media:first-child { grid-row: span 1; }
.feat__thumbs { display: grid; grid-auto-flow: column; gap: .8rem; grid-auto-columns: 1fr; }

.feat__role { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .03em;
  text-transform: uppercase; color: var(--faint); margin-bottom: .75rem; }
.feat__title { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); margin-bottom: .5rem; }
.feat__tagline { font-family: var(--font-display); font-style: italic; color: var(--accent);
  font-size: 1.15rem; margin-bottom: 1.1rem; }
.feat__summary { margin-bottom: 1.1rem; }
.feat__body { color: var(--muted); display: grid; gap: .85rem; max-width: var(--measure); }

.stats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.4rem 0; }
.stats li {
  font-family: var(--font-mono); font-size: .8rem; color: var(--ink);
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 100px;
  background: var(--surface);
}
.stats li::before { content: "● "; color: var(--accent); font-size: .7em; }

.tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.tags li { font-family: var(--font-mono); font-size: .74rem; color: var(--muted);
  letter-spacing: .02em; }
.tags li::before { content: "#"; color: var(--accent); opacity: .8; }

.proj-links { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: 1.3rem; }
.proj-links a {
  font-size: .88rem; font-weight: 500; color: var(--ink);
  border-bottom: 1.5px solid var(--accent); padding-bottom: 1px; transition: color .2s, gap .2s;
  display: inline-flex; align-items: center; gap: .35rem;
}
.proj-links a::after { content: "→"; color: var(--accent); transition: transform .2s var(--ease); }
.proj-links a:hover { color: var(--accent); }
.proj-links a:hover::after { transform: translateX(3px); }

/* --------------------------------- Media ---------------------------------- */
.media {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--bg-2); aspect-ratio: 16 / 10;
}
.media img, .media video { width: 100%; height: 100%; object-fit: cover;
  transition: transform .6s var(--ease); }
.media figcaption {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-family: var(--font-mono); font-size: .72rem; color: #fff;
  padding: 1.4rem .8rem .6rem; letter-spacing: .02em;
  background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
  opacity: 0; transform: translateY(.4rem); transition: opacity .3s, transform .3s;
}
.media:hover figcaption { opacity: 1; transform: none; }

/* figures/plots: contain on a light mat so white-bg plots read cleanly in both themes */
.media--fig { background: #fcfbf9; }
.media--fig img { object-fit: contain; padding: .5rem; }

/* graceful placeholder for not-yet-added media */
.media--ph { display: grid; place-items: center; aspect-ratio: 16 / 10;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--bg-2);
  border: 1px dashed var(--line); color: var(--faint); text-align: center; padding: 1rem;
}
.media--ph::before, .media--ph::after {
  content: ""; position: absolute; width: 12px; height: 12px;
  border: 1.5px solid var(--accent); opacity: .5;
}
.media--ph::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.media--ph::after { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.media--ph .ph-glyph { width: 1.7rem; height: 1.7rem; stroke: var(--faint); fill: none;
  stroke-width: 1.4; margin-bottom: .5rem; }
.media--ph .ph-label { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .02em; }

/* -------------------------------- Card grid ------------------------------- */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: clamp(1.1rem, 2.5vw, 1.75rem); padding-bottom: 1rem;
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: transform .35s var(--ease), box-shadow .35s, border-color .25s;
}
.card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: var(--faint); }
.card:hover .media img, .card:hover .media video { transform: scale(1.045); }
.card .media { border-radius: 0; aspect-ratio: 16 / 10; }
.card__body { padding: 1.1rem 1.15rem 1.3rem; display: flex; flex-direction: column; gap: .5rem;
  flex: 1; }
.card__title { font-size: 1.3rem; }
.card__tagline { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.card__tags { margin-top: auto; padding-top: .7rem; }
.card__hit {
  position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%;
  border-radius: var(--radius);
}
.card__hit:focus-visible { outline-offset: -3px; }
.card::after { /* corner cue */
  content: "↗"; position: absolute; top: .7rem; right: .85rem; z-index: 1;
  color: #fff; font-size: .95rem; opacity: 0; transform: translate(-3px, 3px);
  transition: opacity .3s, transform .3s; text-shadow: 0 1px 6px rgba(0,0,0,.5);
}
.card:hover::after { opacity: .9; transform: none; }

/* ---------------------------------- About --------------------------------- */
.about__grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: clamp(2rem, 5vw, 4rem); }
.about__bio { font-size: 1.12rem; display: grid; gap: 1.1rem; max-width: 40ch; }
.about__bio p { color: var(--ink); }
.about__subhead { font-family: var(--font-mono); font-size: .76rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin-bottom: .8rem; font-weight: 500; }
.about__side > * + .about__subhead { margin-top: 2rem; }

.pub-list, .now-list { list-style: none; padding: 0; display: grid; gap: 1rem; }
.pub-list li { border-left: 2px solid var(--line); padding-left: .9rem; }
.pub-list .pub-title { font-weight: 500; }
.pub-list .pub-title a { border-bottom: 1.5px solid var(--accent); }
.pub-list .pub-meta { color: var(--muted); font-size: .88rem; }
.pub-list .pub-note { font-family: var(--font-mono); font-size: .74rem; color: var(--faint); margin-top: .2rem; }
.now-list li { color: var(--muted); padding-left: 1.1rem; position: relative; }
.now-list li::before { content: "▸"; position: absolute; left: 0; color: var(--accent); }

/* --------------------------------- Footer --------------------------------- */
.site-footer {
  margin-top: clamp(3.5rem, 9vh, 6rem); border-top: 1px solid var(--line);
  background: var(--bg-2); padding: clamp(3rem, 8vh, 5rem) clamp(1.25rem, 5vw, 4rem);
}
.site-footer__cta { font-family: var(--font-display); font-size: clamp(1.5rem, 1rem + 2.5vw, 2.4rem);
  line-height: 1.2; margin-bottom: 1.6rem; }
.site-footer__links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1.4rem;
  margin-bottom: 2.5rem; }
.site-footer__fine { font-family: var(--font-mono); font-size: .76rem; color: var(--faint);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  border-top: 1px solid var(--line); padding-top: 1.3rem; }

/* --------------------------------- Dialog --------------------------------- */
.dialog {
  width: min(56rem, 92vw); max-height: 90vh; padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.dialog::backdrop { background: rgba(10, 8, 6, .55); backdrop-filter: blur(4px); }
.dialog[open] { animation: dialog-in .35s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.dialog__body { overflow-y: auto; max-height: 90vh; padding: clamp(1.5rem, 4vw, 2.75rem); }
.dialog__close {
  position: absolute; top: .8rem; right: .8rem; z-index: 3;
  width: 2.3rem; height: 2.3rem; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  transition: color .2s, transform .3s var(--ease), border-color .2s;
}
.dialog__close svg { width: 1.1rem; height: 1.1rem; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.dialog__close:hover { color: var(--ink); transform: rotate(90deg); border-color: var(--faint); }

.dlg-role { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .03em;
  text-transform: uppercase; color: var(--faint); margin-bottom: .6rem; }
.dlg-title { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); margin-bottom: .4rem; }
.dlg-tagline { font-family: var(--font-display); font-style: italic; color: var(--accent);
  font-size: 1.1rem; margin-bottom: 1.4rem; }
.dlg-gallery { display: grid; gap: 1rem; margin: 1.6rem 0; }
@media (min-width: 40rem) { .dlg-gallery { grid-template-columns: repeat(2, 1fr); }
  .dlg-gallery .media:first-child:nth-last-child(odd) { grid-column: 1 / -1; } }
.dlg-body { display: grid; gap: .9rem; color: var(--muted); max-width: 60ch; }
.dlg-body strong { color: var(--ink); }

/* ------------------------------ Motion / reveal --------------------------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
/* staggered hero load */
.hero .reveal.in { transition-delay: calc(var(--i, 0) * 90ms); }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .spike-train__path { stroke-dasharray: none !important; }
  .dialog[open] { animation: none; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* -------------------------------- Responsive ------------------------------ */
@media (max-width: 60rem) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__portrait { max-width: 22rem; order: -1; }
  .feat { grid-template-columns: 1fr; }
  .feat__media { order: -1; }
  .about__grid { grid-template-columns: 1fr; }
}
@media (max-width: 34rem) {
  .site-nav { gap: 1rem; }
  .site-nav a[href="#work"], .site-nav a[href="#about"] { display: none; } /* keep CV + toggle */
  .section-head { grid-template-columns: auto 1fr; }
  .section-head__note { display: none; }
  .hero__meta .k { min-width: 3.6rem; }
}
