/* =====================
   DESIGN TOKENS
===================== */
:root {
  --bg:         #f5f0e8;
  --surface:    #ffffff;
  --ink:        #1c1a14;
  --ink-light:  #3a3528;
  --gold:       #a07830;
  --gold-light: #c9a75a;
  --text:       #2d2a22;
  --muted:      #6b6455;
  --border:     #ddd5c0;
  --radius:     8px;
}

/* =====================
   RESET & BASE
===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

a { color: inherit; text-decoration: none; }

/* =====================
   SKIP LINK
===================== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--gold);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 4px 4px;
  font-weight: bold;
  z-index: 9999;
}

.skip-link:focus {
  top: 0;
}

/* =====================
   PORTAL BAR
===================== */
.portal-bar {
  background: var(--ink);
  padding: 0.45rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.portal-bar-link {
  font-size: 0.78rem;
  color: var(--gold-light);
  letter-spacing: 0.06em;
  transition: color 0.2s;
}

.portal-bar-link:hover {
  color: #ffffff;
}

/* =====================
   HEADER
===================== */
header {
  background: var(--ink);
  color: #fff;
  padding: 2rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

header h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold-light);
  margin: 0;
  line-height: 1.3;
}

/* Nav links (hexagram prev/next, back link) */
header nav a,
header .back-link,
.back-link {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.2s;
}

header nav a:hover,
header .back-link:hover,
.back-link:hover {
  color: var(--gold-light);
  text-decoration: none;
}

.hex-nav {
  display: flex;
  width: 100%;
  max-width: 700px;
  justify-content: space-between;
  margin-top: 0.25rem;
}

/* =====================
   HEADINGS
===================== */
h2, h3 {
  font-family: "Noto Serif SC", serif;
  font-weight: 700;
  color: var(--text);
  margin: 1.25rem 0 0.6rem;
}

h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* =====================
   SECTIONS
===================== */
section {
  padding: 2rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* =====================
   HEX GRID & CARDS
===================== */
.hex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  align-items: stretch;
  margin-top: 1rem;
}

.hex-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
  height: 100%;
  box-sizing: border-box;
}

.hex-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  border-color: var(--gold);
}

.hex-card-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.hex-card h3 {
  margin: 0 0 0.4rem 0;
  color: var(--ink-light);
  font-size: 1rem;
  font-family: "Noto Serif SC", serif;
}

.hex-card p {
  margin: 0 0 0.4rem 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Focus indicators */
.hex-card-link:focus-visible,
.back-link:focus-visible,
.listen-btn:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* =====================
   HEXAGRAM DETAIL PAGE
===================== */
.hexagram-detail {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem 3rem;
}

.hexagram-detail h2 {
  font-family: "Noto Serif SC", serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 1.5rem 0 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.hexagram-detail ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.hexagram-detail p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.8;
}

/* =====================
   YAO LINES
===================== */
.yao {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  color: var(--text);
}

.yao h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.4rem 0;
}

.yao p {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

/* =====================
   LUCK LEVELS
   (WCAG-compliant on --surface #ffffff)
===================== */
.luck           { font-weight: 600; font-size: 0.85rem; }
.luck-excellent { color: #7a5900; }   /* dark gold  — 元吉/大吉 */
.luck-good      { color: #1a6b36; }   /* dark green — 吉        */
.luck-neutral   { color: #555;    }   /* grey       — 无咎/亨   */
.luck-caution   { color: #994d00; }   /* dark amber — 悔/吝     */
.luck-misfortune{ color: #b22222; }   /* deep red   — 凶        */

/* =====================
   CHINESE TEXT
===================== */
.chinese {
  font-family: "Noto Serif SC", serif;
  font-size: 1.05rem;
  color: var(--text);
  font-style: normal;
  letter-spacing: 0.05em;
}

/* =====================
   LISTEN BUTTON
===================== */
.listen-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.45rem 0.9rem;
  min-height: 40px;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: "Noto Sans SC", sans-serif;
  transition: background 0.2s;
}

.listen-btn:hover {
  background: #8a6828;
}

/* =====================
   TRIGRAM SECTION PAGE
   (qian, kun, etc. — plain <section>)
===================== */
section h2 {
  font-family: "Noto Serif SC", serif;
  font-weight: 700;
  color: var(--text);
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

section p,
section li {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.8;
}

section ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

/* =====================
   FOOTER
===================== */
footer {
  background: var(--ink);
  color: rgba(255,255,255,0.35);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  margin-top: 2rem;
}

/* =====================
   HEADER CHINESE SUBTITLE
===================== */
.header-zh {
  font-family: "Noto Serif SC", serif;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.2em;
  margin-top: 0.2rem;
}

/* =====================
   FOOTER PORTAL LINK
===================== */
.footer-portal-link {
  display: block;
  color: rgba(255,255,255,0.45);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
  transition: color 0.2s;
}
.footer-portal-link:hover { color: var(--gold-light); }

/* =====================
   RESPONSIVE
===================== */
@media (max-width: 600px) {
  header { padding: 1.5rem 1rem; }
  header h1 { font-size: 1.4rem; }
  .hex-grid { grid-template-columns: 1fr; }
  section { padding: 1.5rem 1rem; }
  .hexagram-detail { padding: 0 1rem 2rem; }
}
