@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  --bg: #05070a;
  --panel: rgba(8, 12, 16, .8);
  --line: rgba(120, 255, 190, .14);
  --text: #c9d6d1;
  --dim: #5d6f68;
  --green: #3dffa2;
  --cyan: #45d6ff;
  --amber: #ffc857;
  --red: #ff5f6d;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Arabic", "Segoe UI", Tahoma, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: radial-gradient(1200px 700px at 70% -10%, rgba(69, 214, 255, .07), transparent 60%),
              radial-gradient(900px 600px at 0% 110%, rgba(61, 255, 162, .06), transparent 60%),
              var(--bg);
  min-height: 100vh;
  padding-inline: max(16px, env(safe-area-inset-left));
  overflow-x: hidden;
}
html[lang="ar"] body { font-size: 15.5px; line-height: 1.9; }
::selection { background: var(--green); color: #000; }

/* ---------- background layers ---------- */
#net { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.crt {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}
.crt::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 120px;
  background: linear-gradient(to bottom, transparent, rgba(61,255,162,.05), transparent);
  animation: sweep 7s linear infinite;
  will-change: transform;
}
@keyframes sweep { from { transform: translateY(-120px); } to { transform: translateY(100vh); } }

.shell {
  position: relative; z-index: 2;
  max-width: 1180px; margin: 0 auto;
  padding-block: 16px 24px;
  min-height: 100vh;
  display: flex; flex-direction: column; gap: 14px;
}

/* ---------- status bar ---------- */
.statusbar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  font-size: 12px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 6px 6px 12px; background: rgba(5,7,10,.88);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  direction: ltr;
}
.statusbar b { color: var(--text); font-weight: 500; }
.statusbar .grow { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: ping 2s infinite; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(61,255,162,.6); }
  80%, 100% { box-shadow: 0 0 0 8px rgba(61,255,162,0); }
}
#countdown { color: var(--green); font-variant-numeric: tabular-nums; }

/* language switcher */
.langs {
  display: inline-flex; padding: 3px; gap: 3px;
  border: 1px solid var(--line); border-radius: 7px; background: rgba(0,0,0,.35);
}
.lang {
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  min-width: 44px; min-height: 32px; padding: 0 10px;
  color: var(--dim); background: transparent; border: 0; border-radius: 5px; cursor: pointer;
  transition: color .15s, background .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.lang[lang="ar"] { font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif; font-size: 13px; }
.lang:hover { color: var(--text); background: rgba(61,255,162,.08); }
.lang:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.lang[aria-pressed="true"] { color: #031a0e; background: var(--green); box-shadow: 0 0 14px rgba(61,255,162,.45); }

/* ---------- windows ---------- */
.grid {
  flex: 1;
  display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px;
  align-items: start;
}
.term {
  position: relative;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.03);
  overflow: hidden;
}
.term::before {            /* rotating border glow */
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: conic-gradient(from var(--a, 0deg), transparent 0 70%, rgba(61,255,162,.55) 80%, rgba(69,214,255,.55) 88%, transparent 96%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spin 9s linear infinite;
  pointer-events: none;
}
@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes spin { to { --a: 360deg; } }

.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; font-size: 12px; color: var(--dim);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.015);
}
.lights { display: inline-flex; gap: 6px; }
.lights i { width: 10px; height: 10px; border-radius: 50%; background: #2a3430; transition: background .25s; }
.term:hover .lights i:nth-child(1) { background: var(--red); }
.term:hover .lights i:nth-child(2) { background: var(--amber); }
.term:hover .lights i:nth-child(3) { background: var(--green); }
.title { flex: 1; text-align: center; color: var(--text); opacity: .75; }
.tty.live { color: var(--red); animation: blink 1.6s steps(1) infinite; }

.screen { padding: 18px 20px 22px; }
.cmd, .out { white-space: pre-wrap; overflow-wrap: anywhere; }
.cmd { color: var(--cyan); min-height: 1.7em; }
html[dir="rtl"] .cmd { text-align: right; }
.out { color: var(--text); }
.ok { color: var(--green); }
.hl { color: var(--amber); }
.dim { color: var(--dim); }
.block { margin-top: 22px; }

/* ---------- hero ---------- */
.hero { margin: 24px 0 6px; line-height: 1; }
html[dir="rtl"] .hero { text-align: right; }
.glitch {
  position: relative; display: inline-block;
  font-size: clamp(28px, 7.2vw, 72px); font-weight: 800; letter-spacing: -.03em;
  color: #eafff5;
  text-shadow: 0 0 18px rgba(61,255,162,.35);
}
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.glitch::before { color: var(--cyan); transform: translate(2px, 0); clip-path: inset(0 0 100% 0); animation: g1 5s infinite steps(1); }
.glitch::after  { color: var(--green); transform: translate(-2px, 0); clip-path: inset(100% 0 0 0); animation: g2 5s infinite steps(1); }
@keyframes g1 {
  0%, 88%, 100% { clip-path: inset(0 0 100% 0); }
  89% { clip-path: inset(10% 0 60% 0); transform: translate(4px, -1px); }
  91% { clip-path: inset(55% 0 20% 0); transform: translate(-3px, 1px); }
  93% { clip-path: inset(30% 0 45% 0); transform: translate(2px, 0); }
}
@keyframes g2 {
  0%, 88%, 100% { clip-path: inset(100% 0 0 0); }
  90% { clip-path: inset(70% 0 5% 0); transform: translate(-4px, 1px); }
  92% { clip-path: inset(15% 0 70% 0); transform: translate(3px, -1px); }
  94% { clip-path: inset(40% 0 35% 0); transform: translate(-2px, 0); }
}
.tagline { color: var(--dim); margin-top: 12px; }

.topics { list-style: none; margin-top: 4px; }
.topics li { padding: 3px 0; padding-inline-start: 1.2em; position: relative; }
.topics li::before { content: "›"; position: absolute; inset-inline-start: 0; color: var(--dim); }
html[dir="rtl"] .topics li::before { content: "‹"; }
.tag { color: var(--green); font-weight: 700; margin-inline-end: .6em; unicode-bidi: isolate; direction: ltr; display: inline-block; }

/* ---------- prompt / form ---------- */
.prompt {
  margin-top: 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 10px 10px 14px;
  border: 1px dashed rgba(61,255,162,.3); border-radius: 8px;
  background: rgba(61,255,162,.03);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
html[dir="rtl"] .prompt { padding: 10px 14px 10px 10px; }
.prompt:focus-within {
  border-style: solid; border-color: rgba(61,255,162,.7);
  background: rgba(61,255,162,.05);
  box-shadow: 0 0 0 4px rgba(61,255,162,.07), 0 0 30px -6px rgba(61,255,162,.35);
}
.prompt.valid { border-style: solid; border-color: var(--green); }
.prompt.invalid { border-style: solid; border-color: var(--red); box-shadow: 0 0 0 4px rgba(255,95,109,.08); }
.ps1 { color: var(--green); white-space: nowrap; }
.prompt input[type=email] {
  flex: 1 1 200px; min-width: 0;
  background: transparent; border: 0; outline: 0; border-radius: 0;
  font: inherit; font-size: 16px; color: #fff;   /* 16px: no iOS zoom on focus */
  caret-color: var(--green);
  padding: 8px 0;
  text-align: left;
}
.prompt input::placeholder { color: #3b4944; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.run {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 12px;
  min-height: 42px;
  color: var(--green); background: transparent;
  border: 1px solid rgba(61,255,162,.55); border-radius: 6px;
  padding: 0 16px; cursor: pointer;
  transition: color .12s, background .12s, box-shadow .12s, transform .08s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
html[lang="ar"] .run { letter-spacing: 0; font-size: 14px; }
.run::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(61,255,162,.35), transparent);
  animation: scan 2.8s ease-in-out infinite;
  will-change: transform;
}
@keyframes scan { 0% { transform: translateX(-150%); } 60%, 100% { transform: translateX(350%); } }
.prompt.valid .run, .run:hover, .run:focus-visible {
  background: var(--green); color: #031a0e; outline: none;
  box-shadow: 0 0 24px rgba(61,255,162,.55);
}
.run:hover .run-label { animation: jitter .3s steps(2) 2; }
@keyframes jitter { 50% { transform: translate(1px, -1px); } }
.run:active { transform: translateY(1px) scale(.97); }
.run-key { border: 1px solid currentColor; border-radius: 3px; padding: 0 5px; font-size: 11px; opacity: .8; }
.run.busy { pointer-events: none; }
.run.busy .run-label, .run.busy .run-key { visibility: hidden; }
.run.busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: rot .6s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }
.prompt.shake { animation: shake .3s; }
@keyframes shake { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

.hint { min-height: 1.7em; margin-top: 6px; font-size: 12.5px; color: var(--dim); transition: color .12s; }
.hint.good { color: var(--green); }
.hint.bad { color: var(--red); }

.output { min-height: 0; }
.output .row { white-space: pre-wrap; overflow-wrap: anywhere; }
.output .err { color: var(--red); }
.output .success {
  margin-top: 6px; padding: 10px 12px;
  border-inline-start: 2px solid var(--green);
  background: linear-gradient(90deg, rgba(61,255,162,.12), transparent);
  color: #eafff5;
  animation: pop .25s ease-out;
}
html[dir="rtl"] .output .success { background: linear-gradient(270deg, rgba(61,255,162,.12), transparent); }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

.caret-line { margin-top: 20px; }
.caret {
  display: inline-block; width: .6em; height: 1.1em; vertical-align: -.18em;
  background: var(--green); box-shadow: 0 0 10px var(--green);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- agent log ---------- */
.log { position: sticky; top: 70px; }
.log .screen {
  height: 420px; overflow: hidden; font-size: 11.5px; line-height: 1.65;
  padding: 12px 14px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 25%);
          mask-image: linear-gradient(to bottom, transparent, #000 25%);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.log .entry { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: in .35s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.log .t { color: #3b4944; }
.log .k-fetch { color: var(--cyan); }
.log .k-embed { color: #b58cff; }
.log .k-rank  { color: var(--amber); }
.log .k-sum   { color: var(--green); }
.log .k-sys   { color: var(--dim); }
.meter { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 9px 14px; font-size: 11px; color: var(--dim); }
.bars { flex: 1; display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.bars i { flex: 1; height: 10%; background: linear-gradient(to top, rgba(61,255,162,.25), var(--green)); border-radius: 1px; transition: height .4s ease; }

footer {
  display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: center;
  font-size: 11.5px; color: var(--dim); padding-top: 4px;
  padding-bottom: env(safe-area-inset-bottom);
}
.sep { opacity: .4; }

/* no-JS fallback page served by subscribe.php */
.fallback .shell { justify-content: center; max-width: 640px; }
.fallback .err { color: var(--red); }
.fallback a { color: var(--cyan); }

/* ---------- reveal (only when JS runs; keeps layout fixed = no jumps) ---------- */
.js [data-show], .js [data-type] { visibility: hidden; }
.js .shown { visibility: visible; animation: reveal .25s ease-out; }
@keyframes reveal { from { opacity: 0; filter: blur(2px); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .log { position: relative; top: 0; }
  .log .screen { height: 150px; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) {
  body { font-size: 13.5px; }
  html[lang="ar"] body { font-size: 15px; }
  .shell { padding-block: 10px 18px; gap: 10px; }
  .statusbar { top: 6px; padding-left: 10px; }
  .screen { padding: 14px 14px 18px; }
  .titlebar { padding: 8px 12px; }
  .prompt, html[dir="rtl"] .prompt { padding: 10px; }
  .ps1 { font-size: 12.5px; }
  .prompt input[type=email] { flex-basis: 100%; }
  .run { width: 100%; min-height: 48px; font-size: 13px; }
  .log .screen { height: 120px; font-size: 11px; }
  .crt::after { display: none; }
}
@media (hover: none) { .hide-touch { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js [data-show], .js [data-type] { visibility: visible; }
}
