/* ==========================================================================
   Gen 3 Academy — Portal (TEST BUILD)
   Shared chrome for login / student / parent / teacher.
   Deliberately single-theme: it borrows The Vessels' own deep-ocean tokens so
   the three portals read as the same product as the game they sit around.
   ========================================================================== */

:root {
  --abyss:       #04080f;
  --deep:        #071322;
  --hull:        #0e1f33;
  --raised:      #12283f;
  --line:        rgba(86, 190, 214, .20);
  --line-firm:   rgba(86, 190, 214, .40);
  --cyan:        #56bed6;
  --cyan-bright: #8fe4f5;
  --ember:       #ff8a3d;
  --ember-soft:  #ffb877;
  --good:        #5fd3a8;
  --warn:        #e5b878;
  --text:        #dfeaf2;
  --text-soft:   #b6cbda;
  --muted:       #7d93a6;

  --f-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --f-body:    'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --f-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;

  --r: 5px;
  --shadow: 0 1px 0 rgba(86,190,214,.05), 0 20px 44px -30px rgba(0,0,0,.95);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(86,190,214,.07), transparent 60%),
    var(--abyss);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- the honesty bar ---------- */
.testbar {
  background: rgba(255, 138, 61, .10);
  border-bottom: 1px solid rgba(255, 138, 61, .35);
  color: var(--ember-soft);
  font-size: .8rem;
  padding: .55rem 1.1rem;
  text-align: center;
}
.testbar strong { color: var(--ember); }

/* ---------- topbar ---------- */
.topbar { border-bottom: 1px solid var(--line); background: rgba(7, 19, 34, .72); }
.topbar-in {
  max-width: 1240px; margin-inline: auto; padding: .8rem clamp(1rem, 3vw, 2rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }
.brand-mark {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, var(--ember-soft), var(--ember) 42%, transparent 72%);
  box-shadow: 0 0 16px rgba(255,138,61,.5);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt      { font-family: var(--f-display); font-size: 1rem; font-weight: 600; }
.brand-txt em {
  font-family: var(--f-mono); font-style: normal; font-size: .62rem;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.who { display: flex; align-items: center; gap: .7rem; }
.who-role {
  font-family: var(--f-mono); font-size: .63rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--cyan); border: 1px solid var(--line-firm); border-radius: 3px; padding: .22rem .5rem;
}
.who-name { font-size: .9rem; color: var(--text-soft); }

/* ---------- layout ---------- */
.page { max-width: 1240px; margin-inline: auto; padding: clamp(1.6rem, 4vw, 2.8rem) clamp(1rem, 3vw, 2rem) 5rem; }
.page-narrow { max-width: 860px; }
.phead { margin-bottom: 1.8rem; }
.eyebrow {
  font-family: var(--f-mono); font-size: .66rem; letter-spacing: .17em;
  text-transform: uppercase; color: var(--cyan); margin: 0 0 .45rem;
}
h1 {
  font-family: var(--f-display); font-weight: 600; letter-spacing: -.015em;
  font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.12; margin: 0; text-wrap: balance;
}
h2 { font-family: var(--f-display); font-weight: 600; font-size: 1.25rem; margin: 0; letter-spacing: -.01em; }
h3 { font-family: var(--f-body); font-weight: 600; font-size: .98rem; margin: 0; }
.sub { color: var(--muted); margin: .5rem 0 0; max-width: 62ch; font-size: .95rem; }

.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(2,1fr); } }
@media (min-width: 1000px) { .g3 { grid-template-columns: repeat(3,1fr); } }

/* ---------- cards ---------- */
.card {
  background: rgba(14, 31, 51, .70);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 1rem; }

/* ---------- stat tiles ---------- */
.stats { display: grid; gap: .7rem; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: rgba(7, 19, 34, .6); border: 1px solid var(--line);
  border-radius: var(--r); padding: .85rem .95rem;
  display: flex; flex-direction: column; gap: .18rem;
}
.stat-n {
  font-family: var(--f-mono); font-size: 1.5rem; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--text);
}
.stat-l { font-family: var(--f-mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stat.is-ember .stat-n { color: var(--ember); }
.stat.is-cyan  .stat-n { color: var(--cyan); }

/* ---------- flame meter ---------- */
.flame-wrap { display: flex; flex-direction: column; gap: .5rem; }
.flame-bar {
  position: relative; height: 12px; border-radius: 999px; overflow: hidden;
  background: rgba(4, 8, 15, .8); border: 1px solid var(--line);
}
.flame-fill { height: 100%; background: linear-gradient(90deg, var(--ember), var(--ember-soft)); border-radius: 999px; }
.flame-fill.low { background: linear-gradient(90deg, #8a2c14, var(--ember)); }
.flame-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--cyan); opacity: .85; }
.flame-legend { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: .66rem; color: var(--muted); }

/* ---------- pills ---------- */
.pill {
  display: inline-block; font-family: var(--f-mono); font-size: .62rem;
  letter-spacing: .12em; text-transform: uppercase; padding: .24rem .52rem;
  border-radius: 3px; border: 1px solid var(--line-firm); color: var(--muted); white-space: nowrap;
}
.pill-ok    { color: var(--good);  border-color: rgba(95,211,168,.5);  background: rgba(95,211,168,.09); }
.pill-warn  { color: var(--warn);  border-color: rgba(229,184,120,.5); background: rgba(229,184,120,.09); }
.pill-bad   { color: var(--ember); border-color: rgba(255,138,61,.5);  background: rgba(255,138,61,.10); }
.pill-cyan  { color: var(--cyan);  border-color: var(--line-firm);     background: rgba(86,190,214,.08); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--f-body); font-size: .88rem; font-weight: 500;
  padding: .55rem 1rem; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--line-firm); background: rgba(86,190,214,.10); color: var(--cyan-bright);
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: rgba(86,190,214,.18); border-color: var(--cyan); }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #1a0c03; font-weight: 600; }
.btn-primary:hover { background: var(--ember-soft); border-color: var(--ember-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(86,190,214,.08); }
.btn-sm { font-size: .78rem; padding: .35rem .7rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
/* Was .btn only, which missed every <button> that is not styled as one --
   the sign-in tabs, the close buttons on the cards -- so tabbing through the
   portal went invisible the moment it left a link or a field. */
.btn:focus-visible, button:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px;
}
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label {
  font-family: var(--f-mono); font-size: .64rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.field input, .field select, .field textarea {
  font-family: var(--f-body); font-size: .95rem;
  background: rgba(4, 8, 15, .65); border: 1px solid var(--line);
  border-radius: var(--r); padding: .6rem .75rem; color: var(--text);
}
.field input::placeholder { color: rgba(125,147,166,.65); }
.field .hint { font-size: .76rem; color: var(--muted); }
.field .hint.good { color: var(--good); }
.field .hint.bad  { color: var(--ember); }
.field-row { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-row { grid-template-columns: 1fr 1fr; } }

fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; margin: 0 0 1rem; }
legend {
  font-family: var(--f-mono); font-size: .64rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--cyan); padding: 0 .4rem;
}

.msg { border-radius: var(--r); padding: .7rem .9rem; font-size: .88rem; margin-bottom: 1rem; }
.msg-bad  { background: rgba(255,138,61,.10); border: 1px solid rgba(255,138,61,.4); color: var(--ember-soft); }
.msg-good { background: rgba(95,211,168,.10); border: 1px solid rgba(95,211,168,.4); color: var(--good); }
.msg-info { background: rgba(86,190,214,.08); border: 1px solid var(--line-firm); color: var(--text-soft); }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: .35rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  font-family: var(--f-body); font-size: .86rem; color: var(--muted); padding: .55rem .8rem;
}
.tab:hover { color: var(--text-soft); }
.tab.active { color: var(--cyan-bright); border-bottom-color: var(--cyan); }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: rgba(7,19,34,.55); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; min-width: 860px; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  font-family: var(--f-mono); font-size: .6rem; font-weight: 500; letter-spacing: .13em;
  text-transform: uppercase; color: var(--muted); background: rgba(4,8,15,.55);
  border-bottom: 1px solid var(--line-firm); white-space: nowrap; position: sticky; top: 0;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--cyan); }
thead th .arr { color: var(--cyan); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(86,190,214,.05); }
td.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
td .uname { font-family: var(--f-mono); font-size: .82rem; color: var(--cyan); }

/* ---------- transcripts ---------- */
.convo { display: flex; flex-direction: column; gap: .7rem; }
.turn { display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: start; }
.turn-who {
  font-family: var(--f-mono); font-size: .58rem; letter-spacing: .12em; text-transform: uppercase;
  padding: .28rem .45rem; border-radius: 3px; border: 1px solid var(--line); white-space: nowrap;
}
.turn-ai      .turn-who { color: var(--cyan);  border-color: var(--line-firm); }
.turn-student .turn-who { color: var(--ember); border-color: rgba(255,138,61,.4); }
.turn-body {
  background: rgba(7,19,34,.7); border: 1px solid var(--line); border-radius: var(--r);
  padding: .6rem .8rem; font-size: .9rem; color: var(--text-soft);
}
.turn-student .turn-body { background: rgba(255,138,61,.06); border-color: rgba(255,138,61,.22); }
.turn-time { font-family: var(--f-mono); font-size: .62rem; color: var(--muted); margin-top: .3rem; display: block; }

.tcard { border: 1px solid var(--line); border-radius: var(--r); background: rgba(7,19,34,.5); margin-bottom: .8rem; }
.tcard-head {
  display: flex; flex-wrap: wrap; gap: .5rem .9rem; align-items: center;
  padding: .8rem 1rem; cursor: pointer; border-bottom: 1px solid transparent;
}
.tcard-head:hover { background: rgba(86,190,214,.05); }
.tcard.open .tcard-head { border-bottom-color: var(--line); }
.tcard-q { flex: 1 1 260px; font-size: .9rem; color: var(--text); }
.tcard-body { padding: 1rem; display: none; }
.tcard.open .tcard-body { display: block; }
.flags { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- misc ---------- */
.empty { color: var(--muted); font-size: .9rem; padding: 1.4rem; text-align: center; }
.code {
  font-family: var(--f-mono); letter-spacing: .1em; font-size: 1.1rem; color: var(--cyan-bright);
  background: rgba(86,190,214,.08); border: 1px dashed var(--line-firm);
  border-radius: var(--r); padding: .5rem .8rem; display: inline-block;
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; font-size: .88rem; }
.kv dt { font-family: var(--f-mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); align-self: center; }
.kv dd { margin: 0; color: var(--text-soft); }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.6rem; transform: translateX(-50%);
  background: var(--hull); border: 1px solid var(--line-firm); border-radius: var(--r);
  padding: .7rem 1.1rem; font-size: .88rem; color: var(--text);
  box-shadow: var(--shadow); z-index: 60; max-width: 90vw;
}

.demo-creds { font-family: var(--f-mono); font-size: .8rem; }
.demo-creds b { color: var(--cyan-bright); font-weight: 500; }
.demo-creds tr td { padding: .3rem .6rem; border: 0; }
.demo-creds table { min-width: 0; }

a { color: var(--cyan); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* The portal is a document, not an animation, but it inherits transitions from
   the shared design language. Nothing should move for somebody who asked their
   system for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
