/* =====================================================================
 * 🎨 THE BUILD CALIBRE MASTER RESPONSIVE CORE STYLESHEET
 * ===================================================================== */

/* 🛠️ GLOBAL MOBILE CORE RESET */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* Smooth mobile tap feedback */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #2d3748;
  background-color: #f7fafc;
  padding: 0;
}

/* 📦 FLUID STRUCTURAL CONTAINER */
.chapter-container {
  width: 100%;
  max-width: 768px; /* Perfect line length for optimal reading readability */
  margin: 0 auto;
  padding: 16px; /* Fluid padding for compact smartphone screens */
}

@media (min-width: 600px) {
  .chapter-container {
    padding: 32px; /* Smooth padding expansion for desktop/tablets */
  }
}

/* 🧭 ACCESSIBLE TOUCH NAVIGATION CONTROLS */
.nav-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* Standard fingertip tap target bounds */
  padding: 0 16px;
  background-color: #ffffff;
  color: #4a5568;
  text-decoration: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.btn-nav:active {
  background-color: #edf2f7;
  transform: scale(0.98);
}

/* 🏷️ SYSTEM HEADINGS */
h1 {
  font-size: 24px;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 24px;
  line-height: 1.2;
}

@media (min-width: 600px) {
  h1 { font-size: 32px; }
}

/* 🧱 ACCORDION COMPONENTS (<details> & <summary>) */
details {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

details[open] {
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* 🎯 COGNITIVE TOUCH ACCORDION INTERFACES */
summary {
  display: flex;
  align-items: center;
  min-height: 48px; /* Large safe interactive tap target boundary */
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  color: #2b6cb0;
  background-color: #ebf8ff;
  cursor: pointer;
  user-select: none;
  outline: none;
  list-style: none; /* Strip out native browser layout arrows */
}

summary::-webkit-details-marker {
  display: none; /* Webkit browser custom marker arrow fallback overrides */
}

/* 📐 PLUMB-LINE VERTICAL DISCLOSURE TRIANGLE FIX */
summary::before {
  content: "▶";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  margin-right: 12px;
  color: #3182ce;
  transition: transform 0.2s ease;
  
  /* 🛠️ GLYPH ADJUSTMENT: Micro-translates character box down to center the font baseline */
  transform: translateY(1px); 
}

/* Rotates indicator arrow smoothly downwards while preserving alignment vectors */
details[open] > summary::before {
  transform: rotate(90deg) translateX(1px); 
}

/* 🔏 SUMMARY INNER HEADER MARGIN RESET */
summary h1, 
summary h2, 
summary h3, 
summary h4 {
  margin: 0 !important;
  padding: 0 !important;
  display: inline-block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

/* 📂 MULTI-NESTED ACCORDION INNER SHIFTS */
details details {
  margin: 10px 12px;
  border-color: #edf2f7;
}

details details summary {
  background-color: #f7fafc;
  color: #4a5568;
  font-size: 14px;
}

/* 📝 INTERNAL BODY CONTAINER LAYOUTS */
details > *:not(summary) {
  padding: 16px;
}

p {
  margin-bottom: 14px;
  font-size: 15px;
  color: #4a5568;
}

ul, ol {
  padding-left: 24px;
  margin-bottom: 12px;
}

li {
  margin-bottom: 8px;
  font-size: 15px;
}

/* 🛡️ ABSOLUTE MOBILE WIDTH PROTECTION LAYER */
p, li, span, h1, h2, h3, h4, summary {
  word-wrap: break-word;
  word-break: break-word; /* Stops long strings or variables from pushing outer walls */
}

/* 🧮 MATHJAX HORIZONTAL OVERFLOW & BASELINE BALANCING RULES */
.MathJax_Display, 
mjx-container[display="true"], 
.mjx-chtml[display="true"] {
  overflow-x: auto !important; /* Grants an isolated horizontal swipe viewport to complex math models */
  overflow-y: hidden !important;
  max-width: 100% !important;
  padding: 8px 0;
  margin: 12px 0 !important;
  -webkit-overflow-scrolling: touch; /* Kinetic layout swipe inertia tracking on Apple iOS devices */
}

/* 📏 FIXES INLINE MATH EXPRESSIONS FROM SITTING TOO HIGH RELATIVE TO TEXT */
mjx-container:not([display="true"]) {
  display: inline-block !important;
  vertical-align: -0.12em !important; /* Locks math baselines to the lowercase text path line */
  line-height: 0;
}

/* 🏷️ HIGHLIGHT KEYWORD STYLING BOXES */
.keyword {
  font-weight: 600;
  background-color: #fefcbf;
  color: #744210;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
}

/* =====================================================================
   🎯 UNIFORM DETAILS COMPONENT LIST ALIGNMENT PATCH (V2)
   ===================================================================== */
.topic-box ul, 
.sub-topic ul {
  margin-left: 30px !important;  /* Pushes the bullets completely inside the blue box */
  padding-left: 0 !important;    /* Resets default browser behavior */
  margin-top: 12px;
  margin-bottom: 12px;
}

.topic-box li, 
.sub-topic li {
  margin-bottom: 10px;           /* Adds clean breathing room between items */
  line-height: 1.6;              /* Optimizes textbook tracking readability */
}

/* Fallback protection if nested lists are generated */
.topic-box ul ul, 
.sub-topic ul ul {
  margin-left: 20px !important;
  margin-top: 6px;
}

/* 🔮 BUILD CALIBRE RESPONSIVE TABLE COMPONENT (V3.0) */
table { 
  width: 100% !important; 
  border-collapse: collapse !important; 
  margin: 24px 0 !important; 
  box-sizing: border-box !important;
  background-color: #ffffff !important;

  /* 🔄 UNLOCKS NATIVE SCROLL: Safely encapsulates wide columns inside a scroll frame */
  display: block !important;  
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch; /* Momentum scrolling on iOS devices */
}

th, td { 
  padding: 12px 14px !important; 
  text-align: left !important; 
  /* Deep slate-gray ensures distinct, clean border lines */
  border: 1px solid #94a3b8 !important; 
  vertical-align: top !important;

  /* 🛡️ ANTI-SQUISH GUARD: Enforces elegant internal sentence wrapping */
  white-space: normal !important;
  word-break: break-word !important;
  word-wrap: break-word !important;
  min-width: 140px !important; /* Prevents text from crowding into vertical strips */
}

th { 
  background-color: #f1f5f9 !important; 
  font-weight: 600 !important; 
  border-bottom: 2px solid #475569 !important;
}

tr:nth-child(even) {
  background-color: #f8fafc !important; /* Alternating rows for heavy datasets */
}

blockquote.example-block { 
  width: 100% !important; 
  box-sizing: border-box !important; 
  margin: 16px 0 !important; 
  padding: 16px !important; 
  background: #f8fafc !important; 
  border-left: 4px solid #3182ce !important; 
}

/* ==========================================================================
   BUILD CALIBRE CURRICULUM HIGHLIGHTS & BORDER TOKENS
   ========================================================================== */

/* 1. The Missing Yellow Keyword Highlighting */
span.keyword {
  background-color: #fef08a; /* Soft, readable educational yellow highlight */
  color: #1e293b;            /* High-contrast dark charcoal text */
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  display: inline-block;
}

/* 2. Uniform Blockquote / Primary Source Borders & Backgrounds */
blockquote.example-block {
  margin: 16px 0;
  padding: 16px 20px;
  border-left: 4px solid #94a3b8; /* Solid slate-gray left accent border */
  background-color: #f8fafc;     /* Clean off-white/slate-tint background tint */
  border-radius: 0 8px 8px 0;
}

blockquote.example-block hr {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 12px 0;
}

/* 3. Global Interactive Tree Structural Borders */
details.topic-box {
  display: block;
  margin-bottom: 16px;
  border: 1px solid #cbd5e1;       /* Light slate layout grid border */
  border-radius: 8px;
  background-color: #ffffff;
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

details.sub-topic {
  display: block;
  margin-left: 20px;
  margin-top: 12px;
  margin-bottom: 12px;
  padding-left: 14px;
  border-left: 2px solid #e2e8f0;  /* Standard connecting hierarchy line */
}
