/* Chess Checkup. Mobile first. Class prefix mx-.
   Colors and fonts follow the marcosponce.com system. --mx-amber-ink is a darker amber
   derived from the brand amber, used where amber has to carry text (contrast 4.5 or more). */

@font-face {
  font-family: "DM Sans";
  src: url("../fonts/dm-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 1000;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Playfair Display";
  src: url("../fonts/playfair-display-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --mx-bg: #FAFAF7;
  --mx-bg-alt: #F5F3EE;
  --mx-text: #2C2C2C;
  --mx-ink: #1A1A1A;
  --mx-amber: #B07A3B;
  --mx-amber-ink: #8A5A1F;
  --mx-muted: #5E5A52;
  --mx-line: #DCD5C4;
  --mx-win: #4F6F52;
  --mx-draw: #8C877B;
  --mx-loss: #A4503F;
  --mx-error-bg: #FBEFEA;
  --mx-error-text: #7A2E1F;
  --mx-radius: 10px;
  --mx-font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mx-font-head: "Playfair Display", Georgia, "Times New Roman", serif;
  --mx-gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--mx-bg);
  color: var(--mx-text);
  font-family: var(--mx-font-body);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

h1, h2, h3 {
  font-family: var(--mx-font-head);
  color: var(--mx-ink);
  line-height: 1.2;
  margin: 0;
  font-weight: 700;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }

a { color: var(--mx-amber-ink); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--mx-amber);
  outline-offset: 2px;
}

.mx-wrap { width: 100%; max-width: 46rem; margin: 0 auto; padding-inline: var(--mx-gutter); }

.mx-skip {
  position: absolute; left: -999px; top: 0; background: var(--mx-ink); color: #fff; padding: 0.5rem 0.75rem; z-index: 10;
}
.mx-skip:focus { left: 0; }

/* ---------- Header and intro ---------- */
.mx-header { border-bottom: 1px solid var(--mx-line); background: var(--mx-bg-alt); padding-block: 0.9rem; }
.mx-brand { font-family: var(--mx-font-head); font-weight: 700; font-size: 1.35rem; color: var(--mx-ink); margin: 0; line-height: 1.1; }
.mx-byline { margin: 0.15rem 0 0; font-size: 0.9rem; color: var(--mx-muted); }
.mx-intro { padding-block: 1.75rem 1rem; }
.mx-lead { font-size: 1.05rem; margin: 0.75rem 0 0; max-width: 38rem; }

/* ---------- Form ---------- */
.mx-form { background: var(--mx-bg-alt); border: 1px solid var(--mx-line); border-radius: var(--mx-radius); padding: 1rem; margin-block: 0.5rem 1.5rem; }
.mx-field { margin-bottom: 0.9rem; min-width: 0; }
.mx-field label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.3rem; color: var(--mx-ink); }
.mx-field-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 0.75rem; }
.mx-field-row > * { min-width: 0; }
.mx-input {
  display: block; box-sizing: border-box; width: 100%; max-width: 100%; min-width: 0; min-height: 48px;
  padding: 0.55rem 0.7rem; font: inherit; color: var(--mx-ink);
  background: #fff; border: 1px solid #BDB6A6; border-radius: 8px;
}
/* iPhone Safari draws date fields with its own wider, centered box that ignores width: 100%
   and spills out of the form card. Dropping the native look gives a plain box that obeys the
   width, and the text is pushed to the left like the other fields. The picker still opens. */
input[type="date"].mx-input {
  -webkit-appearance: none; appearance: none;
  inline-size: 100%; min-inline-size: 0; max-inline-size: 100%; height: 48px; line-height: 1.3;
  text-align: left;
}
input[type="date"].mx-input::-webkit-date-and-time-value { text-align: left; min-width: 0; margin: 0; }
input[type="date"].mx-input::-webkit-datetime-edit { padding: 0; }
.mx-hint { font-size: 0.85rem; color: var(--mx-muted); margin: 0.35rem 0 0; }
.mx-details { margin: 0.25rem 0 1rem; }
.mx-details summary { cursor: pointer; font-weight: 600; color: var(--mx-amber-ink); min-height: 44px; display: flex; align-items: center; }
.mx-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.mx-btn {
  min-height: 48px; padding: 0.6rem 1.25rem; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--mx-amber); color: var(--mx-ink); border: 2px solid var(--mx-amber); border-radius: 8px;
}
.mx-btn:hover { background: #C18A47; border-color: #C18A47; }
.mx-btn[disabled] { opacity: 0.6; cursor: progress; }
.mx-btn--ghost { background: transparent; color: var(--mx-ink); border-color: var(--mx-ink); }
.mx-btn--ghost:hover { background: #fff; border-color: var(--mx-ink); }
.mx-error { background: var(--mx-error-bg); color: var(--mx-error-text); border: 1px solid #E5BBAE; border-radius: 8px; padding: 0.7rem 0.9rem; margin: 1rem 0 0; font-weight: 500; }
.mx-status { margin-top: 1rem; }
.mx-status p { margin: 0.4rem 0 0; font-size: 0.95rem; color: var(--mx-muted); }
progress { width: 100%; height: 10px; accent-color: var(--mx-amber); }

/* ---------- Results ---------- */
.mx-results-head { padding-block: 0.5rem 0.25rem; }
.mx-results-head h2 { font-size: 1.5rem; }
.mx-trust { margin: 0.35rem 0 0; color: var(--mx-muted); font-size: 0.95rem; }
.mx-note { font-size: 0.9rem; color: var(--mx-muted); margin: 0.6rem 0 0; }

.mx-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-block: 1.1rem; padding: 0; list-style: none; }
.mx-tile { background: var(--mx-bg-alt); border: 1px solid var(--mx-line); border-radius: var(--mx-radius); padding: 0.8rem 0.8rem 0.7rem; min-width: 0; }
.mx-tile-label { font-size: 0.82rem; font-weight: 600; color: var(--mx-muted); margin: 0 0 0.25rem; line-height: 1.3; }
.mx-tile-value { font-family: var(--mx-font-head); font-size: 1.45rem; font-weight: 700; color: var(--mx-ink); margin: 0; line-height: 1.15; }
.mx-tile-detail { font-size: 0.82rem; color: var(--mx-muted); margin: 0.3rem 0 0; line-height: 1.35; }
.mx-tile--pending .mx-tile-value { font-size: 1.05rem; color: var(--mx-muted); font-family: var(--mx-font-body); font-weight: 600; }

.mx-card { background: #fff; border: 1px solid var(--mx-line); border-radius: var(--mx-radius); padding: 1rem; margin-block: 0.9rem; }
.mx-card > h2 { margin-bottom: 0.5rem; }
.mx-card--placeholder { background: var(--mx-bg-alt); border-style: dashed; }
.mx-card--placeholder p:last-child { margin-bottom: 0; }
.mx-sub { font-size: 0.95rem; color: var(--mx-muted); margin: 0 0 0.6rem; }
.mx-small { font-size: 0.85rem; color: var(--mx-muted); }
/* The debug line carries a long address with no spaces; it must wrap, never widen the page. */
#mx-debug { overflow-wrap: anywhere; }
/* The footer's Build line is a plain-looking button (it toggles the diagnostic line). */
.mx-build { font: inherit; font-size: 0.85rem; color: var(--mx-muted); background: none; border: 0; padding: 0.6rem 0; margin: 0; min-height: 44px; cursor: pointer; text-decoration: underline dotted; }

.mx-row { padding-block: 0.55rem; border-top: 1px solid var(--mx-line); }
.mx-row:first-of-type { border-top: 0; }
.mx-card h3 { margin: 1.25rem 0 0.1rem; }
.mx-card .mx-legend + h3 { margin-top: 0.6rem; }
.mx-card h3 + .mx-row { border-top: 0; }
.mx-row-label { font-weight: 600; color: var(--mx-ink); font-size: 0.95rem; }
.mx-row-value { font-size: 0.9rem; color: var(--mx-muted); margin: 0.2rem 0 0; }

.mx-wld { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--mx-line); margin-top: 0.3rem; }
.mx-wld > span { display: block; min-width: 3px; }
.mx-wld .mx-w { background: var(--mx-win); }
.mx-wld .mx-d { background: var(--mx-draw); }
.mx-wld .mx-l { background: var(--mx-loss); }
.mx-legend { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.82rem; color: var(--mx-muted); margin: 0 0 0.4rem; }
.mx-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }
.mx-legend .mx-w::before { background: var(--mx-win); }
.mx-legend .mx-d::before { background: var(--mx-draw); }
.mx-legend .mx-l::before { background: var(--mx-loss); }

.mx-bar { height: 10px; background: var(--mx-line); border-radius: 5px; overflow: hidden; margin-top: 0.3rem; }
.mx-bar > span { display: block; height: 100%; background: var(--mx-amber); border-radius: 5px; }

.mx-spark { width: 100%; height: auto; display: block; margin-block: 0.4rem 0.2rem; }
.mx-spark path { fill: none; stroke: var(--mx-amber-ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.mx-spark line { stroke: var(--mx-line); stroke-width: 1; vector-effect: non-scaling-stroke; }

.mx-cols { display: grid; gap: 3px; align-items: end; height: 84px; margin-top: 0.5rem; }
.mx-cols--24 { grid-template-columns: repeat(24, minmax(0, 1fr)); }
.mx-cols--7 { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; height: 70px; }
.mx-col { background: var(--mx-line); border-radius: 3px 3px 0 0; min-height: 3px; }
.mx-col[data-n]:not([data-n="0"]) { background: var(--mx-amber); }
.mx-axis { display: grid; margin-top: 0.25rem; font-size: 0.75rem; color: var(--mx-muted); }
.mx-axis--24 { grid-template-columns: repeat(24, minmax(0, 1fr)); }
.mx-axis--24 span { overflow: visible; white-space: nowrap; }
.mx-axis--7 { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }

/* ---------- Engine panel ---------- */
.mx-notice { background: var(--mx-bg-alt); border: 1px solid var(--mx-line); border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.9rem; color: var(--mx-ink); margin: 0.6rem 0; }
#mx-engine-panel .mx-actions { margin-top: 0.75rem; }
#mx-engine-panel progress { margin-top: 0.5rem; }

/* ---------- Footer ---------- */
.mx-footer { border-top: 1px solid var(--mx-line); background: var(--mx-bg-alt); margin-top: 2.5rem; padding-block: 1.25rem 2rem; font-size: 0.9rem; color: var(--mx-muted); }
.mx-footer p { margin: 0 0 0.4rem; }
.mx-attribution { color: var(--mx-ink); font-weight: 600; }

/* ---------- The Free report (Session C) ----------
   A written document: headings, paragraphs with numbers, one static board. The board is an
   inline SVG with its own colors (board/board.js); nothing here recolors a square. */
.mx-report-head { font-family: var(--mx-font-head); font-weight: 700; font-size: 1.1rem; color: var(--mx-ink); margin: 0 0 0.2rem; }
.mx-leak { margin-top: 0.5rem; }
.mx-leak h3, .mx-proof h3, .mx-week h3, .mx-rest h3, .mx-strengths h3, .mx-pro h3 { font-size: 1.2rem; }
.mx-leak p { margin: 0.5rem 0; }
.mx-proof { border-top: 1px solid var(--mx-line); margin-top: 1.1rem; padding-top: 0.25rem; }
.mx-why { font-weight: 600; color: var(--mx-ink); }
.mx-board-wrap { max-width: 26rem; margin: 0.75rem 0 0.5rem; }
.mx-board { width: 100%; height: auto; display: block; }
.mx-board-coord { font-family: var(--mx-font-body); }
.mx-piece { pointer-events: none; }
.mx-piece-w, .mx-piece-b, .mx-arrow, .mx-arrow--played, .mx-arrow--better { pointer-events: none; }
.mx-link { color: var(--mx-amber-ink); font-weight: 600; text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; }
.mx-week { border-top: 1px solid var(--mx-line); margin-top: 1.1rem; }
.mx-vote { background: var(--mx-bg-alt); border: 1px solid var(--mx-line); border-radius: var(--mx-radius); padding: 0.8rem 0.9rem; margin: 1rem 0; }
.mx-vote-q { font-weight: 700; color: var(--mx-ink); margin: 0 0 0.5rem; }
.mx-vote .mx-small { margin: 0.5rem 0 0; }
.mx-btn--chosen { background: var(--mx-ink); color: var(--mx-bg); }
.mx-btn--chosen:hover { background: var(--mx-ink); }
.mx-rest { border-top: 1px solid var(--mx-line); margin-top: 1.1rem; }
.mx-strengths { border-top: 1px solid var(--mx-line); margin-top: 1.1rem; }
.mx-teaser { padding-left: 1.3rem; margin: 0.5rem 0 0; }
.mx-teaser li { margin: 0.45rem 0; }
.mx-blur { filter: blur(5px); user-select: none; -webkit-user-select: none; color: var(--mx-muted); }
.mx-pro { background: var(--mx-bg-alt); border: 1px solid var(--mx-line); border-radius: var(--mx-radius); padding: 0.9rem 1rem 1rem; margin-top: 1.25rem; }
.mx-pro h3 { margin-top: 0.1rem; }
.mx-pro-list { padding-left: 1.3rem; margin: 0.4rem 0 0.9rem; }
.mx-pro-list li { margin: 0.3rem 0; }
.mx-pro .mx-btn[disabled] { cursor: not-allowed; }
.mx-pro .mx-small { margin: 0.5rem 0 0; }
/* Session D: the Pro button is a link to the Gumroad checkout, drawn as a button. */
a.mx-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; color: var(--mx-ink); }
a.mx-btn:visited { color: var(--mx-ink); }
.mx-pro a.mx-btn { width: 100%; padding-inline: 0.75rem; }
.mx-waitlist { border-top: 1px solid var(--mx-line); margin-top: 1rem; padding-top: 0.8rem; }
.mx-waitlist-lead { font-weight: 600; color: var(--mx-ink); margin: 0 0 0.6rem; }
.mx-waitlist label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.3rem; color: var(--mx-ink); }
.mx-waitlist-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
.mx-waitlist-row > * { min-width: 0; }
.mx-waitlist .mx-input { min-height: 48px; }
.mx-waitlist-status:empty { display: none; }
.mx-waitlist-status[data-state="invalid"], .mx-waitlist-status[data-state="failed"] { color: var(--mx-error-text); }
.mx-waitlist-status[data-state="done"] { color: var(--mx-ink); font-weight: 600; }
@media (min-width: 560px) {
  .mx-waitlist-row { grid-template-columns: minmax(0, 1fr) auto; }
}
.mx-method { font-size: 0.85rem; color: var(--mx-muted); margin: 1.25rem 0 0.4rem; border-top: 1px solid var(--mx-line); padding-top: 0.8rem; }
.mx-report-footer { font-size: 0.85rem; color: var(--mx-ink); font-weight: 600; margin: 0; }

/* ---------- Wider screens ---------- */
@media (min-width: 560px) {
  h1 { font-size: 2.3rem; }
  .mx-field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mx-tiles { grid-template-columns: repeat(4, 1fr); }
  .mx-form { padding: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
