/* training_html, root .tr-shell (a wrapper with no rule of its own; .tr-root
   is the block inside it). Every selector is scoped :where(.tr-shell), which
   adds zero specificity. The banner and modal slot divs always hold Anvil's
   <anvil-dropzone> (display: contents), so an empty slot is
   :not(:has(> anvil-dropzone > *)); @keyframes tr-ch-spin is private to this
   form, because keyframe names are global. */

:where(.tr-shell) .tr-root {
  padding: var(--ch-space-lg);
  max-width: 1400px;
  margin: 0 auto;
  font-family: var(--ch-font-primary);
  background: var(--ch-bg-primary);
  min-height: 100vh;
  color: var(--ch-text-primary);
  /* Greenwood chrome lifts here so the whole training tab
     reads the sage/brand/terra radial gradient regardless of
     which child surface is mounted. Scoped to .tr-root so the
     rest of the carehome app (mar charts, settings, monthly
     scripts) keeps its neutral chrome — never on body::before. */
  position: relative;
}
:where(.tr-shell) .tr-root::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(620px 460px at 88% 6%, rgba(107,170,132,0.16), transparent 70%),
    radial-gradient(560px 420px at 4% 40%, rgba(246,139,31,0.08), transparent 70%),
    radial-gradient(700px 500px at 70% 90%, rgba(154,69,35,0.06), transparent 70%);
}
/* Lift content children above the ::before chrome — every direct
   child of .tr-root paints on top of the radial gradient. Position
   alone does it (tree order after ::before); a z-index would make
   each slot a stacking context and trap its dialogs under the
   assistant drawer. The loading overlay keeps its position: fixed. */
:where(.tr-shell) .tr-root > *:not(.ch-loading-overlay) {
  position: relative;
}

/* Top-level banner slot — global notifications (role-change-reload,
   new-test, expiring). Local variants (apology, in-progress-other-device)
   live in the runner's own banner slot, not here. */
:where(.tr-shell) .tr-banner-slot:not(:has(> anvil-dropzone > *)) {
  display: none;
}
:where(.tr-shell) .tr-banner-slot {
  margin-bottom: var(--ch-space-md);
}

/* Tab strip — only rendered when both Take training + Manage are
   accessible (admin-as-learner). Solo-surface users see no strip
   at all per UX §F-T01.6. */
:where(.tr-shell) .tr-tab-strip {
  display: none;
  gap: 0;
  border-bottom: 2px solid var(--ch-border);
  margin-bottom: var(--ch-space-lg);
}
:where(.tr-shell) .tr-tab-strip.tr-visible {
  display: flex;
}
:where(.tr-shell) .tr-tab-strip [role="tab"] {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--ch-font-primary);
  color: var(--ch-text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--ch-transition-fast), border-color var(--ch-transition-fast);
  min-height: 44px;
}
:where(.tr-shell) .tr-tab-strip [role="tab"]:hover {
  color: var(--ch-text-primary);
}
:where(.tr-shell) .tr-tab-strip [role="tab"].tr-active {
  color: var(--ch-accent-primary-text, #b45309);
  border-bottom-color: var(--ch-accent-primary);
  font-weight: 600;
}
:where(.tr-shell) .tr-tab-strip [role="tab"]:focus-visible {
  outline: 2px solid var(--ch-border-focus);
  outline-offset: -2px;
  border-radius: var(--ch-radius-sm);
}

/* Content slot — children mount here */
:where(.tr-shell) .tr-content-slot {
  background: var(--ch-bg-primary);
}

/* Modal slot — sits above the content; children mount overlays here */
:where(.tr-shell) .tr-modal-slot:not(:has(> anvil-dropzone > *)) {
  display: none;
}

/* Loading overlay — instant show/hide so even sub-250ms server
   round-trips register visually. The previous opacity+visibility
   fade meant a fast role_context + dashboard fetch finished
   before the overlay reached perceptible opacity. */
:where(.tr-shell) .ch-loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--ch-bg-overlay, rgba(0, 0, 0, 0.5));
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10001;
}
:where(.tr-shell) .ch-loading-overlay.visible {
  display: flex;
}
:where(.tr-shell) .ch-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--ch-border);
  border-top-color: var(--ch-accent-primary);
  border-radius: 50%;
  animation: tr-ch-spin 1s linear infinite;
}
:where(.tr-shell) .ch-loading-text {
  color: var(--ch-text-inverse);
  font-size: 14px;
  font-weight: 500;
}
@keyframes tr-ch-spin {
  to { transform: rotate(360deg); }
}
