/*
 * Physics SciEd Final Student Portal Harmonization
 * Milestone 6 integration layer v1.0
 *
 * This stylesheet intentionally contains only shared cross-page refinements.
 * Page-specific controllers and page-specific layout systems remain unchanged.
 */

:root {
  --psc-student-shell-max: 1420px;
  --psc-student-header-height: 68px;
  --psc-student-page-gap: clamp(12px, 2vw, 22px);
  --psc-student-section-radius: 20px;
  --psc-student-card-radius: 16px;
  --psc-student-mobile-nav-height: 68px;
}

/* ---------------------------------------------------------
   Universal learner-page hygiene
   --------------------------------------------------------- */

html {
  scroll-behavior: smooth;
}

body.psc-student-portal,
body.psc-reader-page,
body.psc-assessment-page,
body.psc-library-page {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.psc-student-portal img,
body.psc-reader-page img,
body.psc-assessment-page img,
body.psc-library-page img {
  max-width: 100%;
}

body.psc-student-portal button,
body.psc-student-portal a,
body.psc-reader-page button,
body.psc-reader-page a,
body.psc-assessment-page button,
body.psc-assessment-page a,
body.psc-library-page button,
body.psc-library-page a {
  -webkit-tap-highlight-color: transparent;
}

body.psc-student-portal :where(a, button, input, select, textarea):focus-visible,
body.psc-reader-page :where(a, button, input, select, textarea):focus-visible,
body.psc-assessment-page :where(a, button, input, select, textarea):focus-visible,
body.psc-library-page :where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(243, 198, 50, 0.42) !important;
  outline-offset: 2px;
}

/* ---------------------------------------------------------
   Shared learner headers
   --------------------------------------------------------- */

.student-portal-navbar,
.assessment-portal-header {
  min-height: var(--psc-student-header-height) !important;
}

.student-portal-navbar-inner,
.assessment-portal-header-inner {
  width: min(var(--psc-student-shell-max), 100%) !important;
  min-height: var(--psc-student-header-height) !important;
}

.student-portal-brand-copy strong,
.assessment-portal-brand-copy strong {
  letter-spacing: -0.018em !important;
}

.student-portal-brand-copy small,
.assessment-portal-brand-copy small {
  line-height: 1.22 !important;
}

/* ---------------------------------------------------------
   Shared shell alignment
   --------------------------------------------------------- */

.student-reader-context-inner,
.student-reader-shell,
.quiz-result-shell,
.library-page-shell,
.assessment-dashboard-shell,
.assessment-login-shell {
  width: min(var(--psc-student-shell-max), 100%) !important;
}

.student-reader-context,
.student-reader-shell,
.quiz-result-shell,
.library-page-shell,
.assessment-dashboard-shell {
  padding-inline:
    var(--psc-student-page-gap) !important;
}

.student-reader-context-inner,
.student-reader-card,
.quiz-result-heading-card,
.quiz-result-score-card,
.quiz-result-review-card,
.library-intro-panel,
.library-directory-card,
.assessment-dashboard-intro,
.assessment-card,
#resultArea {
  box-shadow: none !important;
}

/* ---------------------------------------------------------
   Cross-page button consistency
   --------------------------------------------------------- */

body.psc-student-portal .btn,
body.psc-reader-page .btn,
body.psc-assessment-page .btn,
body.psc-library-page .btn {
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif !important;
}

body.psc-student-portal .btn-primary,
body.psc-reader-page .btn-primary,
body.psc-assessment-page .btn-primary,
body.psc-library-page .btn-primary {
  color: #10233f !important;
  background: #f3c632 !important;
  border-color: #f3c632 !important;
  box-shadow: none !important;
}

body.psc-student-portal .btn-primary:hover,
body.psc-student-portal .btn-primary:focus,
body.psc-reader-page .btn-primary:hover,
body.psc-reader-page .btn-primary:focus,
body.psc-assessment-page .btn-primary:hover,
body.psc-assessment-page .btn-primary:focus,
body.psc-library-page .btn-primary:hover,
body.psc-library-page .btn-primary:focus {
  color: #10233f !important;
  background: #dfaf1f !important;
  border-color: #dfaf1f !important;
}

/* ---------------------------------------------------------
   Shared field consistency
   --------------------------------------------------------- */

body.psc-student-portal .form-control,
body.psc-student-portal .form-select,
body.psc-reader-page .form-control,
body.psc-reader-page .form-select,
body.psc-assessment-page .form-control,
body.psc-assessment-page .form-select,
body.psc-library-page .form-control,
body.psc-library-page .form-select {
  color: #10233f !important;
  background-color: #ffffff !important;
  border-color: #d8cfae !important;
  box-shadow: none !important;
}

body.psc-student-portal .form-control:focus,
body.psc-student-portal .form-select:focus,
body.psc-reader-page .form-control:focus,
body.psc-reader-page .form-select:focus,
body.psc-assessment-page .form-control:focus,
body.psc-assessment-page .form-select:focus,
body.psc-library-page .form-control:focus,
body.psc-library-page .form-select:focus {
  border-color: #174ea6 !important;
  box-shadow: 0 0 0 0.18rem rgba(23, 78, 166, 0.14) !important;
}

/* ---------------------------------------------------------
   Learner-dashboard integration
   --------------------------------------------------------- */

.student-feature-links {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.student-feature-link {
  min-width: 0;
  height: 100%;
}

.student-feature-link > span:nth-child(2) {
  min-width: 0;
}

.student-feature-link strong,
.student-feature-link small {
  overflow-wrap: anywhere;
}

.student-feature-link > i:last-child {
  flex: 0 0 auto;
}

/* ---------------------------------------------------------
   Reader and result alignment
   --------------------------------------------------------- */

.student-reader-title,
.quiz-result-title,
.library-intro-panel h1,
.assessment-login-intro h1,
.assessment-dashboard-intro h1 {
  text-wrap: balance;
}

.student-reader-canvas-wrap {
  overscroll-behavior: contain;
}

.answer-result-item,
.review-question-card,
.book-card,
.answer-row {
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}

/* ---------------------------------------------------------
   Mobile integration
   --------------------------------------------------------- */

@media (max-width: 1040px) {
  .student-feature-links {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .student-portal-navbar-inner,
  .assessment-portal-header-inner {
    gap: 9px !important;
  }
}

@media (max-width: 700px) {
  .student-reader-context-inner,
  .library-intro-panel,
  .library-directory-card,
  .assessment-dashboard-intro,
  .assessment-card,
  #resultArea {
    border-radius: 17px !important;
  }

  .student-reader-context,
  .student-reader-shell,
  .quiz-result-shell,
  .library-page-shell,
  .assessment-dashboard-shell {
    padding-inline: 10px !important;
  }
}

@media (max-width: 520px) {
  .student-portal-brand-copy small,
  .assessment-portal-brand-copy small {
    max-width: 72vw !important;
  }

  .student-feature-link {
    min-height: 68px;
  }

  .student-reader-tools,
  .assessment-header-actions {
    scrollbar-width: thin;
  }
}

/* ---------------------------------------------------------
   Reduced motion
   --------------------------------------------------------- */

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

  body.psc-student-portal *,
  body.psc-reader-page *,
  body.psc-assessment-page *,
  body.psc-library-page * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
/* =========================================================
   Final Student Dashboard Layout Hotfix v1.0.1
   Prevents the three quick tools from being squeezed inside
   the former narrow welcome-panel side column.
   ========================================================= */

body.psc-student-page .student-welcome-panel {
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: start !important;
  gap: 18px !important;
}

body.psc-student-page .student-welcome-copy {
  max-width: 980px;
}

body.psc-student-page .student-feature-links {
  width: 100% !important;
  max-width: none !important;
  grid-template-columns:
    repeat(3, minmax(0, 1fr)) !important;
  align-items: stretch;
}

body.psc-student-page .student-feature-link {
  width: 100%;
  height: auto !important;
  min-height: 76px;
}

body.psc-student-page
.student-feature-link
> span:nth-child(2) {
  min-width: 0;
}

body.psc-student-page .student-feature-link strong,
body.psc-student-page .student-feature-link small {
  word-break: normal !important;
  overflow-wrap: break-word !important;
  writing-mode: horizontal-tb !important;
}

@media (max-width: 1040px) {
  body.psc-student-page .student-feature-links {
    grid-template-columns: 1fr !important;
  }

  body.psc-student-page .student-feature-link {
    max-width: none !important;
  }
}

@media (max-width: 640px) {
  body.psc-student-page .student-welcome-panel {
    gap: 14px !important;
  }

  body.psc-student-page .student-feature-link {
    min-height: 68px;
  }
}
