/* Practice: the subject tree, the topic workspace (source chips, the Filter popover) and the problem cards. */

.topic-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.2px; }

/* ------------------------------------------------------------------ practice tree */
.subjects { display: flex; flex-direction: column; gap: 12px; }

.subject-head {
  width: 100%;
  display: grid;
  grid-template-columns: 20px 1fr auto 170px;
  align-items: center; gap: 14px;
  padding: 16px 20px;
  background: none; border: 0;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius);
}
.subject.static .subject-head { grid-template-columns: 1fr auto; cursor: default; }
.subject-head:hover { background: var(--surface-2); }
.subject.static .subject-head:hover { background: none; }
.chev { width: 18px; height: 18px; color: var(--text-3); vertical-align: 0; transition: transform .15s; }
.subject.open .chev { transform: rotate(90deg); }
.subject-title { font-size: 15px; font-weight: 600; }
.subject-meta { color: var(--text-3); font-size: 13.5px; white-space: nowrap; }
.subject-progress { display: flex; align-items: center; gap: 10px; }
.subject-progress .num { width: 38px; text-align: right; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.meter { position: relative; flex: 1; height: 4px; min-width: 60px; background: var(--border); border-radius: 99px; overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--good); border-radius: 99px; }
.meter.sm { min-width: 48px; }

.subject-body { display: none; padding: 0 20px 14px 54px; }
.subject.open .subject-body { display: block; }

.chapter { padding: 12px 0 6px; border-top: 1px solid var(--border); }
.chapter-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 34px; }
.chapter-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; }
.chapter-head h3 { font-size: 14px; font-weight: 600; }
.chapter-count { font-size: 13px; color: var(--text-3); white-space: nowrap; }

/* A chapter file (workbook, notes) as an icon link; .lock-mark: a small lock while it needs sign-in. */
.file-btn { position: relative; flex: none; }
.lock-mark { position: absolute; right: 1px; bottom: 1px; display: grid; place-items: center; width: 14px; height: 14px; color: var(--text-3); background: var(--surface); border-radius: 50%; }
.lock-mark .i { width: 10px; height: 10px; vertical-align: 0; }

.topic-list { list-style: none; margin: 6px 0 0; padding: 0; }
.topic-row {
  display: grid;
  grid-template-columns: 1fr 96px 136px 18px;
  align-items: center; gap: 14px;
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  color: var(--text);
}
.topic-row:hover { background: var(--surface-2); color: var(--text); }
.topic-row:hover .arrow { color: var(--brand); transform: translateX(2px); }
/* A topic with no problems yet: not a link, "Soon" in place of the count */
.topic-row.is-empty { color: var(--text-3); cursor: default; }
.topic-row.is-empty:hover { background: none; color: var(--text-3); }
.topic-soon { grid-column: 2 / -1; justify-self: end; font-size: 13px; }
.topic-name { font-size: 14px; }
.topic-count { font-size: 13px; color: var(--text-3); text-align: right; white-space: nowrap; }
.topic-progress { display: flex; align-items: center; gap: 8px; }
.topic-progress .num { width: 44px; text-align: right; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.arrow { display: inline-flex; color: var(--text-3); transition: transform .12s; }
.arrow .i { width: 16px; height: 16px; }

.practice-all { display: inline-block; margin-top: 10px; font-size: 13.5px; font-weight: 500; }

/* ------------------------------------------------------------------ topic workspace */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-3); margin-bottom: 12px; }
.crumbs .sep { color: var(--border-strong); }
.topic-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.topic-head-text { flex: 1; min-width: 0; }
.topic-sub { display: flex; align-items: center; gap: 12px; margin-top: 6px; color: var(--text-3); }
#topic-meta { white-space: nowrap; }
.progress-line { flex: 0 1 160px; min-width: 40px; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-line span { display: block; height: 100%; width: 0; background: var(--good); transition: width .3s; }
.topic-head-actions { display: flex; align-items: center; gap: 2px; }

/* One row: source chips on the left, the Filter button on the right */
.filters { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.filters .chips { flex: 1; min-width: 0; }
.filter-btn { flex: none; margin-left: auto; }
.filter-btn.on { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.filter-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11.5px; font-weight: 600; color: var(--on-brand); background: var(--brand-solid); border-radius: 99px; font-variant-numeric: tabular-nums; }
.filter-count[hidden] { display: none; }

/* The Filter popover (a bottom sheet on phones) */
.filter-pop { width: 392px; padding: 8px 6px; }
.fp-group + .fp-group { margin-top: 6px; }
.fp-opts { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 6px; }
.fp-opts .chip { height: 28px; padding: 0 10px; }
.fp-opts .chip[data-status="incorrect"].on { color: var(--bad); background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.fp-opts .chip[data-status="incorrect"].on .n { color: var(--bad); }
.fp-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 8px 10px 2px; border-top: 1px solid var(--border); }
.filter-pop:not(.sheet) #filter-done { display: none; }
.filter-pop.sheet { width: 100%; }

/* "Other exams" overflow chip + its menu */
.chip-more .caret { width: 14px; height: 14px; margin: 0 -3px 0 -1px; opacity: .7; transition: transform .15s; }
.chip-more[aria-expanded="true"] .caret { transform: rotate(180deg); }
.exam-menu { position: fixed; z-index: 55; min-width: 200px; max-width: calc(100vw - 16px); max-height: min(360px, 60vh); overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); }
.exam-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; font-size: 14px; text-align: left; color: var(--text); background: none; border: 0; border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap; }
.exam-menu-item .lbl { flex: 1; }
.exam-menu-item .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.exam-menu-item:hover, .exam-menu-item:focus-visible { background: var(--surface-2); outline: none; }
.exam-menu-item.on::after { content: ""; width: 5px; height: 9px; margin: -3px 3px 0 0; border: solid var(--brand); border-width: 0 1.75px 1.75px 0; transform: rotate(45deg); }

.filter-summary { display: flex; align-items: center; gap: 10px; margin: -6px 0 12px; font-size: 13px; color: var(--text-3); }

.problems { display: flex; flex-direction: column; gap: 12px; }

/* ------------------------------------------------------------------ problem card */
.problem { padding: 16px 20px 12px; scroll-margin-top: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px); transition: box-shadow .3s, border-color .3s; }
.problem.flash { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.problem.answered.good { border-left: 3px solid var(--good); }
.problem.answered.bad { border-left: 3px solid var(--bad); }

/* "Q1  MCQ · 1 mark · GATE DA 2025" ... timer, bookmark on the right */
.p-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.p-meta { flex: 1; min-width: 0; min-height: 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }   /* the Studio preview's badges */
.problem .p-head { align-items: center; gap: 10px; min-height: 32px; margin-bottom: 8px; }
.p-num { flex: none; font-weight: 600; font-size: 15px; }
.p-info { flex: 1; min-width: 0; font-size: 13px; color: var(--text-3); }
.p-src { color: inherit; white-space: nowrap; }
a.p-src:hover { color: var(--brand); }
a.p-src .i { margin-left: 3px; vertical-align: -2px; }
.p-head > .icon-btn { flex: none; }
.link-external { color: var(--brand); text-decoration: none; font-weight: 500; }
.link-external:hover { text-decoration: underline; }
.q-image {
  margin: 14px 0;
  text-align: center;
}
.q-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: inline-block;
}
.btn-bookmark[aria-pressed="true"] .i { fill: currentColor; }

.rich { font-size: var(--fs-read); line-height: 1.7; overflow-wrap: anywhere; }
.rich .para { display: block; height: .7em; }
/* Maths never widens the page: display formulas scroll sideways, and an inline formula
   wider than its line (marked .mjx-wide by app.js) becomes its own scrolling line.
   A soft edge shadow shows there is more to scroll (it hides at each end: the --sc-bg
   covers scroll with the content). --sc-bg is the colour behind the formula. */
.problem { --sc-bg: var(--surface); }
.solution { --sc-bg: var(--surface-2); }

@media (hover: hover) {
  .option:hover { --sc-bg: var(--surface-2); }
}
.option.sel { --sc-bg: var(--brand-soft); }
.option.correct { --sc-bg: var(--good-soft); }
.option.wrong { --sc-bg: var(--bad-soft); }
.rich mjx-container[display="true"], .opt-text mjx-container[display="true"],
.problem mjx-container.mjx-wide {
  overflow-x: auto; overflow-y: hidden; max-width: 100%; padding: 2px 0;
  background:
    linear-gradient(to right, var(--sc-bg) 40%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--sc-bg) 40%, transparent) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .2), transparent) left center / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .2), transparent) right center / 10px 100% no-repeat scroll;
}
html.dark .rich mjx-container[display="true"], html.dark .opt-text mjx-container[display="true"],
html.dark .problem mjx-container.mjx-wide {
  background:
    linear-gradient(to right, var(--sc-bg) 40%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--sc-bg) 40%, transparent) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, .55), transparent) left center / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, .55), transparent) right center / 10px 100% no-repeat scroll;
}
.problem mjx-container.mjx-wide { display: block; margin: 4px 0; }
.p-body { margin-bottom: 14px; }
.blank { display: inline-block; width: 5.5em; border-bottom: 1.5px solid var(--text-2); margin: 0 .2em; vertical-align: -2px; }
pre.code {
  margin: 10px 0;
  padding: 12px 14px;
  overflow-x: auto;
  font: 13.5px/1.55 var(--mono);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: pre;
}
.rich table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 12px 0;
}
.rich table th, .rich table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 13.5px;
}
.rich table th {
  background: var(--surface-2);
  font-weight: 700;
}
.rich img {
  max-width: 100%;
  height: auto;
}

.options { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.opt-key {
  flex: none;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  font-size: 13px; font-weight: 700;
  color: var(--text-2);
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
}
.options.multi .opt-key { border-radius: 7px; }
.opt-text { flex: 1; min-width: 0; padding-top: 1px; font-size: 15px; line-height: 1.6; }
.option.sel { border-color: var(--brand); background: var(--brand-soft); }
.option.sel .opt-key { border-color: var(--brand); background: var(--brand); color: #fff; }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.correct .opt-key { border-color: var(--good); background: var(--good); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .opt-key { border-color: var(--bad); background: var(--bad); color: #fff; }
.problem.answered .option { cursor: default; }
.msq-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.nat { display: flex; gap: 8px; max-width: 380px; margin-bottom: 10px; }
.nat-input {
  flex: 1; min-width: 0; height: 38px; padding: 0 12px;
  font: inherit; font-size: 15px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 9px;
}
.nat-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
/* ± key for phones (the iPhone number pad has no minus); hidden with a mouse */
.nat-sign { display: none; flex: none; width: 44px; padding: 0; justify-content: center; font-size: 19px; font-weight: 600; }

.verdict { display: flex; align-items: center; gap: 6px; margin: 4px 0 10px; padding: 9px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.verdict.good { background: var(--good-soft); color: var(--good); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }

.p-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.p-actions > .btn-text:first-child { margin-left: -8px; }
.p-actions > .spacer { flex: 1; }
.p-id { font: 12px var(--mono); color: var(--text-3); letter-spacing: .2px; }

.solution {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  white-space: pre-wrap;
}
.sol-credit { margin: 10px 0 0; font-size: 11.5px; color: var(--text-3); text-align: right; white-space: normal; }
.solution .sol-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.modal-video { width: min(840px, 95vw); }
.modal-video.short { width: min(420px, 100%); }
.modal-video.short .video-frame { aspect-ratio: 9 / 16; max-height: 70vh; }
.modal-video .modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.video-frame { position: relative; aspect-ratio: 16 / 9; max-height: 75vh; background: #000; border-radius: 4px; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-timestamp-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 3px 8px; border-radius: 6px; }
.video-archetype-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); background: var(--surface-2); padding: 3px 8px; border-radius: 6px; }

.p-timer { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.p-timer[hidden] { display: none; }
.p-timer.slow { color: var(--warn); }

@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) {
  /* The chips scroll sideways in their line (base.css); the Filter button stays put on the right */
  .filters { gap: 8px; }
  .filters .chips { margin-right: 0; padding-right: 0; }
  .exam-menu-item { height: 44px; }
  .nat-input,
  .qe-form select,
  .qe-form textarea,
  .qe-form input { font-size: 16px; }
}

@media (max-width: 640px) {
  #view-practice .page-head { flex-direction: row; align-items: center; }
  #view-practice .page-actions { width: auto; gap: 0; margin-right: -6px; }
  .topic-head h1 { font-size: 20px; }
  .subjects { gap: 10px; }
  .subject-head { grid-template-columns: 18px 1fr; padding: 14px; gap: 4px 10px; }
  .subject-meta, .subject-progress { grid-column: 2; }
  .subject.static .subject-head { grid-template-columns: 1fr; }
  .subject.static .subject-meta { grid-column: 1; }
  .subject-body { padding: 0 14px 10px; }
  .chapter { padding-top: 12px; }
  .chapter-head { gap: 12px; min-height: 40px; }
  .chapter-head h3 { font-size: 15px; }
  .topic-row { grid-template-columns: 1fr auto 14px; gap: 10px; padding: 12px 10px; }
  .topic-count, .topic-progress .meter { display: none; }
  .topic-progress .num { width: auto; }
  .practice-all { margin-top: 12px; }
  /* One-line trail: Practice / Chapter (the subject is dropped, a long chapter is cut) */
  .crumbs { font-size: 13px; margin-bottom: 8px; flex-wrap: nowrap; white-space: nowrap; }
  .crumb-mid, .crumb-mid + .sep { display: none; }
  .crumbs > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .topic-head { gap: 8px; margin-bottom: 14px; }
  .topic-head-actions { margin: -4px -6px 0 0; }
  /* The Filter button keeps its icon and count; the label goes */
  .filter-btn { position: relative; width: 38px; padding: 0; }
  .filter-btn > span:not(.filter-count) { display: none; }
  .filter-btn .filter-count { position: absolute; top: -6px; right: -6px; }
  .fp-opts .chip { height: 36px; padding: 0 12px; }
  .problems { gap: 10px; }
  .problem { padding: 12px 14px 8px; }
  .p-info { font-size: 12.5px; }
  .option { padding: 11px 12px; min-height: 48px; align-items: center; }
  .opt-text { padding-top: 0; }
  .nat { max-width: none; }
  .nat .btn-check, .msq-row .btn-check { min-width: 92px; justify-content: center; }
  .p-actions .btn-sm { height: 34px; }
  .modal-video { width: 100%; }
}

/* Touch screens: targets of about 40px or more */
@media (pointer: coarse) {
  .nat-sign { display: inline-flex; }
  .nat-input, .nat .btn { height: 44px; }
  .msq-row .btn-check { height: 42px; }
  .p-head > .icon-btn { width: 40px; height: 40px; margin: -4px -8px -4px 0; }
  .p-actions .btn-sm { height: 38px; }
  .topic-head-actions .icon-btn, .chapter-head .icon-btn { width: 40px; height: 40px; }
  .filter-btn { height: 38px; }
  .crumbs a { padding: 8px 0; margin: -8px 0; }
}

/* Touch screens: no sticky hover tints after a tap; pressed feedback instead */
@media (hover: none) {
  .option:not(.sel):not(.correct):not(.wrong):hover { border-color: var(--border); background: transparent; }
  .topic-row:hover, .subject-head:hover { background: transparent; }
  .topic-row:hover .arrow { color: var(--text-3); transform: none; }
  .option:not(.sel):not(.correct):not(.wrong):active, .topic-row:active, .subject-head:active { background: var(--surface-2); }
}

@media (prefers-reduced-motion: reduce) {
  .chev,
  .progress-line span { transition: none; }
}

/* Locked curated problems: one quiet line (practice.js lockBanner) */
.lock-line { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; font-size: 13.5px; color: var(--text-2); }
.lock-line > .i { flex: none; color: var(--text-3); vertical-align: -2px; }
.lock-line a, .lock-line .link-btn { font-weight: 500; }

/* Sentinel at the end of a long problem list: more cards are drawn when it comes near (app.js showCards) */
.more-cards { height: 1px; }
