/* نظام التصميم — هوية بادل أوتلت (البند 6).
   الخط: IBM Plex Sans Arabic Bold. الألوان من ملف الهوية.
   القياس كله بوحدة rem مربوطة بحجم الشاشة: 1rem = 20px على شاشة طولية 1080×1920. */

@font-face {
  font-family: 'Plex Arabic';
  src: url('/fonts/IBMPlexSansArabic-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: block;
}
@font-face {
  font-family: 'Plex Arabic';
  src: url('/fonts/IBMPlexSansArabic-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  --purple: #6952eb;
  --purple-dark: #4f3bc9;
  --purple-soft: #f1eeff;
  --purple-line: #dcd6fb;
  --green: #a9dd45;
  --green-dark: #5d8a0d;
  --teal: #00a79d;
  --black: #141414;
  --grey: #6b6b76;
  --line: #e8e7ee;
  --white: #ffffff;
  --radius: 1.6rem;
  --pill: 999px;
  --shadow: 0 0.6rem 2rem rgba(105, 82, 235, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: min(1.8519vw, 1.0417vh);
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;
  background: var(--white);
  color: var(--black);
  font-family: 'Plex Arabic', system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

#app {
  position: relative;
  width: 54rem;
  height: 96rem;
  margin: 0 auto;
  overflow: hidden;
  background: var(--white);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

img {
  -webkit-user-drag: none;
}

.num {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 2.4rem 3rem 3rem;
  overflow-y: auto;
  scrollbar-width: none;
  animation: enter 0.35s ease both;
}
.screen::-webkit-scrollbar {
  display: none;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(1.2rem); }
  to { opacity: 1; transform: none; }
}

/* ---------- عناصر مشتركة ---------- */

/* ملف الشعار مربع بهوامش بيضاء واسعة، فيُعرض الجزء الأوسط منه فقط. */
.logo {
  width: 17rem;
  height: 3rem;
  flex: none;
  background: url('/logo.png') center / 113% auto no-repeat;
}

.lang {
  min-width: 7.5rem;
  padding: 0.7rem 1.4rem;
  border: 0.12rem solid var(--line);
  border-radius: var(--pill);
  font-size: 1.15rem;
  color: var(--grey);
  background: var(--white);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: none;
  height: 4rem;
}

.back,
.bar-space {
  min-width: 7.5rem;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1.2rem;
  border-radius: var(--pill);
  font-size: 1.25rem;
  color: var(--purple);
  background: var(--purple-soft);
}

.arrow {
  width: 0.7rem;
  height: 0.7rem;
  border-top: 0.2rem solid currentColor;
  border-inline-start: 0.2rem solid currentColor;
  transform: rotate(-45deg);
}
[dir='rtl'] .arrow {
  transform: rotate(45deg);
}

.primary,
.secondary {
  display: block;
  flex: none;
  border-radius: var(--pill);
  transition: transform 0.12s ease, background 0.12s ease;
}

.primary {
  align-self: center;
  min-width: 24rem;
  padding: 1.3rem 3rem;
  font-size: 1.7rem;
  color: var(--white);
  background: var(--purple);
  box-shadow: var(--shadow);
}
.primary:active {
  transform: scale(0.97);
  background: var(--purple-dark);
}

.secondary {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.25rem;
  color: var(--purple);
  background: var(--purple-soft);
}
.secondary:active {
  transform: scale(0.97);
  background: var(--purple-line);
}

.empty {
  margin-top: 6rem;
  font-size: 1.8rem;
  text-align: center;
  color: var(--grey);
}

/* ---------- شاشة الانتظار ---------- */

.screen-idle {
  align-items: center;
  padding-bottom: 2.4rem;
  cursor: pointer;
  animation: none;
}

.idle-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex: none;
}
.idle-top .logo {
  width: 22rem;
  height: 3.9rem;
}

.stage {
  position: relative;
  flex: none;
  width: 44rem;
  height: 44rem;
  margin-top: 4rem;
}

.ring {
  position: absolute;
  border-radius: 50%;
}
.ring-a {
  inset: 2rem;
  background: var(--purple-soft);
  animation: breathe 6s ease-in-out infinite;
}
.ring-b {
  inset: 0;
  border: 0.5rem solid transparent;
  border-top-color: var(--purple);
  border-inline-end-color: var(--green);
  animation: spin 14s linear infinite;
}

.ball {
  position: absolute;
  border-radius: 50%;
  background: var(--green);
}
.ball-a {
  width: 4.4rem;
  height: 4.4rem;
  top: 3rem;
  inset-inline-end: 2rem;
  animation: bounce 3.2s ease-in-out infinite;
}
.ball-b {
  width: 2.4rem;
  height: 2.4rem;
  bottom: 5rem;
  inset-inline-start: 2.5rem;
  background: var(--teal);
  animation: bounce 4.1s ease-in-out infinite reverse;
}

.slot {
  position: absolute;
  inset: 0;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.slide-image {
  width: 31rem;
  height: 31rem;
  object-fit: contain;
  animation: slide-in 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.1) both, float 5s ease-in-out 0.9s infinite;
}
/* الصورة بعد قص خلفيتها البيضاء: شفافة فعلاً مع ظل خفيف. */
.slide-image.cut {
  filter: drop-shadow(0 1.2rem 1.4rem rgba(20, 20, 20, 0.22));
}
/* إن تعذر القص: الدمج يذيب البياض في الدائرة الفاتحة. */
.slide-image.flat {
  mix-blend-mode: multiply;
}
.slide-image.missing {
  width: 14rem;
  height: 14rem;
  opacity: 0.25;
}

.slide-name {
  position: absolute;
  bottom: -1.2rem;
  max-width: 40rem;
  padding: 0.7rem 1.8rem;
  border-radius: var(--pill);
  font-size: 1.3rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--white);
  background: var(--black);
  animation: fade 0.6s ease 0.3s both;
}

.campaign {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2.4rem;
  background: var(--black);
}

.idle-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: auto;
  text-align: center;
}
.idle-text h1 {
  font-size: 4rem;
  line-height: 1.25;
}
.idle-text p {
  max-width: 38rem;
  margin-top: 1rem;
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--grey);
}

.cta {
  margin-top: 3rem;
  padding: 1.6rem 4.5rem;
  border-radius: var(--pill);
  font-size: 2.2rem;
  color: var(--white);
  background: var(--purple);
  animation: pulse 2.2s ease-in-out infinite;
}
.cta.waiting {
  color: var(--grey);
  background: var(--line);
  animation: none;
}

.idle-bottom {
  display: flex;
  width: 100%;
  margin-top: 3rem;
  flex: none;
}
.side-link {
  padding: 0.8rem 0;
  font-size: 1.2rem;
  color: var(--grey);
  text-decoration: underline;
  text-underline-offset: 0.4rem;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.04); } }
@keyframes bounce { 50% { transform: translateY(-2.4rem); } }
@keyframes float { 50% { transform: translateY(-1.4rem) rotate(-3deg); } }
@keyframes slide-in {
  from { opacity: 0; transform: scale(0.8) rotate(8deg); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(105, 82, 235, 0.45); }
  50% { box-shadow: 0 0 0 1.8rem rgba(105, 82, 235, 0); }
}

/* ---------- الأسئلة ---------- */

.progress {
  flex: none;
  height: 0.8rem;
  margin-top: 2rem;
  border-radius: var(--pill);
  background: var(--purple-soft);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--pill);
  background: var(--purple);
  transition: width 0.3s ease;
}

.step {
  margin-top: 1rem;
  font-size: 1.15rem;
  color: var(--grey);
}

.welcome {
  margin-top: 2.4rem;
  padding: 1.4rem 1.8rem;
  border-radius: var(--radius);
  font-size: 1.5rem;
  text-align: center;
  color: var(--purple-dark);
  background: var(--purple-soft);
}

.question-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  padding-bottom: 5rem;
}

.question {
  margin: 3.2rem 0 2.8rem;
  font-size: 3.2rem;
  line-height: 1.3;
  text-align: center;
}

.options {
  display: grid;
  gap: 1.4rem;
}
.cols-1 { grid-template-columns: 1fr; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.options.locked { pointer-events: none; }

.option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 8.4rem;
  padding: 1.2rem;
  border: 0.2rem solid var(--purple-line);
  border-radius: var(--radius);
  font-size: 2rem;
  background: var(--white);
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.option small {
  font-size: 0.6em;
  color: var(--grey);
}
.option:active {
  transform: scale(0.97);
  background: var(--purple-soft);
}
.option.selected {
  border-color: var(--purple);
  background: var(--purple-soft);
}
.option.chosen,
.option.chosen small,
.option.chosen .option-hint {
  border-color: var(--purple);
  color: var(--white);
  background: var(--purple);
}

.tall .option {
  min-height: 22rem;
  font-size: 3rem;
}
.cols-3 .option {
  font-size: 1.6rem;
}

.option-hint {
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--grey);
  background: none !important;
}

.brand {
  min-height: 11rem;
  font-size: 1.25rem !important;
}
.brand-logo {
  width: 7rem;
  height: 5rem;
  object-fit: contain;
  mix-blend-mode: multiply;
}
.brand-logo.missing {
  display: none;
}
.hint {
  margin: -1.6rem 0 1.8rem;
  font-size: 1.4rem;
  font-weight: 400;
  text-align: center;
  color: var(--grey);
}

/* براند محدد: إطار بنفسجي وعلامة صح. */
.brand {
  position: relative;
}
.brand.selected {
  border-width: 0.35rem;
}
.brand.selected::after {
  content: '';
  position: absolute;
  top: 0.7rem;
  inset-inline-end: 0.7rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: var(--purple)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    center / 65% no-repeat;
}

.brand-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin-top: 2.2rem;
}
.brand-actions .primary {
  min-width: 0;
  width: 100%;
  font-size: 2rem;
}
.primary:disabled {
  opacity: 0.3;
  box-shadow: none;
}

/* «مو مهم»: زر مستقل واضح بنفس حجم «التالي». */
.any-brand {
  padding: 1.3rem 2rem;
  border-radius: var(--pill);
  font-size: 2rem;
  color: var(--white);
  background: var(--black);
  transition: transform 0.12s ease;
}
.any-brand:active {
  transform: scale(0.97);
}
.brand.chosen .brand-logo {
  padding: 0.3rem;
  border-radius: 0.6rem;
  background: var(--white);
  mix-blend-mode: normal;
}

/* ---------- التنبيه اللطيف ---------- */

.screen-notice {
  align-items: center;
  justify-content: center;
  gap: 3.5rem;
  cursor: pointer;
}
.screen-notice .logo {
  position: absolute;
  top: 2.9rem;
}

.notice-card {
  padding: 3.5rem 3rem;
  border-radius: 2.4rem;
  text-align: center;
  background: var(--purple-soft);
}
.notice-mark {
  width: 5rem;
  height: 5rem;
  margin: 0 auto 1.8rem;
  border-radius: 50%;
  background: var(--green);
  animation: bounce 2.4s ease-in-out infinite;
}
.notice-card h2 {
  font-size: 1.6rem;
  color: var(--purple);
}
.notice-card p {
  margin-top: 1.2rem;
  font-size: 2.3rem;
  line-height: 1.6;
}
.notice-card strong {
  color: var(--purple);
}

.countdown {
  width: 24rem;
  height: 0.5rem;
  border-radius: var(--pill);
  background: var(--purple-soft);
  overflow: hidden;
}
.countdown-fill {
  height: 100%;
  background: var(--purple);
  transform-origin: inline-start;
  animation: drain linear both;
}
@keyframes drain {
  from { width: 100%; }
  to { width: 0; }
}

/* ---------- النتيجة ---------- */

.result-title {
  margin: 1.6rem 0 1.2rem;
  font-size: 2.6rem;
  text-align: center;
}

.notes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: none;
  margin-bottom: 1.2rem;
  padding: 1rem 1.4rem;
  border-inline-start: 0.4rem solid var(--teal);
  border-radius: 1rem;
  font-size: 1.2rem;
  font-weight: 400;
  background: #eefaf9;
}

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  flex: none;
}
.cards.count-1 {
  grid-template-columns: 30rem;
  justify-content: center;
}

.card {
  display: flex;
  flex-direction: column;
  border: 0.15rem solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-image {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 19rem;
  background: var(--white);
}
.compact .cards .card-image {
  height: 13.5rem;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.card-image img.missing {
  width: 8rem;
  height: 8rem;
  opacity: 0.25;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.7rem;
  padding: 1.2rem 1.3rem 1.3rem;
}
.card-brand {
  font-size: 1.05rem;
  color: var(--purple);
}
.card h3,
.sheet h3 {
  font-size: 1.4rem;
  line-height: 1.35;
}
.card h3 {
  display: -webkit-box;
  min-height: 3.8rem;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.price {
  font-size: 2.1rem;
  color: var(--purple);
}
.price small {
  font-size: 0.55em;
}

.why {
  padding: 0.9rem 1rem;
  border-radius: 1rem;
  background: #f5fbe9;
}
.why h4 {
  font-size: 1.05rem;
  color: var(--green-dark);
}
.why ul {
  margin-top: 0.4rem;
  list-style: none;
}
.why li {
  position: relative;
  padding-inline-start: 1.5rem;
  font-size: 1.15rem;
  line-height: 1.7;
}
.why li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0.1rem;
  top: 0.62rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--green);
}

.specs {
  display: flex;
  flex-direction: column;
}
.specs div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 0.08rem solid var(--line);
  font-size: 1.1rem;
}
.specs div:last-child {
  border-bottom: 0;
}
.specs dt {
  font-weight: 400;
  color: var(--grey);
}

.card .secondary {
  margin-top: auto;
}

.card.wide {
  flex-direction: row;
}
.card.wide .card-image {
  width: 19rem;
  height: auto;
  min-height: 19rem;
}
.card.wide h3 {
  min-height: 0;
}

.third-block {
  flex: none;
  margin-top: 1.6rem;
}
.third-block h2 {
  margin-bottom: 0.8rem;
  font-size: 1.3rem;
  color: var(--grey);
}

.staff {
  flex: none;
  margin: 2rem 0 0;
  padding: 1.3rem 1.5rem;
  border-radius: var(--radius);
  font-size: 1.9rem;
  text-align: center;
  color: var(--black);
  background: var(--green);
}

.stale {
  flex: none;
  margin-top: 0.8rem;
  font-size: 1.2rem;
  text-align: center;
  color: var(--teal);
}

.screen-result .primary {
  margin-top: 1.8rem;
}

/* «رشّح لي ثالث»: رابط نصي خافت وغير بارز (البند 2). */
.faint {
  align-self: center;
  flex: none;
  margin-top: 1.2rem;
  padding: 0.6rem 1rem;
  font-size: 1.05rem;
  font-weight: 400;
  color: #a3a3ad;
  text-decoration: underline;
  text-underline-offset: 0.35rem;
}

/* ---------- التفاصيل ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  background: rgba(20, 20, 20, 0.55);
  animation: fade 0.2s ease both;
}
@keyframes fade {
  from { opacity: 0; }
}

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 88rem;
  padding: 2.6rem 2.6rem 2.4rem;
  border-radius: 2.4rem 2.4rem 0 0;
  background: var(--white);
  animation: rise 0.3s ease both;
}
@keyframes rise {
  from { transform: translateY(6rem); }
}

.sheet-close {
  position: absolute;
  top: 1.4rem;
  inset-inline-end: 1.6rem;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--grey);
  background: var(--purple-soft);
}

.sheet-head {
  display: grid;
  grid-template-columns: 17rem 1fr;
  gap: 1.6rem;
  flex: none;
  padding-inline-end: 4rem;
}
.sheet-head .card-image {
  height: 17rem;
  border: 0.15rem solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.sheet-head .specs {
  margin-top: 0.6rem;
}

.description {
  flex: 1;
  min-height: 0;
  margin: 1.6rem 0;
  padding-inline-end: 0.8rem;
  overflow-y: auto;
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.9;
  text-align: start;
}
.description p + p {
  margin-top: 0.9rem;
}

/* ---------- مراجعة آخر الترشيحات ---------- */

.history {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-item {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  align-items: center;
  gap: 1.2rem;
  padding: 1.2rem 1.4rem;
  border: 0.15rem solid var(--line);
  border-radius: var(--radius);
  text-align: start;
  background: var(--white);
}
.history-item:active {
  background: var(--purple-soft);
}

.history-time {
  font-size: 1.5rem;
  color: var(--purple);
}

.history-main {
  min-width: 0;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chips span {
  padding: 0.15rem 0.8rem;
  border-radius: var(--pill);
  font-size: 1rem;
  background: var(--purple-soft);
}
.history-names {
  margin-top: 0.5rem;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--grey);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-thumbs {
  display: flex;
  gap: 0.4rem;
}
.history-thumbs img {
  width: 5rem;
  height: 5rem;
  object-fit: contain;
}
.history-thumbs img.missing {
  opacity: 0.2;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01s !important;
    transition-duration: 0.01s !important;
  }
}
