/* The sign-in gate: a splash with motion art, then a frosted card.

   Kept apart from styles.css on purpose. The gate is always dark whatever the
   device theme is (it is a doorway, not a page), and styles.css is held to the
   palette contract in theme.test.mjs. The art uses gold and sage only; the
   win/loss colours are reserved for graded outcomes and never appear here. */

body.locked > *:not(#gate):not(script) {
  display: none !important;
}

.gate {
  --g-bg: #0b110e;
  --g-ink: #e8efea;
  --g-dim: #a9b8b0;
  --g-gold: #d9a441;
  --g-gold-hi: #e8c687;
  --g-line: rgba(255, 255, 255, 0.14);
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 38%, #16241c 0%, var(--g-bg) 62%);
  color: var(--g-ink);
  font-family: var(--font-body, "Public Sans", system-ui, sans-serif);
  transition: opacity 0.6s ease, visibility 0.6s;
}

.gate[data-phase="done"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  animation: g-fade 1.6s ease 0.1s forwards;
}

/* The pitch, laid flat and tilted away, drawn line by line. */
.gate-pitch {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: perspective(900px) rotateX(58deg) translateY(4%) scale(1.5);
  opacity: 0.55;
}

.gate-pitch svg {
  width: min(86vw, 460px);
  height: auto;
  overflow: visible;
}

.gate-pitch path,
.gate-pitch circle,
.gate-pitch rect {
  fill: none;
  stroke: var(--g-gold);
  stroke-width: 0.35;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: g-draw 2.2s cubic-bezier(0.3, 0.6, 0.2, 1) forwards;
}

.gate-pitch .p2 { animation-delay: 0.25s; }
.gate-pitch .p3 { animation-delay: 0.5s; }

.gate-arc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.gate-arc .trail {
  fill: none;
  stroke: var(--g-gold-hi);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0.8;
  animation: g-draw 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.5s forwards;
}

.gate-arc .ball {
  fill: var(--g-gold-hi);
  filter: drop-shadow(0 0 8px rgba(232, 198, 135, 0.9));
}

/* A scrim that blurs the art once the card is up, so the card reads as a pop-up. */
.gate-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 13, 10, 0);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
  transition: background 0.8s ease, backdrop-filter 0.8s ease, -webkit-backdrop-filter 0.8s ease;
  pointer-events: none;
}

.gate[data-phase="login"] .gate-scrim {
  background: rgba(8, 13, 10, 0.38);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.gate-main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}

.gate-brand {
  margin: 0;
  text-align: center;
  font-family: var(--font-display, "Teko", system-ui, sans-serif);
  text-transform: uppercase;
  line-height: 0.9;
  animation: g-brand 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.7s both;
}

.gate-brand .fnp {
  display: block;
  font-size: clamp(4.4rem, 22vw, 7rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-right: -0.06em;
  background: linear-gradient(100deg, #b98322 20%, #f3dca6 45%, #d9a441 60%, #b98322 80%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: g-shine 3.2s ease 1.6s 1;
}

.gate-brand .edge {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.25rem, 6vw, 1.7rem);
  font-weight: 500;
  letter-spacing: 0.5em;
  margin-right: -0.5em;
  color: var(--g-ink);
}

.gate-dock {
  display: grid;
  grid-template-rows: 0fr;
  width: 100%;
  max-width: 380px;
  transition: grid-template-rows 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.gate[data-phase="login"] .gate-dock {
  grid-template-rows: 1fr;
}

.gate-dock-in {
  min-height: 0;
  overflow: hidden;
  padding: 12px 12px 28px;
  margin: -12px -12px -28px;
}

.gate-card {
  position: relative;
  margin-top: 28px;
  padding: 22px 20px 18px;
  border: 1px solid var(--g-line);
  border-radius: 22px;
  background: rgba(22, 34, 28, 0.5);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: translateY(26px) scale(0.97);
  transition: opacity 0.7s ease 0.25s, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) 0.25s;
}

.gate[data-phase="login"] .gate-card {
  opacity: 1;
  transform: none;
}

.gate-card h2 {
  margin: 0 0 2px;
  font-family: var(--font-display, "Teko", system-ui, sans-serif);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gate-sub {
  margin: 0 0 16px;
  color: var(--g-dim);
  font-size: 0.9rem;
}

.gate-field {
  display: block;
  margin-bottom: 12px;
}
.gate-field[hidden] { display: none; }

.gate-field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--g-dim);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gate-input {
  position: relative;
  display: flex;
}

.gate-input input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--g-line);
  border-radius: 12px;
  background: rgba(8, 13, 10, 0.55);
  color: var(--g-ink);
  font: inherit;
  font-size: 16px; /* under 16px, iOS zooms the page on focus */
}

input.gate-code { text-transform: uppercase; letter-spacing: 0.08em; }

.gate-input input.has-peek {
  padding-right: 64px;
}

.gate-input input:focus {
  outline: 2px solid var(--g-gold);
  outline-offset: 1px;
  border-color: transparent;
}

.gate-peek {
  position: absolute;
  top: 0;
  right: 0;
  height: 48px;
  padding: 0 14px;
  border: 0;
  background: none;
  color: var(--g-gold-hi);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.gate-msg {
  min-height: 1.3em;
  margin: 2px 0 10px;
  color: #ffc2b4;
  font-size: 0.88rem;
  line-height: 1.35;
}

.gate-go {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #e6b653, #cf9632);
  color: #1b1405;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.gate-go:hover { filter: brightness(1.06); }
.gate-go:active { transform: scale(0.985); }
.gate-go:focus-visible { outline: 2px solid var(--g-ink); outline-offset: 2px; }
.gate-go:disabled { opacity: 0.7; cursor: progress; }
.gate-go[data-busy]::after { content: "…"; }

.gate-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0 0;
  color: var(--g-dim);
  font-size: 0.8rem;
  text-align: center;
}

/* Rule 1: the not-betting-advice line is never dismissable, and it is here too. */
.gate-link[hidden] { display: none; }
.gate-link {
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--g-gold-hi);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.gate-link:focus-visible { outline: 2px solid var(--g-gold); outline-offset: 2px; border-radius: 6px; }

.gate-skip {
  position: absolute;
  z-index: 2;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  color: var(--g-dim);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  animation: g-fade 0.8s ease 1.2s forwards;
  pointer-events: none;
}

.gate:not([data-phase="splash"]) .gate-skip {
  display: none;
}

/* Locked again from inside a running session: no ceremony. */
.gate.relock,
.gate.relock * {
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}

@keyframes g-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes g-fade {
  to { opacity: 1; }
}

@keyframes g-brand {
  from { opacity: 0; filter: blur(14px); transform: scale(1.12); letter-spacing: 0.1em; }
  to   { opacity: 1; filter: blur(0);   transform: none; }
}

@keyframes g-shine {
  from { background-position: 120% 0; }
  to   { background-position: -60% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gate *,
  .gate *::before,
  .gate *::after {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
    transition-duration: 0.01s !important;
    transition-delay: 0s !important;
  }
  .gate-arc .ball { display: none; }
}

/* --- the owner's Members panel -------------------------------------------
   Opens over the app, so it wears the app's own tokens (styles.css) rather than
   the gate's always-dark ones. */
.members-dialog {
  border: none;
  border-radius: 18px;
  padding: 0;
  width: min(520px, calc(100vw - 24px));
  max-height: min(90vh, 820px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
}
.members-dialog::backdrop {
  background: rgba(10, 14, 12, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.members-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 12px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.members-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.members-body { padding: 4px 18px 20px; }
.mem-sec h3 { margin: 18px 0 4px; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); }
.mem-note { margin: 0 0 10px; color: var(--dim); font-size: 0.82rem; line-height: 1.4; }
.mem-new { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 10px; }
.mem-new input, .mem-new select {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.mem-new .mem-primary { grid-column: 1 / -1; }
.mem-new textarea {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}
.own-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 6px; }
.own-grid .mem-btn { min-height: 42px; }
.own-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
/* The push history's pages: newer on the left, older on the right. */
.own-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.own-pager .mem-note { margin: 0; }
.own-pager .mem-btn[disabled] { opacity: 0.45; cursor: default; }
.mem-new-one { grid-template-columns: 1fr; }
.mem-email { margin-top: 18px; }
.mem-email > summary { font-weight: 600; color: var(--text); }
.mem-list { list-style: none; margin: 0; padding: 0; }
.mem-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.mem-item.is-off .mem-main { opacity: 0.6; }
.mem-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mem-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.mem-sub { color: var(--dim); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; }
.mem-code { font-family: var(--font-mono); font-size: 0.86rem; letter-spacing: 0.04em; color: var(--accent-ink); }
.mem-btns { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.mem-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.mem-btn.mem-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); min-height: 42px; }
.mem-btn.mem-quiet { color: var(--dim); }
.mem-btn:disabled { opacity: 0.6; cursor: progress; }
.mem-pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.mem-pill.is-on { background: var(--accent-soft); color: var(--accent-ink); }
.mem-old { margin-top: 10px; }
.mem-old summary { cursor: pointer; color: var(--dim); font-size: 0.82rem; padding: 6px 0; }


/* --- the arena splash (the owner's call, 2026-11-01) ------------------------------------------------------------------------
   Gold and sage only, like the rest of the gate. The crowd is a silhouette; its camera flashes are white pinpoints that burst at
   random (gate.js places them); three light beams sweep slowly; the court draws itself; the crest scales in. All still for
   anyone whose device asks for reduced motion. */
/* a real arena behind it all (the owner, 2026-11-04), its court and stands in the photo, so the drawn ones go; the flashes and beams stay */
.gate { background-image: linear-gradient(180deg, rgba(6, 10, 8, 0.05), rgba(6, 10, 8, 0.2) 55%, rgba(6, 10, 8, 0.6)), url("/assets/theme/arena.jpg"); background-size: cover; background-position: center 42%; }
/* the arena is the picture: the drawn art that sat over it steps aside */
.gate-pitch, .gate-crowd, .gate canvas, .gate-arc, .gate-stands::before { display: none; }
.gate-stands { position: absolute; inset: 0 0 auto 0; height: 42%; pointer-events: none; overflow: hidden; }
.gate-crowd { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 55%; }
.gate-crowd path { fill: #050907; opacity: 0.9; }
.gate-flashes { position: absolute; inset: 0 0 18% 0; }
.gate-flashes i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: 0; box-shadow: 0 0 10px 4px rgba(255, 255, 255, 0.85), 0 0 26px 10px rgba(232, 198, 135, 0.35); animation: g-flash 3.2s infinite; }
@keyframes g-flash { 0%, 92%, 100% { opacity: 0; transform: scale(0.4); } 94% { opacity: 1; transform: scale(1.6); } 97% { opacity: 0.35; transform: scale(1); } }
.gate-beams { position: absolute; inset: 0; pointer-events: none; overflow: hidden; mix-blend-mode: screen; }
.gate-beams i { position: absolute; top: -20%; width: 34%; height: 120%; background: linear-gradient(180deg, rgba(232, 198, 135, 0.16), rgba(232, 198, 135, 0)); clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%); transform-origin: 50% 0; animation: g-sweep 7s ease-in-out infinite alternate; }
.gate-beams i:nth-child(1) { left: 2%; animation-delay: -1s; }
.gate-beams i:nth-child(2) { left: 33%; animation-duration: 9s; opacity: 0.7; }
.gate-beams i:nth-child(3) { left: 64%; animation-delay: -4s; }
@keyframes g-sweep { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
.gate-crest { display: block; width: clamp(64px, 16vw, 96px); height: auto; margin: 0 auto 10px; overflow: visible; animation: g-crest 1.1s 0.3s cubic-bezier(0.2, 0.9, 0.2, 1.2) both; filter: drop-shadow(0 6px 22px rgba(217, 164, 65, 0.35)); }
@keyframes g-crest { from { opacity: 0; transform: scale(0.6) translateY(10px); } to { opacity: 1; transform: none; } }
.gate-crest .crest-shield { fill: rgba(217, 164, 65, 0.1); stroke: var(--g-gold); stroke-width: 3; stroke-dasharray: 1; stroke-dashoffset: 1; animation: g-draw 1.4s 0.2s ease-out forwards; }
.gate-crest .crest-inner { fill: none; stroke: var(--g-gold-hi); stroke-width: 1; opacity: 0.6; stroke-dasharray: 1; stroke-dashoffset: 1; animation: g-draw 1.4s 0.5s ease-out forwards; }
.gate-crest .crest-star { fill: var(--g-gold-hi); }
.gate-crest .crest-fnp { fill: var(--g-ink); font: 800 26px/1 var(--font-display, "Barlow Condensed", system-ui, sans-serif); letter-spacing: 1px; }
.gate-crest .crest-bar { stroke: var(--g-gold); stroke-width: 2.5; stroke-linecap: round; }
@media (prefers-reduced-motion: reduce) {
  .gate-flashes i, .gate-beams i { animation: none; }
  .gate-flashes i { opacity: 0.5; }
}

/* The owner's panel scrolls by itself: the page behind it stays put (2026-11-01: scrolling stuck and moved the panels behind).
   One scroller only, the body under a fixed header (2026-10-31: the panel and its body both scrolled and fought over a drag). */
.members-dialog[open] { display: flex; flex-direction: column; max-height: min(90dvh, 820px); overflow: hidden; }
.members-dialog .members-head { flex: none; }
.members-dialog .members-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
html:has(dialog[open]) { overflow: hidden; }

/* The owner's tools on a phone: tabs on one sliding row that stay in reach, buttons a full thumb wide, nothing clipped */
.admin-tabs { display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 8px 0; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tabs .subtab { flex: 0 0 auto; }
@media (max-width: 640px) {
  .mem-new { grid-template-columns: 1fr; }
  .mem-new input, .mem-new select, .mem-new textarea, .mem-new .mem-btn { width: 100%; min-height: 44px; font-size: 16px; }
  .own-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .mem-item { flex-wrap: wrap; row-gap: 8px; }
  .mem-main { flex: 1 1 100%; }
  .mem-main strong { white-space: normal; }
  .mem-btns { flex: 1 1 100%; flex-wrap: wrap; }
  .mem-btns .mem-btn { flex: 1 1 auto; min-height: 42px; }
}

/* On a phone the owner's tools are a whole screen, not a small box */
@media (max-width: 640px) {
  .members-dialog, .members-dialog[open] { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
}

/* The owner's tools: a way back always in reach, buttons that say how each job last went */
.members-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.members-head h2 { flex: 1; margin: 0; font-size: 1rem; text-align: center; }
.mem-back { min-height: 40px; padding: 0 10px; border: 0; background: none; color: var(--accent-ink); font: inherit; font-weight: 700; cursor: pointer; }
.mem-reload { min-height: 36px; }
.own-group { margin: 12px 0 2px; font-size: 0.72rem; font-weight: 700; color: var(--dim); }
.job-list { display: grid; }
.job-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.job-row details { flex: 1; min-width: 0; }
.job-row summary { display: flex; align-items: center; gap: 2px; min-height: 36px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.job-row summary::-webkit-details-marker { display: none; }
.job-name { font-size: 0.88rem; font-weight: 600; margin-right: 8px; }
.job-when { font-size: 0.72rem; color: var(--dim); }
.job-when.is-bad { color: var(--accent-ink); font-weight: 700; }
.job-detail { margin: 2px 0 6px 15px; font-size: 0.74rem; overflow-wrap: anywhere; }
.job-run { flex: 0 0 auto; min-height: 36px; padding: 0 14px; }
.mem-devices { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.82rem; color: var(--dim); }
.mem-devices select { min-height: 36px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.ov-actions { display: grid; gap: 6px; margin: -6px 0 12px; }
.ov-link { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; cursor: pointer; }
.ov-line[data-admin-tab] { cursor: pointer; }
.mem-search { width: 100%; min-height: 42px; margin: 4px 0 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
.own-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }

