/*
 * Yamaamah's look, for pages made outside the site's own code: course
 * studios, the grammar units, storybooks, uploaded lessons, the typing page
 * and the مُطَالَعَة tool. One file, linked from each, so they all wear the
 * same paper, ink, red and gold as yamaamah.com and change with it.
 *
 * The values are the site's own (src/app/globals.css, light theme); a test
 * (src/lib/design/theme.test.ts) fails if the two ever differ. See DESIGN.md.
 *
 * A page keeps its own layout and code. It sets data-ym on <html> to say
 * which family it is, and the matching block below points that family's own
 * colour and font names at Yamaamah's, so nothing in its HTML changes.
 */
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Scheherazade+New:wght@400;700&display=swap');

:root {
  /* Colour: the site's light theme. */
  --ym-bg: #fbf7ee;
  --ym-surface: #ffffff;
  --ym-surface-2: #f7f1e3;
  --ym-border: #e6dfd0;
  --ym-text: #1f1b16;
  --ym-muted: #635c50;
  --ym-accent: #c62828;
  --ym-accent-hover: #a51f1f;
  --ym-on-accent: #ffffff;
  --ym-gold: #b68a35;
  --ym-gold-soft: #f3ead6;
  --ym-link: #1d4e89;
  --ym-correct: #0a6b45;
  --ym-correct-bg: #d6f1e5;
  --ym-incorrect: #a4243b;
  --ym-incorrect-bg: #fbdfe3;
  --ym-partial: #7a5000;
  --ym-partial-bg: #fcefc6;
  --ym-focus: #1d4e89;
  --ym-shadow: 0 1px 2px rgb(60 45 20 / 7%), 0 6px 16px -6px rgb(60 45 20 / 12%);

  /* Type: Scheherazade New for Arabic with tashkeel, Amiri for Arabic titles, the system face for the rest. */
  --ym-font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ym-font-arabic: "Scheherazade New", "Geeza Pro", "Noto Naskh Arabic", "Traditional Arabic", serif;
  --ym-font-arabic-display: "Amiri", "Scheherazade New", serif;
  --ym-text-base: 17px;
  --ym-arabic-scale: 1.3;

  /* Shape. */
  --ym-radius: 14px;
  --ym-radius-pill: 999px;
  --ym-target: 44px;
}

/* ---------- The base every Yamaamah page shares ---------- */
html[data-ym] { background: var(--ym-bg); color-scheme: light; }
html[data-ym] body {
  background: var(--ym-bg);
  color: var(--ym-text);
  font-family: var(--ym-font-ui);
  -webkit-text-size-adjust: 100%;
}
html[data-ym] [lang="ar"], html[data-ym] .arabic, html[data-ym] .ar { font-family: var(--ym-font-arabic); }
html[data-ym] a { color: var(--ym-link); }
html[data-ym] :focus-visible { outline: 3px solid var(--ym-focus); outline-offset: 2px; }
html[data-ym] img, html[data-ym] svg, html[data-ym] video { max-width: 100%; }

/* Reusable parts, for new pages: the same card and buttons as the site. */
.ym-card { background: var(--ym-surface); border: 1px solid var(--ym-border); border-radius: var(--ym-radius); box-shadow: var(--ym-shadow); padding: 16px; }
.ym-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--ym-target); padding: 8px 18px; border-radius: var(--ym-radius-pill);
  border: 1px solid var(--ym-text); background: var(--ym-surface); color: var(--ym-text); font: inherit; font-weight: 600; cursor: pointer;
}
.ym-btn-primary { background: var(--ym-accent); border-color: var(--ym-accent); color: var(--ym-on-accent); box-shadow: inset 0 -3px 0 rgb(0 0 0 / 18%); }
.ym-btn-primary:hover { background: var(--ym-accent-hover); }
.ym-band { height: 6px; background: radial-gradient(circle, var(--ym-gold) 1px, transparent 1.5px) 0 50% / 8px 6px repeat-x; border-bottom: 1px solid var(--ym-gold-soft); }

/* ---------- Families: each page's own names pointed at Yamaamah's ---------- */

/* The Arabic I / II studios (navy, teal, a gradient header). Their own colour
   names reach most parts; the few colours written in place are set here. */
html[data-ym="studio"] {
  --navy: var(--ym-text); --teal: var(--ym-accent); --light: var(--ym-surface-2); --border: var(--ym-border);
  --ink: var(--ym-text); --muted: var(--ym-muted); --good: var(--ym-correct); --bad: var(--ym-incorrect);
}
html[data-ym="studio"] .hero {
  background: var(--ym-surface); color: var(--ym-text);
  border-bottom: 2px dotted var(--ym-gold); box-shadow: 0 4px 0 -2px var(--ym-gold-soft);
}
html[data-ym="studio"] .hero h1 { color: var(--ym-accent); }
html[data-ym="studio"] .hero p { color: var(--ym-muted); font-family: var(--ym-font-arabic-display); font-size: 1.25rem; unicode-bidi: plaintext; text-align: left; }
html[data-ym="studio"] .tab, html[data-ym="studio"] .btn, html[data-ym="studio"] .audio, html[data-ym="studio"] .toggle {
  border-radius: var(--ym-radius-pill); min-height: var(--ym-target);
}
html[data-ym="studio"] .tab.active { background: var(--ym-accent); border-color: var(--ym-accent); color: var(--ym-on-accent); }
html[data-ym="studio"] .btn:not(.secondary):not(.hollow) { box-shadow: inset 0 -3px 0 rgb(0 0 0 / 18%); }
html[data-ym="studio"] .btn.secondary { background: var(--ym-gold-soft); color: var(--ym-text); }
html[data-ym="studio"] .audio { background: var(--ym-surface); border-color: var(--ym-gold); color: var(--ym-text); }
html[data-ym="studio"] .toggle.off { background: var(--ym-surface-2); color: var(--ym-muted); }
html[data-ym="studio"] .card, html[data-ym="studio"] .toolbar { border-color: var(--ym-border); box-shadow: var(--ym-shadow); border-radius: var(--ym-radius); }
html[data-ym="studio"] .arabic, html[data-ym="studio"] .match-item.arabic, html[data-ym="studio"] .key { font-family: var(--ym-font-arabic); }
html[data-ym="studio"] .key { color: var(--ym-text); border-color: var(--ym-border); border-bottom-color: var(--ym-gold); }
html[data-ym="studio"] .key.mark { background: var(--ym-gold-soft); }
html[data-ym="studio"] .wires line { stroke: var(--ym-gold); }
html[data-ym="studio"] .wires line.good { stroke: var(--ym-correct); }
html[data-ym="studio"] .wires line.wrong { stroke: var(--ym-incorrect); }
html[data-ym="studio"] .score { background: var(--ym-correct-bg); border-color: var(--ym-correct); color: var(--ym-correct); }
/* The colours the studio writes in place, rather than by name. */
html[data-ym="studio"] .pill { background: var(--ym-gold-soft); color: var(--ym-text); }
html[data-ym="studio"] .latin, html[data-ym="studio"] .mini, html[data-ym="studio"] .footer, html[data-ym="studio"] .kbdlabel { color: var(--ym-muted); }
html[data-ym="studio"] .flash { border-color: var(--ym-gold); background: var(--ym-surface); }
html[data-ym="studio"] .match-item { background: var(--ym-surface); }
html[data-ym="studio"] .match-item.chosen { background: var(--ym-gold-soft); }
html[data-ym="studio"] .input { border-color: var(--ym-border); }
html[data-ym="studio"] .hint { background: var(--ym-partial-bg); border-left-color: var(--ym-gold); }
html[data-ym="studio"] .kbd { background: var(--ym-surface-2); border-color: var(--ym-border); box-shadow: 0 5px 0 var(--ym-border); }
html[data-ym="studio"] .key:hover { background: var(--ym-gold-soft); }
html[data-ym="studio"] .cloze-line { background: var(--ym-surface-2); }
html[data-ym="studio"] .gapfield { background: var(--ym-surface); color: var(--ym-text); }
html[data-ym="studio"] .gapfield::placeholder { color: var(--ym-muted); }
html[data-ym="studio"] .toggle.off { border-color: var(--ym-border); }
html[data-ym="studio"] .skill { background: var(--ym-surface-2); }

/* The Arabic 3 grammar units (ink and paper, a dark bar). The grammar colour code is the lesson, and stays. */
html[data-ym="companion"] {
  --paper: var(--ym-bg); --sheet: var(--ym-surface); --ink: var(--ym-text); --ink-2: var(--ym-muted);
  --rule: var(--ym-border); --tint: var(--ym-surface-2); --focus: var(--ym-focus);
  --bar: var(--ym-surface); --bar-fg: var(--ym-text);
  --f-en: var(--ym-font-ui); --f-ar: var(--ym-font-arabic); --f-ar-d: var(--ym-font-arabic-display);
}
html[data-ym="companion"] body { font-size: var(--ym-text-base); }
html[data-ym="companion"] .bar { border-bottom: 2px dotted var(--ym-gold); }
html[data-ym="companion"] .bar .brand b { color: var(--ym-accent); }
html[data-ym="companion"] .ar { font-size: max(1em, 18px); }
/* The legend's case names carry their size in the tag itself, small; read at 18px at least. */
html[data-ym="companion"] .legend b .ar { font-size: max(1.1em, 18px) !important; }
/* The Arabic rule beside the English one was set smaller than it; Arabic with tashkeel needs the larger size. */
html[data-ym="companion"] .rule-ar { font-size: max(1.15rem, 18px); line-height: 1.9; }
html[data-ym="companion"] .rule-ar .lab { font-size: 18px; }
html[data-ym="companion"] .bar button { min-height: 40px; }
/* A pressed switch is red, as on the site. */
html[data-ym="companion"] .seg button[aria-pressed="true"], html[data-ym="companion"] .tbtn[aria-pressed="true"],
html[data-ym="companion"] .part-sw button[aria-pressed="true"] { background: var(--ym-accent); color: var(--ym-on-accent); border-color: var(--ym-accent); }

/* Older lessons and the مُطَالَعَة tool (green accent on cream), and uploaded
   lessons with the look switched on: lessons made with an AI mostly use these
   same names, so they follow the site's colours as well as its fonts. */
html[data-ym="classic"], html[data-ym="lesson"] {
  --bg: var(--ym-bg); --card: var(--ym-surface); --ink: var(--ym-text); --muted: var(--ym-muted); --line: var(--ym-border);
  --accent: var(--ym-accent); --accent-soft: var(--ym-gold-soft); --gold: var(--ym-gold);
  --good: var(--ym-correct); --bad: var(--ym-incorrect); --warn: var(--ym-partial); --warn-bg: var(--ym-partial-bg);
  --arabic: var(--ym-font-arabic);
}

/* The typing page (paper, desk and red pencil). */
html[data-ym="typing"] {
  --paper: var(--ym-surface); --desk: var(--ym-bg); --ink: var(--ym-text); --muted: var(--ym-muted); --grid: var(--ym-border);
  --red: var(--ym-accent); --ok: var(--ym-correct);
}

/* Storybooks (lib/storybooks). */
html[data-ym="storybook"] h1, html[data-ym="storybook"] .ar { font-family: var(--ym-font-arabic); }
html[data-ym="storybook"] button { border-color: var(--ym-gold); min-height: var(--ym-target); }

@media (prefers-reduced-motion: reduce) {
  html[data-ym] *, html[data-ym] *::before, html[data-ym] *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
