/* The sign-in page: the form on the left, a short looping picture of how an answer is made on
   the right. Tokens, the base and the buttons come from app/css/tokens.css, base.css and
   components.css, which load first. The picture moves with transform and opacity only;
   app/signin.js sets the state classes and types the question. */

/* ---------- the sign-in form's fields and card (moved from the old style.css) ---------- */
body.signin-page { display: grid; place-items: center; min-height: 100vh; padding: var(--space-8) var(--space-6); background: radial-gradient(1200px 600px at 50% -10%, var(--sig-soft) 0%, var(--canvas) 60%); }
.signin { width: 100%; max-width: 400px; }
.signin-card { display: grid; gap: var(--space-5); padding: var(--space-10) var(--space-9) var(--space-9); border: 1px solid var(--rule); border-radius: var(--radius-xl); background: var(--sheet); box-shadow: var(--shadow-raised); }
.signin-brand { margin: 0 0 var(--space-3); }
.signin-brand .wordmark { color: var(--ink); font-size: 20px; }
.signin-brand .wordmark em { color: var(--dim); }
.signin-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.signin-lead { margin: 0 0 var(--space-4); font-size: var(--size-body); color: var(--dim); }
.field { display: grid; gap: var(--space-3); font-size: var(--size-sm); font-weight: 500; color: var(--ink-2); }
.field input { height: 42px; padding: 0 var(--space-5); border: 1px solid var(--field-edge); border-radius: var(--radius); background: var(--sheet); font-size: var(--size-body); color: var(--ink); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.field input:focus { outline: none; border-color: var(--sig-light); box-shadow: 0 0 0 3px var(--sig-soft); }
.signin-error { min-height: 1.4em; margin: 0; font-size: var(--size-sm); color: var(--bad); }
.signin-error:empty { min-height: 0; }
.signin-submit { height: 44px; margin-top: var(--space-2); font-size: var(--size-body); }
/* Supporting browsers cross-fade to the workspace, which declares the same rule (shell.css). */
@view-transition { navigation: auto; }

body.auth-page {
  /* One knob for the whole loop: every duration and delay in the picture, and the timeline in
     signin.js, is divided by it. 1.4 plays the loop in about 8 seconds. */
  --loop-speed: 1.4;
  min-height: 100vh; background-color: var(--canvas);
  /* The deck's ground: the same faint grid as the workspace's main column. */
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }

/* ---------- the form ---------- */
.auth-main { display: flex; align-items: center; justify-content: center; min-width: 0; padding: var(--space-12) var(--space-10); }
.auth-form { display: flex; flex-direction: column; width: 100%; max-width: 380px; }
.auth-brand { margin: 0 0 var(--space-11); }
.auth-brand .wordmark { color: var(--ink); font-size: 20px; }
.auth-brand .wordmark em { color: var(--ink-2); font-weight: 400; }
.auth-title { margin: 0 0 var(--space-4); font-size: var(--size-question); font-weight: 600; line-height: var(--lh-tight); letter-spacing: -.02em; }
.auth-lead { margin: 0 0 var(--space-10); font-size: var(--size-lg); line-height: var(--lh-copy); color: var(--ink-2); }
.auth-form .field { margin-bottom: var(--space-7); }
.auth-form .field input { height: 44px; }
.auth-form .field input:focus { outline: none; border-color: var(--sig); box-shadow: 0 0 0 3px var(--sig-soft); }
.auth-error { margin: 0 0 var(--space-6); font-size: var(--size-sm); line-height: var(--lh-ui); color: var(--bad); }
.auth-error:empty { margin: 0; }
.auth-submit { width: 100%; height: 46px; margin-top: var(--space-2); font-size: var(--size-body); }
.auth-submit svg { width: 16px; height: 16px; flex: none; }
.auth-submit.is-success:disabled { opacity: 1; cursor: default; }

/* ---------- leaving for the workspace ----------
   After a good sign-in (signin.js): the form lifts 8 px and fades, the picture fades, both in
   220 ms; then the workspace opens. Where the browser supports cross-document view transitions,
   the page change itself cross-fades too; the workspace stylesheet carries the matching rule. */
body.is-leaving .auth-form { opacity: 0; transform: translateY(-8px); transition: opacity 220ms cubic-bezier(.2, .8, .2, 1), transform 220ms cubic-bezier(.2, .8, .2, 1); }
body.is-leaving .auth-aside { opacity: 0; transition: opacity 220ms cubic-bezier(.2, .8, .2, 1); }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: auth-vt-out 200ms cubic-bezier(.2, .8, .2, 1) both; }
  ::view-transition-new(root) { animation: auth-vt-in 260ms cubic-bezier(.2, .8, .2, 1) both; }
}
@keyframes auth-vt-out { to { opacity: 0; } }
@keyframes auth-vt-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  body.is-leaving .auth-form, body.is-leaving .auth-aside { transition: none; }
}

/* Demo accounts: only when the server lists some. Choosing one fills the two fields. */
.auth-demo { display: grid; gap: var(--space-3); margin-bottom: var(--space-7); padding-bottom: var(--space-7); border-bottom: 1px solid var(--rule); }
.auth-demo-label { font-size: var(--size-sm); font-weight: 500; color: var(--ink-2); }
.auth-select { position: relative; display: block; }
.auth-select select {
  width: 100%; height: 40px; padding: 0 var(--space-10) 0 var(--space-5); border: 1px solid var(--field-edge); border-radius: var(--radius);
  background: var(--chrome); font-size: var(--size-body); color: var(--ink); appearance: none; -webkit-appearance: none; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.auth-select select:hover { border-color: var(--ink-2); background: var(--sheet); }
.auth-select select:focus { outline: none; border-color: var(--sig); box-shadow: 0 0 0 3px var(--sig-soft); }
.auth-select svg { position: absolute; top: 50%; right: var(--space-5); width: 16px; height: 16px; margin-top: -8px; color: var(--dim); pointer-events: none; }
.auth-form .field input.is-filled { animation: auth-filled 300ms ease-out; }
@keyframes auth-filled { from { border-color: var(--sig-light); background-color: var(--sig-soft); } to { border-color: var(--field-edge); background-color: var(--sheet); } }

/* The theme switch (app/js/theme.js), in the page's top corner. */
.auth > .theme-toggle { position: fixed; top: var(--space-8); right: var(--space-8); z-index: 10; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--sheet); color: var(--ink-2); transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.auth > .theme-toggle:hover { border-color: var(--field-edge); color: var(--ink); }
.auth > .theme-toggle .ico { width: 16px; height: 16px; }

/* ---------- the picture ---------- */
.auth-aside {
  position: relative; display: flex; align-items: center; justify-content: center; min-width: 0;
  margin: var(--space-5); padding: var(--space-12) var(--space-10);
  border: 1px solid var(--rule); border-radius: var(--radius-xl);
  background: radial-gradient(900px 520px at 85% 0%, var(--sig-soft) 0%, var(--sheet) 55%, var(--sheet) 100%);
}
.demo-wrap { width: 100%; max-width: 500px; }
.demo-heading { margin: 0; font-size: var(--size-title); font-weight: 600; line-height: var(--lh-tight); letter-spacing: -.02em; color: var(--ink); }
.demo-caption { margin: var(--space-3) 0 var(--space-10); font-size: var(--size-body); color: var(--ink-2); }

.demo { display: grid; gap: var(--space-9); transition: opacity calc(520ms / var(--loop-speed)) ease-out; }
.demo.is-out { opacity: 0; }
.demo.is-reset, .demo.is-reset *, .demo.is-reset *::before, .demo.is-reset *::after { transition: none !important; animation: none !important; }
.demo.is-paused *, .demo.is-paused *::before, .demo.is-paused *::after { animation-play-state: paused !important; }

/* The question, typed. The hidden copy holds the box at its full size, so nothing moves. */
.demo-ask {
  display: flex; align-items: flex-start; gap: var(--space-5); padding: var(--space-5) var(--space-7);
  border: 1px solid var(--rule-2); border-radius: 26px; background: var(--sheet); box-shadow: var(--shadow-card);
  font-size: var(--size-body); line-height: var(--lh-ui); color: var(--ink);
}
.demo-ask-icon { flex: none; width: 16px; height: 16px; margin-top: 3px; color: var(--dim); }
.demo-ask-text { display: grid; flex: 1; min-width: 0; }
.demo-ask-sizer, .demo-ask-typed { grid-area: 1 / 1; }
.demo-ask-sizer { visibility: hidden; }
.demo-ask-typed::after { content: ""; display: inline-block; width: 2px; height: 1.1em; margin-left: 1px; vertical-align: -.2em; background: var(--sig); opacity: 0; }
.demo.is-typing .demo-ask-typed::after { animation: demo-caret calc(1000ms / var(--loop-speed)) steps(1) infinite; }
@keyframes demo-caret { 0% { opacity: 1; } 50% { opacity: 0; } }

/* The five steps on one line. The line fills by scaling, node to node. */
.demo-pipe { position: relative; }
.demo-track { position: absolute; top: 10px; left: 10%; right: 10%; height: 2px; overflow: hidden; border-radius: 2px; background: var(--rule-2); }
.demo-fill {
  position: absolute; inset: 0; background: var(--sig); transform: scaleX(0); transform-origin: left center;
  transition: transform calc(460ms / var(--loop-speed)) cubic-bezier(.2, .7, .3, 1);
}
.demo[data-fill="1"] .demo-fill { transform: scaleX(.25); }
.demo[data-fill="2"] .demo-fill { transform: scaleX(.5); }
.demo[data-fill="3"] .demo-fill { transform: scaleX(.75); }
.demo[data-fill="4"] .demo-fill { transform: scaleX(1); }

.demo-steps { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.demo-step { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 0 var(--space-1); text-align: center; }
.demo-node {
  position: relative; isolation: isolate; box-sizing: border-box; width: 22px; height: 22px; margin-bottom: var(--space-4);
  border: 1.5px solid var(--rule-2); border-radius: 50%; background: var(--sheet);
}
/* Active: an accent ring with a dot, and a soft halo that breathes out. */
.demo-node::before {
  content: ""; position: absolute; inset: -1.5px; border: 1.5px solid var(--sig); border-radius: 50%;
  background: radial-gradient(circle, var(--sig) 0 3px, var(--sheet) 3.5px); opacity: 0;
  transition: opacity calc(260ms / var(--loop-speed)) ease-out;
}
.demo-node::after { content: ""; position: absolute; inset: -1.5px; z-index: -1; border-radius: 50%; background: var(--sig); opacity: 0; }
.demo-step.is-active .demo-node::before { opacity: 1; }
.demo-step.is-active .demo-node::after { animation: demo-halo calc(1400ms / var(--loop-speed)) cubic-bezier(.2, .7, .3, 1) infinite; }
@keyframes demo-halo { 0% { opacity: .24; transform: scale(1); } 100% { opacity: 0; transform: scale(2.2); } }
/* Done: a filled accent disc with a check. */
.demo-node svg {
  position: absolute; inset: -1.5px; width: 22px; height: 22px; padding: 4px; border-radius: 50%;
  background: var(--sig); color: var(--on-accent); opacity: 0; transform: scale(.55);
  transition: opacity calc(240ms / var(--loop-speed)) ease-out, transform calc(360ms / var(--loop-speed)) cubic-bezier(.3, 1.3, .5, 1);
}
.demo-step.is-done .demo-node svg { opacity: 1; transform: none; }
.demo-label {
  font-size: var(--size-meta); font-weight: 600; line-height: 1.3; color: var(--ink); opacity: .42;
  transition: opacity calc(300ms / var(--loop-speed)) ease-out;
}
.demo-result {
  min-height: 2.7em; margin-top: var(--space-1); font-size: var(--size-label); line-height: 1.35; color: var(--dim);
  opacity: 0; transform: translateY(4px);
  transition: opacity calc(320ms / var(--loop-speed)) ease-out, transform calc(320ms / var(--loop-speed)) ease-out;
}
.demo-step.is-active .demo-label, .demo-step.is-done .demo-label { opacity: 1; }
.demo-step.is-done .demo-result { opacity: 1; transform: none; }

/* The answer card rises in; the verified mark follows; then the approval ticks. It is the deck's
   highlighted card: a cyan edge over a soft cyan tint, the figure in cyan. */
.demo-answer {
  padding: var(--space-8); border: 1px solid var(--accent-line); border-radius: var(--radius-lg); background: linear-gradient(var(--sig-soft), var(--sig-soft)), var(--sheet); box-shadow: var(--shadow-raised);
  opacity: 0; transform: translateY(14px) scale(.985);
  transition: opacity calc(480ms / var(--loop-speed)) ease-out, transform calc(620ms / var(--loop-speed)) cubic-bezier(.2, .7, .3, 1);
}
.demo.has-answer .demo-answer { opacity: 1; transform: none; }
.demo-answer-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.demo-kicker { font: 400 var(--size-meta)/16px var(--font-mono); letter-spacing: var(--track-label); text-transform: uppercase; color: var(--ink-2); }
.demo-verified {
  display: inline-flex; align-items: center; gap: var(--space-4); padding: var(--space-1) 0;
  font: 500 var(--size-meta)/16px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--sig);
  opacity: 0; transform: scale(.92);
  transition: opacity calc(300ms / var(--loop-speed)) ease-out, transform calc(360ms / var(--loop-speed)) cubic-bezier(.2, .7, .3, 1);
}
.demo.has-answer .demo-verified { opacity: 1; transform: none; transition-delay: calc(420ms / var(--loop-speed)); }
.demo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sig); }
.demo-figure { margin: var(--space-6) 0 var(--space-2); font: 500 var(--size-figure)/1.05 var(--font-mono); letter-spacing: -.02em; color: var(--sig); }
.demo-desc { margin: 0; font-size: var(--size-body); color: var(--ink-2); }
.demo-answer-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap;
  margin-top: var(--space-7); padding-top: var(--space-6); border-top: 1px solid var(--rule);
}
.demo-source { display: inline-flex; align-items: center; gap: var(--space-3); font: 400 var(--size-meta)/16px var(--font-mono); color: var(--ink-2); }
.demo-source svg { width: 14px; height: 14px; flex: none; }
.demo-approve {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: var(--space-4);
  padding: var(--space-2) var(--space-5) var(--space-2) var(--space-3);
  border: 1px solid var(--rule-2); border-radius: 999px; background: var(--sheet);
  font-size: var(--size-meta); font-weight: 600; color: var(--ink-2);
}
.demo-approve::before {
  content: ""; position: absolute; inset: -1px; z-index: -1; border: 1px solid var(--sig-light); border-radius: 999px;
  background: var(--sig-soft); opacity: 0; transition: opacity calc(320ms / var(--loop-speed)) ease-out;
}
.demo-box { position: relative; width: 16px; height: 16px; border: 1.5px solid var(--rule-2); border-radius: var(--radius-xs); background: var(--sheet); }
.demo-box svg {
  position: absolute; inset: -1.5px; width: 16px; height: 16px; padding: 2px; border-radius: var(--radius-xs);
  background: var(--sig); color: var(--on-accent); opacity: 0; transform: scale(.5);
  transition: opacity calc(220ms / var(--loop-speed)) ease-out, transform calc(340ms / var(--loop-speed)) cubic-bezier(.3, 1.4, .5, 1);
}
.demo.is-approved .demo-approve::before { opacity: 1; }
.demo.is-approved .demo-box svg { opacity: 1; transform: none; }

/* Reduced motion: the served final frame, still. */
@media (prefers-reduced-motion: reduce) {
  .demo, .demo *, .demo *::before, .demo *::after { transition: none !important; animation: none !important; }
}

/* ---------- narrower windows ---------- */
@media (max-width: 1239px) {
  .auth-main { padding: var(--space-11) var(--space-9); }
  .auth-aside { padding: var(--space-11) var(--space-9); }
}
@media (max-width: 999px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-main { padding: var(--space-11) var(--space-6); }
}
@media (max-width: 480px) {
  .auth-main { align-items: flex-start; padding-top: var(--space-10); }
  .auth-brand { margin-bottom: var(--space-10); }
}
