/* Tajdeed web keyboard (web port of the 1.0.7 iOS keyboard). Pinned to the bottom of the screen like the system keyboard (fixed, safe-area aware), full width on phones.
   Logical properties; opacity/transform motion <=150ms; light + dark with the same pattern as writing-assist.css. */
body #wk{--wk-bg:#f7f7f7;--wk-line:#dcdfe1;--wk-key:#fff;--wk-fn:#e4e6e8;--wk-ink:#111a1f;--wk-mute:#52626a;--wk-brand:#0a7d68;--wk-on:#fff;--wk-press:#d3ece4;--wk-ring:#0a7d68;--wk-shadow:0 1px 0 rgba(0,0,0,.22);--wk-h:44px;--wk-gap:5px;
  box-sizing:border-box;position:fixed;inset-inline:0;inset-block-end:0;z-index:60;inline-size:100%;max-inline-size:100%;margin:0;padding:6px 6px calc(8px + env(safe-area-inset-bottom,0px));border:0;border-block-start:1px solid var(--wk-line);border-radius:14px 14px 0 0;box-shadow:0 -6px 18px rgba(0,0,0,.12);background:var(--wk-bg);color:var(--wk-ink);
  opacity:0;transform:translateY(24px);transition:opacity 150ms ease-out,transform 150ms ease-out;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;touch-action:manipulation}
body #wk.wk-in{opacity:1;transform:none}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]) body #wk{--wk-bg:#090c10;--wk-line:#27323a;--wk-key:#1b2229;--wk-fn:#11171c;--wk-ink:#e9f2ef;--wk-mute:#9db6ae;--wk-brand:#2ff0c2;--wk-on:#06110e;--wk-press:#2a4a43;--wk-ring:#6ff3d3;--wk-shadow:0 1px 0 rgba(0,0,0,.6)}}
:root[data-theme=dark] body #wk{--wk-bg:#090c10;--wk-line:#27323a;--wk-key:#1b2229;--wk-fn:#11171c;--wk-ink:#e9f2ef;--wk-mute:#9db6ae;--wk-brand:#2ff0c2;--wk-on:#06110e;--wk-press:#2a4a43;--wk-ring:#6ff3d3;--wk-shadow:0 1px 0 rgba(0,0,0,.6)}
body #wk *{box-sizing:border-box}
body #wk[hidden],body #wk [hidden]{display:none!important}
/* room for the keyboard: the view gets extra bottom space equal to the keyboard height (--wk-space, set by web-keyboard.js) */
:root:root body #writing[data-wk-open]{padding-block-end:calc(var(--wk-space,0px) + 12px)}
/* the Persian-family extra row is only rendered on tall screens (web-keyboard.js extraShown); shorter screens reach those letters by long-press */
/* short screens: textarea shrinks to ~3 lines while the keyboard is open */
@media (max-height:700px){
  :root:root body #writing[data-wk-open] #text-form{grid-template-rows:none;row-gap:6px}
  :root:root body #writing[data-wk-open] #text-form #writing-input{min-block-size:0;block-size:84px;max-block-size:84px}
  body #wk{--wk-h:40px;--wk-gap:4px;padding:4px 6px calc(6px + env(safe-area-inset-bottom,0px))}
  body #wk{--wk-dh:30px}
}
/* very short screens (small iPhone with Safari bars): a 2-3 line text box so the submit button still fits above the keyboard */
@media (max-height:600px){
  :root:root body #writing[data-wk-open] #text-form #writing-input{block-size:60px;max-block-size:60px}
}

body #wk .wk-head{display:flex;align-items:center;justify-content:space-between;gap:8px;min-block-size:44px;margin-block-end:2px}
:root:root body #wk .wk-close{appearance:none;-webkit-appearance:none;margin:0;margin-inline-start:auto;min-inline-size:88px;min-block-size:44px;padding:0 12px;gap:6px;border:0;border-radius:10px;background:var(--wk-fn);color:var(--wk-ink);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;font:inherit;font-size:16px;font-weight:600;line-height:1;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
:root:root body #wk .wk-close svg{inline-size:22px;block-size:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
:root:root body #wk .wk-close:active{background:var(--wk-press)}
:root:root body #wk .wk-close:focus-visible{outline:2px solid var(--wk-ring);outline-offset:-2px}

body #wk .wk-body{display:flex;flex-direction:column;gap:var(--wk-gap)}
body #wk .wk-row{display:flex;flex-direction:row;gap:var(--wk-gap);inline-size:100%;direction:ltr}
:root:root body #wk .wk-row.wk-digits .wk-k{block-size:var(--wk-dh,36px);font-size:17px;color:var(--wk-mute)}
:root:root body #wk .wk-k{appearance:none;-webkit-appearance:none;position:relative;flex:var(--w,1) 1 0;min-inline-size:0;block-size:var(--wk-h);margin:0;padding:0;border:0;border-radius:9px;background:var(--wk-key);color:var(--wk-ink);box-shadow:var(--wk-shadow);
  display:inline-flex;align-items:center;justify-content:center;font:inherit;font-size:20px;font-weight:500;line-height:1;letter-spacing:0;text-transform:none;white-space:nowrap;cursor:pointer;overflow:visible;
  font-family:"Noto Naskh Arabic","Geeza Pro","Segoe UI",Tahoma,system-ui,sans-serif;-webkit-tap-highlight-color:transparent;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  transition:transform 90ms ease-out,opacity 90ms ease-out,background-color 90ms ease-out}
:root:root body #wk .wk-fn{background:var(--wk-fn);font-size:16px;font-weight:600}
:root:root body #wk .wk-k svg{inline-size:22px;block-size:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
:root:root body #wk .wk-shift.wk-on svg{fill:currentColor}
:root:root body #wk .wk-shift.wk-on{background:var(--wk-brand);color:var(--wk-on)}
:root:root body #wk .wk-shift.wk-lock::after{content:"";position:absolute;inset-block-end:5px;inset-inline:35%;block-size:3px;border-radius:2px;background:currentColor}
:root:root body #wk .wk-ret{background:var(--wk-brand);color:var(--wk-on)}
:root:root body #wk .wk-space{background:var(--wk-key)}
:root:root body #wk .wk-diac{font-size:22px}
:root:root body #wk .wk-lang{font-size:16px;letter-spacing:.02em;font-family:system-ui,"Segoe UI",sans-serif}
:root:root body #wk .wk-k.wk-down{transform:scale(.94);opacity:.88;background:var(--wk-press)}
:root:root body #wk .wk-shift.wk-on.wk-down,:root:root body #wk .wk-ret.wk-down{background:var(--wk-brand)}
:root:root body #wk .wk-k:focus-visible{outline:2px solid var(--wk-ring);outline-offset:1px;z-index:1}

/* long-press popup */
body #wk .wk-pop{position:absolute;z-index:3;display:flex;gap:2px;padding:3px;border:1px solid var(--wk-line);border-radius:12px;background:var(--wk-key);box-shadow:0 6px 18px rgba(0,0,0,.28);direction:ltr}
:root:root body #wk .wk-v{appearance:none;-webkit-appearance:none;flex:1 1 0;min-inline-size:0;block-size:44px;margin:0;padding:0;border:0;border-radius:9px;background:transparent;color:var(--wk-ink);font:inherit;font-size:22px;line-height:1;cursor:pointer;
  font-family:"Noto Naskh Arabic","Geeza Pro","Segoe UI",Tahoma,system-ui,sans-serif;touch-action:none;-webkit-user-select:none;user-select:none}
:root:root body #wk .wk-v.wk-sel{background:var(--wk-brand);color:var(--wk-on)}
:root:root body #wk .wk-v:focus-visible{outline:2px solid var(--wk-ring);outline-offset:-2px}

@media (min-width:1024px){
  body #wk{--wk-h:46px;max-inline-size:640px;margin-inline:auto}
  :root:root body #writing[data-wk-open] #text-form{grid-template-rows:none}
  :root:root body #writing[data-wk-open] #text-form #writing-input{min-block-size:0;block-size:120px;max-block-size:120px}
}
@media (prefers-reduced-motion:reduce){
  body #wk{transition:none;transform:none}
  :root:root body #wk .wk-k{transition:none}
}
@media print{body #wk{display:none}}

/* the tab bar steps aside while the keyboard is open on touch devices and phone-width screens (see syncNav in web-keyboard.js) */
:root:root.wk-nav-hidden body .bottom-nav{display:none!important}
:root:root body #wk .wk-close-t{display:inline-block;font-size:16px;font-weight:600;line-height:1.6;white-space:nowrap}
/* iOS zooms inputs under 16px; the writing box must stay >=16px, and keeps no tap flash while our keyboard replaces the native one */
@media (pointer:coarse){:root:root body #writing #writing-input{font-size:max(16px,1em);-webkit-tap-highlight-color:transparent}}

/* empty slot in a kana grid */
:root:root body #wk .wk-sp{flex:1 1 0;min-inline-size:0;block-size:var(--wk-h);visibility:hidden;pointer-events:none}
:root:root body #wk .wk-kana{font-size:18px}

/* ---- the small keyboard icon in the corner of the writing box (#wk-toggle, injected by web-keyboard.js) --------------------------
   44px hit area, 32px visual chip, inline-end top corner of #text-form (top-left in RTL). The textarea reserves room on that side. */
:root:root body #writing #text-form{position:relative}
:root:root body #writing #text-form .wk-toggle{--tg-mute:#5d6f76;--tg-brand:#0a7d68;--tg-on:#fff;--tg-line:#c9d6d2;--tg-chip:rgba(255,255,255,.86);--tg-press:#d5ece4;
  appearance:none;-webkit-appearance:none;position:absolute;inset-block-start:2px;inset-inline-end:2px;z-index:2;box-sizing:border-box;inline-size:44px;block-size:44px;min-inline-size:44px;min-block-size:44px;margin:0;padding:0;border:0;border-radius:0;background:transparent;box-shadow:none;
  display:inline-flex;align-items:center;justify-content:center;color:var(--tg-mute);cursor:pointer;grid-row:auto;grid-column:auto;-webkit-tap-highlight-color:transparent;touch-action:manipulation;-webkit-user-select:none;user-select:none}
:root:root body #writing #text-form .wk-toggle[hidden]{display:none!important}
:root:root body #writing #text-form .wk-tg-i{position:relative;display:inline-flex;align-items:center;justify-content:center;inline-size:32px;block-size:32px;box-sizing:border-box;border:1px solid var(--tg-line);border-radius:10px;background:var(--tg-chip);transition:background-color 120ms ease-out,color 120ms ease-out,border-color 120ms ease-out}
:root:root body #writing #text-form .wk-toggle svg{inline-size:20px;block-size:20px;margin:0;display:block;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round;pointer-events:none}
:root:root body #writing #text-form .wk-toggle.wk-tg-lang{color:var(--tg-brand)}
:root:root body #writing #text-form .wk-toggle.wk-tg-lang .wk-tg-i{border-color:var(--tg-brand)}
:root:root body #writing #text-form .wk-toggle.wk-tg-open .wk-tg-i,:root:root body #writing #text-form .wk-toggle:active .wk-tg-i{background:var(--tg-brand);border-color:var(--tg-brand);color:var(--tg-on)}
:root:root body #writing #text-form .wk-toggle.wk-tg-open{color:var(--tg-on)}
:root:root body #writing #text-form .wk-toggle:focus-visible{outline:2px solid var(--tg-brand);outline-offset:-4px;border-radius:12px}
:root:root body #writing #text-form .wk-tg-b{position:absolute;inset-block-end:-5px;inset-inline-end:-5px;min-inline-size:16px;block-size:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--tg-brand);color:var(--tg-on);font:700 9px/14px system-ui,"Segoe UI",sans-serif;letter-spacing:0;text-align:center;pointer-events:none}
:root:root body #writing #text-form .wk-tg-b[hidden]{display:none!important}
@media (prefers-color-scheme:dark){:root:not([data-theme=light]) body #writing #text-form .wk-toggle{--tg-mute:#9db6ae;--tg-brand:#2ff0c2;--tg-on:#06110e;--tg-line:#38605a;--tg-chip:rgba(11,31,33,.86);--tg-press:#26433f}}
:root[data-theme=dark] body #writing #text-form .wk-toggle{--tg-mute:#9db6ae;--tg-brand:#2ff0c2;--tg-on:#06110e;--tg-line:#38605a;--tg-chip:rgba(11,31,33,.86);--tg-press:#26433f}
/* the textarea keeps its text clear of the icon: extra padding on the icon's physical side (left in RTL, right in LTR) */
:root:root:root body #writing #text-form.wk-tg-on #writing-input{padding-left:50px}
:root[dir=ltr]:root:root body #writing #text-form.wk-tg-on #writing-input{padding-left:16px;padding-right:50px}
@media (prefers-reduced-motion:reduce){:root:root body #writing #text-form .wk-tg-i{transition:none}}
@media print{#wk-toggle{display:none}}
/* QA 2026-11-29: keep typed text clear of the corner keyboard icon (it sat under «في» on the first line). */
:root:root body #writing #text-form:has(.wk-toggle:not([hidden])) #writing-input{padding-inline-end:50px!important}
