/* ==========================================================================
   TrainerPlatform - Base
   --------------------------------------------------------------------------
   Element-level defaults layered on top of Bootstrap's reboot. Everything
   here is token-driven so it follows the active theme automatically.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* Anchor navigation must clear the sticky mobile top bar. */
  scroll-padding-top: calc(var(--tp-topbar-height) + var(--tp-space-4));
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--tp-bg-canvas);
  color: var(--tp-text-primary);
  font-family: var(--tp-font-sans);
  font-size: var(--tp-text-base);
  font-weight: var(--tp-weight-regular);
  line-height: var(--tp-leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------
   Focus. One visible, consistent ring. Never remove it outright - only
   scope it to keyboard users via :focus-visible.
   -------------------------------------------------------------------- */
:focus { outline: none; }

:focus-visible {
  outline: var(--tp-border-thick) solid var(--tp-brand);
  outline-offset: 2px;
  border-radius: var(--tp-radius-sm);
}

/* --------------------------------------------------------------------
   Links
   -------------------------------------------------------------------- */
a {
  color: var(--tp-text-link);
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 0.15em;
  transition: color var(--tp-duration-fast) var(--tp-ease-standard);
}

a:hover { color: var(--tp-brand-hover); text-decoration-color: currentColor; }

/* --------------------------------------------------------------------
   Media
   -------------------------------------------------------------------- */
img, svg, video, canvas { max-width: 100%; height: auto; display: block; }
svg { flex-shrink: 0; }

/* --------------------------------------------------------------------
   Forms - inherit typography rather than the UA default
   -------------------------------------------------------------------- */
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; }
textarea { resize: vertical; }

hr {
  border: 0;
  border-top: var(--tp-border-thin) solid var(--tp-border-subtle);
  margin: var(--tp-space-5) 0;
  opacity: 1;
}

/* --------------------------------------------------------------------
   Scrollbars - themed, unobtrusive
   -------------------------------------------------------------------- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--tp-border-strong) transparent;
}

/* --------------------------------------------------------------------
   Accessibility helpers
   -------------------------------------------------------------------- */

/* Visually hidden but available to assistive technology. */
.tp-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link - the first focusable element on every page. */
.tp-skip-link {
  position: absolute;
  top: var(--tp-space-2);
  left: var(--tp-space-2);
  z-index: var(--tp-z-toast);
  padding: var(--tp-space-2) var(--tp-space-4);
  border-radius: var(--tp-radius-md);
  background: var(--tp-brand);
  color: var(--tp-text-on-brand);
  font-weight: var(--tp-weight-semibold);
  text-decoration: none;
  transform: translateY(calc(-100% - var(--tp-space-4)));
  transition: transform var(--tp-duration-base) var(--tp-ease-emphasis);
}

.tp-skip-link:focus-visible {
  transform: translateY(0);
  color: var(--tp-text-on-brand);
}

/* Honour an explicit request for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Respect forced-colors / high-contrast modes. */
@media (forced-colors: active) {
  :focus-visible { outline: var(--tp-border-thick) solid CanvasText; }
}

/* --------------------------------------------------------------------
   Print - drop the chrome, keep the content
   -------------------------------------------------------------------- */
@media print {
  .tp-sidebar, .tp-bottom-nav, .tp-topbar, .tp-skip-link { display: none !important; }
  .tp-shell__main { padding: 0 !important; }
  body { background: #fff; color: #000; }
}
