/* Stella sign-in: one-door dialog (Google, Discord, email code), error dialog, header
   account corner while signed out, and the signed-out My Media panel.
   Colours come from the hs4 tokens, so light and dark follow the site theme.
   Frames (dialogs, panels) are square; controls are pills. */

.ssi-dialog {
  box-sizing: border-box;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 0;
  background: var(--hs4-surface);
  color: var(--hs4-text);
  box-shadow: var(--hs4-card-shadow-hot);
  overflow: auto;
  font-family: var(--hs4-font-inter);
}

.ssi-dialog::backdrop {
  background: rgba(20, 20, 20, 0.45);
}

html[data-theme="dark"] .ssi-dialog {
  outline: 1px solid color-mix(in srgb, var(--hs4-text) 14%, transparent);
}

html[data-theme="dark"] .ssi-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.ssi-alert {
  width: min(420px, calc(100vw - 32px));
}

.ssi-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 32px 30px;
}

.ssi-card-sm {
  gap: 12px;
  padding: 26px 26px 22px;
}

.ssi-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ssi-head .ssi-title {
  flex: 1 1 auto;
  min-width: 0;
}

.ssi-head-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ssi-title {
  margin: 0;
  font: 400 40px / 44px var(--hs4-font-serif);
  outline: none;
}

.ssi-title-sm {
  font-size: 28px;
  line-height: 32px;
}

.ssi-sub,
.ssi-body {
  margin: 0;
  color: var(--hs4-muted-text);
  font-size: 15px;
  line-height: 22px;
}

.ssi-body {
  color: var(--hs4-text);
}

.ssi-body strong {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.ssi-icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 -14px 0 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--hs4-text);
  cursor: pointer;
}

.ssi-back {
  margin: 0 0 0 -14px;
}

.ssi-icon-btn:hover {
  background: color-mix(in srgb, var(--hs4-text) 8%, transparent);
}

/* Buttons */
.ssi-providers,
.ssi-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ssi-row {
  display: flex;
  gap: 10px;
}

.ssi-row > .ssi-btn {
  flex: 1 1 0;
}

.ssi-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--hs4-field-edge);
  border-radius: 999px;
  background: var(--hs4-surface);
  color: var(--hs4-text);
  font: 500 15px / 1 var(--hs4-font-inter);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, opacity 0.15s;
}

.ssi-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--hs4-text) 6%, var(--hs4-surface));
}

/* "Last used": a small tag at the end of the method used last on this device */
.ssi-btn {
  position: relative;
}

.ssi-last {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--hs4-selected-soft);
  color: var(--hs4-on-selected-soft);
  font: 600 11px / 1 var(--hs4-font-inter);
  white-space: nowrap;
}

/* On the top edge of the button or field, outside the label, so the words
   stay centred like the other buttons */
.ssi-btn .ssi-last,
.ssi-field-tagged .ssi-last {
  position: absolute;
  top: -9px;
  right: 18px;
  padding: 2px 8px;
  line-height: 14px;
  box-shadow: 0 0 0 3px var(--hs4-surface);
  pointer-events: none;
}

.ssi-field-tagged {
  position: relative;
}

/* The code from the email: one real input over six boxes, so autofill,
   paste and the phone's code suggestion all work */
.ssi-otp {
  position: relative;
}

.ssi-otp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  opacity: 0;
  cursor: text;
}

.ssi-otp-boxes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  pointer-events: none;
}

.ssi-otp-boxes span {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  border: 1px solid var(--hs4-field-edge);
  border-radius: 12px;
  background: var(--hs4-bg);
  font: 500 22px / 1 var(--hs4-font-inter);
  font-variant-numeric: tabular-nums;
}

.ssi-otp:focus-within .ssi-otp-boxes span.is-cur {
  border-color: var(--hs4-focus);
  box-shadow: 0 0 0 1px var(--hs4-focus);
}

.ssi-otp-input.is-invalid + .ssi-otp-boxes span {
  border-color: var(--hs4-pink-text);
}

.ssi-otp.is-busy .ssi-otp-boxes {
  opacity: 0.55;
}

/* Same rows on every step: the slot holds the two provider buttons or two
   lines of text, the spacer stands in for the "or" line */
.ssi-slot {
  min-height: 106px;
}

.ssi-slot-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ssi-slot-text .ssi-body {
  overflow-wrap: anywhere;
}

.ssi-spacer {
  height: 18px;
}

.ssi-small {
  font-size: 13px;
  line-height: 19px;
}

.ssi-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.ssi-btn-quiet {
  border-color: color-mix(in srgb, var(--hs4-text) 18%, transparent);
  color: var(--hs4-muted-text);
}

.ssi-btn-primary {
  border-color: var(--hs4-action-ring);
  background: var(--hs4-action);
  color: var(--hs4-on-action);
}

html:not([data-theme="dark"]) .ssi-btn-primary {
  border-color: var(--hs4-action);
}

.ssi-btn-primary:hover:not(:disabled) {
  background: var(--hs4-action-hover);
}

.ssi-btn-primary:active:not(:disabled) {
  background: var(--hs4-action-press);
}

.ssi-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.ssi-btn.is-busy:disabled,
.ssi-btn[data-ssi="resend"]:disabled {
  opacity: 1;
  cursor: progress;
}

.ssi-btn[data-ssi="resend"]:disabled {
  color: var(--hs4-muted-text);
  cursor: default;
}

.ssi-lead {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.ssi-logo {
  display: block;
}

.ssi-spin {
  box-sizing: border-box;
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ssi-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .ssi-spin {
    animation-duration: 2.4s;
  }
}

.ssi-divider {
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--hs4-muted-text);
  font-size: 13px;
}

.ssi-divider::before,
.ssi-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--hs4-text) 16%, transparent);
}

/* Email form */
.ssi-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ssi-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.ssi-label-text {
  display: block;
  margin: 0 0 6px 4px;
  font: 500 13px / 18px var(--hs4-font-inter);
}

.ssi-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--hs4-field-edge);
  border-radius: 999px;
  background: var(--hs4-bg);
  color: var(--hs4-text);
  font: 400 16px var(--hs4-font-inter);
}

.ssi-input::placeholder {
  color: var(--hs4-muted-text);
  opacity: 0.85;
}

.ssi-input:focus {
  outline: none;
  border-color: var(--hs4-focus);
  box-shadow: 0 0 0 1px var(--hs4-focus);
}

.ssi-input.is-invalid {
  border-color: var(--hs4-pink-text);
  box-shadow: 0 0 0 1px var(--hs4-pink-text);
}

.ssi-err,
.ssi-notice {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 6px 0 0 4px;
  color: var(--hs4-pink-text);
  font-size: 13px;
  line-height: 18px;
}

.ssi-err svg,
.ssi-notice svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.ssi-err[hidden],
.ssi-notice[hidden] {
  display: none;
}

.ssi-notice {
  margin: 0;
  padding: 12px 14px;
  background: var(--hs4-pink-tint);
  font-size: 14px;
  line-height: 20px;
}

.ssi-hint {
  margin: 6px 0 0 4px;
  color: var(--hs4-muted-text);
  font-size: 13px;
  line-height: 18px;
}

.ssi-link {
  padding: 4px;
  margin: -4px;
  border: 0;
  background: none;
  color: var(--hs4-blue-text);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.ssi-link:hover:not(:disabled) {
  text-decoration-thickness: 2px;
}

.ssi-link:disabled {
  opacity: 0.5;
  cursor: default;
}

.ssi-link-center {
  align-self: center;
  margin: 2px 0 0;
  padding: 10px 4px;
  font-size: 14px;
}

.ssi-foot {
  margin: 0;
  color: var(--hs4-muted-text);
  font-size: 13px;
  line-height: 18px;
  text-align: center;
}

.ssi-badge,
.ssi-alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--hs4-blue-tint);
  color: var(--hs4-blue-text);
}

.ssi-alert-icon {
  width: 40px;
  height: 40px;
  margin: 0;
  background: var(--hs4-pink-tint);
  color: var(--hs4-pink-text);
}

.ssi-details summary {
  color: var(--hs4-muted-text);
  font-size: 13px;
  line-height: 18px;
  cursor: pointer;
}

.ssi-details p {
  margin: 6px 0 0;
  color: var(--hs4-muted-text);
  font: 400 12px / 18px ui-monospace, Menlo, monospace;
}

.ssi-card-sm .ssi-row {
  margin-top: 8px;
}

.ssi-btn:focus-visible,
.ssi-link:focus-visible,
.ssi-icon-btn:focus-visible,
.ssi-header-signin:focus-visible {
  outline: 2px solid var(--hs4-focus);
  outline-offset: 2px;
}

/* Header account corner while signed out */
.ssi-header-signin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--hs4-action-ring);
  border-radius: 999px;
  background: var(--hs4-action);
  color: var(--hs4-on-action);
  font: 600 14px / 1 var(--hs4-font-inter);
  white-space: nowrap;
  cursor: pointer;
}

html:not([data-theme="dark"]) .ssi-header-signin {
  border-color: var(--hs4-action);
}

.ssi-header-signin:hover:not(:disabled) {
  background: var(--hs4-action-hover);
}

.ssi-header-signin:disabled {
  opacity: 0.45;
  cursor: default;
}

.ssi-header-busy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid color-mix(in srgb, var(--hs4-text) 20%, transparent);
  border-radius: 999px;
  color: var(--hs4-muted-text);
  font: 500 14px / 1 var(--hs4-font-inter);
  white-space: nowrap;
}

.ssi-header-busy .ssi-spin {
  width: 14px;
  height: 14px;
}

/* My Media while signed out */
.ssi-panel {
  box-sizing: border-box;
  max-width: 560px;
  margin: 48px auto;
  padding: 36px 32px;
  border: 1px solid color-mix(in srgb, var(--hs4-text) 12%, transparent);
  background: var(--hs4-surface);
}

.ssi-panel-title {
  margin: 0 0 10px;
  font: 400 40px / 44px var(--hs4-font-serif);
}

.ssi-panel-text {
  margin: 0;
  color: var(--hs4-muted-text);
  font-size: 15px;
  line-height: 22px;
}

/* A sign-in-only page while the session is checked: just the spinner */
.ssi-page-busy {
  display: flex;
  justify-content: center;
  padding: 96px 16px;
  color: var(--hs4-muted-text);
}

.ssi-page-busy .ssi-spin {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.ssi-panel-actions {
  margin-top: 24px;
}

/* Grab bar: phones only, drag it down to close the sheet */
.ssi-grab {
  display: none;
}

/* Phone: the dialog becomes a bottom sheet */
@media (max-width: 560px) {
  .ssi-dialog:not(.ssi-alert) {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    transition: transform 0.2s ease;
  }

  .ssi-dialog.is-dragging {
    transition: none;
  }

  .ssi-grab {
    display: flex;
    justify-content: center;
    padding: 10px 0 2px;
    touch-action: none;
    cursor: grab;
  }

  .ssi-grab::before {
    content: "";
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--hs4-text) 24%, transparent);
  }

  .ssi-card {
    padding: 6px 20px calc(24px + env(safe-area-inset-bottom));
    gap: 12px;
  }

  .ssi-title {
    font-size: 30px;
    line-height: 36px;
  }

  .ssi-panel {
    margin: 24px 16px;
    padding: 28px 20px;
  }

  .ssi-panel-actions {
    flex-direction: column;
  }

  .ssi-header-signin,
  .ssi-header-busy {
    min-height: 36px;
    padding: 0 14px;
  }

  .ssi-header-busy span:not(.ssi-spin) {
    max-width: 0;
    overflow: hidden;
  }
}
