/* Orpheus front end: the Ma design (orpheus-design/09-ma/SYSTEM.md).
   This file holds the tokens (light in :root, dark twice: the data-theme
   attribute set in Settings and the system preference), the self-hosted
   fonts, the Base rules of the design and the loading state shown before
   the app mounts. Every colour of the app lives here and nowhere else. The
   components are in css/ma.css, app states in the area files under css/. */

/* ---------- Fonts (web/fonts, see web/fonts/README.md) ---------- */
/* Zen Kaku Gothic New, Latin subset, four weights: letters and punctuation. */
@font-face {
  font-family: "Zen Kaku Gothic New";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("/fonts/zen-kaku-gothic-new-300-latin.woff2") format("woff2");
  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: "Zen Kaku Gothic New";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/zen-kaku-gothic-new-400-latin.woff2") format("woff2");
  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: "Zen Kaku Gothic New";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/zen-kaku-gothic-new-500-latin.woff2") format("woff2");
  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: "Zen Kaku Gothic New";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/zen-kaku-gothic-new-700-latin.woff2") format("woff2");
  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;
}
/* Ma Numerals: the digits, the comma, the full stop and the colon of Noto
   Sans JP (lining, tabular figures). Google serves one variable file for the
   weights 300, 400 and 500, so one rule covers the range. The unicode range
   keeps every other character on Zen Kaku Gothic New. */
@font-face {
  font-family: "Ma Numerals";
  font-style: normal;
  font-weight: 300 500;
  font-display: swap;
  src: url("/fonts/ma-numerals.woff2") format("woff2");
  unicode-range: U+2C, U+2E, U+30-3A;
}

/* ---------- Tokens: light (the primary theme) ---------- */
:root {
  color-scheme: light;

  /* App tokens (the names the app used before Ma) */
  --bg: #F3F3F1;          /* paper: a quiet light grey */
  --surface: #E9E9E7;     /* hover fill, folded bodies, table heads */
  --fg: #2A2A29;          /* sumi ink: text, lines, right answers */
  --muted: #575756;       /* secondary text (6.6:1 on paper) */
  --border: #DCDCDA;      /* separators only, never a control edge */
  --accent: #2A2A29;      /* primary action fill = ink */
  --accent-fg: #F3F3F1;   /* text on the primary action */
  --ok: #2A2A29;          /* right = ink (shape: tick, filled) */
  --ok-bg: #E6E6E4;
  --bad: #BA1830;         /* wrong = beni red (shape: cross) */
  --bad-bg: #F6E6E8;
  --focus: #2A2A29;       /* focus ring */
  --warn: #2A2A29;        /* warnings use a mark, not a colour */
  --kbd-bg: #E6E6E4;      /* keycap fill */

  /* Ma colour tokens */
  --home: #BA1830;        /* the red dot: the tonic, your place */
  --home-halo: #F3F3F1;   /* ring around a red dot that sits on ink */
  --line: #2A2A29;        /* edge of every control (1 px) */
  --rule: #DCDCDA;        /* hairline between sections */
  --sheet: #FAFAF9;       /* an open track: a sheet that stands off the paper */
  --sheet-edge: #C6C6C4;  /* thin solid edge of the sheet (a locked track has a dashed --faint edge) */
  --faint: #858584;       /* marks only: locked dots, future ticks (3.3:1) */
  --on-ink: #F3F3F1;      /* text on an ink fill */
  --on-ink-muted: #C4C4C2;
  --kbd-on-ink: #454544;  /* keycap on an ink fill */
  --key-white: #F9F9F8;   /* piano */
  --key-black: #2A2A29;
  --key-line: #2A2A29;
  --key-label: #575756;
  --key-down: #DCDCDA;    /* a pressed piano key */
  --heat-empty: #D5D5D3;  /* a day with no answers */
  --chart-grid: #DCDCDA;
  --chart-ink: #2A2A29;
  --chart-soft: #858584;  /* second series, helped answers */
  --accent-hover: #444443;
  /* Theme swatches in Settings show both themes, so they do not change with the theme */
  --sw-paper-light: #F3F3F1;
  --sw-ink-light: #2A2A29;
  --sw-paper-dark: #1A1A19;
  --sw-ink-dark: #DDDDDC;

  /* Type. Digits, the comma, the full stop and the colon come from Ma Numerals (its range holds
     only them); every other character falls through to Zen Kaku Gothic New. */
  --font-text: "Ma Numerals", "Zen Kaku Gothic New", system-ui, sans-serif;
  --font-glyph: "Zen Kaku Gothic New", system-ui, sans-serif;
  --w-light: 300;
  --w-text: 400;
  --w-label: 500;
  --w-strong: 700;

  --fs-display: 44px;  --lh-display: 52px;
  --fs-answer: 40px;   --lh-answer: 48px;
  --fs-num: 36px;      --lh-num: 44px;
  --fs-h2: 20px;       --lh-h2: 28px;
  --fs-body: 16px;     --lh-body: 24px;
  --fs-label: 14px;    --lh-label: 20px;
  --fs-small: 13px;    --lh-small: 20px;
  --fs-micro: 12px;    --lh-micro: 16px;
  --ls-display: 0.01em;
  --ls-label: 0.02em;
  --ls-micro: 0.04em;

  /* Space: one scale, multiples of 4 px */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* Grid (the text block: 60 characters of 16 px = 960 px) */
  --cols: 12;
  --gutter: 24px;
  --page-max: 960px;
  --page-pad: 32px;

  /* Sizes */
  --bar-h: 56px;
  --ctrl: 40px;          /* tool buttons, segmented controls, fields */
  --ctrl-lg: 48px;       /* primary action, lesson control row */
  --touch: 44px;         /* smallest touch target */
  --kbd-h: 20px;
  --answer-h: 104px;
  --stage-h: 168px;      /* reserved height of the drawing area */
  --staff-space: 14px;   /* one staff space */
  --node: 12px;          /* level node */
  --node-pitch: 32px;    /* distance between level nodes on Ear and Theory */
  --pic: 24px;           /* pictogram */
  --pic-lg: 32px;
  --ic: 20px;            /* control glyph */

  /* Shape */
  --r-1: 2px;            /* buttons, cells, fields */
  --r-2: 3px;            /* keycaps */
  --hair: 1px;
  --focus-w: 2px;
  --focus-gap: 2px;

  /* Motion */
  --t-fast: 120ms;
  --t-med: 200ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* Tablet: 8 columns */
@media (max-width: 1023px) {
  :root {
    --cols: 8;
    --page-pad: 32px;
  }
}

/* Phone: 4 columns */
@media (max-width: 599px) {
  :root {
    --cols: 4;
    --gutter: 16px;
    --page-pad: 16px;
    --fs-display: 32px;  --lh-display: 40px;
    --fs-answer: 32px;   --lh-answer: 40px;
    --fs-num: 28px;      --lh-num: 36px;
    --ctrl: 44px;
    --answer-h: 72px;
    --stage-h: 128px;
    --staff-space: 10px;
    --node-pitch: 44px;
  }
}

/* ---------- Tokens: dark (the second theme) ----------
   Sumi grey-black paper, off-white ink, the same red lifted and softened for
   the dark ground. The same values twice: when Settings chose Dark, and when
   Settings chose System and the device prefers dark. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1A1A19;
  --surface: #232322;
  --fg: #DDDDDC;
  --muted: #A3A3A3;
  --border: #333332;
  --accent: #DDDDDC;
  --accent-fg: #1A1A19;
  --ok: #DDDDDC;
  --ok-bg: #2C2C2B;
  --bad: #E0606F;
  --bad-bg: #33191E;
  --focus: #DDDDDC;
  --warn: #DDDDDC;
  --kbd-bg: #2E2E2D;

  --home: #E0606F;
  --home-halo: #1A1A19;
  --line: #B5B5B4;
  --rule: #333332;
  --faint: #7E7E7D;
  --on-ink: #1A1A19;
  --on-ink-muted: #4A4A4A;
  --kbd-on-ink: #C4C4C2;
  --key-white: #D4D4D3;
  --key-black: #1A1A19;
  --key-line: #1A1A19;
  --key-label: #3A3A3A;
  --key-down: #9E9E9D;
  --heat-empty: #383837;
  --chart-grid: #333332;
  --chart-ink: #DDDDDC;
  --chart-soft: #7E7E7D;
  --accent-hover: #EDEDEC;
  --sheet: #262625;
  --sheet-edge: #454544;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1A1A19;
    --surface: #232322;
    --fg: #DDDDDC;
    --muted: #A3A3A3;
    --border: #333332;
    --accent: #DDDDDC;
    --accent-fg: #1A1A19;
    --ok: #DDDDDC;
    --ok-bg: #2C2C2B;
    --bad: #E0606F;
    --bad-bg: #33191E;
    --focus: #DDDDDC;
    --warn: #DDDDDC;
    --kbd-bg: #2E2E2D;

    --home: #E0606F;
    --home-halo: #1A1A19;
    --line: #B5B5B4;
    --rule: #333332;
    --faint: #7E7E7D;
    --on-ink: #1A1A19;
    --on-ink-muted: #4A4A4A;
    --kbd-on-ink: #C4C4C2;
    --key-white: #D4D4D3;
    --key-black: #1A1A19;
    --key-line: #1A1A19;
    --key-label: #3A3A3A;
    --key-down: #9E9E9D;
    --heat-empty: #383837;
    --chart-grid: #333332;
    --chart-ink: #DDDDDC;
    --chart-soft: #7E7E7D;
    --accent-hover: #EDEDEC;
    --sheet: #262625;
    --sheet-edge: #454544;
  }
}

/* ---------- Base (the Base section of 09-ma/design.css) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: var(--w-text);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; background: var(--bg); }
/* The frame of SYSTEM.md 3.1: the root the app renders into is a column, the page grows, so the footer
   sits at the bottom of a short page. */
#app { min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, h4, p, ol, ul, dl, dd, figure, fieldset { margin: 0; padding: 0; border: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
:focus-visible { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-gap); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.link { color: var(--fg); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.ic { width: var(--ic); height: var(--ic); flex: none; }
.pic { width: var(--pic); height: var(--pic); flex: none; color: var(--fg); }
.pic--lg { width: var(--pic-lg); height: var(--pic-lg); }
.h { fill: var(--home); }                 /* red parts inside glyphs */
.acc { display: inline-block; width: 0.34em; height: 0.8em; margin: 0 0.06em 0 0.03em; fill: currentColor; overflow: visible; }
.here-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--home); flex: none; }

.page {
  flex: 1 0 auto; width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--page-pad));
  margin: 0 auto;
  padding: var(--s-7) var(--page-pad) var(--s-9);
}
.grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); column-gap: var(--gutter); }
.display { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: var(--w-light); letter-spacing: var(--ls-display); }
.h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--w-text); }
.h3 { font-size: var(--fs-label); line-height: var(--lh-label); font-weight: var(--w-label); letter-spacing: var(--ls-label); }

/* ---------- Loading state (index.html, before the app mounts) ---------- */
/* Paper, the mark with the red dot, the word Orpheus, one quiet line. */
.loading {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  max-width: calc(var(--page-max) + 2 * var(--page-pad)); margin: 0 auto;
  padding: var(--s-9) var(--page-pad); text-align: center; color: var(--muted);
}
.loading__mark { width: 40px; height: 40px; fill: none; stroke: var(--fg); stroke-width: 1.25; }
.loading__mark .h { fill: var(--home); stroke: none; }
.loading__title { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--w-label); letter-spacing: 0.06em; color: var(--fg); }
.loading__line { font-size: var(--fs-small); line-height: var(--lh-small); }
