/* Transbay account: the sign-in corner on transbay.dev's own pages, and the
 * account, sign-in and choose-username pages.
 *
 * Builds on style.css and glass.css. The bento pattern and the token and
 * danger treatments follow flaguu/console.css, prefixed here so a page that
 * loads both never has the two fighting.
 */

/* --- The top-right corner ------------------------------------------------ */

.tb-corner {
  position: fixed; top: 22px; right: 22px;
  z-index: 20;
  display: flex; align-items: center; gap: 0.6rem;
}

/* The chip's menu and the signed-in chip are shown and hidden by nav-auth.js
 * through `hidden`, which the display rules below would otherwise override. */
[data-nav-auth] [hidden] { display: none !important; }

.tb-corner .nav-signin {
  font-family: var(--font-display); font-weight: 600;
  padding: 0.7em 1.35em;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  transition: background 0.3s ease, border-color 0.3s ease;
}
.tb-corner .nav-signin:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.3);
  text-decoration: none;
}
.tb-corner .chip-button {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
}
.tb-corner .chip-button:hover { background: rgba(255, 255, 255, 0.14); }

/* The Sign in pill grows into this panel, from the corner it sits in. */
.tb-corner .nav-signin { transition: background 0.3s ease, border-color 0.3s ease, opacity 0.2s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1); }
.tb-corner.signin-open .nav-signin { opacity: 0; transform: scale(1.15); pointer-events: none; }

.signin-pop {
  position: absolute; top: 0; right: 0;
  width: min(320px, calc(100vw - 32px));
  padding: 1.25rem 1.25rem 1.1rem;
  border-radius: 24px;
  transform-origin: top right;
  transform: scale(0.35, 0.18);
  opacity: 0;
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.3, 1.08), opacity 0.22s ease;
  /* Opaque enough to read over whatever is behind it; glass alone let the cards show through. */
  background: rgba(22, 24, 31, 0.97);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.tb-corner.signin-open .signin-pop { transform: none; opacity: 1; }
.signin-pop-title {
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  margin: 0 0 0.35rem; color: #fff;
}
.signin-pop-text { font-size: 0.92rem; color: rgba(255, 255, 255, 0.78); margin: 0 0 1rem; }
.signin-pop .apple-button { margin: 0; }
.signin-pop-note { font-size: 0.8rem; color: rgba(255, 255, 255, 0.55); margin: 0.75rem 0 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .signin-pop, .tb-corner .nav-signin { transition: opacity 0.15s ease; }
  .signin-pop { transform: none; }
}

/* Flaguu's purple is the default accent; transbay.dev's own avatar is neutral. */
body.tb .chip-avatar { background: linear-gradient(135deg, var(--bay-accent), var(--flaguu-accent)); }

/* BayTransit Widgets' header has no Download button, so the slot is narrower. */
.account-slot-compact { width: auto; }

@media (max-width: 1200px) {
  body.landing .tb-corner { position: absolute; top: 16px; right: 16px; }
  .tb-corner .nav-signin { font-size: 0.95rem; }
}

/* On a phone the transbay.dev pill takes the left half of the top edge, so the
 * signed-in chip shrinks to its avatar -- the name is in the menu's page anyway. */
@media (max-width: 620px) {
  .tb-corner { top: 16px; right: 16px; }
  body.about .landing-mark { top: 16px; left: 16px; font-size: 0.95rem; }
  .tb-corner .chip-name, .tb-corner .chip-caret { display: none; }
  .tb-corner .chip-button { padding: 0.3rem; }
}

/* --- Account pages --------------------------------------------------------- */

body.tb { min-height: 100dvh; }

.tb-main { padding: 120px 24px 96px; }
.tb-wrap { max-width: 1040px; margin: 0 auto; }
.tb-narrow { max-width: 520px; margin: 0 auto; }

.tb-head { margin-bottom: 2rem; }
.tb-head .eyebrow { margin-bottom: 0.4rem; }
.tb-head h1 { font-size: clamp(2rem, 5vw, 2.9rem); margin: 0 0 0.35em; }
.tb-head p { color: rgba(255, 255, 255, 0.72); max-width: 60ch; margin: 0; }

.tb-bento {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gap);
}
.tb-bento > * { min-width: 0; }
.tb-tile h2 { font-size: 1.15rem; margin: 0 0 0.9rem; }
.tb-tile p:last-child { margin-bottom: 0; }

.tile-profile { grid-column: span 4; }
.tile-tokens  { grid-column: span 2; }
.tile-sites   { grid-column: span 4; }
.tile-session { grid-column: span 2; }
.tile-danger  { grid-column: 1 / -1; }

@media (max-width: 920px) {
  .tb-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-profile, .tile-sites, .tile-danger { grid-column: 1 / -1; }
  .tile-tokens, .tile-session { grid-column: span 1; }
}
@media (max-width: 620px) {
  .tb-main { padding: 96px 16px 72px; }
  .tb-bento { grid-template-columns: minmax(0, 1fr); }
  .tb-bento > * { grid-column: 1 / -1; }
}

/* Profile */
.who {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.3rem;
}
.who-avatar {
  flex: none;
  width: 64px; height: 64px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--bay-accent), var(--flaguu-accent));
  color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 1.8rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}
.who-name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.45rem;
  overflow-wrap: anywhere;
}
.who-since { color: var(--ink-faint); font-size: 0.88rem; }

.inline-form { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form + .hint { display: block; margin-top: 0.5rem; font-size: 0.82rem; color: var(--ink-faint); }
.inline-form .field { flex: 1 1 14rem; }

/* Game tokens -- Flaguu's, in Flaguu's colours. */
.tile-tokens {
  --accent: var(--flaguu-accent); --accent-soft: var(--flaguu-accent-soft);
  display: flex; flex-direction: column;
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent) 26%, transparent),
      color-mix(in srgb, var(--accent) 9%, transparent));
}
.tile-tokens .eyebrow { color: var(--accent-soft); margin: 0 0 0.4rem; }
.token-count {
  display: flex; align-items: baseline; gap: 0.55rem;
  margin: 0 0 0.7rem;
}
.token-count .n {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.8rem, 8vw, 3.8rem); line-height: 1;
  background: linear-gradient(180deg, var(--accent-soft), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-variant-numeric: tabular-nums;
}
.token-count .unit { font-family: var(--font-display); font-weight: 500; font-size: 1.05rem; color: var(--ink-dim); }
.token-count.pending .n { background: none; color: var(--ink-faint); }
.token-count.problem { color: #FFB4AE; font-size: 0.95rem; }
.tile-tokens .more { margin-top: auto; padding-top: 0.6rem; font-weight: 600; }

/* Sites */
.site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.site-row {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
a.site-row:hover {
  text-decoration: none;
  border-color: var(--edge-strong);
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}
.site-row img { flex: none; width: 44px; height: 44px; border-radius: 11px; }
.site-row .text { flex: 1; min-width: 0; }
.site-row .name { display: block; font-weight: 600; color: var(--ink); }
.site-row .desc { display: block; font-size: 0.88rem; color: var(--ink-dim); }
.site-row .go { flex: none; color: var(--ink-dim); font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.site-row.soon { opacity: 0.6; }
.site-row.soon .go { font-weight: 500; color: var(--ink-faint); }

/* Session */
.tile-session { display: flex; flex-direction: column; }
.tile-session .btn-row { margin-top: auto; padding-top: 0.8rem; }

/* Danger */
.tile-danger { border-color: rgba(255, 69, 58, 0.4); }
.tile-danger h2 { color: #FFB4AE; }
.btn-danger {
  background: rgba(255, 69, 58, 0.14);
  border-color: rgba(255, 69, 58, 0.4);
  color: #FFB4AE;
}
.btn-danger:hover { background: rgba(255, 69, 58, 0.26); }
.btn-danger:disabled:hover, .btn-danger[disabled]:hover { background: rgba(255, 69, 58, 0.14); }

/* Sign in and choose-username */
.tb-card { text-align: left; }
.apple-button {
  display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  width: 100%;
  background: #fff; color: #000; border-color: #fff;
}
.apple-button:hover { background: #E8E8ED; color: #000; }
.apple-button svg { width: 1.05em; height: 1.05em; fill: currentColor; margin-top: -0.15em; }

.tb-loading { color: var(--ink-faint); }
