@font-face { font-family: "Plex Arabic"; src: url("fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* Every text/background pair here passes AA; test/contrast.test.js checks it */
:root {
  --ground: #e6f4f1;
  --panel: #ffffff;
  --ink: #0f2222;
  --soft: #4a5e5c;
  --line: #c4d8d4;
  --accent: #ff6b00;
  --on-accent: #1a0d00;
  --pass: #0b7a4b;
  --fail: #b42318;
  --ui: "Atkinson Hyperlegible", "Plex Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f2222;
    --panel: #163030;
    --ink: #e6f4f1;
    --soft: #9db5b1;
    --line: #2b4a49;
    --accent: #ff6b00;
    --on-accent: #1a0d00;
    --pass: #5bd6a0;
    --fail: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --ground: #0f2222;
    --panel: #163030;
    --ink: #e6f4f1;
    --soft: #9db5b1;
    --line: #2b4a49;
    --accent: #ff6b00;
    --on-accent: #1a0d00;
    --pass: #5bd6a0;
    --fail: #ff8a80;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 16px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bar { display: flex; align-items: baseline; gap: 4px 20px; flex-wrap: wrap; padding: 18px 28px 8px; }
.brand { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -0.02em; }
.brand span { color: var(--accent); -webkit-text-stroke: 0.6px var(--ink); }
.purpose { flex: 1; margin: 0; font-size: 17px; }
.bar-meta { color: var(--soft); font-size: 14px; }
.bar-meta .lang { margin-inline-start: 12px; unicode-bidi: isolate; }
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.help { margin: 0; color: var(--soft); font-size: 13px; line-height: 1.4; }
.reset { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--soft); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.hex { direction: ltr; }
.grid th { direction: ltr; } /* colour codes read left to right on the Arabic page too */
:dir(rtl) .score { text-align: end; }

.wrap { flex: 1; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); grid-template-rows: 1fr auto; gap: 14px; padding: 6px 28px 12px; }

/* Preview in the user's colours */
.preview { display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 26px 36px; border-radius: 20px; background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--line); }
.preview h2 { margin: 0; font-size: 40px; line-height: 1.1; font-weight: 700; }
.preview p { margin: 0; max-width: 56ch; font-size: 18px; }
.preview .row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.preview .sample-btn { padding: 10px 18px; border: 2px solid var(--fg); border-radius: 10px; background: none; color: var(--fg); font-weight: 700; }
.preview small { font-size: 13px; }

/* Score and controls */
.side { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; border-radius: 20px; background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.score { margin: 0; font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.score small { font-size: 28px; color: var(--soft); }
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 0; list-style: none; }
.badges li { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 10px; background: var(--ground); font-size: 14px; }
.badges b { font-size: 15px; }
.badges .mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 700; font-size: 14px; color: var(--panel); }
.badges .ok .mark { background: var(--pass); }
.badges .no .mark { background: var(--fail); }
.badges .ok { color: var(--ink); }

.pickers { display: grid; gap: 8px; }
.picker { display: grid; grid-template-columns: 92px 40px 1fr; align-items: center; gap: 10px; }
.picker > span { font-weight: 700; }
.swatch { position: relative; width: 38px; height: 38px; border-radius: 10px; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2); overflow: hidden; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.swatch:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.hex { height: 38px; padding: 0 12px; border: 2px solid var(--line); border-radius: 10px; background: none; font-size: 16px; }
.hex:focus { outline: none; border-color: var(--accent); }
.hex[aria-invalid="true"] { border-color: var(--fail); }
.swap { justify-self: start; padding: 4px 12px; border: 2px solid var(--line); border-radius: 999px; background: none; font-weight: 700; font-size: 14px; }
.swap:hover { border-color: var(--ink); }

.aim { display: flex; align-items: center; gap: 12px; }
.aim > span { font-weight: 700; width: 92px; }
.seg { display: flex; padding: 3px; border-radius: 11px; background: var(--ground); }
.seg button { padding: 6px 16px; border: 0; border-radius: 8px; background: none; color: var(--soft); font-weight: 700; }
.seg button[aria-checked="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 4px rgb(0 0 0 / 0.15); }

.fixes { display: flex; gap: 8px; }
.primary { flex: 1; height: 44px; border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px; }
.primary:disabled { cursor: default; background: var(--ground); color: var(--soft); }
.note { margin: 0; min-height: 1.45em; color: var(--soft); font-size: 14px; }

/* Palette grid */
.palette { grid-column: 1 / -1; display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; padding: 14px 20px; border-radius: 20px; background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.palette h2 { margin: 0 0 4px; font-size: 18px; }
.palette p { margin: 0 0 10px; color: var(--soft); font-size: 14px; }
.palette input { width: 100%; height: 40px; padding: 0 12px; border: 2px solid var(--line); border-radius: 10px; background: none; font-size: 15px; }
.palette input:focus { outline: none; border-color: var(--accent); }
.grid-wrap { overflow-x: auto; }
.grid { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.grid th { padding: 2px 4px; color: var(--soft); font-weight: 400; white-space: nowrap; }
.grid th i { display: inline-block; width: 12px; height: 12px; margin-inline-end: 5px; border-radius: 3px; vertical-align: -1px; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.2); }
.grid td { padding: 0; }
.grid td button { display: grid; place-items: center; width: 62px; height: 31px; border: 0; border-radius: 8px; background: var(--bg); color: var(--fg); font-weight: 700; font-size: 13px; line-height: 1.1; }
.grid td button small { font-size: 10px; font-weight: 700; }
.grid td.same button { opacity: 0.25; }

.toast { position: fixed; left: 50%; bottom: 22px; display: flex; align-items: center; gap: 12px; margin: 0; padding-block: 10px; padding-inline: 16px 12px; border-radius: 12px; background: var(--ink); color: var(--ground); font-weight: 700; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { padding: 4px 10px; border: 0; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

@media (max-width: 860px) {
  .bar, .wrap { padding-inline: 16px; }
  .purpose { flex-basis: 100%; order: 3; font-size: 16px; }
  .wrap { grid-template-columns: minmax(0, 1fr); }
  .preview { min-height: 0; padding: 24px; }
  .preview h2 { font-size: 32px; }
  .side { padding: 18px; }
  .score { font-size: 52px; }
  .picker { grid-template-columns: 84px 40px minmax(0, 1fr); }
  .palette { grid-template-columns: minmax(0, 1fr); }
}

/* Questions under the tool: for people who scroll, and for search engines */
.faq { max-width: 920px; margin: 0 auto; padding: 56px 20px 64px; }
.faq h2 { margin: 0 0 20px; font: 700 22px/1.2 var(--ui); letter-spacing: -0.02em; }
.faq-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px 32px; }
.faq h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.faq p { margin: 0; color: var(--soft); line-height: 1.6; }

/* Light/dark button (theme.js): follows the device until the visitor picks */
.theme { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-inline-start: 8px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; vertical-align: middle; }
.theme:hover { background: var(--line); }
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme .sun, .theme[data-dark="true"] .moon { display: none; }
.theme[data-dark="true"] .sun { display: block; }
