/*
  Quiz page fixed-layout version.
  الهدف: زر Next و Back لا يتحركان بين الأسئلة.
*/

.quiz-page {
  --quiz-x: clamp(18px, 4.8vw, 22px);
  --quiz-top: clamp(12px, 1.7dvh, 18px);

  --quiz-question-area: 198px;
  --quiz-options-area: 350px;
  --quiz-actions-area: 86px;
  --quiz-option-gap: 9px;

  width: 100%;
  max-width: var(--mobile-max-width);
  height: 100dvh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;

  padding:
    calc(var(--safe-top) + var(--quiz-top))
    var(--quiz-x)
    calc(var(--safe-bottom) + 8px);

  display: grid;
  grid-template-rows: auto 1fr auto;
  row-gap: 0;

  background:
    radial-gradient(circle at 50% 7%, rgba(255, 230, 237, 0.35), transparent 32%),
    linear-gradient(180deg, #fffdfb 0%, #ffffff 100%);
}

/* HEADER */

.quiz-header {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  column-gap: 14px;
}

.quiz-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.quiz-progress-area {
  min-width: 0;
  padding-right: 2px;
}

.quiz-count {
  margin-bottom: 10px;
  text-align: center;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
  color: var(--color-navy);
}

.quiz-progress-track {
  width: 100%;
  height: 7px;
  border-radius: var(--radius-full);
  background: #eff0f3;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-primary);
  transition: width 180ms ease;
}

/* CONTENT FIXED AREAS */

.quiz-content {
  min-height: 0;
  margin-top: 0;

  display: grid;
  grid-template-rows:
    var(--quiz-question-area)
    var(--quiz-options-area)
    var(--quiz-actions-area);

  align-content: start;
}

.quiz-question-box {
  height: var(--quiz-question-area);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.quiz-question {
  margin: 0;
  font-family: var(--font-title);
  font-size: 32px;
  line-height: 1.12;
  letter-spacing: -1.1px;
  color: var(--color-navy);
}

/* OPTIONS */

.quiz-options {
  height: var(--quiz-options-area);
  margin-top: 0;

  display: grid;
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: var(--quiz-option-gap);
}

.quiz-option {
  width: 100%;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;

  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 11px;

  padding: 7px 12px;

  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(236, 236, 242, 0.95);
  box-shadow: 0 8px 20px rgba(7, 20, 63, 0.06);

  text-align: left;
  color: var(--color-navy);

  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

.quiz-option:active {
  transform: scale(0.99);
}

.quiz-option.is-selected {
  border-color: rgba(255, 47, 117, 0.5);
  background: #fff8fa;
  box-shadow: 0 10px 22px rgba(255, 47, 117, 0.12);
}

.quiz-option-placeholder {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.quiz-option-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quiz-option-icon svg {
  width: 52%;
  height: 52%;
}

.quiz-option-text {
  font-size: 14.4px;
  line-height: 1.18;
  font-weight: 650;
  color: var(--color-navy);
}

/* COLORS */

.option-pink {
  background: #ffe7ef;
  color: #ff3d7d;
}

.option-orange {
  background: #fff0e5;
  color: #f2a032;
}

.option-green {
  background: #defbf0;
  color: #28c991;
}

.option-purple {
  background: #f0e4ff;
  color: #9b62e8;
}

.option-blue {
  background: #e8f4ff;
  color: #398fda;
}

.option-yellow {
  background: #fff6dd;
  color: #f2b423;
}

/* ACTIONS FIXED */

.quiz-actions {
  height: var(--quiz-actions-area);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.quiz-next-button {
  position: relative;
  margin-top: 0;
  min-height: 48px;

  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 900;
}

.quiz-next-arrow {
  position: absolute;
  right: 22px;
  font-size: 1.15em;
  line-height: 1;
}

.quiz-next-middle {
  font-family: var(--font-main);
  font-size: 1em;
  margin: 0 6px;
}

.quiz-back-button {
  width: 100%;
  margin-top: 10px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  color: #55506f;
  font-size: 15px;
  font-weight: 550;
}

/* MOTIVATION CARD */

.quiz-motivation-card {
  position: relative;
  min-height: 72px;
  margin-top: 0;
  padding: 12px 84px 12px 13px;

  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;

  border-radius: 18px;
  background: linear-gradient(135deg, #fff1f4 0%, #fff7f8 100%);
  overflow: hidden;
}

.quiz-motivation-card.is-final {
  background: linear-gradient(135deg, #fff0f3 0%, #fff8fa 100%);
}

.quiz-motivation-heart {
  color: #ff7aa0;
}

.quiz-motivation-heart svg {
  width: 27px;
  height: 27px;
}

.quiz-motivation-text {
  position: relative;
  z-index: 2;
}

.quiz-motivation-text h2 {
  margin-bottom: 4px;
  color: var(--color-navy);
  font-size: 14.5px;
  line-height: 1.1;
  font-weight: 850;
}

.quiz-motivation-text p {
  max-width: 210px;
  color: var(--color-text);
  font-size: 10.8px;
  line-height: 1.3;
  font-weight: 520;
}

/* CSS PLANT / DECORATION */

.quiz-plant {
  position: absolute;
  right: 12px;
  bottom: -4px;
  width: 66px;
  height: 74px;
}

.plant-stem {
  position: absolute;
  left: 33px;
  bottom: 14px;
  width: 4px;
  height: 50px;
  border-radius: 99px;
  background: #69442d;
  transform: rotate(-9deg);
  transform-origin: bottom;
}

.plant-leaf {
  position: absolute;
  width: 20px;
  height: 29px;
  border-radius: 100% 0 100% 0;
  background: linear-gradient(135deg, #78c75f 0%, #4b9b39 100%);
}

.leaf-1 {
  left: 17px;
  top: 22px;
  transform: rotate(-45deg);
}

.leaf-2 {
  right: 10px;
  top: 8px;
  transform: rotate(42deg);
}

.leaf-3 {
  right: 9px;
  top: 39px;
  transform: rotate(48deg);
}

.plant-soil {
  position: absolute;
  left: 14px;
  right: 4px;
  bottom: 0;
  height: 18px;
  border-radius: 50% 50% 0 0;
  background: #6b412b;
}

/* NO ANSWER ANIMATION */

.quiz-options.needs-answer .quiz-option:not(.quiz-option-placeholder) {
  animation: quizNeedAnswer 260ms ease;
}

@keyframes quizNeedAnswer {
  0% {
    transform: translateX(0);
  }

  30% {
    transform: translateX(-4px);
  }

  60% {
    transform: translateX(4px);
  }

  100% {
    transform: translateX(0);
  }
}

/* iPhone Plus / Pro Max */

@media (min-width: 414px) and (min-height: 890px) {
  .quiz-page {
    --quiz-x: 22px;
    --quiz-top: 18px;

    --quiz-question-area: 205px;
    --quiz-options-area: 354px;
    --quiz-actions-area: 86px;
    --quiz-option-gap: 9px;
  }

  .quiz-question {
    font-size: 32.5px;
    line-height: 1.12;
  }

  .quiz-option-text {
    font-size: 14.4px;
  }

  .quiz-next-button {
    min-height: 48px;
    font-size: 22px;
  }

  .quiz-motivation-card {
    min-height: 72px;
  }
}

/* iPhone normal / Pro */

@media (max-width: 414px) and (max-height: 880px) {
  .quiz-page {
    --quiz-x: 18px;
    --quiz-top: 12px;

    --quiz-question-area: 180px;
    --quiz-options-area: 320px;
    --quiz-actions-area: 78px;
    --quiz-option-gap: 8px;
  }

  .quiz-header {
    grid-template-columns: 40px 1fr;
    column-gap: 12px;
  }

  .quiz-logo {
    width: 38px;
    height: 38px;
  }

  .quiz-count {
    font-size: 13.5px;
    margin-bottom: 9px;
  }

  .quiz-question {
    font-size: 28px;
    line-height: 1.11;
  }

  .quiz-option {
    grid-template-columns: 38px 1fr;
    gap: 10px;
    padding: 6px 11px;
    border-radius: 15px;
  }

  .quiz-option-icon {
    width: 35px;
    height: 35px;
  }

  .quiz-option-text {
    font-size: 13.2px;
    line-height: 1.17;
  }

  .quiz-next-button {
    min-height: 44px;
    font-size: 20px;
  }

  .quiz-back-button {
    margin-top: 8px;
    font-size: 14px;
  }

  .quiz-motivation-card {
    min-height: 66px;
    padding: 10px 75px 10px 12px;
  }

  .quiz-motivation-heart svg {
    width: 24px;
    height: 24px;
  }

  .quiz-motivation-text h2 {
    font-size: 13.5px;
  }

  .quiz-motivation-text p {
    font-size: 10px;
  }

  .quiz-plant {
    width: 58px;
    height: 66px;
  }
}

/* Small phones */

@media (max-width: 374px), (max-height: 760px) {
  .quiz-page {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;

    --quiz-x: 15px;
    --quiz-top: 9px;

    --quiz-question-area: 165px;
    --quiz-options-area: 292px;
    --quiz-actions-area: 72px;
    --quiz-option-gap: 7px;
  }

  .quiz-question {
    font-size: 24px;
  }

  .quiz-option {
    grid-template-columns: 34px 1fr;
    padding: 6px 10px;
  }

  .quiz-option-icon {
    width: 31px;
    height: 31px;
  }

  .quiz-option-text {
    font-size: 12.2px;
  }

  .quiz-next-button {
    min-height: 40px;
    font-size: 18px;
  }

  .quiz-motivation-card {
    min-height: 62px;
  }
}

/* Auto next mode: no Next button */

.quiz-actions {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-next-button {
  display: none !important;
}

.quiz-back-button {
  margin-top: 0;
  font-size: 16px;
}

.quiz-option-text {
  font-size: 16px;
  line-height: 1.22;
  font-weight: 650;
}

.quiz-option.is-selected {
  transform: scale(0.99);
}

.quiz-option:disabled {
  cursor: default;
}

@media (min-width: 414px) and (min-height: 890px) {
  .quiz-page {
    --quiz-actions-area: 48px;
  }

  .quiz-option-text {
    font-size: 16.4px;
    line-height: 1.22;
  }

  .quiz-back-button {
    font-size: 16px;
  }
}

@media (max-width: 414px) and (max-height: 880px) {
  .quiz-page {
    --quiz-actions-area: 42px;
  }

  .quiz-option-text {
    font-size: 14.8px;
    line-height: 1.2;
  }

  .quiz-back-button {
    font-size: 14.5px;
  }
}

@media (max-width: 374px), (max-height: 760px) {
  .quiz-page {
    --quiz-actions-area: 40px;
  }

  .quiz-option-text {
    font-size: 13.6px;
  }
}

/* =====================================================
   Tall iPhone spacing balance
   يستغل الفراغ السفلي في iPhone Pro Max بدون كسر الهواتف الصغيرة
===================================================== */

/* كبر خط الإجابات قليلًا للجميع */
.quiz-option-text {
  font-size: 16px;
  line-height: 1.22;
  font-weight: 680;
}

/* تأكد أن Back في منطقته فقط */
.quiz-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  height: var(--quiz-actions-area);
}

.quiz-back-button {
  margin-top: 0;
}

/* iPhone Plus / Pro Max / الشاشات الطويلة */
@media (min-width: 414px) and (min-height: 890px) {
  .quiz-page {
    --quiz-question-area: 214px;
    --quiz-options-area: 388px;
    --quiz-actions-area: 56px;
    --quiz-option-gap: 11px;
  }

  .quiz-content {
    min-height: 0;

    display: grid;
    grid-template-rows:
      var(--quiz-question-area)
      var(--quiz-options-area)
      var(--quiz-actions-area);

    /*
      هذه هي النقطة المهمة:
      توزع الفراغ بين السؤال والإجابات وBack
      بدل أن يبقى الفراغ كله فوق الكرت السفلي
    */
    align-content: space-between;
  }

  .quiz-question-box {
    height: var(--quiz-question-area);
    align-items: center;
  }

  .quiz-options {
    height: var(--quiz-options-area);
    grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: var(--quiz-option-gap);
  }

  .quiz-option {
    height: 100%;
    min-height: 0;
    grid-template-columns: 44px 1fr;
    padding: 8px 13px;
  }

  .quiz-option-icon {
    width: 40px;
    height: 40px;
  }

  .quiz-option-text {
    font-size: 17px;
    line-height: 1.23;
  }

  .quiz-back-button {
    font-size: 16px;
  }

  .quiz-motivation-card {
    min-height: 76px;
  }
}

/* iPhone normal / Pro: لا نبالغ في الفراغ */
@media (max-width: 414px) and (max-height: 880px) {
  .quiz-content {
    align-content: start;
  }

  .quiz-option-text {
    font-size: 15px;
    line-height: 1.2;
  }
}

/* الهواتف الصغيرة جدًا */
@media (max-width: 374px), (max-height: 760px) {
  .quiz-content {
    align-content: start;
  }

  .quiz-option-text {
    font-size: 13.8px;
  }
}

/* =====================================================
   Fix long answers card height
   يجعل بطاقة الإجابة تتمدد إذا كان النص طويل
   مع الحفاظ على أماكن الصفحة ثابتة قدر الإمكان
===================================================== */

.quiz-options {
  height: var(--quiz-options-area);

  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--quiz-option-gap);

  overflow: visible;
}

.quiz-option {
  height: auto;
  min-height: 60px;
  flex: 0 0 auto;

  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;

  box-sizing: border-box;
}

.quiz-option-placeholder {
  min-height: 60px;
  flex: 0 0 auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.quiz-option-text {
  display: block;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;

  font-size: 16px;
  line-height: 1.24;
  font-weight: 680;
}

/* iPhone Plus / Pro Max */
@media (min-width: 414px) and (min-height: 890px) {
  .quiz-page {
    --quiz-question-area: 205px;
    --quiz-options-area: 405px;
    --quiz-actions-area: 48px;
    --quiz-option-gap: 10px;
  }

  .quiz-option {
    min-height: 61px;
    grid-template-columns: 44px 1fr;
    padding: 8px 14px;
  }

  .quiz-option-placeholder {
    min-height: 61px;
  }

  .quiz-option-icon {
    width: 40px;
    height: 40px;
  }

  .quiz-option-text {
    font-size: 16.4px;
    line-height: 1.25;
  }
}

/* iPhone normal / Pro */
@media (max-width: 414px) and (max-height: 880px) {
  .quiz-page {
    --quiz-question-area: 180px;
    --quiz-options-area: 360px;
    --quiz-actions-area: 44px;
    --quiz-option-gap: 8px;
  }

  .quiz-option {
    min-height: 56px;
    grid-template-columns: 38px 1fr;
    padding: 7px 12px;
  }

  .quiz-option-placeholder {
    min-height: 56px;
  }

  .quiz-option-icon {
    width: 35px;
    height: 35px;
  }

  .quiz-option-text {
    font-size: 15px;
    line-height: 1.22;
  }
}

/* Small phones */
@media (max-width: 374px), (max-height: 760px) {
  .quiz-page {
    --quiz-question-area: 165px;
    --quiz-options-area: 318px;
    --quiz-actions-area: 40px;
    --quiz-option-gap: 7px;
  }

  .quiz-option {
    min-height: 52px;
    grid-template-columns: 34px 1fr;
    padding: 6px 10px;
  }

  .quiz-option-placeholder {
    min-height: 52px;
  }

  .quiz-option-icon {
    width: 31px;
    height: 31px;
  }

  .quiz-option-text {
    font-size: 13.8px;
    line-height: 1.2;
  }
}