/* ==========================================================================
   THE MATHEMATICIANS' LIBRARY - CORE BRAND SPECIFICATION
   ========================================================================== */

:root {
  --book-green: #1c5235;
  --book-cream: #fbf9f3;
  --book-terracotta: #b84a39;
  --book-gold: #d4a359;
  --text-primary: #1f2924;
  --text-muted: #5c6e65;
  --bg-white: #ffffff;
  --border-light: #e6eae7;
}

/* Base Document Configuration (Ensure this is normal, clean text) */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--book-cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Georgia, serif;
  color: var(--text-primary);
  font-style: normal !important; /* Forces all body text back to clean, upright standard typography */
}


/* Master Grid Structure: Left Spine & Right Content */
body {
  display: grid;
  grid-template-columns: 60px 1fr;
}

/* Universal Link Styling (Banish Browser Blue Site-Wide) */
a {
  color: var(--book-terracotta);
  text-decoration: none;
  transition: color 0.2s ease;
}

/* Clear hover state behavior for all links */
a:hover {
  color: var(--book-green);
  text-decoration: underline;
}

p, li, div, span, h1, h2, h3, h4, section, main {
  font-style: normal;
}


/* ==========================================================================
   COMPONENT 1: THE BOOK SPINE SIDEBAR
   ========================================================================== */
.book-spine-sidebar {
  grid-column: 1;
  background-color: var(--book-green);
  border-right: 4px solid var(--book-gold);
  display: flex;
  justify-content: center;
  align-items: center;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.spine-text {
  writing-mode: vertical-lr;
  transform: rotate(180deg); /* Flips typography so it reads upward, matching classic binding */
  color: var(--book-cream);
  font-weight: bold;
  font-size: 1.2rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ==========================================================================
   COMPONENT 2: THE MAIN WINDOW CONTENT
   ========================================================================== */
.site-content-wrapper {
  grid-column: 2;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  padding: 40px;
}

/* Celestial Border Frame Motif */
header {
  border-bottom: 2px solid var(--book-gold);
  border-image: repeating-linear-gradient(90deg, var(--book-gold), var(--book-gold) 10px, transparent 10px, transparent 20px) 2;
  padding-bottom: 25px;
  margin-bottom: 40px;
}

header h1 { 
  color: var(--book-green); 
  font-family: Georgia, serif; 
  font-size: 2.4rem; 
  margin: 0 0 8px 0; 
}

/* Navigation Dashboard Links */
.nav-menu { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.nav-label { font-weight: bold; color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }
.nav-btn {
  background: var(--bg-white); border: 1px solid var(--border-light);
  padding: 8px 16px; border-radius: 4px; text-decoration: none; color: var(--book-green); font-weight: 500;
  transition: all 0.2s ease;
}
.nav-btn:hover { border-color: var(--book-terracotta); color: var(--book-terracotta); }
.nav-btn.active { background: var(--book-green); color: var(--bg-white); border-color: var(--book-gold); }

/* Core Layout Component Card Containers */
.grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 25px; list-style: none; padding: 0; margin-top: 20px; }
.book-card {
  background: var(--bg-white); border: 1px solid var(--border-light); border-radius: 6px;
  padding: 18px; display: flex; flex-direction: column; box-shadow: 0 4px 6px rgba(28,82,53,0.02);
  transition: transform 0.2s ease;
}
.book-card:hover { transform: translateY(-3px); border-color: var(--book-gold); }
.book-card img { width: 100%; height: 220px; object-fit: cover; border-radius: 4px; background: #eee; margin-bottom: 14px; }
.card-title a { color: var(--book-green); text-decoration: none; font-weight: bold; font-size: 1.15rem; font-family: Georgia, serif; }
.card-title a:hover { color: var(--book-terracotta); }
.meta-row { font-size: 0.85rem; color: var(--text-muted); margin: 5px 0; }
.meta-row a { color: var(--book-terracotta); text-decoration: none; font-weight: 500; }

/* Inactive/Pending Chapter Content States */
.opacity-muted { opacity: 0.85; }
.chapter-status-banner {
  background-color: #f5f1e3; border: 1px dashed var(--book-gold); border-left: 4px solid var(--book-gold);
  padding: 18px; margin: 15px 0 25px 0; border-radius: 4px; font-size: 0.95rem;
}
.funding-link { color: var(--book-terracotta); font-weight: bold; text-decoration: none; display: inline-block; margin-top: 8px; }
.funding-link:hover { text-decoration: underline; }

/* Timeline Interface Architecture Tracks */
.timeline-container { position: relative; padding-left: 35px; margin-top: 30px; }
.timeline-container::before { content: ''; position: absolute; left: 12px; top: 0; bottom: 0; width: 2px; background: var(--book-gold); }
.timeline-item { position: relative; margin-bottom: 30px; }
.timeline-item::before { content: ''; position: absolute; left: -27px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--book-terracotta); }

.timeline-milestone-marker { text-align: center; position: relative; margin: 45px 0 35px -35px; }
.timeline-milestone-marker::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; border-top: 1px dashed var(--book-gold); z-index: 1; }
.timeline-milestone-marker span { background: var(--book-cream); padding: 0 15px; color: var(--book-green); font-weight: bold; font-size: 0.95rem; position: relative; z-index: 2; font-family: Georgia, serif; }
.timeline-event-text { max-width: 550px; font-size: 0.95rem; line-height: 1.5; }
.timeline-event-text strong { color: var(--book-green); }
.timeline-event-text em { display: block; color: var(--text-muted); margin-top: 4px; }

/* Mapping Framework Containers */
#map { width: 100%; height: 580px; border-radius: 6px; border: 1px solid var(--border-light); margin-top: 20px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }

/* Thematic Filters & Static Assets */
.tag-pill { display: inline-block; background: var(--border-light); color: var(--book-green); padding: 4px 12px; border-radius: 12px; text-decoration: none; font-size: 0.85rem; margin-right: 6px; font-weight: 500; }
.tag-pill:hover { background: var(--book-gold); color: white; }
.resource-section { background:#fff; padding:22px; border:1px solid var(--border-light); border-radius:6px; margin-top:20px; box-shadow: 0 2px 4px rgba(0,0,0,0.01); }

/* Ornate Celestial Footer Frame Banner */
.companion-footer {
  background: var(--bg-white); border: 1px solid var(--border-light);
  border-top: 4px double var(--book-gold); /* Double track line mimicking engraving borders */
  border-bottom: 4px double var(--book-gold);
  padding: 25px; margin-top: 60px; border-radius: 4px;
}
.companion-footer h3 { margin-top: 0; color: var(--book-green); font-family: Georgia, serif; }
.companion-footer a { color: var(--book-terracotta); font-weight: bold; text-decoration: none; }
.companion-footer a:hover { text-decoration: underline; }

/* ==========================================================================
   INTERCONNECTED RESPONSIVE INTERFACE MEDIA OVERRIDES
   ========================================================================== */
@media (max-width: 768px) {
  /* On tablets and smaller screens, stack the spine bar to the top of the viewport */
  body { grid-template-columns: 1fr; }
  
  .book-spine-sidebar {
    grid-column: 1; height: 50px; width: 100%; position: relative;
    border-right: none; border-bottom: 3px solid var(--book-gold);
    padding: 0; justify-content: center; align-items: center;
  }
  .spine-text {
    writing-mode: horizontal-tb; transform: none;
    font-size: 1rem; letter-spacing: 0.2em; padding: 0;
  }
  
  .site-content-wrapper { grid-column: 1; padding: 20px; }
}

@media (max-width: 480px) {
  header h1 { font-size: 1.8rem; }
  .grid-list { grid-template-columns: 1fr; gap: 16px; }
  .book-card img { height: 230px; }
  #map { height: 380px; }
  .nav-menu { gap: 6px; }
  .nav-btn { padding: 6px 10px; font-size: 0.85rem; flex: 1 1 auto; text-align: center; }
}
/* ==========================================================================
   INDIVIDUAL BOOK RESOUCE PAGE PROFILE LAYOUTS
   ========================================================================== */
.back-link-wrapper { margin-top: 0; margin-bottom: 20px; }
.back-link { color: var(--book-terracotta); text-decoration: none; font-weight: bold; }
.back-link:hover { text-decoration: underline; }

/* The side-by-side flex engine split container */
.book-profile-flex {
  display: flex;
  gap: 30px;
  align-items: flex-start;
  margin-top: 15px;
}

.book-profile-cover {
  flex: 0 0 220px; /* Locks the image box width tightly */
  max-width: 220px;
}
.book-profile-cover img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 10px rgba(28,82,53,0.06);
  display: block;
}

.book-profile-meta {
  flex: 1; /* Allows text to reclaim remaining horizontal area */
}
.book-main-title {
  margin: 0 0 10px 0 !important;
  font-size: 2.2rem !important;
  line-height: 1.2;
}
.book-main-author {
  margin: 0 0 15px 0;
  color: var(--text-primary);
  font-size: 1.1rem;
}
.book-main-tags {
  margin-top: 20px;
  border-top: 1px solid var(--border-light);
  padding-top: 15px;
}

/* Responsive collapse rule for tight smartphone glass */
@media (max-width: 550px) {
  .book-profile-flex {
    flex-direction: column; /* Stacks image directly over text on tight screens */
    gap: 20px;
    align-items: center;
    text-align: center;
  }
  .book-profile-cover {
    max-width: 180px; /* Slims image footprint slightly on phones */
  }
  .book-main-title {
    font-size: 1.6rem !important;
  }
}
/* Responsive Full-Width Embed Components */
.embed-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  margin: 20px 0;
  border-radius: 4px;
}

/* Forces the embedded window to stretch cleanly to its box margins */
.embed-container iframe {
  width: 100% !important;
  border: 0;
}

/* Aspect ratio boxes to keep simulators or players looking sharp */
.ratio-16-9 { padding-top: 56.25%; } /* Standard widescreen videos */
.ratio-4-3  { padding-top: 75%; }    /* Traditional math tools or grids */

.embed-container iframe {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
}

/* ==========================================================================
   THE STACKS - MASTER TYPOGRAPHY BRANDING UPDATE WITH HANGING SYMBOL
   ========================================================================== */

/* Main Header Title: Made bold, tiny, and tightly tracked like an imprint label */
header h1 {
  color: var(--book-green) !important;
  font-family: Georgia, serif;
  font-size: 1.15rem !important; /* Shrunk down to act as a crisp secondary tag */
  font-weight: 800 !important;   /* Made heavy and bold to anchor its authority */
  text-transform: uppercase;     /* Switched to uppercase to give it a sharp structural feel */
  letter-spacing: 2px;          /* Tracked out slightly to balance the boldness */
  margin: 0;
  line-height: 1.2;
}

/* Sub-brand 'The Stacks': The undisputed visual hero of the layout */
.stacks-subtitle {
  display: block;
  font-size: 1.55rem; /* Amplified slightly more for major canvas dominance */
  font-family: Georgia, serif;
  font-weight: 800;
  color: var(--text-primary) !important;
  letter-spacing: 7px;
  text-transform: uppercase;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--book-gold);
  width: 100%;
}

/* Hanging Structural Symbol Styling */
.stacks-branch-symbol {
  color: var(--book-gold) !important; /* Painted in gold to create a beautiful 3-colour harmony */
  font-size: 1.7rem !important;        /* Large enough to match the initial caps footprint */
  font-weight: 400 !important;        /* Kept lighter so it doesn't look bulky */
  margin-right: 8px;                  /* Clean, intentional horizontal spacing */
  letter-spacing: 0 !important;       /* Removes tracking so it stays close to the 'T' */
}

/* Pronounced Initial Caps: Bouncing off the page in Terracotta */
.stacks-subtitle > span:not(.stacks-branch-symbol) {
  color: var(--book-terracotta) !important;
  font-weight: 900;
  font-size: 2.0rem; /* Pushed up slightly more to maximise the small-caps gap */
  display: inline-block;
  transform: translateY(1px);
}

/* ==========================================================================
   INLINE LOGOTYPE BRANDING UTILITY FOR "THE STACKS"
   ========================================================================== */

/* The base container that styles the whole phrase as a clean small-caps unit */
.inline-stacks-brand {
  font-family: Georgia, serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px; /* Subtle spacing to evoke tracking without breaking text flow */
  color: var(--text-primary);
  font-size: 0.92em; /* Marginally scales down to sit cleanly on standard line-heights */
}

/* Forces the initial capital letters inside the text flow to pop in Terracotta */
.inline-stacks-brand span {
  color: var(--book-terracotta) !important;
  font-weight: 900;
  font-size: 1.25em; /* Scaled up relatively to preserve the pronounced capital feel */
}

/* Inline Book Title Brand Highlight */
.inline-book-title {
  color: var(--book-green) !important;
  font-weight: 700;
  font-family: Georgia, serif; /* Optional: adds an elegant editorial serif contrast inside plain body text */
}



