/* Homepage (public/home.js), matching docs/master/APPROVED_HOMEPAGE_REFERENCE.png: a warm dusk study
   room in purple, lavender and gold; frosted rounded panels; soft glows on the key cards.
   Mobile-first: one column in the spec's phone order; wider screens use the reference's layout.
   All drawing is CSS gradients and inline SVG (no images, no external files). Logical properties
   keep right-to-left layouts possible. Everything is scoped to .hp. */

.hp {
  --hp-ink: #1d1b3a;
  --hp-soft-ink: #4b4775;
  --hp-violet: #5b3fd6;
  --hp-violet-deep: #3f2aa8;
  --hp-gold: #ffc94a;
  --hp-glass: rgb(255 255 255 / 82%);
  --hp-dark-glass: rgb(48 30 102 / 78%);
  --hp-radius: 28px;
  position: relative;
  isolation: isolate;
  display: grid;
  gap: 14px;
  padding: 12px;
  min-height: 100vh;
  overflow: hidden;
  color: var(--hp-ink);
  font-family: "Nunito", "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

/* The study-room scene: layered glows standing in for lamps, shelves and the dusk window. */
.hp-scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 22%, rgb(255 190 110 / 55%), transparent 28%),
    radial-gradient(circle at 70% 8%, rgb(255 214 140 / 45%), transparent 22%),
    radial-gradient(circle at 92% 70%, rgb(255 160 200 / 35%), transparent 30%),
    radial-gradient(circle at 40% 90%, rgb(160 120 255 / 40%), transparent 35%),
    repeating-linear-gradient(90deg, rgb(90 60 150 / 0%) 0 46px, rgb(90 60 150 / 12%) 46px 50px),
    linear-gradient(160deg, #3b2a7a 0%, #7a5bc9 38%, #c99ad8 70%, #f3c7a4 100%);
}

/* ---------- Top bar ---------- */
.hp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.hp-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 20px;
  background: var(--hp-dark-glass); color: #ffffff;
  backdrop-filter: blur(10px);
}
.hp-logo { width: 40px; height: 40px; flex: none; }
.hp-brand p { margin: 0; }
.hp-brand-name { font-weight: 800; font-size: 1.35rem; line-height: 1.1; }
.hp-tagline { font-size: 0.8rem; opacity: 0.92; }
.hp-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hp-pill {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  min-height: 44px; padding: 4px 14px; border-radius: 999px; border: 0;
  background: var(--hp-dark-glass); color: #ffffff; font: inherit; font-weight: 800;
}
.hp-pill .hp-icon { width: 24px; height: 24px; }
.hp-num { font-size: 1.15rem; }
.hp-profile { position: relative; }
button.hp-who { cursor: pointer; }
.hp-avatar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(145deg, #ffd98a, #ff8fab); color: var(--hp-ink); font-weight: 900;
}
.hp-menu {
  position: absolute; inset-inline-end: 0; inset-block-start: calc(100% + 6px); z-index: 5;
  margin: 0; padding: 6px; list-style: none; min-width: 200px;
  border-radius: 18px; background: #ffffff; box-shadow: 0 10px 30px rgb(30 15 80 / 30%);
}
.hp-menu[hidden] { display: none; }
.hp-menu-item {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 12px;
  background: transparent; color: var(--hp-ink); font: inherit; font-weight: 700; text-align: start; cursor: pointer;
}
.hp-menu-item:hover { background: #f1edff; }

/* ---------- Greeting ---------- */
.hp-hero { display: flex; align-items: flex-end; gap: 8px; }
.hp-learner { display: none; } /* phones: the student character hides (design spec) */
.hp-tutor { display: flex; align-items: center; gap: 10px; flex: 1; }
.hp-tutor-art { flex: none; width: 92px; height: 92px; filter: drop-shadow(0 8px 14px rgb(40 20 100 / 35%)); }
.hp-bubble {
  position: relative; flex: 1; padding: 12px 16px; border-radius: 24px;
  background: #ffffff; box-shadow: 0 8px 24px rgb(40 20 100 / 25%);
}
.hp-bubble p { margin: 0; }
.hp-greeting { font-size: 1.1rem; font-weight: 800; line-height: 1.3; }
.hp-hello { margin-block-start: 4px !important; color: var(--hp-soft-ink); }
.hp-ai { margin-block-start: 6px !important; font-size: 0.8rem; color: var(--hp-soft-ink); }

/* ---------- Cards ---------- */
.hp-card { border-radius: var(--hp-radius); padding: 16px; }
.hp-card h2, .hp-card p { margin: 0; }
.hp-continue {
  display: flex; gap: 14px; align-items: center;
  background: linear-gradient(150deg, rgb(255 255 255 / 95%), rgb(236 228 255 / 90%));
  box-shadow: 0 0 0 2px rgb(255 255 255 / 70%), 0 0 28px rgb(190 160 255 / 65%), 0 12px 30px rgb(40 20 100 / 25%);
}
.hp-continue-art { width: 72px; height: 72px; flex: none; }
.hp-continue-body { display: grid; gap: 6px; flex: 1; min-width: 0; }
.hp-label { font-size: 1rem; font-weight: 800; color: var(--hp-violet); }
.hp-title { font-size: 1.3rem; font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.hp-meta { color: var(--hp-soft-ink); font-weight: 700; }
.hp-bar-meter {
  width: 100%; height: 12px; border: 0; border-radius: 999px; overflow: hidden;
  appearance: none; background: #e3ddf5; accent-color: #34c26f;
}
.hp-bar-meter::-webkit-progress-bar { background: #e3ddf5; border-radius: 999px; }
.hp-bar-meter::-webkit-progress-value { background: linear-gradient(90deg, #34c26f, #7be08f); border-radius: 999px; }
.hp-bar-meter::-moz-progress-bar { background: linear-gradient(90deg, #34c26f, #7be08f); border-radius: 999px; }
.hp-gold { accent-color: var(--hp-gold); }
.hp-gold::-webkit-progress-value { background: linear-gradient(90deg, #ffb020, #ffd76a); }
.hp-gold::-moz-progress-bar { background: linear-gradient(90deg, #ffb020, #ffd76a); }
.hp-go {
  justify-self: end; min-height: 52px; padding: 10px 26px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #6f55ef, var(--hp-violet-deep)); color: #ffffff;
  font: inherit; font-size: 1.15rem; font-weight: 900; cursor: pointer;
  box-shadow: 0 8px 18px rgb(63 42 168 / 40%);
}

.hp-mission {
  display: flex; gap: 14px; align-items: center; color: #ffffff;
  background: linear-gradient(150deg, #5a3cc9, #7b4fd8);
  box-shadow: 0 0 0 2px rgb(255 190 90 / 85%), 0 0 26px rgb(255 160 70 / 55%);
}
.hp-mission-art { width: 64px; height: 64px; flex: none; }
.hp-mission > div { display: grid; gap: 6px; }
.hp-mission-title { font-size: 1.35rem; font-weight: 900; }
.hp-mission-text { font-size: 1.05rem; font-weight: 700; }
.hp-mission-reward { color: #ffe39a; font-weight: 700; }
.hp-mission-count { font-weight: 700; }
.hp-ghost {
  justify-self: start; min-height: 44px; padding: 8px 18px; border-radius: 999px;
  border: 2px solid rgb(255 255 255 / 80%); background: transparent; color: #ffffff;
  font: inherit; font-weight: 800; cursor: pointer;
}

/* ---------- Subjects ---------- */
.hp-subjects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hp-subject {
  display: grid; justify-items: center; align-content: center; gap: 6px;
  min-height: 112px; padding: 12px 8px; border: 0; border-radius: 24px;
  color: var(--hp-ink); font: inherit; font-size: 1.15rem; font-weight: 900; cursor: pointer;
  box-shadow: inset 0 -4px 0 rgb(0 0 0 / 6%), 0 8px 18px rgb(40 20 100 / 20%);
  background: linear-gradient(160deg, #fff6fb, #f6d9f0);
}
.hp-subject[data-world="maths"] { background: linear-gradient(160deg, #f1eaff, #d9c9ff); }
.hp-subject[data-world="science"] { background: linear-gradient(160deg, #e9fff6, #bfeedd); }
.hp-subject[data-world="english"] { background: linear-gradient(160deg, #fff4e6, #ffd9b0); }
.hp-subject[data-world="social"] { background: linear-gradient(160deg, #fff0ee, #ffc9c1); }
.hp-subject[data-world="computer"] { background: linear-gradient(160deg, #eef2ff, #c9d4ff); }
.hp-subject[aria-pressed="true"] { box-shadow: 0 0 0 3px #ffffff, 0 0 24px rgb(190 140 255 / 85%); }
.hp-subject-art { width: 52px; height: 52px; }
.hp-subject-name { line-height: 1.15; text-align: center; }

/* ---------- My Progress ---------- */
.hp-progress { color: #ffffff; background: var(--hp-dark-glass); backdrop-filter: blur(10px); }
.hp-progress-head { display: flex; justify-content: space-between; align-items: center; }
.hp-progress-title { font-size: 1.3rem; font-weight: 900; }
.hp-chevron {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 50%;
  background: rgb(255 255 255 / 14%); color: #ffffff; font-size: 1.6rem; font-weight: 900; cursor: pointer;
}
.hp-progress-row { display: flex; gap: 14px; align-items: center; margin-block-start: 8px; }
.hp-ring-box { position: relative; width: 112px; height: 112px; flex: none; }
.hp-ring { width: 112px; height: 112px; }
.hp-ring-track { stroke: rgb(255 255 255 / 18%); }
.hp-ring-fill { stroke: var(--hp-gold); }
.hp-ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; margin: 0; }
.hp-ring-num { font-size: 1.5rem; font-weight: 900; }
.hp-ring-sub { font-size: 0.7rem; max-width: 70px; line-height: 1.1; }
.hp-facts { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.hp-facts li { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.hp-facts .hp-icon { width: 26px; height: 26px; flex: none; }

/* ---------- Tutor carousel ---------- */
.hp-tutors {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--hp-radius);
  background: rgb(255 255 255 / 22%); backdrop-filter: blur(8px);
}
.hp-change {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  min-height: 52px; padding: 6px 16px; border: 0; border-radius: 999px;
  background: var(--hp-dark-glass); color: #ffffff; font: inherit; font-weight: 800; cursor: pointer;
}
.hp-play { width: 30px; height: 30px; }
.hp-track {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  flex: 1; padding: 4px; scrollbar-width: thin;
}
.hp-tile {
  position: relative; display: grid; justify-items: center; gap: 2px; flex: none;
  scroll-snap-align: start; width: 104px; min-height: 120px; padding: 6px; border: 0; border-radius: 22px;
  background: linear-gradient(160deg, #ffffff, #e8defc); color: var(--hp-ink); font: inherit; font-weight: 800; cursor: pointer;
}
.hp-tile[aria-pressed="true"] { box-shadow: 0 0 0 3px #ffffff, 0 0 20px rgb(190 140 255 / 90%); }
.hp-tile-art { width: 80px; height: 80px; }
.hp-tile-name { font-size: 0.85rem; }
.hp-tick {
  position: absolute; inset-block-end: 26px; inset-inline-end: 8px; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%; background: var(--hp-violet); color: #ffffff; font-weight: 900;
}
.hp-next {
  flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%;
  background: var(--hp-violet); color: #ffffff; font-size: 1.8rem; font-weight: 900; cursor: pointer;
}
[dir="rtl"] .hp-next { transform: scaleX(-1); }

/* ---------- Shared ---------- */
.hp-vh {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.hp button:focus-visible { outline: 4px solid var(--hp-gold); outline-offset: 3px; }

/* Gentle motion only, and none when reduced motion is asked for. */
@media (prefers-reduced-motion: no-preference) {
  .hp-tutor-art { animation: hp-float 5s ease-in-out infinite; }
  .hp-go, .hp-subject, .hp-tile { transition: transform 0.15s ease; }
  .hp-go:hover, .hp-subject:hover, .hp-tile:hover { transform: translateY(-2px); }
}
@keyframes hp-float { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) {
  .hp *, .hp *::before, .hp *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  .hp { padding: 18px; gap: 16px; }
  .hp-subjects { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hp-tutor-art { width: 120px; height: 120px; }
}

/* ---------- Desktop: the reference layout ---------- */
@media (min-width: 1024px) {
  .hp {
    grid-template-columns: minmax(220px, 1fr) minmax(0, 1.5fr) minmax(300px, 1fr);
    grid-template-areas:
      "bar bar bar"
      "learner tutor progress"
      "learner continue mission"
      "subjects subjects subjects"
      "tutors tutors tutors";
    align-items: start;
    padding: 20px 28px;
  }
  .hp-bar { grid-area: bar; }
  /* The greeting section's two parts take their own grid areas (the section keeps its label). */
  .hp-hero { display: contents; }
  .hp-learner { grid-area: learner; display: block; width: 100%; max-width: 300px; height: auto; align-self: end; }
  .hp-tutor { grid-area: tutor; }
  .hp-continue { grid-area: continue; }
  .hp-mission { grid-area: mission; align-self: stretch; }
  .hp-progress { grid-area: progress; }
  .hp-subjects { grid-area: subjects; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hp-tutors { grid-area: tutors; }
  .hp-continue .hp-title { font-size: 1.6rem; }
}

/* ---------- Older students: same layout and brand, quieter palette, smaller character ---------- */
.hp[data-older="true"] .hp-scene {
  background:
    radial-gradient(circle at 80% 10%, rgb(255 214 140 / 25%), transparent 25%),
    linear-gradient(160deg, #23204a 0%, #3d3772 55%, #6b5f99 100%);
}
.hp[data-older="true"] .hp-learner { display: none; }
@media (min-width: 1024px) {
  .hp[data-older="true"] {
    grid-template-areas:
      "bar bar bar"
      "tutor tutor progress"
      "continue continue mission"
      "subjects subjects subjects"
      "tutors tutors tutors";
  }
}
.hp[data-older="true"] .hp-tutor-art { width: 72px; height: 72px; animation: none; }
.hp[data-older="true"] .hp-greeting { font-size: 1rem; }
.hp[data-older="true"] .hp-continue { box-shadow: 0 10px 26px rgb(10 5 40 / 35%); }
.hp[data-older="true"] .hp-mission { background: #3a3470; box-shadow: 0 0 0 1px rgb(255 201 74 / 60%); }
.hp[data-older="true"] .hp-subject { min-height: 88px; font-size: 1rem; background: #f4f2fb; }
.hp[data-older="true"] .hp-subject-art { width: 36px; height: 36px; }
