/* Dark, flat, and quiet.
 *
 * This page sits under four game windows on a wide monitor and is looked at
 * out of the corner of an eye for a couple of hours. Everything about it is
 * shaped by that: the codes are the only bright thing, the chrome is nearly
 * invisible, and nothing animates except the one thing that just changed.
 */
:root {
  --bg: #0c0e12;
  --panel: #14171d;
  --line: #22262e;
  --text: #e6e9ec;
  --dim: #79838d;
  --accent: #6c63ff;
  --fresh: #e8ecf1;
  --stale: #6a727b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-monospace, Consolas, "DejaVu Sans Mono", monospace;
}

/* -- landing ------------------------------------------------------------- */

.centre {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 22px 20px;
}

.card h1 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 700;
}

.card .lede {
  margin: 0 0 18px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
}

label {
  display: block;
  margin: 0 0 5px;
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim);
}

input[type="text"], select {
  width: 100%;
  padding: 9px 10px;
  margin: 0 0 14px;
  background: #0e1116;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 6px;
}

/* The slot picker. Four seats, laid out in the order they appear as columns
 * on the room page, because that is what the number means: slot 3 is the
 * third column, which sits under the third game window. There is no `any`:
 * a seat picked for you is a column pointed at a window you did not choose. */
.slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 8px;
}

.slot {
  padding: 7px 2px 6px;
  background: #0e1116;
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}

.slot b { font-size: 13px; font-weight: 700; }

.slot i {
  font-style: normal;
  font-size: 9px;
  letter-spacing: .04em;
  color: var(--dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot:hover:not(:disabled) { border-color: #39404b; }

.slot.on {
  border-color: var(--accent);
  background: #171a2b;
}

.slot.on i { color: var(--text); }
.slot.yours b, .slot.yours i { color: var(--accent); }

.slot:disabled {
  cursor: default;
  opacity: .45;
}

.hint {
  margin: 0 0 16px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
}

.primary {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: .04em;
}

.primary:disabled { opacity: .5; cursor: default; }

.error {
  margin: 12px 0 0;
  color: #e8756a;
  font-size: 12px;
  min-height: 1em;
}

/* -- room ---------------------------------------------------------------- */

.room {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* The bar is one row and never wraps. Its vertical padding is a named value
 * because the alarm button cancels it out to reach the full banner height:
 * keep the two in step. */
.bar {
  --bar-pad-y: 7px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: var(--bar-pad-y) 12px;
  background: #0a0c10;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.bar .meta { color: var(--text); flex: 0 0 auto; }
.bar .meta b { color: var(--dim); font-weight: 400; }

.bar .watchers {
  color: var(--dim);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

/* Round trip to the server, in milliseconds. Small, dim and always there: it
 * is the one number that says the codes on this screen are current. */
.bar .lag { color: #4a525c; font-size: 11px; }

/* Two of these flank the alarm. One part each against the alarm's two, so the
 * alarm takes half of whatever is left between the bookmarklet button and
 * Leave, at any window width. */
.bar .spacer { flex: 1 1 0; min-width: 0; }

/* The alarm. Rectangular, edge to edge of the banner's height, and the only
 * red thing on the page. `align-self: stretch` fills the bar's content box
 * and the negative block margin eats its padding, so the button is exactly as
 * tall as the bar and no taller. */
.alarm {
  flex: 2 1 0;
  min-width: 76px;
  align-self: stretch;
  margin-block: calc(-1 * var(--bar-pad-y));
  padding: 0;
  border-radius: 0;
  border-left: 1px solid #2d1210;
  border-right: 1px solid #2d1210;
  background: #7c1e17;
  color: #ffd8d2;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .34em;
  /* Tracking is added after the last letter too, so the word sits left of
   * centre without this. */
  text-indent: .34em;
}

.alarm:hover { background: #98251c; }
.alarm:active { background: #bb2f23; }

/* While it is ringing. A hard two-frame flip rather than a fade, because an
 * alarm that eases in and out reads as decoration. */
.alarm.ringing { animation: klaxon .4s steps(1, end) infinite; }

@keyframes klaxon {
  0%, 49.9% { background: #e0402e; color: #fff; }
  50%, 100% { background: #7c1e17; color: #ffd8d2; }
}

/* Move between slots without leaving the room. Same numbering as the columns
 * below, so pressing 3 puts you in the third column. */
.seatpick {
  display: inline-flex;
  gap: 3px;
}

.seat {
  width: 22px;
  height: 22px;
  padding: 0;
  background: #0e1116;
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px;
  border-radius: 4px;
}

.seat:hover:not(:disabled) { border-color: #39404b; color: var(--text); }

.seat.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: default;
}

.seat:disabled { opacity: .35; cursor: default; }

.pill {
  flex: 0 0 auto;
  padding: 4px 11px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 99px;
}

.pill.ghost {
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  font-weight: 400;
}

.offline {
  flex: 0 0 auto;
  color: #e8b05a;
  font-size: 12px;
}

.offline[hidden], .pill[hidden] { display: none; }

/* Browsers refuse to make a sound on a page nobody has clicked yet, and this
 * page is arrived at by navigation, so the first chime would be swallowed
 * with nothing said. This appears only when a play was actually refused and
 * goes away on the first click anywhere. */
.pill.muted {
  background: #4a3a12;
  color: #f0cf84;
  font-weight: 400;
}

/* Four equal columns, full height. Each one sits under the game window it
 * feeds, which is the whole reason the orchestrator can route a copied code
 * by pointer position alone: see docs/guild-war.md. */
.grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 0;
}

.box {
  position: relative;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 12px;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.box:last-child { border-right: 0; }
.box.empty { cursor: default; }
.box:not(.empty):hover { background: #171b22; }

.box .code {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .09em;
  color: var(--fresh);
  z-index: 1;
}

.box.stale .code { color: var(--stale); }
.box .who { font-size: 13px; color: var(--dim); z-index: 1; }
.box .waiting { font-size: 13px; color: #3d444d; letter-spacing: .06em; }

/* How long this code has been sitting there, to the millisecond, redrawn
 * every frame. A raid code is worth roughly ninety seconds, so the number
 * that matters is not whether it is stale but how close it is to being. It
 * also proves the page is live: a frozen counter is a dead socket.
 *
 * On your OWN column it is brighter and bigger, because it is doing a second
 * job there. The bookmarklet draws nothing in the game tab, so this counter
 * restarting from zero is how you know the press reached the finder. */
.box .age {
  position: absolute;
  bottom: 10px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: #39404a;
  z-index: 1;
  pointer-events: none;
}

.box.stale .age { color: #6b5330; }

.box.mine .age {
  font-size: 14px;
  font-weight: 700;
  color: #8b84ff;
}

/* Which column is yours, said rather than counted. You cannot count columns
 * while you are looking at a raid. */
.box .tag {
  position: absolute;
  top: 8px;
  left: 10px;
  display: none;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  z-index: 1;
  pointer-events: none;
}

.box.mine .tag { display: block; }

/* Occupied, but their page is shut. The seat is inside its grace period and
 * is about to be handed back, so the code in it is the last thing they will
 * post from that slot. Worth seeing, not worth shouting about. */
.box.away .who, .box.away .waiting { color: #8a6a3d; }

.box.mine::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  background: var(--accent);
}

/* The COPIED wash. Tiled text at very low contrast, so a box you have
 * already taken reads as done at a glance without hiding the code under it.
 * Per viewer and never sent to the server: whether you have copied a code is
 * nobody else's business and would be wrong for them anyway.
 *
 * HOW MANY WORDS IS COMPUTED, NOT GUESSED. A fixed number of repetitions
 * covers a laptop window and leaves the bottom half of a tall one bare, so
 * room.js measures the box and refills on every resize. The -10% bleed is what
 * stops the tiling from lining up with the edges. */
.box .wash {
  position: absolute;
  inset: -10%;
  display: none;
  color: #232830;
  font-size: 15px;
  font-weight: 700;
  line-height: 2.1;
  letter-spacing: .12em;
  word-spacing: .5em;
  overflow: hidden;
  pointer-events: none;
}

.box.copied .wash { display: block; }

.box .flash {
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.box.just-copied .flash { animation: flash .45s ease-out; }

@keyframes flash {
  from { opacity: .22; }
  to { opacity: 0; }
}

/* A code that just changed. The one animation on the page, because a new code
 * arriving is the one event worth pulling an eye across the screen. */
.box.fresh .code { animation: arrive .6s ease-out; }

@keyframes arrive {
  from { color: var(--accent); transform: scale(1.06); }
  to { color: var(--fresh); transform: scale(1); }
}

/* A code arriving in YOUR column rings the whole box, and rings it for long
 * enough to catch out of the corner of an eye. This is the confirmation the
 * bookmarklet deliberately does not draw in the game tab. */
.box.mine.fresh { animation: landed 1.1s ease-out; }

@keyframes landed {
  from { box-shadow: inset 0 0 0 3px var(--accent); background: #171a2b; }
  to { box-shadow: inset 0 0 0 0 transparent; background: transparent; }
}

/* -- modal --------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal[hidden] { display: none; }

.modal .card { max-width: 560px; }

.modal h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}

.modal p { color: var(--dim); font-size: 12px; margin: 0 0 12px; }
.modal ol { color: var(--dim); font-size: 12px; margin: 0 0 14px 18px; padding: 0; }
.modal li { margin-bottom: 5px; }

.drag {
  display: inline-block;
  padding: 8px 14px;
  margin: 0 0 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  cursor: grab;
}

.snippet {
  width: 100%;
  height: 96px;
  padding: 9px;
  background: #0e1116;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 11px/1.45 ui-monospace, Consolas, monospace;
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-all;
}

.row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.row button { padding: 8px 14px; }

.secondary {
  background: #20242c;
  color: var(--text);
}

/* Narrow. Not what this page is for -- it is meant to be a strip across the
 * bottom of a wide monitor -- but a window dragged small should still be
 * usable rather than pushed off its own right edge. The bar wraps and the
 * alarm takes the second row whole, which is the one control that would be
 * useless squeezed. */
@media (max-width: 720px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .box { border-bottom: 1px solid var(--line); }
  .box .code { font-size: 18px; }

  .bar { flex-wrap: wrap; gap: 8px; row-gap: 7px; }
  .bar .spacer { display: none; }
  .bar .watchers { margin-left: auto; }

  .alarm {
    order: 9;
    flex: 1 0 100%;
    height: 28px;
    margin-block: 0 calc(-1 * var(--bar-pad-y));
    margin-inline: -12px;
    border-left: 0;
    border-right: 0;
    width: auto;
  }
}
