/* OneLearn Global course assistant. Brand: OneCare Group guidelines 2025 (navy 274C, gold 871C). */

:root {
  --navy: #231e56;
  --navy-deep: #171340;
  --gold: #b9a879;
  --gold-soft: rgba(185, 168, 121, 0.18);
  --paper: #f6f6fa;
  --ink: #1d1b35;
  --ink-muted: #5c5a74;
  --line: #dddce8;
  --focus: #3678b8;
  --question-bg: rgba(35, 30, 86, 0.07);

  --font-heading: "Poppins", system-ui, sans-serif;
  --font-body: "Montserrat", system-ui, sans-serif;

  --rail-width: 300px;
  --measure: 72ch;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button, textarea, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.nowrap { white-space: nowrap; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Layout */

.shell {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  grid-template-rows: 100%;
  height: 100vh;
  height: 100dvh;
}

/* Scope rail: the course boundary, always visible on desktop */

.rail {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 32px 24px 24px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  overflow-y: auto;
}

.rail-logo { width: 100%; max-width: 252px; height: auto; }

.rail-kicker {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

.rail-title {
  margin: 0;
  font: 600 22px/1.25 var(--font-heading);
}

.rail-standard {
  margin: 6px 0 0;
  color: var(--gold);
  font-size: 13px;
}

.rail-sections {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.rail-sections li {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: baseline;
  padding: 8px 10px 8px 12px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.78);
  font: 500 14px/1.35 var(--font-heading);
  transition: background-color 400ms ease, color 400ms ease;
}

.rail-sections .num {
  color: rgba(185, 168, 121, 0.75);
  font-weight: 600;
}

/* The one motion moment: sections used in the latest answer light up */
.rail-sections li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--gold);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 400ms ease;
}

.rail-sections li.is-cited {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.rail-sections li.is-cited .num { color: var(--gold); }
.rail-sections li.is-cited::before { transform: scaleY(1); }

.rail-scope {
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.rail-signout { margin-top: auto; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-button:hover { color: #fff; }

/* Chat column */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.chat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
}

.chat-bar-title {
  margin: 0;
  color: var(--ink-muted);
  font: 500 14px var(--font-heading);
}

.scope-toggle { display: none; }

.new-chat {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.new-chat:hover { border-color: var(--navy); }

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Centred reading column: side padding grows so content never exceeds the measure */
  padding: 40px max(32px, calc((100% - var(--measure)) / 2)) 24px;
}

/* Empty state */

.welcome { text-align: center; }

.welcome h2 {
  margin: 12vh 0 8px;
  color: var(--navy);
  font: 600 28px/1.2 var(--font-heading);
}

.welcome p {
  margin: 0 0 28px;
  color: var(--ink-muted);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.suggestions button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.suggestions button:hover {
  border-color: var(--navy);
  color: var(--navy);
}

/* Conversation */

.turn { margin: 0 0 32px; }

.question {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--question-bg);
  color: var(--navy);
  font-weight: 500;
  white-space: pre-wrap;
}

.answer p { margin: 0 0 12px; }
.answer ul { margin: 0 0 12px; padding-left: 20px; }
.answer li { margin-bottom: 6px; }
.answer strong { font-weight: 600; }

.answer.is-streaming > :last-child::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--gold);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret { 50% { opacity: 0; } }

.answer.is-declined {
  padding-left: 14px;
  border-left: 3px solid var(--gold);
  color: var(--ink-muted);
}

.answer.is-error {
  padding-left: 14px;
  border-left: 3px solid #b3261e;
  color: var(--ink);
}

.cite {
  display: inline-block;
  min-width: 18px;
  margin: 0 1px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: var(--gold-soft);
  color: var(--navy);
  font: 600 11px/17px var(--font-heading);
  vertical-align: 2px;
  cursor: pointer;
}

.cite:hover { background: var(--gold); }

.sources {
  margin: 4px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}

.sources h3 {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font: 500 13px var(--font-heading);
}

.sources ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.sources li {
  display: grid;
  grid-template-columns: 26px 1fr;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  transition: background-color 300ms ease;
}

.sources li.is-highlighted { background: var(--gold-soft); }

.sources .source-num {
  color: var(--navy);
  font: 600 13px var(--font-heading);
}

.sources .source-section { color: var(--ink-muted); }
.sources .source-slide { color: var(--ink); font-weight: 500; }

/* Composer */

.composer {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: min(100%, calc(var(--measure) + 64px));
  margin: 0 auto;
  padding: 16px 32px 8px;
}

.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  resize: none;
  overflow-y: hidden;
  line-height: 1.5;
}

.composer textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }

.composer button {
  height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font: 600 14px var(--font-heading);
  cursor: pointer;
}

.composer button:disabled { opacity: 0.45; cursor: not-allowed; }

.counter {
  position: absolute;
  right: 124px;
  bottom: 14px;
  color: var(--ink-muted);
  font-size: 12px;
}

.footnote {
  width: min(100%, calc(var(--measure) + 64px));
  margin: 0 auto;
  padding: 0 32px 16px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12px;
}

/* Mobile: the rail becomes a sheet opened from the top bar */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: min(88vw, 340px);
    transform: translateX(-100%);
    transition: transform 250ms ease;
  }

  .rail.is-open {
    transform: none;
    box-shadow: 0 0 0 100vmax rgba(23, 19, 64, 0.45);
  }

  .chat-bar {
    padding: 10px 16px;
    background: var(--navy);
    border-bottom: 0;
  }

  .chat-bar-title { display: none; }

  .scope-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
    border: 0;
    background: none;
    color: #fff;
    font: 500 13px var(--font-heading);
    cursor: pointer;
  }

  .scope-toggle span {
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
  }

  .new-chat {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
  }

  .thread { padding: 24px 16px 16px; }
  .welcome h2 { margin-top: 2vh; font-size: 24px; }
  .composer { padding: 12px 16px 6px; }
  .counter { right: 108px; }
  .footnote { padding: 0 16px 12px; }
}

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

/* Login */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
}

.login-card {
  width: min(100%, 400px);
  text-align: center;
  padding: 36px 32px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.login-card img { display: block; width: 150px; height: auto; margin: 0 auto 24px; }

.login-card h1 {
  margin: 0 0 8px;
  color: var(--navy);
  font: 600 22px/1.3 var(--font-heading);
}

.login-card p {
  margin: 0 0 24px;
  color: var(--ink-muted);
  font-size: 14px;
}

.login-card label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
}

.login-card input {
  width: 100%;
  height: 46px;
  margin-bottom: 16px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-card input:focus-visible { outline-offset: 0; border-color: var(--focus); }

.login-card button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font: 600 15px var(--font-heading);
  cursor: pointer;
}

.login-error {
  margin: -4px 0 16px !important;
  color: #b3261e !important;
  font-weight: 500;
}

.login-card .login-footer {
  margin: 20px 0 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12px;
  text-align: center;
}
