/* =========================================================================
   MathsFamily — lesson page design system
   Single shared stylesheet for the redesigned lesson/resource pages.
   Everything generic (tokens, header, menu, search results, breadcrumb,
   article typography, callouts, sidebar, lesson navigation, footer) lives
   here. Page-specific widgets (e.g. css/allaboutnumbers.css) stay separate.

   Link order on a page: lesson-page.css FIRST, page-specific CSS after it.
   All classes are prefixed "lp-" (except the .site-search-* result classes,
   which are generated by js/setupforms.js and shared with the Algolia search).
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
  --lp-bg: #f4f4f6;
  --lp-surface: #ffffff;
  --lp-border: #e6e6eb;
  --lp-border-strong: #cfd4dc;
  --lp-text: #3a3e45;
  --lp-muted: #5f646d;
  --lp-heading: #16181d;

  --lp-orange: #e8710a;        /* accents, bars, progress */
  --lp-orange-dark: #b85400;   /* orange text on white (AA contrast) */
  --lp-orange-soft: #fdebd9;
  --lp-blue: #0b78c2;
  --lp-blue-soft: #eaf4fb;

  /* section boxes + heading underline (carried over from the original topic pages) */
  --lp-box-accent: #f79522;
  --lp-box-border: #f5c47a;
  --lp-h2-line: #ffe9c8;

  --lp-radius: 14px;
  --lp-shadow: 0 1px 2px rgba(20, 22, 28, 0.04), 0 10px 28px rgba(20, 22, 28, 0.06);

  --lp-font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --lp-font-serif: "Libre Baskerville", Georgia, "Times New Roman", serif;

  --lp-gutter: clamp(16px, 3.2vw, 42px);
  --lp-sticky-h: 132px;   /* header + breadcrumb; re-measured by js/lesson-page.js */
  --lp-max: 1520px;
}

/* ---------- Base ---------- */
.lp-body *,
.lp-body *::before,
.lp-body *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

.lp-body {
  margin: 0;
  background: var(--lp-bg);
  color: var(--lp-text);
  font-family: var(--lp-font-sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.lp-body img {
  max-width: 100%;
}

.lp-body :focus-visible {
  outline: 3px solid rgba(11, 120, 194, 0.45);
  outline-offset: 2px;
}

.lp-skip {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--lp-heading);
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
}

.lp-skip:focus {
  top: 12px;
}

/* ---------- Sticky top area (header + breadcrumb + reading-progress bar) ---------- */
.lp-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--lp-surface);
}

/* Reading progress: just a thin bar along the bottom edge of the sticky area */
.lp-readbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: transparent;
  pointer-events: none;
}

.lp-readbar-fill {
  height: 100%;
  width: 0;
  background: var(--lp-orange);
  border-radius: 0 4px 4px 0;
  transition: width 0.12s linear;
}

/* ---------- Header ---------- */
.lp-header {
  position: relative;
  z-index: 50;
  background: var(--lp-surface);
  border-bottom: 1px solid var(--lp-border);
}

/* One row. If the inline navigation cannot fit (the search box hits its
   minimum width), js/lesson-page.js adds .is-collapsed and the navigation
   becomes the hamburger drop-down instead of wrapping onto a second line. */
.lp-header-inner {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 var(--lp-gutter);
  min-height: 78px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 24px;
}

.lp-logo {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
}

.lp-logo img {
  display: block;
  height: 34px;
  width: auto;
}

/* Search box (behaviour lives in js/setupforms.js -> setupSiteSearch()) */
.lp-search {
  position: relative;
  flex: 1 1 320px;
  min-width: 200px;
  max-width: 480px;
}

.lp-search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 18px;
  background: var(--lp-bg);
  border: 1px solid var(--lp-border);
  border-radius: 999px;
  color: var(--lp-muted);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.lp-search-field:focus-within {
  background: #fff;
  border-color: var(--lp-orange);
  box-shadow: 0 0 0 3px rgba(232, 113, 10, 0.18);
}

.lp-search-field i {
  font-size: 0.95rem;
  flex-shrink: 0;
}

.lp-search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  font: inherit;
  font-size: 0.97rem;
  color: var(--lp-heading);
}

.lp-search-input::placeholder {
  color: var(--lp-muted);
}

/* Search results — class names are generated by js/setupforms.js */
.site-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(70vh, 460px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--lp-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 22, 28, 0.16);
  z-index: 70;
  text-align: left;
}

.site-search-results.active {
  display: block;
}

.site-search-result-item {
  display: block;
  padding: 12px 18px;
  text-decoration: none;
  border-bottom: 1px solid #f0f0f3;
  color: inherit;
}

.site-search-result-item:last-child {
  border-bottom: 0;
}

.site-search-result-item:hover,
.site-search-result-item:focus {
  background: #fff7ef;
}

.site-search-result-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--lp-heading);
  line-height: 1.4;
}

.site-search-result-title em {
  font-style: normal;
  color: var(--lp-orange-dark);
}

.site-search-result-desc {
  margin-top: 2px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--lp-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.site-search-result-desc em {
  font-style: normal;
  font-weight: 600;
  color: var(--lp-heading);
}

.site-search-empty,
.site-search-loading {
  padding: 16px 18px;
  font-size: 0.88rem;
  color: var(--lp-muted);
  text-align: center;
}

/* ---------- Main navigation (inline) ---------- */
.lp-nav {
  margin-left: auto;
  flex: 0 0 auto;
}

.lp-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lp-nav > ul {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lp-nav > ul > li {
  position: relative;
  white-space: nowrap;
}

.lp-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--lp-heading);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}

.lp-nav-link:hover,
.lp-has-sub:hover > .lp-nav-link {
  color: var(--lp-orange-dark);
}

.lp-nav-link i {
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.lp-has-sub.is-open > .lp-nav-link i,
.lp-has-sub:hover > .lp-nav-link i {
  transform: rotate(180deg);
}

.lp-nav-cta {
  margin-left: 6px;
}

.lp-cta {
  display: inline-block;
  padding: 11px 24px;
  border-radius: 999px;
  background: var(--lp-orange);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(232, 113, 10, 0.3);
  transition: background 0.2s, transform 0.2s;
}

.lp-cta:hover {
  background: #d1650a;
  transform: translateY(-1px);
}

/* Resources drop-down (inline mode) */
.lp-sub {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 270px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--lp-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 22, 28, 0.16);
  z-index: 60;
}

/* invisible bridge so the menu doesn't close while the pointer crosses the gap */
.lp-sub::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

.lp-has-sub:hover > .lp-sub,
.lp-has-sub:focus-within > .lp-sub,
.lp-has-sub.is-open > .lp-sub {
  display: block;
}

.lp-sub a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--lp-heading);
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
}

.lp-sub a:hover {
  background: var(--lp-orange-soft);
  color: var(--lp-orange-dark);
}

/* Header actions */
.lp-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lp-icon-btn,
.lp-menu-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--lp-heading);
  font-size: 1.05rem;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.lp-icon-btn:hover,
.lp-icon-btn[aria-expanded="true"] {
  background: var(--lp-bg);
}

/* hamburger only exists in collapsed mode */
.lp-menu-btn {
  display: none;
  border-color: var(--lp-border-strong);
  margin-left: 4px;
}

.lp-menu-btn:hover,
.lp-menu-btn[aria-expanded="true"] {
  border-color: var(--lp-blue);
  color: var(--lp-blue);
}

/* Account drop-down */
.lp-account {
  position: relative;
}

.lp-account-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 250px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--lp-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 22, 28, 0.16);
  z-index: 60;
}

.lp-account.is-open .lp-account-panel {
  display: block;
}

.lp-account-signed {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--lp-border);
}

.lp-account-signed small {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--lp-muted);
}

.lp-account-signed strong {
  display: block;
  margin-top: 2px;
  color: var(--lp-heading);
  word-break: break-word;
}

/* Signed in: the account icon becomes a pill showing the username */
.lp-account-label {
  display: none;
}

.lp-account.is-signed-in .lp-account-btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 0 12px;
  border-radius: 999px;
  border-color: var(--lp-border-strong);
  background: var(--lp-orange-soft);
}

.lp-account.is-signed-in .lp-account-label {
  display: inline;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--lp-heading);
}

.lp-account-hint {
  margin: 0 0 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--lp-muted);
}

.lp-cta--block {
  display: block;
  text-align: center;
  box-shadow: none;
}

.lp-account-link {
  display: block;
  padding: 10px 0;
  color: var(--lp-heading);
  font-weight: 500;
  text-decoration: none;
  border-top: 1px solid var(--lp-border);
}

.lp-account-link:first-of-type {
  border-top: 0;
}

.lp-account-link:hover {
  color: var(--lp-orange-dark);
}

/* ---------- Collapsed header (navigation too wide for one line) ---------- */
.lp-header.is-collapsed .lp-menu-btn {
  display: inline-grid;
}

.lp-header.is-collapsed .lp-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  background: var(--lp-surface);
  border-top: 1px solid var(--lp-border);
  border-bottom: 1px solid var(--lp-border);
  box-shadow: 0 16px 30px rgba(20, 22, 28, 0.08);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}

.lp-header.is-collapsed .lp-nav.is-open {
  display: block;
}

.lp-header.is-collapsed .lp-nav > ul {
  display: block;
  max-width: 1800px;
  margin: 0 auto;
  padding: 10px var(--lp-gutter) 20px;
}

.lp-header.is-collapsed .lp-nav > ul > li {
  white-space: normal;
}

.lp-header.is-collapsed .lp-nav-link {
  display: flex;
  width: 100%;
  padding: 12px 0;
}

.lp-header.is-collapsed .lp-sub-toggle {
  pointer-events: none;
}

.lp-header.is-collapsed .lp-sub-toggle i {
  display: none;
}

/* sub-links are always listed (indented) inside the hamburger panel */
.lp-header.is-collapsed .lp-sub {
  display: block;
  position: static;
  min-width: 0;
  padding: 0 0 6px 16px;
  border: 0;
  border-left: 2px solid var(--lp-border);
  border-radius: 0;
  box-shadow: none;
  margin: 0 0 6px;
}

.lp-header.is-collapsed .lp-sub::before {
  display: none;
}

.lp-header.is-collapsed .lp-nav-cta {
  margin: 12px 0 0;
}

/* ---------- Breadcrumb ---------- */
.lp-crumbs {
  background: var(--lp-surface);
  border-bottom: 1px solid var(--lp-border);
}

.lp-crumbs-inner {
  max-width: var(--lp-max);
  margin: 0 auto;
  padding: 13px var(--lp-gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--lp-muted);
}

.lp-crumbs a {
  color: var(--lp-orange-dark);
  font-weight: 600;
  text-decoration: none;
}

.lp-crumbs a:hover {
  text-decoration: underline;
}

.lp-crumbs .lp-sep {
  color: #a3a8b0;
}

/* ---------- Page layout ---------- */
.lp-layout {
  max-width: var(--lp-max);
  margin: 0 auto;
  padding: 44px var(--lp-gutter) 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 40px;
  align-items: start;
}

.lp-card {
  background: var(--lp-surface);
  border: 1px solid var(--lp-border);
  border-radius: var(--lp-radius);
  box-shadow: var(--lp-shadow);
  padding: clamp(24px, 4.2vw, 52px);
  min-width: 0;
}

/* ---------- Article typography ---------- */
.lp-eyebrow {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--lp-orange-dark);
}

.lp-title {
  margin: 0 0 1.1rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid var(--lp-h2-line);
  font-family: var(--lp-font-serif);
  font-size: clamp(2rem, 4.4vw, 3.1rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--lp-heading);
}

.lp-lead {
  margin: 0;
  padding: 1.4rem 1.6rem;
  background: linear-gradient(135deg, #fff8f0, #fff);
  border: 1px solid var(--lp-box-border);
  border-left: 5px solid var(--lp-box-accent);
  border-radius: 12px;
  font-size: clamp(1.05rem, 1.7vw, 1.2rem);
  line-height: 1.85;
  color: var(--lp-muted);
}

/* :where() keeps these element rules at zero specificity so page-specific
   widget CSS (loaded after this file) always wins over them. */
:where(.lp-article) p,
:where(.lp-article) li {
  font-size: 1.05rem;
  line-height: 1.9;
}

:where(.lp-article) p {
  margin: 0 0 1.1rem;
}

:where(.lp-article) h2 {
  position: relative;
  margin: 0 0 1rem;
  padding: 0 0 0.55rem 16px;
  border-bottom: 2px solid var(--lp-h2-line);
  font-family: var(--lp-font-serif);
  font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--lp-heading);
}

/* the orange accent bar sits beside the heading text, above the underline */
:where(.lp-article) h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.1em;
  bottom: calc(0.55rem + 0.1em);
  width: 4px;
  border-radius: 2px;
  background: var(--lp-orange);
}

:where(.lp-article) h3 {
  margin: 2rem 0 0.7rem;
  font-size: 1.22rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--lp-heading);
}

:where(.lp-article) h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.45;
  color: #262a31;
}

:where(.lp-article) ul,
:where(.lp-article) ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
}

:where(.lp-article) li {
  margin: 0.45rem 0;
}

:where(.lp-article) li::marker {
  color: var(--lp-orange);
}

:where(.lp-article) strong {
  color: var(--lp-heading);
  font-weight: 600;
}

:where(.lp-article) a {
  color: var(--lp-orange-dark);
}

:where(.lp-article) table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0 1.6rem;
  font-size: 0.95rem;
}

:where(.lp-article) th {
  text-align: left;
  padding: 12px 16px;
  background: var(--lp-bg);
  font-weight: 600;
  color: var(--lp-heading);
  border-bottom: 1px solid var(--lp-border);
}

:where(.lp-article) td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--lp-border);
}

.lp-section {
  margin-top: 3rem;
  scroll-margin-top: calc(var(--lp-sticky-h) + 16px);
}

.lp-intro {
  scroll-margin-top: calc(var(--lp-sticky-h) + 16px);
}

/* ---------- Section box (body copy of each lesson section) ---------- */
.lp-prose {
  background: linear-gradient(135deg, #fff8f0, #fff);
  border: 1px solid var(--lp-box-border);
  border-left: 5px solid var(--lp-box-accent);
  border-radius: 12px;
  padding: 1.4rem 1.6rem;
}

.lp-prose > :first-child {
  margin-top: 0;
}

.lp-prose > :last-child {
  margin-bottom: 0;
}

/* ---------- Callouts ---------- */
.lp-callout {
  margin-top: 3rem;
  padding: 28px 32px;
  border-left: 4px solid var(--lp-blue);
  border-radius: 4px 12px 12px 4px;
  background: var(--lp-blue-soft);
  scroll-margin-top: calc(var(--lp-sticky-h) + 16px);
}

.lp-callout h2::before,
.lp-related h2::before {
  content: none;
}

.lp-callout h2,
.lp-related h2 {
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
  font-family: var(--lp-font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--lp-heading);
}

.lp-callout ul {
  margin-bottom: 0;
}

.lp-callout li::marker {
  color: var(--lp-blue);
}

.lp-related {
  margin-top: 3rem;
  padding: 28px 32px;
  border-left: 4px solid var(--lp-orange);
  border-radius: 4px 12px 12px 4px;
  background: var(--lp-orange-soft);
  scroll-margin-top: calc(var(--lp-sticky-h) + 16px);
}

.lp-related ul {
  margin: 0;
  padding-left: 1.3rem;
  columns: 2;
  column-gap: 48px;
}

.lp-related li {
  break-inside: avoid;
  margin: 0 0 0.75rem;
}

.lp-related a {
  font-weight: 600;
  color: var(--lp-orange-dark);
  text-decoration: none;
}

.lp-related a:hover {
  text-decoration: underline;
}

/* ---------- Previous / next lesson ---------- */
.lp-lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 2.6rem;
  padding-top: 1.8rem;
  border-top: 1px solid var(--lp-border);
}

.lp-lesson-link {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  text-decoration: none;
  color: var(--lp-heading);
}

.lp-lesson-link--next {
  text-align: right;
  margin-left: auto;
}

.lp-lesson-text small {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--lp-muted);
}

.lp-lesson-text strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.lp-lesson-arrow {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--lp-border-strong);
  border-radius: 50%;
  background: #fff;
  font-size: 0.95rem;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.lp-lesson-link:hover .lp-lesson-arrow {
  background: var(--lp-orange);
  border-color: var(--lp-orange);
  color: #fff;
}

/* ---------- Sidebar ---------- */
.lp-aside {
  position: sticky;
  top: calc(var(--lp-sticky-h) + 24px);
  display: grid;
  gap: 24px;
  min-width: 0;
}

.lp-panel {
  background: var(--lp-surface);
  border: 1px solid var(--lp-border);
  border-radius: var(--lp-radius);
  box-shadow: var(--lp-shadow);
  padding: 26px;
}

.lp-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
  font-family: var(--lp-font-sans);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--lp-heading);
}

.lp-panel-title svg {
  width: 20px;
  height: 20px;
  color: var(--lp-blue);
  flex-shrink: 0;
}

.lp-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--lp-border);
}

.lp-toc-list a {
  display: block;
  margin-left: -1px;
  padding: 10px 20px;
  border-left: 3px solid transparent;
  color: var(--lp-muted);
  text-decoration: none;
  font-size: 0.98rem;
  line-height: 1.4;
  transition: color 0.2s, border-color 0.2s;
}

.lp-toc-list a:hover {
  color: var(--lp-heading);
}

.lp-toc-list a.is-active {
  color: var(--lp-orange-dark);
  font-weight: 600;
  border-left-color: var(--lp-orange);
}

/* ---------- Footer ---------- */
.lp-footer {
  background: #1a1d22;
  color: #b7bcc5;
}

.lp-footer-inner {
  max-width: var(--lp-max);
  margin: 0 auto;
  padding: 0 var(--lp-gutter);
}

.lp-footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 1.4fr;
  gap: 40px;
  padding-top: 56px;
  padding-bottom: 44px;
}

.lp-footer-title {
  margin: 0 0 18px;
  font-family: var(--lp-font-sans);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.lp-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lp-footer li {
  margin: 0 0 12px;
}

.lp-footer a {
  color: #b7bcc5;
  text-decoration: none;
  transition: color 0.2s;
}

.lp-footer a:hover {
  color: #fff;
}

.lp-footer-logo {
  display: inline-block;
  line-height: 0;
}

.lp-footer-logo img {
  display: block;
  height: 30px;
  width: auto;
}

.lp-footer-tag {
  margin: 18px 0 20px;
  max-width: 300px;
  line-height: 1.65;
}

.lp-social {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lp-social li {
  margin: 0;
}

.lp-social a {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1rem;
  transition: background 0.2s, transform 0.2s;
}

.lp-social a:hover {
  background: var(--lp-orange);
  transform: translateY(-2px);
}

.lp-footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.lp-footer-bottom .lp-footer-inner {
  padding-top: 20px;
  padding-bottom: 20px;
  font-size: 0.88rem;
  text-align: center;
}

/* ---------- Back to top ---------- */
.lp-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--lp-orange);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(232, 113, 10, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
  z-index: 40;
}

.lp-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .lp-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    padding-top: 32px;
  }

  .lp-aside {
    position: static;
  }

  .lp-footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .lp-header-inner {
    min-height: 64px;
    gap: 10px;
  }

  .lp-logo img {
    height: 38px;
    width: 38px;
    border-radius: 8px;
  }

  .lp-search-field {
    height: 42px;
    padding: 0 14px;
  }

  .lp-search {
    min-width: 0;
    max-width: none;
  }

  .lp-hide-sm {
    display: none;
  }

  .lp-icon-btn,
  .lp-menu-btn {
    width: 40px;
    height: 40px;
  }

  .lp-menu-btn {
    margin-left: 0;
  }

  .lp-account-panel {
    right: -52px;
  }

  .lp-account.is-signed-in .lp-account-label {
    display: none;
  }

  .lp-account.is-signed-in .lp-account-btn {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .lp-layout {
    padding-top: 20px;
    padding-bottom: 40px;
  }

  .lp-related ul {
    columns: 1;
  }

  .lp-callout,
  .lp-related {
    padding: 22px 20px;
  }

  .lp-prose,
  .lp-lead {
    padding: 1.1rem 1.1rem;
  }

  .lp-lesson-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 22px;
  }

  .lp-lesson-link--next {
    justify-content: flex-end;
  }

  .lp-panel {
    padding: 22px;
  }

  .lp-footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-top: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .lp-body *,
  .lp-body *::before,
  .lp-body *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Lesson components inside a section box ----------
   Component look-and-feel (concept-box, example-card, math-example, topic-table,
   step demos ...) lives in resources/css/style.css and the per-page widget CSS;
   these rules only fit them into the boxed section layout. */
.lp-prose .concept-box {
  background: #fff;
  border-width: 1px 1px 1px 4px;
}

.lp-prose .concept-box > :last-child,
.lp-prose .example-body > :last-child,
.lp-prose .tip-box > :last-child {
  margin-bottom: 0;
}

.lp-prose .example-card {
  margin-top: 1rem;
}

.lp-prose .concept-box p,
.lp-prose .example-body p {
  line-height: 1.85;
}

.lp-article img,
.lp-article svg {
  max-width: 100%;
}

.lp-article .btn {
  display: inline-block;
  padding: 9px 22px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.lp-article .btn-primary,
.lp-article .btn-secondary {
  background: var(--lp-orange);
  color: #fff;
}

.lp-article .btn-primary:hover,
.lp-article .btn-secondary:hover {
  background: #d1650a;
  color: #fff;
}

.lp-prose {
  min-width: 0;
  overflow-wrap: break-word;
}

@media (max-width: 640px) {
  .lp-prose table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .lp-prose .math-example,
  .lp-prose .math-stmt {
    overflow-x: auto;
  }
}

.lp-lead + .lp-prose {
  margin-top: 1.25rem;
}

/* ---------- Alerts / Messages hover panels ---------- */
.lp-notify {
  position: relative;
}

.lp-notify-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: -60px;
  width: 300px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid var(--lp-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(20, 22, 28, 0.16);
  z-index: 60;
}

/* invisible bridge so the panel stays open while the pointer crosses the gap */
.lp-notify-panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  height: 8px;
}

.lp-notify:hover .lp-notify-panel,
.lp-notify:focus-within .lp-notify-panel {
  display: block;
}

.lp-notify:hover > .lp-icon-btn {
  background: var(--lp-bg);
}

.lp-notify-title {
  margin: 0 0 10px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--lp-border);
  font-size: 1rem;
  font-weight: 700;
  color: var(--lp-heading);
}

.lp-notify-panel p {
  margin: 0;
  padding: 8px 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--lp-muted);
  border-bottom: 1px solid var(--lp-border);
}

.lp-notify-more {
  display: block;
  margin-top: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--lp-orange-dark);
  text-decoration: none;
}

.lp-notify-more:hover {
  text-decoration: underline;
}

/* ---------- Pages that still load the legacy root style.css ----------
   (great mathematicians, tricks, timeline, fun facts, sudoku) */
.lp-body {
  overflow-x: visible;
}

.lp-header {
  display: block;
  width: auto;
  padding: 0;
  box-shadow: none;
}

.lp-layout--single {
  grid-template-columns: minmax(0, 1fr);
}

/* card-style content (tricks, eras, facts, games) keeps its own component styling */
.lp-section--cards h2::before {
  display: none;
}

.lp-section--cards h2 {
  padding-left: 0;
  border-bottom: 0;
}

/* long tables of contents scroll inside the sticky panel */
.lp-aside .lp-panel {
  max-height: calc(100vh - var(--lp-sticky-h) - 48px);
  overflow-y: auto;
}

/* ---------- Mobile bottom navigation ---------- */
.lp-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .lp-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  }

  .lp-bottom-item {
    flex: 1;
    max-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 40px;
    color: #94a3b8;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
  }

  .lp-bottom-item i {
    font-size: 1.45rem;
  }

  .lp-bottom-item span {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.3px;
  }

  .lp-bottom-item.is-active {
    color: #f97316;
  }

  .lp-bottom-item.is-active span {
    font-weight: 600;
  }

  .lp-bottom-item:active {
    transform: scale(0.94);
    background: rgba(249, 115, 22, 0.08);
  }

  /* keep the footer and back-to-top button clear of the bar */
  .lp-body {
    padding-bottom: 78px;
  }

  .lp-top {
    bottom: 92px;
  }
}

/* ---------- Legal / info pages ---------- */
.lp-meta {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: var(--lp-muted);
}

.lp-layout--narrow {
  max-width: 1040px;
}

.lp-article hr {
  margin: 1.6rem 0;
  border: 0;
  border-top: 1px solid var(--lp-border);
}

/* header + footer used on pages that do not carry the .lp-body class (quiz, dashboard) */
.lp-header,
.lp-footer {
  font-family: var(--lp-font-sans);
  line-height: 1.7;
}
