/* The website's pages. Colours, type and sizes come from generated/tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0 auto;
  max-width: 1000px;
  padding: var(--space-4) var(--space-4) var(--space-7);
  font-family: var(--font-latin), var(--script-fonts), system-ui, sans-serif;
  font-size: var(--text-s);
  line-height: 1.55;
  background: var(--paper);
}
/* Each script gets fonts made for it. Arabic and Urdu fonts come from this site;
   the others are the fonts every phone and computer already has for that script. */
:root { --script-fonts: system-ui; }
:root:lang(ar) { --script-fonts: var(--font-arabic); }
:root:lang(ur) { --script-fonts: var(--font-arabic); }
:root:lang(hi) { --script-fonts: "Nirmala UI", "Noto Sans Devanagari", "Kohinoor Devanagari"; }
:root:lang(zh) { --script-fonts: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC"; }
:root:lang(zh-HK) { --script-fonts: "Microsoft JhengHei", "PingFang HK", "Noto Sans HK", "Noto Sans CJK TC"; }
:root:lang(ja) { --script-fonts: "Yu Gothic UI", "Yu Gothic", "Hiragino Sans", "Noto Sans JP", "Noto Sans CJK JP"; }
:root:lang(ko) { --script-fonts: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR"; }
:root:lang(am), :root:lang(ti) { --script-fonts: "Nyala", "Ebrima", "Noto Sans Ethiopic", "Kefa"; }
:root[lang="ar"] body { font-family: var(--font-arabic), var(--font-latin), system-ui, sans-serif; line-height: 1.75; }
/* Urdu readers expect Nastaliq, which needs extra room between lines. */
:root[lang="ur"] body { font-family: "Noto Nastaliq Urdu", var(--font-arabic), var(--font-latin), sans-serif; line-height: 2.2; }
:root[lang="ur"] h1, :root[lang="ur"] h2 { line-height: 1.9; }
:root:lang(hi) body, :root:lang(am) body, :root:lang(ti) body { line-height: 1.75; }
[lang="zgh"], .tif { font-family: var(--font-tifinagh), var(--font-latin), sans-serif; }
h1 { font-size: var(--text-xxl); line-height: 1.1; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: var(--text-l); line-height: 1.25; font-weight: 500; margin: 0 0 var(--space-3); }
p { margin: 0 0 var(--space-3); }
a { color: var(--accent); }
button, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; margin-bottom: var(--space-6); }
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink); text-decoration: none; font-weight: 600; font-size: var(--text-m); }
.mark { font-family: var(--font-tifinagh), sans-serif; font-size: 36px; line-height: 1; color: var(--flag-red); }
.top-end { display: flex; align-items: center; gap: var(--space-2); }
/* The way into "your name in Tifinagh", on every page. */
.nav-name {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 6px 14px 6px 10px;
  border-radius: var(--radius-pill); background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 500;
}
.nav-name:hover { filter: brightness(1.08); }
.nav-name[aria-current="page"] { background: var(--key-fn); color: var(--ink); }
.nav-mark { font-family: var(--font-tifinagh), sans-serif; font-size: 1.15em; line-height: 1; padding-inline-end: var(--space-2); border-inline-end: 1px solid currentColor; }
.flag { width: 21px; height: 14px; flex: none; border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08); }

/* The language menu: the current language, opening onto all of them. */
.lang-menu { position: relative; line-height: 1.3; }
.lang-menu summary {
  list-style: none; display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 40px; padding: 6px 14px; border-radius: var(--radius-pill); background: var(--key-fn); cursor: pointer;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: ""; width: 7px; height: 7px; margin-inline-start: 2px; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.lang-menu[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.lang-list {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 10;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px;
  width: min(420px, calc(100vw - 2 * var(--space-4))); padding: var(--space-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.18);
}
.lang-list a { display: flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 6px 10px; border-radius: var(--radius-key); color: var(--ink); text-decoration: none; }
.lang-list a:hover { background: var(--paper); }
.lang-list a[aria-current="page"] { background: var(--key-fn); font-weight: 500; }

/* The footer lists every language too, so each page links to all its translations. */
.langs { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.langs a { display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; color: var(--ink); text-decoration: none; }
.langs a:hover span { text-decoration: underline; }
.langs a[aria-current="page"] { font-weight: 600; }

.hero { display: grid; gap: var(--space-3); }
.lead { color: var(--muted); font-size: var(--text-m); max-width: 46ch; margin-bottom: var(--space-3); }
.tool { display: grid; gap: var(--space-3); max-width: var(--desktop-max-width); width: 100%; margin-inline: auto; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--key-fn); border-radius: var(--radius-pill); }
.seg button { border: 0; background: transparent; border-radius: var(--radius-pill); padding: 6px 14px; cursor: pointer; color: var(--ink); min-height: 36px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 500; }
.variants { justify-self: start; }

.field-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: var(--space-3); display: grid; gap: var(--space-2); }
textarea {
  width: 100%; min-height: 4.5em; resize: vertical; border: 0; background: transparent; outline: none; color: var(--ink);
  font-family: var(--font-tifinagh), var(--font-latin), sans-serif; font-size: var(--text-l); line-height: 1.5; text-align: left;
}
textarea::placeholder { color: var(--muted); font-family: var(--font-latin), var(--font-arabic), sans-serif; font-size: var(--text-m); }
:root[lang="ar"] textarea::placeholder { text-align: right; }
.field-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; justify-content: flex-end; }
.status { margin: 0 auto 0 0; margin-inline: 0 auto; color: var(--muted); font-size: var(--text-xs); }
.action { border: 1px solid var(--line); background: transparent; border-radius: var(--radius-pill); padding: 6px 18px; min-height: 40px; cursor: pointer; }
.action:hover { border-color: var(--accent); }
.action.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }
.action.primary.is-done { background: var(--success); border-color: var(--success); }
.action[hidden] { display: none; }

.kb { min-height: 260px; }
.settings { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: center; color: var(--muted); font-size: var(--text-xs); }
.setting { display: flex; gap: var(--space-2); align-items: center; }

.block { margin-top: var(--space-7); max-width: 72ch; }
.block:first-of-type { max-width: none; }
.note { color: var(--muted); font-size: var(--text-xs); }
.alphabet { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--space-2); margin-top: var(--space-4); }
.letter { display: grid; justify-items: center; gap: 2px; padding: var(--space-3) var(--space-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-key); cursor: pointer; color: var(--ink); }
.letter:hover { border-color: var(--accent); }
.l-glyph { font-family: var(--font-tifinagh), sans-serif; font-size: var(--text-xl); line-height: 1.15; }
.l-latin { font-family: var(--font-latin), sans-serif; font-size: var(--text-s); }
.l-key { font-family: var(--font-latin), sans-serif; font-size: var(--text-xs); color: var(--muted); }

.prose p { max-width: 68ch; }
.prose details { border-top: 1px solid var(--line); padding: var(--space-3) 0; }
.prose details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 500; }
.prose details p { margin: var(--space-2) 0 0; color: var(--ink); }

.foot { margin-top: var(--space-7); padding-top: var(--space-4); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; font-size: var(--text-xs); }
.foot { align-items: flex-start; }
/* A pill to our sister site, arabickeys.app, on a row of its own above the footer links. */
.sister-row { order: -1; flex-basis: 100%; }
.sister-pill {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 5px 16px 5px 6px;
  border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); text-decoration: none; font-size: var(--text-xs); transition: border-color 150ms, transform 150ms;
}
.sister-pill:hover { border-color: var(--accent); transform: translateY(-1px); }
.sister-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-family: var(--font-arabic), sans-serif; font-size: 15px; line-height: 1;
}
.sister-domain { font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .sister-pill { transition: none; } .sister-pill:hover { transform: none; } }
.foot > a { color: var(--muted); white-space: nowrap; }

@media (max-width: 560px) {
  h1 { font-size: var(--text-xl); }
  .top { margin-bottom: var(--space-5); }
  /* On a phone the keyboard runs edge to edge, like a system keyboard, so 11 keys fit. */
  .kb { margin-inline: calc(-1 * var(--space-4)); border-radius: 0; }
  .variants { justify-self: stretch; justify-content: center; }
}
