/* ============================================================
   bjunjo.com — single source of truth stylesheet

   Architecture:
   1. Design Tokens (CSS Custom Properties)
   2. Reset
   3. Base Typography & Links
   4. Layout Primitives  (.page / .home-wrap)
   5. Components         (header, nav, bio, essay-list,
                          newsletter, subscribe-btn, footer)
   6. Page Variants      (home, essay, about)
   7. Responsive

   Rules:
   - ONE file. Zero inline styles. Zero embedded <style> blocks.
   - Every value references a token.
   - HTML carries only semantic structure + BEM-lite classes.
   ============================================================ */


/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */
:root {
  /* Color */
  --bg:      #f9f7f2;
  --text:    #1c1c1c;
  --muted:   #888;
  --border:  #e2ddd5;

  /* Layout */
  --max: 600px;

  /* Type scale (minor third x1.2) */
  --text-xs:   0.72rem;   /* ~11.5px  labels, meta, nav */
  --text-sm:   0.875rem;  /* ~14px    secondary body    */
  --text-base: 1rem;      /*  16px    primary body      */
  --text-lg:   1.2rem;    /* ~19px    name / h1         */
  --text-xl:   1.44rem;   /* ~23px    essay title       */

  /* Spacing (8-pt grid) */
  --sp-1: 0.5rem;   /*  8px */
  --sp-2: 1rem;     /* 16px */
  --sp-3: 1.5rem;   /* 24px */
  --sp-4: 2rem;     /* 32px */
  --sp-5: 3rem;     /* 48px */
  --sp-6: 4rem;     /* 64px */

  /* Motion */
  --ease: 0.15s ease;
}


/* ── 2. RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 20px;  /* mobile-first: comfortable for all ages */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}
@media (min-width: 640px) {
  html { font-size: 18px; }  /* desktop */
}

ul { list-style: none; }
img { display: block; max-width: 100%; }


/* ── 3. BASE TYPOGRAPHY & LINKS ───────────────────────────── */

/* Korean pages */
body.lang-ko {
  font-family: 'Noto Serif KR', 'Apple SD Gothic Neo', Georgia, serif;
}
/* English pages */
body.lang-en {
  font-family: 'EB Garamond', Georgia, serif;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.85;
  overflow-x: hidden;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--ease);
}
a:hover { text-decoration-color: var(--text); }


/* ── 4. LAYOUT PRIMITIVES ─────────────────────────────────── */

/*
  .page
  Standard interior pages: essay list, essay body, about.
  Centered column with consistent vertical padding.
*/
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-3);
}

/*
  .home-wrap
  Homepage only. Full-viewport flex column so every element
  fits above the fold without scrolling.
  clamp() scales padding with viewport height.
*/
body.home-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0;
}
.home-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: var(--max);
  width: 100%;
  margin: 0 auto;
  padding:
    clamp(1.4rem, 5vh, 2.8rem)
    var(--sp-3)
    clamp(0.8rem, 2.5vh, 1.6rem);
}


/* ── 5. COMPONENTS ────────────────────────────────────────── */

/* — Header — */
header { margin-bottom: var(--sp-4); }

header h1 {
  font-family: 'Inter', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0;
}
header h1 a {
  text-decoration: none;
  color: var(--text);
}
header h1 a:hover { opacity: 0.7; }

/* — Nav — */
nav {
  margin-top: var(--sp-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
nav a {
  text-decoration: none;
  color: var(--muted);
  transition: color var(--ease);
}
nav a:hover { color: var(--text); }
nav a.active {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* — Bio line — */
.bio {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.6;
}
.bio a { color: var(--muted); text-decoration-color: var(--border); }
.bio a:hover { color: var(--text); }

/* — Section label — */
.section-label {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp-2);
}

/* — Essay list — */
.essay-list { margin-bottom: var(--sp-4); }

.essay-list li {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border);
}
.essay-list li:first-child { border-top: 1px solid var(--border); }

.essay-list .meta {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.essay-list .title-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.essay-list .title-row a { text-decoration: none; }
.essay-list .title-row a:hover {
  text-decoration: underline;
  text-decoration-color: var(--text);
}
.essay-list .updated-badge {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.essay-list .title { font-size: var(--text-base); line-height: 1.5; }
.essay-list .title a { text-decoration: none; }
.essay-list .title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--text);
}
.essay-list .subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
  font-style: italic;
  margin-top: 0.15rem;
  line-height: 1.5;
}

/* — Newsletter block (interior pages) — */
.newsletter {
  margin: var(--sp-4) 0;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.newsletter p {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--sp-2);
  line-height: 1.6;
}

/* — Newsletter strip (homepage, inline) — */
.home-newsletter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.home-newsletter p {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.5;
}

/* — Subscribe button — */
.subscribe-btn {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.55rem 1rem;
  min-height: 40px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: opacity var(--ease);
}
.subscribe-btn:hover { opacity: 0.75; }

/* — Footer — */
footer {
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.footer-left {
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.footer-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
footer a:hover { color: var(--text); }
footer a:hover svg { fill: var(--text); }
footer svg { transition: fill var(--ease); }

/* Footer spacing by context */
.home-wrap footer { margin-top: var(--sp-2); }
.page footer      { margin-top: var(--sp-5); }


/* ── 6. PAGE VARIANTS ─────────────────────────────────────── */

/* — Homepage overrides — */
.home-wrap header         { margin-bottom: var(--sp-4); }
.home-wrap .bio           { margin-bottom: var(--sp-2); }
.home-wrap .essay-list    { flex: 1; margin-bottom: 0; }
.home-wrap .essay-list li { padding: 0.55rem 0; }

/* — Essay page — */
.essay-header { margin-bottom: var(--sp-4); }

.essay-header .date {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-1);
}
.essay-header h1 {
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}
.essay-header .subtitle {
  font-size: var(--text-base);
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}

.essay-body p {
  font-size: var(--text-base);
  line-height: 1.9;
  margin-bottom: 1.4rem;
}
.essay-body p:last-child { margin-bottom: 0; }

.essay-body h2 {
  font-size: var(--text-base);
  font-weight: 500;
  margin: var(--sp-4) 0 var(--sp-2);
  letter-spacing: -0.01em;
}
.essay-body blockquote {
  border-left: 2px solid var(--border);
  padding-left: var(--sp-2);
  color: var(--muted);
  font-style: italic;
  margin: var(--sp-3) 0;
}

/* — Translate notice — */
.translate-notice {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: var(--sp-4);
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.translate-notice a { color: var(--muted); }
.translate-notice a:hover { color: var(--text); }

/* — About / section pages — */
.page-title {
  font-size: var(--text-lg);
  font-weight: 500;
  margin-bottom: var(--sp-4);
}
section { margin-bottom: var(--sp-4); }
section p {
  font-size: var(--text-base);
  line-height: 1.85;
  margin-bottom: 0.85rem;
}
section p:last-child { margin-bottom: 0; }

/* — Book list — */
section ul {
  margin: 0 0 0.85rem;
  padding: 0;
}
section ul li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  line-height: 1.7;
}
section ul li:first-child { border-top: 1px solid var(--border); }

/* — Affiliate notice — */
.affiliate-notice {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--sp-1);
}


/* — Books section — */
.book-cat-desc {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--sp-2);
  font-style: italic;
}

.book-list {
  margin: 0 0 var(--sp-2);
  padding: 0;
}
.book-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
.book-list li:first-child { border-top: 1px solid var(--border); }
.book-list a {
  font-size: var(--text-base);
  text-decoration: none;
}
.book-list a:hover { text-decoration: underline; text-decoration-color: var(--text); }
.book-meta {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 0.1rem;
}

/* — Book detail page — */
.book-back {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  margin-bottom: var(--sp-2);
}
.book-back a { text-decoration: none; color: var(--muted); }
.book-back a:hover { color: var(--text); }
.book-author {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: -0.5rem;
  margin-bottom: var(--sp-2);
  font-style: italic;
}
.book-buy-link {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  margin-bottom: var(--sp-3);
  transition: border-color var(--ease), color var(--ease);
}
.book-buy-link:hover { border-color: var(--text); color: var(--text); }
.book-hl-note {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--sp-3);
  font-style: italic;
}
.book-highlight {
  font-size: var(--text-base);
  font-style: italic;
  line-height: 1.85;
  margin-bottom: 1.4rem;
  padding-left: var(--sp-2);
  border-left: 2px solid var(--border);
  color: var(--text);
}


/* ── 7. BOOK NOTE ─────────────────────────────────────────── */
.book-note-section {
  margin-bottom: var(--sp-4);
}
.book-note {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-base);
  line-height: 1.75;
  background: #f8f5f0;
  border-left: 3px solid #c9b99a;
  padding: var(--sp-2) var(--sp-3);
  border-radius: 0 4px 4px 0;
  color: var(--text);
  margin-bottom: 0;
}

/* ── 8. RESPONSIVE ────────────────────────────────────────── */

/* Mobile: stack home-newsletter vertically */
@media (max-width: 480px) {
  .home-newsletter {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
  }
}

/* Desktop: wider padding + side-by-side essay meta */
@media (min-width: 640px) {
  .page      { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .home-wrap { padding-left: var(--sp-4); padding-right: var(--sp-4); }

  .essay-list li { display: flex; align-items: baseline; gap: var(--sp-2); }
  .essay-list .meta { white-space: nowrap; min-width: 80px; margin-bottom: 0; }

  .essay-list .title { flex: 1; }
}

/* ── 8. ENGLISH FONT COMPENSATION ────────────────────────────
   EB Garamond has a lower x-height than Noto Serif KR.
   Bump English body text ~12% larger for visual parity.
   ─────────────────────────────────────────────────────────── */
body.lang-en .essay-body p,
body.lang-en .essay-body li,
body.lang-en .essay-body blockquote {
  font-size: 1.12rem;
  line-height: 1.95;
}
body.lang-en .essay-header h1 {
  font-size: 1.7rem;
}
body.lang-en .essay-header .subtitle {
  font-size: 1.12rem;
}
body.lang-en .essay-list .title {
  font-size: 1.05rem;
}
body.lang-en .essay-list .subtitle {
  font-size: 0.95rem;
}


/* ── 9. RISK LIST ─────────────────────────────────────────────
   Used in /ko/why-bitcoin/ for the 24 stock risks.
   Card-style rows: number left, name + description right.
   ─────────────────────────────────────────────────────────── */
.risk-list {
  margin: 1.5rem 0 2rem;
}
.risk-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}
.risk-item:first-child {
  border-top: 1px solid var(--border);
}
.risk-num {
  flex-shrink: 0;
  width: 1.8rem;
  font-family: 'Inter', sans-serif;
  font-size: var(--text-xs);
  color: var(--muted);
  padding-top: 0.25rem;
  text-align: right;
}
.risk-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.risk-content strong {
  font-weight: 500;
  color: var(--text);
  font-size: var(--text-base);
}
.risk-content span {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.6;
}

/* Book personal note */
.book-note-label {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
  margin-top: 2rem;
}
.book-personal-note {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.95rem;
  font-style: normal;
  line-height: 1.75;
  color: #333;
  border-left: 3px solid #c8b89a;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 2.5rem;
  background: #faf8f4;
}
