/**
 * Component Styles
 * Reusable UI components
 */

/* ===== TYPOGRAPHY COMPONENTS ===== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-md);
  margin-top: 32px;
}

/* Remove top margin from first heading */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
  margin-top: 0;
}

/* Section titles (H2) - larger sizing */
h2 {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 300;
  font-size: 42px;
  line-height: 52px;
  margin-top: 64px;
}

/* Remove top margin from first H2 */
h2:first-child {
  margin-top: 0;
}

/* Sub-section titles (H3) - summary descriptions */
h3 {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 300;
  font-size: 32px;
  line-height: 40px;
  color: #263C91;
}

h4 {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 300;
  font-size: 24px;
  line-height: 28px;
  color: #263C91;
  margin-bottom: -10px;
}

p {
  margin-bottom: var(--spacing-md);
  line-height: var(--line-height-relaxed);
}

/* Dark mode - brighter headings */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
  color: #E8EAEF;
}

/* H3 in dark mode - lighter blue for better visibility */
[data-theme="dark"] h3 {
  color: #A8B1D3;
}

/* Mobile typography overrides */
@media (max-width: 767px) {
  h2 {
    font-size: 32px !important;
    line-height: 40px !important;
    margin-top: 42px !important;
  }
}

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-display);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-body);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  min-height: 44px; /* Touch-friendly */
}

.btn-primary {
  background: var(--color-cta-purple);
  color: var(--color-white);
}

.btn-primary:hover {
  background: var(--color-esentire-blue-100);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ===== NAVIGATION COMPONENTS ===== */

.nav-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Back link */
.back-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-family: var(--font-display);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--color-text-primary);
  transition: color var(--transition-base);
}

.back-link:hover {
  color: var(--color-cta-purple);
}

.arrow-left-icon {
  transition: transform var(--transition-base);
}

.back-link:hover .arrow-left-icon {
  transform: translateX(-2px);
}

/* Book header */
.book-header {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.book-title {
  font-family: var(--font-display);
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  margin: 0;
}

.book-subtitle {
  font-family: var(--font-display);
  font-size: var(--font-size-h4);
  font-weight: var(--font-weight-light);
  line-height: var(--line-height-normal);
  color: var(--color-text-secondary);
  margin: 0;
}

.book-author {
  font-family: var(--font-body);
  font-size: var(--font-size-body-large);
  color: var(--color-text-primary);
  margin: 0;
}

/* Download button */
.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-cta-purple);
  color: var(--color-white);
  font-family: var(--font-display);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-base);
  min-height: 44px;
}

.download-btn:hover {
  background: var(--color-esentire-blue-100);
  transform: translateY(-1px);
}

.download-icon {
  transition: transform var(--transition-base);
}

.download-btn:hover .download-icon {
  transform: translateY(2px);
}

/* Nav divider */
.nav-divider {
  border: none;
  height: 1px;
  background: var(--color-border);
  margin: 0;
}

/* ===== CHAPTER NAVIGATION ===== */

.chapter-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chapter-item {
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0;
}

.chapter-item:first-child {
  padding-top: 0;
}

.chapter-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0;
  text-align: left;
  cursor: pointer;
  background: transparent;
  border: none;
}

.chapter-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  cursor: pointer;
}

/* Chapter number in navigation */
.chapter-trigger .chapter-number {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: var(--font-weight-medium);
  line-height: 22px;
  color: var(--color-cta-purple);
  text-transform: uppercase;
  letter-spacing: 3.5px;
  margin: 0;
}

/* Chapter title in navigation - NOT the gradient version */
.chapter-trigger .chapter-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: var(--font-weight-regular);
  line-height: 28px;
  color: var(--color-text-primary);
  text-transform: capitalize;
  margin: 0;
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: unset;
  background-clip: unset;
  text-fill-color: unset;
  transition: color var(--transition-base);
}

.chapter-trigger:hover .chapter-title {
  color: var(--color-cta-purple);
}

/* Accordion icons */
.accordion-icon {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  transition: opacity 200ms var(--transition-timing),
              transform 200ms var(--transition-timing);
  color: var(--color-text-primary);
  filter: none;
}

/* Dark mode: Make icons white */
[data-theme="dark"] .accordion-icon {
  filter: brightness(0) invert(1);
}

/* Show plus by default, minus when expanded */
.chapter-item .icon-plus {
  display: block;
}

.chapter-item .icon-minus {
  display: none;
}

.chapter-item.expanded .icon-plus {
  display: none;
}

.chapter-item.expanded .icon-minus {
  display: block;
}

/* Chapter sections */
.chapter-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 0;
  padding-left: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: max-height 400ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 350ms cubic-bezier(0.4, 0, 0.2, 1),
              transform 400ms cubic-bezier(0.4, 0, 0.2, 1),
              margin-top 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-item.expanded .chapter-sections {
  max-height: 1000px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 16px;
}

/* Section links */
.section-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  text-decoration: none;
  transition: opacity var(--transition-base);
}

.section-link:hover {
  opacity: 0.7;
}

.section-bookmark {
  flex-shrink: 0;
  width: 20px !important;
  height: 20px !important;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1),
              transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Show bookmark for active section */
.section-link.active .section-bookmark {
  opacity: 1;
  transform: scale(1);
}

.section-title {
  flex: 1;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: var(--font-weight-regular);
  line-height: 24px;
  color: var(--color-text-primary);
}

.chapter-label {
  flex: 1;
  text-transform: capitalize;
}

.expand-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.chapter-item[aria-expanded="true"] .expand-icon {
  transform: rotate(45deg);
}

.section-list {
  padding: 8px 0 0 0;
  display: none;
  list-style: none;
}

.chapter-item[aria-expanded="true"] .section-list {
  display: block;
}

.chapter-item:first-child .chapter-trigger .chapter-title {
  display: none;
}

.section-list li {
  margin-bottom: 4px;
}

.section-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 28px;
  color: var(--color-text-primary);
  transition: all var(--transition-base);
  text-decoration: none;
}

.section-list a:hover {
  color: var(--color-cta-purple);
}

.section-list a[aria-current="true"] {
  color: var(--color-cta-purple);
  font-weight: var(--font-weight-regular);
}

/* Bookmark icon for active section */
.section-list a[aria-current="true"]::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: var(--color-cta-purple);
  mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="M3.75 3.75v12.5l6.25-3.75 6.25 3.75V3.75H3.75z" fill="currentColor"/></svg>');
  mask-size: contain;
  mask-repeat: no-repeat;
  flex-shrink: 0;
}

/* ===== THEME TOGGLE SWITCH ===== */

.theme-toggle-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 0;
  border-radius: 0;
  transition: all var(--transition-base);
}

.theme-toggle-switch:focus-visible {
  outline: 2px solid var(--color-cta-purple);
  outline-offset: 2px;
}

/* Theme icons */
.theme-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  transition: opacity var(--transition-base), transform var(--transition-base);
  margin: 0 !important;
}

/* Remove margin from all images in theme toggle */
.theme-toggle-switch img {
  margin: 0 !important;
}

/* Toggle switch container */
.theme-switch {
  position: relative;
  width: 40px;
  height: 20px;
  flex-shrink: 0;
}

/* Switch track (background) */
.theme-switch-track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 10px;
  transition: background-color var(--transition-base);
}

/* Switch thumb (sliding circle) */
.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--color-surface);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-smooth);
}

/* Light mode state (default) */
[data-theme="light"] .theme-toggle-switch .sun-icon {
  opacity: 1;
}

[data-theme="light"] .theme-toggle-switch .moon-icon {
  opacity: 0.3;
}

[data-theme="light"] .theme-switch-track {
  background: rgba(80, 99, 249, 0.1);
}

[data-theme="light"] .theme-switch-thumb {
  transform: translateX(0);
  background: #5063F9;
  box-shadow: 0 2px 4px rgba(80, 99, 249, 0.3);
}

/* Dark mode state */
[data-theme="dark"] .theme-toggle-switch .sun-icon {
  opacity: 0.3;
}

[data-theme="dark"] .theme-toggle-switch .moon-icon {
  opacity: 1;
}

[data-theme="dark"] .theme-switch-track {
  background: rgba(225, 226, 249, 0.2);
}

[data-theme="dark"] .theme-switch-thumb {
  transform: translateX(20px);
  background: #E1E2F9;
  box-shadow: 0 2px 4px rgba(225, 226, 249, 0.3);
}

/* Hover effects */
.theme-toggle-switch:hover .sun-icon,
.theme-toggle-switch:hover .moon-icon {
  transform: scale(1.1);
}

/* Legacy theme toggle button (mobile header) */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface-secondary);
  color: var(--color-text-primary);
  transition: all var(--transition-base);
  cursor: pointer;
}

.theme-toggle-btn:hover {
  background: var(--color-cta-purple);
  color: var(--color-white);
  transform: rotate(15deg);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Toggle icon visibility based on theme (mobile button) */
[data-theme="light"] .theme-toggle-btn .moon-icon {
  display: none;
}

[data-theme="light"] .theme-toggle-btn .sun-icon {
  display: inline-block;
}

[data-theme="dark"] .theme-toggle-btn .sun-icon {
  display: none;
}

[data-theme="dark"] .theme-toggle-btn .moon-icon {
  display: inline-block;
}

/* ===== CONTENT COMPONENTS ===== */

/* Chapter header */
.chapter-header {
  margin-bottom: var(--spacing-2xl);
}

/* Chapter number in content header (not navigation) */
.chapter-header .chapter-number {
  font-family: var(--font-display);
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--color-cta-purple);
  margin-bottom: var(--spacing-sm);
}

/* Chapter title in content header (with gradient) */
.chapter-header .chapter-title {
  font-family: var(--font-display);
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-light);

  /* NEW GRADIENT v2 - To revert, replace with: linear-gradient(135deg, var(--color-cta-purple), var(--color-esentire-blue-100)) */
  background: linear-gradient(92.66deg, #40C3D9 -8.84%, #8C5FE8 19.1%, #696DE3 47.05%, #263C91 84.31%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-fill-color: transparent;
}

/* Section */
section {
  margin-bottom: var(--spacing-3xl);
}

section h3 {
  font-size: var(--font-size-h2);
  margin-bottom: var(--spacing-lg);
}

section h4 {
  font-size: var(--font-size-h3);
  margin-bottom: var(--spacing-md);
  color: var(--color-esentire-blue-100);
}

/* Lists */
ul, ol {
  margin: var(--spacing-md) 0;
  padding-left: var(--spacing-xl);
}

ul {
  list-style: disc;
}

ol {
  list-style: decimal;
}

li {
  margin-bottom: var(--spacing-sm);
  line-height: var(--line-height-relaxed);
}

/* Images */
img {
  width: 100%;
  height: auto;
  border-radius: var(--border-radius-lg);
  margin: var(--spacing-xl) 0;
}

/* Reset image styling for navigation icons */
.chapter-nav img,
.main-nav img {
  width: auto;
  height: auto;
  border-radius: 0;
  margin: 0;
}

/* Tables - Matching Figma Design */
table {
  width: 100%;
  margin: var(--spacing-xl) 0;
  border-radius: 16px;
  overflow: hidden;
  border-collapse: collapse;
  border: none;
  table-layout: auto;
}

/* Table wrapper for horizontal scrolling - liquid at all sizes */
.table-scroll-wrapper {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--spacing-xl) 0;
  box-sizing: border-box;
}

.table-scroll-wrapper table {
  margin: 0;
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

/* Header row - eSentire Blue background */
thead {
  background: #263C91;
  color: #FFFFFF;
}

thead tr {
  background: #263C91;
}

th {
  padding: 16px 20px;
  text-align: left;
  font-family: 'IBM Plex Serif', serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 28px;
  color: #FFFFFF;
  border: none;
}

/* First cell in header row - minimum width */
th:first-child {
  min-width: 150px;
}

/* Body cells */
td {
  padding: 16px 20px;
  font-family: 'IBM Plex Serif', serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 19px;
  color: #0E142B;
  border: none;
}

/* First cell in body rows - minimum width */
td:first-child {
  min-width: 150px;
}

/* Alternating row colors - matching Figma */
tbody tr:nth-child(odd) {
  background: #F4F5F9; /* eSentire Blue/5 */
}

tbody tr:nth-child(even) {
  background: #FFFFFF;
}

/* Dark mode table styles - Matching Figma Dark Mode Design */
[data-theme="dark"] table thead {
  background: #A8B1D3; /* eSentire Blue/40 */
}

[data-theme="dark"] table thead tr {
  background: #A8B1D3; /* eSentire Blue/40 */
}

[data-theme="dark"] table th {
  background: #A8B1D3; /* eSentire Blue/40 */
  color: #0E142B; /* Dark Navy/100 */
  font-weight: 500; /* Medium weight in dark mode */
}

[data-theme="dark"] table td {
  color: #FFFFFF; /* White text in dark mode */
}

[data-theme="dark"] tbody tr:nth-child(odd) {
  background: #36373B; /* Dark Mode/30 */
}

[data-theme="dark"] tbody tr:nth-child(even) {
  background: #434347; /* Dark Mode/5 */
}

/* Mobile table styles - Sticky first column with horizontal scroll */
@media (max-width: 767px) {
  /* Enable horizontal scrolling with touch support - contained within reading pane */
  .table-scroll-wrapper {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    margin: var(--spacing-xl) 0 !important;
    padding: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    /* Subtle shadow to indicate scrollability */
    box-shadow: inset -8px 0 8px -8px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
  }

  /* Force table to be liquid and fit within container */
  .table-scroll-wrapper table {
    display: table;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    table-layout: auto !important;
    box-sizing: border-box;
  }

  /* Compact font sizes for mobile with word wrapping */
  table th {
    font-size: 11px !important;
    line-height: 15px !important;
    padding: 4px 6px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
  }

  table td {
    font-size: 7px !important;
    line-height: 9px !important;
    padding: 4px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
  }

  /* Sticky first column - header and data cells */
  table th:first-child,
  table td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    box-shadow: 3px 0 5px rgba(0, 0, 0, 0.12);
    white-space: normal !important;
  }

  /* Ensure sticky header cell has proper background and highest z-index */
  table thead th:first-child {
    background: #263C91;
    z-index: 11;
  }

  /* Ensure sticky body cells maintain alternating colors */
  tbody tr:nth-child(odd) td:first-child {
    background: #F4F5F9;
  }

  tbody tr:nth-child(even) td:first-child {
    background: #FFFFFF;
  }

  /* Dark mode sticky cells */
  [data-theme="dark"] table thead th:first-child {
    background: #A8B1D3;
  }

  [data-theme="dark"] tbody tr:nth-child(odd) td:first-child {
    background: #36373B;
  }

  [data-theme="dark"] tbody tr:nth-child(even) td:first-child {
    background: #434347;
  }

  /* First column sizing for mobile - allow natural width with constraints */
  table th:first-child,
  table td:first-child {
    min-width: 80px;
    max-width: 150px;
    width: auto;
  }

  /* Other columns flexible sizing */
  table th:not(:first-child),
  table td:not(:first-child) {
    width: auto;
    min-width: 60px;
  }
}

/* Tablet & Small Desktop - Liquid tables with sticky first column */
@media (min-width: 768px) and (max-width: 1279px) {
  .table-scroll-wrapper {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure tables remain liquid */
  .table-scroll-wrapper table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }

  table th {
    font-size: 15px !important;
    line-height: 22px !important;
    padding: 12px 14px !important;
  }

  table td {
    font-size: 14px !important;
    line-height: 21px !important;
    padding: 10px 14px !important;
  }

  /* Enable sticky first column on tablets */
  table th:first-child,
  table td:first-child {
    position: sticky;
    left: 0;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    min-width: 100px;
    max-width: 200px;
  }

  table thead th:first-child {
    background: #263C91;
    z-index: 11;
  }

  tbody tr:nth-child(odd) td:first-child {
    background: #F4F5F9;
  }

  tbody tr:nth-child(even) td:first-child {
    background: #FFFFFF;
  }

  [data-theme="dark"] table thead th:first-child {
    background: #A8B1D3;
  }

  [data-theme="dark"] tbody tr:nth-child(odd) td:first-child {
    background: #36373B;
  }

  [data-theme="dark"] tbody tr:nth-child(even) td:first-child {
    background: #434347;
  }
}

/* Desktop - Liquid tables */
@media (min-width: 1280px) {
  .table-scroll-wrapper {
    overflow-x: auto;
  }

  /* Ensure tables remain liquid on desktop */
  .table-scroll-wrapper table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
  }
}

/* ===== CHAPTER NAVIGATION ===== */

.chapter-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 32px;
  margin-top: var(--spacing-2xl);
  border-top: 1px solid var(--color-border);
}

.chapter-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-base);
}

.chapter-nav-btn:hover {
  background: var(--color-surface-secondary);
  border-color: var(--color-cta-purple);
}

.chapter-nav-btn:active {
  transform: scale(0.98);
}

.chapter-nav-btn[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.chapter-nav-btn .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.chapter-nav-btn.prev .nav-icon {
  transform: rotate(270deg);
}

.chapter-nav-btn.next .nav-icon {
  transform: rotate(90deg);
}

.chapter-nav-btn .nav-label {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 22px;
  letter-spacing: 1.12px;
  text-transform: uppercase;
  color: var(--color-cta-purple);
  white-space: nowrap;
}

/* Mobile: Hide text labels */
@media (max-width: 767px) {
  .chapter-nav-btn .nav-label {
    display: none;
  }
}

/* Dark mode */
[data-theme="dark"] .chapter-navigation {
  border-top-color: var(--color-border);
}

[data-theme="dark"] .chapter-nav-btn {
  border-color: var(--color-border);
}

[data-theme="dark"] .chapter-nav-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--color-cta-purple);
}

/* ===== LOADING STATES ===== */

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-cta-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== LINKS ===== */

/* Base link styles - classic blue with underline */
a {
  color: #0066CC; /* Classic web link blue */
  text-decoration: underline;
  transition: color var(--transition-base), text-decoration-color var(--transition-base);
}

a:hover {
  color: #0052A3; /* Darker blue on hover */
  text-decoration-color: #0052A3;
}

a:active {
  color: #003D7A; /* Even darker when clicked */
}

a:visited {
  color: #551A8B; /* Classic visited link purple */
}

/* Dark mode link colors - brighter for better visibility */
[data-theme="dark"] a {
  color: #6BA3FF; /* Lighter blue for dark backgrounds */
}

[data-theme="dark"] a:hover {
  color: #8FBBFF; /* Brighter on hover */
  text-decoration-color: #8FBBFF;
}

[data-theme="dark"] a:active {
  color: #A8CBFF; /* Brightest when clicked */
}

[data-theme="dark"] a:visited {
  color: #B794F6; /* Lighter purple for visited links */
}

/* Exception: Navigation links should not have underlines */
.chapter-nav a,
.main-nav a,
.back-link,
.section-link,
.chapter-nav-btn,
.download-btn {
  text-decoration: none;
}

/* Exception: Keep existing styles for these elements */
.chapter-nav a:hover,
.main-nav a:hover,
.section-link:hover {
  text-decoration: none;
}

/* ===== CODE BLOCKS ===== */

/* Inline code */
code {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
  font-size: 0.9em;
  background: var(--color-surface-secondary);
  color: var(--color-text-primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

/* Dark mode inline code */
[data-theme="dark"] code {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #E8EAEF;
}

/* Code blocks */
pre {
  background: #F4F5F9;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: var(--spacing-lg);
  margin: var(--spacing-xl) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  word-wrap: break-word;
  white-space: pre-wrap;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #1B1C20;
  display: block;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Dark mode code blocks */
[data-theme="dark"] pre {
  background: #25262A;
  border-color: #36373B;
}

[data-theme="dark"] pre code {
  color: #E8EAEF;
}

/* Scrollbar styling for code blocks */
pre::-webkit-scrollbar {
  height: 8px;
}

pre::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] pre::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== BLOCKQUOTES ===== */

blockquote {
  margin: var(--spacing-xl) 0;
  padding: var(--spacing-lg) var(--spacing-xl);
  border-left: 4px solid var(--color-cta-purple);
  background: var(--color-surface-secondary);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: var(--font-size-body-large);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-secondary);
  font-style: italic;
}

blockquote p {
  margin-bottom: var(--spacing-md);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Citation or attribution in blockquotes */
blockquote cite,
blockquote footer {
  display: block;
  margin-top: var(--spacing-md);
  font-size: var(--font-size-small);
  color: var(--color-text-tertiary);
  font-style: normal;
}

/* Dark mode blockquotes */
[data-theme="dark"] blockquote {
  background: rgba(255, 255, 255, 0.03);
  border-left-color: #6273F9;
  color: #A0A4B1;
}

[data-theme="dark"] blockquote cite,
[data-theme="dark"] blockquote footer {
  color: #787C8D;
}

/* ===== HORIZONTAL RULES ===== */

hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--color-border) 20%,
    var(--color-border) 80%,
    transparent 100%
  );
  margin: var(--spacing-2xl) 0;
}

/* Dark mode horizontal rules */
[data-theme="dark"] hr {
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 20%,
    rgba(255, 255, 255, 0.1) 80%,
    transparent 100%
  );
}

/* ===== ENHANCED LIST STYLING ===== */

/* Content area lists - enhanced spacing and styling */
.chapter-content ul,
.chapter-content ol {
  margin: var(--spacing-lg) 0;
  padding-left: var(--spacing-xl);
}

.chapter-content ul {
  list-style: none;
  padding-left: 0;
}

.chapter-content ul li {
  position: relative;
  padding-left: 32px;
  margin-bottom: var(--spacing-md);
  line-height: var(--line-height-relaxed);
}

/* Custom bullet points */
.chapter-content ul li::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 12px;
  width: 6px;
  height: 6px;
  background: var(--color-cta-purple);
  border-radius: 50%;
}

/* Nested list bullets - smaller and different color */
.chapter-content ul li ul li::before {
  width: 4px;
  height: 4px;
  background: var(--color-text-tertiary);
  top: 13px;
}

/* Ordered lists */
.chapter-content ol {
  counter-reset: item;
  list-style: none;
  padding-left: 0;
}

.chapter-content ol li {
  position: relative;
  padding-left: 20px;
  margin-bottom: var(--spacing-md);
  line-height: var(--line-height-relaxed);
  counter-increment: item;
}

.chapter-content ol li::before {
  content: counter(item) ".";
  position: absolute;
  left: 8px;
  font-weight: var(--font-weight-semibold);
  color: var(--color-cta-purple);
  font-family: var(--font-display);
  display: none;
}

/* Nested ordered lists */
.chapter-content ol li ol {
  margin-top: var(--spacing-sm);
}

.chapter-content ol li ol li::before {
  content: counter(item, lower-alpha) ".";
  color: var(--color-text-secondary);
}

/* List items with bold leading text */
.chapter-content li strong:first-child {
  color: var(--color-text-primary);
  display: inline-block;
}

/* Dark mode list styling */
[data-theme="dark"] .chapter-content ul li::before {
  background: #6273F9;
}

[data-theme="dark"] .chapter-content ol li::before {
  color: #6273F9;
}

/* ===== WARNING/ALERT BOXES ===== */

.warning-box {
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning-border);
  border-radius: var(--border-radius-sm);
  padding: var(--spacing-lg);
  margin: var(--spacing-xl) 0;
  color: var(--color-warning-text);
  font-family: var(--font-body);
  font-size: var(--font-size-small);
  line-height: var(--line-height-normal);
}

.warning-box p {
  color: var(--color-warning-text);
  margin-bottom: 0;
}

.warning-box p:not(:last-child) {
  margin-bottom: var(--spacing-md);
}

/* Dark mode - slightly brighter for better contrast */
[data-theme="dark"] .warning-box {
  background: var(--color-warning-bg);
  border-left-color: var(--color-warning-border);
}

/* ===== NOTE BOXES (Sticky Note Style) ===== */

.note-box {
  background: var(--color-note-bg);
  border-left: 4px solid var(--color-note-border);
  border-radius: var(--border-radius-sm);
  padding: var(--spacing-lg);
  margin: var(--spacing-xl) 0;
  color: var(--color-note-text);
  font-family: var(--font-body);
  font-size: var(--font-size-small);
  line-height: var(--line-height-normal);
}

.note-box-title {
  font-family: var(--font-display);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-semibold);
  color: var(--color-note-title);
  margin-bottom: var(--spacing-md);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.note-box p {
  color: var(--color-note-text);
  margin-bottom: 0;
}

.note-box p:not(:last-child) {
  margin-bottom: var(--spacing-md);
}

/* Dark mode - adjusted colors for better readability */
[data-theme="dark"] .note-box {
  background: var(--color-note-bg);
  border-left-color: var(--color-note-border);
}

[data-theme="dark"] .note-box-title {
  color: var(--color-note-title);
}