/* Sign-in page. Uses shared/tokens.css (copied next to it) and the generated brand.css; no
   inline styles, so its CSP allows style-src 'self' only.
   One centred column in the Apple ID pattern: the client's molecule assembles as the mark,
   then the logo, a headline, two grouped fields with floating labels and one pill button. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh; background: var(--surface); color: var(--ink-1);
  font-family: var(--font); font-size: var(--fs-body); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -webkit-tap-highlight-color: transparent;
}
:root[data-theme="dark"] body { background: var(--bg); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- layout ---------- */
.login {
  min-height: 100dvh; display: grid; grid-template-rows: 1fr auto; justify-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.login-body { align-self: center; width: 100%; max-width: 400px; padding: clamp(16px, 4vh, 48px) 0; text-align: center; }

/* ---------- the mark, the logo and the words ---------- */
.login-mark { display: flex; justify-content: center; margin: 0 auto clamp(20px, 3.4vh, 32px); }
.login-molecule { display: block; width: clamp(150px, 46vw, 216px); height: auto; overflow: visible; }
.login-logo { display: block; height: 34px; width: auto; max-width: 200px; margin: 0 auto clamp(22px, 3.4vh, 30px); object-fit: contain; }
.login-title { margin: 0; color: var(--ink); font-size: clamp(1.875rem, 4.8vw, 2.5rem); font-weight: var(--w-light); line-height: 1.12; letter-spacing: var(--track-display); text-wrap: balance; }
.login-lead { margin: 10px auto 0; color: var(--ink-2); font-size: 1.0625rem; max-width: 30ch; text-wrap: balance; }
.login-help { margin: 22px 0 0; color: var(--ink-2); font-size: var(--fs-small); }

/* ---------- form: two fields grouped in one rounded box, labels inside ---------- */
.login-form { margin-top: clamp(26px, 4vh, 36px); text-align: left; }
.login-group { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); }
.login-field { position: relative; }
.login-field + .login-field { border-top: 1px solid var(--line-2); }
.login-input {
  display: block; width: 100%; height: 58px; padding: 24px 16px 6px; margin: 0;
  border: 0; border-radius: 0; background: transparent; color: var(--ink-1); font-size: 1.0625rem;
  -webkit-appearance: none; appearance: none; transition: box-shadow var(--t-state);
}
.login-field:first-child .login-input { border-radius: 13px 13px 0 0; }
.login-field:last-child .login-input { border-radius: 0 0 13px 13px; }
.login-input:focus { outline: none; }
.login-input:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.login-input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--danger); }
.login-field label {
  position: absolute; left: 17px; right: 16px; top: 0; height: 58px; display: flex; align-items: center;
  color: var(--ink-3); font-size: 1.0625rem; line-height: 1.2; pointer-events: none; transform-origin: 0 50%; white-space: nowrap;
  transition: transform var(--t-state) var(--ease), color var(--t-state);
}
.login-input:focus + label, .login-input:not(:placeholder-shown) + label, .login-input:-webkit-autofill + label {
  transform: translateY(-12px) scale(.76); color: var(--ink-2);
}
.login-input:focus + label { color: var(--focus); }
.login-input[aria-invalid="true"] + label { color: var(--danger-text); }

.login-secret .login-input { padding-right: 84px; }
.login-reveal {
  position: absolute; top: 7px; right: 7px; min-width: 64px; height: 44px; padding: 0 12px;
  border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--brand-secondary-text);
  font-size: .9375rem; font-weight: 600; cursor: pointer; transition: background-color var(--t-state);
}
.login-reveal:hover { background: var(--fill); }
.login-field-error { margin: 8px 4px 0; color: var(--danger-text); font-size: var(--fs-small); font-weight: 500; }

.login-message {
  display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; padding: 12px 14px;
  border-radius: 12px; background: var(--danger-soft); color: var(--danger-text);
  font-size: .9375rem; line-height: 1.4;
}
.login-message[hidden] { display: none; }
.login-message-icon { flex: none; margin-top: 1px; }
.login-message.is-info { background: var(--fill); color: var(--ink-2); }
.login-message.is-info .login-message-icon { display: none; }

.login-submit {
  display: block; width: 100%; min-height: 54px; padding: 0 24px; margin-top: 18px;
  border: 0; border-radius: var(--radius-pill); background: var(--brand-primary); color: var(--on-primary);
  font-size: 1.0625rem; font-weight: 600; letter-spacing: -.005em; cursor: pointer;
  transition: filter var(--t-state), transform var(--t-tap) var(--ease), background-color var(--t-state);
}
.login-submit:hover { filter: brightness(1.08); }
.login-submit:active { transform: scale(.98); }
.login-submit[aria-busy="true"] { cursor: progress; background: var(--brand-primary-strong); filter: none; }

/* ---------- footer: the client's tagline and the prototype notice ---------- */
.login-foot { display: grid; justify-items: center; gap: 4px; padding-top: 16px; text-align: center; }
.login-tagline { margin: 0; color: var(--brand-secondary-text); font-size: var(--fs-micro); font-weight: 500; letter-spacing: var(--track-wide); text-transform: uppercase; line-height: 1.6; }
.login-notice { margin: 0; color: var(--ink-3); font-size: var(--fs-micro); }
.login-tagline:empty, .login-notice:empty { display: none; }

/* ---------- the molecule: tinted tiles with a glass sheen, one solid, bonds in the gaps ---------- */
.mol-hex {
  fill: color-mix(in srgb, var(--tone) var(--hex-tint), var(--surface));
  stroke: color-mix(in srgb, var(--tone) var(--hex-edge), var(--surface)); stroke-width: 2;
}
.mol-hex.is-solid { fill: var(--tone); stroke: none; }
/* on a dark page the edge tiles are glass: a breath of their tone and a clear outline */
:root[data-theme="dark"] .mol-hex:not(.is-solid) { fill: color-mix(in srgb, var(--tone) 14%, var(--bg)); stroke: color-mix(in srgb, var(--tone) 60%, var(--bg)); stroke-width: 1.5; }
.mol-sheen { opacity: .9; }
:root[data-theme="dark"] .mol-sheen { opacity: .35; }
.mol-bonds line { stroke: var(--bond); stroke-width: 2; stroke-linecap: round; }
.mol-bonds circle { fill: var(--surface); stroke: var(--bond); stroke-width: 2; }
:root[data-theme="dark"] .mol-bonds circle { fill: var(--bg); }

/* It assembles once on load, nearest tile first, then the bonds appear. */
.mol-cell { transform-box: fill-box; transform-origin: center; animation: mol-in var(--t-grow) var(--ease-out) both; }
.mol-d0 { animation-delay: 80ms; }  .mol-d1 { animation-delay: 150ms; } .mol-d2 { animation-delay: 220ms; }
.mol-d3 { animation-delay: 290ms; } .mol-d4 { animation-delay: 360ms; } .mol-d5 { animation-delay: 430ms; }
.mol-d6 { animation-delay: 500ms; } .mol-d7 { animation-delay: 570ms; } .mol-d8 { animation-delay: 640ms; }
.mol-d9 { animation-delay: 710ms; } .mol-d10 { animation-delay: 780ms; }
.mol-bonds { animation: mol-bonds var(--t-state) ease-out 900ms both; }
@keyframes mol-in { from { opacity: 0; transform: scale(.6); } }
@keyframes mol-bonds { from { opacity: 0; } }

/* large portrait screens (totems): everything scaled up for reading at a distance */
@media (orientation: portrait) and (min-width: 1000px) and (min-height: 1500px) {
  .login-body { zoom: 1.45; }
  .login-foot { zoom: 1.25; }
}
/* short landscape screens (phones on their side): a smaller mark */
@media (max-height: 560px) and (orientation: landscape) {
  .login-molecule { width: 120px; }
  .login-mark { margin-bottom: 14px; }
  .login-logo { margin-bottom: 16px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .mol-cell, .mol-bonds { animation: none; }
  .login-input, .login-field label, .login-submit, .login-reveal { transition: none; }
}
