/*
 * Account pages (login, register, password reset, payment, ...).
 * Mirrors the look of the /secure/ app: HeaderToolbar.vue header bar,
 * InputButton.vue radius/borders and the Bootstrap-derived palette.
 */

:root {
  --ss-font: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --ss-text: #404040;
  --ss-text-strong: #333;
  --ss-muted: #707070;
  --ss-wordmark: #777;

  --ss-primary: #428bca;
  --ss-primary-strong: #3276b1;
  --ss-primary-stronger: #285e8e;
  --ss-primary-tint: #eef4fa;

  --ss-bg: #f8f8f8;
  --ss-surface: #fff;
  --ss-border: #ccc;
  --ss-border-subtle: #e5e5e5;
  --ss-hover: #f5f5f5;
  --ss-header-bg: #f8f8f8;
  --ss-header-border: #e7e7e7;
  --ss-header-h: 3.3rem;

  --ss-danger: #a94442;
  --ss-danger-bg: #f2dede;
  --ss-danger-border: #ebccd1;
  --ss-danger-solid: #c9302c;
  --ss-success: #3c763d;
  --ss-success-bg: #dff0d8;
  --ss-success-border: #d6e9c6;
  --ss-info: #31708f;
  --ss-info-bg: #d9edf7;
  --ss-info-border: #bce8f1;
  --ss-warning: #8a6d3b;
  --ss-warning-bg: #fcf8e3;
  --ss-warning-border: #faebcc;

  --ss-radius-sm: 0.3rem;
  --ss-radius: 0.6rem;
  --ss-radius-card: 0.5rem;
  --ss-shadow: 0 0.5rem 0.5rem rgba(0, 0, 0, 0.1);
  --ss-focus: 0 0 0 3px rgba(66, 139, 202, 0.35);
  --ss-tap: 2.75rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.auth {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--ss-bg);
  color: var(--ss-text);
  font-family: var(--ss-font);
  font-size: 1rem;
  line-height: 1.5;
}

a {
  color: var(--ss-primary-strong);
}

a:hover {
  color: var(--ss-primary-stronger);
}

:focus-visible {
  outline: none;
  box-shadow: var(--ss-focus);
}

.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;
}

/* Header: same bar as the app's HeaderToolbar. */
.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--ss-header-h);
  padding: 0.1rem max(0.75rem, env(safe-area-inset-right)) 0.1rem
    max(0.75rem, env(safe-area-inset-left));
  padding-top: max(0.1rem, env(safe-area-inset-top));
  background: var(--ss-header-bg);
  border-bottom: 1px solid var(--ss-header-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  min-height: var(--ss-tap);
}

.brand img {
  height: 2.2rem;
  width: auto;
}

.brand span {
  color: var(--ss-wordmark);
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1;
}

.lang {
  position: relative;
  display: flex;
  align-items: center;
}

.lang select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 2.25rem;
  max-width: 11rem;
  padding: 0.25rem 1.9rem 0.25rem 2rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ss-text);
  background: var(--ss-surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath fill='%23707070' d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/%3E%3C/svg%3E")
    no-repeat right 0.4rem center / 1.1rem;
  border: 1px solid var(--ss-border);
  border-radius: var(--ss-radius);
  cursor: pointer;
}

.lang::before {
  content: '';
  position: absolute;
  left: 0.55rem;
  width: 1.05rem;
  height: 1.05rem;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath fill='%23707070' d='M480-80q-82 0-155-31.5t-127.5-86Q143-252 111.5-325T80-480q0-83 31.5-155.5t86-127Q252-817 325-848.5T480-880q83 0 155.5 31.5t127 86q54.5 54.5 86 127T880-480q0 82-31.5 155t-86 127.5q-54.5 54.5-127 86T480-80Zm0-82q26-36 45-75t31-83H404q12 44 31 83t45 75Zm-104-16q-18-33-31.5-68.5T322-320H204q29 50 72.5 87t99.5 55Zm208 0q56-18 99.5-55t72.5-87H638q-9 38-22.5 73.5T584-178ZM170-400h136q-3-20-4.5-39.5T300-480q0-21 1.5-40.5T306-560H170q-5 20-7.5 39.5T160-480q0 21 2.5 40.5T170-400Zm216 0h188q3-20 4.5-39.5T580-480q0-21-1.5-40.5T574-560H386q-3 20-4.5 39.5T380-480q0 21 1.5 40.5T386-400Zm268 0h136q5-20 7.5-39.5T800-480q0-21-2.5-40.5T790-560H654q3 20 4.5 39.5T660-480q0 21-1.5 40.5T654-400Zm-16-240h118q-29-50-72.5-87T584-782q18 33 31.5 68.5T638-640Zm-234 0h152q-12-44-31-83t-45-75q-26 36-45 75t-31 83Zm-200 0h118q9-38 22.5-73.5T376-782q-56 18-99.5 55T204-640Z'/%3E%3C/svg%3E")
    no-repeat center / contain;
}

/* Main column + card. */
.auth-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.5rem max(1rem, env(safe-area-inset-right)) 1.5rem
    max(1rem, env(safe-area-inset-left));
}

.auth-main.wide {
  max-width: 46rem;
}

/* Back control styled like the app's InputButton. */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  margin: 0 0 1rem;
  padding: 0.35rem 0.85rem 0.35rem 0.55rem;
  color: var(--ss-text);
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: var(--ss-radius);
  font-size: 0.95rem;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.back-link svg {
  flex: none;
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
}

.back-link:hover,
.back-link:active {
  color: var(--ss-text);
  background: var(--ss-hover);
}

/* Help page: resources and contact form side by side on wide screens. */
.auth-main.help {
  max-width: 64rem;
}

@media (min-width: 50rem) {
  .help-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    align-items: start;
    gap: 1.5rem;
  }

  .help-grid .card + .card {
    margin-top: 0;
  }
}

.card {
  background: var(--ss-surface);
  border: 1px solid var(--ss-border-subtle);
  border-radius: var(--ss-radius-card);
  box-shadow: var(--ss-shadow);
  padding: 1.5rem;
}

.card + .card,
.below-card {
  margin-top: 1rem;
}

.card h1 {
  margin: 0 0 0.35rem;
  color: var(--ss-text-strong);
  font-size: 1.5rem;
  font-weight: bold;
  line-height: 1.25;
}

.card h2 {
  margin: 0 0 0.35rem;
  color: var(--ss-text-strong);
  font-size: 1.25rem;
  font-weight: bold;
  line-height: 1.25;
}

.card .lead {
  margin: 0 0 1.25rem;
  color: var(--ss-muted);
}

.card > :last-child {
  margin-bottom: 0;
}

.below-card {
  text-align: center;
  color: var(--ss-muted);
}

.below-card p {
  margin: 0.5rem 0;
}

/* Below 28rem the card fills the screen like a native page. */
@media (max-width: 28rem) {
  body.auth {
    background: var(--ss-surface);
  }

  .auth-main {
    padding-top: 1rem;
  }

  .card {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0.5rem 0 0;
  }

  .card + .card {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ss-border-subtle);
  }

  .brand span {
    font-size: 1.2rem;
  }
}

@media (min-width: 50rem) {
  .auth-main {
    padding-top: 3rem;
  }

  .brand span {
    font-size: 1.7rem;
  }
}

/* Alerts (class names are relied upon by handler tests). */
.alert {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--ss-radius-sm);
  font-size: 0.95rem;
}

.alert a {
  color: inherit;
  font-weight: bold;
}

.alert-danger {
  color: var(--ss-danger);
  background: var(--ss-danger-bg);
  border-color: var(--ss-danger-border);
}

.alert-success {
  color: var(--ss-success);
  background: var(--ss-success-bg);
  border-color: var(--ss-success-border);
}

.alert-info {
  color: var(--ss-info);
  background: var(--ss-info-bg);
  border-color: var(--ss-info-border);
}

.alert-warning {
  color: var(--ss-warning);
  background: var(--ss-warning-bg);
  border-color: var(--ss-warning-border);
}

/* Forms. */
.field {
  margin: 0 0 1rem;
}

.field > label,
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.3rem;
  color: var(--ss-text);
  font-size: 0.92rem;
  font-weight: normal;
}

/* Label on the left, aside link on the right, control below: the aside comes
   after the control in the DOM so keyboard focus moves field to field. */
.field.has-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.5rem;
}

.field.has-aside > .field-label {
  grid-row: 1;
  grid-column: 1;
}

.field.has-aside > .field-aside {
  grid-row: 1;
  grid-column: 2;
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
}

.field.has-aside > :not(.field-label):not(.field-aside) {
  grid-column: 1 / -1;
}

.input,
.field input[type='text'],
.field input[type='email'],
.field input[type='password'],
.field textarea {
  display: block;
  width: 100%;
  min-height: var(--ss-tap);
  padding: 0.55rem 0.75rem;
  /* 16px or larger stops iOS Safari zooming on focus. */
  font: inherit;
  font-size: 1rem;
  color: var(--ss-text);
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: var(--ss-radius);
  appearance: none;
  -webkit-appearance: none;
}

.field textarea {
  min-height: 9rem;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ss-primary);
  box-shadow: var(--ss-focus);
}

.field [aria-invalid='true'] {
  border-color: var(--ss-danger);
}

.field-error {
  margin: 0.3rem 0 0;
  color: var(--ss-danger);
  font-size: 0.9rem;
}

.field-hint {
  margin: 0.3rem 0 0;
  color: var(--ss-muted);
  font-size: 0.85rem;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 4.5rem;
}

.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  min-width: var(--ss-tap);
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--ss-primary-strong);
  background: none;
  border: 0;
  border-radius: 0 var(--ss-radius) var(--ss-radius) 0;
  cursor: pointer;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0 0 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.1rem 0 0;
  accent-color: var(--ss-primary-strong);
}

details.reveal {
  margin: 0 0 1rem;
}

details.reveal > summary {
  display: inline-flex;
  align-items: center;
  min-height: var(--ss-tap);
  color: var(--ss-primary-strong);
  cursor: pointer;
  list-style: none;
}

details.reveal > summary::-webkit-details-marker {
  display: none;
}

details.reveal > summary::after {
  content: '+';
  margin-left: 0.4rem;
}

details.reveal[open] > summary::after {
  content: '\2212';
}

.captcha {
  margin: 0 0 1rem;
  min-height: 65px;
}

/* Buttons. */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: var(--ss-tap);
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: normal;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  color: var(--ss-text);
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: var(--ss-radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  color: #fff;
  background: var(--ss-primary-strong);
  border-color: var(--ss-primary-strong);
}

.btn-danger {
  color: #fff;
  background: var(--ss-danger-solid);
  border-color: var(--ss-danger-solid);
}

.btn-link {
  width: auto;
  display: inline-flex;
  padding: 0.5rem;
  color: var(--ss-primary-strong);
  background: none;
  border-color: transparent;
  font-weight: normal;
}

.btn + .btn {
  margin-top: 0.6rem;
}

@media (hover: hover) {
  .btn:hover {
    background: var(--ss-hover);
  }

  .btn-primary:hover {
    color: #fff;
    background: var(--ss-primary-stronger);
    border-color: var(--ss-primary-stronger);
  }

  .btn-danger:hover {
    background: #ac2925;
  }

  .btn-link:hover {
    background: none;
    text-decoration: underline;
  }
}

.btn[aria-busy='true'],
.btn:disabled {
  opacity: 0.65;
  cursor: progress;
}

.btn[aria-busy='true']::before {
  content: '';
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ss-spin 0.7s linear infinite;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin: 1rem 0 0;
  font-size: 0.95rem;
}

.links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--ss-tap);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--ss-muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--ss-border-subtle);
}

/* Rows of links (help resources), styled like the app's account rows. */
.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border: 1px solid var(--ss-border-subtle);
  border-radius: var(--ss-radius);
}

.link-list li + li {
  border-top: 1px solid var(--ss-border-subtle);
}

.link-list a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  min-height: 3rem;
  padding: 0.6rem 2.75rem 0.6rem 1rem;
  color: var(--ss-text);
  line-height: 1.3;
  text-decoration: none;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath fill='%23999' d='M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z'/%3E%3C/svg%3E")
    no-repeat right 0.9rem center / 1.1rem;
  -webkit-tap-highlight-color: transparent;
}

.link-list a:hover,
.link-list a:active {
  color: var(--ss-text);
  background-color: var(--ss-hover);
}

.link-list a:focus-visible {
  box-shadow: inset var(--ss-focus);
}

.link-hint {
  color: var(--ss-muted);
  font-size: 0.85rem;
}

/* Icon badge used on confirmation pages. */
.badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 0 1rem;
  border-radius: 50%;
  background: var(--ss-primary-tint);
}

.badge-icon svg {
  width: 1.9rem;
  height: 1.9rem;
  fill: var(--ss-primary-strong);
}

.sent-to {
  word-break: break-all;
  color: var(--ss-text-strong);
  font-weight: bold;
}

.muted {
  color: var(--ss-muted);
  font-size: 0.9rem;
}

/* Payment plans. */
.plans {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
}

@media (min-width: 40rem) {
  .plans {
    grid-template-columns: 1fr 1fr;
  }
}

.plan {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.1rem;
  border: 1px solid var(--ss-border);
  border-radius: var(--ss-radius);
  background: var(--ss-surface);
}

.plan.featured {
  border: 2px solid var(--ss-primary);
  padding: calc(1.1rem - 1px);
}

.plan-badge {
  position: absolute;
  top: -0.7rem;
  right: 0.9rem;
  padding: 0.1rem 0.55rem;
  border-radius: 1rem;
  background: var(--ss-primary-strong);
  color: #fff;
  font-size: 0.75rem;
  font-weight: normal;
}

.plan h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: bold;
  color: var(--ss-text-strong);
}

.plan-price {
  margin: 0;
  color: var(--ss-text-strong);
  font-size: 1.75rem;
  font-weight: bold;
  line-height: 1.2;
}

.plan-price small {
  color: var(--ss-muted);
  font-size: 0.95rem;
  font-weight: normal;
}

.plan-note {
  margin: 0 0 0.75rem;
  min-height: 1.4em;
  color: var(--ss-muted);
  font-size: 0.9rem;
}

.plan .btn {
  margin-top: auto;
}

/* "Both plans include" panel, card-styled like the account status card. */
.features-panel {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--ss-border-subtle);
  border-radius: var(--ss-radius);
  background: #fafbfc;
}

.card .features-title {
  margin: 0 0 0.75rem;
  color: #999;
  font-size: 0.9rem;
  font-weight: normal;
}

.features {
  display: grid;
  gap: 0.6rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

@media (min-width: 36rem) {
  .features {
    grid-template-columns: 1fr 1fr;
  }
}

.features li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  line-height: 1.35;
}

.features li::before {
  content: '';
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--ss-primary-tint)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath fill='%233276b1' d='M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z'/%3E%3C/svg%3E")
    no-repeat center / 0.85rem;
}

.features-note {
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--ss-border-subtle);
  color: var(--ss-muted);
  font-size: 0.85rem;
}

.status-pill {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: normal;
  background: var(--ss-warning-bg);
  color: var(--ss-warning);
}

.status-pill.expired {
  background: var(--ss-danger-bg);
  color: var(--ss-danger);
}

.signed-in {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--ss-border-subtle);
  color: var(--ss-muted);
  font-size: 0.9rem;
  text-align: center;
  word-break: break-word;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0.5rem 0 1.25rem;
  border: 3px solid var(--ss-primary-tint);
  border-top-color: var(--ss-primary-strong);
  border-radius: 50%;
  animation: ss-spin 0.8s linear infinite;
}

/* Footer. */
.auth-footer {
  flex: none;
  padding: 1rem max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  text-align: center;
  font-size: 0.85rem;
}

.auth-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 0.25rem;
}

.auth-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0 0.5rem;
  color: var(--ss-muted);
  text-decoration: none;
}

.auth-footer a:hover {
  color: var(--ss-text);
  text-decoration: underline;
}

/* Very narrow phones: keep Turnstile (300px) from overflowing. */
@media (max-width: 22rem) {
  .auth-main {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy='true']::before,
  .spinner {
    animation-duration: 2s;
  }
}
