/*
 * One hue drives every glow and slowly cycles round the colour wheel (the same names and
 * timing as Getaway's, so all tabs match). bar.css reads --at-hue from here.
 */
@property --at-hue {
  syntax: "<number>";
  inherits: true;
  initial-value: 220;
}

@keyframes at-hue-cycle {
  from { --at-hue: 220; }
  to { --at-hue: 580; }
}

:root {
  color-scheme: dark;
  animation: at-hue-cycle 24s linear infinite;
  --at-glow: hsl(var(--at-hue) 95% 68% / 0.45);
  --at-glow-soft: hsl(var(--at-hue) 95% 68% / 0.16);
  --at-tint: hsl(var(--at-hue) 100% 82%);
  --bg: #050505;
  --fg: #ededed;
  --muted: #8a8a8a;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.28);
  --accent: #ffffff;
  --accent-glow: var(--at-glow);
  --error: #ff5a5f;
  --error-glow: rgba(255, 90, 95, 0.55);
  --sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Background video (login and Home pages only), behind the glow and the text --- */

.bg-video {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

/*
 * YouTube draws its own UI where we can't hide it: play/pause and the spinner in the player's
 * centre, title along the top, logo bottom-right. Covering the player doesn't work (YouTube
 * then treats the muted video as hidden and keeps pausing it), so the player is placed so all
 * of that falls off-screen instead:
 * - its centre sits --edge past the right edge of the screen, so we see the picture just left of centre;
 * - it's tall enough that its top and bottom (the video's baked-in black bars, ~18.6% each,
 *   plus the title and logo) are off-screen too: only the middle ~63% is picture, so it needs
 *   at least 282vh of width (159vh tall); 292vh leaves a margin for that estimate.
 */
.bg-video iframe {
  --edge: max(120px, 10vw);
  --w: max(2 * (100vw + var(--edge)), 292vh);
  position: absolute;
  top: 50%;
  left: calc(100vw + var(--edge) - var(--w) / 2);
  width: var(--w);
  height: calc(var(--w) * 9 / 16);
  border: 0;
  transform: translateY(-50%);
}

/* Darken it so the glowing text stays the star. */
.bg-video::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(5, 5, 5, 0.6) 0%, rgba(5, 5, 5, 0.84) 70%, rgba(5, 5, 5, 0.94) 100%);
}

/* --- Background glow: a soft light that slowly drifts behind everything --- */

.glow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.glow i {
  position: absolute;
  left: 50%;
  top: 46%;
  width: max(60rem, 115vmin);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.09) 0%, rgba(255, 255, 255, 0.024) 38%, transparent 62%),
    radial-gradient(
      circle,
      hsl(var(--at-hue) 90% 62% / 0.16) 0%,
      hsl(var(--at-hue) 90% 60% / 0.05) 34%,
      transparent 58%
    );
  translate: -50% -50%;
  animation: drift 20s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate(-4%, -3%) scale(1); }
  to { transform: translate(4%, 3%) scale(1.08); }
}

/* --- Glowing heavy type --- */

.ink {
  margin: 0;
  font-family: var(--sans);
  font-weight: 800;
  line-height: 1;
  /* Room for descenders (g, y) so the gradient doesn't clip them. */
  padding: 0.04em 0.08em 0.14em 0.02em;
  /* Top layer: the band of light that sweeps across. Bottom layer: white fading into the glow colour. */
  background:
    linear-gradient(100deg, transparent 42%, rgba(255, 255, 255, 0.95) 50%, transparent 58%),
    linear-gradient(180deg, #f2f2f2 20%, var(--at-tint));
  background-size: 250% 100%, 100% 100%;
  background-position: 100% 0, 0 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px var(--at-glow-soft));
}

.wordmark {
  font-size: clamp(2.75rem, 12vw, 8.5rem);
  letter-spacing: -0.065em;
  /* "backwards", not "both": once risen, the element's own glow filter (which follows the hue) takes over. */
  animation:
    rise 1s var(--ease-out) backwards,
    shimmer 7s ease-in-out 1.4s infinite;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.2em);
    filter: blur(14px) drop-shadow(0 0 28px var(--at-glow-soft));
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0) drop-shadow(0 0 28px var(--at-glow-soft));
  }
}

/* A band of light sweeps across the text, then pauses. */
@keyframes shimmer {
  0% { background-position: 100% 0, 0 0; }
  40%, 100% { background-position: 0% 0, 0 0; }
}

/* --- Login gate --- */

.gate {
  position: relative;
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(1.25rem, 3.5vw, 2.5rem);
  padding: 2rem 1rem;
  text-align: center;
}

.login {
  width: min(100%, 18rem);
}

.field {
  position: relative;
  animation: fade-in 0.8s ease 0.9s both;
}

/* The glowing line under the wordmark doubles as the password field's underline. */
.field::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 6rem;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  translate: -50% 0;
  transition: width 0.5s var(--ease-out), box-shadow 0.3s;
  animation: draw 1.2s var(--ease-out) 0.35s both;
}

.field:focus-within::after,
.field:has(input:not(:placeholder-shown))::after {
  width: 100%;
  box-shadow: 0 0 20px 1px var(--accent-glow);
}

@keyframes draw {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.field input {
  width: 100%;
  padding: 0.85rem 2.5rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.3em;
  text-align: center;
  caret-color: var(--at-tint);
}

.field input::placeholder {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

.field input:focus::placeholder {
  opacity: 0.45;
}

.field button {
  position: absolute;
  right: 0;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  translate: -0.25rem -50%;
  transition: opacity 0.25s, translate 0.25s var(--ease-out), color 0.2s, filter 0.2s;
}

/* The arrow only appears once something has been typed. */
.field input:not(:placeholder-shown) + button {
  opacity: 1;
  translate: 0 -50%;
}

.field button:hover,
.field button:focus-visible {
  color: var(--at-tint);
  filter: drop-shadow(0 0 8px var(--accent-glow));
  outline: 0;
}

.field.has-error {
  animation: shake 0.4s;
}

.field.has-error::after {
  width: 100%;
  background: var(--error);
  box-shadow: 0 0 18px 1px var(--error-glow);
}

.message {
  min-height: 1rem;
  margin: 1.1rem 0 0;
  color: var(--error);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 0 12px var(--error-glow);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* After a wrong password the page reloads: skip the intro so it doesn't replay every time. */
.gate.again .wordmark,
.gate.again .title {
  animation: shimmer 7s ease-in-out 0.4s infinite;
}

.gate.again .field::after,
.gate.again .field:not(.has-error),
.gate.again .note,
.gate.again .aside {
  animation: none;
}

/* --- Signed-in area (the top bar itself is in bar.css) --- */

.home {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.empty {
  position: relative;
  flex: 1;
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.25rem;
  padding: 2rem 1rem;
  text-align: center;
}

.title {
  font-size: clamp(2.5rem, 9vw, 5.5rem);
  letter-spacing: -0.06em;
  animation:
    rise 1s var(--ease-out) backwards,
    shimmer 7s ease-in-out 1.4s infinite;
}

.rule {
  width: 6rem;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
  animation: draw 1.2s var(--ease-out) 0.35s both;
}

.note {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  animation: fade-in 0.8s ease 0.9s both;
}

.note a {
  text-underline-offset: 0.35em;
}

/* --- Forms with several lines (login, join, new password, account) --- */

.field + .field {
  margin-top: 0.4rem;
}

.home > .gate {
  flex: 1;
  min-height: 0;
}

.message.ok {
  color: var(--at-tint);
  text-shadow: 0 0 12px var(--at-glow);
}

/* Small link under a form, e.g. "Have an invite code? Join". */
.aside {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
  animation: fade-in 0.8s ease 1.1s both;
}

.aside:hover,
.aside:focus-visible {
  color: var(--at-tint);
  text-shadow: 0 0 12px var(--at-glow);
  outline: 0;
}

/* --- Admin page --- */

.page {
  position: relative;
  width: min(100%, 52rem);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3rem) 1rem 4rem;
  display: grid;
  gap: 1.5rem;
}

.page > .title {
  justify-self: center;
}

.notice {
  margin: 0;
  justify-self: center;
  color: var(--at-tint);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow: 0 0 12px var(--at-glow);
}

.panel {
  padding: 1.25rem clamp(1rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(10, 10, 10, 0.55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.label {
  margin: 0;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
}

.panel > .muted {
  margin: 0.6rem 0 0;
}

.rows {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.row.is-new {
  margin: 0 -0.75rem;
  padding: 0.9rem 0.75rem;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--at-glow), 0 0 24px var(--at-glow-soft);
}

.row-main {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  flex: 1 1 16rem;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.row-actions form {
  margin: 0;
}

.code {
  color: var(--at-tint);
  font-family: var(--mono);
  font-size: 1.25rem;
  letter-spacing: 0.18em;
  text-shadow: 0 0 14px var(--at-glow);
}

.person {
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.badge {
  margin-left: 0.4rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--at-glow);
  border-radius: 999px;
  color: var(--at-tint);
  font-family: var(--mono);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  vertical-align: middle;
}

.copy-field {
  width: 100%;
  padding: 0.4rem 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.copy-field:focus {
  color: var(--fg);
  border-bottom-color: var(--at-glow);
}

.pill {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.pill:hover,
.pill:focus-visible {
  color: var(--fg);
  border-color: var(--line-strong);
  box-shadow: 0 0 16px var(--at-glow-soft);
  outline: 0;
}

.pill.primary {
  color: var(--fg);
  border-color: var(--at-glow);
  box-shadow: 0 0 16px var(--at-glow-soft);
}

.pill.primary:hover,
.pill.primary:focus-visible {
  box-shadow: 0 0 22px var(--at-glow);
}

.pill.danger:hover,
.pill.danger:focus-visible {
  color: var(--error);
  border-color: var(--error);
  box-shadow: 0 0 16px var(--error-glow);
}

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

  .bg-video {
    display: none;
  }
}
