@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-enter { animation: page-enter 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }

/* Sidebar menu: thin scrollbar that shows on hover, tinted with the brand colour. */
.sidebar-scroll { scrollbar-gutter: stable; overscroll-behavior: contain; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: transparent; border-radius: 9999px; transition: background 150ms; }
.sidebar-scroll:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--brand) 35%, transparent); }
.sidebar-scroll::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--brand) 65%, transparent); }
/* Chromium ignores the ::-webkit-scrollbar rules once these are set, so they are for Firefox only. */
@supports not selector(::-webkit-scrollbar) {
  .sidebar-scroll { scrollbar-width: thin; scrollbar-color: transparent transparent; }
  .sidebar-scroll:hover { scrollbar-color: color-mix(in srgb, var(--brand) 45%, transparent) transparent; }
}

.toast { animation: toast-in 220ms ease-out both; transition: opacity 200ms ease, transform 200ms ease; }
.toast.is-leaving { opacity: 0; transform: translateY(-8px); }

.spinner {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 9999px;
  animation: spin 0.7s linear infinite;
}

body.is-navigating::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 60;
  background: linear-gradient(90deg, var(--brand), var(--brand-accent));
  animation: nav-progress 1.2s ease-in-out infinite;
  transform-origin: left;
}

@keyframes nav-progress {
  0% { transform: scaleX(0); }
  60% { transform: scaleX(0.8); }
  100% { transform: scaleX(0.95); }
}

/* Lesson viewers in full screen: fill the screen instead of keeping the inline height */
[data-pdf-viewer]:fullscreen {
  display: flex;
  flex-direction: column;
  background: #f1f5f9;
}
[data-pdf-viewer]:fullscreen [data-pdf-pages] { flex: 1; height: auto; min-height: 0; }
[data-player]:fullscreen { display: flex; flex-direction: column; }
[data-player]:fullscreen video { flex: 1; min-height: 0; aspect-ratio: auto; object-fit: contain; }

/* Text lessons written in Markdown */
.lesson-text > * + * { margin-top: 1rem; }
.lesson-text h1, .lesson-text h2, .lesson-text h3, .lesson-text h4 { color: rgb(15 23 42); font-weight: 600; line-height: 1.3; }
.lesson-text h1 { font-size: 1.5rem; }
.lesson-text h2 { font-size: 1.25rem; margin-top: 2rem; }
.lesson-text h3 { font-size: 1.0625rem; margin-top: 1.5rem; }
.lesson-text h4 { font-size: 1rem; margin-top: 1.25rem; }
.lesson-text :is(h1, h2, h3, h4) + * { margin-top: 0.5rem; }
.lesson-text strong { color: rgb(15 23 42); font-weight: 600; }
.lesson-text a { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.lesson-text ul, .lesson-text ol { padding-left: 1.5rem; }
.lesson-text ul { list-style: disc; }
.lesson-text ol { list-style: decimal; }
.lesson-text li + li, .lesson-text li > ul, .lesson-text li > ol { margin-top: 0.25rem; }
.lesson-text li::marker { color: rgb(100 116 139); }
.lesson-text blockquote {
  border-left: 3px solid var(--brand); background: rgb(248 250 252); border-radius: 0 0.5rem 0.5rem 0;
  padding: 0.75rem 1rem; color: rgb(51 65 85);
}
.lesson-text code {
  background: rgb(241 245 249); border-radius: 0.25rem; padding: 0.1rem 0.35rem; font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.lesson-text pre { background: rgb(15 23 42); color: rgb(226 232 240); border-radius: 0.5rem; padding: 1rem; overflow-x: auto; }
.lesson-text pre code { background: none; padding: 0; color: inherit; }
.lesson-text hr { border: 0; border-top: 1px solid rgb(226 232 240); margin: 2rem 0; }
.lesson-text table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 0.875rem; }
.lesson-text th, .lesson-text td { border: 1px solid rgb(226 232 240); padding: 0.5rem 0.75rem; text-align: left; }
.lesson-text th { background: rgb(248 250 252); color: rgb(15 23 42); font-weight: 600; }

/* Date picker in the organization's colours */
.flatpickr-calendar { font-family: inherit; border-radius: 0.75rem; box-shadow: 0 10px 30px rgb(15 23 42 / 0.12); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus {
  background: var(--brand); border-color: var(--brand);
}
.flatpickr-day.today { border-color: var(--brand); }

/* Grid columns shrink with the screen instead of growing to their widest content (long names, file pickers) */
.grid > * { min-width: 0; }

/* Data tables on phones: each row becomes a card, each cell a "label  value" line taken from data-label */
@media (max-width: 639px) {
  .table-stack { min-width: 0 !important; }
  .table-stack thead { display: none; }
  .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 0.875rem 1.25rem; }
  .table-stack td {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.25rem 0 !important; text-align: right;
  }
  .table-stack td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    font-size: 0.75rem; color: rgb(100 116 139);
  }
  .table-stack td:first-child { display: block; padding-bottom: 0.5rem !important; text-align: left; }
  .table-stack td:first-child::before, .table-stack td:not([data-label])::before { content: none; }
  .table-stack td:not([data-label]) { justify-content: flex-start; }
}

/* Public certificate validation */
.verify-bg {
  background-color: rgb(248 250 252);
  background-image:
    radial-gradient(60rem 30rem at 10% -10%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 60%),
    radial-gradient(50rem 28rem at 110% 0%, color-mix(in srgb, var(--brand-accent) 18%, transparent), transparent 60%),
    radial-gradient(circle at 1px 1px, rgb(15 23 42 / 0.06) 1px, transparent 0);
  background-size: auto, auto, 22px 22px;
  background-attachment: fixed;
}
.verify-tile { background: color-mix(in srgb, var(--brand) 10%, white); }
.verify-halo::before, .verify-halo::after {
  content: ''; position: absolute; inset: 0; border-radius: 9999px;
  background: currentColor; opacity: 0; animation: verify-halo 2.4s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
.verify-halo::after { animation-delay: 1.2s; }
.verify-halo > * { position: relative; }
.verify-halo-expired::before, .verify-halo-expired::after,
.verify-halo-revoked::before, .verify-halo-revoked::after { animation-iteration-count: 1; }
@keyframes verify-halo {
  0% { transform: scale(1); opacity: 0.22; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* Comfortable touch targets on touch screens */
@media (pointer: coarse) {
  .touch-target { min-height: 44px; min-width: 44px; display: inline-grid; place-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
