/* ========================================================================
1. COVER PAGE: SYSTEM LAYOUT (Locked Screen & No UI)
======================================================================== */

html:has(#cover-page),
html:has(#cover-page) body {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%) !important;
  height: 100vh !important;
  width: 100vw !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}

html.coal:has(#cover-page) body,
html.navy:has(#cover-page) body,
html.ayu:has(#cover-page) body {
  background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%) !important;
}

html:has(#cover-page) .sidebar,
html:has(#cover-page) .menu-bar,
html:has(#cover-page) .nav-chapters,
html:has(#cover-page) .mobile-topbar,
html:has(#cover-page) .nav-wrapper,
html:has(#cover-page) .nav-wide-wrapper,
html:has(#cover-page) a.nav-chapters,
html:has(#cover-page) a.mobile-nav-chapters {
  display: none !important;
}

html:has(#cover-page) .page-wrapper {
  background: transparent !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100vh !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ========================================================================
2. COVER PAGE: CONTENT STYLING
======================================================================== */

#cover-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  text-align: center;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  animation: fadeIn 1.5s ease-out;
}

/* --- FIX 1: THE ARROW KILLER --- */
/* Restore the text, but kill the link behavior */
#cover-page .cover-title a.header {
  display: inline-block !important;
  visibility: visible !important;
  text-decoration: none !important;
  color: inherit !important;
  pointer-events: none !important; /* Makes it unclickable */
}

/* Remove the arrow (which is a pseudo-element on either the h1 or the a) */
#cover-page .cover-title::before,
#cover-page .cover-title::after,
#cover-page .cover-title a.header::before,
#cover-page .cover-title a.header::after {
  content: none !important;
  display: none !important;
}

/* LOGO */
#cover-page .cover-logo {
  height: 40vh !important;
  width: auto !important;
  margin-bottom: 2vh !important;
  filter: drop-shadow(0 10px 15px rgba(0,0,0,0.2));
}

/* TITLE */
#cover-page .cover-title {
  font-size: 10vmin !important;
  font-size: clamp(2rem, 10vmin, 6rem) !important;
  font-weight: 800;
  margin: 0;
  color: var(--fg);
  letter-spacing: -0.05em;
  line-height: 1.1;
}

/* SUBTITLE */
#cover-page .cover-subtitle {
  font-size: 2.5vmin !important;
  font-size: clamp(1rem, 3vmin, 2rem) !important;
  font-weight: 300;
  color: var(--fg);
  opacity: 0.9;
  margin-top: 1vh !important;
}

/* DIVIDER */
#cover-page .cover-divider {
  width: 10vw;
  height: 4px;
  background: var(--links);
  margin: 3vh auto !important;
  border-radius: 4px;
}

/* --- FIX 2: TIGHTEST POSSIBLE META --- */
#cover-page .cover-meta {
  margin-bottom: 4vh !important;
  color: var(--fg);
  opacity: 0.8;

  font-size: 2.5vmin !important;
  font-size: clamp(2.0rem, 2.5vmin, 1.2rem) !important;

  /* Force lines to be close together */
  line-height: 1.2 !important;
}

#cover-page .cover-meta p {
  /* Zero margin and padding ensures they stack directly */
  margin: 0 !important;
  padding: 0 !important;
}

#cover-page .cover-meta .version {
  font-size: 0.75em !important; /* 85% size of the author name */
  opacity: 0.8 !important;       /* Slightly fainter */
  margin-top: 0.8vh !important;  /* Add a small gap above it */
  font-family: 'Consolas', 'Monaco', monospace !important; /* Tech look */
}

/* BUTTON */
#cover-page .cover-button {
  display: inline-block;
  padding: 1.5vh 3vw !important;
  background-color: var(--links);
  color: white !important;
  text-decoration: none;
  border-radius: 50px;
  font-weight: bold;

  font-size: 2.5vmin !important;
  font-size: clamp(1rem, 2.5vmin, 1.5rem) !important;

  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#cover-page .cover-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.3);
  text-decoration: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========================================================================
3. Sidebar Logo Styling
======================================================================== */
.sidebar-logo-link {
    display: block;
    text-align: center;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 20px;
    text-decoration: none !important; /* Remove underline from link */
    border: none !important;
}

.sidebar-logo {
    width: 30%;
    max-width: 180px;
    height: auto;
    opacity: 0.95;
    transition: transform 0.2s ease;
}

.sidebar-logo:hover {
    transform: scale(1.05);
    opacity: 1;
}

/* =========================================
   HIDE "COVER" TEXT LINK
   ========================================= */
/* Since the Logo now serves as the link to the Cover/Home,
   we hide the first text entry in the sidebar to avoid redundancy.
*/
.sidebar-scrollbox .chapter > li:first-child {
    display: none !important;
}

/* ========================================================================
5. CUSTOM MATH ENVIRONMENT BLOCKS
   Usage: <div class="theorem" data-title="...">, <div class="proof">, etc.
======================================================================== */

/* Shared base styles for all environment types */
div.theorem, div.lemma, div.corollary, div.proposition,
div.definition, div.proof, div.remark, div.assumption, div.example {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 1.4em 0 !important;
    padding: 0.75em 1.1em 0.75em 1.2em !important;
    border-radius: 0 6px 6px 0;
    color: var(--fg) !important;
    font-style: normal;
    /* border-left is set per-type below */
}

/* Label injected by JS as first child div */
.math-env-label {
    display: block;
    margin-bottom: 0.35em;
    font-weight: 700;
    font-variant: small-caps;
    letter-spacing: 0.06em;
    font-size: 0.92em;
    line-height: 1.4;
}

.math-env-title {
    font-weight: 400;
    font-variant: normal;
    letter-spacing: normal;
    font-style: italic;
    margin-left: 0.2em;
}
.math-env-title::before { content: "("; }
.math-env-title::after  { content: ")"; }

/* Per-type: border + background + label colour — muted academic palette */
div.theorem     { border-left: 4px solid #4a7bb5 !important; background: rgba(74,123,181,0.09) !important; }
div.lemma       { border-left: 4px solid #7b6fa0 !important; background: rgba(123,111,160,0.09) !important; }
div.corollary   { border-left: 4px solid #7aaabf !important; background: rgba(122,170,191,0.09) !important; }
div.proposition { border-left: 4px solid #5b8db8 !important; background: rgba(91,141,184,0.09) !important; }
div.definition  { border-left: 4px solid #4e8c6e !important; background: rgba(78,140,110,0.09) !important; }
div.proof       { border-left: 4px solid #8a9bae !important; background: rgba(138,155,174,0.09) !important; font-style: italic; }
div.remark      { border-left: 4px solid #b07d62 !important; background: rgba(176,125,98,0.09) !important; }
div.assumption  { border-left: 4px solid #7a8c6e !important; background: rgba(122,140,110,0.08) !important; }
div.example     { border-left: 4px solid #c4a84f !important; background: rgba(196,168,79,0.09) !important; }

div.theorem     .math-env-label { color: #2d5f8a; }
div.lemma       .math-env-label { color: #5c5080; }
div.corollary   .math-env-label { color: #4a88a2; }
div.proposition .math-env-label { color: #3a6e96; }
div.definition  .math-env-label { color: #2e6b4f; }
div.proof       .math-env-label { color: #566878; font-style: normal; }
div.remark      .math-env-label { color: #8a5c3e; }
div.assumption  .math-env-label { color: #546347; }
div.example     .math-env-label { color: #8a6f1e; }

/* proof body italic but math upright */
div.proof mjx-container { font-style: normal; }

/* Dark themes — slightly boosted alpha so muted colours stay visible */
html.coal div.theorem,   html.navy div.theorem,   html.ayu div.theorem     { background: rgba(74,123,181,0.14) !important; }
html.coal div.lemma,     html.navy div.lemma,     html.ayu div.lemma       { background: rgba(123,111,160,0.14) !important; }
html.coal div.corollary, html.navy div.corollary, html.ayu div.corollary   { background: rgba(122,170,191,0.14) !important; }
html.coal div.proposition, html.navy div.proposition, html.ayu div.proposition { background: rgba(91,141,184,0.14) !important; }
html.coal div.definition,  html.navy div.definition,  html.ayu div.definition  { background: rgba(78,140,110,0.14) !important; }
html.coal div.proof,     html.navy div.proof,     html.ayu div.proof       { background: rgba(138,155,174,0.12) !important; }
html.coal div.remark,    html.navy div.remark,    html.ayu div.remark      { background: rgba(176,125,98,0.14) !important; }
html.coal div.assumption, html.navy div.assumption, html.ayu div.assumption { background: rgba(122,140,110,0.13) !important; }
html.coal div.example,   html.navy div.example,   html.ayu div.example     { background: rgba(196,168,79,0.14) !important; }
