/* ITS Board — the scare-floor look (M1).
 *
 * Read from across an office on a wall-mounted TV, so: big type, saturated
 * per-employee colour, one obviously-dominant leader, and as many people on one
 * screen as will legibly fit. Past that the board scrolls — see the `main` rule
 * and the traversal section of app.js.
 *
 * Deliberately conservative CSS. These boxes run old Chromium WebViews inside
 * Yandex browser, so nothing here uses :has(), container queries, aspect-ratio,
 * inset, or flexbox gap (Chrome 84+ — too new to bet a wall display on).
 * Spacing is margins; positioning is grid and absolute offsets.
 *
 * Sizing is in vh so the whole board scales to the screen it lands on, and the
 * row count decides the scale: .compact kicks in from 13 rows (see COMPACT_FROM
 * in app.js) and keeps 16 people on a 1080p screen without overflow.
 */

:root {
  --bg: #071429;
  --panel: #10294d;
  --panel-2: #17407a;
  --text: #eaf1fb;
  --muted: #9db4d4;
  --accent: #37c8a6;        /* per-row override, set inline by app.js */
  --on: #37c8a6;            /* a switch that is on; never overridden per row */
  --focus: #ffd34d;
  --glow-ms: 1800ms;        /* must match GLOW_MS in app.js */

  /* Row height is a budget, not a guess: eleven rows plus the taller leader,
     the top bar and the status bar have to fit 100vh with room to spare. Every
     text element below sets an explicit line-height for that reason — leaving
     it at `normal` makes row height depend on the font the box happens to have,
     and Cyrillic faces run taller than Latin ones. */
  --av: 5.3vh;              /* portrait diameter */
  --row-pad: .6vh;
  --row-gap: .65vh;
  --name-gap: .35vh;
  --fs-name: 1.9vw;
  --fs-rank: 2.2vw;
  --fs-hours: 1.8vw;
  --bar-h: 1.1vh;
  --lh: 1.15;

  /* The control column. Icon-only buttons, so it needs to fit an icon plus a
     little padding — everything else goes back to the board. Labels live in the
     hover tooltips instead. */
  --sidebar: 4.8vw;
  --icon: 2.3vw;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
}

/* Two columns: the board on the left, every control on the right.
 *
 * One column rather than a bar above and a bar below, because the TV's cursor
 * is walked across the screen a D-pad step at a time. Every control the remote
 * needs — the four periods and the two scroll buttons — is therefore stacked
 * within a short travel of the others, in the vertical middle. */
body {
  display: flex; flex-direction: row;
  padding: 2vh 3vw;
  background-image:
    radial-gradient(120vw 80vh at 50% -20vh, rgba(55, 200, 166, .12), transparent 70%);
}

#stage {
  display: flex; flex-direction: column;
  flex: 1; min-width: 0; min-height: 0;
}

/* ---- top bar ---- */

#topbar {
  display: flex; align-items: center;
  margin-bottom: 1.6vh;
}
#title {
  font-size: 2.4vw; margin: 0; font-weight: 800;
  line-height: var(--lh); letter-spacing: .02em;
}

/* ---- the control column ---- */

#sidebar {
  flex: none;
  width: var(--sidebar);
  margin-left: 2.2vw;
  display: flex; flex-direction: column;
  justify-content: center;      /* short cursor travel between any two controls */
}

#periods { display: flex; flex-direction: column; }
.period {
  position: relative;                /* anchors .tip */
  display: block; width: 100%;
  padding: 1.1vh .4vw; border-radius: 1.4vh;
  margin-bottom: .9vh;
  background: var(--panel); color: var(--muted);
  border: .3vh solid transparent; cursor: pointer;
  font-family: inherit;
}
.period:last-child { margin-bottom: 0; }
.period.active  { color: var(--text); background: var(--panel-2); }
.period.focused { border-color: var(--focus); }

/* ---- browsing dates (index.html #browse) ---- */
/*
 * The two arrows live beside the heading, next to the date they move.
 *
 * They were in the sidebar first, flanking the month button, and that is where
 * they went wrong: the sidebar is one icon wide, so the arrows had to come out
 * of the month icon's own width, which left all three too small to aim at with
 * a cursor driven a step at a time and the row visibly uneven against its
 * neighbours. Here there is empty space to the right of the title and a date
 * to point at, and the sidebar goes back to being four equal icons.
 */
#browse {
  display: flex;
  align-items: center;
  gap: .5vw;
  margin-left: 1.4vw;
}

.step {
  position: relative;                /* anchors .tip */
  display: block;
  padding: .7vh .6vw; border-radius: 1.2vh;
  background: var(--panel); color: var(--muted);
  border: .3vh solid transparent; cursor: pointer;
  font-family: inherit;
}
.step:hover   { color: var(--text); }
.step:hover .tip { opacity: 1; }
.step:active  { background: var(--focus); color: #05203a; }
.step.focused { border-color: var(--focus); }

/* Same treatment, and the same reasoning, as .scrollbtn:disabled — "there is
   nothing further this way", for somebody who can only press and watch. */
.step:disabled {
  background: var(--panel); color: var(--muted);
  opacity: .45; cursor: default;
}

/* Smaller than a sidebar icon on purpose: these are subordinate to the heading
   they sit beside, not a fifth period. */
.icon-step {
  width: 1.3vw; height: 1.3vw;
}

/* The tooltip hangs below these two instead of to their left: at the top of the
   screen there is nothing to the left of the first arrow except the title it
   would cover. */
#browse .tip {
  right: auto; left: 50%; top: 100%;
  transform: translateX(-50%);
  margin-right: 0; margin-top: 1.1vh;
}
#browse .tip::after {
  right: auto; left: 50%; top: -.3vw;
  margin-top: 0; margin-left: -.3vw;
}


/* Lucide's own presentation, kept here rather than on every element so the
   weight can be tuned for TV distance in one place. */
.icon {
  display: block;
  width: var(--icon); height: var(--icon);
  margin: 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The tooltip is the only thing naming an icon, so it is NOT behind
   @media (hover: hover) the way the row highlight is: if the TV's browser
   reports itself as a non-hover device, gating this would leave every button
   permanently unlabelled. A tooltip left showing after a tap on a phone is a
   far cheaper failure. */
.tip {
  position: absolute;
  right: 100%; top: 50%;
  transform: translateY(-50%);
  margin-right: 1.1vw;
  white-space: nowrap;
  font-size: 1.2vw; line-height: var(--lh); font-weight: 700;
  color: var(--text); background: var(--panel-2);
  padding: .6vh 1vw; border-radius: 999px;
  box-shadow: 0 .6vh 1.8vh rgba(0, 0, 0, .55);
  opacity: 0;
  pointer-events: none;               /* never steals the hover it describes */
  transition: opacity 120ms ease;
}
/* A rotated square for the caret: no border-triangle trick, so it inherits the
   pill's colour in one place and cannot drift out of step with it. */
.tip::after {
  content: '';
  position: absolute;
  right: -.3vw; top: 50%;
  width: .6vw; height: .6vw;
  margin-top: -.3vw;
  background: var(--panel-2);
  transform: rotate(45deg);
}
.period:hover .tip,
.scrollbtn:hover .tip { opacity: 1; }

/* Set apart from the periods: these do something to the board rather than
   choosing what the board shows, and the gap is what says so. */
#controls { margin-top: 3.5vh; }

/* Administration, set apart again by a wider gap: this one changes the
   installation, not the picture. Quieter than the scroll buttons on purpose —
   it is used about once a year and must never compete with them for the eye. */
#admin { margin-top: 3.5vh; }
#admin[hidden] { display: none; }
.adminbtn {
  position: relative;                /* anchors .tip */
  display: block; width: 100%;
  padding: 1.1vh .4vw; border-radius: 1.4vh;
  background: var(--panel); color: var(--muted);
  border: .3vh solid transparent; cursor: pointer;
  font-family: inherit;
}
.adminbtn:hover  { color: var(--text); }
.adminbtn:active { background: var(--focus); color: #05203a; }
.adminbtn:hover .tip { opacity: 1; }

/* ---- the board ---- */

/* The scroll container. `position: relative` is load-bearing, not decoration:
   it makes <main> the offsetParent of every row, so app.js can read a row's
   position with offsetTop — a layout value that ignores both the scroll offset
   and the FLIP transform a row may be mid-way through. getBoundingClientRect()
   would report where the row is *animating*, and centring on that lands wrong. */
/* The negative margin and the matching padding cancel out, so the rows sit
   exactly where they always did — but the *clip* edge moves outward by half a
   vw. A scroll container clips both axes, and without that slack the selected
   row's accent ring would be shaved off flush at the left and right. */
main {
  position: relative;
  flex: 1; min-height: 0;
  margin: 0 -.5vw; padding: 0 .5vw;
  overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* A scrollbar is the only static hint that there are more people below, so it is
   styled to belong rather than hidden. Webkit-only; elsewhere the UA's own bar
   shows up, which is equally fine. */
main::-webkit-scrollbar { width: .7vw; }
main::-webkit-scrollbar-track { background: rgba(0, 0, 0, .3); border-radius: 999px; }
main::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 999px; }

#board { list-style: none; margin: 0; padding: 0; }

.row {
  position: relative;
  display: grid;
  /* rank | portrait | name+bar | paid hours | total hours.
     The last column is new in M2; it takes its width off the bar, which is why
     the bar is narrower than it used to be. */
  grid-template-columns: 3.5vw auto 1fr 8vw 6.4vw;
  align-items: center;
  margin-bottom: var(--row-gap);
  padding: var(--row-pad) 1.2vw;
  background: var(--panel);
  border-left: .45vw solid var(--accent);
  border-radius: .8vh;
  will-change: transform;
  cursor: pointer;
}
.row > * { position: relative; z-index: 1; }
.row:last-child { margin-bottom: 0; }

.rank {
  font-size: var(--fs-rank); font-weight: 800; color: var(--muted);
  line-height: var(--lh);
  text-align: center; font-variant-numeric: tabular-nums;
}

.avatar {
  position: relative; display: block;
  width: var(--av); height: var(--av);
  margin-right: 1.1vw;
  border-radius: 50%; overflow: hidden;
  background: #071429;
  box-shadow: 0 0 0 .25vh rgba(255, 255, 255, .18);
}
.avatar .face,
.avatar .photo {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; display: block;
}
.avatar .photo { object-fit: cover; }
/* The UA rule for [hidden] loses to the selectors above, so say it explicitly —
   without this a failed photo would cover its own fallback with nothing. */
.avatar .photo[hidden] { display: none; }

.who { display: block; min-width: 0; }
.name {
  display: block;
  font-size: var(--fs-name); font-weight: 700; line-height: var(--lh);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: var(--name-gap);
}
.bar {
  display: block; height: var(--bar-h);
  background: rgba(0, 0, 0, .35); border-radius: 999px; overflow: hidden;
  margin-right: 1.2vw;
}
.fill {
  display: block; height: 100%; width: 0;
  background: var(--accent); border-radius: 999px;
  transition: width 600ms cubic-bezier(.2, .8, .2, 1);
}
.hours {
  font-size: var(--fs-hours); font-weight: 700; line-height: var(--lh);
  text-align: right; font-variant-numeric: tabular-nums;
}

/* Total hours — every hour worked, billable or not. Deliberately quiet: it is
   context for the ranked number, never a competitor to it. The rule is muted
   colour and a smaller size, plus a hairline to say "different quantity"; the
   caption carries the meaning, because a wall display gets no tooltip. */
.total {
  font-size: calc(var(--fs-hours) * .72);
  line-height: var(--lh);
  text-align: right;
  padding-left: .8vw;
  margin-left: .8vw;
  border-left: .1vw solid rgba(255, 255, 255, .13);
  color: var(--muted);
}
.total .cap {
  display: block;
  font-size: .62em; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  line-height: 1.3;
}
.total .val {
  display: block;
  font-weight: 700; font-variant-numeric: tabular-nums;
}

/* ---- the leader: the one row you see first ---- */

.row.leader {
  --av: 7.2vh;
  background: linear-gradient(90deg, var(--panel-2), var(--panel) 60%);
  box-shadow: 0 0 0 .3vh rgba(255, 255, 255, .10), 0 1.4vh 3vh rgba(0, 0, 0, .35);
  padding-top: .8vh; padding-bottom: .8vh;
  margin-bottom: 1vh;
}
.row.leader .rank   { font-size: 2.9vw; color: var(--text); }
.row.leader .name   { font-size: 2.5vw; font-weight: 800; }
.row.leader .hours  { font-size: 2.2vw; }
.row.leader .total  { font-size: 1.35vw; }
.row.leader .bar    { height: 1.5vh; }
/* The star marks whoever is first. It keys on position, not on being uniquely
   first, so a tie on hours still crowns exactly one row. */
.row.leader .rank::before {
  content: '★';
  display: block; line-height: 1;
  font-size: .7em; color: var(--accent);
  margin-bottom: .2vh;
}

/* ---- pointing at a row, and picking one ---- */
/*
 * Two overlays share the row and must not fight: ::before is the hover/selected
 * tint (a steady state) and ::after is the rank-up glow (a one-shot animation).
 * Both are opacity-only, so neither costs layout on a weak box.
 *
 * Hover is behind `@media (hover: hover)` because a tap on a phone leaves the
 * :hover state stuck on the tapped row until something else is tapped.
 */
.row::before {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 0;
  border-radius: inherit;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
@media (hover: hover) {
  .row:hover::before { opacity: .12; }
}

/* Written as `#board .row.selected` so it outranks `.row.leader` (0,2,0) without
   depending on rule order — the leader can be the selected row, and when it is,
   the selection ring has to win over the leader's own shadow. */
#board .row.selected::before { opacity: .2; }
#board .row.selected {
  box-shadow: 0 0 0 .35vh var(--accent), 0 1.4vh 3vh rgba(0, 0, 0, .45);
}

/* Growing the selected row is what makes the pick feel like a pick. The leader
   is excluded: it is already the largest row on the board, and inflating it
   further just shoves everyone else down for nothing. */
#board .row.selected:not(.leader) {
  --av: 6.4vh;
  --fs-name: 2.2vw;
  --fs-rank: 2.4vw;
  --fs-hours: 2vw;
  --bar-h: 1.3vh;
  padding-top: .8vh; padding-bottom: .8vh;
}
#board.compact .row.selected:not(.leader) {
  --av: 4.6vh;
  --fs-name: 1.7vw;
  --fs-rank: 1.9vw;
  --fs-hours: 1.6vw;
  --bar-h: 1vh;
  padding-top: .55vh; padding-bottom: .55vh;
}

/* ---- a row that just climbed ---- */

.row::after {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), transparent 65%);
  opacity: 0;
  pointer-events: none;
}
.row.rankup::after { animation: glow var(--glow-ms) ease-out 1; }

/* Opacity only — nothing here forces layout or paint of the row itself, which
   is what keeps the animation cheap on a weak box. */
@keyframes glow {
  0%   { opacity: 0; }
  12%  { opacity: .55; }
  100% { opacity: 0; }
}

/* ---- compact: 13 rows and up ---- */

#board.compact {
  --av: 3.6vh;
  --row-pad: .35vh;
  --row-gap: .5vh;
  --name-gap: .3vh;
  --fs-name: 1.35vw;
  --fs-rank: 1.6vw;
  --fs-hours: 1.3vw;
  --bar-h: .8vh;
}
#board.compact .row.leader {
  --av: 4.8vh;
  padding-top: .5vh; padding-bottom: .5vh;
  margin-bottom: .8vh;
}
#board.compact .row.leader .rank  { font-size: 1.9vw; }
#board.compact .row.leader .name  { font-size: 1.7vw; }
#board.compact .row.leader .hours { font-size: 1.55vw; }
#board.compact .row.leader .total { font-size: 1.0vw; }
#board.compact .row.leader .bar   { height: 1.1vh; }

/* ---- status bar and the empty board ---- */

#statusbar {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); font-size: 1.1vw; line-height: var(--lh);
  margin-top: 1.4vh;
}
#status-left { display: flex; align-items: center; }
#hint { margin-left: 1.2vw; }

/* The count of people off-screen. Brighter than the rest of the status bar,
   because on a wall display it is the only thing saying the board continues. */
#more { margin-left: 1.2vw; color: var(--text); font-weight: 700; }
#more[hidden] { display: none; }

/* The scroll buttons. Same silhouette as a period button so the column reads as
   one column, but lit brighter: on the TV these are the only way down the
   board, and the eye should find them first. */
.scrollbtn {
  position: relative;                /* anchors .tip */
  display: block; width: 100%;
  padding: 1.4vh .4vw; border-radius: 1.4vh;
  margin-bottom: .9vh;
  color: var(--text); background: var(--panel-2);
  border: .3vh solid transparent; cursor: pointer;
  font-family: inherit;
}
.scrollbtn:last-child { margin-bottom: 0; }
.scrollbtn:active { background: var(--focus); color: #05203a; }

/* "There is nothing further this way" — the only feedback available to somebody
   pressing the button from the far side of a room, since the board itself
   simply would not move. Browsers suppress pointer events on a disabled
   control, so its tooltip stops appearing too; that is the right trade, because
   a tooltip is a label and a greyed button has nothing left to explain. */
.scrollbtn:disabled {
  background: var(--panel); color: var(--muted);
  opacity: .45; cursor: default;
}

/* ---- the login page (login.html) ---- */
/*
 * Sized for the hardest case: a wall TV whose only pointer is a mouse cursor
 * driven by a D-pad. Keys are therefore large and widely spaced — a cursor you
 * nudge with a directional pad cannot be placed precisely, and a mistyped
 * password on a device you cannot walk up to is expensive.
 */

.login-page {
  display: block;                   /* not the board's two-column flex row */
  overflow-y: auto;
  padding: 4vh 4vw;
}

#gate {
  max-width: 62vw;
  margin: 0 auto;
  text-align: center;
}
#gate-title {
  font-size: 2.6vw; font-weight: 800; line-height: var(--lh);
  margin: 0 0 1vh;
}
#gate-lead, #gate-note {
  color: var(--muted); font-size: 1.3vw; line-height: var(--lh);
  margin: 0 0 2.5vh;
}
#gate-note { margin: 2.5vh 0 0; }

/* Two stacked fields since named logins (2026-10-12): a login name and a
   password. Grid rather than two flex rows so that both inputs come out exactly
   the same width and line up — the reveal button gets a column of its own, and
   the login row simply leaves that column empty. Flex would have made the login
   field wider than the password field by the width of that button.
   Grid is already load-bearing in this stylesheet (the leaderboard row), so
   this is not a new bet on what the old TV WebViews support. */
#gate-field {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  row-gap: 1.4vh;
}
#gate-user, #gate-input {
  grid-column: 1;                 /* both in the field column, one per row */
  width: 34vw; min-width: 0;
  font-family: inherit; font-size: 2vw; line-height: var(--lh);
  text-align: center;
  color: var(--text); background: var(--panel);
  border: .3vh solid var(--panel-2); border-radius: 1.2vh;
  padding: 1.2vh 1vw;
}
/* Only the masked field is spaced out character by character: a login name is
   read as a word, and letter-spacing makes one harder to read, not easier. */
#gate-input { letter-spacing: .15em; }
#gate-reveal { grid-column: 2; }
#gate-user::placeholder, #gate-input::placeholder {
  color: var(--muted); opacity: .75; letter-spacing: normal;
}
#gate-user:focus, #gate-input:focus { outline: none; border-color: var(--focus); }

#gate-hint {
  color: var(--muted); font-size: 1.1vw; line-height: var(--lh);
  margin: 1.6vh 0 0;
}
#gate-hint[hidden] { display: none; }

.ghost {
  font-family: inherit; font-size: 1.1vw; line-height: var(--lh);
  color: var(--muted); background: none;
  border: .2vh solid var(--panel-2); border-radius: 999px;
  padding: .8vh 1vw; margin-left: 1vw;
  cursor: pointer;
}

#gate-error {
  color: #fca5a5; font-size: 1.3vw; line-height: var(--lh);
  font-weight: 700; margin: 1.6vh 0 0;
}
#gate-error[hidden] { display: none; }

#keyboard { margin: 3vh 0 0; }
.krow {
  display: flex; justify-content: center;
  margin-bottom: 1.1vh;
}
.key {
  font-family: inherit; font-size: 1.5vw; line-height: 1;
  color: var(--text); background: var(--panel);
  border: .3vh solid transparent; border-radius: 1vh;
  min-width: 4.2vw; padding: 1.6vh .6vw;
  margin: 0 .35vw;
  cursor: pointer;
}
.key:hover  { background: var(--panel-2); }
.key:active { border-color: var(--focus); }
.key.wide   { min-width: 7vw; font-size: 1.2vw; color: var(--muted); }
.key.on     { background: var(--panel-2); color: var(--on); border-color: var(--on); }

#gate-submit {
  font-family: inherit; font-size: 1.6vw; line-height: var(--lh); font-weight: 700;
  color: #05203a; background: var(--on);
  border: none; border-radius: 999px;
  padding: 1.4vh 4vw; margin: 3vh 0 0;
  cursor: pointer;
}
#gate-submit:disabled { opacity: .55; cursor: default; }

/* ---- the change-password dialog (index.html) ---- */
/*
 * Shares the login page's keys — .key and .krow are defined once, above — for
 * the reason the keyboard is shared at all: two sets of controls that drift
 * apart would leave the one on the wall as the worse of the two.
 *
 * position: fixed over the whole viewport rather than a <dialog> element:
 * <dialog> and ::backdrop are Chrome 37/come-and-go on these WebViews, and a
 * modal that fails to open on the TV is a modal that does not exist.
 */
.modal {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 10;
  background: rgba(3, 9, 20, .82);
  overflow-y: auto;
  padding: 2vh 4vw;
  text-align: center;
}
.modal[hidden] { display: none; }

.modal-panel {
  display: inline-block;
  text-align: center;
  max-width: 64vw;
  margin: 0 auto;
  background: var(--bg);
  border: .3vh solid var(--panel-2);
  border-radius: 2vh;
  padding: 2.4vh 3vw;
  box-shadow: 0 2vh 6vh rgba(0, 0, 0, .7);
}

#pw-title {
  font-size: 2vw; font-weight: 800; line-height: var(--lh);
  margin: 0 0 1.4vh;
}

.pw-field { margin-bottom: 1vh; }
.pw-label {
  display: block;
  color: var(--muted); font-size: 1.1vw; line-height: var(--lh);
  margin-bottom: .5vh;
}
.pw-input {
  display: block; width: 34vw; margin: 0 auto;
  font-family: inherit; font-size: 1.6vw; line-height: var(--lh);
  letter-spacing: .15em;
  text-align: center;
  color: var(--text); background: var(--panel);
  border: .3vh solid var(--panel-2); border-radius: 1.2vh;
  padding: .9vh 1vw;
}
.pw-input:focus { outline: none; border-color: var(--focus); }

/* Which field the on-screen keys type into. The TV draws its own cursor and
   never reports :focus-visible, so the selected field is marked by app.js with
   a class rather than left to the browser to indicate. */
.pw-input.selected { border-color: var(--focus); background: var(--panel-2); }

#pw-tools { margin: 0 0 1vh; }

/* Doubles as the error line and the success line: one place on the panel where
   the answer appears, so nobody has to know where to look. */
#pw-message {
  color: #fca5a5; font-size: 1.2vw; line-height: var(--lh);
  font-weight: 700; margin: 1.4vh 0 0;
}
#pw-message.ok { color: var(--on); }
#pw-message[hidden] { display: none; }

#pw-keyboard { margin: 1.6vh 0 0; }

/* The dialog's keys are smaller than the login page's, and have to be.
 * login.html spends the whole screen on one field and a keyboard; this panel
 * carries three fields, a title and two actions as well. At the login page's
 * sizing the panel comes to roughly 1100px on a 1080p screen and starts to
 * scroll — and scrolling a dialog with a cursor you nudge from across a room is
 * the thing this whole design is trying to avoid. Measured at 1920x1080 and
 * 1280x720; both fit with room over.
 *
 * They are still comfortably larger than a mouse needs. The constraint is the
 * D-pad cursor, and these keep the same generous hit area per key that made the
 * login page usable on the real TV.
 */
#pw-keyboard .krow { margin-bottom: .7vh; }
#pw-scope {
  color: var(--muted); font-size: 1.05vw; line-height: var(--lh);
  margin: 0 0 1.4vh;
}
#pw-scope[hidden] { display: none; }

#pw-keyboard .key {
  font-size: 1.3vw;
  min-width: 3.8vw; padding: .95vh .5vw;
  margin: 0 .3vw;
}
#pw-keyboard .key.wide { min-width: 6.2vw; font-size: 1.05vw; }

#pw-actions { margin: 1.5vh 0 0; }
#pw-save {
  font-family: inherit; font-size: 1.4vw; line-height: var(--lh); font-weight: 700;
  color: #05203a; background: var(--on);
  border: none; border-radius: 999px;
  padding: 1.2vh 3vw; margin-left: 1.4vw;
  cursor: pointer;
}
#pw-save:disabled { opacity: .55; cursor: default; }
#pw-cancel { padding: 1.2vh 2vw; }

/* Logging the device out: the one control on this panel that costs something.
   A TV that logs out needs somebody to clock the password back in with a
   remote, so a stray click here is expensive in a way no other button is.
   Three things keep it from being hit by accident, and it needs all three
   because the cursor is steered a nudge at a time from across a room:

     - distance. It sits in the far-left corner of its own row, below a rule
       and a deliberately large gap, while Сохранить is bottom-right. Nothing
       aiming for Сохранить passes anywhere near it.
     - quietness. Small and muted, so the eye does not land on it either.
     - and it arms rather than fires — app.js makes the first click ask. */
/* One at each end of the row, which is the arrangement the client asked for
   and also the safest one available: Забыть пароль и выйти keeps the
   far-left corner it was given for being expensive, and the button that joined
   it is the cheapest control on the panel — it opens a list and changes
   nothing — so it is the right thing to put in the other corner. */
#pw-exit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2.6vh 0 0;
  padding: 1.4vh 0 0;
  border-top: .1vh solid rgba(255, 255, 255, .13);
  text-align: left;
}
#pw-exit > * { margin-left: 0; }
#users-open[hidden] { display: none; }
#pw-logout {
  font-size: .95vw;
  padding: .9vh 1.6vw; margin: 0;
  color: var(--muted); border-color: rgba(255, 255, 255, .13);
}
#pw-logout:disabled { opacity: .55; cursor: default; }

/* Asked once and waiting for the second click. Amber rather than red: this is
   a question, not a warning, and it withdraws it again after a few seconds. */
#pw-logout.armed {
  color: var(--focus); border-color: var(--focus);
}

/* ---- managing the logins (index.html #users-view, #user-edit) ---- */
/*
 * Three panels share the one dialog, one at a time. The attribute does the
 * hiding so that app.js only ever sets `hidden` and never fights a class.
 */
.pw-view[hidden] { display: none; }

#users-note, #user-edit-who {
  color: var(--muted); font-size: 1.1vw; line-height: var(--lh);
  margin: 0 0 1.6vh;
}

#users-list {
  list-style: none;
  margin: 0; padding: 0;
  width: 56vw;                      /* wider than the password form: six columns */
  text-align: left;
}

/*
 * One row per login, the full width of the panel, as the client asked. The
 * name takes whatever the buttons leave, so every row's controls line up in a
 * column however long the names are — on a display read from across a room,
 * ragged columns are read as a list that has lost its alignment rather than as
 * names of different lengths.
 */
.user-row {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: .2vh solid transparent;
  border-radius: 1.2vh;
  padding: 1vh 1.2vw;
  margin-bottom: .8vh;
}
.user-row:last-child { margin-bottom: 0; }

/* The shared password: shown so the list is the truth about who can get in,
   and visibly not editable from here. */
.user-row.fixed { opacity: .72; }

.user-name {
  flex: 1 1 auto;
  min-width: 0;                     /* so a long name ellipsises instead of pushing */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-size: 1.3vw; line-height: var(--lh); font-weight: 700;
}
.user-self {
  color: var(--muted); font-size: .95vw; font-weight: 400;
  margin-left: .8vw;
}

/*
 * Active or suspended, as a small light rather than a word: it is the one
 * thing on the row that has to be readable at a glance from the far side of
 * the room, and at this size a word would not be. The ring is what makes it
 * read as a lamp rather than as a bullet point.
 */
.lamp {
  flex: none;
  width: 1vw; height: 1vw;
  border-radius: 50%;
  margin-right: 1vw;
}
.lamp.on {
  background: var(--on);
  box-shadow: 0 0 .9vh var(--on), inset 0 0 0 .2vh rgba(255, 255, 255, .35);
}
.lamp.off {
  background: #b4293a;
  box-shadow: 0 0 .9vh rgba(180, 41, 58, .55), inset 0 0 0 .2vh rgba(255, 255, 255, .2);
}

.user-row .ghost {
  flex: none;
  font-size: 1vw;
  padding: .7vh 1vw; margin-left: .8vw;
}
.user-row .ghost:disabled { opacity: .5; cursor: default; }

/* The admin toggle says what the login IS as well as offering the change: the
   row has one slot for both, and a separate badge would cost a column. */
.user-row .toggle.on {
  color: var(--text);
  border-color: var(--focus);
  background: var(--panel-2);
}

/* Red type, not a red button: the row already carries four controls, and a
   filled red block among them would pull the eye to the one thing nobody is
   looking for.

   The min-width is what the armed label needs. Without it the button grows on
   the first click and shoves the other three leftwards — out from under a
   cursor that is already on its way to one of them, which on this remote takes
   a second or two to correct. */
.user-row .danger {
  color: #fca5a5;
  min-width: 13.6vw;
  text-align: center;
}
.user-row .danger:hover { border-color: #fca5a5; }

/* Asked once and waiting for the second click — the same amber question the
   logout button asks, and it withdraws itself the same way. */
.user-row .danger.armed {
  color: var(--focus); border-color: var(--focus);
}

/* The last row is the one that adds a row. Full width, so it reads as part of
   the list rather than as an action on the list. */
.user-row.user-add { background: none; padding: 0; margin-top: 1.2vh; }
.rowadd {
  display: block; width: 100%;
  font-family: inherit; font-size: 1.15vw; line-height: var(--lh); font-weight: 700;
  color: var(--muted); background: none;
  border: .2vh dashed var(--panel-2); border-radius: 1.2vh;
  padding: 1vh 1.2vw;
  cursor: pointer;
}
.rowadd:hover { color: var(--text); border-color: var(--focus); }

#users-message {
  color: #fca5a5; font-size: 1.2vw; line-height: var(--lh);
  font-weight: 700; margin: 1.4vh 0 0;
}
#users-message.ok { color: var(--on); }
#users-message[hidden] { display: none; }

#users-actions, #user-edit-actions { margin: 1.8vh 0 0; }
#user-edit-tools { margin: 0 0 1vh; }
#user-edit-tools[hidden] { display: none; }

#user-edit-message {
  color: #fca5a5; font-size: 1.2vw; line-height: var(--lh);
  font-weight: 700; margin: 1.4vh 0 0;
}
#user-edit-message.ok { color: var(--on); }
#user-edit-message[hidden] { display: none; }

/* The second keyboard, sized exactly like the password form's — same panel,
   same distance, same thumbs. */
#user-keyboard { margin: 1.6vh 0 0; }

#user-edit-save {
  font-family: inherit; font-size: 1.4vw; line-height: var(--lh); font-weight: 700;
  color: #05203a; background: var(--on);
  border: none; border-radius: 999px;
  padding: 1.2vh 3vw; margin-left: 1.4vw;
  cursor: pointer;
}
#user-edit-save:disabled { opacity: .55; cursor: default; }
#user-edit-cancel { padding: 1.2vh 2vw; }

/* A login is typed, not read out loud: the password form's wide letter-spacing
   suits a password being checked character by character and makes a name hard
   to recognise. */
#user-edit-login { letter-spacing: .02em; }

/* "Смена" and "Месяц" are legitimately empty most of the time — the source data
   is back-entered days later — so this is a normal daily state, not an error. */
#empty {
  display: block; text-align: center; color: var(--muted);
  font-size: 1.7vw; margin: 14vh auto 0; max-width: 40vw;
}
#empty::before {
  content: '···';
  display: block; font-size: 5vw; line-height: 1;
  color: var(--panel-2); margin-bottom: 2vh;
}
#empty[hidden] { display: none; }
