/* El Rincón del Drama — single stylesheet, mobile-first, no framework.
   Brand: dark red + gold. Web fonts via Google Fonts (see <head> in the
   generators): Noto Serif for body text, Be Vietnam Pro for headings/UI.
   Both ship a full vietnamese subset, so Vietnamese diacritics render
   correctly — system Georgia detached tone marks from letters. */

:root {
  --red: #7a1f1f;
  --red-dark: #5c1616;
  --red-soft: #f6e8e8;
  --gold: #c9a227;
  --gold-soft: #fdf6dd;
  --ink: #26221e;
  --muted: #6d625a;
  --bg: #fdf9f4;
  --card: #ffffff;
  --line: #e8ddd2;
  --max-read: 42rem;
  --max-page: 64rem;
  --font-serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --font-sans: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  /* Scale the Georgia fallback to Noto Serif's x-height so the font swap
     doesn't shift layout (visually-stable-font-fallbacks). */
  font-size-adjust: from-font;
  font-size: 1.075rem;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, .sans {
  font-family: var(--font-sans);
  font-size-adjust: from-font;
  line-height: 1.3;
}
/* Balanced wrapping for headings only — never on * (expensive algorithm). */
h1, h2, h3 {
  text-wrap: balance;
}

a { color: var(--red); }
a:hover { color: var(--red-dark); }

/* ---------- Reading progress bar (JS-driven) ---------- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: var(--gold);
  z-index: 100;
}

/* ---------- Header / nav ---------- */
.site-header {
  background: var(--red);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.header-inner {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .02em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.brand .brand-mark {
  color: var(--gold);
  font-weight: 800;
}
/* Header logo: 32px display size; the 128px/256px srcset covers retina.
   Width/height attributes in the markup reserve the space (no CLS). */
.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex: none;
}
.brand:hover { color: #ffe9a8; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,.6);
  color: #fff;
  border-radius: 6px;
  padding: .4rem .7rem;
  font-size: 1rem;
  cursor: pointer;
}

.main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.main-nav a {
  color: #f7e9d0;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: .95rem;
}
.main-nav a:hover, .main-nav a[aria-current="page"] { color: #fff; text-decoration: underline; }

.lang-switch {
  font-family: var(--font-sans);
  font-size: .85rem;
  color: #f7e9d0;
  white-space: nowrap;
}
.lang-switch a { color: #ffe9a8; text-decoration: none; }
.lang-switch a:hover { text-decoration: underline; }
.lang-switch strong { color: #fff; }

/* ---------- Layout ---------- */
.wrap {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}
.reading { max-width: var(--max-read); margin: 0 auto; }

.hero {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  border-bottom: 2px solid var(--gold);
  margin-bottom: 2rem;
}
.hero h1 { font-size: 2rem; color: var(--red); margin: .2rem 0 .5rem; }
.hero p { color: var(--muted); max-width: 36rem; margin: 0 auto; font-size: 1.05rem; }
/* Homepage hero image (LCP): fluid width, intrinsic aspect ratio kept via
   the width/height attributes in the markup (no CLS). */
.hero-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.25rem auto 0;
  border-radius: 12px;
}

.section-title {
  color: var(--red);
  border-bottom: 2px solid var(--gold);
  padding-bottom: .35rem;
  margin-top: 2rem;
}

/* ---------- Story cards ---------- */
.story-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 40rem) {
  .story-list { grid-template-columns: 1fr 1fr; }
}
.story-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
}
.story-card h3 { margin: 0 0 .4rem; font-size: 1.2rem; }
.story-card h3 a { color: var(--red); text-decoration: none; }
.story-card h3 a:hover { text-decoration: underline; }
.story-card .excerpt { color: var(--muted); font-size: .98rem; flex: 1; }
.story-card .meta {
  font-family: var(--font-sans);
  font-size: .82rem;
  color: var(--muted);
  margin-top: .8rem;
}
.fiction-tag {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: .78rem;
  font-weight: 600;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid #e3c8c8;
  border-radius: 999px;
  padding: .15rem .65rem;
  margin-bottom: .6rem;
}

/* ---------- Story page ---------- */
.story-header { text-align: center; margin-bottom: 1.5rem; }
.story-header h1 { color: var(--red); font-size: 1.9rem; margin: .6rem 0 .3rem; }
.story-header .byline {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: .9rem;
}
.story-body p { margin: 0 0 1.15em; font-size: 1.12rem; text-align: left; text-wrap: pretty; }
.story-body blockquote {
  margin: 1.2em 0;
  padding: .6em 1.1em;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  font-style: italic;
}
.story-body hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }
.story-body h2 { color: var(--red); font-size: 1.3rem; margin-top: 2em; }

.moraleja {
  margin: 2em 0;
  padding: 1rem 1.25rem;
  background: var(--gold-soft);
  border: 1px solid #ecd88a;
  border-radius: 8px;
  text-align: center;
  font-style: italic;
  font-size: 1.1rem;
}

.temp-notice {
  margin: 1.5rem 0;
  padding: .9rem 1.1rem;
  background: #fff8e1;
  border: 1px dashed var(--gold);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: .92rem;
  color: #6b5a12;
}

.related {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 2px solid var(--gold);
}
.related h2 { color: var(--red); font-size: 1.2rem; }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li { margin: .45rem 0; }

.back-home { margin-top: 2rem; text-align: center; }
.btn {
  display: inline-block;
  background: var(--red);
  color: #fff !important;
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: .65rem 1.4rem;
  border-radius: 8px;
}
.btn:hover { background: var(--red-dark); }

/* ---------- AdSense placeholder slots (no real ad code yet) ---------- */
.ad-slot {
  margin: 2rem auto;
  padding: 1rem;
  max-width: 36rem;
  border: 1px dashed #cbb;
  border-radius: 8px;
  background: #faf5ef;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: .85rem;
}

/* ---------- Language picker (root) ---------- */
.lang-grid {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
@media (min-width: 40rem) {
  .lang-grid { grid-template-columns: 1fr 1fr; }
}
.lang-grid a {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.4rem 1.25rem;
  text-decoration: none;
  color: var(--ink);
}
.lang-grid a:hover { border-color: var(--gold); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.lang-grid .lang-name { font-size: 1.25rem; font-weight: 700; color: var(--red); font-family: var(--font-sans); }
.lang-grid .lang-desc { color: var(--muted); font-size: .95rem; margin-top: .25rem; }
.badge {
  display: inline-block;
  background: var(--gold);
  color: #3a2c00;
  font-family: var(--font-sans);
  font-size: .75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .6rem;
  margin-left: .5rem;
  vertical-align: middle;
}

/* ---------- Trust pages ---------- */
.trust h2 { color: var(--red); font-size: 1.25rem; margin-top: 1.8em; }
.trust p, .trust li { font-size: 1.02rem; }
.updated {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: .85rem;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--red-dark);
  color: #e8d9c8;
  margin-top: 2rem;
}
.footer-inner {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: 1.8rem 1rem;
  font-family: var(--font-sans);
  font-size: .9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
}
.site-footer a { color: #ffe9a8; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-nav { list-style: none; margin: 0; padding: 0; display: flex; gap: 1.1rem; flex-wrap: wrap; }

/* ---------- Mobile ---------- */
@media (max-width: 48rem) {
  .nav-toggle { display: inline-block; }
  .main-nav { display: none; width: 100%; }
  .main-nav.open { display: block; }
  .main-nav ul { flex-direction: column; gap: .6rem; padding: .8rem 0 .4rem; }
  .header-inner { flex-wrap: wrap; }
  .hero h1 { font-size: 1.6rem; }
  .story-header h1 { font-size: 1.55rem; }
  body { font-size: 1.05rem; }
}

/* ---------- Cookie consent banner (Việc 4 — AdSense/Adsterra prep) ----------
   Non-modal bar fixed at the bottom; it never blocks reading. Hidden by
   default (the `hidden` attribute); main.js shows it only when no
   `drama_consent` cookie exists yet, and adds `consent-visible` to <body>
   so the page keeps enough bottom padding that the bar never covers the
   footer content. Both buttons share one style (no dark pattern). */
.consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: .5rem 1rem;
  padding: .8rem 1rem;
  background: var(--red-dark);
  color: #fdf9f4;
  box-shadow: 0 -2px 10px rgba(0,0,0,.25);
  font-family: var(--font-sans);
  font-size: .9rem;
  line-height: 1.5;
}
/* display:flex above would override the UA `hidden` rule — restore it. */
.consent-banner[hidden] { display: none; }
.consent-text { margin: 0; max-width: 44rem; }
.consent-text a { color: #ffe9a8; }
.consent-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.consent-btn {
  min-width: 24px;
  min-height: 24px;
  padding: .55rem 1.2rem;
  border: 1px solid #ffe9a8;
  border-radius: 8px;
  background: transparent;
  color: #fdf9f4;
  font-family: var(--font-sans);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
.consent-btn:hover { background: rgba(255,233,168,.15); }
.consent-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.consent-text a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
/* Room for the bar so it never covers the footer; taller on narrow screens
   where the text wraps onto more lines. */
body.consent-visible { padding-bottom: 9rem; }
@media (min-width: 40rem) {
  body.consent-visible { padding-bottom: 4.5rem; }
}
