/* =====================================================================
   wixct collections — shared styles for every page
   Theme tokens, header, header tools (theme · Ko-fi · language · avatar),
   Ko-fi dialog, grain, glow, interactive headline, buttons.
   ===================================================================== */

/* ---------- 0. Thmanyah Sans (relative to this file: /assets/fonts/) ---------- */
@font-face{ font-family:'Thmanyah Sans'; font-weight:300; font-style:normal; font-display:swap; src:url('fonts/thmanyah-sans-Light.woff2') format('woff2'); }
@font-face{ font-family:'Thmanyah Sans'; font-weight:400; font-style:normal; font-display:swap; src:url('fonts/thmanyah-sans-Regular.woff2') format('woff2'); }
@font-face{ font-family:'Thmanyah Sans'; font-weight:500; font-style:normal; font-display:swap; src:url('fonts/thmanyah-sans-Medium.woff2') format('woff2'); }
@font-face{ font-family:'Thmanyah Sans'; font-weight:700; font-style:normal; font-display:swap; src:url('fonts/thmanyah-sans-Bold.woff2') format('woff2'); }
@font-face{ font-family:'Thmanyah Sans'; font-weight:900; font-style:normal; font-display:swap; src:url('fonts/thmanyah-sans-Black.woff2') format('woff2'); }

/* ---------- 1. Theme tokens ----------
   Dark  = warm charcoal night (never pure black)
   Light = warm sand paper     (never pure white) */
:root,
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0f1113;
  --bg-deep:#0b0c0e;
  --surface:rgba(23,26,29,.72);
  --surface-solid:#16191c;
  --raised:#1d2125;
  --well:#121417;
  --border:#252a2f;
  --line:#343a41;
  --text:#ece7dc;
  --dim:#b5b0a6;
  --faint:#837f78;
  --accent:#ff8a3d;
  --accent-soft:rgba(255,138,61,.14);
  --on-accent:#1b0e04;
  --btn:#ece7dc;
  --on-btn:#141618;
  --hover:rgba(236,231,220,.08);
  --glow-a:rgba(255,138,61,.11);
  --glow-b:rgba(255,138,61,.11);
  --glow-c:rgba(120,220,150,.035);
  --shadow:0 18px 50px rgba(0,0,0,.45);
  --card-shadow:0 10px 26px rgba(0,0,0,.55);
  --header-frost:rgba(15,17,19,.74);
  --grain:.06;
  --grain-blend:normal;
}
:root[data-theme="light"]{
  color-scheme:light;
  --bg:#f1ebdf;
  --bg-deep:#e9e1d2;
  --surface:rgba(251,247,239,.74);
  --surface-solid:#f8f3ea;
  --raised:#fdfaf4;
  --well:#e8e0d1;
  --border:#ddd3c2;
  --line:#cbbfab;
  --text:#211d18;
  --dim:#574f45;
  --faint:#857b6d;
  --accent:#cf5a17;
  --accent-soft:rgba(207,90,23,.12);
  --on-accent:#fff7ef;
  --btn:#211d18;
  --on-btn:#f6f0e5;
  --hover:rgba(33,29,24,.07);
  --glow-a:rgba(255,150,80,.22);
  --glow-b:rgba(255,150,80,.22);
  --glow-c:rgba(120,200,140,.08);
  --shadow:0 18px 50px rgba(80,60,30,.16);
  --card-shadow:0 10px 24px rgba(70,50,20,.22);
  --header-frost:rgba(241,235,223,.78);
  --grain:.09;
  --grain-blend:multiply;
}

:root{
  /* Thmanyah Sans (owner; github.com/EngDawood/thmanyah-font-web, Thmanyah's font licence), self-hosted */
  --font:'Thmanyah Sans','Space Grotesk','Helvetica Neue',Arial,sans-serif;
  --font-ar:'Thmanyah Sans','IBM Plex Sans Arabic','Space Grotesk',Tahoma,sans-serif;
  --ease-out:cubic-bezier(.22,1,.36,1);
  --radius:clamp(14px, 1.8vmin, 22px);
  --gutter:clamp(16px, 3.4vmin, 56px);
}
:root[lang="ar"]{ --font:var(--font-ar); }

*{ box-sizing:border-box; }
html,body{
  margin:0; background:var(--bg); color:var(--text);
  font-family:var(--font); -webkit-font-smoothing:antialiased;
  -webkit-text-size-adjust:100%;
}
body{ overflow-x:hidden; min-height:100vh; min-height:100dvh; }
/* theme swaps fade instead of flashing */
body, .site-header, .card, .panel, .btn{ transition:background-color .35s ease, color .35s ease, border-color .35s ease; }
button{ font:inherit; color:inherit; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:3px; }
[hidden]{ display:none !important; }
.sr{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

@view-transition{ navigation:auto; }
::view-transition-old(root), ::view-transition-new(root){ animation-duration:.35s; }

/* ---------- 2. Atmosphere: glow + film grain (never on exported covers) ---------- */
.glow{
  position:fixed; inset:0; z-index:0; pointer-events:none;
  background:
    radial-gradient(60vmax 45vmax at 12% 16%, var(--glow-a), transparent 60%),
    radial-gradient(55vmax 45vmax at 90% 88%, var(--glow-b), transparent 60%),
    radial-gradient(40vmax 30vmax at 55% 55%, var(--glow-c), transparent 60%);
  transition:opacity .4s ease;
}
.grain{
  position:fixed; inset:0; z-index:2; pointer-events:none; opacity:var(--grain); mix-blend-mode:var(--grain-blend);
  background-image:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ---------- 3. Header ---------- */
.site-header{
  position:fixed; top:0; left:0; right:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding-top:calc(clamp(12px, 2.6vmin, 34px) + env(safe-area-inset-top,0px));
  padding-bottom:clamp(10px, 1.6vmin, 18px);
  padding-inline:calc(var(--gutter) + env(safe-area-inset-left,0px)) calc(var(--gutter) + env(safe-area-inset-right,0px));
  transition:background-color .25s ease, backdrop-filter .25s ease;
}
.site-header.scrolled{
  background:var(--header-frost);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
}
.brand{
  display:inline-flex; align-items:center; gap:clamp(10px, 1.8vmin, 20px);
  color:var(--text); text-decoration:none; min-width:0;
  view-transition-name:brand;
}
.brand .mark{ width:clamp(30px, 4.2vmin, 46px); height:clamp(30px, 4.2vmin, 46px); flex-shrink:0; display:block; }
.brand .mark .c1{ fill:var(--accent); }
.brand .mark .c2{ fill:var(--text); opacity:.22; }
.brand .mark .c3{ fill:var(--text); opacity:.5; }
.brand .mark rect{ transition:transform .35s var(--ease-out); transform-box:fill-box; transform-origin:50% 100%; }
@media (hover:hover){
  .brand:hover .mark .c2{ transform:rotate(-10deg) translateX(-6%); }
  .brand:hover .mark .c3{ transform:rotate(10deg) translateX(6%); }
}
.brand .div{ width:1px; height:clamp(22px, 3.4vmin, 40px); background:var(--line); }
.brand .name{ font-size:clamp(17px, 2.6vmin, 30px); font-weight:600; letter-spacing:.01em; white-space:nowrap; }

.tools{ display:flex; align-items:center; gap:4px; view-transition-name:tools; }
.tool{
  position:relative; display:inline-grid; place-items:center;
  width:44px; height:44px; padding:0; border:0; border-radius:999px;
  background:transparent; color:var(--text); cursor:pointer; overflow:hidden; text-decoration:none;
  transition:background-color .2s ease, transform 160ms var(--ease-out);
  -webkit-tap-highlight-color:transparent;
}
.tool:active{ transform:scale(.94); }
@media (hover:hover) and (pointer:fine){ .tool:hover{ background:var(--hover); } }

/* theme: sun ↔ moon */
.tool .ic{ grid-area:1/1; display:grid; place-items:center; transition:transform 300ms var(--ease-out), opacity 200ms ease; }
.tool svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
:root[data-theme="dark"] #theme .moon{ opacity:0; transform:rotate(-90deg) scale(.6); }
:root[data-theme="light"] #theme .sun{ opacity:0; transform:rotate(90deg) scale(.6); }

/* Ko-fi cup: steam rises and heart beats on hover */
.kofi-link svg{ width:24px; height:24px; stroke-width:2; overflow:visible; }
.kofi-link .heart{ fill:currentColor; stroke:none; transform-box:fill-box; transform-origin:center; }
.kofi-link .steam{ opacity:0; transform:translateY(3px); transition:opacity 200ms ease, transform 300ms var(--ease-out); }
@media (hover:hover) and (pointer:fine){
  .kofi-link:hover .steam{ opacity:1; transform:none; }
  .kofi-link:hover .heart{ animation:beat 600ms var(--ease-out); color:var(--accent); }
}
@keyframes beat{ 30%{ transform:scale(1.25); } 60%{ transform:scale(.95); } }

/* language: 🇸🇦 ع ↔ 🇺🇸 EN */
#locale{ width:auto; padding:0 12px; font:700 17px/1 'IBM Plex Sans Arabic',system-ui,sans-serif; }
#locale .glyph{ grid-area:1/1; display:inline-flex; align-items:center; gap:7px; transition:transform 240ms var(--ease-out), opacity 180ms ease; }
#locale img{ width:21px; height:14px; border-radius:3px; object-fit:cover; box-shadow:0 0 0 1px var(--line); }
#locale .en{ font-family:'Space Grotesk',system-ui,sans-serif; font-size:14px; letter-spacing:.02em; }
:root:not([lang="ar"]) #locale .en{ opacity:0; transform:translateY(110%); }
:root[lang="ar"] #locale .ar{ opacity:0; transform:translateY(-110%); }

/* avatar + name */
.tools .sep{ width:1px; height:24px; background:var(--line); margin:0 8px; }
.me{
  display:inline-flex; align-items:center; gap:10px; height:44px; padding:0 14px 0 4px;
  border-radius:999px; color:var(--text); text-decoration:none; font-weight:600; font-size:16px;
  transition:background-color .2s ease, transform 160ms var(--ease-out);
}
:root[dir="rtl"] .me{ padding:0 4px 0 14px; }
.me img{
  width:34px; height:34px; border-radius:999px; object-fit:cover; display:block;
  box-shadow:0 0 0 2px var(--bg), 0 0 0 3.5px var(--line);
  transition:box-shadow .25s ease, transform .35s var(--ease-out);
}
.me:active{ transform:scale(.97); }
@media (hover:hover) and (pointer:fine){
  .me:hover{ background:var(--hover); }
  .me:hover img{ box-shadow:0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); transform:rotate(-6deg); }
}
@media (max-width:520px){
  .brand{ gap:8px; }
  .brand .name{ font-size:17px; }
  .brand .div{ display:none; }
  .me span{ display:none; }
  .me{ padding:0 4px; }
  .tools .sep{ margin:0 4px; }
  /* phones: the name and five tools only fit side by side with narrower tools (the name never runs under them) */
  .tools{ gap:2px; }
  .tool{ width:38px; }
  .brand .name{ overflow:hidden; text-overflow:ellipsis; }
}
@media (max-width:420px){ .brand .name{ display:none; } }
/* Arabic: the language button reads "EN" with its flag, a little wider */
@media (max-width:440px){ :root[dir="rtl"] .brand .name{ display:none; } }

/* ---------- 4. Ko-fi dialog ---------- */
dialog.kofi{
  width:min(480px, calc(100vw - 32px)); max-height:calc(100dvh - 32px);
  padding:20px; border:1px solid var(--border); border-radius:20px;
  background:var(--raised); color:var(--text); box-shadow:var(--shadow); overflow:auto;
}
dialog.kofi::backdrop{ background:rgba(8,8,10,.6); backdrop-filter:blur(3px); }
dialog.kofi[open]{ animation:pop-in 250ms var(--ease-out); }
dialog.kofi[open]::backdrop{ animation:fade-in 250ms var(--ease-out); }
dialog.kofi[data-state="closing"]{ opacity:0; transform:scale(.96); transition:opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
@keyframes pop-in{ from{ opacity:0; transform:scale(.96); } }
@keyframes fade-in{ from{ opacity:0; } }
.kofi-head{ display:flex; align-items:center; gap:12px; }
.kofi-head h2{ flex:1; margin:0; font-size:22px; letter-spacing:-.02em; line-height:1.2; }
.kofi-close{
  display:grid; place-items:center; width:40px; height:40px; border:0; border-radius:999px;
  background:var(--hover); color:var(--text); cursor:pointer; transition:transform 160ms var(--ease-out);
}
.kofi-close:active{ transform:scale(.94); }
.kofi-close svg{ width:18px; height:18px; stroke:currentColor; stroke-width:2; stroke-linecap:round; fill:none; }
.kofi-body{ margin:8px 0 16px; color:var(--dim); font-size:16px; line-height:1.55; }
.kofi-frame{ display:block; width:100%; height:585px; border:0; border-radius:14px; background:#fff; transition:height 300ms var(--ease-out); }
.kofi-frame.is-open{ height:712px; }
.kofi-open{
  display:inline-flex; align-items:center; gap:8px; min-height:40px; margin-top:14px; padding:0 16px;
  border-radius:999px; background:var(--hover); color:var(--text); font-size:15px; font-weight:600; text-decoration:none;
}
.kofi-open svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; transition:transform 200ms var(--ease-out); }
:root[dir="rtl"] .kofi-open svg{ transform:scaleX(-1); }
@media (hover:hover) and (pointer:fine){ .kofi-open:hover svg{ transform:translate(2px,-2px); } }

/* ---------- 5. Interactive headline letters (English only — Arabic letters must stay joined) ---------- */
[data-interactive]{ user-select:none; -webkit-user-select:none; -webkit-tap-highlight-color:transparent; }
[data-interactive] .word{ display:inline-block; white-space:nowrap; }
[data-interactive] .ch{
  display:inline-block; will-change:transform;
  transition:color .35s ease, transform .22s cubic-bezier(.2,.8,.3,1);
  transform:translateY(calc(var(--lift,0) * -0.22em)) scale(calc(1 + var(--lift,0) * .12));
}
[data-interactive] .ch.hot{ color:var(--accent); }
[data-interactive].wave .ch{ animation:wave .9s cubic-bezier(.3,.7,.3,1) both; animation-delay:calc(var(--i) * 28ms); }
@keyframes wave{
  0%  { transform:translateY(0) scale(1); color:var(--text); }
  35% { transform:translateY(-.26em) scale(1.12); color:var(--accent); }
  100%{ transform:translateY(0) scale(1); color:var(--text); }
}

/* ---------- 6. Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:10px;
  min-height:48px; padding:0 22px; border-radius:999px; border:1px solid transparent;
  background:var(--btn); color:var(--on-btn); font-weight:600; font-size:16px; text-decoration:none; cursor:pointer;
  transition:transform 160ms var(--ease-out), background-color .25s ease, box-shadow .25s ease, opacity .2s ease;
  -webkit-tap-highlight-color:transparent;
}
.btn svg{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; flex-shrink:0; }
.btn:active{ transform:scale(.97); }
@media (hover:hover){ .btn:hover{ box-shadow:0 8px 24px var(--accent-soft); } }
.btn.ghost{ background:transparent; color:var(--text); border-color:var(--line); }
@media (hover:hover){ .btn.ghost:hover{ background:var(--hover); box-shadow:none; } }
.btn.accent{ background:var(--accent); color:var(--on-accent); }
.btn[disabled], .btn[aria-disabled="true"]{ opacity:.45; cursor:not-allowed; box-shadow:none; transform:none; }
.btn .soon{ font-size:12px; font-weight:600; padding:2px 8px; border-radius:999px; background:var(--hover); }

/* toast for small confirmations (copied, saved) */
.toast{
  position:fixed; left:50%; bottom:calc(24px + env(safe-area-inset-bottom,0px)); z-index:70;
  transform:translate(-50%, 16px); opacity:0; pointer-events:none;
  padding:10px 18px; border-radius:999px; background:var(--btn); color:var(--on-btn); font-weight:600; font-size:15px;
  box-shadow:var(--shadow); transition:opacity .2s ease, transform .3s var(--ease-out);
}
.toast.show{ opacity:1; transform:translate(-50%, 0); }

/* page heading shared by inner pages */
.page-title{
  margin:0; font-weight:700; letter-spacing:-.03em; line-height:1; text-wrap:balance;
  font-size:clamp(30px, 6vmin, 72px);
}
:root[lang="ar"] .page-title, :root[lang="ar"] .headline{ letter-spacing:0; line-height:1.25; }
.page-sub{ margin:12px 0 0; color:var(--dim); font-size:clamp(14px, 1.8vmin, 19px); line-height:1.5; }

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
  [data-interactive] .ch{ transform:none !important; }
}

/* Simkl's icon is a black tile: on the dark theme it's shown inverted (white tile, black S) so it stands out */
:root[data-theme="dark"] img[src$="/simkl.png"]{ filter:invert(1); }

/* ---------- password dialog (WIXCT.askPassword) ---------- */
dialog.pw-dialog{ width:min(440px, calc(100vw - 32px)); padding:22px; border:1px solid var(--border); border-radius:22px; background:var(--surface-solid); color:var(--text); box-shadow:var(--shadow); }
dialog.pw-dialog::backdrop{ background:rgba(8,8,10,.6); backdrop-filter:blur(3px); }
.pw-dialog form{ display:grid; gap:12px; }
.pw-dialog h2{ margin:0; font-size:21px; }
.pw-dialog p{ margin:0; color:var(--dim); }
.pw-dialog input{ min-height:46px; padding:0 14px; border-radius:12px; border:1px solid var(--line); background:var(--well); color:var(--text); font:inherit; }
.pw-dialog .pw-err{ color:#ff6b5b; min-height:1.2em; font-size:14px; }
.pw-actions{ display:flex; flex-wrap:wrap; gap:10px; justify-content:flex-end; align-items:center; }
.pw-actions .pw-alt, .pw-actions .pw-cancel{ min-height:44px; padding:0 14px; border:0; border-radius:999px; background:transparent; color:var(--dim); font:inherit; cursor:pointer; }
.pw-actions .pw-alt{ margin-inline-end:auto; text-decoration:underline; padding:0; }
@media (hover:hover){ .pw-actions .pw-cancel:hover{ background:var(--hover); color:var(--text); } }
