/* =====================================================================
   K697 — طبقة تجميل الهاب (hub-polish.css)
   تعمل فوق أي ثيم (v1–v8): تعتمد --accent و --ease فقط مع fallback
   العودة في ذلك: تختفي كل الحركة في prefers-reduced-motion
   ===================================================================== */

/* ------------------------------------------------------------------ */
/* 1) مجيء الصفحة — تشويقي متتابع: خلفية → شعار → سطر → بوابات          */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  @keyframes k7p-hub-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  @keyframes k7p-hub-rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes k7p-hub-gate {
    /* الشعار يدخل بذاخرة ثم يستقر */
    0%   { opacity: 0; transform: translateY(-14px) scale(0.985); filter: blur(6px); }
    100% { opacity: 1; transform: none; filter: blur(0); }
  }

  .stage   { animation: k7p-hub-fade 0.9s var(--ease, ease) both; }
  .mark    { animation: k7p-hub-gate 0.7s var(--ease, cubic-bezier(0.22, 1, 0.36, 1)) 0.15s both; }
  .mark__status { animation: k7p-hub-fade 0.6s var(--ease, ease) 0.55s both; }
  .k697-install-card { animation: k7p-hub-rise 0.55s var(--ease, ease) 0.45s both; }
  .colophon { animation: k7p-hub-fade 0.8s var(--ease, ease) 1s both; }

  .portals .portal {
    animation: k7p-hub-rise 0.6s var(--ease, cubic-bezier(0.22, 1, 0.36, 1)) both;
  }
  .portals .portal:nth-child(1) { animation-delay: 0.35s; }
  .portals .portal:nth-child(2) { animation-delay: 0.43s; }
  .portals .portal:nth-child(3) { animation-delay: 0.51s; }
}

/* ------------------------------------------------------------------ */
/* 2) كروت البوابات — كشاف ضوئي وسحب خفيف                               */
/* ------------------------------------------------------------------ */
:where(.portal) {
  /* مقبض 3D هادئ — أذكى من تضخيم صارخ */
  transition: background 0.3s var(--ease, ease), box-shadow 0.35s var(--ease, ease);
}

@media (prefers-reduced-motion: no-preference) {
  :where(.portal__glyph) {
    transition: transform 0.4s var(--ease, cubic-bezier(0.22, 1, 0.36, 1)), box-shadow 0.35s var(--ease, ease);
    will-change: transform;
  }
  :where(.portal:hover .portal__glyph) {
    transform: translateY(-3px);
  }
  :where(.portal:hover) {
    /* كشاف من الأعلى بلون كل بوابة */
    background-image: radial-gradient(
      ellipse 120% 60% at 50% -10%,
      color-mix(in srgb, var(--accent, #f0a030) 12%, transparent),
      transparent 65%
    );
  }
  /* شعاع يمسح خط التمييز الأفقي */
  :where(.portal__accent) {
    position: relative;
    overflow: hidden;
  }
  :where(.portal__accent)::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 22%;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent, #fff) 90%, #fff), transparent);
    opacity: 0;
    transform: translateX(-120%);
  }
  :where(.portal:hover .portal__accent)::after {
    animation: k7p-hub-sweep 1.1s var(--ease, ease) infinite;
    opacity: 1;
  }
  @keyframes k7p-hub-sweep {
    from { transform: translateX(120%); }
    to   { transform: translateX(-560%); }
  }
}

/* ------------------------------------------------------------------ */
/* 6) نبض البوابة (حصري) — مؤشر حي أسفل كل كارت                         */
/* ------------------------------------------------------------------ */
.portal__pulse {
  margin-top: 0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid color-mix(in srgb, var(--accent, #f0a030) 25%, transparent);
  background: color-mix(in srgb, var(--accent, #f0a030) 7%, rgba(0, 0, 0, 0.25));
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--accent, #f0a030) 82%, #fff);
}
.portal__pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #f0a030);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #f0a030) 55%, transparent);
  animation: k697-pulse-dot 2.2s ease-out infinite;
}
@keyframes k697-pulse-dot {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent, #f0a030) 55%, transparent); }
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.portal__pulse-text { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .portal__pulse-dot { animation: none; }
}

/* ------------------------------------------------------------------ */
/* 7) تفاصيل دقيقة — نصوص ذرية                                          */
/* ------------------------------------------------------------------ */
:where(.portal__meta) {
  /* أوضح قليلاً من الشفاف الحالي دون كسر طابع الشفافية */
  opacity: 0.62;
  transition: opacity 0.3s var(--ease, ease);
}
:where(.portal:hover .portal__meta) { opacity: 0.85; }

:where(.portal:focus-visible) {
  /* لوحة مفاتيح: حلقة واضحة دائمة */
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent, #f0a030) 70%, transparent);
}

/* ------------------------------------------------------------------ */
/* 4) شعار التثبيت PWA — أنعم وأثقل حضورًا                              */
/* ------------------------------------------------------------------ */
:where(.k697-install-card) {
  transition: box-shadow 0.3s var(--ease, ease), border-color 0.3s var(--ease, ease), background 0.3s var(--ease, ease);
}
:where(.k697-install-cta):hover {
  filter: brightness(1.05);
}
@media (prefers-reduced-motion: no-preference) {
  :where(.k697-install-cta) { transition: transform 0.2s var(--ease, ease), filter 0.2s var(--ease, ease); }
  :where(.k697-install-cta):active { transform: scale(0.98); }
}

/* ------------------------------------------------------------------ */
/* 5) أمان حركي: منع استهلاك الرسوميات على الأجهزة الضعيفة            */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .stage, .mark, .mark__status, .k697-install-card, .colophon,
  .portals .portal, .portal__accent::after, .k697-recent { animation: none !important; }
}

/* ------------------------------------------------------------------ */
/* 8) «تابع من حيث توقفت» — رجوع سريع لآخر 3 صفحات (W18)               */
/*    شريط رقيق بين الشعار والبوابات؛ يظهر فقط لو فيه سجل سابق         */
/* ------------------------------------------------------------------ */
.k697-recent {
  width: 100%;
  max-width: 1020px;
  align-self: stretch;
  display: grid;
  gap: 7px;
  /* يلتصق بالبوابات بدل أن يأخذ فراغ gate الكامل (2–3rem) */
  margin-block: calc(-1 * clamp(0.6rem, 1.6vw, 1rem));
  animation: k7p-hub-fade 0.5s var(--ease, ease) both;
}
.k697-recent[hidden] { display: none; }

/* عنوان الثيم فوق البوابات (v2/v9) كان سيتصادم مع الشريط — يُخفى عند ظهوره */
.k697-recent:not([hidden]) ~ .portals::before { content: none; }

.k697-recent__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-inline: 2px;
}

.k697-recent__kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.66rem;
  font-weight: 700;
  opacity: 0.45;
}
.k697-recent__kicker svg { width: 13px; height: 13px; }

.k697-recent__clear {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.62rem;
  opacity: 0.35;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s var(--ease, ease), background 0.2s var(--ease, ease);
}
.k697-recent__clear:hover,
.k697-recent__clear:focus-visible {
  opacity: 0.9;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.k697-recent__list {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin: 0;
  padding: 1px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.k697-recent__list::-webkit-scrollbar { display: none; }
.k697-recent__list > li { flex: 0 1 auto; min-width: 0; }

.k697-recent__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  max-width: 100%;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  background: color-mix(in srgb, currentColor 6%, transparent);
  color: inherit;
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 600;
  transition: border-color 0.25s var(--ease, ease), background 0.25s var(--ease, ease),
              transform 0.25s var(--ease, ease), box-shadow 0.25s var(--ease, ease);
}

.k697-recent__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--k7p-dot, currentColor);
  box-shadow: 0 0 9px color-mix(in srgb, var(--k7p-dot, currentColor) 60%, transparent);
}
.k697-recent__item[data-sys="canteen"]   { --k7p-dot: var(--accent-canteen, #c8a050); }
.k697-recent__item[data-sys="mess"]      { --k7p-dot: var(--accent-mess, #7fd8b2); }
.k697-recent__item[data-sys="battalion"] { --k7p-dot: var(--accent-battalion, #9db8c9); }
.k697-recent__item[data-sys="console"]   { --k7p-dot: var(--hud, var(--accent, #e8c777)); }

.k697-recent__lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.k697-recent__sys {
  flex: 0 0 auto;
  font-size: 0.58rem;
  font-weight: 500;
  opacity: 0.42;
}
.k697-recent__sys::before {
  content: "·";
  margin-inline-end: 4px;
  opacity: 0.7;
}
.k697-recent__ago {
  flex: 0 0 auto;
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.45;
}

@media (prefers-reduced-motion: no-preference) {
  .k697-recent__item:hover,
  .k697-recent__item:focus-visible {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--k7p-dot, currentColor) 55%, transparent);
    background: color-mix(in srgb, var(--k7p-dot, currentColor) 12%, transparent);
    box-shadow: 0 6px 18px -12px color-mix(in srgb, var(--k7p-dot, currentColor) 70%, transparent);
  }
}
.k697-recent__item:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--k7p-dot, currentColor) 70%, transparent);
  outline-offset: 2px;
}

@media (max-width: 720px) {
  .k697-recent {
    gap: 6px;
    margin-block: calc(-1 * clamp(0.5rem, 1.6vw, 0.85rem));
  }
  .k697-recent__item { padding: 6px 11px; font-size: 0.7rem; gap: 6px; }

  .tenant-pick__title {
    text-align: center;
  }
  .portals {
    gap: 10px !important;
  }
  .portal {
    min-height: 0;
  }
}
@media (max-width: 480px) {
  .k697-recent__ago { display: none; }
  .mark__line,
  .mark__status {
    font-size: 0.8rem;
    line-height: 1.5;
    padding-inline: 8px;
  }
}
