/* Atlas of World History — style.css */
:root {
  --bg: #14100c;
  --bg-soft: #1c1712;
  --panel: #221b14;
  --ink: #ece3d4;
  --ink-dim: #b7a98f;
  --ink-faint: #8a7c64;
  --gold: #c9a24b;
  --gold-bright: #e6c168;
  --parchment: #e8dcc0;
  --line: #3a2f22;
  --line-soft: #2a2118;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia", "Songti SC", "STSong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(201,162,75,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(201,162,75,0.06), transparent 55%);
  background-attachment: fixed;
}

/* ---- language toggle: show one language at a time ---- */
html[data-lang="en"] :lang(zh) { display: none; }
html[data-lang="zh"] :lang(en) { display: none; }
/* keep code/proper markup readable regardless */

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; color: var(--parchment); }
a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: var(--parchment); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(20,16,12,0.82);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 20px; color: var(--parchment); letter-spacing: 0.3px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold) 55%, #6d4f18);
  box-shadow: 0 0 0 1px rgba(230,193,104,0.4), 0 4px 14px rgba(0,0,0,0.5);
  position: relative;
}
.brand .mark::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  border: 1px solid rgba(20,16,12,0.55);
}
.nav-right { display: flex; align-items: center; gap: 14px; }
.nav-link { color: var(--ink-dim); font-size: 15px; }
.nav-link:hover { color: var(--parchment); }

.lang-toggle {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  background: var(--bg-soft);
}
.lang-toggle button {
  appearance: none; border: 0; background: transparent; color: var(--ink-faint);
  font-family: var(--sans); font-size: 14px; padding: 6px 14px; cursor: pointer; transition: .2s;
}
.lang-toggle button.active { background: var(--gold); color: #1a140b; font-weight: 600; }

/* ---------- hero ---------- */
.hero { padding: 92px 0 64px; text-align: center; position: relative; }
.hero h1 { font-size: clamp(38px, 6vw, 68px); margin: 0 0 8px; letter-spacing: 0.5px; }
.hero .subtitle { color: var(--gold); font-family: var(--serif); font-style: italic; font-size: clamp(18px, 2.4vw, 24px); margin-bottom: 22px; }
.hero .lede { max-width: 660px; margin: 0 auto 32px; color: var(--ink-dim); font-size: 18px; }
.hero-rule { width: 120px; height: 1px; margin: 0 auto 34px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

.cta-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 12px 24px; border-radius: 999px; font-size: 15px; font-weight: 600;
  border: 1px solid var(--line); color: var(--parchment); background: var(--panel); transition: .2s;
}
.btn:hover { border-color: var(--gold); color: var(--parchment); transform: translateY(-1px); }
.btn-primary { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #1a140b; border-color: transparent; }
.btn-primary:hover { color: #1a140b; box-shadow: 0 8px 22px rgba(201,162,75,0.28); }
.btn .yt { width: 18px; height: 18px; display: inline-block; }

/* ---------- section heads ---------- */
.section-head { text-align: center; margin: 20px 0 46px; }
.section-head .eyebrow { text-transform: uppercase; letter-spacing: 3px; font-size: 12px; color: var(--gold); margin-bottom: 10px; }
.section-head h2 { font-size: clamp(28px, 4vw, 40px); margin: 0; }
.section-head p { color: var(--ink-dim); max-width: 620px; margin: 12px auto 0; }

/* ---------- horizontal timeline ---------- */
.htimeline-wrap {
  overflow-x: auto; overflow-y: hidden; padding: 6px 22px 20px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--gold) transparent;
}
.htimeline-wrap::-webkit-scrollbar { height: 9px; }
.htimeline-wrap::-webkit-scrollbar-track { background: transparent; }
.htimeline-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.htimeline-wrap::-webkit-scrollbar-thumb:hover { background: var(--gold); }
.htimeline { position: relative; display: flex; gap: 24px; width: max-content; padding-top: 44px; }
.htimeline::before {
  content: ""; position: absolute; top: 21px; left: 20px; right: 20px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 5%, var(--gold) 95%, transparent);
  opacity: .55;
}
.hera { position: relative; flex: 0 0 300px; scroll-snap-align: center; }
.hera-dot {
  position: absolute; top: -30px; left: 24px; width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold) 60%, #5c4114);
  box-shadow: 0 0 0 5px var(--bg), 0 0 0 6px var(--line); z-index: 2;
}
.hera-dot::after { content: ""; position: absolute; left: 50%; top: 15px; transform: translateX(-50%); width: 2px; height: 15px; background: var(--line); }
.hera-card {
  position: relative; background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line); border-radius: 16px; padding: 22px;
  min-height: 344px; height: 100%; display: flex; flex-direction: column;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.hera-card:hover { transform: translateY(-4px); border-color: rgba(201,162,75,0.55); box-shadow: 0 14px 34px rgba(0,0,0,0.4); }
.hera-emblem { width: 54px; height: 54px; color: var(--gold); margin-bottom: 14px; filter: drop-shadow(0 2px 6px rgba(201,162,75,0.25)); }
.hera-emblem svg { width: 100%; height: 100%; display: block; }
.hera-num { position: absolute; top: 14px; right: 18px; font-family: var(--serif); font-size: 44px; color: rgba(201,162,75,0.16); font-weight: 700; line-height: 1; }
.hera .range { font-size: 12px; letter-spacing: 1px; color: var(--gold); text-transform: uppercase; margin-bottom: 6px; }
.hera h3 { font-size: 22px; margin: 0 0 10px; }
.hera .blurb { color: var(--ink-dim); font-size: 14.5px; margin: 0 0 16px; flex: 1; }
.hera .reads { display: flex; flex-wrap: wrap; gap: 8px; }
.htimeline-hint { margin-top: 14px; font-size: 13px; color: var(--ink-faint); font-style: italic; }

/* ---------- scroll-reveal animations ---------- */
.has-js [data-reveal] {
  opacity: 0; transform: translateY(22px);
  transition: opacity .6s ease, transform .7s cubic-bezier(.2,.7,.2,1);
  transition-delay: calc(var(--i, 0) * 70ms);
}
.has-js [data-reveal].is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .has-js [data-reveal] { opacity: 1 !important; transform: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 14px;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-soft);
  background: rgba(0,0,0,0.2); color: var(--parchment); transition: .2s;
}
.chip:hover { border-color: var(--gold); background: rgba(201,162,75,0.12); }
.chip::before { content: "❧"; color: var(--gold); font-size: 13px; }
.reads-empty { font-size: 13px; color: var(--ink-faint); font-style: italic; }

/* ---------- articles grid (home) ---------- */
.articles { padding: 40px 0 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.acard {
  display: flex; flex-direction: column; background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line); border-radius: 14px; padding: 22px; transition: .25s; height: 100%;
}
.acard:hover { transform: translateY(-3px); border-color: rgba(201,162,75,0.55); box-shadow: 0 12px 30px rgba(0,0,0,0.4); }
.acard .era-tag { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.acard h3 { font-size: 21px; margin: 0 0 10px; color: var(--parchment); }
.acard p { color: var(--ink-dim); font-size: 15px; margin: 0 0 16px; flex: 1; }
.acard .more { font-size: 14px; color: var(--gold-bright); font-weight: 600; }

/* ---------- article page ---------- */
.article { padding: 48px 0 20px; }
.article-inner { max-width: 760px; margin: 0 auto; }
.breadcrumb { font-size: 14px; color: var(--ink-faint); margin-bottom: 22px; }
.breadcrumb a { color: var(--ink-dim); }
.article .era-tag { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 12px; }
.article h1 { font-size: clamp(30px, 5vw, 46px); margin: 0 0 14px; line-height: 1.15; }
.article .meta { color: var(--ink-faint); font-size: 14px; border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 30px; }
.article .body p { margin: 0 0 24px; color: var(--ink); }
.article .body p:first-of-type::first-letter {
  font-family: var(--serif); font-size: 62px; line-height: 0.8; float: left;
  padding: 6px 12px 0 0; color: var(--gold);
}
.article-cta {
  margin: 44px 0 10px; padding: 26px; border-radius: 14px; text-align: center;
  background: linear-gradient(180deg, rgba(201,162,75,0.10), rgba(201,162,75,0.03));
  border: 1px solid var(--line);
}
.article-cta h4 { font-size: 20px; margin: 0 0 8px; }
.article-cta p { color: var(--ink-dim); margin: 0 0 16px; font-size: 15px; }

.article-nav { display: flex; justify-content: space-between; gap: 14px; margin: 30px 0; flex-wrap: wrap; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 70px; padding: 40px 0; color: var(--ink-faint); }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.site-footer a { color: var(--ink-dim); }
.site-footer .fbrand { font-family: var(--serif); color: var(--parchment); font-size: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding: 60px 0 40px; }
  .nav-link { display: none; }
  .hera { flex-basis: 80vw; }
  .htimeline-wrap { padding-left: 16px; padding-right: 16px; }
  .hera-num { font-size: 34px; }
  .site-footer .wrap { flex-direction: column; text-align: center; }
  .filter-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .filter-label { width: auto; }
}

/* ---------- hero (sub-page variant) ---------- */
.hero-sub { padding: 56px 0 30px; }

/* ---------- nations: home teaser region grid ---------- */
.region-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px;
}
.region-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--parchment);
  font-family: var(--serif); font-size: 18px; transition: transform .15s, border-color .15s;
}
.region-chip:hover { transform: translateY(-2px); border-color: rgba(201,162,75,0.55); color: var(--parchment); }
.region-chip .rc-count {
  font-family: var(--sans); font-size: 13px; color: var(--bg);
  background: var(--gold); border-radius: 20px; padding: 2px 10px; font-weight: 700;
}

/* ---------- nations: filter bar ---------- */
.filter-bar {
  border: 1px solid var(--line); border-radius: 14px; background: rgba(28,23,18,0.6);
  padding: 16px 18px; margin-bottom: 28px;
}
.filter-row { display: flex; align-items: baseline; gap: 12px; padding: 7px 0; }
.filter-row + .filter-row { border-top: 1px solid var(--line-soft); }
.filter-label {
  flex: none; width: 62px; text-transform: uppercase; letter-spacing: 1.5px;
  font-size: 12px; color: var(--gold); padding-top: 5px;
}
.fbtns { display: flex; flex-wrap: wrap; gap: 7px; }
.fbtn {
  font-family: var(--sans); font-size: 13px; cursor: pointer;
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: transparent; color: var(--ink-dim); transition: all .12s;
}
.fbtn:hover { border-color: var(--gold); color: var(--parchment); }
.fbtn.active { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: #1a140b; border-color: transparent; font-weight: 600; }
.filter-count { margin-top: 12px; font-size: 13px; color: var(--ink-faint); text-align: right; }
.filter-count #ncount { color: var(--gold-bright); font-weight: 700; }

/* ---------- nations: card grid ---------- */
.ngrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.ncard {
  display: flex; flex-direction: column; padding: 20px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.ncard:hover { transform: translateY(-3px); border-color: rgba(201,162,75,0.5); box-shadow: 0 12px 30px rgba(0,0,0,0.4); }
.ncard-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.ncard .ntype { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.ncard .nrange { font-size: 12px; color: var(--ink-faint); font-family: var(--sans); }
.ncard h3 { font-size: 20px; margin: 0 0 6px; color: var(--parchment); }
.ncard .ncap { font-size: 13px; color: var(--ink-faint); margin-bottom: 9px; }
.ncard p { color: var(--ink-dim); font-size: 14.5px; line-height: 1.6; margin: 0 0 14px; flex: 1; }
.nmeta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ntag {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--ink-dim); background: rgba(201,162,75,0.06);
}
.ntag.ghost { background: transparent; color: var(--ink-faint); }
a.ntag:hover { border-color: var(--gold); color: var(--parchment); }
.nread { margin-left: auto; font-size: 13px; color: var(--gold-bright); font-weight: 600; }
.nempty { text-align: center; color: var(--ink-faint); padding: 50px 0; font-style: italic; }
.ncard.has-profile { border-color: rgba(201,162,75,0.42); box-shadow: inset 0 0 0 1px rgba(201,162,75,0.10); }
.nbadge {
  display: inline-block; vertical-align: middle; margin-left: 9px;
  font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: #1a140b; background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-radius: 20px; padding: 2px 9px; position: relative; top: -2px;
}

/* ---------- museum-grade profile page ---------- */
.pf-hero {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(900px 380px at 78% -30%, rgba(201,162,75,0.16), transparent 60%),
    linear-gradient(180deg, rgba(201,162,75,0.05), transparent 70%);
  padding: 26px 0 40px;
}
.pf-hero .breadcrumb { margin-bottom: 22px; }
.pf-kicker { text-transform: uppercase; letter-spacing: 2.5px; font-size: 12px; color: var(--gold); margin-bottom: 12px; }
.pf-hero h1 { font-size: clamp(38px, 6vw, 68px); margin: 0; line-height: 1.05; }
.pf-tagline { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 2.3vw, 24px); color: var(--ink-dim); margin: 18px 0 0; max-width: 760px; }

.pf-body { display: grid; grid-template-columns: 300px 1fr; gap: 44px; align-items: start; padding-top: 44px; padding-bottom: 20px; }
@media (max-width: 900px) { .pf-body { grid-template-columns: 1fr; gap: 30px; } }

.pf-facts {
  position: sticky; top: 84px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  padding: 22px 22px 8px; overflow: hidden;
}
@media (max-width: 900px) { .pf-facts { position: static; } }
.pf-facts-title { font-family: var(--serif); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 16px; }
.pf-facts dl { margin: 0; }
.pf-facts .fact { padding: 11px 0; border-top: 1px solid var(--line-soft); }
.pf-facts .fact:first-child { border-top: none; }
.pf-facts dt { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 3px; }
.pf-facts dd { margin: 0; font-size: 15px; color: var(--parchment); line-height: 1.5; }

.pf-main { min-width: 0; }
.pf-map {
  margin: 0 0 34px; padding: 18px; border: 1px solid var(--line); border-radius: 16px;
  background: radial-gradient(700px 300px at 60% 30%, rgba(201,162,75,0.06), transparent 70%), var(--bg-soft);
}
.pf-map svg { display: block; width: 100%; height: auto; }
.pf-map .wm-land polygon { fill: rgba(138,124,100,0.14); stroke: var(--line); stroke-width: 1.2; stroke-linejoin: round; }
.pf-map .wm-hl { fill: rgba(201,162,75,0.28); stroke: var(--gold-bright); stroke-width: 1.5; }
.pf-map .wm-cap { fill: var(--gold-bright); }
.pf-map .wm-cap-ring { fill: none; stroke: var(--gold-bright); stroke-width: 1.5; opacity: 0.5; }
.pf-map figcaption { margin-top: 10px; font-size: 12.5px; color: var(--ink-faint); font-style: italic; text-align: center; }
.pf-section { margin-bottom: 40px; }
.pf-section h2 { font-size: clamp(22px, 3vw, 28px); margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.pf-section p { color: var(--ink); margin: 0 0 16px; }

.pf-timeline { list-style: none; margin: 0; padding: 0; }
.pf-timeline li { display: flex; gap: 18px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.pf-timeline li:first-child { border-top: none; }
.pf-year { flex: none; width: 108px; font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--gold-bright); text-align: right; }
.pf-event { color: var(--ink-dim); }

.pf-rulers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pf-ruler { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: rgba(28,23,18,0.5); }
.pf-ruler-name { font-family: var(--serif); font-size: 18px; color: var(--parchment); }
.pf-ruler-note { font-size: 13px; color: var(--ink-faint); margin-top: 3px; }

.pf-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pf-rel { display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel); transition: transform .15s, border-color .15s; }
.pf-rel:hover { transform: translateY(-2px); border-color: rgba(201,162,75,0.55); }
.pf-rel-name { font-family: var(--serif); font-size: 17px; color: var(--parchment); }
.pf-rel-range { font-size: 12px; color: var(--ink-faint); }

/* ---------- modern-country classification ---------- */
.ntag.country { border-color: rgba(201,162,75,0.4); color: var(--gold-bright); background: rgba(201,162,75,0.10); }
.ntag.country:hover { border-color: var(--gold); color: var(--parchment); }
.country-index { display: flex; flex-direction: column; gap: 8px; }
.country-region { margin-bottom: 14px; }
.country-region h2 { font-size: 20px; color: var(--gold); margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.country-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 15px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--parchment); font-family: var(--serif); font-size: 17px;
  transition: transform .15s, border-color .15s;
}
.country-chip:hover { transform: translateY(-2px); border-color: rgba(201,162,75,0.55); color: var(--parchment); }
.country-chip .cc-count {
  font-family: var(--sans); font-size: 13px; color: var(--bg);
  background: var(--gold); border-radius: 20px; padding: 2px 10px; font-weight: 700; flex: none;
}
