/* صفحة تنزيل Bismaya BBM — الهوية مأخوذة من شاشة الدخول في تطبيق الإدارة:
   lib/presentation/screens/login_screen.dart + login_screen_widgets.dart + widgets/bismaya_photo_bg.dart.
   تصميم أحادي المظهر عن قصد (صورة المجمّع الداكنة كشاشة الدخول) — كل الألوان مرسومة صراحةً.

   التخطيط (قرار المالك 2026-10-28):
   - موبايل (< 600px): الصفحة كلها في شاشة واحدة بلا تمرير — كل بطاقة صف مضغوط (أيقونة | نص | زر).
   - تابلت (600–1099px): بطاقات عمودية في عمودين.
   - كمبيوتر (≥ 1100px): أربع بطاقات عمودية في صف واحد. */

@font-face {
  font-family: 'HacenBeirut';
  src: url('assets/HacenBeirut.ttf') format('truetype');
  font-display: swap;
}

/* أيقونات العلامات (Android / Windows / Apple) من خط Font Awesome Brands الموجود أصلاً في المشروع
   (font_awesome_flutter) — بلا مكتبات ولا روابط خارجية. */
@font-face {
  font-family: 'FontAwesomeBrands';
  src: url('assets/fa-brands-400.otf') format('opentype');
  font-display: block;
}

:root {
  /* login_screen.dart */
  --gold: #ddab6a;               /* _accentGold / _loginGold */
  --ink: #23180e;                /* _loginInk */
  --btn-top: #e7b676;            /* تدرّج زر الدخول */
  --btn-mid: #cf9f66;
  --btn-bottom: #c2915b;
  --page-bg: #2e2520;            /* Scaffold backgroundColor / deepBrown */
  --scrim: rgba(0, 0, 0, 0.35);  /* BismayaPhotoBackground.scrim = 0x59000000 */

  /* بطاقة الدخول الزجاجية */
  --glass-fill: rgba(255, 255, 255, 0.118);   /* white.withAlpha(30) */
  --glass-border: rgba(255, 255, 255, 0.314); /* white.withAlpha(80) */
  --glass-shadow: 0 8px 32px 2px rgba(0, 0, 0, 0.39); /* black.withAlpha(100), blur 32, spread 2 */
  --field-fill: rgba(255, 255, 255, 0.078);   /* white.withAlpha(20) */
  --field-border: rgba(255, 255, 255, 0.275); /* white.withAlpha(70) */

  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.8);
  --text-dim: rgba(255, 255, 255, 0.64);

  /* AppSpacing */
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;

  --font: 'HacenBeirut', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── خلفية صورة المجمّع: طولية على الموبايل، عرضية من 600px (نقاط كسر Responsive) ── */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: var(--page-bg);
  background-image: linear-gradient(var(--scrim), var(--scrim)), url('assets/photo_bg_phone.jpg');
  background-size: cover;
  background-position: center top;
}

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), clamp(12px, 3vh, 28px)) var(--sp-lg)
    max(env(safe-area-inset-bottom), var(--sp-md));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(12px, 2.4vh, 22px);
}

/* ── الرأس: شعار + عنوان + الخط الذهبي القصير (_logoBlock) ── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(4px, 1vh, 10px);
  animation: rise 0.7s cubic-bezier(0.33, 1, 0.68, 1) both;
}

.hero__logo {
  /* يتقلّص مع ارتفاع الشاشة أيضاً حتى تتسع الصفحة كلها في شاشة الموبايل */
  width: clamp(64px, min(22vw, 13vh), 168px);
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
}

.hero__brand {
  margin: 0;
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.hero__title {
  margin: 0;
  font-size: clamp(19px, 4.2vw, 30px);
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-wrap: balance;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}

.hero__rule {
  display: block;
  width: 48px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold);
}

.hero__lead {
  margin: 0;
  max-width: 34em;
  color: var(--text-soft);
  font-size: clamp(13px, 2.4vw, 17px);
  text-wrap: balance;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ══ البطاقات — موبايل أولاً: صف مضغوط (أيقونة | عنوان ووصف | زر) ══ */
.cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'icon title  action'
    'icon desc   action'
    'icon meta   action';
  align-items: center;
  column-gap: var(--sp-md);
  row-gap: 2px;
  padding: 11px 12px;
  border-radius: 16px;
  background: var(--glass-fill);
  border: 1.2px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: rise 0.7s 0.2s cubic-bezier(0.33, 1, 0.68, 1) both;
}

.card:nth-child(2) { animation-delay: 0.28s; }
.card:nth-child(3) { animation-delay: 0.36s; }
.card:nth-child(4) { animation-delay: 0.44s; }

.card__icon {
  grid-area: icon;
  align-self: center;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(221, 171, 106, 0.14);
  border: 1px solid rgba(221, 171, 106, 0.45);
}

.brand-glyph {
  font-family: 'FontAwesomeBrands';
  font-style: normal;
  font-weight: 400;
  font-size: 20px;
  line-height: 1;
  color: var(--gold);
}

.web-glyph {
  width: 22px;
  height: 22px;
  stroke: var(--gold);
}

.card__title {
  grid-area: title;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.card__desc {
  grid-area: desc;
  margin: 0;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.45;
}

/* اسم النطاق تحت وصف بطاقة الوصول المباشر — على الشاشات الأوسع فقط */
.card__domain {
  display: none;
  margin: 0;
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: right;
}

/* معلومات الإصدار — على الموبايل سطر واحد صغير (الإصدار · الحجم · التاريخ) */
.card__meta {
  grid-area: meta;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  color: var(--text-dim);
  font-size: 11.5px;
}

.card__meta[hidden],
.card__notes[hidden],
.footer__version[hidden] {
  display: none;
}

.meta-row {
  display: flex;
  gap: 4px;
}

.meta-row dt {
  display: none;
}

.meta-row dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.meta-row--hash {
  display: none;
}

.card__notes {
  display: none;
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}

.card__action {
  grid-area: action;
}

/* ── زر ذهبي (_goldButton) — مضغوط على الموبايل ── */
.btn-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  min-width: 84px;
  padding-inline: 12px 5px;
  border-radius: 19px;
  background: linear-gradient(180deg, var(--btn-top), var(--btn-mid), var(--btn-bottom));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  text-decoration: none;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn-gold:hover {
  filter: brightness(1.06);
}

.btn-gold:active {
  transform: translateY(1px);
}

.btn-gold:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.btn-gold__disc {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
}

.btn-gold__disc svg {
  width: 16px;
  height: 16px;
  stroke: var(--btn-top);
}

/* «قريباً» — بلا أي رابط */
.soon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  min-width: 84px;
  padding: 0 14px;
  border-radius: 19px;
  border: 1.5px dashed rgba(221, 171, 106, 0.6);
  background: rgba(35, 24, 14, 0.28);
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

/* ── التذييل: سطر واحد على الموبايل ── */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
}

.footer p {
  margin: 0;
}

.footer__brand {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.footer__version {
  font-variant-numeric: tabular-nums;
}

/* شاشات موبايل قصيرة جداً (مثل iPhone SE): سطر «Bismaya BBM» مكرَّر داخل الشعار نفسه فيُخفى */
@media (max-width: 599px) and (max-height: 700px) {
  .hero__brand {
    display: none;
  }

  .card__desc {
    font-size: 12px;
  }
}

/* ══ تابلت/كمبيوتر (≥ 600px): البطاقات العمودية كبطاقة الدخول ══ */
@media (min-width: 600px) {
  .backdrop {
    background-image: linear-gradient(var(--scrim), var(--scrim)), url('assets/photo_bg_wide.jpg');
    background-position: center;
  }

  .page {
    justify-content: flex-start;
    padding-top: max(5vh, var(--sp-xl));
    padding-bottom: var(--sp-xl);
    gap: clamp(28px, 5vh, 48px);
  }

  .hero {
    gap: var(--sp-md);
  }

  .hero__logo {
    width: clamp(104px, 22vw, 168px);
  }

  .hero__brand {
    font-size: 15px;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-lg);
    max-width: 760px;
  }

  .card {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* لا يرث توسيط صف الموبايل — النص يميناً والزر بعرض البطاقة */
    gap: var(--sp-md);
    padding: 28px var(--sp-xl) var(--sp-xl);
    border-radius: 20px;
  }

  .card__icon {
    align-self: flex-start;
    width: 60px;
    height: 60px;
  }

  .brand-glyph {
    font-size: 28px;
  }

  .web-glyph {
    width: 30px;
    height: 30px;
  }

  .card__title {
    font-size: 20px;
    line-height: 1.4;
  }

  .card__desc {
    font-size: 15px;
    line-height: 1.6;
    min-height: 3.2em; /* يحجز سطرين حتى تتطابق حواف البطاقات المتجاورة */
  }

  .card__domain {
    display: block;
  }

  /* معلومات الإصدار — حقول زجاجية كحقول الدخول */
  .card__meta {
    display: grid;
    gap: 6px;
    padding: var(--sp-sm) var(--sp-md);
    border-radius: 12px;
    background: var(--field-fill);
    border: 1px solid var(--field-border);
    color: var(--text);
    font-size: 14px;
  }

  .meta-row {
    justify-content: space-between;
    align-items: baseline;
    gap: var(--sp-md);
  }

  .meta-row dt {
    display: block;
    color: var(--text-dim);
  }

  .meta-row dd {
    text-align: start;
  }

  .meta-row--hash {
    display: flex;
  }

  .meta-row--hash dd {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
    font-weight: 400;
    direction: ltr;
    color: var(--text-soft);
  }

  .card__notes {
    display: block;
  }

  .card__notes[hidden] {
    display: none;
  }

  .card__action {
    margin-top: auto;
    padding-top: var(--sp-sm);
  }

  /* زر الدخول الذهبي بمقاسه الكامل: ارتفاع 56، دائرة داكنة في الطرف */
  .btn-gold {
    position: relative;
    display: flex;
    width: 100%;
    height: 56px;
    padding: 0 64px;
    border-radius: 28px;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.35);
    font-size: 18px;
  }

  .btn-gold__disc {
    position: absolute;
    inset-inline-end: 8px;
    top: 8px;
    bottom: 8px;
    width: 40px;
    height: auto;
  }

  .btn-gold__disc svg {
    width: 22px;
    height: 22px;
  }

  .soon {
    display: flex;
    width: 100%;
    height: 56px;
    border-radius: 28px;
    font-size: 18px;
    letter-spacing: 0.02em;
  }

  .footer {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding-top: var(--sp-lg);
    font-size: 14px;
  }

  .footer__brand {
    letter-spacing: 0.12em;
  }
}

@media (min-width: 1100px) {
  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: none;
    gap: 20px;
  }

  .card {
    padding-inline: 20px;
  }
}

/* ══ صفحة دليل التثبيت على ويندوز (windows.html) — عمود قراءة واحد بلوحات زجاجية ══ */
.page--guide {
  max-width: 760px;
  justify-content: flex-start;
  padding-top: max(env(safe-area-inset-top), var(--sp-lg));
  padding-bottom: max(env(safe-area-inset-bottom), var(--sp-lg));
}

.guide-head {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  text-align: center;
}

.guide-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  background: rgba(35, 24, 14, 0.35);
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.guide-back:hover {
  background: rgba(35, 24, 14, 0.55);
}

/* نفس مقاس شعار صفحة التحميل (.hero__logo) — طلب المالك 2026-10-29 */
.guide-head__logo {
  width: clamp(64px, min(22vw, 13vh), 168px);
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
}

.guide-head__title {
  margin: 0;
  font-size: clamp(21px, 4.6vw, 30px);
  font-weight: 800;
  line-height: 1.35;
  text-wrap: balance;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}

.guide-head__lead {
  margin: 0;
  max-width: 36em;
  color: var(--text-soft);
  font-size: clamp(14px, 2.6vw, 16.5px);
  line-height: 1.75;
  text-wrap: pretty;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.guide {
  display: grid;
  gap: var(--sp-md);
}

.guide-panel {
  padding: var(--sp-lg) var(--sp-lg) 18px;
  border-radius: 16px;
  background: rgba(35, 24, 14, 0.42);
  border: 1.2px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.guide-panel__title {
  margin: 0 0 var(--sp-md);
  color: var(--gold);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.4;
}

.guide-list,
.guide-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  font-size: 15px;
  line-height: 1.8;
}

.guide-list li {
  position: relative;
  padding-inline-start: 18px;
}

.guide-list li::before {
  content: '';
  position: absolute;
  inset-inline-start: 2px;
  top: 0.78em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
}

/* خطوات مرقّمة فعلاً (تسلسل حقيقي): رقم ذهبي داخل دائرة داكنة كدائرة الزر الذهبي */
.guide-steps {
  counter-reset: step;
}

.guide-steps li {
  position: relative;
  counter-increment: step;
  min-height: 30px;
  padding-inline-start: 42px;
}

.guide-steps li::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 1px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  border: 1.5px solid var(--gold);
  color: var(--btn-top);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.guide-list b,
.guide-steps b,
.guide-text b {
  color: var(--text);
  font-weight: 800;
}

.guide-alt {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 14px;
}

.guide-en {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-family: 'Segoe UI', Tahoma, sans-serif;
  font-size: 12.5px;
  text-align: right;
}

.guide-link {
  color: var(--gold);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-link:focus-visible,
.guide-back:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.guide-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-soft);
}

.guide-cta {
  display: flex;
  justify-content: center;
  padding-top: var(--sp-sm);
}

.guide-cta .btn-gold {
  width: 100%;
  max-width: 420px;
  height: 52px;
  padding-inline: 20px 8px;
  border-radius: 26px;
  font-size: 16px;
}

.guide-cta .btn-gold__disc {
  width: 38px;
  height: 38px;
}

@media (min-width: 600px) {
  .page--guide {
    gap: 28px;
  }

  .guide-head__logo {
    width: clamp(104px, 22vw, 168px);
  }

  .guide-panel {
    padding: 22px var(--sp-xl) var(--sp-xl);
    border-radius: 20px;
  }

  .guide-panel__title {
    font-size: 20px;
  }

  .guide-list,
  .guide-steps,
  .guide-text {
    font-size: 16px;
  }

  .guide-cta .btn-gold {
    position: relative;
    height: 56px;
    padding: 0 64px;
    border-radius: 28px;
    font-size: 18px;
  }

  .guide-cta .btn-gold__disc {
    position: absolute;
    inset-inline-end: 8px;
    top: 8px;
    bottom: 8px;
    width: 40px;
    height: auto;
  }
}

/* انزلاق خفيف فقط — المحتوى ظاهر دائماً (بلا opacity: 0)، فلا تظهر الصفحة فارغة في معاينة رابط
   أو التقاط مبكّر أو جهاز بطيء. */
@keyframes rise {
  from {
    transform: translateY(14px);
  }
  to {
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero,
  .card {
    animation: none;
  }

  .btn-gold {
    transition: none;
  }
}
