/* رحلة الروضة (#/kg3): the 3D journey. A full-screen WebGL canvas with a light HUD on top:
   top bar, labels that float over the 3D stops, the owl's words, the station card, one big button.
   A game opens in .jr-play over the world. Own keyframes are prefixed jr-. */

.jr {
  --jr-ink: #1F2A24;
  --jr-gold: #FFC72C;
  --jr-gold-deep: #E0A800;
  --jr-green: #2EAD6B;
  --jr-green-deep: #1F8A52;
  position: fixed; inset: 0; overflow: hidden; background: #DDF3FF; color: var(--jr-ink);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.jr-canvas { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; display: block; touch-action: none; cursor: grab; }
.jr-canvas:active { cursor: grabbing; }

/* ---------- top bar ---------- */
.jr-top {
  position: absolute; inset-inline: 0; inset-block-start: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  pointer-events: none;
}
.jr-top > * { pointer-events: auto; }
.jr-round {
  flex: none; display: grid; place-items: center; min-inline-size: 48px; block-size: 48px; padding: 0 12px;
  border: 0; border-radius: 999px; background: linear-gradient(#FFFFFF, #EEF6FB); color: var(--jr-ink);
  font: inherit; font-size: 22px; font-weight: 900; cursor: pointer;
  box-shadow: 0 4px 0 #B9CBD6, 0 8px 18px #0002;
}
.jr-round:active { transform: translateY(3px); box-shadow: 0 1px 0 #B9CBD6, 0 4px 10px #0002; }
.jr-round--grown { font-size: 15px; }
.jr-title {
  flex: 1; min-inline-size: 0; display: grid; padding: 6px 14px; border-radius: 18px;
  background: #FFFFFFD9; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 6px 16px #0001;
}
.jr-kicker { font-size: 13px; font-weight: 800; color: #1B74A8; }
.jr-name { font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jr-stars {
  flex: none; padding: 8px 14px; border-radius: 999px; font-weight: 900; color: #8A5A00; white-space: nowrap;
  background: linear-gradient(#FFE58A, var(--jr-gold)); box-shadow: 0 4px 0 var(--jr-gold-deep), 0 8px 16px #0002;
}

/* ---------- labels over the stops ---------- */
.jr-labels { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.jr-pill, .jr-choose {
  position: absolute; inset-inline-start: 0; inset-block-start: 0; left: 0; right: auto; pointer-events: auto;
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border: 0; border-radius: 999px;
  background: #FFFFFF; color: var(--jr-ink); font: inherit; font-weight: 900; font-size: 15px; white-space: nowrap; cursor: pointer;
  box-shadow: 0 4px 0 #0002, 0 8px 18px #0003; transition: opacity .25s;
  will-change: transform;
}
.jr-pill::after { content: ""; position: absolute; inset-block-start: 100%; left: 50%; margin-left: -7px; border: 7px solid transparent; border-block-start-color: #FFFFFF; }
.jr-pill-icon {
  display: grid; place-items: center; inline-size: 32px; block-size: 32px; border-radius: 50%;
  background: #FFF4D6; color: #E8613C; font-size: 18px; font-weight: 900;
}
.jr-pill-text { display: inline-flex; align-items: baseline; gap: 6px; }
.jr-pill-text small { font-size: 12px; color: #6B6458; font-weight: 800; }
.jr-pill--gate { background: #8B5E3C; color: #FFF8E7; padding: 6px 14px; font-size: 14px; }
.jr-pill--gate::after { border-block-start-color: #8B5E3C; }
.jr-pill--soon { background: #EEF0F2; color: #6B6458; padding: 6px 14px; font-size: 14px; }
.jr-pill--soon::after { border-block-start-color: #EEF0F2; }
.jr-pill.is-done .jr-pill-icon { background: var(--jr-green); color: #fff; }
.jr-pill.is-locked { background: #F3F4F6; color: #7A7F85; }
.jr-pill.is-locked::after { border-block-start-color: #F3F4F6; }
.jr-pill.is-locked .jr-pill-icon { background: #E2E5E9; }
.jr-pill.is-next { background: var(--jr-gold); box-shadow: 0 4px 0 var(--jr-gold-deep), 0 0 0 6px #FFC72C55, 0 10px 22px #0003; animation: jr-bob 1.4s ease-in-out infinite; }
.jr-pill.is-next::after { border-block-start-color: var(--jr-gold); }
.jr-pill.is-next .jr-pill-icon { background: #fff; }
@keyframes jr-bob { 50% { margin-block-start: -6px; } }

.jr-choose {
  padding: 10px 18px; font-size: 18px; background: var(--c, var(--jr-gold)); color: #fff; text-shadow: 0 1px 0 #0004;
  box-shadow: 0 5px 0 #0003, 0 10px 20px #0003; animation: jr-bob 1.6s ease-in-out infinite;
}

/* ---------- bottom: owl words, station card, the big button ---------- */
.jr-bottom {
  position: absolute; inset-inline: 0; inset-block-end: 0; z-index: 3;
  display: grid; gap: 10px; justify-items: stretch;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 14px);
  pointer-events: none;
  background: linear-gradient(to top, #00000026, transparent);
}
.jr-bottom > * { pointer-events: auto; }
.jr-say {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 22px; background: #FFFFFFEE; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 0 #0001, 0 10px 24px #0002;
}
.jr-say-owl { font-size: 30px; }
.jr-say-text { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.5; }
.jr-say-again { border: 0; background: #EEF6FB; border-radius: 50%; inline-size: 42px; block-size: 42px; font-size: 18px; cursor: pointer; }
.jr-card {
  padding: 14px 18px; border-radius: 24px; background: linear-gradient(160deg, #FFFFFF, #FFF8E2);
  box-shadow: 0 6px 0 #E9D9A8, 0 12px 26px #0003; animation: jr-in .45s cubic-bezier(.3, 1.5, .5, 1) both;
}
.jr-card[hidden] { display: none; }
.jr-card-kicker { margin: 0; font-size: 14px; font-weight: 900; color: #1B74A8; }
.jr-card-title { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 24px; font-weight: 900; }
.jr-card-icon {
  display: grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 14px;
  background: #FFF4D6; color: #E8613C; font-size: 24px; box-shadow: inset 0 -3px 0 #F2D58A;
}
.jr-card-plan { margin: 0 0 4px; display: inline-block; padding: 2px 10px; border-radius: 999px; background: #E1F1FB; color: #1B74A8; font-size: 14px; font-weight: 800; }
.jr-card-lesson { margin: 0; color: #5B5348; line-height: 1.6; }
@keyframes jr-in { from { transform: translateY(30px) scale(.92); opacity: 0; } }

.jr-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
.jr-nav[hidden] { display: none; }
.jr-arrow {
  inline-size: 64px; min-block-size: 64px; border: 0; border-radius: 22px; cursor: pointer; touch-action: none;
  background: linear-gradient(#FFFFFF, #EAF4FA); color: #1B74A8; font: inherit; font-size: 24px; font-weight: 900;
  box-shadow: 0 7px 0 #B9CBD6, 0 14px 26px #0002; transition: transform .08s, box-shadow .08s;
  -webkit-touch-callout: none;
}
.jr-arrow.is-on, .jr-arrow:active { transform: translateY(5px); box-shadow: 0 2px 0 #B9CBD6, 0 6px 14px #0002; background: #DDF0FB; }
.jr-hint { display: none; margin: 0; text-align: center; font-size: 14px; font-weight: 800; color: #fff; text-shadow: 0 1px 3px #0008; }
.jr-bottom.is-choosing .jr-hint { display: none; }
.jr-card-again { margin-block-start: 8px; }
.jr-go {
  min-block-size: 64px; padding: 12px 22px; border: 0; border-radius: 22px;
  background: linear-gradient(#3CC57E, var(--jr-green)); color: #fff; font: inherit; font-size: 21px; font-weight: 900; cursor: pointer;
  text-shadow: 0 2px 0 #0003; box-shadow: 0 7px 0 var(--jr-green-deep), 0 14px 26px #0003;
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.jr-go:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--jr-green-deep), 0 6px 14px #0003; }
.jr-go:disabled { filter: saturate(.4) brightness(1.05); }
.jr-go[hidden] { display: none; }

.jr.is-choosing .jr-say { justify-self: center; max-inline-size: 520px; }
.jr.is-playing .jr-top, .jr.is-playing .jr-bottom, .jr.is-playing .jr-labels { visibility: hidden; }

/* ---------- a game over the world ---------- */
.jr-play { position: absolute; inset: 0; z-index: 5; overflow-y: auto; touch-action: auto; user-select: auto; -webkit-user-select: auto; animation: jr-fade .3s ease both; }
.jr-play[hidden] { display: none; }
.jr-play .fz { min-block-size: 100%; }
@keyframes jr-fade { from { opacity: 0; transform: scale(1.04); } }

/* ---------- grown-ups sheet ---------- */
.jr-sheet { position: absolute; inset: 0; z-index: 6; display: grid; align-items: end; justify-items: center; background: #0006; touch-action: auto; user-select: auto; }
.jr-sheet[hidden] { display: none; }
.jr-sheet-card {
  position: relative; inline-size: min(100%, 680px); max-block-size: 86dvh; overflow-y: auto; padding: 22px 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border-radius: 28px 28px 0 0; background: #FFFDF6; line-height: 1.6; animation: jr-in .35s ease both;
}
.jr-sheet-close { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; min-inline-size: 42px; block-size: 42px; font-size: 18px; }
.jr-sheet-title { margin: 2px 0 8px; font-size: 22px; font-weight: 900; }
.jr-sheet-sub { margin: 12px 0 0; font-weight: 900; }
.jr-sheet-list { margin: 6px 0; padding-inline-start: 22px; }
.jr-sheet-list li { margin-block: 4px; }
.jr-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 14px; }
.jr-chip { padding: 8px 14px; border: 2px solid #E4EEF5; border-radius: 999px; background: #fff; font: inherit; font-weight: 800; cursor: pointer; }

/* ---------- wide screens: HUD in the corner, the world stays big ---------- */
@media (min-width: 900px) {
  .jr-top { padding-inline: 24px; }
  .jr-title { flex: 0 1 auto; }
  .jr-top .jr-stars { margin-inline-start: auto; }
  .jr-bottom {
    inset-inline: auto; inset-inline-start: 24px; inset-block-end: 20px; inline-size: 440px; padding: 0;
    background: none;
  }
  .jr-say-text { font-size: 19px; }
  .jr-hint { display: block; }
  .jr-bottom:not(.is-choosing) .jr-hint { display: block; }
  .jr-pill { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .jr * { animation: none !important; }
}

/* phones: a compact card so the world stays in view (the lesson line is in «للكبار») */
@media (max-width: 899px) {
  .jr-bottom { gap: 8px; }
  .jr-say { padding: 8px 12px; }
  .jr-say-owl { font-size: 24px; }
  .jr-say-text { font-size: 16px; line-height: 1.45; }
  .jr-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; padding: 10px 14px; }
  .jr-card > * { grid-column: 1; }
  .jr-card-title { font-size: 20px; margin: 2px 0; }
  .jr-card-icon { inline-size: 36px; block-size: 36px; font-size: 20px; }
  .jr-card-plan { font-size: 13px; justify-self: start; }
  .jr-card-lesson { display: none; }
  .jr-card-again { grid-column: 2; grid-row: 1 / span 3; margin: 0; padding: 8px 12px; font-size: 14px; }
  .jr-arrow { inline-size: 58px; min-block-size: 58px; font-size: 22px; }
  .jr-go { min-block-size: 58px; font-size: 18px; padding: 10px 14px; }
}
