/* ============================================================================
   رِماية — landing · قسم «اعرف أي عرض يبيع» (لوحة التحليلات)
   نسخة ضوئية مصغّرة عن لوحة التحليلات الحقيقية، مبنية بـCSS grid صرف:
   لا رسم على canvas ولا تكبير بـtransform. البادئة db-.
   التوكنات: الحبر والعناوين من landing.css، والألوان الضوئية داخل الإطار
   مكتوبة صريحةً (لوحة المنتج ليست على الصفحة الداكنة).
   ========================================================================== */

.db {
  position: relative;
  padding-block: var(--sec-y);
  overflow: clip;
}

/* ------------------------------------------------------------- رأس القسم --- */
.db-head {
  margin-block-end: 56px;
  text-align: center;
}

.db-title {
  font-size: clamp(32px, 4.2vw, 54px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--white);
}

.db-sub {
  margin-block-start: 16px;
  margin-inline: auto;
  max-width: 46ch;
  font-size: clamp(16px, 1.4vw, 18px);
  line-height: 1.8;
  color: var(--text-2);
}

/* ----------------------------------------------------------- إطار النافذة --- */
.db-stage {
  width: min(100%, 1160px);
  margin-inline: auto;
}

.db-window {
  border-radius: 20px;
  background: #f6f5fb;
  overflow: hidden;
  box-shadow:
    0 60px 120px -50px rgba(92, 23, 253, 0.5),
    0 40px 90px -30px rgba(8, 0, 30, 0.75),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* داخلها لوحة ضوئية — نص صريح لا يرث شفافية الصفحة الداكنة. */
.db-app,
.db-app * {
  box-sizing: border-box;
}

.db-app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  background: #f6f5fb;
  color: #1b1530;
  font-size: 13px;
  line-height: 1.55;
}

/* ----------------------------------------------------------- الشريط الجانبي */
.db-side {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 14px;
  background: #fbfaff;
  border-inline-end: 1px solid #ece9f5;
}

.db-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-inline-start: 10px;
}

.db-brand-ico {
  display: block;
  width: 26px;
  height: 26px;
  flex: none;
}

.db-brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #1b1530;
}

.db-nav {
  display: grid;
  gap: 2px;
}

.db-nav__it {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: #6b6680;
}

.db-nav__it.is-on {
  background: rgba(92, 23, 253, 0.09);
  color: #5c17fd;
  font-weight: 600;
}

.db-nav__it.is-on::before {
  content: "";
  position: absolute;
  inset-inline-start: -9px;
  inset-block: 8px;
  width: 3px;
  border-radius: 3px;
  background: #5c17fd;
}

/* --------------------------------------------------------- العمود الرئيسي */
.db-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.db-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  background: #ffffff;
  border-block-end: 1px solid #ece9f5;
}

.db-top-title {
  font-size: 15px;
  font-weight: 600;
  color: #1b1530;
  white-space: nowrap;
}

.db-seg {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: auto;
  padding: 3px;
  border-radius: 999px;
  background: #f2f0f7;
}

.db-seg > span {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: #6b6680;
  white-space: nowrap;
}

.db-seg > span.is-on {
  background: #ffffff;
  color: #1b1530;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(51, 23, 97, 0.12);
}

.db-store {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 3px 4px 3px 11px;
  border: 1px solid #ece9f5;
  border-radius: 999px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 500;
  color: #1b1530;
}

.db-mono {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ede6ff;
  color: #5c17fd;
  font-size: 11px;
  font-weight: 700;
}

.db-body {
  display: grid;
  gap: 16px;
  align-content: start;
  padding: 20px;
  min-width: 0;
}

/* ------------------------------------------------------------------ الأيقونات */
.db-i {
  display: block;
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------- بلاطات KPI */
.db-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.db-kpi {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 20px;
  border: 1px solid #ece9f5;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(51, 23, 97, 0.04);
}

.db-kpi-ico {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f2f0f7;
  color: #5c17fd;
}

.db-kpi-ico .db-i {
  width: 18px;
  height: 18px;
}

.db-kpi-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  color: #6b6680;
}

.db-kpi-val {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: #1b1530;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.db-cur {
  font-style: normal;
  font-size: 13px;
  font-weight: 500;
  color: #6b6680;
}

.db-pct {
  font-style: normal;
  font-size: 18px;
  font-weight: 600;
  color: #6b6680;
}

.db-kpi-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-block-start: 2px;
  min-height: 22px;
}

.db-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e6f4ee;
  color: #11795a;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.db-delta .db-i {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}

.db-spark {
  display: block;
  width: 84px;
  height: 26px;
  margin-inline-start: auto;
  flex: none;
}

.db-spark-line {
  fill: none;
  stroke: #5c17fd;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.5;
}

/* -------------------------------------------------------------- بطاقات عامة */
.db-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid #ece9f5;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(51, 23, 97, 0.04);
}

.db-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #1b1530;
}

.db-grid2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  min-width: 0;
}

/* ------------------------------------------------------------------ الرسم */
/* الرسم سلسلة زمنية تُقرأ من اليسار إلى اليمين (كالمخطط الحقيقي)، ومحور
   القيم على يساره — فيزيائيًا، لا منطقيًا، حتى لا ينقلب الترتيب. */
.db-plot {
  position: relative;
  margin-block-start: 18px;
  padding-left: 50px;
}

.db-yaxis {
  position: absolute;
  inset-block: 0;
  left: 0;
  width: 42px;
}

.db-yaxis > span {
  position: absolute;
  left: 0;
  font-size: 12px;
  line-height: 1;
  color: #6b6680;
  font-variant-numeric: tabular-nums;
  transform: translateY(-50%);
}

.db-yaxis > span:nth-child(1) {
  top: 0.5%;
}

.db-yaxis > span:nth-child(2) {
  top: 33.34%;
}

.db-yaxis > span:nth-child(3) {
  top: 66.67%;
}

.db-yaxis > span:nth-child(4) {
  top: 99.5%;
}

.db-canvas {
  position: relative;
}

/* الارتفاع من نسبة الرسم نفسه (viewBox 560×200) — بلا min-height، لأن
   min-height مع aspect-ratio يشتقّ العرض فينفلت الرسم من البطاقة. */
.db-chart {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 560 / 200;
}

.db-gridline {
  fill: none;
  stroke: #f0eef7;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.db-line {
  fill: none;
  stroke: #5c17fd;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.db-fill {
  fill: url(#dbFill);
  stroke: none;
}

.db-dot {
  fill: #5c17fd;
  stroke: #ffffff;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.db-tipwrap {
  position: absolute;
  top: 28.88%;
  left: 98.57%;
  display: block;
}

.db-tip {
  position: absolute;
  inset-block-end: 0;
  right: 10px;
  padding: 5px 10px;
  border-radius: 9px;
  background: #1b1530;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 24px -12px rgba(27, 21, 48, 0.7);
  transform: translateY(-12px);
}

.db-xaxis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-block-start: 10px;
  padding-left: 50px;
  direction: ltr;
  font-size: 12px;
  line-height: 1.5;
  color: #6b6680;
}

.db-xaxis > span {
  unicode-bidi: isolate;
  white-space: nowrap;
}

/* ------------------------------------------------------------ حسب نوع العرض */
.db-types {
  display: grid;
  gap: 15px;
  margin-block-start: 18px;
  padding: 0;
  list-style: none;
}

.db-type-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-block-end: 7px;
}

.db-type-label {
  font-size: 13px;
  font-weight: 500;
  color: #1b1530;
}

.db-type-val {
  font-size: 13px;
  font-weight: 600;
  color: #6b6680;
  font-variant-numeric: tabular-nums;
}

.db-bar,
.db-mini {
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: #f2f0f7;
}

.db-bar {
  height: 8px;
}

.db-mini {
  height: 6px;
  max-width: 230px;
}

.db-grow {
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5c17fd, #bb50f8);
  transform-origin: 100% 50%;
}

/* ------------------------------------------------------------- أفضل العروض */
.db-table {
  display: grid;
  margin-block-start: 14px;
}

.db-trow {
  display: grid;
  grid-template-columns: minmax(0, 2.3fr) 74px 74px 74px 74px 92px;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
  border-block-start: 1px solid #ece9f5;
}

.db-trow--head {
  padding-block: 2px 8px;
  border-block-start: 0;
  font-size: 12px;
  font-weight: 500;
  color: #6b6680;
}

.db-tname {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  color: #1b1530;
}

.db-tcell {
  display: flex;
}

.db-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #e6f4ee;
  color: #11795a;
  font-size: 12px;
  font-style: normal;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.db-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.db-tn {
  font-size: 13px;
  color: #55516b;
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.db-tn--strong {
  font-weight: 600;
  color: #1b1530;
}

.db-curm {
  display: none;
  font-style: normal;
  font-size: 12px;
  font-weight: 400;
  color: #6b6680;
}

/* --------------------------------------------------------------- أسفل النافذة */
.db-cap {
  margin-block-start: 18px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-3);
}

.db-points {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 34px;
  margin-block-start: 24px;
  padding: 0;
  list-style: none;
}

.db-points > li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.db-point-ico {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 9px;
  background: rgba(92, 23, 253, 0.16);
  color: #c9a8ff;
}

.db-point-ico .db-i {
  width: 17px;
  height: 17px;
}

/* ============================================================================
   الحركة — لا تُشعل إلا بعد تأكيد JS (html.js)، وبلا JS يظهر الحال النهائي.
   ========================================================================== */
.js .db-line {
  stroke-dashoffset: 1;
}

.js .db-fill,
.js .db-dot,
.js .db-tipwrap {
  opacity: 0;
}

.js .db-grow {
  transform: scaleX(0);
}

.js .db-trow {
  opacity: 0;
  transform: translateY(8px);
}

.db.is-in .db-line {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1.5s var(--ease);
}

.db.is-in .db-fill {
  opacity: 1;
  transition: opacity 0.9s 0.5s var(--ease);
}

.db.is-in .db-dot {
  opacity: 1;
  transition: opacity 0.3s 1.15s linear;
}

.db.is-in .db-tipwrap {
  opacity: 1;
  transition: opacity 0.45s 1.15s var(--ease);
}

.db.is-in .db-grow {
  transform: scaleX(1);
  transition: transform 0.9s var(--ease);
}

.db.is-in .db-trow {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.55s var(--ease),
    transform 0.55s var(--ease);
}

/* تتابع خفيف: أشرطة الأنواع وصفوف الجدول */
.db.is-in .db-types > li:nth-child(1) .db-grow {
  transition-delay: 0.1s;
}

.db.is-in .db-types > li:nth-child(2) .db-grow {
  transition-delay: 0.19s;
}

.db.is-in .db-types > li:nth-child(3) .db-grow {
  transition-delay: 0.28s;
}

.db.is-in .db-types > li:nth-child(4) .db-grow {
  transition-delay: 0.37s;
}

.db.is-in .db-table > .db-trow:nth-child(2) {
  transition-delay: 0.2s;
}

.db.is-in .db-table > .db-trow:nth-child(3) {
  transition-delay: 0.3s;
}

.db.is-in .db-table > .db-trow:nth-child(4) {
  transition-delay: 0.4s;
}

.db.is-in .db-table > .db-trow:nth-child(5) {
  transition-delay: 0.5s;
}

.db.is-in .db-table > .db-trow:nth-child(2) .db-grow {
  transition-delay: 0.55s;
}

.db.is-in .db-table > .db-trow:nth-child(3) .db-grow {
  transition-delay: 0.65s;
}

.db.is-in .db-table > .db-trow:nth-child(4) .db-grow {
  transition-delay: 0.75s;
}

.db.is-in .db-table > .db-trow:nth-child(5) .db-grow {
  transition-delay: 0.85s;
}

/* ============================================================================
   التجاوب
   ========================================================================== */
@media (max-width: 1023px) {
  .db-side {
    display: none;
  }

  .db-app {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .db-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .db-grid2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The window's own box-shadow is a glow wide enough to read as a lighter band
   behind a full-width card on a phone. The section carries one editorial glow
   instead, and the window keeps a tight lift. */
.db-stage {
  position: relative;
}

.db-stage::before {
  content: "";
  position: absolute;
  inset: -6% 0 auto;
  block-size: 58%;
  background: radial-gradient(58% 60% at 50% 32%, rgba(92, 23, 253, 0.2), transparent 72%);
  pointer-events: none;
}

.db-window {
  position: relative;
}

@media (max-width: 760px) {
  .db {
    padding-block-end: 56px;
  }

  .db-head {
    margin-block-end: 36px;
  }

  .db-window {
    box-shadow:
      0 24px 50px -34px rgba(8, 0, 30, 0.9),
      0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  .db-points {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 8px;
    margin-block-start: 22px;
  }
}

@media (max-width: 700px) {
  .db-top {
    flex-wrap: wrap;
    gap: 10px;
  }

  .db-seg {
    order: 3;
    width: 100%;
    margin-inline-start: 0;
    justify-content: space-between;
  }

  .db-seg > span {
    flex: 1;
    text-align: center;
  }

  .db-store {
    margin-inline-start: auto;
  }

  .db-xaxis > span:nth-child(2),
  .db-xaxis > span:nth-child(4) {
    display: none;
  }
}

@media (max-width: 620px) {
  .db-top {
    padding: 12px 14px;
  }

  .db-body {
    gap: 12px;
    padding: 14px;
  }

  .db-kpis,
  .db-grid2 {
    gap: 12px;
  }

  .db-kpi,
  .db-card {
    padding: 14px;
  }

  .db-plot {
    padding-left: 44px;
  }

  .db-yaxis {
    width: 38px;
  }

  .db-xaxis {
    padding-left: 44px;
  }

  /* الرسم أطول قليلًا على الهاتف: المستطيل 2.8:1 يصير شريطًا رقيقًا. */
  .db-chart {
    height: 132px;
  }

  /* التلميح يجانب النقطة (لا فوقها) حتى لا يخرج من البطاقة الضيّقة. */
  .db-tip {
    inset-block-end: auto;
    top: 0;
    right: 12px;
    transform: translateY(-50%);
  }

  /* الجدول يصير قائمة مكدّسة: الاسم + شريط مصغّر + المبيعات */
  .db-trow {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding-block: 14px;
  }

  .db-trow--head {
    display: none;
  }

  .db-trow > .db-tcell,
  .db-trow > .db-tn:nth-child(3),
  .db-trow > .db-tn:nth-child(4),
  .db-trow > .db-tn:nth-child(5) {
    display: none;
  }

  .db-mini {
    max-width: none;
  }

  .db-tn--strong {
    font-size: 14px;
    text-align: end;
  }

  .db-curm {
    display: inline;
    margin-inline-start: 3px;
  }
}

@media (max-width: 420px) {
  .db-kpi-val {
    font-size: 20px;
  }

  .db-pct {
    font-size: 15px;
  }

  .db-spark {
    display: none;
  }
}

@media (max-width: 360px) {
  .db-kpi {
    padding: 12px;
  }

  .db-kpi-val {
    font-size: 18px;
  }

  .db-cur {
    font-size: 12px;
  }

  .db-bar {
    height: 7px;
  }
}

/* ------------------------------------------------------- تقليل الحركة ---- */
@media (prefers-reduced-motion: reduce) {
  .db *,
  .db *::before,
  .db *::after {
    transition: none !important;
    animation: none !important;
  }

  .js .db-line {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
  }

  .js .db-fill,
  .js .db-dot,
  .js .db-tipwrap,
  .js .db-trow {
    opacity: 1;
    transform: none;
  }

  .js .db-grow {
    transform: none;
  }
}
