/* MyGarminLiveTrack — its own styles on top of msk-ui (ui/tokens.css,
   ui/components.css) for the settings, the code page and the front page. The
   dashboard has dashboard.css. Colours only as tokens: both modes work. */

.hidden { display: none !important; }
.ok { color: var(--ok); }
.stat { font-variant-numeric: tabular-nums; }
button:disabled, .btn-ghost:disabled {
  opacity: .45; cursor: default; filter: none; transform: none;
}

/* ---------- settings ---------- */

main label {
  display: block; margin: .95rem 0 0;
  font-size: .82rem; font-weight: 500; color: var(--muted);
}
.card > label:first-child, .card > div:first-child > label:first-child { margin-top: 0; }
main .muted { font-size: .85rem; }
.note { margin: .5rem 0 0; color: var(--muted); font-size: .85rem; }
.note:empty { display: none; }
.panel > h2:first-child { margin-top: .6rem; }
.nav-link.my-page::after { content: "↗"; font-size: .8em; opacity: .7; }

/* A panel arriving should be felt rather than noticed. */
.panel { animation: lt-panel .18s ease-out; }
@keyframes lt-panel { from { opacity: 0; transform: translateY(4px); } }

/* What the worker is doing is why the page gets opened, so it never scrolls
   away: it stays under the header. */
.statusbar {
  position: sticky; z-index: 50;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px) + .5rem);
  margin: 0 0 1.4rem; padding: .7rem 1rem;
  background: var(--header-bg);
  -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.statusbar .head { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.statusbar .dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--faint);
}
.statusbar.running .dot { background: var(--ok); animation: lt-pulse 2s ease-in-out infinite; }
.statusbar.error .dot { background: var(--danger); }
@keyframes lt-pulse { 50% { opacity: .35; } }
.statusbar .what { font-weight: 600; }
.statusbar .sub {
  margin-top: .1rem; color: var(--muted); font-size: .8rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.statusbar .err { margin-top: .2rem; color: var(--danger); font-size: .85rem; }
.statusbar .sub:empty, .statusbar .err:empty { display: none; }
.pill {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  padding: .15rem .55rem; border-radius: 999px;
  background: var(--hover-soft); color: var(--muted);
}
/* A rehearsal looks exactly like a race; this is the line that says it is not. */
.simulated {
  margin-top: .6rem; padding: .5rem .75rem; font-size: .85rem;
  border: 1px solid var(--warn); border-radius: var(--r-sm); background: var(--warn-weak);
}

/* Rows of a field and its button. */
.switch { display: flex; align-items: center; gap: .6rem; }
.switch .grow { flex: 1 1 auto; min-width: 0; }
.switch button, .switch .btn-ghost { flex: none; }
.switch input, .switch select { margin-top: 0; }
label + .switch, label + .row { margin-top: .3rem; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }
.card .actions { margin-top: 1.1rem; }
.card .actions > button { flex: 1 1 0; }

/* A ghost button that destroys something says so in red. */
.btn-ghost.danger-text { color: var(--danger); }
.btn-ghost.danger-text:hover { background: var(--danger-weak); }

/* Grouped list: sessions and the legs of the course. */
.list {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm);
}
.list:empty { display: none; }
.card + .list, .note + .list { margin-top: .75rem; }
.item { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem;
        transition: background .12s; }
.item + .item { border-top: 1px solid var(--line-2); }
.item .body { flex: 1 1 auto; min-width: 0; }
.item .title { font-size: .92rem; }
.item .meta {
  margin-top: .1rem; color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* On a phone the facts wrap rather than get cut off: they are why the list exists. */
@media (max-width: 520px) { .item .meta { white-space: normal; } }
/* The sport of a leg corrects a guess, so it sits in its row, not across it. */
.item select { width: auto; flex: none; margin: 0; padding: .35rem 1.8rem .35rem .6rem;
               font-size: .82rem; }
.item button { flex: none; }
/* Only where there is a pointer: on a touch screen nothing hides behind hover. */
@media (hover: hover) {
  .item:hover { background: var(--hover); }
  .item .danger-text { opacity: .6; }
  .item:hover .danger-text, .item .danger-text:focus-visible { opacity: 1; }
}

/* Share codes. */
.codes {
  margin-top: .9rem; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
}
.codes:empty { display: none; }
.code-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem .75rem; }
.code-row + .code-row { border-top: 1px solid var(--line-2); }
.code-row .digits { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem;
                    letter-spacing: .18em; }
.code-row .label {
  flex: 1 1 auto; min-width: 0; color: var(--muted); font-size: .85rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.code-row.off .digits, .code-row.off .label { opacity: .45; }
/* Shown under its row after Copy link: readable where the clipboard is not,
   selectable in one gesture. */
.share-url {
  padding: 0 .75rem .6rem; font: .78rem/1.5 var(--mono); color: var(--muted);
  word-break: break-all; -webkit-user-select: all; user-select: all;
}
.new-code { display: flex; gap: .6rem; margin-top: .9rem; flex-wrap: wrap; }
.new-code input { margin: 0; }
.new-code #new-digits { width: 7rem; flex: none; font-variant-numeric: tabular-nums;
                        letter-spacing: .18em; text-align: center; }
.new-code .grow { flex: 1 1 10rem; width: auto; }
.new-code button { flex: none; }

/* A real switch, not a button that says what it would do. */
.toggle {
  position: relative; flex: none; width: 51px; height: 31px; min-height: 0;
  padding: 0; border: 0; border-radius: 999px; box-shadow: none;
  background: var(--line-strong); transition: background .2s;
}
.toggle:hover { filter: none; }
.toggle:active { transform: none; }
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: var(--accent-ink); box-shadow: var(--shadow-sm);
  transition: transform .2s cubic-bezier(.4, 0, .2, 1);
}
.toggle[aria-checked="true"] { background: var(--ok); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }

/* Does the form match what is running, or is it only typed in? */
.pending { display: flex; align-items: center; gap: .5rem; margin-top: 1rem;
           font-size: .85rem; color: var(--muted); }
.pending .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.pending.applied { color: var(--ok); }
.pending.applied .dot { background: var(--ok); }
.pending.staged { color: var(--warn); }
.pending.staged .dot { background: var(--warn); }
#gc-recheck { margin-left: auto; }
@media (max-width: 520px) {
  .pending { align-items: flex-start; flex-wrap: wrap; }
  .pending .dot { margin-top: .4rem; }
  #gc-recheck { margin: .4rem 0 0 1.05rem; }
}

/* What a button just did, under the card it belongs to. */
#flash, #page-flash, #access-flash, #gc-flash, #sessions-flash, #course-flash,
#tz-flash, #timing-flash, #notice-flash { margin: .8rem 0 0; font-size: .9rem; min-height: 1.3em; }

.modal-head h3 { margin: 0; font-size: 1.02rem; }
.modal-body p { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- the code page ---------- */

body.gate {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 1.5rem;
}
.gate .card { width: 100%; max-width: 24rem; margin: 0; padding: 1.8rem 1.6rem; text-align: center; }
.gate .brand-logo { width: 2.8rem; height: 2.8rem; margin: 0 auto 1rem; }
.gate h1 { font-size: 1.2rem; margin: 0 0 .4rem; }
.gate p { margin: 0 0 1.2rem; color: var(--muted); font-size: .9rem; }
.gate #code {
  font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: .5em; text-indent: .5em; text-align: center;
}
.gate button { width: 100%; margin-top: .9rem; }
.gate .msg { margin-top: .9rem; min-height: 1.2em; font-size: .85rem; color: var(--danger); }
.langs { margin-top: 1.1rem; font-size: .78rem; color: var(--faint); }
.langs a { color: var(--muted); }
.langs a.current { color: var(--fg); font-weight: 700; text-decoration: none; }

/* ---------- the front page ---------- */

body.front {
  display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
}
.front .brand { font-size: 1.2rem; gap: .7rem; color: var(--muted); }
.front .brand-logo { width: 2.4rem; height: 2.4rem; }

/* ---------- "sign in as" (MyAuth) ---------- */

/* An admin seeing the page as this user: plain to see, as in MyAuth. */
.imp-banner {
  position: sticky; top: 0; z-index: 101; display: flex; align-items: center;
  justify-content: center; gap: .75rem; flex-wrap: wrap; padding: .55rem 1rem;
  background: linear-gradient(var(--warn-weak), var(--warn-weak)), var(--bg);
  border-bottom: 2px solid var(--warn); color: var(--fg); font-weight: 600;
}
/* the banner holds the sticky top; the msk-ui header (sticky, z 100) scrolls away */
.imp-banner + header { position: static; }
