@import url("fonts/nanum-myeongjo.css");

/* Shared by the published site AND the editor — one source of truth. */

:root {
  --bg: #fbfaf7;
  --ink: #1d1c1a;
  --soft: #4a4843;
  --muted: #8d887d;
  --rule: #e7e3da;
  --accent: #8a3a1e;
  --measure: 40rem;
  /* Fallback is per glyph: Latin comes from Newsreader (it has no Hangul),
     Hangul falls through to Nanum Myeongjo KR, self-hosted in public/fonts with
     size-adjust: 94% (see fonts/nanum-myeongjo.css). */
  --serif: "Newsreader", "Nanum Myeongjo KR", "AppleMyungjo", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --ink: #ece8df;
    --soft: #bdb8ad;
    --muted: #7d786e;
    --rule: #2b2925;
    --accent: #e0916c;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1.72;            /* Hangul needs a little more air than Latin */
  font-optical-sizing: auto;
  font-synthesis: weight;       /* never fake-slant Hangul: Korean has no true italic */
  word-break: keep-all;         /* break Korean at spaces, not mid-word */
  overflow-wrap: break-word;
  line-break: strict;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.5rem 8rem;
}

/* ---------- site header ---------- */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2.5rem 0 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.masthead a { color: var(--ink); text-decoration: none; font-weight: 500; }
.masthead .nav { display: flex; gap: 1.5rem; }
.masthead .nav a { font-weight: 400; color: var(--muted); }
.masthead .nav a:hover { color: var(--accent); }
.masthead a:hover { color: var(--accent); }

/* ---------- article ---------- */
.article { padding-top: 5.5rem; }

.meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.title {
  font-weight: 500;
  font-size: clamp(2.2rem, 6vw, 3.1rem);
  line-height: 1.2;
  letter-spacing: -0.012em;     /* gentle: tight tracking crowds Hangul */
  margin: 0 0 1.25rem;
  text-wrap: balance;
}

.dek {
  font-style: italic;
  font-size: 1.35rem;
  line-height: 1.55;
  color: var(--soft);
  margin: 0 0 3.5rem;
  text-wrap: pretty;
}

.prose { display: flow-root; } /* the article always contains its floated images */
.prose > * { margin: 0 0 1.5rem; }
.prose p { text-wrap: pretty; }

.prose h2 {
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: -0.008em;
  margin: 3.25rem 0 1.1rem;
}
.prose h3 {
  font-size: 1.3rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.4;
  margin: 2.5rem 0 0.9rem;
}

.prose a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.prose a:hover { color: var(--accent); }

.prose strong, .prose b { font-weight: 600; }

.prose blockquote {
  margin: 2.25rem 0;
  padding: 0 0 0 1.4rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
  color: var(--soft);
}
.prose blockquote > :last-child { margin-bottom: 0; }

.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin-bottom: 0.4rem; padding-left: 0.3rem; }
.prose li::marker { color: var(--muted); }

.prose hr {
  border: 0;
  height: 2rem;
  margin: 3rem 0;
  text-align: center;
  overflow: visible;
}
.prose hr::after {
  content: "* * *";
  letter-spacing: 0.6em;
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- images ----------
   <figure class="img-full | img-side | img-wide"><img><figcaption>…</figcaption></figure>
   Bare <img> (older posts) behaves like img-full. */
.prose img { display: block; max-width: 100%; height: auto; margin: 2.5rem auto; }

.prose figure { margin: 2.75rem 0; }
.prose figure img { margin: 0 auto; max-height: 85vh; width: auto; }
.prose figcaption {
  font-family: var(--sans);
  font-size: 0.75rem;
  line-height: 1.55;
  color: var(--muted);
  margin-top: 0.8rem;
  text-wrap: pretty;
}
.prose figcaption:empty { display: none; }
.prose figure.selected { outline: 2px solid var(--accent); outline-offset: 8px; }

/* 1 — full column */
.prose figure.img-full img { width: 100%; max-height: none; }

/* 3 — panoramic: breaks out of the text column */
.prose figure.img-wide {
  width: min(72rem, calc(100vw - 3rem));
  margin-left: 50%;
  transform: translateX(-50%);
}
.prose figure.img-wide img { width: 100%; max-height: none; }
.prose figure.img-wide figcaption { text-align: center; }

/* 2 — facing page: a smaller image beside the text (in a wide window it moves to the right page, see "open-book spread") */
.prose figure.img-side {
  float: right;
  width: 46%;
  margin: 0.35rem 0 1.25rem 1.75rem;
}
.prose figure.img-side img { width: 100%; max-height: none; }
.prose figure.img-side.selected { outline-offset: 6px; }
.prose h2, .prose h3, .prose hr, .prose figure.img-full, .prose figure.img-wide, .prose > img { clear: both; }

/* ---------- open-book spread ----------
   A post containing a Side image gets class "spread" on .page. On wide windows the page becomes
   two equal columns: text on the left page, images on the right page, centred as one spread. */
@media (min-width: 1100px) {
  .page.spread {
    --gap: 5rem;
    --col: min(38rem, calc((100vw - 6rem - var(--gap)) / 2));
    max-width: none;
  }
  .spread .masthead, .spread .colophon {
    max-width: calc(var(--col) * 2 + var(--gap));
    margin-left: auto; margin-right: auto;
  }
  .spread .article { width: var(--col); margin-left: calc(50% - var(--col) - var(--gap) / 2); }
  /* headline spills across both pages */
  .spread .title { width: calc(var(--col) * 2 + var(--gap)); font-size: clamp(2.8rem, 4.6vw, 4.4rem); line-height: 1.12; margin-bottom: 1.5rem; }
  .spread .dek { width: calc(var(--col) * 2 + var(--gap)); max-width: 52rem; font-size: 1.5rem; margin-bottom: 4rem; }

  /* two real columns: text on the left page, images on the right page */
  .spread .prose {
    display: grid;
    grid-template-columns: var(--col) var(--col);
    column-gap: var(--gap);
    align-items: start;
    width: calc(var(--col) * 2 + var(--gap));
  }
  .spread .prose > * { grid-column: 1; }
  /* grid items don't collapse margins like normal blocks do, so tighten the spacing around headings */
  .spread .prose h2 { margin-top: 1.75rem; }
  .spread .prose h3 { margin-top: 1.25rem; }
  .spread .prose blockquote { margin: 0.75rem 0 2.25rem; }
  .spread .prose hr { margin: 1.5rem 0; }

  /* Side image: pinned, centred in the right column. spread.js gives it a grid-row spanning the text
     up to the next image, so it stays in view until the next one takes over. */
  .spread .prose figure.img-side {
    grid-column: 2;
    float: none; clear: none;
    width: auto;
    margin: 0.3rem 0 1.5rem;
    align-self: stretch;           /* the figure is the whole stretch of text the image stays beside… */
  }
  .spread .prose figure.img-side .pin { position: sticky; top: 12vh; }   /* …and the image + caption pin inside it */
  .spread .prose figure.img-side img { width: auto; max-width: 100%; max-height: 68vh; margin: 0 auto; }
  .spread .prose figure.img-side figcaption { text-align: center; }
  .spread .prose figure.img-side.selected { outline: none; }
  .spread .prose figure.img-side.selected .pin { outline: 2px solid var(--accent); outline-offset: 6px; }
  .spread .prose figure.img-full { clear: none; }
  /* panoramic = a double-page image across both pages */
  .spread .prose figure.img-wide { grid-column: 1 / -1; width: auto; margin: 2.75rem 0; transform: none; }
}
@media (max-width: 600px) {
  .prose figure.img-side { float: none; width: min(82%, 20rem); margin: 2.25rem auto; }
}
html, body { overflow-x: clip; }

.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82em;
  background: var(--rule);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}
.prose pre {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  background: var(--rule);
  padding: 1rem 1.2rem;
  border-radius: 4px;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; }

/* ---------- index ---------- */
.index { padding-top: 5.5rem; }
.index h1 {
  font-size: 1rem;
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 3rem;
}
.entry {
  display: block;
  color: inherit;
  text-decoration: none;
  padding: 1.6rem 0;
  border-top: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 1px solid var(--rule); }
.entry .meta { margin-bottom: 0.5rem; }
.entry h2 {
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.008em;
  margin: 0;
}
.entry p { margin: 0.5rem 0 0; font-style: italic; color: var(--soft); font-size: 1.1rem; line-height: 1.55; }
.entry:hover h2 { color: var(--accent); }
.empty { color: var(--muted); font-style: italic; }

footer.colophon {
  margin-top: 6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 600px) {
  body { font-size: 1.125rem; }
  .article, .index { padding-top: 3.5rem; }
  .dek { font-size: 1.2rem; margin-bottom: 2.5rem; }
}

/* ---------- home: one image, one rolling-text ring ----------
   Wide: ring in the top-left corner of the page, image on the right.
   Narrow: image centred, ring overlapping the image's top-left corner. */
.home {
  position: relative;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 5.5rem 1.5rem 3.5rem;
}
.home-art { position: relative; margin: 0; }
.home-art img { display: block; width: auto; height: auto; max-width: min(88vw, 46rem); max-height: 70vh; }
.home-blank { width: min(70vw, 24rem); aspect-ratio: 3 / 4; border: 1px solid var(--rule); }
.badge {
  position: absolute; left: -0.75rem; top: -3.75rem;
  width: 8rem; aspect-ratio: 1; border-radius: 50%;
  background: var(--bg); color: var(--ink);
  display: block; text-decoration: none;
}
.badge svg { width: 100%; height: 100%; display: block; overflow: visible; }
.badge text { font-family: var(--sans); font-size: 17px; font-weight: 500; letter-spacing: 0.04em; fill: currentColor; }
.badge .spin { transform-origin: 100px 100px; animation: ring-spin 36s linear infinite; }
.badge:hover .spin { animation-duration: 12s; }
@keyframes ring-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .badge .spin { animation: none; } }
.home-credit { margin-top: 0.9rem; font-family: var(--sans); font-size: 0.72rem; line-height: 1.5; letter-spacing: 0.02em; color: var(--muted); text-align: center; text-wrap: balance; }
.home-nav { margin-top: 2.5rem; display: flex; gap: 2rem; justify-content: center; font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.04em; }
.home-nav a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--rule); padding-bottom: 2px; }
.home-nav a:hover { color: var(--accent); border-color: var(--accent); }

@media (min-width: 900px) {
  .home { flex-direction: row; justify-content: flex-end; align-items: center; padding: 2.5rem 4vw; }
  .home-art { position: static; }                     /* so the ring positions against the page, not the image */
  .home-art img { max-width: 56vw; max-height: calc(100vh - 5rem); max-height: calc(100svh - 5rem); }
  .badge { left: 4vw; top: 2.25rem; width: 11rem; }
  .home-credit { position: absolute; left: 4vw; bottom: 2.5rem; margin: 0; max-width: 20rem; text-align: left; text-wrap: pretty; }
  .home-nav { position: absolute; left: 4vw; top: 50%; transform: translateY(-50%); margin: 0; flex-direction: column; justify-content: flex-start; gap: 1.1rem; font-size: 0.9rem; }
  .home-nav a { align-self: flex-start; }
}
@media (max-width: 600px) {
  .badge { left: -0.5rem; top: -3.75rem; width: 8.25rem; }
  .home-art img { max-height: 66vh; }
}
