/* ProfNavigator: interaction layer.
 * Load after the page's base stylesheet. No content is hidden for animation.
 * Brand variables support the canonical v4 token names and the first prototype's aliases.
 */
/* Controls share color feedback. Their boxes, labels and icons keep the same
 * geometry in pointer and keyboard states. Keep this list scoped to portal UI;
 * the separately owned BVI controls are not part of this correction. */
.button,
.button--primary,
.tool-button,
.tool-link,
.interest-button,
.interest-text-link,
.interest-close,
.interest-choice-card,
.interest-options > summary,
.icon-button,
.dialog-close,
.mobile-menu-button,
.responsive-navigation-action,
.responsive-navigation-row,
.record-dialog-close,
.legal-dialog-close,
.filter-chip,
.pn-ev-month-button,
.pn-ev-item,
.pn-map-workspace button,
.pn-map-popup a,
.pn-organization-links a,
.directory-pagination button,
.teacher-pagination a,
.teacher-library-sections a,
.teacher-publication-link,
.teacher-guide-actions a,
.moderation-tabs button,
.search-hints button,
.site-footer button:not(.bvi-open),
.text-link,
.nav-link,
.mega-grid > a,
.mega-footer a,
.catalogue-entries a,
.footer-bottom a,
.profession-catalogue-link,
.profession-catalogue-nav a,
.reading-related-more,
.teacher-tool-link,
.related-card,
.back-to-top,
.portal-card,
.material-card,
.profession-card,
.route-card {
  transition: var(--pn-control-transition);
}

.material-card .card-media {
  overflow: hidden;
}

/* Pointer effects supplement keyboard focus; they do not convey selection. */
@media (hover: hover) and (pointer: fine) {
  .portal-card:hover:not(:focus-within),
  .profession-card:hover:not(:focus-within),
  .route-card:hover:not(:focus-within) {
    border-color: var(--pn-border-control, var(--control, #817989));
  }

  .button.primary:hover,
  .button--primary:hover {
    background-color: var(--pn-primary-hover, var(--primary-hover, #42394e));
    border-color: var(--pn-primary-hover, var(--primary-hover, #42394e));
  }
}

.portal-card:focus-within,
.material-card:focus-within,
.profession-card:focus-within,
.route-card:focus-within {
  border-color: var(--pn-border-control, var(--control, #8c8c93));
}

.button.primary:active,
.button--primary:active {
  background-color: var(--pn-primary-active, #352d40);
  border-color: var(--pn-primary-active, #352d40);
}

/* Focus uses the existing boundary. Native selects can match :focus-visible
   after a pointer click too, so neither focus state adds a second contour. */
:is(a,button,input,select,textarea,summary):focus {
  outline: none;
}
:is(input,select,textarea,.button,.button--primary):focus {
  box-shadow: none;
}
:root :is(input,select,textarea):focus-visible,
.button:focus-visible {
  border-color: var(--text);
}
:is(a,button,summary):focus-visible {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
label:has(> input:is([type="checkbox"],[type="radio"]):focus-visible) {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
:is(.record-dialog-close,.dialog-close,.mobile-menu-button):focus-visible {
  border-color: var(--text);
  background-color: var(--soft);
}

/* The native open state owns visibility, keyboard navigation and focus. */
@keyframes pn-panel-entry {
  from { opacity: .7; }
  to { opacity: 1; }
}

html[data-pn-motion="on"] :is([open] > [data-motion-panel], [data-motion-panel]:is([open], .is-open:not([hidden]))) {
  animation: pn-panel-entry var(--motion-normal) var(--motion-ease-out);
}

.mega-panel[hidden] {
  display: none !important;
}

@media (forced-colors: none) {
  :root progress[data-pn-progress] {
    background-image: linear-gradient(var(--pn-primary), var(--pn-primary));
    background-repeat: no-repeat;
  }
  :root progress[data-pn-progress]::-webkit-progress-bar,
  :root progress[data-pn-progress]::-webkit-progress-value { background: transparent; }
  :root progress[data-pn-progress]::-moz-progress-bar { background: transparent; }
}

/* The return control and arrow stay fixed. The ring follows page progress;
 * the controller keeps the control clear of the footer. */
.back-to-top {
  position: fixed;
  left: max(24px, env(safe-area-inset-left, 0px));
  right: auto;
  bottom: calc(var(--top-control-bottom, 88px) + env(safe-area-inset-bottom, 0px));
  z-index: var(--pn-layer-top, 20);
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--pn-brand);
  border-radius: 50%;
  background: var(--pn-brand);
  color: var(--pn-on-primary);
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.5;
  text-decoration: none;
  box-shadow: 0 4px 16px rgb(23 43 77 / .22), 0 0 0 3px var(--surface);
}
.back-to-top[hidden] { display: none !important; }
.back-to-top .top-progress { position: absolute; inset: -1px; width: 56px; height: 56px; fill: none; stroke: currentColor; stroke-width: 1.7; transform: rotate(-90deg); pointer-events: none; }
.back-to-top .top-progress-track { opacity: .18; }
.back-to-top .top-progress-value { stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--top-progress, 0)); }
.top-icon-stage { position: relative; display: grid; place-items: center; width: 28px; height: 28px; pointer-events: none; }
.back-to-top .top-arrow { grid-area: 1/1; width: 24px; height: 24px; }
.back-to-top .top-label { position: absolute; left: calc(100% + 13px); padding: 7px 12px; border: 1px solid var(--pn-brand); border-radius: 6px; background: var(--pn-brand); color: var(--pn-on-primary); white-space: nowrap; visibility: hidden; pointer-events: none; }
.back-to-top:focus-visible .top-label, .back-to-top:hover .top-label { visibility: visible; }
.back-to-top:focus-visible { outline: none; background: var(--primary); border-color: var(--primary); }
.back-to-top:active { background: var(--primary-hover); border-color: var(--primary-hover); }
@media (hover: hover) and (pointer: fine) {
  .back-to-top:hover { background: var(--primary); border-color: var(--primary); }
}
html[data-pn-motion="off"] *,
html[data-pn-motion="off"] *::before,
html[data-pn-motion="off"] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
@media (max-width: 760px) { .back-to-top { left: max(16px, env(safe-area-inset-left, 0px)); } }

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .portal-card,
  .material-card,
  .profession-card,
  .route-card,
  .material-card .card-media img,
  .back-to-top,
  .back-to-top svg {
    transform: none !important;
  }
  .back-to-top .top-progress { transform: rotate(-90deg) !important; }

  .mega-panel {
    translate: none !important;
    opacity: 1;
  }
}

@media (forced-colors: active) {
  .portal-card,
  .material-card,
  .profession-card,
  .route-card {
    border: 1px solid CanvasText;
    box-shadow: none;
  }

  .portal-card:focus-within,
  .material-card:focus-within,
  .profession-card:focus-within,
  .route-card:focus-within {
    border-color: Highlight;
  }

  :root :is(input,select,textarea):focus-visible,
  .button:focus-visible,
  :is(.record-dialog-close,.dialog-close,.mobile-menu-button):focus-visible { border-color: Highlight; }

  .back-to-top {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonText;
    box-shadow: none;
  }

  .back-to-top:hover,
  .back-to-top:active {
    background: Highlight;
    color: HighlightText;
    border-color: Highlight;
  }

  .back-to-top:focus-visible,
  .back-to-top:active {
    border-color: Highlight;
    box-shadow: none;
  }

  .button.primary:focus-visible,
  .button--primary:focus-visible {
    box-shadow: none;
  }
}
