/* MathPages shared layout, v1.1.1
   =================================================================
   One identical copy of this file ships with every *.mathpages.org site
   (MathErrata, MathCollab, MathLearn, MathWork, MathVideos). Change the
   master copy and then copy it to each site; never edit a site's copy.

   It provides: colour tokens (light + dark), base typography, the two-row
   header (brand · search · account, then section tabs), the footer bar,
   the theme switcher, the split sign-in page, and (v1.1) one spec for
   controls and shapes: buttons, text boxes, dropdowns, corner rounding.
   Everything is prefixed "mp-" so it cannot collide with a site's classes.

   Shared rules a site's own stylesheet should follow (v1.1):
   - Corner rounding: only --mp-radius-sm / --mp-radius / --mp-radius-lg /
     --mp-radius-pill (tags; controls; cards and panels; chips and switches).
   - Boldness: only 400 (text), 600 (semi-bold labels) and 700 (bold).
   - Text boxes and dropdowns: border var(--mp-control-border) (3:1 contrast),
     height var(--mp-control-height), or --mp-control-height-compact in
     dense staff forms. Buttons: the .mp-button spec or the same values;
     small buttons (.mp-button-small) are bold too.
   - Checkboxes and radio buttons (v1.1.1): set here for every site, 18px
     (24px on touch screens) in the accent colour. A site should not resize
     them; .mp-check lays out a checkbox beside its label.
   - Layout changes only at these widths: 1180, 960, 760 and 520px
     (max-width queries). The shared header and footer use the same ones.

   A site's own stylesheet loads AFTER this file and normally sets only:
     --mp-product     the site's own colour (middle stripe of its mark)
     --mp-max-width   1460px by default; MathLearn uses 100%
   plus its own page components. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --mp-page: #fbf8f3;
  --mp-surface: #fffdf9;
  --mp-surface-soft: #fff6f0;
  --mp-surface-muted: #f5efe8;
  --mp-header-bg: #fffdf9;
  --mp-footer-bg: #f5efe8;
  --mp-ink: #302b28;
  --mp-muted: #665e58;
  --mp-border: #e5dcd3;
  --mp-border-strong: #cbbdb3;
  --mp-control-border: #8d7f71;
  --mp-link: #973d29;
  --mp-link-hover: #702815;
  --mp-accent: #bb5237;
  --mp-accent-hover: #973d29;
  --mp-on-accent: #fff;
  --mp-tab-active: #bb5237;
  --mp-focus: #b96a48;
  --mp-error-bg: #fff0f1;
  --mp-error-ink: #8e2029;
  --mp-product: #bb5237;
  --mp-shadow: 0 4px 18px rgb(69 48 35 / 4%);
  --mp-serif: Georgia, "Times New Roman", serif;
  --mp-sans: "Segoe UI", Aptos, "Helvetica Neue", Arial, sans-serif;
  --mp-max-width: 1460px;
  --mp-gutter: 24px;
  /* Shapes and controls (v1.1). */
  --mp-radius-sm: 6px;
  --mp-radius: 8px;
  --mp-radius-lg: 12px;
  --mp-radius-pill: 999px;
  --mp-control-height: 2.75rem;
  --mp-control-height-compact: 2.5rem;
  --mp-button-font: .9375rem;
  font-family: var(--mp-sans);
  font-synthesis: none;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --mp-page: #15191d;
  --mp-surface: #22282d;
  --mp-surface-soft: #352b27;
  --mp-surface-muted: #1b2226;
  --mp-header-bg: #1b2226;
  --mp-footer-bg: #1a2125;
  --mp-ink: #f3eee9;
  --mp-muted: #c0b5ab;
  --mp-border: #4c565c;
  --mp-border-strong: #778088;
  --mp-control-border: #7e8a8f;
  --mp-link: #f5b08c;
  --mp-link-hover: #ffe0ce;
  --mp-accent: #95402d;
  --mp-accent-hover: #a74933;
  --mp-tab-active: #e8a484;
  --mp-focus: #f8d66a;
  --mp-error-bg: #3d2328;
  --mp-error-ink: #ffb8bd;
  --mp-shadow: 0 5px 18px rgb(13 12 21 / 38%);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--mp-page); color: var(--mp-ink); font: 1rem/1.6 var(--mp-sans); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
h1, h2, h3, h4 { font-family: var(--mp-serif); font-weight: 700; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: clamp(1.625rem, 2.6vw, 2rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.2rem; }
a { color: var(--mp-link); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { color: var(--mp-link-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--mp-focus); outline-offset: 3px; }
.mp-sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.mp-skip-link { position: absolute; z-index: 1000; left: 1rem; top: .75rem; padding: .7rem 1rem; background: var(--mp-surface); color: var(--mp-ink); font-weight: 600; transform: translateY(-200%); }
.mp-skip-link:focus { transform: none; }

/* ---------- Page frame: footer always reaches the bottom ---------- */
.mp-frame { display: flex; flex-direction: column; min-height: 100vh; }
.mp-main { flex: 1 0 auto; }
.mp-shell { width: min(var(--mp-max-width), 100% - 2 * var(--mp-gutter)); margin-inline: auto; }

/* ---------- Header, row 1: brand · search · account ---------- */
.mp-header { background: var(--mp-header-bg); color: var(--mp-ink); border-bottom: 1px solid var(--mp-border); }
.mp-header-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; min-height: 64px; padding-block: 12px 6px; }
.mp-brand { display: inline-flex; align-items: center; gap: 10px; flex: none; color: var(--mp-ink); text-decoration: none; }
.mp-brand:hover { color: var(--mp-ink); }
/* The mark keeps its cream tile in dark mode so its dark stripes stay visible. */
.mp-brand-mark { display: block; width: 42px; height: 42px; padding: 3px; background: #fffdf9; border-radius: 7px; }
.mp-wordmark { font: 700 25px/1.2 var(--mp-serif); letter-spacing: -.032em; }
.mp-header-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .5rem 1.25rem; flex: 1 1 auto; min-width: 0; }

/* Search: a single box with its button on the right (the MathVideos pattern). */
.mp-search { flex: 0 1 20rem; max-width: 20rem; min-width: 0; margin: 0; }
.mp-search-controls { display: flex; align-items: stretch; gap: .5rem; }
.mp-search-controls input { flex: 1 1 auto; width: 100%; min-width: 0; min-height: var(--mp-control-height); margin: 0; padding: .6rem .75rem; border: 1px solid var(--mp-control-border); border-radius: var(--mp-radius); background: var(--mp-surface); color: var(--mp-ink); font-size: 1rem; line-height: 1.4; appearance: none; }
.mp-search-controls input::placeholder { color: var(--mp-muted); opacity: 1; }
.mp-search-controls button { flex: none; min-height: var(--mp-control-height); margin: 0; padding: .6rem .95rem; border: 1px solid var(--mp-accent); border-radius: var(--mp-radius); background: var(--mp-accent); color: var(--mp-on-accent); font-size: var(--mp-button-font); font-weight: 700; cursor: pointer; }
.mp-search-controls button:hover { background: var(--mp-accent-hover); border-color: var(--mp-accent-hover); }

/* Account cluster: theme switcher, site extras, name, sign in / sign out. */
.mp-account { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8125rem; }
.mp-account form { display: flex; margin: 0; }
.mp-account-link { color: var(--mp-link); font-weight: 700; text-decoration: none; white-space: nowrap; }
.mp-account-link:hover, .mp-account-link[aria-current="page"] { color: var(--mp-link-hover); text-decoration: underline; }
.mp-account-note { color: var(--mp-muted); white-space: nowrap; }
.mp-account-name { max-width: 160px; overflow: hidden; color: var(--mp-muted); text-overflow: ellipsis; white-space: nowrap; }
.mp-account-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; margin: 0; padding: .35rem .9rem; border: 1px solid var(--mp-border); border-radius: var(--mp-radius); background: transparent; color: var(--mp-link); font-size: .8125rem; font-weight: 700; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer; }
.mp-account-button:hover { background: var(--mp-surface-soft); color: var(--mp-link); text-decoration: none; }
.mp-theme { display: inline-flex; align-items: center; gap: .4rem; color: var(--mp-ink); font-weight: 700; white-space: nowrap; }
.mp-theme select { min-height: 36px; margin: 0; padding: .3rem .5rem; border: 1px solid var(--mp-control-border); border-radius: var(--mp-radius); background: var(--mp-surface); color: var(--mp-ink); font-size: .8125rem; font-weight: 400; }

/* ---------- Header, row 2: section tabs ---------- */
.mp-header-nav { display: flex; align-items: stretch; min-height: 48px; }
.mp-tabs { display: flex; align-items: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.mp-tabs::-webkit-scrollbar { display: none; }
.mp-tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 11px 16px; border-bottom: 3px solid transparent; color: var(--mp-muted); font: 400 1rem/1.4 var(--mp-serif); text-decoration: none; white-space: nowrap; }
.mp-tabs a:hover { background: var(--mp-surface-soft); color: var(--mp-ink); }
.mp-tabs a[aria-current="page"], .mp-tabs a[aria-current="location"] { border-bottom-color: var(--mp-tab-active); color: var(--mp-link); }

/* ---------- Footer bar: identity · links · copyright ---------- */
.mp-footer { background: var(--mp-footer-bg); color: var(--mp-muted); border-top: 1px solid var(--mp-border); font-size: .8125rem; }
.mp-footer-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem 1.5rem; padding-block: 22px; }
.mp-footer-id { justify-self: start; }
.mp-footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1.5rem; }
.mp-footer-links a { display: inline-block; color: var(--mp-muted); line-height: 24px; text-decoration: none; }
.mp-footer-links a:hover { color: var(--mp-link); text-decoration: underline; }
.mp-footer-copyright { justify-self: end; white-space: nowrap; }

/* ---------- Controls: buttons, text boxes, dropdowns (v1.1) ----------
   Sites may use these classes, or give their own classes the same values. */
.mp-button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: var(--mp-control-height); margin: 0; padding: .6rem 1.1rem; border: 1px solid var(--mp-border-strong); border-radius: var(--mp-radius); background: var(--mp-surface-soft); color: var(--mp-link); font-size: var(--mp-button-font); font-weight: 700; line-height: 1.3; text-decoration: none; cursor: pointer; }
.mp-button:hover { border-color: var(--mp-link); color: var(--mp-link); }
.mp-button-primary { border-color: var(--mp-accent); background: var(--mp-accent); color: var(--mp-on-accent); }
.mp-button-primary:hover { border-color: var(--mp-accent-hover); background: var(--mp-accent-hover); color: var(--mp-on-accent); }
.mp-button-small { min-height: 2.25rem; padding: .35rem .8rem; font-size: .8125rem; }
.mp-button-block { width: 100%; }
.mp-input { width: 100%; min-height: var(--mp-control-height); margin: 0; padding: .6rem .75rem; border: 1px solid var(--mp-control-border); border-radius: var(--mp-radius); background: var(--mp-surface); color: var(--mp-ink); font-size: 1rem; line-height: 1.4; }
textarea.mp-input { line-height: 1.5; resize: vertical; }
.mp-input-compact { min-height: var(--mp-control-height-compact); padding-block: .45rem; font-size: .9375rem; }

/* Checkboxes and radio buttons (v1.1.1): one size everywhere, in the accent colour. */
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; flex: none; vertical-align: middle; accent-color: var(--mp-accent); }
@media (pointer: coarse) { input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; } }
.mp-check { display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; font-weight: 400; cursor: pointer; }
.mp-check input { margin: 3px 0 0; }
.mp-field label.mp-check { display: flex; margin-bottom: 0; font-size: .875rem; font-weight: 400; }   /* not a field heading */

.mp-field { margin: 0 0 19px; }
.mp-field label { display: block; margin-bottom: 8px; font-size: .8125rem; font-weight: 700; }
.mp-field input:not([type="checkbox"]):not([type="radio"]) { display: block; width: 100%; min-height: var(--mp-control-height); margin: 0; padding: .6rem .75rem; border: 1px solid var(--mp-control-border); border-radius: var(--mp-radius); background: var(--mp-surface); color: var(--mp-ink); }
.mp-form-errors, .mp-field-errors { margin: 0 0 16px; padding: 9px 12px; border-radius: var(--mp-radius); background: var(--mp-error-bg); color: var(--mp-error-ink); font-size: .8125rem; }
.mp-field-errors { margin: 8px 0 0; }
.mp-field-help { margin: 7px 0 0; color: var(--mp-muted); font-size: .8125rem; line-height: 1.45; }
.mp-form-errors p, .mp-field-errors p, .mp-form-errors ul, .mp-field-errors ul { margin: 0; padding: 0; list-style: none; }
.mp-password { display: flex; align-items: stretch; gap: 8px; }
.mp-password input { flex: 1; min-width: 0; }
.mp-password-toggle { flex: none; min-width: 58px; min-height: var(--mp-control-height); margin: 0; padding: 8px; border: 1px solid var(--mp-control-border); border-radius: var(--mp-radius); background: var(--mp-surface-soft); color: var(--mp-link); font-size: .8125rem; font-weight: 700; cursor: pointer; }

/* ---------- Sign-in page: brand panel beside the form card ---------- */
.mp-auth-main { width: min(1080px, 100% - 2 * var(--mp-gutter)); margin-inline: auto; padding-block: 38px 34px; }
.mp-auth-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .85fr); gap: 28px; align-items: stretch; }
.mp-auth-brand { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; min-height: clamp(490px, 66vh, 660px); overflow: hidden; border: 1px solid var(--mp-border); border-radius: var(--mp-radius-lg); background: linear-gradient(150deg, var(--mp-surface), var(--mp-surface-soft)); color: var(--mp-ink); }
.mp-auth-brand img { width: min(48%, 240px); height: auto; border-radius: 14%; }
html[data-theme="dark"] .mp-auth-brand img { padding: 5%; background: #fffdf9; }
.mp-auth-wordmark { font: 700 clamp(28px, 3vw, 42px)/1.1 var(--mp-serif); letter-spacing: -.8px; }
.mp-auth-card { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: clamp(28px, 4.4vw, 54px); border: 1px solid var(--mp-border); border-radius: var(--mp-radius-lg); background: var(--mp-surface); box-shadow: var(--mp-shadow); }
.mp-auth-card h1 { margin: 0 0 22px; font-size: clamp(32px, 3vw, 40px); }
.mp-auth-note { margin: 22px 0 0; color: var(--mp-muted); font-size: .875rem; line-height: 1.5; }

/* ---------- Narrow screens: 960 · 760 · 520 ---------- */
@media (max-width: 960px) {
  /* Brand and account share the first line; search takes the full second line. */
  .mp-header-top { flex-wrap: wrap; gap: .6rem 1rem; padding-block: 10px 8px; }
  .mp-header-tools { display: contents; }
  .mp-account { order: 1; margin-left: auto; gap: .4rem .75rem; }
  .mp-search { order: 2; flex: 1 1 100%; max-width: none; }
  .mp-auth-layout { grid-template-columns: 1fr; gap: 18px; }
  .mp-auth-brand { flex-direction: row; gap: 25px; min-height: 190px; }
  .mp-auth-brand img { width: 100px; }
}
@media (max-width: 760px) {
  :root { --mp-gutter: 16px; }
  .mp-brand-mark { width: 36px; height: 36px; }
  .mp-wordmark { font-size: 21px; }
  .mp-theme-text, .mp-account-name { display: none; }
  .mp-tabs a { min-height: 46px; padding: 10px 12px; font-size: .95rem; }
  .mp-footer-inner { grid-template-columns: 1fr; justify-items: start; }
  .mp-footer-links { justify-content: flex-start; }
  .mp-footer-copyright { justify-self: start; }
}
@media (max-width: 520px) {
  .mp-auth-card { padding: 27px 22px; }
  .mp-auth-brand { min-height: 145px; }
  .mp-auth-brand img { width: 80px; }
}
@media (pointer: coarse) {
  .mp-account-button, .mp-theme select { min-height: 44px; }
}
@media (forced-colors: active) {
  .mp-tabs a[aria-current="page"], .mp-tabs a[aria-current="location"] { border-bottom-color: Highlight; }
}
@media print {
  .mp-header-tools, .mp-header-nav, .mp-footer, .mp-skip-link { display: none; }
}
