/* ============================================================
   jewan/notes — Ledger 톤 (Mono Terminal)
   메인·Study·Sub-pages 공통 baseline
   ============================================================ */

:root {
  /* ---- fonts ---- */
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "Menlo", monospace;
  --font-sans: "Pretendard Variable", "Pretendard", "SUIT Variable", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --font-serif: "Source Serif 4", Georgia, "Pretendard Variable", serif;

  /* ---- colors (warm paper + ink) ---- */
  --bg: #f5f1e8;
  --paper: #faf6ec;
  --ink: #1a1a1a;
  --ink-strong: #0a0a0a;
  --muted: #6a6258;
  --line: #1a1a1a;
  --line-soft: rgba(26, 26, 26, 0.18);
  --dash: rgba(26, 26, 26, 0.32);
  --accent: #8b1a1a;

  /* ---- typography scale ---- */
  --tracking-meta: 0.18em;
  --tracking-label: 0.1em;
  --tracking-loose: 0.06em;
  --size-meta: 11px;
  --size-label: 12px;

  /* ---- layout ---- */
  --content-width: 760px;
  --content-width-wide: 920px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "ss06", "ss07";
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background-image: linear-gradient(rgba(26, 26, 26, 0.025) 1px, transparent 1px);
  background-size: 100% 28px;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

img { max-width: 100%; display: block; }

/* ============================================================
   accessibility
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ============================================================
   shell + nav (title-frame + top strip)
   ============================================================ */
.site-shell {
  width: min(calc(100% - 40px), var(--content-width));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.site-shell.wide {
  width: min(calc(100% - 40px), var(--content-width-wide));
}

/* ---- title frame (메인 헤더 박스) ---- */
.title-frame {
  border: 1px solid var(--line);
  padding: 14px 18px;
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--paper);
}
.title-frame .name {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink-strong);
}
.title-frame .ver {
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- nav strip (title-frame 아래) ---- */
.nav-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 0 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--size-meta);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.nav-strip .crumbs { color: var(--muted); }
.nav-strip nav { display: flex; gap: 18px; }
.nav-strip nav a {
  color: var(--muted);
  border-bottom: 1px dashed transparent;
  padding-bottom: 1px;
}
.nav-strip nav a:hover,
.nav-strip nav a[aria-current="page"] {
  color: var(--ink-strong);
  border-color: var(--dash);
}

/* ============================================================
   preamble (lede card)
   ============================================================ */
.preamble {
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  margin-bottom: 36px;
}
.preamble .label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.preamble p { margin: 0; line-height: 1.75; }

/* ============================================================
   sections (numbered)
   ============================================================ */
.section { margin-bottom: 40px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
}
.section-head .marker { color: var(--ink-strong); font-weight: 600; }
.section-head .label { color: var(--muted); }
.section-head::after {
  content: "";
  flex: 1;
  height: 0;
  border-top: 1px dashed var(--dash);
}

/* ============================================================
   ledger rows (item list)
   ============================================================ */
.row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--dash);
  align-items: baseline;
}
.row:last-child { border-bottom: 1px solid var(--line); }
.row .idx {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: var(--tracking-loose);
}
.row .name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.row .name a {
  border-bottom: 1px dashed var(--dash);
  padding-bottom: 1px;
}
.row .name a:hover { border-style: solid; border-color: var(--ink); }
.row .name small {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 6px;
}
.row .meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ============================================================
   ascii rule (section divider)
   ============================================================ */
.ascii-rule {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--muted);
  margin: 32px 0 24px;
  text-align: center;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

/* ============================================================
   article (sub-page reading)
   ============================================================ */
.article {
  padding-top: 4px;
}
.article .kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.article h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.18;
  letter-spacing: -0.018em;
  margin: 0 0 14px;
}
.article .lead {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 32px;
}
.article .article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 16px;
  margin-bottom: 32px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
}
.article .article-meta strong { color: var(--ink-strong); font-weight: 500; }
.article-body {
  font-family: var(--font-serif);
  font-size: 17.5px;
  line-height: 1.78;
  letter-spacing: -0.005em;
}
.article-body h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: 48px 0 14px;
  padding-top: 32px;
  border-top: 1px dashed var(--dash);
}
.article-body h3 {
  font-weight: 600;
  font-size: 18px;
  margin: 28px 0 10px;
}
.article-body p { margin: 0 0 18px; }
.article-body a {
  color: var(--ink);
  border-bottom: 1px solid var(--dash);
  padding-bottom: 1px;
}
.article-body a:hover { border-color: var(--ink); }
.article-body code, .article-body kbd, .article-body samp {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  padding: 1px 6px;
  border-radius: 3px;
}
.article-body pre {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  margin: 22px 0;
}
.article-body pre code {
  background: none; border: none; padding: 0; border-radius: 0;
}
.article-body ul, .article-body ol {
  margin: 0 0 18px;
  padding-left: 24px;
}
.article-body li { margin-bottom: 6px; }
.article-body blockquote {
  margin: 22px 0;
  padding: 8px 18px;
  border-left: 3px solid var(--ink);
  color: var(--muted);
  font-style: italic;
}
.article-body hr {
  border: none;
  border-top: 1px dashed var(--dash);
  margin: 36px 0;
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 15px;
}
.article-body th, .article-body td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  text-align: left;
}
.article-body th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

/* ============================================================
   sub-page reading helpers (cards, chips, buttons, TOC)
   ============================================================ */
.article-hero { padding-top: 8px; margin-bottom: 36px; }
.article-hero .tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 3px 10px;
  margin-bottom: 14px;
}
.article-hero h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(30px, 4.6vw, 46px);
  line-height: 1.16;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}
.article-hero .lead {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 22px;
}
.article-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
  border: 1px dashed var(--dash);
  padding: 4px 10px;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 32px;
}
.button {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border: 1px solid var(--ink);
  transition: background 0.15s, color 0.15s;
}
.button:hover { background: var(--paper); color: var(--ink); }
.button-secondary {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink);
  padding: 12px 18px;
  border: 1px solid var(--ink);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}
.button-secondary:hover { background: var(--ink); color: var(--paper); }

/* ---- side-panel TOC ---- */
.article-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  align-items: start;
}
.side-panel {
  position: sticky;
  top: 24px;
  padding: 14px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.side-panel h3 {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.toc {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
}
.toc a {
  color: var(--ink);
  border-bottom: 1px dashed transparent;
  padding: 2px 0;
  transition: border-color 0.15s, color 0.15s;
}
.toc a:hover { color: var(--accent); border-color: var(--dash); }

/* ---- cards & grids in article body ---- */
.card {
  border: 1px solid var(--line-soft);
  padding: 14px 16px;
  background: var(--paper);
}
.card h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--tracking-meta);
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}
.card p { margin: 0; font-size: 14.5px; line-height: 1.6; }
.grid {
  display: grid;
  gap: 12px;
  margin: 22px 0;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ============================================================
   footer
   ============================================================ */
.site-footer {
  margin-top: 56px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--muted);
}
.site-footer a {
  color: var(--ink);
  border-bottom: 1px dashed var(--dash);
  padding-bottom: 1px;
}
.site-footer a:hover { border-style: solid; }

/* ============================================================
   responsive
   ============================================================ */
@media (max-width: 800px) {
  .article-layout { grid-template-columns: 1fr; }
  .side-panel { position: static; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  body { background-size: 100% 24px; }
  .site-shell { padding: 20px 0 48px; }
  .title-frame { padding: 12px 14px; }
  .title-frame .name { font-size: 16px; }
  .nav-strip { font-size: 10px; gap: 10px; }
  .nav-strip nav { gap: 14px; }
  .preamble { padding: 14px 14px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .row .idx, .row .meta { font-size: 10px; }
  .article-body { font-size: 16.5px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .nav-strip .crumbs { display: none; }
}
