/* The sign-in page, the admin/superuser portal and the lobby. Colours and fonts come from app.css. */

/* ---------- sign-in ---------- */
.authpage {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 8vh 16px 16px;
}
.authbox {
  width: min(420px, 100%);
}
.authbox h1 {
  margin: 0 0 6px;
}
.authform {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.authform .f input {
  width: 100%;
}
.authswitch {
  margin: 12px 0 0;
}
.authmsg {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--hit);
  font-weight: 600;
}
.authmsg.good {
  color: var(--ok);
}

/* ---------- portal ---------- */
.portalwrap {
  max-width: 1100px;
}
.portalhead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.portalhead h1 {
  margin: 0;
}
.portalacts {
  flex-wrap: wrap;
  gap: 6px;
}
.portalnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}
.portalnav [aria-current="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--pip);
}
.portalnav {
  margin-bottom: 10px;
}
/* what just happened: a message at the bottom of the screen, wherever the button was (tap it to close) */
.portalmsg {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  width: max-content;
  max-width: min(640px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--ok);
  background: var(--sheet);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.portalmsg:empty {
  display: none;
}
.portalmsg.bad {
  border-left-color: var(--hit);
  color: var(--hit);
}
.portalmsg::after {
  content: "×";
  margin-left: 12px;
  color: var(--muted);
  font-weight: 400;
}
.portalmain h2 {
  margin-top: 18px;
}
.portalmain h2:first-child {
  margin-top: 0;
}
.ptable {
  width: 100%;
  border-collapse: collapse;
}
.ptable th,
.ptable td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.ptable .acts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.pwreset {
  display: inline-flex;
  gap: 6px;
}
/* app.css gives the text fields without a type, passwords and textareas the look of input[type="text"]; on the
   sign-in page, the portal and the lobby they also take its width. :where() gives this no specificity, so sizing
   like .authform .f input, .f.grow input, .pmatrix thead th input, .lane h3 input and .feedform input still wins */
:where(input:not([type]), input[type="password"], textarea) {
  width: 160px;
}
.pform {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 6px 0;
}
.f.grow {
  flex: 1 1 220px;
}
.f.grow input,
.f textarea {
  width: 100%;
}
.f.num input {
  width: 70px;
}
.pcard {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 10px 0;
  display: grid;
  gap: 8px;
}
.pcard h3 {
  margin: 0;
}
/* user groups: a row per permission, a column per group; the permission column stays put when it scrolls sideways */
.pmatrixform {
  min-width: 0; /* so the table scrolls inside the panel instead of widening the page */
}
.pmatrixwrap {
  overflow-x: auto;
  margin: 6px 0;
}
.pmatrix {
  border-collapse: collapse;
  min-width: 100%;
}
.pmatrix th,
.pmatrix td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  text-align: center;
  vertical-align: middle;
}
.pmatrix thead th {
  vertical-align: bottom;
  min-width: 140px;
}
.pmatrix thead th input {
  display: block;
  width: 100%;
  margin-bottom: 4px;
}
.pmatrix thead th input:first-child {
  font-weight: 600;
}
.pmatrix tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--sheet);
  text-align: left;
  min-width: 200px;
  max-width: 320px;
}
.pmatrix tbody th {
  font-size: 13px;
  font-weight: normal;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  white-space: normal;
}
.pmatrix tbody th .hint {
  display: block;
}
.pmatrix tbody tr:hover > * {
  background: var(--accent-soft);
}
/* each permission is a toggle that looks like the other buttons: the checkbox is hidden, the button says On or Off,
   and On is highlighted like the open section's button */
.ptoggle {
  position: relative;
  display: inline-block;
  min-width: 4.5em;
}
.ptoggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ptoggle::after {
  content: "Off";
}
.btn.ptoggle:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--pip);
  font-weight: 600;
}
.ptoggle:has(input:checked)::after {
  content: "On";
}
.ptoggle:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}
.ptoggle:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pmatrix tr.adminonly th > * {
  opacity: 0.7;
}
.pmatrix tfoot td {
  border-bottom: 0;
}
/* on a phone, one group at a time, picked above the matrix */
.gpick {
  display: none;
}
@media (max-width: 640px) {
  .pmatrix tr > :first-child {
    min-width: 150px;
    max-width: 180px;
  }
  .pmatrix thead th {
    min-width: 120px;
  }
  .gpick {
    display: grid;
    max-width: 240px;
  }
  .pmatrix .gcol.off {
    display: none;
  }
  .pmatrix {
    width: 100%;
  }
  /* one group's column fits beside the permissions */
  .pmatrix thead th.gcol {
    min-width: 0;
  }
  .pmatrix thead th .hint {
    white-space: normal;
  }
}
/* default lances: a row per lance, a pill per 'Mech; the headings sort it */
.lancefilter {
  max-width: 720px;
}
.lancefilter > .hint {
  align-self: center;
}
.sortbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.lancetable [aria-sort] {
  color: var(--ink);
}
.lancetable .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.lancetable .pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.lancetable .pills .chip {
  margin: 0;
  padding: 2px 6px;
}
.lancetable .pills .chip b {
  font-size: 12px;
}
.lancetable .pills .chip:hover,
.lancetable .pills .chip:focus-visible {
  border-color: var(--accent);
}
@media (max-width: 640px) {
  /* the headings become a row of sort buttons */
  .ptable.lancetable thead {
    display: block;
  }
  .lancetable thead tr {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 4px 0;
    border-bottom: 1px solid var(--pip-edge);
  }
  .lancetable thead th {
    border: 0;
    padding: 0;
  }
  .lancetable thead th.lineup {
    display: none;
  }
  /* then a row per lance: the name and BV share the first line, the house the next (if it has one), then the
     pills, which show how many 'Mechs */
  .lancetable tbody tr {
    grid-template-columns: 1fr auto;
    align-items: baseline;
  }
  .lancetable td.count,
  .lancetable td.house:empty {
    display: none;
  }
  .lancetable td.house,
  .lancetable td.lineup {
    grid-column: 1 / -1;
  }
  .lancetable td.house {
    color: var(--muted);
  }
  .lancetable td.bv {
    grid-column: 2;
    grid-row: 1;
  }
  .lancetable td.bv::before {
    content: "BV ";
    color: var(--muted);
  }
}
.lrows {
  display: grid;
  gap: 6px;
}
.lrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.lfill {
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.subsetting {
  margin-left: 28px;
}
.f:has(select:disabled) > span {
  opacity: 0.6;
}
/* the server's setup, read-only */
.serverinfo {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 6px 0;
}
.serverinfo dt {
  color: var(--muted);
}
.serverinfo dd {
  margin: 0;
}
@media (max-width: 640px) {
  .serverinfo {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .serverinfo dd {
    margin-bottom: 6px;
  }
}
/* an account, opened from the list */
.pdetails {
  margin: 6px 0;
}
.pdetails summary {
  cursor: pointer;
}
.portalmain h3 {
  margin: 16px 0 4px;
}
/* a player's 'Mech from the library, viewed: the tracker's record sheet styles (app.css) plus its .mtf file */
.pacts {
  flex-wrap: wrap;
  gap: 6px;
}
.portalmain .sheet {
  grid-template-columns: minmax(0, 1fr); /* wide tables scroll in their box on a phone, not the page */
}
.sh-sec > .hint {
  margin-top: 6px;
}
.sh-warn {
  color: var(--warn);
}
.mtffile summary {
  cursor: pointer;
  font-weight: 600;
}
.mtffile pre {
  margin: 6px 0 0;
  max-height: 60vh;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: 12px var(--mono, monospace);
  white-space: pre;
}
@media (max-width: 640px) {
  .ptable thead {
    display: none;
  }
  .ptable tr {
    display: grid;
    gap: 4px;
    padding: 8px 0;
    border-bottom: 1px solid var(--rule);
  }
  .ptable td {
    border: 0;
    padding: 0;
  }
  .ptable .acts {
    justify-content: flex-start;
  }
  /* the accounts list: what each line is */
  .ptable td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
  }
}

/* ---------- lobby ---------- */
.gamehead h2 .chip,
.ptable .chip {
  font-size: 12px;
  margin-left: 6px;
}
.startwarn {
  margin: 6px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 3px;
}
.gameacts {
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.sidepick,
.testplayers {
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 10px 0;
}
.btn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--pip);
}
.unpicked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 6px 0;
}
.lanes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 14px;
  margin-top: 10px;
}
.lane {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0; /* long names (a default lance's, say) wrap or shrink instead of widening the column */
}
.lane select,
.lanceadd select {
  max-width: 100%;
}
.lanceadd .f.grow select {
  width: 100%;
}
.lane h3 input {
  font: inherit;
  width: 100%;
}
/* ---------- each player's colour (lobby) ---------- */
:root {
  --p0: #b8432f;
  --p1: #2d68ad;
  --p2: #2f7d3a;
  --p3: #9a6a12;
  --p4: #7348ad;
  --p5: #127f7f;
  --p6: #b23d74;
  --p7: #6b5a3a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --p0: #ff8a78;
    --p1: #79adff;
    --p2: #79d487;
    --p3: #efb65e;
    --p4: #bb95ff;
    --p5: #5ed3d3;
    --p6: #ff92c4;
    --p7: #cdb084;
  }
}
:root[data-theme="dark"] {
  --p0: #ff8a78;
  --p1: #79adff;
  --p2: #79d487;
  --p3: #efb65e;
  --p4: #bb95ff;
  --p5: #5ed3d3;
  --p6: #ff92c4;
  --p7: #cdb084;
}
[data-pc="0"] {
  --pc: var(--p0);
}
[data-pc="1"] {
  --pc: var(--p1);
}
[data-pc="2"] {
  --pc: var(--p2);
}
[data-pc="3"] {
  --pc: var(--p3);
}
[data-pc="4"] {
  --pc: var(--p4);
}
[data-pc="5"] {
  --pc: var(--p5);
}
[data-pc="6"] {
  --pc: var(--p6);
}
[data-pc="7"] {
  --pc: var(--p7);
}
.player {
  border: 1px solid var(--rule);
  border-left: 6px solid var(--pc, var(--rule));
  border-radius: 6px;
  padding: 8px;
  display: grid;
  gap: 6px;
  min-height: 56px;
}
/* a player's box takes a light tint of their colour, as well as the stripe ("Not assigned yet" has none) */
.player[data-pc] {
  background: color-mix(in srgb, var(--pc) 9%, transparent);
  border-color: color-mix(in srgb, var(--pc) 35%, var(--rule));
}
.hostruns {
  align-items: center;
  gap: 8px;
}
.player.unassigned {
  border-style: dashed;
  border-left-width: 1px;
}
.player .mechcard {
  border-left: 4px solid var(--pc, var(--rule));
}
.dropover,
.player[data-pc].dropover {
  outline: 3px solid var(--pc, var(--accent));
  outline-offset: 1px;
  background: color-mix(in srgb, var(--pc, var(--accent)) 20%, transparent);
}
/* while a 'Mech is dragged, the boxes it isn't over step back */
.dragon .droptarget:not(.dropover) {
  opacity: 0.55;
}
.phead {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.phead .ppaper {
  padding: 2px 8px;
  font-size: 12px;
}
.phead .pname {
  font-size: 15px;
}
.pbadge {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border-radius: 13px;
  background: var(--pc, var(--muted));
  color: var(--sheet);
  font-weight: 700;
  font-size: 13px;
}
.dropnote {
  font-style: italic;
}
.mechcard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 6px 8px;
}
.mechcard.paper {
  border-style: dotted;
}
.mechcard.dragging {
  opacity: 0.4;
}
.minfo {
  display: grid;
  flex: 1 1 140px;
}
.mctl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.grip {
  cursor: grab;
  touch-action: none; /* dragging with a finger moves the card, not the page */
  user-select: none;
  font-size: 20px;
  line-height: 1;
  padding: 4px 2px;
  color: var(--muted);
}
.dragghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
  cursor: grabbing;
  border-left: 4px solid var(--pc, var(--rule));
}
.droptag {
  flex-basis: 100%;
  font-weight: 700;
  font-size: 13px;
  color: var(--pc, var(--muted));
}
.linkbtn.kick {
  margin-left: auto;
}
.lanceadd {
  border-top: 1px solid var(--rule);
  padding-top: 6px;
}
.newgame {
  display: grid;
  gap: 10px;
}
.modes {
  display: grid;
  gap: 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0;
}
.modes legend {
  font-weight: 600;
  padding: 0 4px;
}
/* the game types look like the other buttons: the radio is hidden and the chosen one is highlighted, like a
   pressed button (.btn.on) */
.modechoice {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--pip-edge);
  border-radius: 3px;
  padding: 8px 11px;
  cursor: pointer;
}
.modechoice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
@media (hover: hover) {
  .modechoice:hover:not(:has(input:checked)) {
    background: var(--accent-soft);
  }
}
.modechoice:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--pip);
}
.modechoice:has(input:checked) .hint {
  color: inherit;
  opacity: 0.85;
}
.modechoice:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.privrow {
  align-items: center;
  gap: 8px;
}
.modechoice > span {
  display: grid;
}
.ffa {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
/* gunnery, piloting and the Add button stay together on one line, whatever the width */
.skills {
  display: flex;
  gap: 8px;
  align-items: end;
  flex: 0 0 auto;
}
.pform .f.pilotname {
  flex: 1 1 120px;
}
.f.pilotname input {
  width: 100%;
}
.lancetotals {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
}
.randomlance {
  margin-top: 6px;
}
.randomlance summary {
  cursor: pointer;
  font-weight: 600;
}
.invite {
  max-width: 720px;
}
.invitelink {
  font-family: var(--mono, monospace);
  font-size: 13px;
}
.ptable .chip {
  margin-left: 6px;
}
.report {
  margin-top: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
}
/* armor, structure and damage: centred under their headings */
.reporttable th.num,
.reporttable td.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* the same column widths in every lance's table, so the lances line up one under the other */
@media (min-width: 641px) {
  .reporttable {
    table-layout: fixed;
    width: 100%;
  }
  .reporttable th:nth-child(1) {
    width: 21%;
  }
  .reporttable th:nth-child(2) {
    width: 23%;
  }
  .reporttable th.num {
    width: 10.5%;
  }
  /* long names (a kill's 'Mech and player, say) wrap inside their column */
  .reporttable td {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}
@media (max-width: 640px) {
  /* a phone stacks each row, each number labelled: left, like the rest */
  .reporttable td.num {
    text-align: left;
  }
}
.reporttable tr.dead td {
  opacity: 0.7;
}
.reportlist li {
  margin: 4px 0;
}
.loglist .chip {
  font-size: 12px;
}
.logfilter {
  max-width: 720px;
}
.lobby .feed {
  margin-top: 14px;
}
/* the host's options that reset or end the session for everyone */
.hostmore {
  margin: 8px 0 0;
}
.hostmore summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.hostmore[open] summary {
  margin-bottom: 4px;
}
.hostmore .row {
  margin-top: 6px;
}
/* a session's optional rules */
.rulesbox {
  margin: 10px 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 12px;
}
.rulesbox summary {
  cursor: pointer;
}
.rulesbox h4 {
  margin: 12px 0 6px;
  font-size: 13px;
}
.rulelist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px 16px;
}
.rule {
  display: grid;
  gap: 2px;
  align-content: start;
}
.rule .btn {
  justify-self: start;
}
