/* Human Factors study-material tab — isolated from quiz app styles */
.hf-study-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin: 18px 0 24px auto;
  padding: 5px;
  border: 1px solid rgba(30, 92, 75, .14);
  border-radius: 14px;
  background: rgba(244, 249, 247, .92);
  box-shadow: 0 8px 24px rgba(32, 75, 64, .06);
}
.hf-study-tab {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #365f54;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.hf-study-tab:hover { transform: translateY(-1px); }
.hf-study-tab.is-active {
  background: #287b65;
  color: #fff;
  box-shadow: 0 5px 14px rgba(40, 123, 101, .22);
}
.hf-study-panel {
  display: none;
  margin-top: 6px;
  border: 1px solid rgba(30, 92, 75, .14);
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 16px 44px rgba(32, 75, 64, .08);
}
.hf-study-panel.is-open { display: block; }
.hf-study-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 24px 28px;
  background: linear-gradient(135deg, #f0f8f5, #fbfdfc);
  border-bottom: 1px solid rgba(30, 92, 75, .10);
}
.hf-study-copy small {
  display: block;
  color: #2a836c;
  font-weight: 800;
  margin-bottom: 6px;
}
.hf-study-copy h3 {
  margin: 0 0 8px;
  color: #173d33;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
}
.hf-study-copy p {
  margin: 0;
  max-width: 780px;
  color: #5c6f69;
  line-height: 1.65;
}
.hf-study-count {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  display: grid;
  place-content: center;
  text-align: center;
  background: #fff;
  border: 1px solid rgba(40,123,101,.14);
  color: #287b65;
  box-shadow: 0 8px 24px rgba(40,123,101,.08);
}
.hf-study-count strong { font-size: 1.55rem; line-height: 1; }
.hf-study-count span { margin-top: 5px; font-size: .78rem; font-weight: 700; color: #638078; }
.hf-study-viewer {
  height: min(78vh, 940px);
  min-height: 640px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  background: #e8efec;
  padding: 14px clamp(8px, 2vw, 22px) 30px;
  scrollbar-color: #8eaaa1 #dbe6e2;
  scrollbar-width: thin;
}
.hf-viewer-note {
  position: sticky;
  top: 0;
  z-index: 2;
  width: fit-content;
  margin: 0 auto 12px;
  padding: 7px 14px;
  border-radius: 999px;
  color: #45675e;
  font-size: .82rem;
  font-weight: 700;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(40,123,101,.12);
  backdrop-filter: blur(6px);
}
.hf-pages {
  display: grid;
  gap: 18px;
  max-width: 980px;
  margin: 0 auto;
}
.hf-page {
  margin: 0;
  padding: 8px 8px 10px;
  background: #fff;
  border: 1px solid rgba(37,77,65,.12);
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(28,62,52,.10);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.hf-page-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 7px;
  pointer-events: none;
  -webkit-user-drag: none;
}
.hf-page figcaption {
  padding-top: 7px;
  text-align: center;
  color: #788983;
  font-size: .78rem;
  font-weight: 600;
}
@media (max-width: 760px) {
  .hf-study-tabs { margin: 12px 0 18px auto; width: 100%; }
  .hf-study-tab { flex: 1; padding: 10px 12px; }
  .hf-study-hero { grid-template-columns: 1fr auto; padding: 18px; gap: 12px; }
  .hf-study-copy p { font-size: .92rem; line-height: 1.55; }
  .hf-study-count { width: 66px; height: 66px; border-radius: 18px; }
  .hf-study-count strong { font-size: 1.25rem; }
  .hf-study-viewer { height: 72vh; min-height: 520px; padding: 10px 6px 22px; }
  .hf-pages { gap: 12px; }
  .hf-page { padding: 4px 4px 8px; border-radius: 9px; }
}
@media (max-width: 500px) {
  .hf-study-hero { grid-template-columns: 1fr; }
  .hf-study-count { width: auto; height: auto; padding: 9px 14px; display: flex; gap: 6px; align-items: baseline; justify-content: center; border-radius: 12px; }
  .hf-study-count span { margin: 0; }
}

/* Full-screen controls for the embedded study material viewer */
.hf-study-viewer-shell {
  position: relative;
  background: #e8efec;
}
.hf-study-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #f8fbfa;
  border-bottom: 1px solid rgba(30, 92, 75, .12);
  color: #355f54;
}
.hf-study-toolbar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: .88rem;
  font-weight: 800;
}
.hf-study-toolbar-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #2b866e;
  box-shadow: 0 0 0 4px rgba(43,134,110,.10);
}
.hf-fullscreen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(40,123,101,.18);
  border-radius: 10px;
  background: #fff;
  color: #287b65;
  font: inherit;
  font-size: .87rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(40,123,101,.07);
  transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.hf-fullscreen-button:hover {
  transform: translateY(-1px);
  background: #287b65;
  color: #fff;
  box-shadow: 0 6px 16px rgba(40,123,101,.18);
}
.hf-fullscreen-button:focus-visible {
  outline: 3px solid rgba(40,123,101,.25);
  outline-offset: 2px;
}
.hf-fullscreen-icon {
  display: inline-grid;
  place-items: center;
  min-width: 1.1em;
  font-size: 1.15rem;
  line-height: 1;
}

/* Native Fullscreen API and the mobile/CSS fallback share the same layout. */
.hf-study-viewer-shell.is-fullscreen,
.hf-study-viewer-shell:fullscreen,
.hf-study-viewer-shell:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: #dfe9e5;
  display: flex;
  flex-direction: column;
  z-index: 2147483646;
}
.hf-study-viewer-shell[data-fullscreen-fallback="true"] {
  position: fixed !important;
  inset: 0 !important;
}
.hf-study-viewer-shell.is-fullscreen .hf-study-toolbar,
.hf-study-viewer-shell:fullscreen .hf-study-toolbar,
.hf-study-viewer-shell:-webkit-full-screen .hf-study-toolbar {
  flex: 0 0 auto;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  box-shadow: 0 3px 16px rgba(20,55,46,.08);
  z-index: 10;
}
.hf-study-viewer-shell.is-fullscreen .hf-study-viewer,
.hf-study-viewer-shell:fullscreen .hf-study-viewer,
.hf-study-viewer-shell:-webkit-full-screen .hf-study-viewer {
  flex: 1 1 auto;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  padding-bottom: max(30px, env(safe-area-inset-bottom));
}
.hf-study-viewer-shell.is-fullscreen .hf-pages,
.hf-study-viewer-shell:fullscreen .hf-pages,
.hf-study-viewer-shell:-webkit-full-screen .hf-pages {
  max-width: 1120px;
}
.hf-study-fullscreen-open {
  overflow: hidden !important;
}

@media (max-width: 600px) {
  .hf-study-toolbar { padding: 9px 10px; }
  .hf-study-toolbar-title { font-size: .8rem; }
  .hf-fullscreen-button { padding: 8px 10px; min-height: 36px; }
  .hf-fullscreen-button span:last-child { display: none; }
  .hf-fullscreen-icon { font-size: 1.3rem; }
  .hf-study-viewer-shell.is-fullscreen .hf-fullscreen-button span:last-child,
  .hf-study-viewer-shell:fullscreen .hf-fullscreen-button span:last-child,
  .hf-study-viewer-shell:-webkit-full-screen .hf-fullscreen-button span:last-child { display: inline; }
}

/* Interactive table of contents */
.hf-study-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hf-toc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(40,123,101,.18);
  border-radius: 10px;
  background: #fff;
  color: #287b65;
  font: inherit;
  font-size: .87rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(40,123,101,.07);
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.hf-toc-button:hover { transform: translateY(-1px); background: #eef7f4; }
.hf-toc-button:focus-visible { outline: 3px solid rgba(40,123,101,.25); outline-offset: 2px; }
.hf-toc-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(15,38,32,.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.hf-toc-backdrop.is-open { opacity: 1; pointer-events: auto; }
.hf-toc-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(440px, 92vw);
  background: #fff;
  border-left: 1px solid rgba(40,123,101,.15);
  box-shadow: -16px 0 42px rgba(18,55,45,.18);
  transform: translateX(105%);
  transition: transform .24s ease;
  display: flex;
  flex-direction: column;
  direction: rtl;
}
.hf-toc-drawer.is-open { transform: translateX(0); }
.hf-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e5efeb;
  background: #f8fbfa;
}
.hf-toc-header div { display: grid; gap: 2px; }
.hf-toc-header small { color: #70857e; font-weight: 700; }
.hf-toc-header strong { color: #173d33; font-size: 1.2rem; }
.hf-toc-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(40,123,101,.16);
  background: #fff;
  color: #365f54;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}
.hf-toc-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 10px 18px;
  scrollbar-width: thin;
  scrollbar-color: #9fb9b0 #eef4f1;
}
.hf-toc-item {
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 8px 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #294c42;
  font: inherit;
  text-align: right;
  cursor: pointer;
}
.hf-toc-item:hover { background: #eff7f4; }
.hf-toc-title { flex: 0 1 auto; font-size: .88rem; line-height: 1.35; }
.hf-toc-dots { flex: 1 1 auto; min-width: 18px; border-bottom: 1px dotted #b5c6c0; transform: translateY(-4px); }
.hf-toc-page {
  flex: 0 0 auto;
  min-width: 28px;
  text-align: center;
  color: #287b65;
  font-weight: 900;
  font-size: .9rem;
  border-radius: 7px;
  padding: 2px 5px;
  background: #eef7f4;
}
.hf-page-has-toc { position: relative; }
.hf-toc-page-button {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 2;
  padding: 7px 11px;
  border: 1px solid rgba(40,123,101,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: #287b65;
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(20,60,50,.10);
}
.hf-page-jump-highlight {
  animation: hfPageJump 1.15s ease;
}
@keyframes hfPageJump {
  0%, 100% { box-shadow: 0 8px 28px rgba(28,62,52,.10); }
  30% { box-shadow: 0 0 0 4px rgba(40,123,101,.35), 0 12px 34px rgba(28,62,52,.16); }
}
.hf-study-viewer-shell.is-fullscreen .hf-toc-drawer,
.hf-study-viewer-shell:fullscreen .hf-toc-drawer,
.hf-study-viewer-shell:-webkit-full-screen .hf-toc-drawer,
.hf-study-viewer-shell.is-fullscreen .hf-toc-backdrop,
.hf-study-viewer-shell:fullscreen .hf-toc-backdrop,
.hf-study-viewer-shell:-webkit-full-screen .hf-toc-backdrop {
  position: fixed;
}
@media (max-width: 600px) {
  .hf-study-toolbar-actions { gap: 6px; }
  .hf-toc-button { padding: 8px 9px; min-height: 36px; }
  .hf-toc-button span:last-child { display: none; }
  .hf-toc-page-button { left: 8px; top: 8px; font-size: .7rem; padding: 6px 9px; }
  .hf-toc-item { padding: 9px 7px; }
  .hf-toc-title { font-size: .84rem; }
}
