/* === Global Reset === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: #f5f5f5;
  font-family: 'Patrick Hand', cursive;
  color: #333;
  line-height: 1.6;
  min-height: 100vh;
  padding: 16px 0;
}

/* === Notebook Page === */
.notebook-page {
  max-width: 900px;
  margin: 0 auto;
  background: #fff;
  position: relative;
  padding: 40px 30px 60px 50px;
  border-radius: 6px;
  box-shadow: 0 0 16px rgba(0,0,0,0.15);
  background-image: linear-gradient(to bottom, #e3eafe 1px, transparent 1px);
  background-size: 100% 32px;
}

/* === Margin Line === */
.margin-line {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(to right, #ff6666 0% 35%, #ff9999 35% 80%, #ff6666 80% 100%);
  border-radius: 2px;
}

/* === Headings === */
h1 {
  font-family: 'Caveat', cursive;
  text-align: center;
  margin: 0 0 30px 0;
  font-size: 2.2rem;
  text-decoration: underline;
  font-weight: 700;
  color: #3e7708; /* note: currently green */
}

h1.blue {
  color: #0609c4;
}

/* === Question & Solution Blocks === */
.exercise {
  margin-bottom: 30px;
  padding-left: 10px;
}

/* Question scaling — targets question and immediate block-level children only */
.question {
  font-size: 1.6rem;   /* adjust this once to scale questions sitewide */
  line-height: 1.4;
  font-weight: bold;
  margin-bottom: 12px;
  color: #b30000;  /* red */
}

/* specific child tags inside question that might inherit different sizes */
.question p,
.question strong,
.question em,
.question .part {
  font-size: inherit;
  line-height: inherit;
}

/* Solution area */
.solution {
  color: #000080;
  font-size: 1.5rem;
  margin-left: 15px;
  margin-bottom: 20px;
  line-height: 1.6;
  background: linear-gradient(180deg, rgba(0,0,0,0.01), transparent);
  padding: 10px 12px;
  border-radius: 6px;
}

/* Ensure nested tags inherit solution style */
.solution p,
.solution .step,
.solution li,
.solution div,
.solution table,
.solution td,
.solution th,
.solution pre {
  color: inherit;
  font-size: inherit;
}

/* small helper part */
.part {
  display: inline-block;
  color: #b80c0c;
  font-size: 1.5rem;
}

/* Step block for sequential working */
.step {
  margin: 10px 0;
  padding-left: 12px;
}

/* Important visual elements */
.important-term {
  display: inline-block;
  background: #b7ebd5;
  padding: 4px 8px;
  margin: 2px 0;
  border-radius: 3px;
  font-weight: 700;
  font-size: large;
}

/* Formula block (single combined definition, allows wrapping) */
.formula {
  display: block;
  font-family: 'Courier New', monospace;
  background: #f4f7fb;
  padding: 8px 10px;
  margin: 10px 0;
  border-radius: 6px;
  border: 1px dashed #cfd8e3;
  overflow-x: auto;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Final answer box */
.final-answer {
  background-color: #e6f7ff;
  padding: 12px 14px;
  border-radius: 6px;
  border: 2px solid #000080;
  margin: 12px 0;
  font-weight: 700;
}

/* Short note / hint box */
.note {
  background: #fff8e1;
  border-left: 4px solid #ffb300;
  padding: 8px 12px;
  border-radius: 4px;
  margin: 8px 0;
}

/* Multiple solutions container */
.mult-solutions {
  margin-top: 8px;
}
.mult-solutions .option {
  margin: 8px 0;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #e0e7ff;
  background: #fafcff;
}
.mult-solutions .option .label {
  font-weight: 700;
  margin-bottom: 6px;
}

/* Figure and diagram wrapper */
.figure {
  display: block;
  margin: 12px auto;
  text-align: center;
}
.figure caption {
  font-style: italic;
  margin-top: 6px;
  color: #666;
}
.math {
      overflow-x: auto;
      padding: 10px 0;
    }

    .math::-webkit-scrollbar {
      height: 5px;
    }

    .math::-webkit-scrollbar-thumb {
      background: #3498db;
      border-radius: 10px;
    }
/* Table styling for factor tables and steps */
table {
      border-collapse: collapse;
      margin: 12px 0;
      width: 100%;
    }
    
    table td, table th {
      border: 1px solid #d6d6d6;
      padding: 8px 10px;
      text-align: center;
    }
    
    table th {
      background-color: #f0f8ff;
    }
    

/* === MathJax / rendering safety rules (prevent overflow) === */
mjx-container,
.mjx-itable,
.mjx-mrow,
.mjx-mn,
.mjx-mi,
.mjx-mo,
.mjx-mfrac,
.mjx-msqrt {
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: break-word !important;
  display: inline-block;
}

/* Images and figures don't overflow */
.solution img,
.figure img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Print friendliness */
@media print {
  body { background: #fff; color: #000; }
  .notebook-page { box-shadow: none; background: transparent; }
  .margin-line { display: none; }
  .final-answer { page-break-inside: avoid; }
}

/* Responsive tweaks */
@media (max-width: 700px) {
  .notebook-page {
    padding: 22px 16px 36px 36px;
    font-size: 0.98rem;
  }
  .formula { font-size: 0.95rem; }
}

/* Small-screen adjustment for question/solution */
@media (max-width: 520px) {
  .question {
    font-size: 1.1rem;
  }
  .solution {
    font-size: 1.05rem;
  }
}
