/* <tenant-domains>: the shared domain setup screens.
 *
 * Every rule is scoped to the element, so a module's own stylesheet is never
 * touched by it. The scope is :where(), which adds no specificity: these rules
 * then lose and win against /swiss.css exactly as they did when they were the
 * vCard module's own. Colours and type come from /swiss.css, which every module
 * loads; the fallbacks keep the screen legible without it.
 */

tenant-domains { display: block; }
tenant-domains[hidden] { display: none; }

/* Layout shared with the host page's own screens. */

:where(tenant-domains) .title--compact {
  font-size: var(--step-3);
  letter-spacing: -0.026em;
}

:where(tenant-domains) .section__head {
  max-width: var(--measure);
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

:where(tenant-domains) .section__head > :last-child {
  margin-bottom: 0;
}

:where(tenant-domains) .dashboard__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
}

:where(tenant-domains) .dashboard__header .section__head {
  margin-bottom: 0;
}

:where(tenant-domains) .loading-state {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-faint);
  padding: 2rem 0;
}

:where(tenant-domains) .empty-state {
  border-top: 1px solid var(--rule);
  padding-top: clamp(2rem, 5vw, 3rem);
  max-width: var(--measure);
}

:where(tenant-domains) .empty-state h3 {
  margin-bottom: 0.5rem;
}

:where(tenant-domains) .empty-state p {
  color: var(--ink-muted);
  margin-bottom: 1.75rem;
}

:where(tenant-domains) .editor-header__titles .title--compact {
  margin: 0;
  font-size: var(--step-2);
}

:where(tenant-domains) .form-input, :where(tenant-domains) .form-textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  line-height: 1.5;
  transition: border-color 0.12s linear;
}

:where(tenant-domains) .form-input::placeholder, :where(tenant-domains) .form-textarea::placeholder {
  color: var(--ink-faint);
  opacity: 0.75;
}

:where(tenant-domains) .form-input:focus, :where(tenant-domains) .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

:where(tenant-domains) .slug-input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--rule);
}

:where(tenant-domains) .slug-input-group:focus-within {
  border-color: var(--accent);
}

:where(tenant-domains) .slug-prefix {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.6rem 0.6rem 0.7rem;
  border-right: 1px solid var(--rule);
  background-color: var(--tint);
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  white-space: nowrap;
}

:where(tenant-domains) .slug-input-group .form-input {
  border: 0;
  background: transparent;
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
}

:where(tenant-domains) .slug-input-group .form-input:focus {
  box-shadow: none;
}

@media (max-width: 48rem) {
  :where(tenant-domains) .dashboard__header {
    flex-direction: column;
    align-items: stretch;
  }
  :where(tenant-domains) .dashboard__header .btn {
    width: 100%;
  }
}

@media (max-width: 40rem) {
  :where(tenant-domains) .form-input, :where(tenant-domains) .form-textarea {
    font-size: 1rem;
    min-height: 2.875rem;
  }
  :where(tenant-domains) .slug-input-group {
    flex-direction: column;
  }
  :where(tenant-domains) .slug-prefix {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
}

/* The domain list and setup steps. */

:where(tenant-domains) .domains__subhead {
  margin: 2rem 0 0.5rem;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint, #64757c);
}

:where(tenant-domains) .domain-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rule, #cdd8dc);
  border-radius: 6px;
  margin-bottom: 0.6rem;
}

:where(tenant-domains) .domain-card__main { flex: 1 1 14rem; min-width: 0; }

:where(tenant-domains) .domain-card__name { font-weight: 600; }

:where(tenant-domains) .domain-card__host { font-size: 0.875rem; margin-top: 0.15rem; }

:where(tenant-domains) .domain-card__detail { font-size: 0.8125rem; color: var(--ink-muted, #4b5a60); margin: 0.2rem 0 0; }

/* Status is the first thing a non-technical admin looks for, so it reads as a
   word rather than a colour alone. */
:where(tenant-domains) .domain-card__status {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

:where(tenant-domains) .domain-card__status--ok { background: #dcfce7; color: #14532d; }

:where(tenant-domains) .domain-card__status--warn { background: #fef3c7; color: #713f12; }

:where(tenant-domains) .domain-card__status--bad { background: #fee2e2; color: #7f1d1d; }

/* One step visible at a time, numbered, so there is never a question about
   what to do next. */
:where(tenant-domains) .setup-step {
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule, #cdd8dc);
}

:where(tenant-domains) .setup-step h3 { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 0.5rem; }

:where(tenant-domains) .setup-step__n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--accent, #0e7490);
  color: #fff;
  font-size: 0.8125rem;
}

:where(tenant-domains) .setup-actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }

/* The record itself: label, value, and a copy button per field, because
   transcribing by hand is where this goes wrong. */
:where(tenant-domains) .record-card {
  border: 1px solid var(--rule, #cdd8dc);
  border-radius: 6px;
  margin: 0.9rem 0;
}

:where(tenant-domains) .record-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--rule, #cdd8dc);
}

:where(tenant-domains) .record-row:last-child { border-bottom: 0; }

:where(tenant-domains) .record-label {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint, #64757c);
}

:where(tenant-domains) .record-value { word-break: break-all; font-size: 0.9375rem; }

:where(tenant-domains) .setup-details { margin: 0.9rem 0; }

:where(tenant-domains) .setup-details summary { cursor: pointer; font-weight: 600; padding: 0.4rem 0; }

:where(tenant-domains) .setup-details ol { margin: 0.5rem 0 0.5rem 1.25rem; }

:where(tenant-domains) .setup-details li { margin-bottom: 0.4rem; }

:where(tenant-domains) .form-input--inline { display: inline-block; width: auto; min-width: 12rem; }

:where(tenant-domains) .note--ok { border-left-color: #16a34a; }

/* The wait, made legible. Two rows, each either spinning or ticked, so the
   question "is anything happening?" is answered without anyone pressing
   anything. A row appears only once the one above it is done. */
:where(tenant-domains) .progress {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

:where(tenant-domains) .progress__item {
  display: grid;
  grid-template-columns: 1.35rem 1fr;
  align-items: start;
  gap: 0.6rem;
  font-size: 0.9375rem;
  line-height: 1.5;
}

:where(tenant-domains) .progress__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  font-size: 1rem;
  /* Holds the row's first line, so a tick and a spinner sit at the same
     height and the list does not shift as each one resolves. */
  line-height: 1.4;
}

/* The spinner is the empty mark's ::after, so swapping in a tick is a matter
   of giving the mark text -- no class has to remove the animation. */
:where(tenant-domains) .progress__item--busy .progress__mark::after {
  content: '';
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: var(--accent, #0e7490);
  animation: progress-spin 0.8s linear infinite;
}

:where(tenant-domains) .progress__item--busy .progress__text { color: var(--ink-faint, #64757c); }

:where(tenant-domains) .progress__item--problem .progress__text { color: #7f1d1d; }

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

@media (prefers-reduced-motion: reduce) {
  :where(tenant-domains) .progress__item--busy .progress__mark::after {
    animation: progress-pulse 1.6s ease-in-out infinite;
  }
  @keyframes progress-pulse { 50% { opacity: 0.35; } }
}
