/* ═══════════════════════════════════════════════════════════════════════
   ARTICLE MASTER — one canonical reading format for every modal.
   Loaded AFTER style.css. Wins by source order + targeted !important.
   See ../MASTER_ARTICLE_FORMAT.md for the spec this implements.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Modal card: cleaner border, kill the 3px double frame ───────────── */
.modal-card {
  border: 1px solid var(--gold-dim) !important;
  box-shadow:
    0 0 0 4px var(--bg-0),
    var(--shadow-deep),
    inset 0 0 0 1px rgba(255, 235, 200, 0.04) !important;
  border-radius: 6px !important;
}

/* ── Modal inner column ─────────────────────────────────────────────── */
.modal-inner {
  max-width: 720px !important;
  margin: 0 auto !important;
  padding: 40px 32px 56px !important;
}
@media (max-width: 720px) {
  .modal-inner { padding: 26px 22px 36px !important; }
}

/* ── HERO ────────────────────────────────────────────────────────────── */
.modal-hero {
  margin: 22px 22px 0 !important;
  width: calc(100% - 44px) !important;
  aspect-ratio: 16 / 9 !important;
  border-radius: 16px !important;
  border: 3px solid var(--gold) !important;
  box-shadow:
    0 0 0 1px var(--gold-dim) inset,
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 28px rgba(214, 168, 90, 0.22) !important;
  background-size: cover !important;
  background-position: center 28% !important;
}
.modal-hero.low-res {
  background-size: contain !important;
  background-color: var(--bg-card-2) !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
}
/* Gap from hero to first content block */
.modal-hero + .modal-content > .modal-inner > .modal-eyebrow,
.modal-hero ~ .modal-content .modal-inner .modal-eyebrow {
  margin-top: 18px;
}

/* ── EYEBROW ────────────────────────────────────────────────────────── */
.modal-eyebrow {
  text-align: center !important;
  font-family: var(--capitals) !important;
  font-size: 11.5px !important;
  letter-spacing: 5px !important;
  text-transform: uppercase;
  color: var(--gold) !important;
  margin: 0 0 28px !important;
}

/* ── TITLE ──────────────────────────────────────────────────────────── */
.modal-title {
  font-family: var(--serif-ko-literary) !important;
  font-weight: 900 !important;
  font-size: clamp(30px, 3.6vw, 44px) !important;
  line-height: 1.18 !important;
  letter-spacing: -0.6px !important;
  color: var(--text) !important;
  text-align: center !important;
  max-width: 22ch;
  margin: 0 auto 16px !important;
  /* Explicitly NO gold shimmer on title — restraint */
  background: none !important;
  -webkit-text-fill-color: var(--text) !important;
  word-break: keep-all;
}
.modal-title .bilingual-en {
  display: block;
  margin-top: 12px;
  font-family: var(--serif-en-literary);
  font-style: italic;
  font-weight: 400;
  font-size: 0.48em !important;
  color: var(--gold-2) !important;
  letter-spacing: 1px;
}

/* ── SUBTITLE (series_root_title, when present) ─────────────────────── */
.modal-subtitle {
  font-family: var(--serif-en-literary) !important;
  font-style: italic !important;
  font-weight: 400 !important;
  font-size: 18px !important;
  color: var(--gold-2) !important;
  text-align: center !important;
  margin: 14px auto 20px !important;
  max-width: 32ch;
}

/* ── META row (publisher · date) ────────────────────────────────────── */
.modal-meta {
  display: flex !important;
  justify-content: center !important;
  flex-wrap: wrap;
  gap: 14px;
  font-family: var(--serif-en-literary);
  font-size: 13.5px !important;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding-bottom: 18px !important;
  margin: 0 auto 22px !important;
  border-bottom: 1px solid var(--gold-dim);
  max-width: 64ch;
}
.modal-meta .pub {
  color: var(--gold-2) !important;
  font-weight: 600 !important;
  font-style: italic;
}
/* Keep the existing pubdate gold-shimmer rule from style.css:2094 */

/* ── Action buttons + language bar — centered, less air ─────────────── */
.modal-actions {
  justify-content: center !important;
  margin: 0 auto 22px !important;
}
.modal-lang-bar {
  justify-content: center !important;
  margin: 0 auto 28px !important;
}

/* ════════════════════════════════════════════════════════════════════
   BODY — the heart of the master format
   ════════════════════════════════════════════════════════════════════ */
.modal-body {
  font-family: var(--serif-ko-literary) !important;
  font-size: 17.5px !important;
  line-height: 1.95 !important;
  letter-spacing: 0.05px !important;
  color: var(--text-2) !important;
  max-width: 64ch !important;
  margin: 0 auto !important;
}
.modal-body p {
  margin: 0 0 22px !important;
  text-indent: 0 !important;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* Korean explicit override (handles :lang(ko) AND lang="ko") */
.modal-body[lang="ko"],
.modal-body:lang(ko) {
  font-family: var(--serif-ko-literary) !important;
  font-size: 17.5px !important;
  line-height: 1.95 !important;
}

/* Western languages */
.modal-body[lang="en"],
.modal-body:lang(en),
.modal-body[lang="es"],
.modal-body:lang(es) {
  font-family: var(--serif-en-literary) !important;
  font-size: 18px !important;
  line-height: 1.75 !important;
}

/* CJK fallback to Korean serif (Nanum Myeongjo has glyph coverage) */
.modal-body[lang="ja"],
.modal-body:lang(ja),
.modal-body[lang="zh"],
.modal-body:lang(zh) {
  font-family: var(--serif-ko-literary) !important;
  font-size: 17px !important;
  line-height: 1.9 !important;
}

/* ── DROP CAP — Playfair Display italic, gold ──────────────────────── */
.modal-body p:first-of-type::first-letter {
  font-family: var(--display-grand) !important;
  font-style: italic !important;
  font-weight: 500 !important;
  font-size: 3.6em !important;
  float: left;
  line-height: 0.82 !important;
  padding: 4px 14px 0 0 !important;
  color: var(--gold) !important;
  filter: drop-shadow(0 1px 4px rgba(214, 168, 90, 0.30));
  -webkit-text-fill-color: var(--gold) !important;
  background: none !important;
}
/* Opening paragraph — same size as body, no weight bump */
.modal-body p:first-of-type {
  font-size: inherit !important;
  font-weight: inherit !important;
}

/* Mobile body */
@media (max-width: 720px) {
  .modal-body {
    font-size: 16.5px !important;
    line-height: 1.9 !important;
  }
  .modal-body p { margin: 0 0 18px !important; }
  .modal-body p:first-of-type::first-letter {
    font-size: 3.2em !important;
    padding: 2px 10px 0 0 !important;
  }
}

/* Clear floats inside body (in case a tall fig still floats) */
.modal-body::after { content: ""; display: block; clear: both; }

/* ════════════════════════════════════════════════════════════════════
   INLINE FIGURES — one frame, three sizes
   ════════════════════════════════════════════════════════════════════ */
.inline-fig {
  margin: 28px auto !important;
  padding: 0;
  float: none !important;          /* kill old float-right tall behavior */
  max-width: 100% !important;
}
.inline-fig.fig-wide   { width: 100% !important;    max-width: 100% !important; }
.inline-fig.fig-square { width: 78% !important;     max-width: 78% !important; }
.inline-fig.fig-tall   { width: 60% !important;     max-width: 60% !important; }

@media (max-width: 720px) {
  .inline-fig.fig-square { width: 92% !important; max-width: 92% !important; }
  .inline-fig.fig-tall   { width: 72% !important; max-width: 72% !important; }
}

.inline-fig .inline-fig-frame {
  background: var(--bg-card-2);
  border-radius: 16px !important;
  padding: 0;
  overflow: hidden;
  border: 0 !important;            /* border lives on the img */
  box-shadow: none !important;
  display: block;
}
.inline-fig img,
body .modal-body .inline-fig img {
  display: block;
  width: 100% !important;
  height: auto !important;
  object-fit: cover;
  cursor: zoom-in;
  border: 3px solid var(--gold) !important;
  border-radius: 16px !important;
  box-shadow:
    0 0 0 1px var(--gold-dim) inset,
    0 14px 32px rgba(0, 0, 0, 0.5),
    0 0 22px rgba(214, 168, 90, 0.20) !important;
  background: var(--bg-card-2);
}
/* Tall figures: never crop the subject; use contain + cap height */
.inline-fig.fig-tall img,
body .modal-body .inline-fig.fig-tall img {
  object-fit: contain !important;
  max-height: 78vh;
}

/* Caption */
.inline-fig-cap {
  text-align: center !important;
  font-family: var(--serif-en-literary) !important;
  font-style: italic !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  color: var(--gold-2) !important;
  margin: 12px auto 0 !important;
  max-width: 90%;
  letter-spacing: 0.2px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.4));
}
@media (max-width: 720px) {
  .inline-fig-cap { font-size: 13px !important; }
}

/* ════════════════════════════════════════════════════════════════════
   CODA — refined
   ════════════════════════════════════════════════════════════════════ */
.modal-coda {
  max-width: 600px !important;
  margin: 60px auto 32px !important;
  text-align: center;
  padding: 0 16px;
}
.modal-coda-rule {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}
.modal-coda-rule::before,
.modal-coda-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-dim) 50%, transparent 100%);
}
.modal-coda-mark {
  font-size: 18px;
  color: var(--gold);
  filter: drop-shadow(0 0 10px rgba(214, 168, 90, 0.45));
}
.coda-author {
  font-family: var(--capitals);
  letter-spacing: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-2);
  margin-bottom: 8px;
  text-shadow: 0 0 12px rgba(214, 168, 90, 0.22);
}
.coda-pub {
  font-family: var(--serif-en-literary);
  font-style: italic;
  font-size: 14.5px;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.coda-series {
  font-family: var(--capitals);
  letter-spacing: 3px;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
}
@media (max-width: 720px) {
  .modal-coda { margin: 44px auto 24px !important; }
}

/* ════════════════════════════════════════════════════════════════════
   PAPER MODE — soften gold halos, darken body text, thin borders
   ════════════════════════════════════════════════════════════════════ */
[data-theme="paper"] .modal-card {
  border: 1px solid var(--gold-dim) !important;
  box-shadow:
    0 0 0 4px var(--bg-0),
    0 32px 80px rgba(50, 30, 0, 0.18) !important;
}
[data-theme="paper"] .modal-body {
  color: var(--text) !important;
}
[data-theme="paper"] .modal-body p:first-of-type::first-letter {
  color: var(--gold-dim) !important;
  -webkit-text-fill-color: var(--gold-dim) !important;
  filter: none;
}
[data-theme="paper"] .modal-hero {
  border-width: 2px !important;
  box-shadow:
    0 0 0 1px var(--gold-dim) inset,
    0 12px 32px rgba(60, 40, 10, 0.20) !important;
}
[data-theme="paper"] .modal-body .inline-fig img,
[data-theme="paper"] body .modal-body .inline-fig img {
  border-width: 2px !important;
  border-color: var(--gold-dim) !important;
  box-shadow:
    0 0 0 1px rgba(180, 140, 60, 0.20) inset,
    0 10px 24px rgba(60, 40, 10, 0.18) !important;
}
[data-theme="paper"] .modal-coda-mark {
  color: var(--gold-dim);
  filter: none;
}
[data-theme="paper"] .modal-title {
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
}
[data-theme="paper"] .inline-fig-cap {
  color: var(--gold-dim) !important;
  filter: none;
}
/* Pubdate shimmer is too much on cream — make it a steady gold */
[data-theme="paper"] .modal-pubdate {
  background: none !important;
  -webkit-text-fill-color: var(--gold-dim) !important;
  color: var(--gold-dim) !important;
  animation: none !important;
  filter: none !important;
  font-style: italic;
}

/* ════════════════════════════════════════════════════════════════════
   PENDING / EMPTY BODY
   ════════════════════════════════════════════════════════════════════ */
.modal-pending {
  font-family: var(--serif-ko-literary);
  max-width: 64ch !important;
  margin: 0 auto !important;
  text-align: center;
  color: var(--muted);
  background: var(--bg-card-2);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  padding: 22px 26px;
  line-height: 1.7;
}
