/*
 * BalanceAI Professional Learning.
 *
 * Palette lifted from BalanceAI_Frontend/src/theming/colors.ts so the site
 * reads as the same product: primary #264653, hover #3b6d7c, body text
 * #5c677d. No framework, no build step — one stylesheet.
 */

:root {
  --primary: #264653;
  --hover: #3b6d7c;
  --body: #5c677d;
  --ink: #1d3640;
  --accent: #05a5f6;
  --surface: #ffffff;
  --page: #eef4f5;
  --line: #d8e2e5;
  --error: #b3261e;
  --ok: #2a9d8f;
  --radius: 12px;
  --wrap: 58rem;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute is styled by the browser as `display: none`, but any
   author rule that sets `display` outranks it — so `.overlay { display: flex }`
   made the video dialog show over the sign-in page even while hidden. This
   restores the attribute's meaning for every element that has it. Keep it
   above everything that sets `display`. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchored modules would otherwise land under the sticky header. */
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  z-index: 30;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

/* ---------- header + nav ---------- */

.site-header {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 15;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 58px;
  flex-wrap: wrap;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.brand {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
}

.brand-sub {
  color: #c7dae0;
  font-size: 0.9rem;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  padding-left: 0.75rem;
}

.site-nav {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  flex: 1 1 100%;
  order: 3;
}

.nav-link {
  color: #c7dae0;
  text-decoration: none;
  font-size: 0.83rem;
  padding: 0.15rem 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.nav-link:hover {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* Set by the scroll-spy observer as each module comes into view. */
.nav-link.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.signed-in-as {
  color: #c7dae0;
  font-size: 0.82rem;
}

main {
  padding: 1.75rem 0 4rem;
  min-height: 60vh;
}

/* ---------- shared ---------- */

h1 {
  font-size: 1.9rem;
  font-weight: 500;
  margin: 0 0 0.75rem;
}

h2 {
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0;
  color: var(--primary);
}

.muted {
  color: var(--body);
}
.small {
  font-size: 0.85rem;
}
.error {
  color: var(--error);
  margin: 0.75rem 0 0;
}
.notice {
  color: var(--primary);
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

/* Cards carry a hairline plus one soft shadow rather than a heavy border.
   On a pale page the shadow does the separating and the border only keeps
   the edge crisp — together they read as paper on a desk instead of boxes
   drawn on a screen. */
.card {
  background: var(--surface);
  border: 1px solid #e4edef;
  border-radius: var(--radius);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1.15rem;
  box-shadow: 0 1px 2px rgba(29, 54, 64, 0.04),
    0 6px 16px rgba(29, 54, 64, 0.05);
}

/* A finished module recedes: it keeps its place in the path but stops
   competing for attention with the one the teacher is on. */
.module.is-done {
  background: #fbfdfd;
}
.module.is-done .module-number {
  background: var(--ok);
}
.module.is-done .module-title {
  color: var(--body);
}

/* width/height on the <img> reserve the box before the file arrives, so the
   page does not jump once a 240 KB hero loads over school wifi. */
.hero {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.intro-card p {
  margin: 0 0 0.6rem;
}

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  align-self: flex-start;
}
.btn:hover:not(:disabled) {
  background: var(--hover);
}
.btn:disabled {
  background: var(--body);
  cursor: default;
}
.btn-small {
  padding: 0.45rem 1rem;
  font-size: 0.87rem;
}

.btn-quiet {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.btn-quiet:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  padding: 0;
  margin-top: 1rem;
  cursor: pointer;
}

/* A visible focus ring everywhere: this site is used on shared staffroom
   machines and school iPads where keyboard navigation is common. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--hover);
  outline-offset: 2px;
}

/* ---------- sign in ---------- */

.signin-card {
  max-width: 26rem;
  margin: 2rem auto;
}

form label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-size: 0.9rem;
  color: var(--body);
}

form input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

form .btn {
  margin-top: 1.5rem;
  width: 100%;
}

/* ---------- track switch + progress ---------- */

.track-switch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.track-label {
  font-size: 0.85rem;
  color: var(--body);
}

.track-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.track-btn {
  background: var(--surface);
  border: 1px solid #b9ccd2;
  color: var(--ink);
  border-radius: 20px;
  padding: 0.35rem 0.95rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.track-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.progress-card {
  padding: 1rem 1.4rem;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.progress-track {
  background: #dfe9ec;
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0;
  transition: width 0.25s ease;
}

.progress-note {
  margin: 0.6rem 0 0;
}

/* ---------- modules ---------- */

.module-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

/* A circle rather than a chip: it reads as a step in a sequence, and gives
   the completed state somewhere obvious to put a tick. */
.module-number {
  background: var(--primary);
  color: #fff;
  font-size: 0.8rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
}

.module-title {
  flex: 1;
  min-width: 12rem;
}

.module-time {
  white-space: nowrap;
}

/* No rounded corners on a single-sided border. */
.objective {
  background: var(--page);
  border-left: 3px solid var(--accent);
  padding: 0.6rem 0.85rem;
  margin: 0 0 0.9rem;
  color: #41626e;
  font-size: 0.92rem;
}

.module-body {
  color: var(--body);
  margin: 0 0 0.8rem;
}

/* Unreviewed copy, marked so it cannot ship quietly. Amber rather than red:
   this is "not checked yet", not "broken". */
.draft-note {
  background: #fdf6e6;
  border: 1px solid #f0dcae;
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  margin: 0 0 0.9rem;
  color: #7a5a12;
  font-size: 0.87rem;
}

.draft-note strong {
  color: #6b4e0d;
}

/* The "why we ask twice" note on the pre self-assessment. Quieter than the
   objective band: it is context, not instruction. */
.rationale {
  color: var(--body);
  font-size: 0.88rem;
  background: var(--surface);
  border-left: 3px solid #85b7eb;
  padding: 0.6rem 0.85rem;
  margin: 0 0 0.9rem;
}

.module-steps {
  color: var(--body);
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
}
.module-steps li {
  margin-bottom: 0.45rem;
}

.task {
  background: #f4f8f9;
  border-left: 3px solid var(--ok);
  padding: 0.6rem 0.85rem;
  margin: 0.9rem 0;
  color: #41626e;
  font-size: 0.92rem;
}

.module-link {
  display: inline-block;
  color: var(--primary);
  font-size: 0.9rem;
  margin: 0 1rem 0.5rem 0;
}

/* ---------- videos ---------- */

/* The poster frame is the background; the button sits over it with a scrim
   so white slide content cannot swallow the play control. */
.inline-video {
  background-color: #0f1e24;
  background-size: cover;
  background-position: center;
  border-radius: 10px;
  margin: 0.9rem 0;
  overflow: hidden;
  line-height: 0;
}

.inline-video video {
  width: 100%;
  max-height: 60vh;
  display: block;
}

.inline-play {
  background: linear-gradient(
    to bottom,
    rgba(15, 30, 36, 0.35),
    rgba(15, 30, 36, 0.6)
  );
  border: none;
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0;
  cursor: pointer;
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}

.inline-play:hover .play-badge {
  transform: scale(1.06);
  background: var(--hover);
}

.play-badge {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  background: rgba(38, 70, 83, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  padding-left: 0.18rem;
  transition: transform 0.15s ease, background 0.15s ease;
}

.play-text {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.play-time {
  opacity: 0.85;
}

/* ---------- slides ---------- */

.slides {
  margin: 0.9rem 0;
}

.slides:focus-visible {
  outline: 3px solid var(--hover);
  outline-offset: 4px;
}

/* 16:9 box reserved up front so the module does not reflow as each slide
   loads, and a neutral backdrop for decks that are not 16:9. */
.slide-frame {
  background: #0f1e24;
  border-radius: 10px;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.slide-img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.slide-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.6rem;
}

.slide-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--primary);
  border-radius: 8px;
  padding: 0.35rem 0.9rem;
  font: inherit;
  font-size: 0.87rem;
  cursor: pointer;
}
.slide-btn:hover:not(:disabled) {
  background: var(--page);
}
.slide-btn:disabled {
  color: #a3b4b9;
  cursor: default;
}

.slide-counter {
  min-width: 7rem;
  text-align: center;
}

.slide-caption {
  text-align: center;
  margin: 0.5rem auto 0;
  max-width: 34rem;
}

/* auto-fit gives one column on a phone and two or three on a laptop with no
   media-query ladder. min() stops a long title widening the track. */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 0.9rem;
  margin: 0.9rem 0;
}

.video-card {
  border: 1px solid #e4edef;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.video-card:hover {
  box-shadow: 0 2px 4px rgba(29, 54, 64, 0.06),
    0 10px 22px rgba(29, 54, 64, 0.09);
  transform: translateY(-2px);
}

.video-card.dimmed {
  opacity: 0.78;
}
.video-card.dimmed:hover {
  box-shadow: none;
  transform: none;
}

.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #dde7ea;
  overflow: hidden;
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    #e7eef0,
    #e7eef0 10px,
    #dfe9ec 10px,
    #dfe9ec 20px
  );
}

.thumb-soon {
  color: var(--body);
  font-size: 0.82rem;
  font-style: italic;
}

.thumb-play {
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(38, 70, 83, 0.9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  padding-left: 0.1rem;
}

.video-title {
  color: var(--primary);
  font-size: 0.98rem;
  font-weight: 500;
  padding: 0.8rem 0.95rem 0;
}

.video-card > .muted.small {
  padding: 0.1rem 0.95rem 0;
}

.video-desc {
  color: var(--body);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0.45rem 0 0.9rem;
  padding: 0 0.95rem;
  flex: 1;
}

.video-card .btn,
.video-card .coming-soon {
  margin: 0 0.95rem 0.95rem;
}

.coming-soon {
  color: var(--body);
  font-style: italic;
  font-size: 0.87rem;
  margin: 0;
}

/* ---------- reflection + done ---------- */

.reflection {
  background: var(--page);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-top: 1rem;
}

.reflection-label {
  font-size: 0.78rem;
  text-transform: none;
  color: var(--body);
  margin-bottom: 0.25rem;
}

.reflection-prompt {
  margin: 0 0 0.6rem;
  color: var(--ink);
  font-size: 0.95rem;
}

.reflection textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 0.92rem;
  resize: vertical;
  background: var(--surface);
}

.done-check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1rem;
  font-size: 0.92rem;
  color: var(--body);
  cursor: pointer;
}

.done-check input {
  width: 1.05rem;
  height: 1.05rem;
}

/* ---------- self-assessment ---------- */

.selfcheck {
  border-color: #85b7eb;
  background: #f7fbff;
}
.selfcheck.post {
  border-color: #5dcaa5;
  background: #f6fcfa;
}
.selfcheck .module-number {
  background: #185fa5;
}
.selfcheck.post .module-number {
  background: #0f6e56;
}

.rating-row {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 0.9rem 0 0.4rem;
}

.rating-text {
  padding: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 0.55rem;
}

.rating-scale {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rating-anchor {
  white-space: nowrap;
}

/* The radio is kept in the DOM (not display:none) so it stays reachable by
   keyboard and screen reader; it is the visible dot that is styled. */
.rating-dot {
  position: relative;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.rating-dot input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.rating-num {
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid #b5d4f4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--body);
  background: var(--surface);
}

.rating-dot input:checked + .rating-num {
  border: 2px solid #185fa5;
  background: #e6f1fb;
  color: #0c447c;
}

.rating-dot input:focus-visible + .rating-num {
  outline: 3px solid var(--hover);
  outline-offset: 2px;
}

/* ---------- growth ---------- */

.growth {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.growth-row {
  margin-bottom: 0.9rem;
}

.growth-text {
  font-size: 0.9rem;
  color: var(--ink);
  margin-bottom: 0.4rem;
}

.growth-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.growth-label {
  width: 3.2rem;
  flex-shrink: 0;
}

.growth-track {
  flex: 1;
  background: #e6ecee;
  border-radius: 5px;
  height: 9px;
  overflow: hidden;
}

.growth-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
}
.growth-fill.before {
  background: #b4b2a9;
}
.growth-fill.after {
  background: #1d9e75;
}

.growth-value {
  width: 1rem;
  text-align: right;
}

.growth-note {
  color: var(--body);
  font-size: 0.88rem;
  background: var(--surface);
  border-left: 3px solid var(--ok);
  padding: 0.6rem 0.85rem;
  margin: 1rem 0 0;
}

/* ---------- results and certificate ---------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.stat {
  background: var(--page);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.stat-value {
  font-size: 1.5rem;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  margin-top: 0.15rem;
}

.record-sub {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 0.25rem;
}

.record .growth {
  margin-top: 0.5rem;
  border-top: none;
  padding-top: 0;
}

.record-caveat {
  margin: 0.9rem 0 0;
}

.optional-tag {
  background: var(--page);
  color: var(--body);
  font-size: 0.72rem;
  border-radius: 20px;
  padding: 0.1rem 0.6rem;
  align-self: center;
}

/* ---------- player ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 20;
}

.player-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: min(64rem, 100%);
  overflow: hidden;
}

.player-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.player-head h2 {
  font-size: 1.1rem;
}
.player-head p {
  margin: 0.15rem 0 0;
}
.player-head .btn-quiet {
  color: var(--primary);
  border-color: var(--line);
}
.player-head .btn-quiet:hover {
  background: var(--page);
}

.player-mount {
  background: #000;
  line-height: 0;
}

.player-mount video {
  width: 100%;
  max-height: 72vh;
  display: block;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
}
.site-footer a {
  color: var(--primary);
}

/* ---------- print ----------
   The record is built into #print-area on demand and everything else is
   hidden, so a teacher gets a clean one-page summary rather than a printed
   screenshot of the site. */

#print-area {
  display: none;
}

@media print {
  body > *:not(#print-area) {
    display: none !important;
  }

  #print-area {
    display: block;
    font-size: 11pt;
    color: #000;
  }

  #print-area h1 {
    font-size: 22pt;
    margin: 0.2rem 0 0.6rem;
  }

  .cert-kicker {
    font-size: 10pt;
    letter-spacing: 1pt;
    text-transform: uppercase;
    margin: 0;
    color: #444;
  }

  .cert-name {
    font-size: 15pt;
    font-weight: bold;
    margin: 0 0 0.2rem;
  }

  .cert-date {
    font-size: 10pt;
    color: #444;
    margin: 0 0 1rem;
  }
  #print-area h2 {
    font-size: 12pt;
    margin-top: 1.2rem;
    color: #000;
  }
  #print-area h3 {
    font-size: 11pt;
    margin: 0.8rem 0 0.2rem;
  }
  #print-area table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.4rem;
  }
  #print-area th,
  #print-area td {
    border: 1px solid #999;
    padding: 4px 6px;
    text-align: left;
    font-size: 10pt;
    vertical-align: top;
  }
  #print-area ul {
    padding-left: 1.1rem;
  }
  .print-footnote {
    margin-top: 1.5rem;
    font-size: 9pt;
    color: #444;
  }
}
