/* The account pages and the parts the hub shares with them: the top bar, the form fields, the notices and the motion. A single
   column of content, kept plain. Plain CSS. Both looks use the tokens of styles.css, and the look is chosen on this device.
   Every Playful rule sits under :root[data-look='playful']. */

:root {
  --bad: #c4372e;
  --bad-50: #fdf0ef;
  --bad-line: #f1b9b5;
  --good: #137a58;
  --good-50: #e9f8f1;
  --good-line: #b7e5d1;
  --auth-a: #2a1c8c;
  --auth-b: #5337d2;
  --auth-c: #8a6dff;
}

:root[data-look='playful'] {
  --bad: #d4313a;
  --bad-50: #fdecec;
  --bad-line: #f5b3b7;
  --good: #12803c;
  --good-50: #e8f8ee;
  --good-line: #a9e3bf;
  --auth-a: #3d24b5;
  --auth-b: #6a4bef;
  --auth-c: #9b86ff;
}

/* The hidden attribute must win over the display of a class, or a hidden button would still show. */
[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  background: var(--canvas);
}

/* ---------- The top bar: the brand and the language switch ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
}

.top__inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.top__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- Buttons: the landing page's buttons, with a spinner while a request runs ---------- */
.btn {
  position: relative;
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
}

.btn--ghost.is-loading::after {
  border-color: var(--line-2);
  border-top-color: var(--primary);
}

.btn--block {
  width: 100%;
}

.btn--danger {
  color: var(--bad);
  border-color: var(--bad-line);
}

.btn--danger:hover {
  background: var(--bad-50);
  border-color: var(--bad);
}

/* ---------- The page: one card, centred ---------- */
.auth {
  display: grid;
  justify-items: center;
  padding: clamp(32px, 7vh, 72px) var(--gutter) 72px;
}

.auth-card {
  width: min(400px, 100%);
}

.auth-card__inner {
  display: grid;
  gap: 20px;
}

.auth-card__inner > * {
  animation: rise 0.5s var(--ease) both;
}

.auth-title {
  font-family: var(--display);
  font-weight: var(--heading-weight);
  font-size: clamp(1.8rem, 3.4vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: var(--heading-tracking);
  text-wrap: balance;
}

.auth-lead {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

.auth-links,
.auth-foot {
  font-size: 15px;
  color: var(--ink-2);
}

.auth-links a,
.auth-foot a {
  color: var(--primary);
  font-weight: 650;
  text-decoration: none;
}

.auth-links a:hover,
.auth-foot a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.auth-action {
  width: 100%;
}

/* A panel of a page: one of several states (checking, form, done, invalid) that shows at a time */
.panel {
  display: grid;
  gap: 18px;
}

.panel:focus {
  outline: none;
}

.panel-title {
  font-family: var(--display);
  font-weight: var(--heading-weight);
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: var(--heading-tracking);
}

.panel-lead {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

.panel-actions {
  display: grid;
  gap: 12px;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--primary-50);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

/* ---------- The form: the fields, the error under a field, and the shake when a form cannot be sent ---------- */
.form {
  display: grid;
  gap: 18px;
}

.form.is-shaking {
  animation: shake 0.45s var(--ease);
}

.field {
  display: grid;
  gap: 8px;
}

.field__label {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}

.field__hint {
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.field__error {
  font-size: 14px;
  font-weight: 550;
  color: var(--bad);
}

.field__error:empty {
  display: none;
}

.field__error:not(:empty) {
  animation: rise 0.25s var(--ease) both;
}

.field__wrap {
  position: relative;
}

.field__input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1.5px solid var(--line-2);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background-color 0.2s var(--ease);
}

.field__input::placeholder {
  color: #9aa2b6;
}

.field__input:hover {
  border-color: var(--primary-line);
}

.field__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}

.field__input--secret {
  padding-right: 52px;
}

.field.is-invalid .field__input {
  border-color: var(--bad);
  background: var(--bad-50);
}

.field__toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-top: -19px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.field__toggle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.field__toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field__toggle .icon-off {
  display: none;
}

.field__toggle[aria-pressed='true'] .icon-on {
  display: none;
}

.field__toggle[aria-pressed='true'] .icon-off {
  display: block;
}

/* ---------- Password strength: four bars, and the rules the password must meet ---------- */
.meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.meter__bar {
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  transition: background-color 0.3s var(--ease);
}

.meter[data-level='1'] .meter__bar.is-on {
  background: var(--bad);
}

.meter[data-level='2'] .meter__bar.is-on {
  background: #d98a00;
}

.meter[data-level='3'] .meter__bar.is-on {
  background: #3d9a6f;
}

.meter[data-level='4'] .meter__bar.is-on {
  background: var(--good);
}

.meter-label {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  min-height: 1.4em;
}

.reqs {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.reqs li {
  display: flex;
  align-items: center;
  gap: 10px;
  transition: color 0.2s var(--ease);
}

.reqs li::before {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.reqs li.is-met {
  color: var(--good);
}

.reqs li.is-met::before {
  background: var(--good);
  border-color: var(--good);
  box-shadow: inset 0 0 0 4px #ffffff;
}

/* ---------- Notices: one message for the page, with a tone ---------- */
.notice {
  margin: 0;
  padding: 13px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.5;
}

.notice:not([hidden]) {
  animation: rise 0.35s var(--ease) both;
}

.notice[data-tone='error'] {
  background: var(--bad-50);
  border-color: var(--bad-line);
  color: #8a1f19;
}

.notice[data-tone='success'] {
  background: var(--good-50);
  border-color: var(--good-line);
  color: #0d5c42;
}

.notice[data-tone='info'] {
  background: var(--primary-50);
  border-color: var(--primary-line);
  color: var(--ink);
}

/* ---------- The check mark of a finished step, drawn as it appears ---------- */
.check {
  width: 72px;
  height: 72px;
  overflow: visible;
}

.check__ring {
  stroke: var(--good);
  stroke-width: 3;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: draw 0.8s var(--ease) forwards;
}

.check__tick {
  stroke: var(--good);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 36;
  stroke-dashoffset: 36;
  animation: draw 0.45s var(--ease) 0.55s forwards;
}

/* ---------- Motion ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
