/* ----------------------------------------------------------------------
   Learning Platform — front desk.
   Visual language ported from the original Algebra 2 companion select:
   dark, quiet, editorial. Each selection screen is its own full view and
   reuses one card (.pick-card) with a per-card accent color.
---------------------------------------------------------------------- */

:root {
  --bg:      #101317;
  --panel:   #161a20;
  --panel-2: #1c222a;
  --line:    #232830;
  --text:    #e9e7e1;   /* warm off-white */
  --muted:   #9aa0a8;
  --faint:   #5c636d;
  --accent:  #8fb6d9;   /* chalk blue */
  --danger:  #c98484;
  --correct: #8fd99c;
  --radius:  10px;
  --font: "Outfit", "Century Gothic", "Futura", "Avenir Next", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- screens -------------------------------------------------------- */

.view {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: clamp(4vh, 7vh, 9vh) 32px;
}
.view[hidden] { display: none; }

.screen-inner {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}

/* header row: back / context on the left, an action on the right */
.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(18px, 3vh, 30px);
  min-height: 24px;
}
.screen-head .context { color: var(--muted); font-size: 0.9rem; }

.screen-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.screen-sub {
  color: var(--muted);
  margin-bottom: clamp(20px, 3.5vh, 36px);
}

/* --- text link / back button --------------------------------------- */

.link {
  font: inherit;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 0;
  transition: color 120ms ease;
}
.link:hover { color: var(--text); }

/* --- login ---------------------------------------------------------- */

#login-view { display: flex; align-items: center; justify-content: center; }

.login-card {
  width: 100%;
  max-width: 380px;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 9%, var(--panel)) 0%,
      var(--panel) 55%);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  border-radius: var(--radius);
  padding: 36px 32px 32px;
}
.login-card h1 {
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.login-card .screen-sub { margin-bottom: 24px; }

form { display: flex; flex-direction: column; gap: 16px; }
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
input {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
input:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--faint); text-transform: none; letter-spacing: 0; }

button[type="submit"] {
  font: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  padding: 11px;
  cursor: pointer;
  margin-top: 4px;
  transition: filter 120ms ease;
}
button[type="submit"]:hover { filter: brightness(1.08); }

.error { color: var(--danger); font-size: 0.86rem; }

/* --- card grids (games / assignments / companions) ------------------ */

.pick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 720px) {
  .pick-grid { grid-template-columns: 1fr; }
}

.pick-card {
  --pc: var(--accent);                 /* per-card accent, set inline */
  position: relative;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--pc) 10%, var(--panel)) 0%,
      var(--panel) 55%);
  border: 1px solid color-mix(in srgb, var(--pc) 35%, var(--line));
  border-radius: var(--radius);
  padding: 24px 22px 26px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition:
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 220ms ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.pick-card::before {                  /* soft top-edge glow in the card's color */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--pc);
  opacity: 0.7;
}
.pick-card:hover {
  border-color: var(--pc);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px -14px color-mix(in srgb, var(--pc) 80%, transparent);
}
.pick-card:disabled { opacity: 0.5; cursor: progress; transform: none; box-shadow: none; }

.pick-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.pick-icon {
  font-size: 2rem;
  line-height: 1;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pc) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--pc) 45%, var(--line));
  margin-bottom: 6px;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--pc) 30%, transparent));
}

.pick-name {
  font-size: 1.18rem;
  font-weight: 500;
  color: var(--pc);
  letter-spacing: 0.005em;
}
.pick-tagline {
  color: var(--muted);
  font-size: 0.9rem;
}
.pick-sample {
  margin-top: auto;
  color: var(--faint);
  font-size: 0.86rem;
  font-style: italic;
  line-height: 1.45;
  padding-top: 10px;
  border-top: 1px dashed color-mix(in srgb, var(--pc) 28%, var(--line));
}

/* assignment status badge inside a card */
.pick-meta {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed color-mix(in srgb, var(--pc) 28%, var(--line));
}
.badge {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge.complete   { color: var(--correct); border-color: color-mix(in srgb, var(--correct) 40%, var(--line)); }
.badge.incomplete { color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

/* small "locked / not assigned" tag on a game card */
.pick-flag {
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}

/* viewport-tall buffer before the discoverable companion tier */
.select-spacer { height: 70vh; pointer-events: none; }

.empty { color: var(--faint); font-size: 0.92rem; }

/* --- in-game placeholder -------------------------------------------- */

.stage {
  max-width: 480px;
  margin: 8vh auto 0;
  text-align: center;
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 8%, var(--panel)) 0%,
      var(--panel) 55%);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: var(--radius);
  padding: 40px 32px 44px;
}
.stage .pick-icon { margin: 0 auto 14px; width: 64px; height: 64px; font-size: 2.4rem; }
.stage h1 { font-size: 1.6rem; font-weight: 400; margin-bottom: 6px; }
.stage .screen-sub { margin-bottom: 18px; }

/* ======================================================================
   Journey game screen — work surface + companion chat.
   Ported from the original game; uses the same palette/vars defined above.
====================================================================== */

#game-view { padding: 0; }

.game-app {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr);
  height: 100%;
  max-width: 1480px;
  margin: 0 auto;
}

.work {
  display: flex;
  flex-direction: column;
  padding: clamp(20px, 4vh, 44px) clamp(20px, 3.5vw, 56px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
}

/* --- RPG panel ------------------------------------------------------- */
.rpg {
  font-size: 0.86rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: clamp(18px, 3vh, 32px);
  background: rgba(255, 255, 255, 0.015);
}
.rpg-stats { display: flex; flex-wrap: wrap; gap: 18px; font-weight: 500; }
.rpg-stats span > span { color: var(--text); }
.rpg-player { color: var(--accent); }
.rpg-hp { color: #c98484; }
.rpg-atk { color: #d9b97a; }
.rpg-xp { color: #7faecb; }
.rpg-bar { height: 6px; background: var(--line); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.rpg-bar-fill { height: 100%; width: 100%; border-radius: 999px; transition: width 320ms ease; }
.rpg-bar-hp { background: #c98484; }
.rpg-bar-enemy { background: #b58fd9; }
.rpg-enemy { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.rpg-enemy.hidden { display: none; }
.rpg-enemy-name { display: flex; justify-content: space-between; color: var(--text); font-weight: 500; }
.rpg-enemy-hp { color: #b58fd9; }
.rpg-enemy-flavor { margin-top: 2px; color: var(--faint); font-style: italic; }
.rpg-log { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--faint); white-space: pre-wrap; min-height: 1.2em; line-height: 1.55; }
.rpg-log .new { color: var(--text); animation: rpgflash 1200ms ease both; }
@keyframes rpgflash { 0% { background: rgba(143,182,217,0.18); } 100% { background: transparent; } }

/* --- question -------------------------------------------------------- */
.unit-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: clamp(24px, 5vh, 56px); }
.unit-label { font-size: 0.78rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.gate-readout { font-size: 0.72rem; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--faint); white-space: nowrap; }
.gate-readout.help { color: #d9b97a; font-weight: 600; }
.question { margin-bottom: clamp(28px, 5vh, 56px); }
.q-header { font-size: clamp(1.7rem, 3.4vw, 2.7rem); font-weight: 400; letter-spacing: -0.015em; line-height: 1.18; text-wrap: balance; }
.q-subheader { margin-top: 14px; font-size: 1.05rem; color: var(--muted); max-width: 56ch; }

/* --- options --------------------------------------------------------- */
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.option { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font: inherit; font-size: 1.02rem; cursor: pointer; transition: border-color 120ms ease, background-color 120ms ease; }
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.option .letter { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.option .label { min-width: 0; overflow-wrap: anywhere; }
.option.wrong-flash { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, var(--panel)); color: var(--text); }
.option.wrong-flash .letter { border-color: var(--danger); color: var(--danger); }
.option.correct-flash { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 18%, var(--panel)); color: var(--text); }
.option.correct-flash .letter { border-color: var(--correct); color: var(--correct); }
.option.eliminated, .option:disabled { cursor: default; }
.option.eliminated { opacity: 0.45; background: transparent; }
.option.eliminated .label { text-decoration: line-through; }
.option.eliminated .letter { border-style: dashed; }

/* --- free-response (row layout — override the column `form` rule) ---- */
.free-form { display: flex; flex-direction: row; gap: 12px; align-items: stretch; }
.free-form input { flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.free-form input:focus { outline: none; border-color: var(--accent); }
.free-form input.wrong-flash { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 18%, var(--panel)); }
.free-form input.correct-flash { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 18%, var(--panel)); }
.free-form button { font: inherit; font-size: 0.86rem; font-weight: 500; letter-spacing: 0.06em; color: var(--bg); background: var(--accent); border: none; border-radius: var(--radius); padding: 0 22px; cursor: pointer; }
.free-form button:disabled { opacity: 0.5; cursor: default; }

/* --- continue / complete -------------------------------------------- */
.continue-row { margin-top: 28px; min-height: 44px; }
.continue { font: inherit; font-size: 0.86rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 10px 26px; cursor: pointer; transition: color 120ms ease, border-color 120ms ease; }
.continue:hover { color: var(--text); border-color: var(--muted); }
.complete-banner { margin-top: 8px; }
.complete-banner.hidden { display: none; }
.done-title { font-size: 1.4rem; font-weight: 400; color: var(--text); text-transform: none; letter-spacing: 0; margin-bottom: 6px; }
.complete-banner .muted { margin-bottom: 18px; }

.hidden { display: none; }

/* --- chat ------------------------------------------------------------ */
.chat { display: flex; flex-direction: column; background: var(--panel); min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
.chat-log { flex: 1 1 0; min-height: 0; overflow-y: scroll; scrollbar-gutter: stable; padding: clamp(20px, 3vw, 32px); display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.chat-log::-webkit-scrollbar { width: 10px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 2px solid var(--panel); }
.msg { max-width: 86%; padding: 11px 15px; border-radius: var(--radius); font-size: 0.97rem; white-space: pre-wrap; overflow-wrap: anywhere; animation: fadein 240ms ease both; }
.msg.companion { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.msg.student { align-self: flex-end; background: rgba(143,182,217,0.12); border: 1px solid rgba(143,182,217,0.25); }
.msg.system { align-self: center; color: var(--faint); font-size: 0.84rem; border: none; background: none; }
.msg.pending { color: var(--faint); }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.chat-input { display: flex; flex-direction: row; gap: 10px; padding: 14px clamp(20px,3vw,32px) 18px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; min-width: 0; font: inherit; font-size: 0.97rem; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 14px; }
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input button { font: inherit; font-size: 0.86rem; font-weight: 500; letter-spacing: 0.06em; color: var(--bg); background: var(--accent); border: none; border-radius: var(--radius); padding: 0 20px; cursor: pointer; }
.chat-input button:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 880px) {
  .game-app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.2fr) minmax(0, 1fr); }
  .work { border-right: none; border-bottom: 1px solid var(--line); }
  .options { grid-template-columns: 1fr; }
}
