/*
 * Flow Bypasser — "Aurora Glass" design tokens and shared components.
 * Used by the popup and the welcome page. The hosted uninstall page ships a copy
 * of this file (plus grain.svg and the fonts); keep them in sync.
 *
 * Direction: dir/lang live on <html> (set by FlowLocale). Anything directional
 * uses logical properties or a [dir="rtl"] override at the root.
 * Tone: body[data-tone] = open | closed | warn | wait. "open" is the base style.
 */

/* ------------------------------------------------------------ fonts */

/* Arabic glyphs always come from the bundled Vazirmatn. */
@font-face {
  font-family: "Flow Arabic";
  src: url("../fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: block;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}

@font-face { font-family: "Inter"; src: url("../fonts/inter-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: block; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: block; }
@font-face { font-family: "Sora"; src: url("../fonts/sora-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: block; }
@font-face { font-family: "Sora"; src: url("../fonts/sora-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: block; }
@font-face { font-family: "Sora"; src: url("../fonts/sora-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: block; }

/* ----------------------------------------------------------- tokens */

:root {
  color-scheme: dark;
  --font: "Flow Arabic", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Flow Arabic", "Sora", "Inter", system-ui, sans-serif;
  --latin: "Inter", system-ui, sans-serif;
  --wordmark: "Sora", "Inter", system-ui, sans-serif;

  --bg: #05060a;
  --bg-2: #080a12;
  --ink: #f5f6fa;
  --soft: #c4c9d4;
  --muted: #8b92a0;
  --faint: #5d6472;
  --hair: rgba(255, 255, 255, 0.08);
  --glass: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));

  --on-1: #c3f7a4;  --on-2: #58e2c6;
  --off-1: #f2c58c; --off-2: #e98f6f;
  --warn: #f2c58c;
  --danger: #ff8f8f;
  --gold-1: #ffe9a3; --gold-2: #ffb84d;
  --focus: #9fd8ff;

  --s1: #3d6bff; --s2: #8b5cff; --s3: #ff4fd2; --s4: #ff8a3d; --s5: #ffd84a; --s6: #6dffa0;
  --pearl: linear-gradient(95deg, #8fd0ff, #b9a2ff 42%, #ffa6db 78%, #ffd3a6);

  --r-sm: 10px; --r-md: 16px; --r-lg: 20px;

  /* Reading-order helpers. Directional gradients start on the inline-start side. */
  --flow-angle: 90deg;
  --rim-angle: 160deg;
  --spectrum: linear-gradient(var(--flow-angle), var(--s1), var(--s2) 22%, var(--s3) 45%, var(--s4) 64%, var(--s5) 80%, var(--s6));
  --glass-rim: linear-gradient(var(--rim-angle), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.02) 70%, rgba(140, 120, 255, 0.18));
}

[dir="rtl"] { --flow-angle: -90deg; --rim-angle: 200deg; }

/* ------------------------------------------------------------- base */

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: #020306; color: var(--ink); font: 13px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
p, h1, h2, h3, ol, fieldset, legend { margin: 0; padding: 0; }
fieldset { border: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

/* Focus ring follows each control's own shape (never reshape it on focus). */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Latin runs (emails, URLs, versions) keep their own order inside Arabic text. */
.ltr { direction: ltr; unicode-bidi: isolate; }

/* Text for screen readers only. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Only directional icons (arrows, chevrons) carry .flip. */
[dir="rtl"] .flip { transform: scaleX(-1); }

/* Hidden SVG that only holds shared <defs> (e.g. the gold star gradient). */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------ shared components */

/* Film grain over a whole surface (file asset: data: URIs are blocked by img-src 'self').
   No mix-blend-mode and no backdrop-filter anywhere: together they make Chrome repaint
   stale vertical bands over the glass cards when a small element (a hovered link) repaints. */
.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("grain.svg");
}

/* Aurora ribbon: always in the top corner opposite the logo. */
.aurora { position: absolute; z-index: 0; top: 0; inset-inline-end: 0; pointer-events: none; }
[dir="rtl"] .aurora { transform: scaleX(-1); }
.aurora svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* The wordmark is always LTR. */
.wordmark { font-family: var(--wordmark); direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-weight: 600; letter-spacing: -0.025em; }
/* Stays LTR so the words keep their order, but aligns with the eyebrow and tagline in RTL. */
[dir="rtl"] .wordmark { text-align: right; }
.wordmark span { background: var(--pearl); -webkit-background-clip: text; background-clip: text; color: transparent; }

.eyebrow-row { display: flex; align-items: center; gap: 8px; }
.eyebrow { font-size: 10.5px; letter-spacing: 0.2em; color: var(--muted); font-weight: 600; }
.ver-chip { font: 500 10.5px/1 var(--latin); color: var(--soft); padding: 3px 7px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09); letter-spacing: 0.02em; }

/* The logo is the bare transparent glyph: no tile, ring, radius or glow. The PNG has
   ~20% transparent padding, so the glyph is scaled up within its box. */
.logo { position: relative; flex: none; }
.logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.35);
  filter: drop-shadow(0 6px 16px rgba(120, 90, 255, 0.35));
}

/* Language pill: both labels use the Latin face with the same tracking. */
.lang { display: inline-flex; align-items: center; height: 28px; padding: 2px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.035); flex: none; }
.lang button { position: relative; height: 22px; min-width: 36px; padding: 0 10px; border-radius: 999px; font: 600 11.5px/22px var(--latin); letter-spacing: 0.04em; color: var(--muted); transition: background-color 0.2s, color 0.2s; }
.lang button::before { content: ""; position: absolute; inset: -7px -1px; } /* larger hit area */
.lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.12); color: var(--ink); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); cursor: default; }

/* Glass surface with a hairline gradient rim. */
.glass { position: relative; border-radius: var(--r-lg); background: var(--glass); }
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: var(--glass-rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* --------------------------------------------------------- status */

.status-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.status-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--on-1); flex: none; }
.status-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--on-1); animation: ping 2.4s ease-out infinite; }
@keyframes ping { 0% { transform: scale(0.6); opacity: 0.7; } 80%, 100% { transform: scale(1.8); opacity: 0; } }
.headline { font: 700 24px/1.25 var(--display); letter-spacing: -0.01em; margin: 8px 0 4px; }
/* padding-block widens the painted text box so Arabic marks (e.g. the shadda in مفعّل) are never clipped. */
.accent { padding-block: 0.12em; background: linear-gradient(var(--flow-angle), var(--on-1), var(--on-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.detail { color: var(--soft); font-size: 12.5px; }

body[data-tone="closed"] .status-dot { background: var(--off-1); }
body[data-tone="closed"] .status-dot::after { display: none; }
body[data-tone="closed"] .accent { background-image: linear-gradient(var(--flow-angle), var(--off-1), var(--off-2)); }
body[data-tone="warn"] .status-dot { background: var(--warn); }
body[data-tone="warn"] .status-dot::after { border-color: var(--warn); }
body[data-tone="warn"] .detail { color: var(--warn); }
body[data-tone="wait"] .status-dot { background: var(--muted); }
body[data-tone="wait"] .status-dot::after { border-color: var(--muted); }
body[data-tone="wait"] .accent {
  color: transparent;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
  background-size: 200% 100%;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  border-radius: 8px;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Large display text in the pearl gradient (not tied to tone). */
.pearl-text { padding-block: 0.12em; background: linear-gradient(calc(var(--flow-angle) + 5deg), #8fd0ff, #b9a2ff 42%, #ffa6db 78%, #ffd3a6); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* --------------------------------------------------------- switch */

/* The thumb starts at inline-start and travels to inline-end when on. */
.switch { position: relative; width: 58px; height: 34px; border-radius: 999px; flex: none; transition: background 0.35s, box-shadow 0.35s, opacity 0.2s; background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.switch .thumb { position: absolute; top: 4px; inset-inline-start: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.08); transition: transform 0.35s cubic-bezier(0.3, 1.4, 0.5, 1); }
.switch[aria-checked="true"] { background: linear-gradient(var(--flow-angle), var(--on-1), var(--on-2)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 22px -2px rgba(100, 235, 180, 0.55); }
[dir="ltr"] .switch[aria-checked="true"] .thumb { transform: translateX(24px); }
[dir="rtl"] .switch[aria-checked="true"] .thumb { transform: translateX(-24px); }
.switch:disabled { opacity: 0.45; cursor: default; }
.switch:focus-visible { outline-offset: 3px; }
.switch-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.switch-label { font-size: 11px; font-weight: 600; color: var(--on-1); }
body[data-tone="closed"] .switch-label,
body[data-tone="wait"] .switch-label { color: var(--muted); }

/* ------------------------------------------------------ pearl CTA */

/*
 * The button never moves or resizes on hover (a hover lift made the bottom edge
 * flicker on and off). The glow brightens instead. Both decorative layers ignore
 * the pointer, so the hit area is exactly the button in every state.
 */
.cta { position: relative; isolation: isolate; width: 100%; height: 56px; border-radius: var(--r-md); display: flex; align-items: center; color: #0a0b10; font-weight: 600; font-size: 15px; transition: opacity 0.2s; }
.cta::before { content: ""; position: absolute; inset: 3px 10px -2px; border-radius: inherit; z-index: -2; background: var(--spectrum); filter: blur(14px); opacity: 0.55; transition: opacity 0.3s; pointer-events: none; }
.cta::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1; background: linear-gradient(180deg, #ffffff, #e6e9f2); box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 rgba(0, 0, 0, 0.08); pointer-events: none; transition: filter 0.15s; }
.cta:hover:not(:disabled)::before { opacity: 0.85; }
.cta:active:not(:disabled)::after { filter: brightness(0.96); }
.cta .lead { width: 56px; height: 100%; display: grid; place-items: center; border-inline-end: 1px solid rgba(0, 0, 0, 0.08); }
.cta .label { flex: 1; text-align: center; }
.cta .trail { width: 56px; display: grid; place-items: center; opacity: 0.55; }
.cta:focus-visible { outline-offset: 3px; }
body[data-tone="closed"] .cta::before { opacity: 0.25; }
.cta:disabled { cursor: not-allowed; opacity: 0.4; }
.cta:disabled::before { opacity: 0; }

.note { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 11.5px; text-align: center; }
.error { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; font-size: 12px; color: var(--danger); background: rgba(255, 120, 120, 0.07); box-shadow: inset 0 0 0 1px rgba(255, 120, 120, 0.18); }

/* -------------------------------------------------- developer strip */

.dev-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px 16px; border-top: 1px solid rgba(255, 255, 255, 0.06); background: rgba(0, 0, 0, 0.28); font-size: 12px; color: var(--muted); }
.dev-strip .by { display: flex; align-items: baseline; gap: 6px; }
.dev-strip .by span { color: var(--faint); }
.dev-strip b { color: var(--ink); font: 600 12.5px var(--latin); }
.dev-strip .links { display: flex; align-items: center; gap: 14px; }
.dev-strip .links a,
.dev-strip .links button { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; transition: color 0.2s; }
.dev-strip .links a:hover,
.dev-strip .links button:hover { color: var(--ink); }
.dev-strip .links svg { width: 14px; height: 14px; }
.dev-strip .site { font-family: var(--latin); }

/* Copy feedback, centred above its trigger without physical left/right. */
.copy-wrap { position: relative; display: inline-flex; }
.toast {
  position: absolute;
  bottom: calc(100% + 8px);
  /* Centred in a box wider than the trigger, so a label longer than "Email"/"البريد" stays centred too. */
  inset-inline: -80px;
  width: max-content;
  margin-inline: auto;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 11px;
  white-space: nowrap;
  background: #f5f6fa;
  color: #0a0b10;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast[data-state="fail"] { background: var(--warn); }

/* ----------------------------------------------------- rating prompt */

/* A wrapper with two sibling buttons (main action + dismiss), never nested. */
.rate {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 40px;
  padding-inline: 0 6px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: linear-gradient(var(--flow-angle), rgba(255, 196, 90, 0.1), rgba(255, 255, 255, 0.025) 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 120, 0.16);
 
  animation: drop 0.5s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
.rate-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; height: 100%; padding-inline: 12px 6px; border-radius: 12px; text-align: start; }
.rate .stars { display: flex; gap: 2px; direction: ltr; }
.rate .stars svg { width: 13px; height: 13px; fill: rgba(255, 210, 120, 0.25); transition: fill 0.2s, transform 0.2s; }
.rate-main:hover .stars svg,
.rate-main:focus-visible .stars svg { fill: url(#gold); }
.rate-main .stars svg:nth-child(2) { transition-delay: 0.05s; }
.rate-main .stars svg:nth-child(3) { transition-delay: 0.1s; }
.rate-main .stars svg:nth-child(4) { transition-delay: 0.15s; }
.rate-main .stars svg:nth-child(5) { transition-delay: 0.2s; }
.rate .q { flex: 1; min-width: 0; color: var(--soft); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate .act { display: inline-flex; align-items: center; gap: 4px; color: var(--gold-1); font-weight: 600; font-size: 12.5px; }
.rate .act svg { width: 14px; height: 14px; transition: transform 0.2s; }
/* Nudge the chevron forward; in RTL keep its mirror while nudging. */
.rate-main:hover .act svg { transform: translateX(2px); }
[dir="rtl"] .rate-main:hover .act svg { transform: scaleX(-1) translateX(2px); }
.rate .x { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; color: var(--faint); transition: color 0.2s, background-color 0.2s; }
.rate .x:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.rate .x svg { width: 14px; height: 14px; }

/* ----------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  .status-dot::after,
  body[data-tone="wait"] .accent,
  .rate { animation: none; }
  *, *::before, *::after { transition-duration: 1ms !important; transition-delay: 0s !important; }
}
