/* GoLive UI components: buttons, inputs, chips, toggle, notices, toast, spinner, and the auth
   card used by the consent screen, sign-in and the console. Load after site.css (it reuses the
   colour tokens defined there). Behaviour lives in /ui.js; every page works without it.

   Motion rules: 150 to 250 ms, ease-out, transform and opacity only, press = scale(.98), and
   nothing moves when the visitor asks for reduced motion. */
:root {
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: 150ms; --t: 200ms; --t-slow: 250ms;
  /* --accent-strong / --btn-ink (site.css): the brand green is too light for white text at
     4.5:1, so buttons and accent text on light surfaces use a deeper shade. */
  --ok: #0b7a45; --ok-soft: #e3f4ea;
  --warn: #b45309; --warn-soft: #fff7ed;
  --bad: #b91c1c; --bad-soft: #fdecec;
  --focus: #2563eb;
  --field-bg: var(--panel);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ok: #34d399; --ok-soft: #11291e;
    --warn: #fbbf24; --warn-soft: #2a2110;
    --bad: #fca5a5; --bad-soft: #2a1414;
    --focus: #93c5fd;
    --field-bg: var(--bg);
  }
}
body { overflow-x: clip; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.brand .mark { width: 24px; height: 24px; border-radius: 6px; flex: none; display: block; }
:where(a, button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── buttons ──────────────────────────────────────────────────────────────────────────── */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--accent-strong); color: var(--btn-ink); font: inherit; font-weight: 650; line-height: 1.2;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; isolation: isolate;
  transition: transform var(--t-fast) var(--ease), opacity var(--t) var(--ease);
}
/* Hover and press tint: an overlay that fades (opacity only). */
.btn::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; background: currentColor; opacity: 0; z-index: -1; transition: opacity var(--t-fast) var(--ease); pointer-events: none; }
.btn:hover::before { opacity: .08; }
.btn:active { transform: scale(.98); }
.btn:active::before { opacity: .14; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.quiet { background: transparent; color: var(--muted); border-color: transparent; }
.btn.quiet:hover { color: var(--ink); }
.btn.danger { background: var(--bad); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger { color: #2a1414; } }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.btn.block { display: flex; width: 100%; }
.btn .ico { width: 18px; height: 18px; flex: none; }
.btn .arrow { transition: transform var(--t) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; transform: none; }
.btn:disabled::before { opacity: 0; }
/* Loading: the label fades out and a spinner fades in, in place, so the button keeps its size. */
.btn .btn-label { display: inline-flex; align-items: center; gap: 8px; transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.btn::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: 0; pointer-events: none; transition: opacity var(--t-fast) var(--ease); }
.btn.is-loading { cursor: progress; }
.btn.is-loading:disabled { opacity: 1; }
.btn.is-loading .btn-label { opacity: 0; transform: scale(.96); }
.btn.is-loading:not(:has(.btn-label)) { color: transparent; }
.btn.is-loading::after { opacity: 1; animation: ui-spin .7s linear infinite; }
.btn.is-loading:not(:has(.btn-label))::after { border-color: var(--btn-ink); border-right-color: transparent; }
/* Copied: the label swaps for a check that pops in. */
.btn .when-idle { display: inline-flex; align-items: center; gap: 6px; }
.btn .when-done { display: none; }
.btn.is-done .when-idle { display: none; }
.btn.is-done .when-done { display: inline-flex; align-items: center; gap: 6px; animation: ui-pop var(--t-slow) var(--ease) both; }

.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ui-spin .7s linear infinite; vertical-align: middle; }

/* ── form fields ──────────────────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; margin: 14px 0; }
.field > label, .field-label { font-weight: 600; font-size: .9rem; }
.field .hint { margin: 0; color: var(--muted); font-size: .82rem; }
.check-row { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; font-size: .9rem; cursor: pointer; }
.check-row input { margin-top: 3px; flex: none; width: 16px; height: 16px; }
.field .hint.risk strong { color: var(--bad, #b42318); }
.input {
  width: 100%; min-height: 44px; font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--field-bg); color: var(--ink);
}
.input::placeholder { color: var(--muted); opacity: 1; }
.input:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; letter-spacing: .01em; }
/* An input with inline actions (show/hide, paste) inside its right edge. */
.input-group { position: relative; display: flex; align-items: center; }
.input-group.has-actions .input { padding-right: 148px; }
.input-actions { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; }
.input-action {
  min-height: 32px; min-width: 32px; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  transition: transform var(--t-fast) var(--ease);
}
.input-action:hover { color: var(--ink); }
.input-action:active { transform: scale(.96); }
.input-action .ico { width: 15px; height: 15px; }
.input-action > span { display: inline-flex; align-items: center; gap: 5px; }
.input-action[aria-pressed="true"] { color: var(--ink); border-color: var(--muted); }

/* ── chips ────────────────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; white-space: nowrap;
  font-size: .78rem; font-weight: 700; letter-spacing: .02em; line-height: 1; padding: 6px 10px; border-radius: 999px;
  background: var(--bg2); color: var(--muted); border: 1px solid transparent;
}
.chip .ico { width: 14px; height: 14px; flex: none; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

/* ── notices (server-rendered messages) and toasts (JS) ───────────────────────────────── */
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 10px; margin: 12px 0; font-size: .9rem; line-height: 1.5;
  background: var(--bg2); color: var(--ink); animation: ui-rise var(--t-slow) var(--ease) both; }
.notice .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.notice p { margin: 0; }
.notice.ok { background: var(--ok-soft); }
.notice.ok .ico { color: var(--ok); }
.notice.warn { background: var(--warn-soft); }
.notice.warn .ico { color: var(--warn); }
.notice.err { background: var(--bad-soft); font-weight: 600; }
.notice.err .ico { color: var(--bad); }
.toast-region { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 50; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: .9rem; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px) scale(.98); transition: opacity var(--t) var(--ease), transform var(--t) var(--ease);
}
.toast.is-shown { opacity: 1; transform: none; }
.toast .ico { width: 16px; height: 16px; color: var(--accent); }

/* ── disclosure ───────────────────────────────────────────────────────────────────────── */
details.disclosure { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; background: var(--bg); }
details.disclosure > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: .88rem; font-weight: 600; color: var(--muted); border-radius: 10px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary:hover { color: var(--ink); }
details.disclosure > summary .chev { width: 16px; height: 16px; transition: transform var(--t) var(--ease); }
details.disclosure[open] > summary .chev { transform: rotate(90deg); }
details.disclosure .disclosure-body { padding: 0 12px 12px; animation: ui-rise var(--t) var(--ease) both; }
details.disclosure dl { margin: 0; display: grid; gap: 4px; font-size: .85rem; }
details.disclosure dt { color: var(--muted); font-weight: 600; margin-top: 6px; }
details.disclosure dd { margin: 0; }
.wrap-anywhere, details.disclosure code { overflow-wrap: anywhere; word-break: break-all; white-space: normal; }

/* ── the auth card (consent, sign-in, expired) ────────────────────────────────────────── */
body.auth { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; margin: 0; padding: 24px 16px; }
.auth-box {
  width: 100%; max-width: 448px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px;
  box-shadow: var(--shadow); animation: ui-rise var(--t-slow) var(--ease) both;
}
.auth-box > .brand { font-size: 1rem; }
.auth-box h1 { font-size: 1.45rem; line-height: 1.25; margin: 18px 0 8px; }
.auth-box h2.label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.auth-box .lead { color: var(--muted); }
.auth-box form { margin: 0; }
.auth-box .actions { display: grid; gap: 10px; margin-top: 18px; }
.auth-box .foot { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.auth-box .foot a { color: var(--ink); }
.auth-box.is-shaking { animation: ui-shake 240ms var(--ease); }
.auth-box .state-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--bg2); color: var(--muted); margin: 22px 0 0; animation: ui-pop var(--t-slow) var(--ease) both; }
.auth-box .state-icon.ok { background: var(--ok-soft); color: var(--ok); }
.auth-box .state-icon.warn { background: var(--warn-soft); color: var(--warn); }
.auth-box .state-icon svg { width: 28px; height: 28px; }
.auth-box ol.steps-list { padding-left: 1.2em; margin: 12px 0; }
.auth-box ol.steps-list li { margin: 6px 0; }
.copy-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.copy-row code { flex: 1 1 200px; min-width: 0; display: flex; align-items: center; padding: 8px 12px; background: var(--code-bg); border-radius: 10px; overflow-wrap: anywhere; font-size: .88rem; }

/* Consent: two tiles joined by a wire whose pulses run toward GoLive. */
.link-visual { display: flex; align-items: center; justify-content: center; gap: 0; margin: 22px 0 6px; }
.link-visual .tile { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; flex: none; border: 1px solid var(--line);
  background: var(--bg2); color: var(--ink); font-size: 1.5rem; font-weight: 750; letter-spacing: -.02em; box-shadow: var(--shadow); }
.link-visual .tile svg { width: 28px; height: 28px; }
.link-visual .tile img { width: 60px; height: 60px; border-radius: 16px; display: block; }
.link-visual .tile.golive { border: 0; background: none; }
.link-visual .tile.is-verified { background: var(--ok-soft); color: var(--ok); }
.link-visual .tile.is-impersonating { background: var(--bad-soft); color: var(--bad); }
.link-visual .wire { position: relative; width: 84px; height: 2px; margin: 0 10px; background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 10px); overflow: visible; }
.link-visual .wire i { position: absolute; top: -3px; left: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: 0; animation: ui-travel 1.8s var(--ease) infinite; }
.link-visual .wire i:nth-child(2) { animation-delay: .6s; }
.link-visual .wire i:nth-child(3) { animation-delay: 1.2s; }
.link-visual .wire .done { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-strong); color: var(--btn-ink); opacity: 0; transform: scale(.5); transition: opacity var(--t) var(--ease), transform var(--t-slow) var(--ease); }
.link-visual .wire .done svg { width: 16px; height: 16px; }
.consent[data-state="success"] .link-visual .wire i { animation: none; opacity: 0; }
.consent[data-state="success"] .link-visual .wire .done { opacity: 1; transform: none; }
.consent[data-state="busy"] .link-visual .wire i { animation-duration: .9s; }

.consent h1 { text-align: center; }
.consent h1 .chip { margin-left: 4px; position: relative; top: -2px; }
.consent .dest { text-align: center; color: var(--muted); margin: 0 0 4px; overflow-wrap: anywhere; }
.consent .dest-host { color: var(--ink); font-size: 1.05rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.consent .notice .dest-host { font-size: .95em; }
.can-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.can-list li { display: flex; gap: 12px; align-items: flex-start; font-size: .92rem; line-height: 1.45; }
.can-list .ico { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-strong); flex: none; }
.consent .step { transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.consent[data-state="success"] .step-form { display: none; }
.consent .step-success { text-align: center; padding: 8px 0 4px; }
.consent .step-success h2 { font-size: 1.35rem; margin: 6px 0 4px; }
.consent .step-success .big-check { width: 64px; height: 64px; border-radius: 50%; margin: 6px auto 8px; display: grid; place-items: center; background: var(--accent-strong); color: var(--btn-ink);
  animation: ui-pop var(--t-slow) var(--ease) both; }
.consent .step-success .big-check svg { width: 32px; height: 32px; animation: ui-pop var(--t-slow) var(--ease) 90ms both; }

/* Account picker and key reveal (console). */
.auth-box ul.picker { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; }
.auth-box ul.picker form { margin: 0; }
.btn.pick { display: flex; width: 100%; justify-content: space-between; text-align: left; background: var(--bg); color: var(--ink); border-color: var(--line); }
.btn.pick:hover { border-color: var(--accent-strong); }
.keybox { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.keybox code { flex: 1 1 260px; min-width: 0; word-break: break-all; padding: 10px 12px; background: var(--code-bg); border-radius: 10px; font-size: .92rem; user-select: all; display: flex; align-items: center; }
.console .card.reveal { border-color: var(--accent-strong); animation: ui-rise var(--t-slow) var(--ease) both; }
.console .reveal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.console .reveal-head h2 { margin: 0; }

/* Console form controls share the field and button look. */
.console .input { max-width: 520px; }
.console button:not(.linkish):not(.input-action) { transition: transform var(--t-fast) var(--ease), opacity var(--t) var(--ease); }
.console button:not(.linkish):not(.input-action):active { transform: scale(.98); }

/* ── hero entrance (landing) ──────────────────────────────────────────────────────────── */
.hero > * { animation: ui-rise var(--t-slow) var(--ease) both; }
.hero > :nth-child(2) { animation-delay: 40ms; }
.hero > :nth-child(3) { animation-delay: 80ms; }
.hero > :nth-child(4) { animation-delay: 120ms; }
.hero > :nth-child(5) { animation-delay: 160ms; }
.hero > .term { animation-delay: 120ms; }
.cta .btn { min-height: 48px; padding: 12px 20px; }
.btn.primary-glow { box-shadow: 0 8px 22px -12px color-mix(in srgb, var(--accent-strong) 90%, transparent); }

@keyframes ui-spin { to { transform: rotate(360deg); } }
@keyframes ui-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ui-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes ui-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
@keyframes ui-travel { 0% { opacity: 0; transform: translateX(0) scale(.6); } 20% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(76px) scale(1); } }

@media (max-width: 420px) {
  .auth-box { padding: 22px 18px; border-radius: 16px; }
  .link-visual .wire { width: 56px; }
  @keyframes ui-travel { 0% { opacity: 0; transform: translateX(0) scale(.6); } 20% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(48px) scale(1); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .btn:active, .input-action:active, .console button:active { transform: none !important; }
  .btn:hover .arrow { transform: none; }
  /* Still show that something is happening, without movement. */
  .btn.is-loading::after, .spinner { animation: none !important; border-right-color: currentColor; opacity: .6; }
  .link-visual .wire i { display: none; }
}

/* Console layout touches for the shared components. */
.console form.stack .btn, .console form.row .btn { justify-self: start; }
.console .card .field { margin: 0; }
.console form.stack .field .input { max-width: 520px; }
.top .btn.danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.small { min-height: 36px; }
