/*
 * "Mod Ujian & Latihan" ribbon, shown only in the training environment
 * (Persekitaran Latihan). Included by resources/views/layouts/partials/training-badge.blade.php,
 * which renders nothing in production.
 *
 * - Always top-right.
 * - Login/auth pages: hangs from the top edge of the window.
 * - App pages: rendered inside the fixed header bar and hangs from its bottom edge,
 *   right-aligned under "Log Keluar" (the header icons leave no room above them).
 *   The page content moves down a little to make room, so it covers nothing.
 * - pointer-events: none, so it never blocks clicks on anything underneath.
 * - Slow blink (well under 3 flashes per second); stops for users who ask the OS
 *   for reduced motion, and in print.
 * - Colour #c24a44 gives white text a 4.8:1 contrast ratio (WCAG AA).
 */
.espek-training-badge {
  position: fixed;
  top: 0;
  right: 64px;
  z-index: 1045; /* above the fixed header (9) and sidebar, below modal backdrops (1050) */
  padding: 8px 28px 9px;
  background-color: #c24a44;
  color: #fff;
  border: 2px solid #fff;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 14px rgba(120, 30, 26, 0.35);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  animation: espek-training-blink 1.4s ease-in-out infinite;
}

.espek-training-badge--app {
  position: absolute; /* relative to .page-main-header, which is position: fixed */
  top: 100%;
  right: 24px;
  padding: 5px 20px 6px;
  font-size: 13px;
}

/* Room under the header so the ribbon never covers the page title row, its action
   buttons or the first cards. Adds to the theme's own padding instead of replacing it. */
.page-wrapper:has(.espek-training-badge--app) .page-body-wrapper .page-body::before {
  content: "";
  display: block;
  height: 16px;
}

@keyframes espek-training-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Login page on small screens: its logo strip reaches the top edge, so the strip makes the room. */
@media (max-width: 991.98px) {
  .espek-training-badge ~ section .login-mobile-brand { padding-top: 52px; }
}

@media (max-width: 575.98px) {
  .espek-training-badge ~ section .login-mobile-brand { padding-top: 34px; }

  .espek-training-badge,
  .espek-training-badge--app {
    right: 12px;
    padding: 3px 12px 4px;
    font-size: 11px;
    letter-spacing: 0.1em;
  }

  /* Other auth pages on phones: the content starts at the very top, so make room for the ribbon. */
  body:has(> .espek-training-badge:not(.espek-training-badge--app)):not(:has(.login-mobile-brand)) {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .espek-training-badge { animation: none; }
}

@media print {
  .espek-training-badge {
    animation: none;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
