/* Alpha Academy Cambodia — Grade 12 maths lesson pages
   ---------------------------------------------------------------------------
   Shared by grade-12-complex-number.html and grade-12-limit.html: both are a
   lesson view and an exercises view behind one switch, so both use the cx*
   markup produced by complex-number.js / limit.js. The lm* rules at the foot
   are the multiple-choice extras the limits page adds.

   Namespaced cx* — style.css owns .card, .chip, .tag and friends.

   MathJax note: the global border-box reset knocks MathJax's radicals out of
   alignment, exactly as on the formula book page, so its subtree is put back
   on content-box below. Do not add padding or borders to mjx-* elements.    */

.cx-wrap { max-width: 1000px; margin-inline: auto; padding-inline: var(--gutter); }
.cx-hide { display: none !important; }

mjx-container, mjx-container * { box-sizing: content-box; }
mjx-container[display="true"] { margin: 0 !important; }

/* Khmer needs its own stack ahead of the Latin face. */
.cx-body {
  font-family: "Kantumruy Pro", "Noto Sans Khmer", "Khmer OS Battambang",
               var(--font-sans);
  line-height: 1.95;
}
:root[lang="en"] .cx-body { font-family: var(--font-sans); line-height: 1.8; }

/* ============================================================ view tabs */
.cx-tabs {
  display: flex; gap: .3rem; background: var(--surface-2);
  border: 1px solid var(--ink-200); border-radius: var(--r-pill);
  padding: .35rem; margin-bottom: 1.4rem; overflow-x: auto;
}
.cx-tabs button {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  font-weight: 600; font-size: .92rem; white-space: nowrap; flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1.1rem; border-radius: var(--r-pill); min-height: 48px;
  background: transparent; color: var(--ink-500); transition: all .16s var(--ease);
}
.cx-tabs button:hover { color: var(--brand-600); }
.cx-tabs button[aria-selected="true"] { background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-xs); }
.cx-tabs button svg { width: 17px; height: 17px; flex: none; }
.cx-tabs .lv {
  font-size: .72rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: var(--r-pill); background: rgba(255, 255, 255, .25);
}
.cx-tabs button[aria-selected="false"] .lv { background: var(--brand-50); color: var(--brand-600); }

/* ================================================================ lesson */
.cx-toc {
  background: var(--surface-2); border: 1px solid var(--ink-200);
  border-radius: var(--r-md); padding: 1rem 1.2rem; margin-bottom: 2rem;
}
.cx-toc b {
  display: block; font-size: .74rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-400); margin-bottom: .5rem;
}
.cx-toc ol { margin: 0; padding-left: 1.2rem; columns: 2; column-gap: 1.6rem; }
.cx-toc li { font-size: .9rem; margin-bottom: .2rem; break-inside: avoid; }
@media (max-width: 640px) { .cx-toc ol { columns: 1; } }

.cx-sec { margin-bottom: 2.6rem; scroll-margin-top: 110px; }
.cx-sec > h3 {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  font-size: 1.15rem; margin: 0 0 .9rem; padding-bottom: .6rem;
  border-bottom: 2px solid var(--brand-100);
}
.cx-sec > h3 .n {
  flex: none; display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand-50); color: var(--brand-600); font-size: .9rem; font-weight: 700;
}
.cx-sec p { font-size: .97rem; color: var(--ink-700); margin: 0 0 .9rem; }

.cx-math {
  overflow-x: auto; overflow-y: hidden; margin: 0 0 1rem;
  background: var(--surface-2); border: 1px solid var(--ink-200);
  border-left: 4px solid var(--brand-500); border-radius: var(--r-sm);
  padding: .85rem 1rem;
}
.cx-list { margin: 0 0 1rem; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .45rem; }
.cx-list li { font-size: .95rem; color: var(--ink-700); }

.cx-note {
  background: var(--accent-100); border-left: 4px solid var(--accent-500);
  border-radius: var(--r-sm); padding: .8rem 1rem; font-size: .92rem !important;
  color: var(--ink-700);
}

.cx-eg {
  border: 1px solid var(--ink-200); border-radius: var(--r-md);
  background: var(--surface); padding: 1rem 1.1rem; margin: 1.2rem 0;
  box-shadow: var(--shadow-xs);
}
.cx-eg .tag {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--success-500);
  background: color-mix(in srgb, var(--success-500) 14%, transparent);
  border-radius: var(--r-pill); padding: .2rem .65rem; margin-bottom: .5rem;
}
.cx-eg .q { font-weight: 600; color: var(--ink-900); }
.cx-eg .cx-math { border-left-color: var(--success-500); }

/* ============================================================ exercises */
.cx-bar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  background: var(--surface); border: 1px solid var(--ink-200);
  border-radius: var(--r-md); padding: .65rem .8rem;
  box-shadow: var(--shadow-xs); margin-bottom: 1.2rem;
}
.cx-search { position: relative; flex: 1 1 220px; min-width: 0; }
.cx-search input {
  width: 100%; font: inherit; font-size: .92rem; min-height: 44px;
  padding: .55rem .9rem .55rem 2.5rem; border-radius: var(--r-pill);
  border: 1px solid var(--ink-200); background: var(--surface-2); color: var(--ink-900);
}
.cx-search input:focus { outline: 0; border-color: var(--brand-500); box-shadow: var(--ring); }
.cx-search svg {
  position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--ink-400); pointer-events: none;
}
.cx-btn {
  appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .85rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: var(--r-pill); white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--ink-200); color: var(--ink-700);
  transition: all .15s var(--ease);
}
.cx-btn:hover { border-color: var(--brand-400); color: var(--brand-600); }
.cx-toggle[aria-pressed="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }

.cx-stats {
  display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; align-items: center;
  font-size: .82rem; color: var(--ink-500); margin: 0 0 1.2rem;
}
.cx-stats b { color: var(--brand-600); }
.cx-progress {
  flex: 1 1 150px; height: 7px; border-radius: 99px; background: var(--ink-100);
  overflow: hidden; min-width: 110px;
}
.cx-progress i { display: block; height: 100%; width: 0; background: var(--grad-brand); transition: width .4s var(--ease); }

.cx-list-ex { display: flex; flex-direction: column; gap: 1rem; }
.cx-card {
  background: var(--surface); border: 1px solid var(--ink-200);
  border-radius: var(--r-lg); padding: clamp(1rem, 2.6vw, 1.4rem);
  box-shadow: var(--shadow-xs); transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.cx-card:hover { box-shadow: var(--shadow-sm); }
.cx-card.is-done { border-color: var(--success-500); background: var(--surface-2); }
.cx-card.is-hidden { display: none; }

.cx-head { display: flex; align-items: flex-start; gap: .8rem; }
.cx-num {
  flex: none; display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand-50); color: var(--brand-600); font-weight: 700; font-size: 1rem;
}
.cx-card.is-done .cx-num { background: var(--success-500); color: #fff; }
/* A four-digit examination year needs a pill, not the square number chip. */
.cx-num--year {
  width: auto; min-width: 38px; padding: 0 .7rem; border-radius: var(--r-pill);
  font-size: .86rem; letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
.cx-q { flex: 1; min-width: 0; font-size: .98rem; color: var(--ink-900); }

.cx-badge {
  display: inline-block; margin-left: .5rem; font-size: .68rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; vertical-align: middle;
  background: var(--brand-50); color: var(--brand-600);
  border-radius: var(--r-pill); padding: .18rem .6rem;
}
.cx-badge--extra { background: var(--accent-100); color: var(--accent-500); }

.cx-done {
  appearance: none; cursor: pointer; flex: none;
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--ink-200); color: var(--ink-400); transition: all .15s var(--ease);
}
.cx-done svg { width: 18px; height: 18px; }
.cx-done:hover { border-color: var(--success-500); color: var(--success-500); }
.cx-done[aria-pressed="true"] { background: var(--success-500); border-color: var(--success-500); color: #fff; }

.cx-parts {
  list-style: none; margin: .8rem 0 0; padding: 0 0 0 calc(38px + .8rem);
  display: flex; flex-direction: column; gap: .5rem;
}
.cx-parts li { display: flex; gap: .55rem; align-items: flex-start; font-size: .94rem; }
.cx-parts .k { flex: none; min-width: 1.8em; font-weight: 700; color: var(--brand-600); }
.cx-parts .tt { flex: 1; min-width: 0; color: var(--ink-700); overflow-x: auto; }

/* =========================================== reference tables (conics) */
.cx-tblwrap { overflow-x: auto; margin: 1rem 0 1.4rem; -webkit-overflow-scrolling: touch; }
.cx-tblcap {
  margin: 0 0 .5rem; font-weight: 700; font-size: .93rem; color: var(--ink-700);
}
.cx-tbl {
  border-collapse: collapse; width: 100%; min-width: 460px;
  background: var(--surface); font-size: .92rem;
  border: 1px solid var(--ink-200); border-radius: var(--r-sm); overflow: hidden;
}
.cx-tbl th, .cx-tbl td {
  border: 1px solid var(--ink-200); padding: .55rem .7rem; text-align: center;
  vertical-align: middle;
}
.cx-tbl thead th {
  background: var(--brand-50); color: var(--brand-600); font-weight: 700;
}
.cx-tbl tbody th {
  background: var(--surface-2); color: var(--ink-700); font-weight: 600;
  text-align: left; white-space: nowrap;
}
.cx-tbl tbody tr:hover td { background: var(--surface-2); }

.cx-empty { text-align: center; color: var(--ink-400); font-size: .95rem; padding: 3rem 0; }

/* Year pills are wider than number chips, so the parts hang further in. */
.cx-card--year .cx-parts { padding-left: calc(62px + .8rem); }

@media (max-width: 640px) { .cx-parts, .cx-card--year .cx-parts { padding-left: 0; } }

/* ============================================= multiple choice (limits) */
.lm-group {
  display: flex; align-items: center; gap: .6rem;
  font-size: 1.05rem; margin: 2.2rem 0 .8rem; padding-bottom: .5rem;
  border-bottom: 2px solid var(--brand-100);
}
.lm-group .c {
  font-size: .72rem; font-weight: 700; padding: .15rem .55rem;
  border-radius: var(--r-pill); background: var(--brand-50); color: var(--brand-600);
}

.lm-opts {
  list-style: none; margin: .8rem 0 0; padding: 0 0 0 calc(38px + .8rem);
  display: grid; gap: .45rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.lm-opt {
  appearance: none; cursor: pointer; font: inherit; text-align: left; width: 100%;
  display: flex; align-items: center; gap: .5rem; min-height: 46px;
  padding: .45rem .8rem; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--ink-200); color: var(--ink-800);
  transition: all .14s var(--ease);
}
.lm-opt:hover { border-color: var(--brand-400); background: var(--brand-50); }
.lm-opt .lt { flex: none; font-weight: 700; color: var(--brand-600); min-width: 1.5em; }
.lm-opt .vl { flex: 1; min-width: 0; overflow-x: auto; }
.lm-opt.is-picked {
  border-color: var(--brand-500); background: var(--brand-50);
  box-shadow: inset 0 0 0 1px var(--brand-500);
}
.lm-opt.is-picked .lt { color: var(--brand-700); }
@media (max-width: 640px) { .lm-opts { padding-left: 0; } }

/* ======================================================= author credit */
.cx-author {
  margin-top: 2.6rem; text-align: center;
  background: var(--surface); border: 1px solid var(--ink-200);
  border-radius: var(--r-lg); padding: clamp(1.4rem, 4vw, 2.2rem);
  box-shadow: var(--shadow-sm);
}
.cx-author img {
  width: 118px; height: 118px; border-radius: 50%; object-fit: cover;
  margin: 0 auto .9rem; display: block;
  border: 4px solid var(--surface); box-shadow: var(--shadow-md);
  outline: 2px solid var(--brand-100);
}
.cx-author .role {
  font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-400); display: block; margin-bottom: .25rem;
}
.cx-author .name {
  font-size: 1.15rem; font-weight: 700; color: var(--ink-900);
  font-family: "Kantumruy Pro", "Noto Sans Khmer", var(--font-display);
}
.cx-author .meta { font-size: .84rem; color: var(--ink-500); margin: .5rem 0 0; line-height: 1.9; }
.cx-author .meta a { color: var(--brand-600); }
.cx-author hr { margin: 1.1rem auto; width: 70px; border: 0; border-top: 1px solid var(--ink-200); }
.cx-author .org { font-size: .9rem; font-weight: 700; color: var(--brand-600); }

/* ================================================================ print */
@media print {
  .site-header, .site-footer, .float-actions, .cx-bar, .cx-tabs, .cta-band,
  .page-hero, .wave, .cx-done, .skip-link, .cx-stats { display: none !important; }
  .cx-card, .cx-sec, .cx-eg { break-inside: avoid; box-shadow: none; border-color: #bbb; }
  .cx-card.is-hidden { display: none !important; }
  body { background: #fff; }
}
