/* يوسف في نيويورك — companion site. Palette and type from the show's style guide (Bean People v2). */
:root {
  color-scheme: light;
  --ink: #2A2742; --cream: #FFF6E8; --sky: #9BD3EC; --red: #E8483A; --navy: #2E3D7C;
  --mustard: #F5B63E; --teal: #1E9D93; --leaf: #69B464; --shade: #6F62A8; --rust: #C24A28;
  --paper: #FFFDF8; --ink-60: rgba(42,39,66,.6); --ink-30: rgba(42,39,66,.3); --ink-12: rgba(42,39,66,.12);
  --sky-pastel: #DDEFF8; --mustard-pastel: #FBE3AE; --leaf-pastel: #DCEFD8; --red-pastel: #FAD3CF; --teal-pastel: #CFE9E6;
  --shadow: 0 6px 0 rgba(111,98,168,.16);
  --ar: "Baloo Bhaijaan 2", "Noto Naskh Arabic", system-ui, sans-serif;
  --en: "Fredoka", "Baloo Bhaijaan 2", system-ui, sans-serif;
  --display: "Lalezar", "Baloo Bhaijaan 2", sans-serif;
  --tab: "Lilita One", "Fredoka", sans-serif;
  --gutter: 16px; --radius: 22px; --maxw: 720px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); background: var(--cream);
  background-image: repeating-linear-gradient(to bottom, transparent 0 39px, rgba(111,98,168,.07) 39px 40px);
  font-family: var(--ar); font-weight: 500; font-size: 18px; line-height: 1.55; overflow-x: hidden;
}
body, main, header, footer, section { direction: rtl; }
.en, [dir="ltr"] { direction: ltr; unicode-bidi: isolate; font-family: var(--en); }
bdi, .num { unicode-bidi: isolate; }
a { color: var(--navy); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* ---- top bar ---- */
.bar { position: sticky; top: 0; z-index: 5; background: rgba(255,246,232,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--ink-12); }
.bar .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.bar .back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; text-decoration: none; font-weight: 700; color: var(--navy); white-space: nowrap; }
.bar .title { flex: 1; text-align: center; font-weight: 800; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .meta { font-family: var(--en); font-weight: 600; color: var(--navy); white-space: nowrap; direction: ltr; unicode-bidi: isolate; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 22px; border-radius: 999px;
  border: 0; background: var(--navy); color: var(--cream); font-weight: 800; font-size: 19px; text-decoration: none;
  box-shadow: 0 4px 0 rgba(42,39,66,.25); transition: transform .12s, box-shadow .12s, background .15s; user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(42,39,66,.25); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.mustard { background: var(--mustard); color: var(--ink); box-shadow: 0 4px 0 #C98E1E; }
.btn.teal { background: var(--teal); box-shadow: 0 4px 0 #157A72; }
.btn.red { background: var(--red); box-shadow: 0 4px 0 #B3352A; }
.btn.ghost { background: var(--paper); color: var(--navy); box-shadow: 0 4px 0 var(--ink-12); border: 2px solid var(--ink-12); }
.btn.wide { width: 100%; }
.btn.big { min-height: 60px; font-size: 21px; }
.btn.icon { min-width: 52px; padding: 10px; }

/* ---- cards ---- */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.tab { display: inline-block; font-family: var(--tab); letter-spacing: .06em; font-size: 14px; padding: 4px 12px 3px; border-radius: 999px; background: var(--navy); color: var(--cream); direction: ltr; }
.tab.mia { background: var(--rust); }              /* Sara, as in the episodes */
.tab.lopez { background: #17766F; }               /* Mrs. Lopez (episode 3), the episode's tab colour */
.tab.ana { background: #A8323F; }                 /* Ana (episode 4) */
.tab.ar { font-family: var(--ar); font-weight: 800; letter-spacing: 0; direction: rtl; }

/* ---- bean canvas ---- */
canvas.bean { display: block; width: 120px; height: 140px; }

/* ---- speech bubble (Fredoka, like the show) ---- */
.bubble {
  position: relative; background: var(--paper); border-radius: 22px; padding: 12px 16px; box-shadow: 0 4px 0 rgba(111,98,168,.18);
  font-family: var(--en); font-weight: 600; font-size: 22px; line-height: 1.25; direction: ltr; text-align: left; color: var(--ink); min-width: 120px;
}
.bubble .tab { position: absolute; top: -12px; left: 14px; }
.bubble::after { content: ""; position: absolute; top: 50%; inset-inline-end: -12px; width: 18px; height: 18px; background: var(--paper); border-radius: 3px; transform: translateY(-50%) rotate(45deg); }
.bubble.tail-left::after { inset-inline-end: auto; inset-inline-start: -8px; }
.hi { background: rgba(245,182,62,.55); border-radius: 8px; padding: 0 4px; }
.bubble .gap { min-width: 1.6em; border-bottom-width: 3px; }

/* ---- chips (answer buttons) ---- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.chips.col { flex-direction: column; }
.chip {
  min-height: 52px; padding: 10px 18px; border-radius: 999px; border: 2px solid var(--ink-12); background: var(--paper); color: var(--ink);
  font-weight: 700; font-size: 19px; box-shadow: 0 3px 0 var(--ink-12); transition: transform .12s, background .15s, border-color .15s; text-align: start;
}
.chip.en { font-family: var(--en); font-weight: 600; font-size: 21px; direction: ltr; }
.chips.col .chip { width: 100%; }
.chip:hover { border-color: var(--navy); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink-12); }
.chip.correct { background: var(--leaf-pastel); border-color: var(--leaf); box-shadow: 0 3px 0 var(--leaf); }
.chip.wrong { background: var(--red-pastel); border-color: var(--red); animation: shake .4s; }
.chip.used { opacity: .35; transform: scale(.96); }
.chip:disabled { cursor: default; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }

/* ---- sentences ---- */
.sentence { font-family: var(--en); font-weight: 600; font-size: 30px; line-height: 1.35; direction: ltr; text-align: center; margin: 10px 0; color: var(--ink); }
.bad:not(.feedback) { text-decoration: underline wavy var(--red); text-decoration-thickness: 3px; text-underline-offset: 7px; text-decoration-skip-ink: none; }
.fixed { background: rgba(245,182,62,.5); border-radius: 10px; padding: 0 6px; }
.gap { display: inline-block; min-width: 2.2em; border-bottom: 4px solid var(--navy); margin: 0 4px; color: var(--navy); line-height: 1.1; }
.gap.filled { border-color: var(--mustard); }
.hint { color: var(--ink-60); font-size: 16px; text-align: center; }
.ar-under { text-align: center; color: var(--ink-60); font-size: 17px; }

/* order tiles */
.slots { display: flex; flex-wrap: wrap; gap: 8px; min-height: 64px; padding: 10px; border-radius: 16px; background: var(--sky-pastel); direction: ltr; justify-content: center; align-items: center; margin-top: 12px; }
.slots:empty::before { content: "tap the words in order ↓"; color: var(--ink-30); font-family: var(--en); font-size: 16px; }
.tiles { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; direction: ltr; margin-top: 14px; }
.tile { min-height: 50px; padding: 8px 16px; border-radius: 14px; border: 2px solid var(--ink-12); background: var(--paper); font-family: var(--en); font-weight: 600; font-size: 22px; box-shadow: 0 3px 0 var(--ink-12); direction: ltr; }
.tile.in-slot { background: var(--paper); border-color: var(--navy); }
.tile:active { transform: translateY(2px); box-shadow: none; }
.tile.ghost { opacity: .22; border-style: dashed; box-shadow: none; color: transparent; pointer-events: none; }
.slots.correct { background: var(--leaf-pastel); }
.slots.wrong { background: var(--red-pastel); animation: shake .4s; }

/* ---- play button ---- */
.play { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; min-width: 64px; padding: 0 24px; border-radius: 999px; border: 0; background: var(--teal); color: var(--cream); font-weight: 800; font-size: 19px; box-shadow: 0 4px 0 #157A72; }
.play.small { min-height: 44px; min-width: 44px; padding: 0 14px; font-size: 16px; }
.play svg { width: 26px; height: 26px; fill: currentColor; }
.play.playing { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* ---- exercise page layout ---- */
.ex-wrap { padding-bottom: 150px; }
.dots { display: flex; gap: 5px; align-items: center; justify-content: center; flex: 1; direction: ltr; }
.dots i { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-30); transition: transform .2s, background .2s; }
.dots i.done { background: var(--leaf); border-color: var(--leaf); }
.dots i.miss { background: var(--red); border-color: var(--red); }
.dots i.cur { background: var(--mustard); border-color: var(--mustard); transform: scale(1.5); }
.stage { display: flex; gap: 10px; align-items: flex-end; margin: 14px 0 8px; min-height: 150px; }
.stage .bubble { flex: 1; margin-bottom: 38px; max-width: 100%; }
.stage canvas.bean { flex: none; width: 134px; height: 142px; }
.kind { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--navy); font-size: 17px; margin-bottom: 8px; }
.kind .n { font-family: var(--tab); background: var(--mustard); color: var(--ink); border-radius: 999px; padding: 2px 10px 0; font-size: 14px; direction: ltr; }
.context { background: var(--sky-pastel); border-radius: 14px; padding: 8px 14px; font-size: 16px; margin-bottom: 8px; }
.context .en { display: inline-block; }   /* an English line moves to the next line whole instead of breaking across the Arabic */
.prompt { font-weight: 800; font-size: 20px; margin-bottom: 6px; }

.feedback { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px var(--gutter) max(14px, env(safe-area-inset-bottom)); background: var(--paper); border-top: 3px solid var(--ink-12); box-shadow: 0 -8px 24px rgba(42,39,66,.08); transform: translateY(110%); visibility: hidden; transition: transform .25s, visibility .25s; }
.feedback.show { transform: none; visibility: visible; }
.feedback .inner { max-width: var(--maxw); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.feedback.ok { background: var(--leaf-pastel); border-top-color: var(--leaf); }
.feedback.bad { background: var(--red-pastel); border-top-color: var(--red); }
.feedback .head { font-weight: 800; font-size: 21px; }
.feedback .why { font-size: 16px; color: var(--ink); }
.feedback .why .en { font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .feedback, .chip, .btn, .dots i { transition: none; } .chip.wrong, .slots.wrong, .play.playing { animation: none; } }

/* countdown ring */
.ring { position: relative; width: 120px; height: 120px; margin: 10px auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.ring .bg { stroke: var(--ink-12); }
.ring .fg { stroke: var(--mustard); stroke-dasharray: 314; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.ring .n { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--tab); font-size: 48px; color: var(--navy); }
.mic { display: inline-flex; align-items: center; gap: 8px; }
.listening { color: var(--red); font-weight: 800; }

/* ---- end screen ---- */
.end { text-align: center; padding: 10px 0 30px; }
.end .stars { font-size: 44px; letter-spacing: 6px; direction: ltr; margin: 6px 0; }
.end .stars .off { opacity: .25; filter: grayscale(1); }
.end .score { font-size: 22px; font-weight: 800; }
.end .learned { text-align: start; margin-top: 16px; }
.end .learned li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--ink-12); }
.end .learned .en { font-weight: 600; font-size: 20px; }
.end .learned .ar { color: var(--ink-60); font-size: 15px; }
.end .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.end canvas.bean { width: 190px; height: 180px; margin: 0 auto; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; }

/* ---- home ---- */
.hero { background: linear-gradient(180deg, #BFE2F2 0%, var(--sky-pastel) 70%, #F3E6CF 70%, #F3E6CF 100%); border-radius: 0 0 36px 36px; padding: 18px 0 0; overflow: hidden; position: relative; }
.hero .wrap { display: grid; grid-template-columns: 1fr; gap: 8px; position: relative; z-index: 1; }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: 46px; color: var(--navy); text-align: center; letter-spacing: .01em; }
.hero .sub { text-align: center; font-size: 18px; color: var(--ink); font-weight: 700; }
.hero .sub .sub-en { white-space: nowrap; }
.hero .sub .en { color: var(--rust); white-space: nowrap; }
.hero .beans { display: flex; justify-content: center; align-items: flex-end; gap: 0; margin-top: 10px; direction: ltr; }
.hero .beans canvas.bean { width: 166px; height: 180px; }   /* ≈ 1.27 H wide: room for the A3 arms (a wave, a shrug) */
.hero .cloud { position: absolute; background: #fff; border-radius: 999px; opacity: .85; z-index: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.stat { background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; text-align: center; }
.stat .big { font-family: var(--tab); font-size: 30px; color: var(--navy); direction: ltr; }
.stat .lbl { font-size: 15px; color: var(--ink-60); }
.review-card { margin-top: 12px; display: flex; align-items: center; gap: 14px; }
.review-card .txt { flex: 1; }
.review-card h2 { font-size: 20px; }
.review-card p { color: var(--ink-60); font-size: 15px; }
.unit { margin-top: 24px; }
.unit h2 { font-size: 20px; }
.unit .ptitle { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.unit .pbar { height: 12px; border-radius: 999px; background: var(--ink-12); overflow: hidden; margin: 8px 0 4px; direction: ltr; }
.unit .pbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--leaf)); border-radius: 999px; width: 0; transition: width .6s; }
.eps { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 14px; }
.ep { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: center; background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); padding: 14px; text-decoration: none; color: var(--ink); position: relative; }
.ep .thumb { width: 76px; height: 76px; border-radius: 18px; display: grid; place-items: center; font-family: var(--tab); font-size: 26px; color: var(--ink); position: relative; direction: ltr; }
.ep .thumb small { font-size: 13px; display: block; letter-spacing: .08em; }
.ep .t-en { font-family: var(--en); font-weight: 600; font-size: 21px; direction: ltr; text-align: start; }
.ep .t-ar { font-weight: 800; font-size: 17px; }
.ep .blurb { font-size: 14px; color: var(--ink-60); }
.ep .stars { direction: ltr; font-size: 15px; letter-spacing: 2px; }
.ep .stars .off { opacity: .25; filter: grayscale(1); }
.ep.locked { opacity: .6; filter: saturate(.3); }
.ep.locked .soon { position: absolute; bottom: 12px; inset-inline-end: 12px; background: var(--ink); color: var(--cream); font-size: 13px; padding: 2px 10px; border-radius: 999px; font-weight: 800; }
.ep .cta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-weight: 800; color: var(--navy); font-size: 15px; }
footer.site { text-align: center; color: var(--ink-60); font-size: 14px; padding: 30px 0 40px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--cream); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (min-width: 700px) {
  :root { --gutter: 24px; }
  .hero h1 { font-size: 60px; }
  .hero .beans canvas.bean { width: 232px; height: 228px; }
  .eps { grid-template-columns: 1fr 1fr; }
  .stage canvas.bean { width: 176px; height: 180px; }
  .stage .bubble { font-size: 26px; }
  .sentence { font-size: 36px; }
  .end .actions { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .end .actions .btn { flex: 1 1 200px; }
}
