/* ══════════════════════════════════════════════════════════
   Single post editorial — long-form layout
   Scoped bajo .post-editorial. Adapta el diseño al sistema
   global (var(--bg), var(--font-display), var(--font-mono)…).
   ══════════════════════════════════════════════════════════ */

.post-editorial {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

/* ─── Reading progress bar (sticky bajo el header) ────── */
.pe-progress {
  height: 2px;
  background: var(--border);
  position: sticky;
  top: 70px;
  z-index: 9;
}
.pe-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width .1s linear;
}

/* ─── Hero ─────────────────────────────────────────────── */
.pe-hero {
  position: relative;
  padding: 64px 56px 56px;
  overflow: hidden;
}
.pe-hero-bg {
  position: absolute;
  right: -100px;
  top: -40px;
  font-family: var(--font-korean);
  font-size: clamp(280px, 50vw, 700px);
  color: rgba(232, 67, 45, .06);
  line-height: .85;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}
.pe-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 1000px;
}

.pe-breadcrumb {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 22px;
}
.pe-breadcrumb a { color: var(--text-dim); transition: color .15s; }
.pe-breadcrumb a:hover { color: var(--text); }
.pe-breadcrumb .pe-cat { color: var(--accent); }
.pe-breadcrumb .pe-sep { color: var(--text-very-dim); }

.pe-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 7.25rem);
  line-height: .95;
  letter-spacing: -.04em;
  margin: 0;
  font-weight: 400;
  text-wrap: pretty;
}
.pe-title em { color: var(--accent); font-style: italic; font-weight: 400; }

.pe-meta {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pe-meta .pe-sep { color: var(--text-very-dim); }
.pe-meta strong { color: var(--text); font-weight: 500; }
.pe-meta .pe-level { color: var(--accent); }

/* ─── Body grid (TOC | body | meta) ────────────────────── */
.pe-body-grid {
  display: grid;
  grid-template-columns: 260px 1fr 220px;
  gap: 72px;
  padding: 40px 56px 80px;
  border-top: 1px solid var(--border);
  max-width: 1440px;
  margin: 0 auto;
}

/* ─── TOC ──────────────────────────────────────────────── */
.pe-toc { position: sticky; top: 110px; align-self: start; }
.pe-section-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 500;
}
.pe-section-tag::before { content: '// '; }
.pe-section-tag--muted { color: var(--text-dim); }

.pe-toc-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
}
.pe-toc-list li { margin: 0; }
.pe-toc-list a {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 10px 0 10px 14px;
  border-left: 2px solid var(--border);
  transition: border-color .2s;
  color: inherit;
}
.pe-toc-list .pe-toc-n {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: .05em;
  transition: color .2s;
}
.pe-toc-list .pe-toc-label {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: -.01em;
  color: var(--text-muted);
  line-height: 1.25;
  transition: color .2s, font-style .2s;
}
.pe-toc-list a:hover .pe-toc-label,
.pe-toc-list a.is-active .pe-toc-label { color: var(--text); }
.pe-toc-list a.is-active {
  border-left-color: var(--accent);
}
.pe-toc-list a.is-active .pe-toc-n { color: var(--accent); }
.pe-toc-list a.is-active .pe-toc-label { font-style: italic; }

.pe-toc-share {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pe-share-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.pe-share-links a {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color .15s;
}
.pe-share-links a:hover { color: var(--accent); }

/* ─── Body content ─────────────────────────────────────── */
.pe-body {
  max-width: 680px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-muted);
  counter-reset: pe-h2;
}
.pe-body > p,
.pe-body > ul,
.pe-body > ol,
.pe-body > blockquote,
.pe-body > div,
.pe-body > aside,
.pe-body > h2,
.pe-body > h3 {
  max-width: 680px;
}
.pe-body p {
  margin: 0 0 22px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-muted);
  text-wrap: pretty;
}
.pe-body p strong { color: var(--text); font-weight: 500; }
.pe-body p em { color: var(--accent); font-style: italic; }
.pe-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--text-very-dim);
  transition: text-decoration-color .15s;
}
.pe-body a:hover { text-decoration-color: var(--accent); }

/* H2 numerada via counter — counter posicionado absoluto para no
 * romper el flujo inline del título (display:flex partía em/strong
 * dentro del h2 en flex-items separados y los desplazaba). */
.pe-body h2 {
  counter-increment: pe-h2;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -.03em;
  font-weight: 400;
  margin: 64px 0 24px;
  text-wrap: pretty;
  color: var(--text);
  position: relative;
  padding-left: 56px;
}
.pe-body h2::before {
  content: counter(pe-h2, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: clamp(14px, 1.2vw + 6px, 28px);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: .06em;
  font-weight: 500;
  line-height: 1;
}
.pe-body h2 em { color: var(--accent); font-style: italic; }

.pe-body h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  letter-spacing: -.025em;
  margin: 36px 0 14px;
  color: var(--text);
}

/* Lead paragraph: solo realce sutil del primer párrafo (tipografía
 * display + ligeramente más grande). Sin drop cap. */
.pe-body > p:first-of-type {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.55;
  letter-spacing: -.005em;
  color: var(--text);
  font-weight: 500;
}

/* Listas estándar */
.pe-body ul,
.pe-body ol {
  margin: 0 0 22px;
  padding-left: 1.5rem;
}
.pe-body li { margin-bottom: .5rem; line-height: 1.7; }

/* ─── Side meta column (autor + stats) ─────────────────── */
.pe-side { position: sticky; top: 110px; align-self: start; display: flex; flex-direction: column; gap: 18px; }
.pe-side-card {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 20px 18px;
}
.pe-author-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -.025em;
  margin-top: 12px;
  color: var(--text);
}
.pe-author-name em { color: var(--accent); font-style: italic; }
.pe-author-bio {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 8px 0 0;
}
.pe-author-link {
  display: inline-block;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: .07em;
  text-transform: uppercase;
}

.pe-stats {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 10px;
  color: var(--text);
}
.pe-stats > div {
  display: contents;
}
.pe-stats > div > span:first-child { color: var(--text-dim); }

/* ─── Tags ─────────────────────────────────────────────── */
.pe-tags-wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 56px 32px;
}
.pe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 680px;
  margin-left: 332px;
}
.pe-tags a {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: 2px;
  transition: border-color .15s, color .15s;
}
.pe-tags a:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Next / prev ──────────────────────────────────────── */
.pe-nav {
  padding: 56px 56px 80px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: 1440px;
  margin: 0 auto;
}
.pe-nav-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 28px 30px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s;
}
.pe-nav-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pe-nav-prev { text-align: left; }
.pe-nav-next { text-align: right; }
.pe-nav-han {
  position: absolute;
  top: -40px;
  font-family: var(--font-korean);
  font-size: 180px;
  color: rgba(232, 67, 45, .06);
  line-height: .85;
  font-weight: 700;
  pointer-events: none;
}
.pe-nav-prev .pe-nav-han { right: -10px; }
.pe-nav-next .pe-nav-han { left: -10px; }
.pe-nav-body { position: relative; }
.pe-nav-dir {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.pe-nav-title {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2vw, 1.85rem);
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1.1;
  color: var(--text);
  text-wrap: pretty;
  max-width: 480px;
}
.pe-nav-next .pe-nav-title { margin-left: auto; }

/* ─── Related ──────────────────────────────────────────── */
.pe-related {
  padding: 80px 56px;
  border-top: 1px solid var(--border);
  max-width: 1440px;
  margin: 0 auto;
}
.pe-related-head { margin-bottom: 36px; }
.pe-related-head h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-weight: 400;
  letter-spacing: -.03em;
  margin: 12px 0 0;
  line-height: 1;
}
.pe-related-head h2 em { color: var(--accent); font-style: italic; }

.pe-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.pe-related-card {
  background: var(--bg2);
  border: 1px solid var(--border-strong);
  padding: 24px 22px;
  position: relative;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color .2s, transform .2s;
}
.pe-related-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pe-related-han {
  position: absolute;
  right: -12px;
  bottom: -50px;
  font-family: var(--font-korean);
  font-size: 160px;
  color: rgba(232, 67, 45, .06);
  line-height: .85;
  font-weight: 700;
  pointer-events: none;
}
.pe-related-body { position: relative; }
.pe-related-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.pe-related-card h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1.1;
  margin: 12px 0 0;
  color: var(--text);
  text-wrap: pretty;
}
.pe-related-foot {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: .07em;
  text-transform: uppercase;
}
.pe-related-cta { color: var(--accent); }

/* ══════════════════════════════════════════════════════════
   Body content components
   Clases que el editor puede usar dentro del post para
   componer pull quotes, tips, tablas vocab, sílabas, listas
   numeradas, end rules, etc.
   ══════════════════════════════════════════════════════════ */

/* PULL QUOTE: <aside class="pe-pullquote"> con [data-hangul="글"] */
.pe-pullquote {
  position: relative;
  margin: 48px -24px;
  padding: 36px 32px;
  border-left: 2px solid var(--accent);
  background: var(--surface);
  overflow: hidden;
  max-width: none;
}
.pe-pullquote[data-hangul]::before {
  content: attr(data-hangul);
  position: absolute;
  right: -10px;
  top: -90px;
  font-family: var(--font-korean);
  font-size: 320px;
  color: rgba(232, 67, 45, .06);
  line-height: .85;
  font-weight: 700;
  pointer-events: none;
}
.pe-pullquote p {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -.015em;
  font-weight: 500;
  margin: 14px 0 0;
  max-width: 580px;
  color: var(--text);
  text-wrap: pretty;
  position: relative;
}
.pe-pullquote p em { color: var(--accent); font-style: italic; }
.pe-pullquote footer,
.pe-pullquote cite {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: .06em;
  margin-top: 18px;
  text-transform: uppercase;
  font-style: normal;
  position: relative;
}

/* TIP CALLOUT: <aside class="pe-tip"> */
.pe-tip {
  margin: 32px 0;
  padding: 20px 22px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: baseline;
  max-width: 680px;
}
.pe-tip > .pe-section-tag {
  white-space: nowrap;
}
.pe-tip p,
.pe-tip > div:last-child {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-muted);
  margin: 0;
}

/* VOCAB TABLE: <table class="pe-vocab-table"> */
.pe-vocab-table {
  width: 100%;
  max-width: 680px;
  margin: 36px 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-collapse: separate;
  border-spacing: 0;
}
.pe-vocab-table caption {
  text-align: left;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.pe-vocab-table caption::before {
  content: '// ';
  color: var(--accent);
}
.pe-vocab-table thead { display: none; }
.pe-vocab-table tbody tr {
  display: grid;
  grid-template-columns: minmax(160px, auto) 130px 1fr 1.2fr;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.pe-vocab-table tbody tr:last-child { border-bottom: 0; }
.pe-vocab-table td {
  font-size: 13px;
  color: var(--text-muted);
}
.pe-vocab-table .pe-han {
  font-family: var(--font-korean);
  font-size: 38px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.02em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.pe-vocab-table .pe-sound {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  letter-spacing: .04em;
}
.pe-vocab-table .pe-ex {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: -.005em;
}

/* SYLLABLE BLOCKS: <div class="pe-syllables"> con .pe-syl hijos */
.pe-syllables {
  margin: 36px 0;
  padding: 36px 24px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 40px;
  max-width: 680px;
}
.pe-syl { text-align: center; }
.pe-syl-han {
  display: block;
  font-family: var(--font-korean);
  font-size: clamp(60px, 8vw, 96px);
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -.025em;
}
.pe-syl-rom {
  display: block;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .06em;
}
.pe-syl-mean {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--text-muted);
  font-style: italic;
}

/* NUMBERED LIST: <ol class="pe-numbered-list">
 * Counter en absolute para no romper text nodes que siguen al <strong>
 * (con display:grid, cada text node tras el <strong> caía en una nueva
 * celda de 60px y quedaba una palabra por línea). */
.pe-numbered-list {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  counter-reset: pe-num;
  max-width: 680px;
}
.pe-body ol.pe-numbered-list,
.pe-body ul.pe-numbered-list { padding-left: 0; }
.pe-numbered-list li {
  counter-increment: pe-num;
  position: relative;
  padding: 20px 0 20px 60px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-muted);
}
.pe-numbered-list li::before {
  content: counter(pe-num, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 22px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: .06em;
  line-height: 1;
}
.pe-numbered-list li strong {
  display: block;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -.025em;
  color: var(--text);
  margin-bottom: 6px;
}

/* END RULE: <div class="pe-end-rule" data-char="끝"> */
.pe-end-rule {
  margin: 64px 0 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  font-family: var(--font-korean);
  font-size: 26px;
  color: var(--text-very-dim);
  letter-spacing: .25em;
  max-width: none;
}
.pe-end-rule::before,
.pe-end-rule::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.pe-end-rule::after { content: ''; }
.pe-end-rule[data-char]::before { content: ''; }
.pe-end-rule[data-char]::after { content: ''; }
.pe-end-rule[data-char] {
  /* hijo único: el char en el medio */
}
.pe-end-rule[data-char]::before { margin-right: 22px; }
.pe-end-rule[data-char]::after  { margin-left: 22px; }
.pe-end-rule[data-char]::before,
.pe-end-rule[data-char]::after { content: ''; }
.pe-end-rule[data-char] {
  position: relative;
}
.pe-end-rule[data-char]::after { content: ''; }
.pe-end-rule[data-char]::before { content: ''; }

/* Si no hay data-char, mostrar 끝 por defecto via ::before */
.pe-end-rule:not([data-char])::before { content: ''; }

/* Variante con char custom: usar markup explicito */
/* <div class="pe-end-rule"><span>끝</span></div> */
.pe-end-rule > span {
  flex: 0 0 auto;
}

/* ─── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .pe-hero,
  .pe-body-grid,
  .pe-tags-wrap,
  .pe-nav,
  .pe-related { padding-left: 32px; padding-right: 32px; }
  .pe-body-grid { grid-template-columns: 220px 1fr; gap: 48px; }
  .pe-side { display: none; }
  .pe-tags { margin-left: 268px; }
  .pe-related-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .pe-hero,
  .pe-body-grid,
  .pe-tags-wrap,
  .pe-nav,
  .pe-related { padding-left: 22px; padding-right: 22px; }
  .pe-hero { padding-top: 32px; padding-bottom: 32px; }
  .pe-progress { top: 60px; }
  .pe-body-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 24px;
    padding-bottom: 56px;
  }
  .pe-toc { position: static; }
  .pe-toc-list a { padding-left: 12px; }
  .pe-tags { margin-left: 0; }
  .pe-nav { grid-template-columns: 1fr; padding: 32px 22px 48px; }
  .pe-nav-card { padding: 22px 24px; }
  .pe-nav-next { text-align: left; }
  .pe-nav-next .pe-nav-title { margin-left: 0; }
  .pe-related { padding: 56px 22px; }
  .pe-related-grid { grid-template-columns: 1fr; }

  .pe-body > p:first-of-type { font-size: 18px; }
  .pe-body h2 { font-size: clamp(1.75rem, 6vw, 2.5rem); padding-left: 38px; margin: 40px 0 16px; }
  .pe-body h2::before { font-size: 11px; top: 10px; }
  .pe-pullquote { margin: 32px -10px; padding: 22px 18px; }
  .pe-pullquote p { font-size: 22px; }
  .pe-pullquote[data-hangul]::before { font-size: 200px; top: -50px; }
  /* Móvil: cada fila → mini-card apilada (no se pierde info) */
  .pe-vocab-table tbody tr {
    display: block;
    padding: 16px 18px 14px;
    gap: 0;
  }
  .pe-vocab-table td {
    display: block;
    font-size: 14px;
    padding: 0;
  }
  .pe-vocab-table .pe-han {
    font-size: 26px;
    margin-bottom: 4px;
  }
  .pe-vocab-table .pe-sound {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  .pe-vocab-table td:nth-child(3) {
    font-size: 15px;
    line-height: 1.4;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 6px;
  }
  .pe-vocab-table .pe-ex {
    font-size: 13px;
    line-height: 1.45;
  }
  .pe-syllables { padding: 22px 16px; gap: 16px; }
  .pe-tip { grid-template-columns: 1fr; gap: 6px; }
  .pe-numbered-list li { padding: 14px 0 14px 40px; }
  .pe-numbered-list li::before { top: 16px; }
  .pe-numbered-list li strong { font-size: 19px; margin-bottom: 4px; }
  .pe-end-rule { font-size: 20px; gap: 16px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .pe-progress-fill,
  .pe-toc-list a,
  .pe-nav-card,
  .pe-related-card { transition-duration: 100ms !important; }
}

/* Performance: secciones below-the-fold */
.pe-tags-wrap,
.pe-nav,
.pe-related {
  content-visibility: auto;
  contain-intrinsic-size: auto 600px;
}
