/* Topics and goals (js/explore.js): the topics and goals pages, topic, situation, interest, goal and skill pages,
   and the topic practice. Built on the design system (css/ui-kit.css, docs/design-system.md): .ds-card, .ds-tile,
   .ds-grid, .ds-head, .ds-progress, .chip, .seg and the tokens. This sheet loads before ui-kit.css, so a rule that
   reshapes one of those shared classes names both classes (.ds-card.x-hero) to win over the shared rule.
   Rules that only change looks are wrapped in :where(html:not(.a11y-contrast)), as the design system asks. */
.x-page { display: grid; gap: var(--sp-6); min-width: 0; }
.x-page h1 { margin: 0; }
.x-sec { display: grid; gap: var(--sp-3); min-width: 0; }
.x-sec > h2 { margin: 0; font-size: var(--fs-h3); }
.ds-head.x-sec-head { margin: 0; }
.x-sec-head p { margin: 2px 0 0; }
.x-bar { display: block; margin: 6px 0 4px; max-width: 320px; }

/* the hero of both ways in: the cat beside the title, everything else spans the card */
.ds-card.x-hero { position: relative; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-3) var(--sp-4); overflow: hidden; }
:where(html:not(.a11y-contrast)) .ds-card.x-hero { border-radius: var(--r-xl); background: linear-gradient(150deg, var(--accent-soft), var(--surface) 58%); }
.x-hero h1 { grid-column: 1; grid-row: 1; font-size: var(--fs-display); }
.x-hero > :not(h1, .x-hero-cat) { grid-column: 1 / -1; }
.x-hero .lead { margin: 0; max-width: 62ch; }
.x-hero-cat { grid-column: 2; grid-row: 1; width: 96px; height: 96px; object-fit: cover; object-position: 50% 30%; border-radius: var(--r-lg); }
:where(html:not(.a11y-contrast)) .x-hero-cat { border: 3px solid var(--surface); box-shadow: var(--e3); background: var(--surface-2); transform: rotate(3deg); }

/* the switch between the two ways in */
.seg.x-switch { display: flex; width: max-content; max-width: 100%; }
.seg.x-switch button { min-height: 42px; padding-inline: 1.2em; font-size: .95rem; }

/* search */
.x-search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-radius: var(--r-pill); min-height: 50px; }
:where(html:not(.a11y-contrast)) .x-search { background: var(--surface); border: 1px solid var(--hairline-strong); box-shadow: var(--e1); }
:where(html:not(.a11y-contrast)) .x-search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.x-search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.x-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 500 1rem var(--font-ui); padding: 12px 0; }
.x-search input::placeholder { color: var(--faint); }
.x-results { display: grid; gap: 10px; }
.x-results:empty { display: none; }

/* "how much time do you have?" */
.ds-card.x-time { gap: var(--sp-3); }
.x-time-h { margin: 0; font-size: var(--fs-h3); }
.x-time-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#x-time-box:empty { display: none; }
#x-time-box { display: grid; gap: 8px; }
#x-time-box > p { margin: 0; }
.x-acts, .x-start { display: grid; gap: 8px; }
.x-act { appearance: none; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 14px; cursor: pointer; text-align: start;
  font: 600 .98rem/1.3 var(--font-ui); color: var(--ink); border-radius: var(--r); }
:where(html:not(.a11y-contrast)) .x-act { background: var(--surface-2); border: 1px solid transparent; transition: border-color var(--dur-1), background-color var(--dur-1); }
:where(html:not(.a11y-contrast)) .x-act:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.x-act > span:first-child { font-size: 1.35rem; line-height: 1; flex: none; }
.x-act > span:last-child { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.x-act small { color: var(--muted); font-weight: 400; font-size: var(--fs-sm); }

/* chips (links and choices share the design system's .chip) */
.x-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip.x-chip { display: inline-flex; align-items: center; gap: .35em; text-decoration: none; line-height: 1.2; }
.chip.x-chip small { font-weight: 500; color: var(--muted); }
.chip.x-chip[aria-pressed="true"] small { color: inherit; opacity: .85; }
:where(html:not(.a11y-contrast)) .chip.x-chip:is(.mine, .me) { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }

/* the learner's goal, and the goal cards */
.ds-card.x-mygoal { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--sp-3) var(--sp-4); }
:where(html:not(.a11y-contrast)) .ds-card.x-mygoal { background: linear-gradient(150deg, var(--ok-soft), var(--surface) 70%); }
:where(html:not(.a11y-contrast)) .ds-card.x-mygoal.soft { background: linear-gradient(150deg, var(--accent-soft), var(--surface) 70%); }
.x-mygoal-txt { display: grid; gap: 2px; min-width: 0; }
.x-mygoal-txt p { margin: 0; }
.x-mygoal-txt strong { font-size: var(--fs-lg); font-weight: 700; }
.x-mygoal-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.x-goal-ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--r); font-size: 1.7rem; line-height: 1; flex: none; background: var(--accent-soft); }
.x-goal-ic.big { width: 76px; height: 76px; border-radius: var(--r-lg); font-size: 2.5rem; }
.ds-grid.x-goals { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--sp-3); }
.ds-card.x-goal { display: flex; align-items: flex-start; gap: 14px; min-width: 0; }
:where(html:not(.a11y-contrast)) .ds-card.x-goal.mine { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.x-goal-txt { display: grid; gap: 4px; min-width: 0; }
.x-goal-txt strong { font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.x-goal-txt small { font-size: var(--fs-sm); line-height: 1.45; color: var(--muted); }
.x-goal-txt .x-bar { margin: 4px 0 0; }

/* topic and situation tiles: the course's own photos on design system tiles */
.ds-grid.x-tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: var(--sp-3); }
.ds-grid.x-tiles.sm { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.ds-tile.x-tile { padding: var(--sp-3); gap: 6px; }
.ds-tile.x-tile strong { line-height: 1.25; }
.x-tile-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.x-tile-foot { display: grid; gap: 6px; margin-top: auto; }
.x-tile-foot .x-bar { margin: 0; height: 6px; }
.ds-tile.x-tile:hover img { transform: scale(1.03); }
.ds-tile.x-tile img { height: auto; transition: transform var(--dur-3) var(--ease); } /* the height attribute is only a hint for the 16:10 box */

/* skills */
.ds-grid.x-skills { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: var(--sp-3); }
.ds-tile.x-skill { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px; row-gap: 2px; }
.ds-tile.x-skill img { grid-row: span 2; width: 48px; height: 48px; aspect-ratio: auto; object-fit: contain; border-radius: 0; background: none; }
.ds-tile.x-skill small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* loading */
.x-loading { display: grid; justify-items: center; gap: 12px; padding: 48px 16px; text-align: center; color: var(--muted); }
.x-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: x-spin 1s linear infinite; }
@keyframes x-spin { to { transform: rotate(360deg); } }

/* a topic, situation, interest, goal or skill page */
.x-bar-top { display: flex; align-items: center; gap: 10px; }
.ds-card.x-cat-head, .ds-card.x-goal-head { display: flex; align-items: center; gap: 18px; min-width: 0; }
.ds-card.x-goal-head { align-items: flex-start; }
:where(html:not(.a11y-contrast)) .ds-card.x-goal-head { background: linear-gradient(150deg, var(--accent-soft), var(--surface) 65%); }
.x-goal-head > div { display: grid; gap: 6px; min-width: 0; flex: 1; }
.x-goal-head p, .x-cat-txt p { margin: 0; }
.x-cat-img { width: 132px; height: 132px; border-radius: var(--r-lg); object-fit: cover; flex: none; background: var(--surface-2); }
.x-skill-img { width: 72px; height: 72px; flex: none; }
.x-cat-emoji { display: grid; place-items: center; width: 96px; height: 96px; border-radius: var(--r-lg); font-size: 3rem; flex: none; background: var(--accent-soft); }
.x-cat-txt { display: grid; gap: 4px; min-width: 0; }
.x-counts { color: var(--ink); font-weight: 500; }
.x-promise { padding: 10px 12px; border-radius: var(--r-sm); background: var(--ok-soft); color: var(--ink); font-weight: 500; max-width: 62ch; }
.x-cat-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.x-lvs, .x-related { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.x-empty { padding: 24px 16px; text-align: center; border-radius: var(--r-lg); background: var(--surface); }

/* a goal's finish date and pace */
.x-finish { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--rule); }
.x-finish-l { display: grid; gap: 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.x-finish input { min-height: 44px; padding: 0 12px; font: 500 1rem var(--font-ui); color: var(--ink); }
:where(html:not(.a11y-contrast)) .x-finish input { border-radius: var(--r-sm); border: 1px solid var(--hairline-strong); background: var(--surface); box-shadow: var(--e1); }
:where(html:not(.a11y-contrast)) .x-finish input:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.x-pace { flex-basis: 100%; margin: 0; line-height: 1.5; }
.x-pace strong { font-weight: 600; color: var(--ink); }
/* which exam */
.ds-card.x-exam { gap: var(--sp-3); }
.x-exam h2 { margin: 0; font-size: var(--fs-h3); }
.x-exam p { margin: 0; }

/* item rows: lessons, stories, books, dialogues, grammar, videos, café tasks */
.x-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.x-row-btn { appearance: none; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 14px; cursor: pointer; text-align: start;
  font: inherit; color: var(--ink); border-radius: var(--r); border-inline-start: 4px solid var(--lv, var(--accent)); }
:where(html:not(.a11y-contrast)) .x-row-btn { background: var(--surface); border: 1px solid var(--hairline); border-inline-start: 4px solid var(--lv, var(--accent)); box-shadow: var(--e1);
  transition: border-color var(--dur-1), box-shadow var(--dur-2) var(--ease); }
:where(html:not(.a11y-contrast)) .x-row-btn:hover { border-color: var(--accent-line); border-inline-start-color: var(--lv, var(--accent)); box-shadow: var(--e2); }
.x-row-ic { font-size: 1.3rem; line-height: 1; flex: none; width: 1.6em; text-align: center; }
.x-row-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.x-row-main strong { font-weight: 600; overflow-wrap: anywhere; }
.x-row-main strong[dir="ltr"] { font-family: var(--font-target); justify-self: start; }
.x-row-main small { color: var(--ink-2); font-size: var(--fs-sm); justify-self: start; overflow-wrap: anywhere; }
.x-row-meta { color: var(--muted); font-size: var(--fs-xs); }
.x-row-state { flex: none; min-width: 1.6em; display: grid; place-items: center; }
.x-check { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--ok); color: var(--surface); font-weight: 700; font-size: .9rem; }
:where(html:not(.a11y-contrast)) .x-row.done .x-row-btn { background: linear-gradient(170deg, var(--ok-soft), var(--surface) 60%); }
.x-row.locked .x-row-main { opacity: .75; }
.x-lv { border-radius: var(--r-lg); border: 1px solid var(--hairline); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.x-lv > summary { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px; cursor: pointer; font-weight: 600; list-style: none; }
.x-lv > summary::-webkit-details-marker { display: none; }
.x-lv > summary::after { content: '▾'; margin-inline-start: auto; color: var(--muted); transition: transform var(--dur-2); }
.x-lv[open] > summary::after { transform: rotate(180deg); }
.x-lv > .x-rows { padding: 0 10px 10px; }

/* a goal's path */
.x-path { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.x-stage { display: grid; gap: 10px; padding-inline-start: 16px; border-inline-start: 4px solid color-mix(in srgb, var(--lv, var(--accent)) 55%, transparent); }
.x-stage h2 { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--fs-h3); }
.x-stage h2 small { margin-inline-start: auto; font-family: var(--font-ui); }
.x-stage.me { border-inline-start-color: var(--lv, var(--accent)); }

/* a skill: how to practise and can-do per level */
.x-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: x-step; }
.x-steps li { position: relative; display: grid; gap: 6px; justify-items: start; padding: 14px 16px; padding-inline-start: 56px; border-radius: var(--r-lg); counter-increment: x-step; }
:where(html:not(.a11y-contrast)) .x-steps li { background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--e1); }
.x-steps li::before { content: counter(x-step); position: absolute; inset-inline-start: 14px; inset-block-start: 14px; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--accent); color: var(--accent-ink); font: 700 .95rem/1 var(--font-target); }
.x-steps strong { font-size: 1.02rem; }
.x-steps p { margin: 0; line-height: 1.55; color: var(--ink-2); }
.x-cando { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.x-cando li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: var(--r); }
:where(html:not(.a11y-contrast)) .x-cando li { background: var(--surface); border: 1px solid var(--hairline); }
.x-cando li p { margin: 0; }
.x-cando li .lv-chip { flex: none; margin-top: 1px; }
:where(html:not(.a11y-contrast)) .x-cando li.me { border-color: var(--lv, var(--accent)); background: color-mix(in srgb, var(--lv, var(--accent)) 8%, var(--surface)); }
.x-cando li.off { opacity: .6; }

/* topic practice */
.x-quiz .x-opts .opt-l { overflow-wrap: anywhere; }
.x-quiz .prompt.sentence .tgt { font-size: 1.25rem; line-height: 1.5; }
.x-quiz .prompt.sentence .tr { display: block; margin-top: 6px; }
.x-few, .x-result { display: grid; justify-items: center; gap: 12px; padding: 18px 8px; text-align: center; }
.x-few p, .x-result p, .x-result h2 { margin: 0; }
.x-few img, .x-result img { width: 128px; height: 128px; border-radius: var(--r-xl); object-fit: cover; box-shadow: var(--e2); }
.ds-badge.x-gems { font-size: 1rem; padding: .35em .9em; }
.x-result .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.x-qzs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.x-qz { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-lg); min-width: 0; }
:where(html:not(.a11y-contrast)) .x-qz { background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--e1); }
.x-qz img { width: 56px; height: 56px; border-radius: var(--r-sm); object-fit: cover; flex: none; }
.x-qz-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.x-qz .btn { flex: none; }
.x-qz.off img { filter: grayscale(.7); opacity: .7; }

/* home and games cards */
.ds-card.x-home { margin-top: var(--sp-3); gap: 8px; }
.x-home p, .x-home strong { margin: 0; }
.x-home strong { font-size: 1.02rem; }
.x-home .x-bar { margin: 2px 0 0; }
.x-home .chip.x-chip { min-height: 38px; padding: .35em .8em; font-size: .88rem; min-width: 0; }
.x-home .x-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.x-home-all { color: var(--accent); font-weight: 600; text-decoration: none; justify-self: start; }
.x-home-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.g-explore .x-game-art { width: 100%; height: 120px; object-fit: cover; object-position: 50% 26%; border-radius: var(--r); }

@media (max-width: 640px) {
  .x-page { gap: var(--sp-5); }
  .ds-card.x-hero { padding: var(--sp-4); }
  .x-hero h1 { font-size: var(--fs-h1); }
  .x-hero-cat { width: 72px; height: 72px; border-radius: var(--r); }
  .seg.x-switch { width: 100%; }
  .seg.x-switch button { flex: 1; }
  .ds-grid.x-goals { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ds-card.x-goal { flex-direction: column; gap: 8px; padding: 14px 12px; }
  .x-goal .x-goal-ic { width: 44px; height: 44px; font-size: 1.45rem; border-radius: var(--r-sm); }
  .x-goal-lead { display: none; } /* the goal's own page has the full text */
  .ds-grid.x-tiles, .ds-grid.x-tiles.sm { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ds-tile.x-tile { padding: 8px 8px 10px; }
  .ds-tile.x-tile img { aspect-ratio: 4 / 3; }
  .ds-tile.x-tile strong { font-size: .95rem; }
  .x-tile-desc { display: none; }
  .ds-grid.x-skills { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ds-tile.x-skill { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 12px 8px; }
  .ds-tile.x-skill img { grid-row: auto; }
  .ds-card.x-cat-head, .ds-card.x-goal-head { flex-direction: column; align-items: flex-start; padding: var(--sp-4); gap: 12px; }
  .x-cat-img { width: 100%; height: 150px; }
  .x-steps li { padding-inline-start: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .x-row-btn, .x-act, .x-bar span, .ds-tile.x-tile img { transition: none; }
  .ds-tile.x-tile:hover img { transform: none; }
  .x-spin { animation-duration: 3s; }
}
.pref-calm .ds-tile.x-tile:hover img { transform: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.x-hero-cat, .x-cat-img, .x-tile img, .x-qz img, .x-few img, .x-result img, .x-game-art) { filter: brightness(.86); } }
:root[data-theme="dark"] :is(.x-hero-cat, .x-cat-img, .x-tile img, .x-qz img, .x-few img, .x-result img, .x-game-art) { filter: brightness(.86); }
