/* joonhyunchae.com — local document stylesheet, no executable client code.
   The base roles are the admitted Ordfruma public-web projection: paper,
   ink, muted ink, line, local system sans, and a 42rem reading measure.
   This document surface adds no second brand palette. */

:root {
  color-scheme: light dark;

  --paper: var(--ord-color-canvas);
  --paper-2: var(--paper);
  --ink: var(--ord-color-ink);
  --ink-2: var(--ord-color-muted-ink);
  --rule: var(--ord-color-line);
  --accent: var(--ink);
  --accent-2: var(--ink-2);
  --mark: var(--rule);

  /* Syntax is distinguished by shape and weight, not an unowned palette. */
  --hl-comment: var(--ink-2);
  --hl-string: var(--ink);
  --hl-keyword: var(--ink);
  --hl-constant: var(--ink);
  --hl-function: var(--ink);
  --hl-type: var(--ink);

  --font-body: var(--ord-font-body);
  --font-korean: "Joonhyun Korean Projection", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono",
    "DejaVu Sans Mono", "D2Coding", monospace;
  --font-math: "STIX Two Math", "Latin Modern Math", "Cambria Math", "Libertinus Math",
    "TeX Gyre Termes Math", "Noto Sans Math", math, serif;

  --measure: var(--ord-measure-reading);
  --gutter: clamp(1.25rem, var(--ord-space-page-inline), 4.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: var(--ord-color-dark-canvas);
    --paper-2: var(--paper);
    --ink: var(--ord-color-dark-ink);
    --ink-2: var(--ord-color-dark-muted-ink);
    --rule: var(--ord-color-dark-line);
    --accent: var(--ink);
    --accent-2: var(--ink-2);
    --mark: var(--rule);

    --hl-comment: var(--ink-2);
    --hl-string: var(--ink);
    --hl-keyword: var(--ink);
    --hl-constant: var(--ink);
    --hl-function: var(--ink);
    --hl-type: var(--ink);
  }
}

/* ---------- base ---------- */

html {
  font-size: 106.25%; /* 17px */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.75;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  word-break: keep-all;          /* Korean: never break inside a word */
  overflow-wrap: break-word;     /* …but never overflow either */
  hanging-punctuation: first last;
}

/* Korean glyph coverage is a bounded, self-hosted document projection. It is
   selected only by an explicit Korean language boundary; unmarked English
   remains on the exact Ordfruma public-web system-sans token above. */
body:lang(ko),
[lang|="ko"] {
  font-family: var(--font-korean);
}

*, *::before, *::after { box-sizing: border-box; }

.wrap {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

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

.skip-link {
  position: absolute;
  left: -200vw;
  top: 0.5rem;
  padding: 0.4em 0.8em;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  z-index: 1;
}
.skip-link:focus { left: 0.5rem; }

/* ---------- chrome ---------- */

header.site {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-block: 2.25rem 3rem;
  font-size: 0.95rem;
}
header.site a { color: var(--ink); text-decoration: none; }
header.site .name { font-weight: 600; letter-spacing: 0.01em; }
header.site nav { display: flex; gap: 1.25rem; }
header.site nav a { color: var(--ink-2); }
header.site nav a:hover,
header.site a:hover { color: var(--accent); }

main { padding-bottom: 4rem; min-height: 50vh; }

footer.site {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding-block: 1.75rem 3rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.85rem;
}
footer.site a { color: var(--ink-2); }
footer.site a:hover { color: var(--accent); }

/* ---------- type ---------- */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 2.4em 0 0.7em;
  text-wrap: balance;
}
h1 { font-size: 1.85rem; margin-top: 0; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.12rem; }
h4, h5, h6 { font-size: 1rem; }

p, ul, ol, dl, blockquote, pre, table, figure, .table-wrap { margin: 0 0 1.25em; }
p { text-wrap: pretty; }
ul, ol { padding-left: 1.4em; }
li { margin-bottom: 0.3em; }
li > ul, li > ol { margin-top: 0.3em; margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-2);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-color: currentColor; }

strong { font-weight: 600; }
small { font-size: 0.85em; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.18em; }
mark { background: var(--mark); color: inherit; padding: 0 0.15em; }
kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 0.1em 0.4em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
}
sup, sub { line-height: 0; font-size: 0.75em; }

hr {
  border: 0;
  height: 1px;
  width: 6rem;
  margin: 3em auto;
  background: var(--rule);
}

blockquote {
  margin-left: 0;
  padding-left: 1.2em;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
}
blockquote > :last-child { margin-bottom: 0; }
blockquote cite { font-style: normal; font-size: 0.9em; }

.meta { color: var(--ink-2); font-size: 0.9rem; }
time { font-variant-numeric: tabular-nums; }

/* GFM alerts: > [!NOTE] … */
.markdown-alert,
blockquote[class^="markdown-alert-"] {
  border-left: 2px solid var(--accent-2);
  padding-left: 1.2em;
  color: inherit;
  margin-left: 0;
}
.markdown-alert-title {
  margin: 0 0 0.25em;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ---------- code ---------- */

code, pre, kbd, samp { font-family: var(--font-mono); }
code {
  font-size: 0.86em;
  background: var(--paper-2);
  padding: 0.12em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--paper-2);
  padding: 1em 1.2em;
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.55;
  tab-size: 4;
  font-size: 0.84rem;
}
pre code { background: none; padding: 0; font-size: inherit; }
figure.code { margin-inline: 0; }
figure.code figcaption {
  font-size: 0.8rem;
  color: var(--ink-2);
  padding: 0 0.4em 0.35em;
}
figure.code figcaption code { background: none; padding: 0; font-size: inherit; }
figure.code pre { margin: 0; }

/* ---------- figures & media ---------- */

figure { margin-inline: 0; }
figure img, figure video {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}
figure.media video, figure.media audio { width: 100%; }
figure.media video { background: var(--paper-2); }
figcaption {
  margin-top: 0.6em;
  font-size: 0.875rem;
  color: var(--ink-2);
  line-height: 1.5;
}
img { max-width: 100%; height: auto; }
p > img { vertical-align: middle; }

.attachment::before { content: "↓ "; color: var(--ink-2); }
.attachment-meta { color: var(--ink-2); font-size: 0.85em; white-space: nowrap; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
.table-wrap table { margin-bottom: 0; }
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.93rem;
  font-variant-numeric: lining-nums tabular-nums;
}
th, td {
  padding: 0.45em 0.75em;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  text-align: left;
}
th { font-weight: 600; border-bottom-width: 2px; }
.align-center { text-align: center; }
.align-right { text-align: right; }
.align-left { text-align: left; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }

/* ---------- mathematics ---------- */

math { font-family: var(--font-math); }
math[display="block"] {
  display: block math;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 1.25em 0;
  padding: 0.25em 0;
}

/* ---------- footnotes & definitions ---------- */

sup.footnote-reference a { text-decoration: none; padding: 0 0.1em; }
:not(.footnote-definition) + .footnote-definition {
  margin-top: 3em;
  padding-top: 1.25em;
  border-top: 1px solid var(--rule);
}
.footnote-definition {
  display: flex;
  gap: 0.6em;
  font-size: 0.9rem;
  color: var(--ink-2);
  margin-bottom: 0.5em;
}
.footnote-definition-label { flex: none; font-variant-numeric: tabular-nums; }
.footnote-definition p { margin: 0; }
dt { font-weight: 600; }
dd { margin: 0 0 0.75em 1.4em; }
ul.contains-task-list { list-style: none; padding-left: 0.25em; }
.task-list-item input { margin-right: 0.5em; }
.task-list-item input[type="checkbox"] { accent-color: var(--accent); }

/* ---------- headings' anchors ---------- */

.anchor {
  margin-left: 0.35em;
  font-weight: 400;
  color: var(--ink-2);
  text-decoration: none;
  opacity: 0;
  transition: opacity 120ms ease-out;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, h5:hover .anchor, h6:hover .anchor,
.anchor:focus { opacity: 1; }

/* ---------- home ---------- */

.intro h1 { font-size: 1.6rem; margin-bottom: 0.6em; }
.intro p { color: var(--ink); }
.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 3.5em 0 1.25em;
}

/* ---------- lists of posts ---------- */

.post-list { list-style: none; padding: 0; margin: 0 0 2em; }
.post-list li { margin-bottom: 1.6em; }
.post-list .title { font-size: 1.08rem; font-weight: 600; }
.post-list li > a { color: var(--ink); text-decoration: none; }
.post-list li > a:hover .title { color: var(--accent); }
.post-list time { display: block; color: var(--ink-2); font-size: 0.85rem; margin-top: 0.1em; }
.post-list .summary { margin: 0.3em 0 0; color: var(--ink-2); font-size: 0.95rem; }
.tag-list { list-style: none; padding: 0; }
.tag-list li { margin-bottom: 0.4em; }
.tag-list .count { color: var(--ink-2); font-size: 0.85rem; }

/* ---------- article ---------- */

.post-header { margin-bottom: 2.5rem; }
.post-header h1 { margin-bottom: 0.35em; }
.post-header .meta a { color: var(--ink-2); }
.post-body > :first-child { margin-top: 0; }
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}
.post-nav .newer { margin-left: auto; text-align: right; }

/* ---------- print ---------- */

@media print {
  :root {
    color-scheme: light;
    --paper: var(--ord-color-canvas);
    --ink: var(--ord-color-ink);
    --ink-2: var(--ord-color-muted-ink);
    --rule: var(--ord-color-line);
  }
  header.site nav, .post-nav, .anchor, .skip-link { display: none; }
  a { color: inherit; text-decoration: none; }
  pre, figure { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Syntax highlighting palette for syntect's `hl-*` classes.
   Deliberately few hues; the code should read like prose. */

.hl-comment, .hl-punctuation.hl-definition.hl-comment { color: var(--hl-comment); font-style: italic; }
.hl-string, .hl-punctuation.hl-definition.hl-string { color: var(--hl-string); }
.hl-string .hl-constant { color: var(--hl-string); }
.hl-keyword, .hl-storage { color: var(--hl-keyword); }
.hl-keyword.hl-operator { color: inherit; }
.hl-punctuation { color: inherit; }
.hl-constant, .hl-support.hl-constant { color: var(--hl-constant); }
.hl-entity.hl-name.hl-function, .hl-support.hl-function, .hl-meta.hl-function-call .hl-variable.hl-function { color: var(--hl-function); }
.hl-entity.hl-name.hl-type, .hl-entity.hl-name.hl-class, .hl-entity.hl-name.hl-struct, .hl-entity.hl-name.hl-enum,
.hl-entity.hl-name.hl-trait, .hl-support.hl-type, .hl-support.hl-class, .hl-storage.hl-type { color: var(--hl-type); }
.hl-storage.hl-modifier, .hl-storage.hl-type.hl-function { color: var(--hl-keyword); }
.hl-variable { color: inherit; }
.hl-variable.hl-parameter { color: inherit; }
.hl-entity.hl-name.hl-tag { color: var(--hl-keyword); }
.hl-entity.hl-other.hl-attribute-name { color: var(--hl-type); }
.hl-markup.hl-heading { font-weight: 600; }
.hl-markup.hl-bold { font-weight: 600; }
.hl-markup.hl-italic { font-style: italic; }
.hl-markup.hl-raw { color: var(--hl-string); }
.hl-markup.hl-underline.hl-link { color: var(--hl-function); }
.hl-invalid { text-decoration: underline wavy; }
.hl-meta.hl-preprocessor, .hl-keyword.hl-control.hl-import { color: var(--hl-keyword); }
.hl-entity.hl-name.hl-section, .hl-entity.hl-name.hl-table { color: var(--hl-type); }
