/* ============================================
   The Mental Game of Poker — 學習網頁
   設計：暗色沉穩 × 紫色強調 × 編輯型版面
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Noto+Serif+TC:wght@400;600;700&family=Noto+Sans+TC:wght@300;400;500;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #0d0d12;
  --bg-card: #16161e;
  --bg-card-hover: #1c1c26;
  --border: #2a2a35;
  --border-strong: #3a3a48;
  --text: #e8e8f0;
  --text-soft: #b8b8c4;
  --text-mute: #7a7a88;
  --accent: #a78bfa;
  --accent-strong: #c4b5fd;
  --accent-deep: #6d28d9;
  --gold: #fbbf24;
  --gold-soft: #fcd34d;
  --danger: #f87171;
  --success: #4ade80;
  --serif-en: 'Cormorant Garamond', serif;
  --serif-tc: 'Noto Serif TC', serif;
  --sans-tc: 'Noto Sans TC', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans-tc);
  font-weight: 300;
  line-height: 1.75;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(167, 139, 250, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(109, 40, 217, 0.05) 0%, transparent 50%);
}

/* ===== Layout ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

.narrow {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Top Navigation ===== */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 13, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}

.topnav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.brand {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-strong);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.brand-tc {
  font-family: var(--serif-tc);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-soft);
  margin-left: 12px;
  letter-spacing: 0.05em;
}

.topnav a.home-link {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  padding: 6px 16px;
  border-radius: 100px;
  transition: all 0.2s;
}

.topnav a.home-link:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
}

.topnav-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.lang-toggle {
  font-family: var(--serif-tc);
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border-strong);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.1em;
  min-width: 64px;
}

.lang-toggle:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
}

.lang-toggle.active {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.08);
}

.lang-toggle.loading {
  opacity: 0.6;
  cursor: wait;
}

/* ===== Hero ===== */
.hero {
  padding: 100px 0 80px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 24px;
}

.hero-title-en {
  font-family: var(--serif-en);
  font-size: clamp(48px, 7vw, 84px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 16px;
}

.hero-title-en em {
  font-style: italic;
  color: var(--accent-strong);
}

.hero-title-tc {
  font-family: var(--serif-tc);
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 400;
  color: var(--text-soft);
  letter-spacing: 0.05em;
  margin-bottom: 32px;
}

.hero-meta {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-mute);
  font-family: var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-meta span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-meta span::before {
  content: '◆';
  color: var(--accent);
  font-size: 8px;
}

.hero-intro {
  max-width: 680px;
  margin: 56px auto 0;
  font-size: 17px;
  color: var(--text-soft);
  line-height: 1.85;
}

.hero-lang-note {
  max-width: 520px;
  margin: 28px auto 0;
  padding: 14px 24px;
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.9;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: rgba(167, 139, 250, 0.04);
}

.hero-lang-note strong {
  color: var(--accent-strong);
  font-weight: 600;
  font-family: var(--serif-tc);
}

/* ===== Chapter Index Grid ===== */
.section-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-label::before,
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-label::before { max-width: 60px; }

.section-title {
  font-family: var(--serif-tc);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  color: var(--text);
}

.section-subtitle {
  text-align: center;
  color: var(--text-mute);
  font-size: 15px;
  margin-bottom: 56px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 80px 0;
}

.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 32px 28px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 0;
  background: var(--accent);
  transition: height 0.3s;
}

.chapter-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.chapter-card:hover::before { height: 100%; }

.chapter-num {
  font-family: var(--serif-en);
  font-size: 56px;
  font-weight: 400;
  font-style: italic;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 16px;
  display: block;
}

.chapter-card-title {
  font-family: var(--serif-tc);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.chapter-card-subtitle {
  font-family: var(--serif-en);
  font-size: 14px;
  font-style: italic;
  color: var(--text-mute);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.chapter-card-desc {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.7;
}

.chapter-card-arrow {
  margin-top: 20px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.2em;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Chapter Page Hero ===== */
.ch-hero {
  padding: 80px 0 60px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.ch-hero-num {
  font-family: var(--serif-en);
  font-size: clamp(120px, 18vw, 220px);
  font-weight: 400;
  font-style: italic;
  line-height: 1;
  color: rgba(167, 139, 250, 0.08);
  position: absolute;
  top: 20px;
  right: -10px;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.ch-eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.ch-title-en {
  font-family: var(--serif-en);
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 600;
  font-style: italic;
  line-height: 1.05;
  color: var(--text);
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.ch-title-tc {
  font-family: var(--serif-tc);
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 600;
  color: var(--accent-strong);
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.ch-tagline {
  font-family: var(--serif-tc);
  font-size: 18px;
  font-weight: 400;
  color: var(--text-soft);
  font-style: italic;
  max-width: 640px;
  line-height: 1.7;
  border-left: 2px solid var(--accent);
  padding-left: 20px;
  position: relative;
  z-index: 1;
}

/* ===== Content Sections ===== */
.ch-section {
  padding: 64px 0;
  border-bottom: 1px solid var(--border);
}

.ch-section:last-of-type { border-bottom: none; }

h2.section-h {
  font-family: var(--serif-tc);
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 16px;
}

h2.section-h .num {
  font-family: var(--serif-en);
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
  font-size: 24px;
}

.section-h-en {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 16px;
  color: var(--text-mute);
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}

h3.sub-h {
  font-family: var(--serif-tc);
  font-size: 22px;
  font-weight: 600;
  margin: 40px 0 16px;
  color: var(--accent-strong);
}

p {
  margin-bottom: 18px;
  color: var(--text-soft);
}

p strong, .text strong {
  color: var(--text);
  font-weight: 500;
}

p em, .text em {
  color: var(--accent-strong);
  font-style: italic;
}

/* ===== Pull Quote / Highlight Box ===== */
.pull-quote {
  font-family: var(--serif-tc);
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
  color: var(--accent-strong);
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  padding: 28px 0;
  margin: 40px 0;
  text-align: center;
  line-height: 1.6;
}

.callout {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.08), rgba(109, 40, 217, 0.04));
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  padding: 24px 28px;
  margin: 32px 0;
  border-radius: 2px;
}

.callout-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.callout-title {
  font-family: var(--serif-tc);
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}

/* ===== Concept Cards (numbered list as visual cards) ===== */
.concept-list {
  display: grid;
  gap: 16px;
  margin: 32px 0;
}

.concept-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px 28px;
  border-radius: 2px;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 24px;
  align-items: start;
  transition: border-color 0.2s;
}

.concept-item:hover {
  border-color: var(--accent);
}

.concept-item .num {
  font-family: var(--serif-en);
  font-size: 36px;
  font-style: italic;
  color: var(--accent);
  line-height: 1;
  font-weight: 400;
}

.concept-item .body h4 {
  font-family: var(--serif-tc);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.concept-item .body .en {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 14px;
  color: var(--text-mute);
  margin-bottom: 12px;
  display: block;
}

.concept-item .body p {
  font-size: 15px;
  margin: 0;
}

/* ===== Diagrams ===== */
.diagram-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 36px;
  margin: 32px 0;
  border-radius: 2px;
  text-align: center;
}

.diagram-wrap svg {
  max-width: 100%;
  height: auto;
}

.diagram-caption {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 20px;
}

/* ===== Flashcards ===== */
.flashcards-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 32px 0;
}

.flashcard {
  perspective: 1000px;
  height: 200px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 4px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--border);
  overflow: hidden;
}

.flashcard-front {
  background: var(--bg-card);
  text-align: center;
  transform: rotateY(0deg);
  -webkit-transform: rotateY(0deg);
}

/* === FIX: hide front face content after flip to prevent text bleed-through === */
.flashcard-front > * {
  transition: opacity 0.15s ease;
}
.flashcard.flipped .flashcard-front > * {
  opacity: 0;
  transition: opacity 0.15s ease 0.3s;
}

/* === Secondary flashcard structure (used in ch8 + appendix) === */
.flashcards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 32px 0;
}
.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 4px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--border);
  overflow: hidden;
}
.flashcard-face.flashcard-front {
  background: var(--bg-card);
  text-align: center;
  transform: rotateY(0deg);
}
.flashcard-face.flashcard-back {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(109, 40, 217, 0.12)), #14141c;
  border: 1px solid var(--accent-deep);
  transform: rotateY(180deg);
  text-align: left;
  overflow-y: auto;
}
.flashcard-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--accent-strong);
  margin-bottom: 12px;
}
.flashcard-front .flashcard-label {
  text-align: center;
}
.flashcard-text {
  font-family: var(--serif-tc);
  font-size: 16px;
  color: var(--text);
  line-height: 1.6;
}
.flashcard-front .flashcard-text {
  font-weight: 600;
  font-size: 17px;
}
.flashcard-back .flashcard-text {
  font-size: 14px;
  font-weight: 400;
  font-family: var(--sans-tc);
  line-height: 1.65;
}
/* Apply same fade-fix to secondary structure */
.flashcard-face.flashcard-front > * {
  transition: opacity 0.15s ease;
}
.flashcard.flipped .flashcard-face.flashcard-front > * {
  opacity: 0;
  transition: opacity 0.15s ease 0.3s;
}

.flashcard-front .term {
  font-family: var(--serif-tc);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.flashcard-front .term-en {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 15px;
  color: var(--accent-strong);
  margin-bottom: 16px;
}

.flashcard-front .hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: auto;
}

.flashcard-back {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(109, 40, 217, 0.12)), #14141c;
  border: 1px solid var(--accent-deep);
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  font-size: 14px;
  color: var(--text);
  line-height: 1.65;
  text-align: left;
  overflow-y: auto;
}

/* ===== Quiz ===== */
.quiz-wrap {
  display: grid;
  gap: 16px;
  margin: 32px 0;
}

.quiz-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.quiz-q {
  padding: 22px 28px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  user-select: none;
}

.quiz-q-num {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
  line-height: 1.4;
}

.quiz-q-text {
  font-family: var(--serif-tc);
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
  line-height: 1.6;
  flex: 1;
}

.quiz-toggle {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.15em;
  border: 1px solid var(--border-strong);
  padding: 4px 10px;
  border-radius: 100px;
  transition: all 0.2s;
}

.quiz-q:hover .quiz-toggle {
  background: var(--accent-deep);
  color: var(--text);
  border-color: var(--accent);
}

.quiz-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
  padding: 0 28px;
  background: rgba(167, 139, 250, 0.04);
  border-top: 1px solid transparent;
}

.quiz-item.open .quiz-a {
  max-height: 600px;
  padding: 22px 28px 26px;
  border-top: 1px solid var(--border);
}

.quiz-a-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.quiz-a-text {
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.75;
}

/* ===== Tags / Pills ===== */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
}

.tag {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-strong);
  background: rgba(167, 139, 250, 0.08);
  border: 1px solid rgba(167, 139, 250, 0.2);
  padding: 4px 12px;
  border-radius: 100px;
  letter-spacing: 0.05em;
}

/* ===== Footer / Citation ===== */
.cite-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 32px;
  margin: 48px 0 0;
  border-radius: 2px;
}

.cite-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.cite-text {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.7;
}

.cite-text strong { color: var(--text); }

footer {
  border-top: 1px solid var(--border);
  padding: 48px 0 64px;
  margin-top: 80px;
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ===== Chapter nav (prev/next) ===== */
.ch-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 48px 0 0;
}

.ch-nav a {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px 28px;
  border-radius: 2px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}

.ch-nav a:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.ch-nav .label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.ch-nav .title {
  font-family: var(--serif-tc);
  font-weight: 600;
  font-size: 16px;
}

.ch-nav .next { text-align: right; }

/* ===== Tilt Type Cards (for chapter 5) ===== */
.tilt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin: 32px 0;
}

.tilt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 4px;
  border-top: 3px solid var(--accent);
  position: relative;
}

.tilt-card.t1 { border-top-color: #f87171; }
.tilt-card.t2 { border-top-color: #fb923c; }
.tilt-card.t3 { border-top-color: #fbbf24; }
.tilt-card.t4 { border-top-color: #a3e635; }
.tilt-card.t5 { border-top-color: #34d399; }
.tilt-card.t6 { border-top-color: #60a5fa; }
.tilt-card.t7 { border-top-color: #c084fc; }

.tilt-card .name-en {
  font-family: var(--serif-en);
  font-style: italic;
  font-size: 14px;
  color: var(--text-mute);
  margin-bottom: 4px;
}

.tilt-card .name-tc {
  font-family: var(--serif-tc);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.tilt-card .trigger {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 12px;
}

.tilt-card .root {
  font-size: 13px;
  color: var(--accent-strong);
  border-top: 1px dashed var(--border-strong);
  padding-top: 12px;
  font-style: italic;
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .container, .narrow { padding: 0 20px; }
  .topnav-inner { padding: 0 20px; }
  .hero { padding: 60px 0 50px; }
  .ch-hero { padding: 50px 0 40px; }
  .ch-section { padding: 48px 0; }
  .ch-nav { grid-template-columns: 1fr; }
  .concept-item { grid-template-columns: 1fr; gap: 12px; }
  .concept-item .num { font-size: 28px; }
  .chapter-grid { padding: 48px 0; }
  .ch-hero-num { font-size: 120px; right: -20px; }
}
