/* General English A1 — home (index.html → dashboard.js), on top of ge.css and pages.css. The same light ground and
   white cards as the title page; lime for "do this next" only, teal for progress. Arabic text never moves: only the stage cards (English and numbers),
   the unit drawings, bars, rings and numbers animate. */

:root {
  /* the title page's names, mapped onto ge.css's tokens */
  --bg: var(--paper); --surface: var(--band); --surface-2: var(--line-2); --muted: var(--ink-2);
  --accent: var(--yellow); --accent-ink: var(--ink); --teal: var(--purple); --c-blue: var(--blue); --c-orange: var(--orange);
  --step-small: 14px; --step-body: clamp(1rem, .96rem + .2vw, 1.0625rem); --step-lead: clamp(1.25rem, 1.1rem + .7vw, 1.625rem);
}

/* ---------- hero: the unit you're in, its next lesson, and its stages as a fanned deck (white, like every card) ---------- */
.d-hero {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: clamp(16px, 3vw, 40px);
  min-height: 440px; padding: clamp(28px, 4vw, 56px) clamp(28px, 4vw, 56px) clamp(20px, 3vw, 40px); border-radius: 28px; overflow: hidden; background: var(--card);
}
.d-hero__text { display: flex; flex-direction: column; gap: 22px; justify-content: center; }
.d-kicker { display: inline-flex; align-items: center; gap: 10px; align-self: flex-start; font-size: var(--step-small); color: var(--muted); }
.d-kicker i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
/* wide screens: the unit label sits on the deck heading's line (same height as its pill, same -12px lift),
   the title, next lesson and progress stay centred in the space below */
@media (min-width: 761px) {
  .d-kicker { min-height: 40px; margin-block: -12px auto; }
  .d-prog { margin-block-end: auto; }
}
.d-hero h1 { font-family: var(--font-head); font-weight: 700; font-size: clamp(2.6rem, 1.3rem + 3.4vw, 4.75rem); line-height: 1.3; word-spacing: .05em; text-wrap: balance; }

.d-next {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 10px; border-radius: 20px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color .25s;
}
.d-next:hover { background: var(--surface); }
.d-next__ico { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.d-next__ico svg { width: 22px; height: 22px; }
.d-next__t { display: grid; gap: 2px; min-width: 0; }
.d-next__t small { font-size: var(--step-small); color: var(--muted); }
.d-next__t b { font-weight: 500; font-size: var(--step-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-next .btn { gap: 8px; }
.d-next .btn svg { width: 18px; height: 18px; }

.d-prog { display: flex; align-items: center; gap: 14px; font-size: var(--step-small); color: var(--muted); }
.d-ticks { display: flex; gap: 5px; }
.d-ticks i { width: 26px; height: 8px; border-radius: 99px; background: var(--surface); transform-origin: right; }
.d-ticks i.on { background: var(--ink); }
.d-ticks i.is-next { background: var(--accent); box-shadow: inset 0 0 0 1.5px var(--ink); }

/* the deck: placed by fan() in dashboard.js (GSAP when motion is on), a soft lime glow under it,
   and a still heading over it (Arabic never moves) */
.d-deck { position: relative; min-height: 400px; margin-block: -12px; }
.d-deck::before {
  content: ""; position: absolute; inset: 22% 4% -18%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(218, 250, 156, .75), rgba(218, 250, 156, 0));
}
.d-fan { position: absolute; inset: 0; touch-action: pan-y; }
.d-deck__head { position: absolute; z-index: 60; top: 0; inset-inline: 0; display: flex; align-items: center; gap: 10px; }
.d-deck__head h2 { font-family: var(--font-head); font-weight: 700; font-size: var(--step-lead); line-height: 1.4; }
.d-deck__head .num { color: var(--muted); font-size: var(--step-small); }
.d-deck__head .d-pill { margin-inline-start: auto; }
.d-dcard {
  --w: clamp(150px, 13vw, 196px);
  position: absolute; left: 50%; bottom: 4%; width: var(--w); aspect-ratio: 4 / 5; margin-left: calc(var(--w) / -2);
  display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 20px; text-align: left;
  background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line), 0 22px 40px -26px rgba(var(--shade), .45);
  transform-origin: 50% 100%; will-change: transform;
}
.d-dcard[data-tone="lime"] { background: var(--accent); box-shadow: 0 0 0 1.5px var(--ink), 0 26px 44px -24px rgba(var(--shade), .5); }
.d-dcard[data-tone="sun"] { background: var(--sun); box-shadow: 0 22px 40px -26px rgba(var(--shade), .45); }
.d-dcard[data-tone="teal"] { background: var(--teal); color: #fff; box-shadow: 0 22px 40px -26px rgba(var(--shade), .45); }
.d-dcard[data-tone="blue"] { background: var(--c-blue); color: #fff; box-shadow: 0 22px 40px -26px rgba(var(--shade), .45); }
.d-dcard[data-tone="orange"] { background: var(--c-orange); color: #fff; box-shadow: 0 22px 40px -26px rgba(var(--shade), .45); }
.d-dcard__top { display: flex; align-items: flex-start; justify-content: space-between; }
.d-dcard__top b { font-size: 2rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
.d-dcard__tick { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; }
.d-dcard__tick svg { width: 14px; height: 14px; }
.d-dcard__next { padding: 3px 10px; border-radius: 99px; background: var(--ink); color: var(--accent); font-size: .75rem; font-weight: 500; }
.d-dcard__t { font-weight: 500; font-size: .9375rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.d-dcard { overflow: hidden; }
.d-dcard > :not(.art) { position: relative; z-index: 1; }
.d-dcard__t { font-size: 1rem; font-weight: 700; line-height: 1.2; -webkit-line-clamp: 2; margin-top: 6px; }
.d-dcard__lock { width: 26px; height: 26px; display: grid; place-items: center; opacity: .6; }
.d-dcard__lock svg { width: 18px; height: 18px; }
.d-dcard__bar { display: block; height: 6px; margin-top: 8px; border-radius: 99px; background: rgba(var(--shade), .12); overflow: hidden; }
.d-dcard__bar i { display: block; height: 100%; border-radius: inherit; background: var(--ink); }
/* the unit's drawing runs off the card's bottom edge, like the unit tiles */
.d-dcard__n { display: grid; line-height: 1; }
.d-dcard__n small { font-size: .75rem; font-weight: 500; opacity: .7; margin-bottom: 4px; }
.d-dcard .art { position: absolute; z-index: 0; width: 92%; height: auto; left: 4%; bottom: -26%; pointer-events: none; }
.d-dcard[data-tone="white"] .art { --a: var(--sun) !important; }
.d-dcard[data-tone="lime"] .art, .d-dcard[data-tone="sun"] .art { --a: #fff !important; }
.d-dcard[data-tone="teal"] .art, .d-dcard[data-tone="blue"] .art, .d-dcard[data-tone="orange"] .art { --a: var(--yellow) !important; }
.d-dcard[aria-disabled="true"] .art { opacity: .4; }

/* ---------- body: the unit's stages, and today beside them ---------- */
.d-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.d-card { border-radius: 24px; background: var(--card); padding: clamp(20px, 2.4vw, 32px); }
.d-head { display: flex; align-items: center; gap: 12px; margin-block-end: 18px; }
.d-head h2 { font-family: var(--font-head); font-weight: 700; font-size: var(--step-lead); line-height: 1.4; }
.d-head .num { color: var(--muted); font-size: var(--step-small); }
.d-head__end { margin-inline-start: auto; }
.d-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--surface); font-size: var(--step-small); font-weight: 500; transition: background-color .2s; }
.d-pill:hover { background: var(--surface-2); }
.d-pill svg { width: 16px; height: 16px; }

/* below the hero, three colours only: grey = not yet, teal = progress and done, lime = do this next */
/* stages: number · icon · name · state, the icons joined by a thin line (teal where it's walked) */
.d-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.d-step a, .d-step > span {
  display: grid; grid-template-columns: 2.4em 48px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  min-height: 68px; padding: 8px 14px; border-radius: 18px; transition: background-color .2s;
}
.d-step a:hover { background: var(--bg); }
.d-step__n { font-size: var(--step-small); font-weight: 500; color: var(--ink-3); text-align: center; }
.d-step__ico { position: relative; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--sunk); color: var(--icon); }
.d-step.is-done .d-step__ico { background: var(--purple-soft); color: var(--teal); }
.d-step__ico svg { width: 20px; height: 20px; }
.d-step:not(:last-child) .d-step__ico::after {
  content: ""; position: absolute; top: calc(100% + 4px); left: 50%; width: 2px; height: 22px; margin-left: -1px; border-radius: 2px; background: var(--line);
}
.d-step.is-done:not(:last-child) .d-step__ico::after { background: var(--purple-line); }
.d-step__tick { position: absolute; inset-block-start: -6px; inset-inline-end: -6px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--teal); color: var(--on-purple); border: 2.5px solid #fff; }
.d-step__tick svg { width: 11px; height: 11px; }
.d-step__t { display: grid; min-width: 0; }
.d-step__t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-step.is-next a { background: var(--accent); }
.d-step.is-next .d-step__ico { background: var(--card); color: var(--ink); box-shadow: 0 6px 14px -8px rgba(var(--shade), .4); }
.d-step.is-next .d-step__n { color: #3d4a24; }
.d-step__go {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 18px; border-radius: 999px;
  background: var(--card); color: var(--ink); font-size: var(--step-small); font-weight: 500; box-shadow: 0 6px 14px -8px rgba(var(--shade), .4);
  transition: box-shadow .2s;
}
.d-step a:hover .d-step__go { box-shadow: 0 10px 18px -8px rgba(var(--shade), .45); }
.d-step__go svg { width: 14px; height: 14px; }
.d-stars { display: flex; gap: 3px; color: var(--line); }
.d-stars svg { width: 18px; height: 18px; }
.d-stars .on { color: var(--teal); }
.d-dcard .d-stars .on { color: currentColor; }
.d-step.is-locked { color: var(--ink-3); }

/* hover: the tile lifts and its icon tips, the arrow leans the RTL way, the stars pop in turn. Text stays still */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .d-step__ico { transition: translate .4s var(--ease), background-color .25s, box-shadow .3s; }
  .d-step__ico > svg { transition: rotate .45s cubic-bezier(.34, 1.56, .64, 1), scale .45s cubic-bezier(.34, 1.56, .64, 1); }
  .d-step__n { transition: color .2s; }
  .d-step a:hover .d-step__ico { translate: 0 -3px; background: var(--card); box-shadow: 0 10px 18px -10px rgba(var(--shade), .35); }
  .d-step.is-done a:hover .d-step__ico { background: var(--purple-hover); }
  .d-step a:hover .d-step__ico::after { height: 25px; }
  .d-step a:hover .d-step__ico > svg { rotate: -10deg; scale: 1.15; }
  .d-step a:hover .d-step__n { color: var(--ink); }
  .d-step.is-next a:hover .d-step__n { color: #3d4a24; }
  .d-step__tick { transition: scale .4s cubic-bezier(.34, 1.56, .64, 1); }
  .d-step a:hover .d-step__tick { scale: 1.15; }
  .d-step__go { transition: box-shadow .2s, translate .35s var(--ease); }
  .d-step__go svg { transition: translate .35s cubic-bezier(.34, 1.56, .64, 1); }
  .d-step a:hover .d-step__go { translate: 0 -2px; }
  .d-step a:hover .d-step__go svg { translate: -3px -3px; }
  .d-stars i { display: grid; transition: scale .35s cubic-bezier(.34, 1.56, .64, 1); }
  .d-stars i:nth-child(2) { transition-delay: .05s; }
  .d-stars i:nth-child(3) { transition-delay: .1s; }
  .d-step a:hover .d-stars i { scale: 1.2; }
  .d-step a:active .d-step__ico { translate: 0 -1px; transition-duration: .1s; }
}

/* today: the goal ring and the week */
.d-side { display: grid; gap: 20px; }
.d-today { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: center; }
.d-today .d-head { grid-column: 1 / -1; margin: 0; }
.d-ring { position: relative; width: 112px; height: 112px; }
.d-ring svg { width: 100%; height: 100%; }
.d-ring__n { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.d-ring__n b { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.d-ring__n small { font-size: var(--step-small); color: var(--muted); }
.d-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 112px; }
.d-week div { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; text-align: center; font-size: .6875rem; color: var(--muted); }
.d-week span { position: relative; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.d-week span i { position: absolute; inset: auto 0 0; height: var(--h); border-radius: inherit; background: var(--purple-line); transform-origin: bottom; }
.d-week .is-today { color: var(--teal); font-weight: 700; }
.d-week .is-today span { box-shadow: inset 0 0 0 1.5px var(--purple-line); }
.d-week .is-today span i { background: var(--teal); }

/* to review: one row each, a grey icon, the number big */
.d-rev { padding: 10px; display: grid; }
.d-rev a { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px; border-radius: 18px; transition: background-color .2s; }
.d-rev a + a { position: relative; }
.d-rev a + a::before { content: ""; position: absolute; top: 0; inset-inline: 74px 12px; height: 1px; background: var(--line); }
.d-rev a:hover { background: var(--bg); }
.d-rev a:hover::before, .d-rev a:hover + a::before { opacity: 0; }
.d-rev__ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--sunk); color: var(--icon); }
.d-rev__ico svg { width: 20px; height: 20px; }
.d-rev__n { display: flex; align-items: baseline; gap: 10px; }
.d-rev__n b { font-size: 2.25rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.d-rev__n span { color: var(--muted); font-size: var(--step-small); }
.d-go { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--muted); transition: background-color .2s, color .2s; }
.d-rev a:hover .d-go { background: var(--purple-soft); color: var(--teal); }
.d-go svg { width: 16px; height: 16px; }

/* rank: the medal and the bar to the next rank */
.d-rank { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; transition: background-color .2s; }
.d-rank:hover { background: #fdfdfd; }
.d-rank .badge { width: 76px; height: 76px; }
.d-rank__t { display: grid; gap: 8px; }
.d-rank__t b { font-family: var(--font-head); font-size: var(--step-lead); line-height: 1.3; }
.d-rank__t small { color: var(--muted); font-size: var(--step-small); }
.d-rank__bar { display: block; height: 8px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.d-rank__bar i { display: block; height: 100%; border-radius: inherit; background: var(--teal); transform-origin: right; }

@media (max-width: 1080px) {
  .d-grid { grid-template-columns: 1fr; }
  .d-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .d-side .d-today { grid-column: 1 / -1; }
}
/* phones: the deck leads the hero (colour first, no heading: the tab bar has الوحدات), then the title on one line,
   the next lesson and a full-width progress row, so the first screen isn't a column of short lines and white space */
@media (max-width: 760px) {
  .d-hero { grid-template-columns: 1fr; min-height: 0; padding: 12px 20px 22px; border-radius: 24px; gap: 16px; }
  .d-hero__text { gap: 16px; }
  .d-hero h1 { font-size: clamp(2rem, 8.5vw, 2.5rem); line-height: 1.25; text-wrap: wrap; }   /* Safari's balance splits two-word titles */
  .d-next { grid-template-columns: auto minmax(0, 1fr); }
  .d-next .btn { grid-column: 1 / -1; width: 100%; }
  .d-prog { gap: 12px; }
  .d-ticks { flex: 1; }
  .d-ticks i { flex: 1; width: auto; }
  .d-deck { order: -1; min-height: 250px; margin: 0 -10px; }
  .d-deck::before { inset: 30% 6% 0; }
  .d-deck__head { display: none; }
  .d-dcard { --w: 132px; padding: 12px; bottom: 40px; border-radius: 16px; }
  .d-dcard__top b { font-size: 1.5rem; }
  .d-dcard__t { font-size: .8125rem; }
  .d-side { grid-template-columns: 1fr; }
  .d-step a, .d-step > span { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding-inline: 8px; }
  .d-step__n { display: none; }
  .d-step__ico { width: 40px; height: 40px; border-radius: 12px; }
}
