
/* Shared layout and question presentation for the learning routes. */
#app .top {
  box-shadow: 0 1px 0 var(--line);
}
#app .lhead {
  padding: clamp(1rem, 2vw, 1.5rem);
  border-inline-start-width: 3px;
}
#app .hero > :is(div, section) { min-width: 0; }
#app .card:not(:has(> a:only-child)):hover {
  transform: none;
  box-shadow: var(--glass-shadow);
  border-color: var(--glass-border) !important;
}
#app .nafs-route .nafs-subject-link {
  min-block-size: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
#app .nafs-route .nafs-subject-link::after {
  content: '';
  inline-size: .5rem;
  block-size: .5rem;
  border-block-start: 2px solid currentColor;
  border-inline-end: 2px solid currentColor;
  transform: rotate(45deg);
  margin-inline-end: .25rem;
}
#app .nafs-route[dir="rtl"] .nafs-subject-link::after { transform: rotate(-45deg); }

#app :is(.question-media, .q-figure, .nafs-fig, .lab-figure, .nafs-route .fig) {
  inline-size: min(100%, 40rem);
  max-inline-size: 100%;
  margin: .85rem auto;
  padding: clamp(.5rem, 2vw, 1rem);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel2);
}
#app .lab-figure .fig { width: 100%; margin: 0; padding: 0; border: 0; }
#app :is(.question-media, .q-figure, .opt-fig) img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

#app .question-media figcaption {
  margin-block-start: .55rem;
  text-align: start;
}
#app .nafs-route :is(#drill, #nafs-mock-section, .form-q) {
  min-inline-size: 0;
}
#app .nafs-route .choice:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--panel) 90%, var(--accent));
}
#app .nafs-route .choice:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#app .nafs-route .choice input { accent-color: var(--accent); }
#nafs-mock-clock { font-variant-numeric: tabular-nums; }
#app .nafs-route [data-exam-index] { min-inline-size: 2.75rem; min-block-size: 2.75rem; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0s; }
  #app :is(.card,.navbtn,.tab,.choice) { transition: none; }
}
@media print {
  #app :is(.question-media, .q-figure, .nafs-fig, .lab-figure) { break-inside: avoid; }
}
#app .nafs-route .question-media { inline-size: min(100%, 29rem); margin-block: .1rem .25rem; }
#app .nafs-route #drill { gap: .75rem; }
#app .nafs-route #drill > :is(h2,p) { margin: 0; }
#app .nafs-route #drill > p:has(> strong) { font-size: clamp(1.03rem, 2vw, 1.15rem); line-height: 1.5; }
@media (max-width: 520px) {
  #app .nafs-route .nafs-heading nav { gap: .35rem; }
  #app .nafs-route .nafs-heading nav .button { padding-inline: .6rem; }
}

.nesmo-reader-text { white-space: pre-wrap; line-height: 1.8; overflow-wrap: anywhere; }
.nesmo-reader-visual { margin: 0; display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,15rem),1fr)); gap: 1rem; align-items: center; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel2); }
.nesmo-reader-visual svg { width: 100%; max-height: 12rem; }
.nesmo-reader-visual p { margin: .4rem 0 0; }
.nesmo-q-card .q-stem { white-space: pre-line; }
.nesmo-q-card .chem { direction: ltr; white-space: nowrap; }

.nesmo-navigation { position: sticky; top: var(--nesmo-top, 0px); z-index: 3; background: var(--panel); }
.nesmo-navigation h2 { overflow-wrap: anywhere; }
.nesmo-q-card .explain { white-space: pre-line; }

.nesmo-q-card { scroll-margin-top: calc(var(--nesmo-top, 0px) + 10rem); }

/* ===== lesson path: one sticky step bar, a "More tools" menu, and Back / Next under every step ===== */
.step-anchor { height: 0; }
.step-bar { position: sticky; top: var(--toph, 0px); z-index: 18; display: flex; align-items: center; gap: .5rem; margin: .6rem 0 .8rem; padding: .4rem .5rem; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); transition: top .25s ease; }
/* the slim top bar slides away while scrolling down (js/compact-header.js): the step bar moves up into its place */
body:has(.top.top-hide) .step-bar { top: 0; }
.step-path { display: flex; flex: 1 1 auto; min-width: 0; gap: .3rem; }
.step-pill { flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: .4rem; min-width: 0; min-height: 40px; padding: .25rem .5rem; font: inherit; font-size: .86rem; font-weight: 600; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.step-pill:hover { background: var(--panel2); color: var(--ink); }
.step-num { display: grid; place-items: center; flex: none; width: 1.55rem; height: 1.55rem; border-radius: 50%; font-size: .78rem; font-weight: 800; background: var(--panel2); color: var(--ink); }
.step-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.step-pill.done .step-num { background: var(--good); color: var(--panel); }
.step-pill.current { color: var(--ink); border-color: var(--c, var(--accent)); background: var(--c-soft, var(--panel2)); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.step-pill.current:not(.done) .step-num { background: var(--c, var(--accent)); color: var(--c-ink, var(--accent-ink)); }

.drop { position: relative; flex: none; }
.drop > summary { list-style: none; cursor: pointer; user-select: none; }
.drop > summary::-webkit-details-marker { display: none; }
.drop-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 25; display: flex; flex-direction: column; gap: 2px; width: max-content; min-width: 13rem; max-width: min(19rem, calc(100vw - 32px)); max-height: min(70vh, 32rem); overflow-y: auto; padding: .35rem; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 34px rgba(0, 0, 0, .25); }
.tools-menu > summary { display: flex; align-items: center; white-space: pre; min-height: 40px; padding: .25rem .8rem; font-size: .86rem; font-weight: 700; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); }
.tools-menu.on > summary { border-color: var(--c, var(--accent)); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.drop-item { display: block; flex: none; width: 100%; min-height: 40px; padding: .4rem .7rem; text-align: start; font: inherit; color: var(--ink); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.drop-item:hover, .drop-item:focus-visible { background: var(--panel2); }
.drop-item.on { background: var(--c-soft, var(--panel2)); box-shadow: inset 0 0 0 1px var(--c, var(--accent)); }
.drop-item b, .drop-item small { display: block; }
.drop-item b { font-size: .88rem; }
.drop-item small { font-size: .74rem; line-height: 1.35; color: var(--muted); }

/* the header's menu opens over the step bar below it */
#app .lhead { position: relative; z-index: 19; }
.lhead-menu > summary { font-size: 1.1rem; line-height: 1; min-width: 40px; justify-content: center; }
#app .lhead-menu .drop-menu > * { justify-content: flex-start; width: 100%; border-radius: 8px; border-color: transparent; text-decoration: none; }

.step-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; margin: .2rem 0 .8rem; font-size: 1.3rem; }
.step-title:focus { outline: none; }
.step-title:focus-visible { outline: 2px solid var(--c, var(--accent)); outline-offset: 4px; border-radius: 4px; }
.step-kicker { font-family: var(--f-body); font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.step-return { margin-bottom: .8rem; }
.step-return[hidden] { display: none; }
/* tall enough that a short step can still scroll to its top */
.lesson-pane { min-height: 55vh; }

.step-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .7rem; margin: 1.6rem 0 .4rem; padding-top: 1rem; border-top: 1px solid var(--line); }
#app .step-foot .step-btn { min-height: 52px; max-width: 100%; padding: .65rem 1.4rem; font-size: 1rem; line-height: 1.35; white-space: normal; text-align: center; }
.step-foot .step-next { margin-inline-start: auto; }
/* read out by screen readers after Next */
.step-status { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wrap .lessonnav a { font-size: .82rem; color: var(--muted); }

@media (max-width: 700px) {
  .step-bar { gap: .3rem; padding: .3rem; }
  .step-path { gap: .2rem; }
  .step-pill { flex: 0 0 auto; padding: .25rem .35rem; }
  .step-pill .step-name { display: none; }
  .step-pill.current { flex: 1 1 auto; }
  .step-pill.current .step-name { display: inline; font-size: .8rem; }
  .tools-word { display: none; }
  .tools-menu > summary { padding: .25rem .55rem; }
  #app .step-foot .step-btn { flex: 1 1 100%; }
  .step-foot .step-next { order: -1; }
  .step-foot > span { display: none; }
}
@media (pointer: coarse) { .step-pill, .tools-menu > summary, .drop-item { min-height: 48px; } }
@media print { .step-bar, .step-foot, .step-return, .lhead-menu { display: none !important; } }

/* ===== temporary lesson link bar ===== */
.linkbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; margin: 0 0 1rem; padding: .75rem .9rem; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow); }
.linkbar-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.linkbar-title { align-self: center; }
.linkbar-field { display: grid; gap: .15rem; min-width: 0; font-size: .76rem; font-weight: 700; color: var(--muted); }
.linkbar-wide { flex: 1 1 14rem; }
.linkbar-field :is(select, input) { width: 100%; min-width: 0; min-height: 40px; padding: .35rem .5rem; font: inherit; font-size: .9rem; font-weight: 400; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.linkbar-field[hidden], .linkbar-out[hidden], .linkbar-mine[hidden] { display: none; }
#app .linkbar :is(.share-make, .share-copy) { min-height: 40px; background: var(--c, var(--accent)); color: var(--c-ink, var(--accent-ink)); }
#app .linkbar .share-x { margin-inline-start: auto; align-self: center; }
.linkbar-out { display: grid; gap: .35rem; }
.linkbar-warn { margin: 0; color: var(--danger); font-weight: 600; }
.linkbar-mine > summary { cursor: pointer; font-size: .85rem; font-weight: 600; }
.linkbar-mine .share-made { margin-top: .5rem; max-height: 15rem; overflow-y: auto; }
@media (max-width: 560px) { .linkbar-field { flex: 1 1 100%; } .linkbar .share-make { flex: 1 1 auto; } }
@media print { .linkbar { display: none !important; } }
@media (max-width: 480px) {
  .step-bar { gap: .2rem; padding: .25rem; }
  .step-path { gap: .12rem; }
  #app .step-pill:not(.current) { width: 1.85rem; padding: 0; border-color: transparent; }
  #app .step-pill.current { padding: 0 .3rem; gap: .25rem; }
  .step-num { width: 1.35rem; height: 1.35rem; }
  #app .tools-menu > summary { padding: .25rem .4rem; font-size: .8rem; }
  .wrap .lhead .lnum { display: none; }
  .wrap .lhead { grid-template-columns: minmax(0, 1fr); }
}
.linkbar .linkbar-note { color: var(--ink); font-weight: 600; }
.linkbar-duration { display: flex; gap: .35rem; }
.linkbar-field .linkbar-duration .linkbar-amount { width: 5rem; flex: none; font-size: 1.05rem; font-weight: 700; text-align: center; }
.linkbar-field .linkbar-duration .linkbar-amount[hidden] { display: none; }
.linkbar-choices { align-items: center; }
.linkbar-quick { display: flex; flex-wrap: wrap; gap: .35rem; }
#app .linkbar-quick .share-day { min-height: 36px; }
#app .linkbar-quick .share-day.on { background: var(--c, var(--accent)); border-color: var(--c, var(--accent)); color: var(--c-ink, var(--accent-ink)); }
.linkbar .linkbar-until { font-size: .85rem; }
.linkbar .linkbar-until.linkbar-warn { color: var(--danger); font-weight: 600; }
