/* App shell for study screens (STORY-04.49: the top bar in top-bar.css, no side bar): one centred container, the page head,
   12-column grid, panels, the slim footer and the phone's bottom tab bar. The test runner replaces all of this (exam.css). */

body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.shell { flex: 1 0 auto; display: flex; flex-direction: column; min-width: 0; }

/* "Your tests" on Settings. */
.your-tests { display: grid; gap: var(--s3); margin: 0; padding: 0; list-style: none; }
.your-test {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) 0; border-bottom: 1px solid var(--line);
}
.your-test__name { font-family: var(--display); font-weight: 700; font-size: var(--fs-l); }

.main { flex: 1 0 auto; padding: var(--s6) 0 var(--s8); min-width: 0; }
.main:focus { outline: none; }
/* The one container (SN :138-139): the bar's row, the page and the footer's row, at most --page-max wide with equal margins. */
.topbar__in, #view > .wrap, .appfoot__in { box-sizing: border-box; width: min(var(--page-max), 100% - 2 * var(--gutter)); margin-inline: auto; }
.wrap--narrow { max-width: 820px; }
.page-head {
  display: flex; align-items: end; justify-content: space-between; gap: var(--s5);
  margin-bottom: var(--s5);
}
.page-head .eyebrow { margin-bottom: var(--s2); }
.page-head .lede { margin-top: var(--s2); max-width: 62ch; }
.page-head__aside { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); flex: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: var(--fs-m); color: var(--ink-2); margin-bottom: var(--s3); }
.crumbs a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; }
.crumbs .i { color: var(--line-strong); }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s5); }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.stack { display: grid; gap: var(--s5); align-content: start; }
.stack--s { gap: var(--s3); }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-l); padding: var(--s5); min-width: 0;
}
.panel--tint { background: var(--teal-tint); border-color: transparent; }
.panel--sunk { background: var(--paper-2); border-color: transparent; }
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4);
  margin-bottom: var(--s4);
}
.sec-head p { color: var(--ink-2); font-size: var(--fs-m); font-variant-numeric: tabular-nums; }
/* A link beside a section heading ("See all", "7 of 22 earned") takes a 44 px tap at every width. */
.sec-head > a { display: inline-flex; align-items: center; min-height: 44px; }
.sec-head__title { display: flex; align-items: center; gap: var(--s3); }
.sec-title { margin: var(--s6) 0 var(--s4); }

/* A coloured square that carries a skill or section icon. */
.tile-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--teal-tint); color: var(--teal);
}
.tile-icon--sun { background: var(--sun-tint); color: var(--sun-ink); }
.tile-icon--coral { background: var(--coral-tint); color: var(--coral-deep); }
.tile-icon--l { width: 56px; height: 56px; border-radius: var(--r-m); }

.tabbar { display: none; }
.disclaimer { margin-top: var(--s6); font-size: var(--fs-s); color: var(--ink-2); max-width: 80ch; }

/* A row that opens a page: the Study layers, Library's pages and Settings' About. */
.layers { display: grid; gap: var(--s3); margin: 0; padding: 0; list-style: none; }
.layer {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) 20px; align-items: center; gap: var(--s4);
  min-height: 72px; padding: calc(var(--s3) + 1px) calc(var(--s4) + 1px);
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r-m); text-decoration: none; /* a row's only edge: 3:1 (STORY-04.49) */
}
.layer > .i { color: var(--ink-2); }
.layer__text strong { display: block; font-family: var(--display); font-size: var(--fs-xl); line-height: 1.25; }
.layer__text span { display: block; font-size: var(--fs-m); color: var(--ink-2); }
.layers__group h2 { font-size: var(--fs-2xl); }
@media (hover: hover) and (pointer: fine) { .layer:hover { border-color: var(--line-strong); } }

/* The independence note at the foot of Library and Settings. */
.page-note { margin-top: var(--s6); font-size: var(--fs-s); line-height: 1.45; color: var(--ink-2); max-width: 80ch; }
.page-note a { display: inline-flex; align-items: center; min-height: 44px; }

/* Before enrolment there is nothing to navigate: the bar holds the brand only (top-bar.css). During a test the shell steps
   aside: the bar, the footer, Help and the tab bar are hidden. */
body.running .topbar, body.running .appfoot, body.running .help-fab, body.running .tabbar, body.running .topscrim { display: none; }
body.running .main { padding: 0; }

/* "Your progress could not be saved": under the bar, full width, its text in the container. */
.save-notice {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) max(var(--gutter), (100% - var(--page-max)) / 2); background: var(--coral-tint); color: var(--ink);
  border-bottom: 1px solid var(--line-2); font-size: var(--fs-m); line-height: 1.45;
}
.save-notice > .i { flex: none; margin-top: 2px; color: var(--coral-deep); }
.save-notice p { min-width: 0; overflow-wrap: anywhere; }
/* The link keeps its place in the sentence; its tap area reaches 44 px tall. */
.save-notice a { position: relative; font-weight: 700; color: inherit; }
.save-notice a::after { content: ""; position: absolute; inset: -12px -4px; }
/* In a running test the notice takes its own row, so the test screen fits under it, whole. */
body.running.save-failed .shell { height: 100vh; height: 100dvh; }
body.running.save-failed .save-notice { flex: none; padding: var(--s2) var(--s4); }
body.running.save-failed .main { flex: 1; min-height: 0; }
body.running.save-failed .exam { height: 100%; }

/* ================= Responsive ================= */
@media (max-width: 1180px) {
  .col-8, .col-7, .col-6, .col-5, .col-4 { grid-column: span 12; }
  .rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .your-test .btn { flex: 1 1 auto; }

  .main { padding: var(--s5) 0 var(--s7); }
  body.no-nav .main { padding-bottom: var(--s7); }
  body.running .main { padding: 0; }
  .page-head { flex-direction: column; align-items: stretch; gap: var(--s4); margin-bottom: var(--s5); }
  .page-head .lede { font-size: var(--fs-base); }
  .page-head__aside .btn { flex: 1 1 auto; }
  .grid, .stack { gap: var(--s5); }
  .stack--s { gap: var(--s3); }
  .rail { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: var(--s4); border-radius: 20px; }
  .sec-head { flex-wrap: wrap; row-gap: 2px; }
  .crumbs { flex-wrap: nowrap; }
  .crumbs a, .crumbs .i { flex: none; }
  .crumbs span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px var(--s2) calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line-2);
  }
  body.no-nav .tabbar { display: none; }
  .tabbar a {
    display: grid; justify-items: center; align-content: center; gap: 2px;
    min-height: 52px; padding: 0; border: 0; border-radius: 12px; background: none; text-decoration: none; user-select: none;
    font-size: 0.75rem; font-weight: 500; color: var(--ink-2);
  }
  .tabbar .i { width: 48px; height: 28px; padding: 4px 14px; border-radius: 14px; }
  .tabbar [aria-current="page"] { color: var(--teal); font-weight: 700; }
  .tabbar [aria-current="page"] .i { background: var(--teal); color: var(--surface); }
}
