/* ============================================
   Taewoo Park — Design Tokens
   Mark Lombardi B&W + editorial scientific tone
   ============================================ */

:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --fg-muted: #6e6e6e;
  --fg-faint: #b5b5b5;
  --line: #1a1a1a;
  --line-soft: #e6e6e6;
  --grain: rgba(10, 10, 10, 0.03);

  /* Unified Pretendard stack across display / body / mono — all Latin and
     Korean glyphs render through the same family for visual consistency. */
  --font-display: "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif;
  --font-body:    "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif;
  --font-kr:      "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif;
  --font-mono:    "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", ui-monospace, monospace;

  --easing-default: cubic-bezier(0.16, 1, 0.3, 1);
  --easing-emphasized: cubic-bezier(0.87, 0, 0.13, 1);
  --duration-fast: 200ms;
  --duration-base: 600ms;
  --duration-slow: 1200ms;

  --grid-gutter: 24px;
  --grid-cols: 12;
  --side-pad: 5vw;
  --max-w: 1440px;
}

/* ============================================
   Viewport optimization
   ============================================ */
/* Cap effective layout width on very wide monitors so content doesn't sprawl */
@media (min-width: 1600px) {
  :root { --side-pad: max(5vw, calc((100vw - 1440px) / 2)); }
}
@media (min-width: 2000px) {
  :root { --side-pad: max(5vw, calc((100vw - 1600px) / 2)); }
}

/* Hero stage — desktop default uses absolute layout (manifest + mindmap).
   Tablet/mobile fall back to a stacked, scroll-friendly layout. */
@media (max-width: 1100px) {
  .hero-title { font-size: clamp(30px, 5vw, 64px) !important; line-height: 1.05 !important; }
}
@media (max-width: 900px) {
  .hero-stage {
    min-height: auto !important;
    padding: 32px var(--side-pad) 56px !important;
    display: flex !important;
    flex-direction: column;
    gap: 32px;
  }
  .hero-stage .hero-left {
    position: static !important;
    width: 100% !important;
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    height: auto !important;
  }
  .hero-stage .hero-mindmap {
    position: relative !important;
    inset: auto !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    bottom: auto !important;
    height: 56vh;
    width: 100%;
  }
  .hero-title { font-size: clamp(34px, 8vw, 56px) !important; }
}
@media (max-width: 600px) {
  .hero-stage { padding: 24px var(--side-pad) 40px !important; }
  .hero-stage .hero-mindmap { height: 48vh; }
  .hero-title { font-size: clamp(28px, 9vw, 44px) !important; }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body, #root {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Slightly tighter global tracking — Pretendard renders cleaner with -0.012em */
  letter-spacing: -0.012em;
}

/* Hard override — every element (including ones with inline fontFamily styles
   from JSX) renders with Pretendard. Mono labels keep tabular geometry via
   font-variant-numeric, but the family itself is unified. */
*, *::before, *::after {
  font-family: "Pretendard Variable", "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif !important;
}
code, kbd, samp, pre, .micro, [data-mono] {
  font-variant-numeric: tabular-nums;
}

/* Pretendard has no italic glyphs — strip browser-synthesized italics
   globally so inline italic styling doesn't fall back to a serif. */
[style*="italic"] { font-style: normal !important; }
i, em, cite, address { font-style: normal; }

/* Display headings — Pretendard ExtraBold (800) is the ceiling; Black (900)
   intentionally avoided. !important keeps inline JSX fontWeight overrides
   (400/600) from demoting display headings. */
.display-xxl { font-weight: 800 !important; letter-spacing: -0.038em; }
.display-xl  { font-weight: 800 !important; letter-spacing: -0.032em; }
.display-lg  { font-weight: 700 !important; letter-spacing: -0.028em; }
.display-md  { font-weight: 700 !important; letter-spacing: -0.024em; }

/* Hero title gets the heaviest treatment (still ExtraBold, not Black) */
.hero-title { font-weight: 800 !important; letter-spacing: -0.040em !important; }

/* h1/h2/h3 fallback if used directly */
h1 { font-weight: 800; letter-spacing: -0.032em; }
h2 { font-weight: 700; letter-spacing: -0.026em; }
h3 { font-weight: 700; letter-spacing: -0.022em; }
h4, h5, h6 { font-weight: 600; letter-spacing: -0.018em; }

/* Body copy: 400 default, tighter tracking */
.body, .body-lg, .body-sm { font-weight: 400; letter-spacing: -0.008em; }
.body-lg { font-weight: 450; }
strong, b { font-weight: 700; }

/* Mono/micro labels — proportional now, so tighter tracking + medium weight */
.micro { letter-spacing: 0.04em; font-weight: 500; }
.micro-fg { font-weight: 600; }

/* Korean mode — redefine body/display tokens to Pretendard so every inline
   var(--font-body) / var(--font-display) usage auto-swaps. Mono stays mono. */
html[lang="kr"] {
  --font-body: var(--font-kr);
  --font-display: var(--font-kr);
}
html[lang="kr"] body,
html[lang="kr"] #root {
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
html[lang="kr"] .display-xxl,
html[lang="kr"] .display-xl,
html[lang="kr"] .display-lg,
html[lang="kr"] .display-md {
  font-weight: 600;
  font-style: normal !important;
  letter-spacing: -0.025em;
}
/* Pretendard has no italic — strip any inline italic so the browser doesn't
   synthesize fake italic (which falls back to a serif). */
html[lang="kr"] [style*="italic"] { font-style: normal !important; }
html[lang="kr"] i, html[lang="kr"] em { font-style: normal; }
/* Mono labels with Korean glyphs — keep mono geometry but ensure Korean
   gets Pretendard fallback rather than browser default. */
html[lang="kr"] {
  --font-mono: "JetBrains Mono", "Berkeley Mono", ui-monospace, "Pretendard Variable", "Pretendard", monospace;
}

body {
  overflow-x: hidden;
  cursor: none;
}

@media (max-width: 900px) {
  body { cursor: auto; }
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: none; }
img, svg, canvas { display: block; max-width: 100%; }

::selection { background: var(--fg); color: var(--bg); }

/* Hairline utilities */
.hr { height: 1px; background: var(--line); width: 100%; }
.hr-soft { height: 1px; background: var(--line-soft); width: 100%; }

/* Mono micro-label */
.micro {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.micro-fg { color: var(--fg); }

/* Grain overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  opacity: 0.5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Hide scrollbar but keep scroll */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-soft); }
::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  canvas[data-motion] { opacity: 0.4; }
}

/* ============================================
   Tablet / split-screen (900–1200px)
   ============================================ */
@media (max-width: 1200px) {
  :root { --side-pad: 4vw; }
  /* Compress nav at split-screen widths so it doesn't overflow */
  header nav button { padding: 6px 9px !important; font-size: 11px !important; }
  header nav button > span:first-child { display: none; }
}

@media (max-width: 1024px) {
  /* Asymmetric 1.x : 1 grids stack early */
  .responsive-stack { grid-template-columns: 1fr !important; gap: 32px !important; }
  /* Footer 4-col → 2-col */
  .footer-grid { grid-template-columns: 1fr 1fr !important; gap: 32px !important; }
  /* Hero bento simplifies */
  .bento-grid { grid-template-columns: repeat(6, 1fr) !important; }
  /* 4-col cards → 2-col */
  .four-col { grid-template-columns: 1fr 1fr !important; }
  /* archive/writing list rows simplify (drop one mid column on tablet) */
  .row-list { grid-template-columns: 50px 90px 1fr 100px 24px !important; gap: 16px !important; }
  /* contact channel row narrows label column */
  .channel-row { grid-template-columns: 130px 1fr 24px !important; }
}

/* ============================================
   Mobile fallbacks (< 900px)
   ============================================ */
@media (max-width: 900px) {
  :root { --side-pad: 5vw; }
  body { cursor: auto; }

  /* Header collapses */
  header nav { display: none !important; }
  header .mobile-menu-btn { display: flex !important; }

  /* Two-col layouts → stack */
  .responsive-stack { grid-template-columns: 1fr !important; gap: 32px !important; }

  /* Display scale */
  .display-xxl { font-size: clamp(40px, 11vw, 72px) !important; }
  .display-xl  { font-size: clamp(32px, 8vw, 56px) !important; }
  .display-lg  { font-size: clamp(28px, 6.5vw, 44px) !important; }
  .display-md  { font-size: clamp(22px, 5vw, 32px) !important; }

  /* Bento, asymmetric grids → single column */
  .bento-grid { grid-template-columns: 1fr !important; grid-auto-rows: auto !important; }
  .bento-grid > * { grid-column: span 1 !important; grid-row: span 1 !important; min-height: 280px; }
  .archive-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Sticky aside hides; timeline becomes inline */
  .sticky-aside { position: static !important; margin-bottom: 32px; }

  /* Page padding */
  .page { padding: 100px var(--side-pad) 100px !important; }

  /* Hide grain on mobile (perf) */
  .grain { display: none; }

  /* Hide horizontal scrub (replace with static frame) */
  .scrub-section { height: auto !important; }
  .scrub-sticky { position: static !important; height: auto !important; grid-template-columns: 1fr !important; gap: 24px !important; }

  /* Footer / venture / contact 3-col blocks stack */
  .three-col { grid-template-columns: 1fr !important; gap: 24px !important; }
  .footer-grid { grid-template-columns: 1fr !important; gap: 32px !important; }

  /* Writing / archive list rows become 2-line cards */
  .row-list {
    grid-template-columns: auto 1fr auto !important;
    grid-template-areas: "n date arrow" "title title title" "tag tag read" !important;
    gap: 8px 12px !important;
    padding: 20px 0 !important;
  }
  .row-list > .row-n   { grid-area: n; }
  .row-list > .row-date { grid-area: date; }
  .row-list > .row-title { grid-area: title; font-size: 22px !important; }
  .row-list > .row-tag  { grid-area: tag; }
  .row-list > .row-read { grid-area: read; justify-self: end; }
  .row-list > .row-arrow { grid-area: arrow; justify-self: end; }

  /* Contact channels — simplify to two lines */
  .channel-row {
    grid-template-columns: 1fr auto !important;
    grid-template-areas: "label arrow" "value value" !important;
    gap: 6px 12px !important;
    padding: 18px 0 !important;
  }
  .channel-row > .channel-k { grid-area: label; }
  .channel-row > .channel-v { grid-area: value; font-size: 22px !important; height: 28px !important; }
  .channel-row > .channel-arrow { grid-area: arrow; }

  /* Contact radial card shrinks gracefully */
  .radial-card { min-height: 360px !important; padding: 18px !important; }

  /* Project-detail 240/1fr two-col header */
  .pd-header { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* Venture CTA stacks: text + arrow */
  .venture-cta-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
  .venture-cta-arrow { justify-self: start; }

  /* NodePrompt input row stacks (preset + textarea) */
  .np-input-grid { grid-template-columns: 1fr !important; gap: 16px !important; }

  /* Marquees: keep but slow */
  .mobile-slow-marquee { animation-duration: 60s !important; }
}

@media (max-width: 600px) {
  .four-col { grid-template-columns: 1fr !important; gap: 20px !important; }
  .four-col > * { grid-column: span 1 !important; }
  .case-strip { gap: 18px !important; }
  .case-strip > div[style*="span 4"] { margin-bottom: 4px !important; }
  .archive-grid { grid-template-columns: 1fr !important; }
  .row-list > .row-title { font-size: 18px !important; }
  /* Tighter page padding on small phones */
  .page { padding: 90px 5vw 80px !important; }
  /* Marquee text: smaller */
  .marquee-band { padding: 10px 0 !important; }
  /* Ensure SVG-based radial card stays readable */
  .radial-card { min-height: 320px !important; }
  .radial-card .radial-label { font-size: 10px !important; }
}

/* ============================================
   Research papers list — tailored mobile grid.
   The PaperRow component uses .paper-row (separate from .row-list)
   because its semantics are n / year / title+authors / venue+method
   / arrow rather than the writing-style n/date/title/tag/read.
   ============================================ */
@media (max-width: 900px) {
  .paper-row {
    grid-template-columns: auto 1fr auto !important;
    grid-template-areas:
      "n year arrow"
      "title title title"
      "venue venue venue" !important;
    gap: 6px 14px !important;
    padding: 22px 0 !important;
    align-items: baseline !important;
  }
  .paper-row > .pr-n     { grid-area: n; }
  .paper-row > .pr-year  { grid-area: year; }
  .paper-row > .pr-title { grid-area: title; margin-top: 4px; }
  .paper-row > .pr-title .display-md { font-size: 22px !important; line-height: 1.2 !important; }
  .paper-row > .pr-venue { grid-area: venue; margin-top: 6px; }
  .paper-row > .pr-arrow { grid-area: arrow; justify-self: end; }
  /* Detail panel below the row already uses .responsive-stack so it
     stacks to 1fr automatically — no extra rule needed here. */
}

/* ============================================
   Coarse-pointer (touch) overrides — kill the cursor: none baked
   into inline styles so the OS-native tap state is preserved.
   ============================================ */
@media (pointer: coarse) {
  [data-cursor],
  .row-list,
  .channel-row,
  .paper-row,
  .paper-row a {
    cursor: auto !important;
  }
  /* Slightly larger tap targets on row interactions */
  .paper-row { min-height: 56px; }
}

/* ============================================
   Typography scale
   ============================================ */
.display-xxl {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(56px, 9vw, 144px);
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.display-xl {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 6.5vw, 96px);
  line-height: 1.0;
  letter-spacing: -0.015em;
}
.display-lg {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(36px, 4.5vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.display-md {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(28px, 3vw, 48px);
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.body-lg {
  font-size: 19px; line-height: 1.55; letter-spacing: -0.005em;
}
/* Section sub-titles in long-form prose (about.jsx pull-out lines).
   Hierarchy comes mostly from size contrast: ExtraBold display at ~28px
   sits above 15.5px regular body. Inline <strong> handles mid-emphasis
   inside paragraphs without needing another sub-title. */
.about-h3 {
  font-family: var(--font-display);
  font-weight: 800;
  font-style: normal;
  font-size: clamp(20px, 2.3vw, 28px);
  line-height: 1.22;
  letter-spacing: -0.022em;
  margin: 56px 0 18px;
  color: var(--fg);
}
.about-h3:first-of-type { margin-top: 8px; }
html[lang="kr"] .about-h3 { letter-spacing: -0.018em; line-height: 1.3; }

/* Long-form body — small, comfortable, with bold accents for mid-emphasis */
.about-body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15.5px;
  line-height: 1.85;
  letter-spacing: -0.005em;
  color: var(--fg);
  margin-bottom: 16px;
}
.about-body.muted { color: var(--fg-muted); }
.about-body strong { font-weight: 700; color: var(--fg); }
.about-body.muted strong { color: var(--fg); }
html[lang="kr"] .about-body { font-size: 15.5px; line-height: 1.95; }
.body { font-size: 15px; line-height: 1.6; letter-spacing: -0.003em; }
.body-sm { font-size: 13px; line-height: 1.55; }

/* Common page chrome */
.page {
  min-height: 100vh;
  padding: 120px var(--side-pad) 160px;
  position: relative;
}

.page-eyebrow {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 40px;
}
.page-eyebrow .dot { width: 6px; height: 6px; background: var(--fg); border-radius: 50%; }

/* Magnetic / link */
.link-arrow {
  display: inline-flex; align-items: baseline; gap: 8px;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg);
  border-bottom: 1px solid var(--fg);
  padding-bottom: 2px;
  transition: gap var(--duration-fast) var(--easing-default);
}
.link-arrow:hover { gap: 14px; }

/* Reveal helpers */
.fade-in {
  opacity: 0; transform: translateY(20px);
  transition: opacity 800ms var(--easing-default), transform 800ms var(--easing-default);
}
.fade-in.in { opacity: 1; transform: translateY(0); }

/* Word-mask reveal */
.word-mask {
  display: inline-block; overflow: hidden; vertical-align: top;
  padding-bottom: 0.05em;
}
.word-mask > span {
  display: inline-block; transform: translateY(110%);
  transition: transform 1000ms var(--easing-default);
}
.word-mask.in > span { transform: translateY(0); }

/* Placeholder image */
.placeholder {
  background:
    repeating-linear-gradient(135deg,
      var(--line-soft) 0 1px, transparent 1px 8px),
    var(--bg);
  border: 1px solid var(--line);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-muted);
}
.placeholder::after {
  content: ""; position: absolute; inset: 0;
  pointer-events: none;
}
