/* typography.css - Optical Sizing, Dropcaps, Literary & List Formatting */

.prose {
  font-family: var(--font-serif);
  font-size: 1.125rem; /* 18px refined reading size */
  line-height: 1.8;
  color: var(--text-main);
  letter-spacing: -0.003em;
}

.prose p {
  margin-bottom: 1.2rem;
  text-align: justify;
}

.prose strong,
.prose b {
  font-weight: 600;
  color: var(--text-main);
}

/* Inline Glossary Term & Interactive Popover */
.glossary-term {
  color: inherit;
  font-weight: inherit;
  text-decoration: underline dotted 1px rgba(100, 116, 139, 0.4);
  text-underline-offset: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  display: inline;
}

.glossary-term:hover {
  text-decoration: underline solid 1px var(--primary);
  color: inherit;
  background-color: transparent;
}

/* Floating Glossary 5-Axis Popover */
.glossary-popover {
  position: absolute;
  z-index: 1000;
  width: 360px;
  max-width: 92vw;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  box-shadow: 0 14px 35px -5px rgba(0, 0, 0, 0.25), 0 10px 15px -6px rgba(0, 0, 0, 0.15);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-main);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.glossary-popover.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.glossary-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}

.glossary-popover-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--primary);
}

.glossary-popover-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  text-transform: uppercase;
}

.glossary-axis-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.glossary-axis-item {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--text-main);
}

.glossary-axis-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.glossary-axis-hestini {
  margin-top: 0.35rem;
  padding: 0.4rem 0.6rem;
  background-color: rgba(234, 88, 12, 0.06);
  border: 1px dashed rgba(234, 88, 12, 0.25);
  border-radius: 6px;
  font-size: 0.75rem;
  color: #9a3412;
}

[data-theme="dark"] .glossary-axis-hestini {
  background-color: rgba(234, 88, 12, 0.15);
  border-color: rgba(234, 88, 12, 0.4);
  color: #fdba74;
}

/* Chapter Bottom CTA to Open Use Case Drawer */
.chapter-usecase-cta {
  margin: 2rem 0 1rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.06) 0%, rgba(59, 130, 246, 0.06) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.chapter-usecase-cta-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.chapter-usecase-cta-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chapter-usecase-cta-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.btn-open-usecase-drawer {
  background: linear-gradient(135deg, var(--primary) 0%, #d97706 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.15rem;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(234, 88, 12, 0.25);
}

.btn-open-usecase-drawer:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
  background: linear-gradient(135deg, #c2410c 0%, #b45309 100%);
}

/* Chapter Kicker & Title */
.kicker {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 0.5rem;
  display: inline-block;
}

.chapter-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.chapter-hook {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-muted);
  border-left: 3px solid var(--primary);
  padding: 0.25rem 0 0.25rem 1rem;
  margin: 1rem 0 1.75rem;
}

/* Chapter Illustrations */
.chapter-illustration {
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-md);
}

.chapter-illustration img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.chapter-illustration figcaption {
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-style: italic;
}

/* Hexagram Card - Giao diện Quẻ Dịch Tinh Hoa */
.hexagram-card {
  background: linear-gradient(145deg, #1e222d 0%, #11141c 100%) !important;
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 1.75rem;
  color: #f1f5f9 !important;
}

.hexagram-card .hexagram-visual {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 90px;
  flex-shrink: 0;
}

.hexagram-card .hex-line-yang {
  height: 9px;
  background: linear-gradient(90deg, #fbbf24, #d97706);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.hexagram-card .hex-line-yin {
  display: flex;
  justify-content: space-between;
  height: 9px;
}

.hexagram-card .hex-line-yin span {
  width: 40px;
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #d97706);
  border-radius: 4px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.hexagram-card .hexagram-info {
  flex: 1;
}

.hexagram-card .hexagram-badge {
  font-size: 0.6875rem;
  font-weight: 800;
  color: #fbbf24 !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.hexagram-card .hexagram-name {
  font-family: var(--font-display, sans-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff !important;
  margin-bottom: 0.45rem;
  letter-spacing: -0.01em;
}

.hexagram-card .hexagram-trigrams {
  font-size: 0.875rem;
  color: #e2e8f0 !important;
  line-height: 1.6;
}

.hexagram-card .hexagram-trigrams div {
  color: #cbd5e1 !important;
}

.hexagram-card .hexagram-trigrams strong {
  color: #fcd34d !important;
  font-weight: 700;
  margin-right: 0.35rem;
}

/* Section Headings inside Novel */
.prose h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin: 2rem 0 1rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

.prose h3 {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-main);
  margin: 1.5rem 0 0.75rem;
}

/* Literary Drop Cap */
.prose > p:first-of-type::first-letter,
.prose section > p:first-of-type::first-letter {
  font-family: var(--font-serif);
  float: left;
  font-size: 3.4em;
  line-height: 0.78;
  margin: 0.08em 0.12em 0 0;
  color: var(--primary);
  font-weight: 700;
}

/* Quotes & Dialogues */
.prose blockquote {
  font-style: italic;
  border-left: 2px solid var(--border-medium);
  padding: 0.35rem 0 0.35rem 1rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
}

.prose strong {
  font-weight: 600;
  color: var(--text-main);
}

.prose em {
  font-style: italic;
}

/* Horizontal Rule Divider */
.prose hr {
  border: none;
  height: 1px;
  background-color: var(--border-subtle);
  margin: 1.75rem 0 1.5rem;
  text-align: center;
  position: relative;
}

.prose hr::after {
  content: "§ § §";
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.4em;
  color: var(--text-faint);
  background-color: var(--bg-app);
  padding: 0 0.75rem;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.prose hr + h2 {
  margin-top: 1rem;
}

/* ---------------------------------------------------- */
/* LISTS & BULLETS */
/* ---------------------------------------------------- */

.styled-list {
  margin: 1rem 0 1.5rem;
  padding: 0;
  list-style: none;
}

/* Unordered Lists */
.styled-list.unordered {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.styled-list.unordered > li {
  position: relative;
  padding-left: 1.5rem;
  line-height: 1.7;
  font-size: 1.0625rem;
  color: var(--text-main);
  text-align: justify;
}

.styled-list.unordered > li::before {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 0.65em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--primary);
}

/* Ordered Lists */
.styled-list.ordered {
  counter-reset: custom-counter;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.styled-list.ordered > li {
  counter-increment: custom-counter;
  position: relative;
  padding-left: 2.25rem;
  line-height: 1.7;
  font-size: 1.0625rem;
  color: var(--text-main);
  text-align: justify;
}

.styled-list.ordered > li::before {
  content: counter(custom-counter);
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background-color: var(--primary-subtle);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(26, 86, 219, 0.2);
}

/* Action Card Lists */
.action-card .styled-list {
  margin: 0.25rem 0 0;
}

.action-card .styled-list.ordered > li {
  font-size: 0.9375rem;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.action-card .styled-list.ordered > li::before {
  background-color: var(--amber-subtle);
  color: var(--amber);
  border-color: rgba(180, 83, 9, 0.25);
}

/* Tables inside Novel */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.55;
  text-align: left;
}

thead {
  background-color: var(--bg-subtle);
}

th {
  color: var(--text-main);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-subtle);
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--bg-hover);
}
