/* Connecting blog. Bright paper, high-contrast ink, photography and the ten dot
   illustrations carry the rhythm. Motion stays inside figure frames; reading text
   is never hidden, blurred or scaled. */
:root {
  color-scheme: light;
  --ink: #172334;
  --muted: #566273;
  --blue: #1659ce;
  --blue-deep: #0f469f;
  --orange: #c43d18;
  --paper: #fff;
  --wash: #f4f6f8;
  --line: #dde3ea;
  --control: #7c8797;
  --read: 740px;
  --wide: 1200px;
  --gutter: clamp(1.1rem, 4vw, 2rem);
  --header: 4rem;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 1.25rem); -webkit-text-size-adjust: 100%; }
body.blog {
  margin: 0; color: var(--ink); background: var(--paper); font-family: var(--font);
  font-size: 17px; line-height: 1.75; letter-spacing: -.015em; word-break: keep-all; overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-underline-offset: .22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
::selection { color: var(--paper); background: var(--blue); }
img, svg, canvas { display: block; max-width: 100%; }
img { height: auto; }
figure, h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: min(100%, var(--wide)); margin-inline: auto; padding-inline: var(--gutter); }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 50; padding: .6rem 1rem; color: var(--paper); background: var(--ink); border-radius: 4px; }
.skip-link:focus { top: 1rem; }
main { display: block; outline: none; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(100%, var(--wide)); height: var(--header); margin-inline: auto; padding-inline: var(--gutter); }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 800; font-size: 1.12rem; letter-spacing: -.03em; text-decoration: none; }
.brand-mark { display: inline-flex; gap: 3px; }
.brand-mark i { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.brand-mark i:last-child { background: var(--orange); }
.brand-sub { padding-left: .55rem; color: var(--muted); font-weight: 600; border-left: 1px solid var(--line); }
.site-nav { display: flex; align-items: center; gap: 1.4rem; font-size: .95rem; }
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover { color: var(--blue); text-decoration: underline; }
.menu-toggle { display: none; min-height: 44px; padding: 0 1rem; background: var(--paper); border: 1px solid var(--control); border-radius: 4px; }
.motion-toggle { min-height: 40px; padding: 0 .85rem; background: var(--paper); border: 1px solid var(--control); border-radius: 999px; font-size: .88rem; }
.motion-toggle[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
html:not(.blog-ready) .motion-toggle { display: none; }
/* --progress (0–1, set by blog.js) is separate from --read, the reading column width. */
.read-progress { --progress: 0; position: fixed; inset: 0 0 auto; z-index: 31; height: 3px; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--blue); transform: scaleX(var(--progress)); transform-origin: left; }

/* Shared labels and meta */
.eyebrow, .section-kicker { color: var(--blue); font-size: .88rem; font-weight: 800; letter-spacing: .02em; }
.post-cat { color: var(--orange); font-size: .86rem; font-weight: 800; }
.post-cat a { color: inherit; text-decoration: none; }
.post-cat a:hover { text-decoration: underline; }
.post-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; color: var(--muted); font-size: .88rem; }
.post-meta > * + *::before { content: ""; display: inline-block; width: 3px; height: 3px; margin: 0 .9rem .2em 0; vertical-align: middle; border-radius: 50%; background: var(--control); }
.post-author { color: var(--ink); font-weight: 700; }
.read-link { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; font-weight: 800; }
.read-link::after { content: "→"; transition: transform .3s var(--ease); }
.read-link:hover::after { transform: translateX(4px); }
.caveat { margin-top: 1.25rem; padding-left: .9rem; color: var(--muted); font-size: .92rem; line-height: 1.7; border-left: 3px solid var(--line); }
.caveat strong { margin-right: .4rem; color: var(--ink); }
.section-sources { margin-top: 1rem; font-size: .9rem; line-height: 1.6; }
.sources-label { color: var(--ink); font-weight: 800; }
.section-sources ul { margin-top: .3rem; list-style: none; }
.section-sources li + li { margin-top: .35rem; }
.source-note { display: block; color: var(--muted); }
.source-internal { color: var(--ink); font-weight: 700; }
.motion-btn { min-height: 40px; padding: 0 .95rem; color: var(--ink); background: var(--paper); border: 1px solid var(--control); border-radius: 999px; font-size: .88rem; font-weight: 700; }
.motion-btn:hover { border-color: var(--ink); }

/* Home */
.home-hero { padding-top: clamp(3rem, 7vw, 5.5rem); padding-bottom: 2.5rem; }
.home-hero h1 { max-width: 15em; margin-top: .8rem; font-size: clamp(2.2rem, 5.4vw, 4rem); line-height: 1.18; letter-spacing: -.045em; }
.hero-lede { max-width: 40em; margin-top: 1.2rem; color: var(--muted); font-size: clamp(1.05rem, 1.6vw, 1.2rem); }
.hero-meta { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.featured { padding-bottom: clamp(3rem, 6vw, 4.5rem); }
.featured-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center; margin-top: 1rem; padding-top: 1.5rem; border-top: 2px solid var(--ink); }
.featured-copy { display: grid; gap: .8rem; }
.featured-title { font-size: clamp(1.6rem, 3vw, 2.35rem); line-height: 1.3; letter-spacing: -.035em; }
.featured-title a, .card-title a { color: var(--ink); text-decoration: none; }
.featured-title a:hover, .card-title a:hover { color: var(--blue); text-decoration: underline; }
.featured-desc { color: var(--muted); font-size: 1.05rem; }
.posts { padding-bottom: clamp(3rem, 7vw, 5rem); scroll-margin-top: var(--header); }
.posts-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-top: 1.5rem; border-top: 2px solid var(--ink); }
.posts-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.035em; }
.result-count { color: var(--muted); font-weight: 700; }
.result-count span { color: var(--ink); font-variant-numeric: tabular-nums; }
.post-tools { display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; gap: 1rem 2rem; align-items: end; margin: 1.5rem 0 2rem; }
.search-field { display: grid; gap: .35rem; }
.search-field label { font-size: .88rem; font-weight: 800; }
.search-field input { width: 100%; min-height: 48px; padding: 0 1rem; background: var(--paper); border: 1px solid var(--control); border-radius: 4px; }
.search-field input:focus-visible { outline-offset: 1px; }
.topic-filter { display: flex; flex-wrap: wrap; gap: .5rem; scroll-margin-top: calc(var(--header) + 1rem); }
.topic-filter button { min-height: 40px; padding: 0 .95rem; background: var(--paper); border: 1px solid var(--control); border-radius: 999px; font-size: .9rem; font-weight: 700; }
.topic-filter button[aria-pressed="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
html:not(.blog-ready) .search-field, html:not(.blog-ready) .topic-filter { display: none; }
.topic-description { grid-column: 1 / -1; min-height: 1.7em; color: var(--muted); font-size: .92rem; }
.post-grid, .related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.5rem 2rem; list-style: none; }
.post-card article { display: grid; gap: 1rem; height: 100%; }
.card-art { display: block; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.card-art img { width: 100%; aspect-ratio: 2 / 1; object-fit: contain; transition: transform .7s var(--ease); }
.post-card:hover .card-art img { transform: scale(1.035); }
.card-copy { display: grid; gap: .5rem; align-content: start; }
.card-title { font-size: 1.22rem; line-height: 1.4; letter-spacing: -.03em; }
.card-desc { color: var(--muted); font-size: .97rem; line-height: 1.65; }
.empty-state { display: grid; justify-items: start; gap: .7rem; padding: 2.5rem; background: var(--wash); border-radius: 4px; }
.empty-state h3 { font-size: 1.25rem; }
.flow-band { padding: clamp(3rem, 7vw, 5rem) 0; background: var(--wash); border-top: 1px solid var(--line); }
/* Home flow: one column in reading order (intro, figure, five steps, notes). On wide screens only
   the figure sits sticky beside the steps; no spacer, scroll lock or hidden panel. */
.flow-inner { display: grid; gap: 1.5rem; }
.flow-head { display: grid; gap: 1rem; }
.flow-head h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.3; letter-spacing: -.035em; }
.flow-list { display: grid; gap: .9rem; list-style: none; }
.flow-step { padding: 1.1rem 1.3rem; background: var(--paper); border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: 4px; transition: border-color .4s var(--ease); }
.flow-step[data-current] { border-left-color: var(--blue); }
.flow-step-label { color: var(--orange); font-size: .86rem; font-weight: 800; }
.flow-step-label span { margin-right: .45rem; font-variant-numeric: tabular-nums; }
.flow-step h3 { margin-top: .15rem; font-size: 1.12rem; line-height: 1.5; }
.flow-step h3 + p, .flow-step p + p { margin-top: .4rem; }
.flow-check { color: var(--muted); font-size: .94rem; }
.flow-check strong { margin-right: .4rem; color: var(--ink); }
.flow-band .dot-stage { background: var(--paper); }
@media (min-width: 1001px) {
  .flow-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-areas: "head art" "list art" "notes art"; column-gap: clamp(2rem, 4vw, 3.5rem); align-items: start; }
  .flow-head { grid-area: head; }
  .flow-list { grid-area: list; }
  .flow-notes { grid-area: notes; }
  .flow-art { grid-area: art; position: sticky; top: calc(var(--header) + 1.5rem); }
}

/* Article */
.post-wrap { padding-top: 1.5rem; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: .2rem .5rem; list-style: none; color: var(--muted); font-size: .88rem; }
.breadcrumb li + li::before { content: "/"; margin-right: .5rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb [aria-current] { color: var(--ink); }
.post-layout { display: grid; grid-template-columns: minmax(0, var(--read)); justify-content: center; margin-top: 1.5rem; }
.toc-rail { display: none; }
.post { min-width: 0; }
.post-head { display: grid; gap: .9rem; }
.post-head h1 { font-size: clamp(2rem, 4.6vw, 3.1rem); line-height: 1.22; letter-spacing: -.045em; }
.post-dek { color: var(--muted); font-size: clamp(1.08rem, 1.8vw, 1.25rem); line-height: 1.65; }
.dot-figure.is-cover { margin-top: 2rem; }
.toc-mobile { margin-top: 2rem; padding: 0 1.1rem; border: 1px solid var(--line); border-radius: 4px; }
.toc-mobile summary { min-height: 48px; display: flex; align-items: center; font-weight: 800; cursor: pointer; }
.toc-mobile ol { padding: 0 0 1rem 1.3rem; }
.toc-mobile li + li { margin-top: .35rem; }
.post-body { margin-top: 2.5rem; font-size: 18px; line-height: 1.88; }
.post-body p + p { margin-top: 1.1em; }
.post-intro { padding-bottom: .5rem; font-size: 1.06em; }
.post-section { margin-top: clamp(3rem, 6vw, 4.2rem); scroll-margin-top: calc(var(--header) + 1rem); }
.post-section h2 { margin-bottom: 1rem; font-size: clamp(1.45rem, 2.6vw, 1.85rem); line-height: 1.38; letter-spacing: -.035em; }
.post-section h2::before { content: attr(data-no); display: block; margin-bottom: .35rem; color: var(--orange); font-size: .9rem; font-weight: 800; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.post-section > .dot-figure, .post-section > .photo-figure { margin: 2rem 0; }
.checklist { display: grid; gap: .65rem; margin: 1.5rem 0; padding: 1.25rem 1.3rem; list-style: none; border: 1px solid var(--line); border-radius: 4px; }
.checklist li { position: relative; padding-left: 2rem; line-height: 1.7; }
.checklist li::before { content: ""; position: absolute; left: 0; top: .3em; width: 1.05rem; height: 1.05rem; border: 2px solid var(--blue); border-radius: 3px; }
.checklist li::after { content: ""; position: absolute; left: .34rem; top: .43em; width: .32rem; height: .6rem; border: solid var(--blue); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.example { margin: 1.6rem 0; padding: 1.3rem 1.4rem; background: var(--wash); border-left: 4px solid var(--blue); border-radius: 0 4px 4px 0; }
.example-label { color: var(--blue); font-size: .85rem; font-weight: 800; }
.example h3 { margin-top: .2rem; font-size: 1.1rem; line-height: 1.5; }
.example p + p, .example h3 + p { margin-top: .5rem; }
.post-sources { margin-top: 4rem; padding-top: 2rem; border-top: 2px solid var(--ink); font-size: .95rem; scroll-margin-top: calc(var(--header) + 1rem); }
.post-sources h2 { font-size: 1.4rem; }
.post-sources h3 { margin-top: 1.6rem; font-size: 1.05rem; }
.post-sources p { margin-top: .7rem; color: var(--muted); }
.source-list { display: grid; gap: .8rem; margin-top: 1rem; padding-left: 1.3rem; }
.related { margin-top: clamp(3.5rem, 7vw, 5rem); padding-top: 2rem; padding-bottom: 4rem; }
.related h2 { margin-bottom: 1.5rem; padding-top: 1.5rem; font-size: 1.6rem; border-top: 2px solid var(--ink); }
.not-found { padding-top: 5rem; padding-bottom: 5rem; }
.not-found h1 { margin-top: .6rem; font-size: clamp(2rem, 5vw, 3rem); }
.not-found-list { display: grid; gap: .5rem; margin-top: 2rem; padding-left: 1.2rem; }

/* Desktop table of contents sits beside the reading column. */
@media (min-width: 1100px) {
  .post-layout { grid-template-columns: 220px minmax(0, var(--read)); column-gap: 56px; justify-content: center; }
  .toc-rail { display: block; }
  .toc { position: sticky; top: calc(var(--header) + 1.5rem); max-height: calc(100vh - var(--header) - 3rem); overflow: auto; padding-right: .5rem; font-size: .9rem; line-height: 1.5; }
  .toc-title { font-weight: 800; }
  .toc ol { margin-top: .8rem; list-style: none; border-left: 1px solid var(--line); }
  .toc a { display: block; padding: .38rem 0 .38rem .9rem; margin-left: -1px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; }
  .toc a:hover { color: var(--ink); }
  .toc a[aria-current="true"] { color: var(--ink); font-weight: 800; border-left-color: var(--blue); }
  .toc-progress { margin-top: 1rem; color: var(--muted); font-size: .84rem; }
  .toc-progress span { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
  .toc-mobile { display: none; }
}

/* Figures */
.dot-figure { position: relative; }
.dot-stage { position: relative; aspect-ratio: 2 / 1; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.dot-fallback, .dot-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.dot-fallback { object-fit: contain; transition: opacity .28s linear; }
.dot-canvas { opacity: 0; pointer-events: none; }
.dot-figure.is-canvas .dot-canvas { opacity: 1; }
.dot-figure.is-canvas .dot-fallback { opacity: 0; }
.figure-caption { margin-top: .6rem; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.figure-meta { display: inline; }
.figure-meta::before { content: "· "; }
.photo-stage { position: relative; aspect-ratio: 3 / 2; overflow: hidden; background: var(--wash); border-radius: 4px; }
.photo-stage img { width: 100%; height: 100%; object-fit: cover; transform: translate3d(0, var(--photo-shift, 0px), 0) scale(var(--photo-scale, 1)); transform-origin: 50% 50%; }
.photo-figure.is-broken .photo-stage { display: grid; place-items: center; min-height: 10rem; }
.photo-figure.is-broken .photo-stage img { display: none; }
.photo-figure.is-broken .photo-stage::after { content: attr(data-broken); padding: 1rem; color: var(--muted); font-size: .92rem; text-align: center; }

/* Kinetic headline: words stay real DOM text; the final state is plain, readable type. */
.kinetic .kw { display: inline-block; }
.kinetic .kw-em { position: relative; }
.kinetic .kw-em::after { content: ""; position: absolute; left: 0; right: 0; bottom: .02em; height: .085em; background: var(--orange); transform: scaleX(0); transform-origin: left center; transition: transform .7s var(--ease); }
.kinetic.is-emphasized .kw-em::after { transform: scaleX(1); }

/* Frame reveal is applied to figure frames only, and only once motion.js runs. */
.motion-on:not(.motion-reduced) .mask-reveal { clip-path: inset(0 0 100% 0 round 4px); transition: clip-path .95s var(--ease); }
.motion-on:not(.motion-reduced) .mask-reveal.is-revealed { clip-path: inset(0 0 0 0 round 4px); }

/* Footer */
.site-footer { padding: 2.5rem 0 3rem; border-top: 1px solid var(--line); font-size: .9rem; }
.flow-band + .site-footer, main:has(> .flow-band:last-child) + .site-footer { border-top: 0; }
.footer-inner { display: grid; gap: .8rem; }
.footer-brand { font-weight: 800; }
.footer-links { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.footer-note { max-width: 52em; color: var(--muted); }

@media (max-width: 1000px) {
  .post-grid, .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-card, .flow-inner { grid-template-columns: 1fr; }
  .post-tools { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .brand-sub { display: none; }
  .site-nav { gap: 1rem; }
}
@media (max-width: 760px) {
  :root { --header: 3.6rem; }
  body.blog { font-size: 16px; }
  /* Without blog.js (JS off or a failed load) every link stays listed and the header scrolls
     away, so it never covers an anchor. The menu folds only after blog.js marks the page ready. */
  html:not(.blog-ready) { scroll-padding-top: 1rem; }
  html:not(.blog-ready) .site-header { position: static; }
  html:not(.blog-ready) .header-inner { flex-wrap: wrap; height: auto; padding-block: .4rem; }
  html:not(.blog-ready) .site-nav { flex-wrap: wrap; gap: 0 1.1rem; width: 100%; }
  html:not(.blog-ready) .site-nav a { display: inline-flex; align-items: center; min-height: 44px; }
  .blog-ready .menu-toggle { display: inline-flex; align-items: center; }
  .blog-ready .site-nav { position: absolute; top: 100%; left: 0; right: 0; display: none; flex-direction: column; align-items: stretch; gap: 0; padding: .5rem var(--gutter) 1rem; background: var(--paper); border-bottom: 1px solid var(--line); }
  .blog-ready .menu-open .site-nav { display: flex; }
  .blog-ready .site-nav a { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--line); }
  .motion-toggle { align-self: flex-start; margin-top: .8rem; min-height: 44px; }
  .topic-filter button, .motion-btn { min-height: 44px; }
  .footer-links a, .toc-mobile li a { display: inline-flex; align-items: center; min-height: 44px; }
  .post-grid, .related-grid { grid-template-columns: 1fr; gap: 2.2rem; }
  .post-body { font-size: 17px; line-height: 1.85; }
  .empty-state { padding: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
  .photo-stage img, .card-art img { transform: none !important; }
  .mask-reveal { clip-path: none !important; }
}
.motion-reduced, .motion-reduced body { scroll-behavior: auto; }
.motion-reduced *, .motion-reduced *::before, .motion-reduced *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
.motion-reduced .photo-stage img, .motion-reduced .card-art img { transform: none !important; }
