/* ===========================================================
   Fati Downloader — الواجهة
   الهوية: حبر بنفسجي غامق + برتقالي شريط الكاسيت، وبَكَرتين
   بتلفّوا وقت الشغل. الحركة الوحيدة بالصفحة مربوطة بفعل المستخدم.
   =========================================================== */

:root{
  --ink:      #141019;   /* الخلفية */
  --shell:    #1D1824;   /* اللوحات */
  --shell-2:  #241E2D;
  --line:     #352D40;   /* الحدود */
  --line-2:   #2A2333;
  --text:     #F0ECF4;
  --muted:    #A197B0;
  --faint:    #6F6580;
  --tape:     #FF7A45;   /* لون التوقيع — برتقالي الشريط */
  --tape-2:   #E65C28;
  --ok:       #5BC98F;
  --err:      #FF6B6B;

  --sans: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
}

*{ box-sizing: border-box; }

html, body{ margin:0; min-height:100%; }

body{
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  justify-content: center;
  padding: 40px 20px 32px;
  -webkit-font-smoothing: antialiased;
}

.page{ width:100%; max-width: 560px; }

/* ------------------------- الرأس ------------------------- */
.head{ margin-bottom: 26px; }

.logo{
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 6px;
  direction: ltr;
  text-align: right;
}
.logo-dot{ color: var(--tape); }

.lede{
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* --------------------- المشغّل (البكرات) --------------------- */
.deck{
  background: linear-gradient(160deg, var(--shell-2), var(--shell));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 20px 12px;
  margin-bottom: 14px;
}

.reels{ display:block; width:100%; height:auto; }

.reels .rim{
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
}
.reels .hub{ fill: var(--tape); }
.reels .spokes line{
  stroke: var(--line);
  stroke-width: 2;
  stroke-linecap: round;
}
.reels .tape{
  stroke: var(--faint);
  stroke-width: 3;
  stroke-linecap: round;
}

.reel{
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

/* اللف بيشتغل بس وقت التنزيل (فعل من المستخدم) */
.deck.working .reel{ animation: turn 2.4s linear infinite; }
.deck.working .reel#reelB{ animation-duration: 1.5s; }
.deck.working .rim{ stroke: var(--tape-2); }
.deck.working .tape{ stroke: var(--tape); }

.deck.done .hub{ fill: var(--ok); }
.deck.done .rim{ stroke: var(--ok); }

.deck.failed .hub{ fill: var(--err); }
.deck.failed .rim{ stroke: var(--err); }

@keyframes turn{ to{ transform: rotate(360deg); } }

.deck-status{
  margin: 12px 0 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
  min-height: 1.2em;
}
.deck.working .deck-status{ color: var(--tape); }
.deck.done    .deck-status{ color: var(--ok); }
.deck.failed  .deck-status{ color: var(--err); }

/* ------------------------- الإدخال ------------------------- */
.panel{
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}

.field{
  display: block;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px 12px;
  cursor: text;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field:focus-within{
  border-color: var(--tape-2);
  box-shadow: 0 0 0 3px rgba(255,122,69,.16);
}

.field-tag{
  display: block;
  font-size: 12px;
  color: var(--faint);
  margin-bottom: 2px;
}

.field input{
  width: 100%;
  background: none;
  border: 0;
  outline: 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 2px 0;
  direction: ltr;
  text-align: left;
}
.field input::placeholder{ color: var(--faint); }

/* أزرار الصيغة + زر التنزيل */
.controls{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.formats{ display: flex; gap: 6px; flex-wrap: wrap; }

.fmt{
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  background: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.fmt:hover{ color: var(--text); border-color: var(--faint); }
.fmt[aria-pressed="true"]{
  color: var(--tape);
  border-color: var(--tape-2);
  background: rgba(255,122,69,.10);
}

.grab{
  margin-inline-start: auto;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 15px;
  color: #21120B;
  background: var(--tape);
  border: 0;
  border-radius: var(--r-md);
  padding: 12px 22px;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
.grab:hover{ background: #FF8C5E; }
.grab:active{ transform: translateY(1px); }
.grab:disabled{
  background: #4A3A33;
  color: #9C8A80;
  cursor: not-allowed;
}

.fmt-note{
  margin: 12px 2px 0;
  color: var(--faint);
  font-size: 12.5px;
}

/* ------------------- النتيجة / الرسائل ------------------- */
.stage:empty{ display: none; }
.stage{ margin-top: 14px; }

.card{
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--shell);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px;
}

.card img{
  width: 104px;
  height: 68px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--ink);
}

.card .title{
  margin: 0 0 4px;
  font-weight: 500;
  font-size: 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .sub{
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.card .sub time{
  font-family: var(--mono);
  color: var(--text);
}

.note{
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--shell);
  padding: 13px 15px;
  font-size: 14px;
  margin: 0;
}
.note.bad{
  color: var(--err);
  border-color: rgba(255,107,107,.32);
  background: rgba(255,107,107,.07);
}
.note.good{
  color: var(--ok);
  border-color: rgba(91,201,143,.30);
  background: rgba(91,201,143,.07);
}
.note b{ color: var(--text); font-weight: 500; word-break: break-all; }

/* ------------------------- الذيل ------------------------- */
.foot{
  margin-top: 22px;
  text-align: center;
}
.foot p{
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}

/* ------------------------ إتاحة ------------------------ */
:focus-visible{
  outline: 2px solid var(--tape);
  outline-offset: 2px;
}

@media (max-width: 480px){
  body{ padding: 26px 16px 24px; }
  .controls{ gap: 8px; }
  .grab{ width: 100%; margin-inline-start: 0; }
  .card img{ width: 84px; height: 56px; }
}

@media (prefers-reduced-motion: reduce){
  .deck.working .reel{ animation: none; }
  *{ transition: none !important; }
}
