/* =====================================================================
   Descriptive Statistics - Study Material
   Shared Stylesheet  (Google Sites & standalone friendly)
   ===================================================================== */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: #1f2937;
  margin: 0;
  background: #f5f7fb;
}

/* ---------- Layout ---------- */
.wrapper {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

/* ---------- Header banner ---------- */
.banner {
  background: linear-gradient(135deg, #0f4c81 0%, #1e7fbf 100%);
  color: #fff;
  padding: 30px 22px;
  border-radius: 14px;
  margin-bottom: 28px;
  box-shadow: 0 6px 20px rgba(15,76,129,0.18);
}
.banner h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
  letter-spacing: 0.3px;
}
.banner p {
  margin: 0;
  opacity: 0.95;
  font-size: 1rem;
}
.banner .crumbs {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-bottom: 8px;
}
.banner .crumbs a { color: #ffe49a; text-decoration: none; }
.banner .crumbs a:hover { text-decoration: underline; }

/* ---------- Navigation grid (index page) ---------- */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 24px 0;
}
.unit-card {
  background: #fff;
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  border-top: 4px solid #1e7fbf;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}
.unit-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
}
.unit-card h3 {
  margin: 0 0 8px;
  color: #0f4c81;
  font-size: 1.15rem;
}
.unit-card p { margin: 0; color: #4b5563; font-size: 0.95rem; }
.unit-card .tag {
  display: inline-block;
  font-size: 0.75rem;
  background: #e6f1fb;
  color: #0f4c81;
  padding: 2px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
  font-weight: 600;
}

/* ---------- Section headings ---------- */
h2 {
  color: #0f4c81;
  border-bottom: 3px solid #1e7fbf;
  padding-bottom: 6px;
  margin-top: 42px;
  font-size: 1.55rem;
}
h3 {
  color: #1e7fbf;
  margin-top: 28px;
  font-size: 1.2rem;
}
h4 {
  color: #0f4c81;
  margin-top: 22px;
  font-size: 1.05rem;
}

/* ---------- Concept / definition box ---------- */
.concept {
  background: #fff;
  border-left: 5px solid #1e7fbf;
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.concept .label {
  display: inline-block;
  background: #1e7fbf;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

/* ---------- Formula box ---------- */
.formula {
  background: #fff8e1;
  border: 1px solid #ffd966;
  border-left: 5px solid #f59e0b;
  padding: 12px 18px;
  margin: 14px 0;
  border-radius: 6px;
  font-size: 1.05rem;
}
.formula .label {
  display: inline-block;
  background: #f59e0b;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  margin-bottom: 4px;
}

/* ---------- Example box ---------- */
.example {
  background: #ecfdf5;
  border-left: 5px solid #059669;
  padding: 14px 18px;
  margin: 16px 0;
  border-radius: 6px;
}
.example .label {
  display: inline-block;
  background: #059669;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 10px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.example h4 {
  margin: 4px 0 8px;
  color: #065f46;
}

/* ---------- Tip / Note box ---------- */
.tip {
  background: #eef2ff;
  border-left: 5px solid #6366f1;
  padding: 10px 16px;
  margin: 14px 0;
  border-radius: 6px;
  font-size: 0.96rem;
}
.tip strong { color: #4338ca; }

/* ---------- Tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
th, td {
  border: 1px solid #d1d5db;
  padding: 8px 12px;
  text-align: center;
  font-size: 0.96rem;
}
th {
  background: #0f4c81;
  color: #fff;
  font-weight: 600;
}
tbody tr:nth-child(even) { background: #f3f4f6; }
table.left td, table.left th { text-align: left; }

/* ---------- Lists ---------- */
ul, ol { padding-left: 22px; }
ul li, ol li { margin: 4px 0; }

/* ---------- Footer / page navigation ---------- */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin: 50px 0 0;
  padding-top: 20px;
  border-top: 2px solid #d1d5db;
  flex-wrap: wrap;
  gap: 10px;
}
.page-nav a {
  color: #0f4c81;
  text-decoration: none;
  background: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-weight: 500;
}
.page-nav a:hover { background: #1e7fbf; color: #fff; }

footer {
  text-align: center;
  margin-top: 40px;
  font-size: 0.85rem;
  color: #6b7280;
}

/* ---------- Topic chip list ---------- */
.chips { margin: 12px 0 24px; }
.chip {
  display: inline-block;
  background: #e6f1fb;
  color: #0f4c81;
  padding: 4px 12px;
  border-radius: 14px;
  margin: 4px 4px 4px 0;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ---------- Two-column on wide screens ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 700px) {
  /* A wide table must scroll inside itself rather than widen the page.
     Without this the table pushes the whole document sideways on a phone and
     the code chips in its cells are cut off at the screen edge. */
  table { display: block; max-width: 100%; overflow-x: auto; }
  /* A long file path or command in running text is one unbreakable word; it
     drags the paragraph, and the page with it, past the screen edge. break-word
     (not anywhere) lets it wrap without shrinking a table's columns. */
  code { overflow-wrap: break-word; }
  pre code { overflow-wrap: normal; }
  /* Same for prose: a run of dot leaders, or a sum written out term by term,
     is one word as far as the line-breaker is concerned. This only affects a
     word that cannot fit; ordinary text wraps exactly as before. */
  p, li, td, th, h1, h2, h3, h4 { overflow-wrap: break-word; }
  /* The same hazard one level out. An unrendered display formula is a BARE TEXT
     NODE inside .concept / .formula / .example -- not inside a <p> -- so the
     rule above cannot reach it, and a long TeX expression is one unbreakable
     word. That matters whenever MathJax has not run: offline, a blocked CDN, a
     slow connection, or simply before the script loads. Without this the page
     is dragged sideways on a phone in exactly those moments. Once MathJax has
     run the rule applies to nothing, because the TeX has been replaced by an
     mjx-container, which scrolls in its own box by the rule below. */
  .concept, .formula, .example, .tip { overflow-wrap: break-word; }
  /* Display math is typeset at its natural width, so it scrolls in its own box
     rather than widening the page. */
  mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
  .two-col { grid-template-columns: 1fr; }
  body { font-size: 16px; }
  .banner h1 { font-size: 1.5rem; }
}

/* ---------- Print friendly ---------- */
@media print {
  body { background: #fff; }
  .banner, .unit-card { box-shadow: none; }
  .page-nav { display: none; }
}

/* ---------- Inline code: high-contrast, distinct from body text ---------- */
code {
  background: #fff4e5;             /* soft cream */
  color: #b91c1c;                  /* deep red — very readable */
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #fcd9b6;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.92em;
  font-weight: 600;
}

/* ---------- Code block (multi-line snippets) ---------- */
pre {
  background: #0f172a;             /* deep navy */
  color: #f1f5f9;                  /* near-white text */
  padding: 14px 18px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.93rem;
  line-height: 1.55;
  margin: 14px 0;
  font-family: "Consolas", "Courier New", monospace;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* Inline code INSIDE pre block inherits pre styling — no double background */
pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
  font-weight: normal;
  font-size: inherit;
}

/* Console-style output box used in some R / Excel units */
.out {
  background: #f8fafc;
  color: #1f2937;
  border-left: 4px solid #475569;
  padding: 10px 14px;
  margin: 8px 0 14px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.55;
  white-space: pre-wrap;
  border-radius: 4px;
}

/* ---------- Figure / SVG diagrams ---------- */
.figure {
  margin: 18px auto;
  text-align: center;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 12px 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  max-width: 620px;
}
.figure svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.figure figcaption {
  margin-top: 8px;
  font-size: 0.88rem;
  color: #4b5563;
  font-style: italic;
}
.figure-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.figure-row .figure { margin: 0; max-width: none; }
@media (max-width: 700px) {
  .figure-row { grid-template-columns: 1fr; }
}

/* ---- in-page navigation, ported from data-science-major ---- */
details {
  margin: 10px 0 22px;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

details > summary {
  cursor: pointer;
  padding: 9px 14px 9px 34px;
  position: relative;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: .02em;
  color: #0f4c81;
  background: #eef4fb;
  list-style: none;               /* hide the default triangle ... */
  user-select: none;
}
details > summary::-webkit-details-marker { display: none; }   /* ... in WebKit */

/* our own marker, so it can rotate */
details > summary::before {
  content: "▸";
  position: absolute;
  left: 14px;
  transition: transform .15s ease;
  display: inline-block;
}
details[open] > summary::before { transform: rotate(90deg); }

details > summary:hover { background: #e3edf9; }
details > summary:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: -3px;
}

details[open] > summary {
  border-bottom: 1px solid #dbe3ee;
}

/* the answer itself */
details > *:not(summary) { margin-left: 14px; margin-right: 14px; }
details > *:nth-child(2) { margin-top: 12px; }
details > *:last-child  { margin-bottom: 12px; }

/* a folded answer must still print, or the page is useless on paper */
@media print {
  details { border: none; background: none; }
  details > summary { display: none; }
  /* the browser hides a closed details' children; override so a printed
     revision copy carries the answers even when they were never expanded */
  details:not([open]) > *:not(summary) { display: block !important; }
  details > *:not(summary) { margin-left: 0; margin-right: 0; }
}

/* ---------------------------------------------------------------------------
   'On this page' contents.

   A unit page runs to two and a half thousand words across a dozen sections.
   Closed by default so it costs one line on a phone; open it and the whole
   shape of the page is visible, and every heading is linkable.
   --------------------------------------------------------------------------- */
details.toc {
  margin: 0 0 24px;
  background: #f7f9fc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #0f4c81;
}
details.toc > summary {
  background: transparent;
  color: #0f4c81;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
details.toc > summary:hover { background: #eef4fb; }
/* No marker: over half the headings on this site number themselves ("3. t-test
   for Difference of Two Means"), so an ordered list rendered them as "3. 3.
   t-test for...". The heading's own number is the one a student refers to. */
details.toc ol {
  margin: 4px 0 12px;
  padding-left: 4px;
  list-style: none;
  columns: 2;
  column-gap: 28px;
}
details.toc li { margin: 3px 0; break-inside: avoid; font-size: .93rem; }
details.toc a { color: #24405c; text-decoration: none; }
details.toc a:hover { color: #0f4c81; text-decoration: underline; }

/* a jumped-to heading should not hide under anything, and should be obvious */
h2[id], h3[id] { scroll-margin-top: 12px; }
h2[id]:target, h3[id]:target {
  background: #fff8e1;
  box-shadow: -6px 0 0 #f59e0b;
  padding-left: 6px;
}

@media (max-width: 700px) {
  details.toc ol { columns: 1; padding-left: 30px; }
}
@media print { details.toc { display: none; } }
