/* ==========================================================================
   Surface: Custom domain (#page-domains) — owned by dashboard-core
   Markup from account-services.js. Owns: .domains-page, .domain-card(.is-locked),
   .stepper > .step(.is-done/.is-current) (.step-dot), .domain-step, .domain-summary
   (.domain-globe, .domain-summary-actions, .danger-text), .provider-tabs,
   .provider-hint, .dns-table > .dns-row(.dns-head) (.dns-cell), .verify-panel
   (.verify-state, .check-results li.ok/.bad), .domain-ssl, .domain-done (.done-icon),
   .domain-locked (.domain-preview, .domain-locked-copy), .domain-help (.help-list).
   r181 (unslop): the current step is the one accent (a solid dot and its underline); done steps are a
   small green check on a neutral line; icons sit in the muted role without tiles.
   ========================================================================== */

@layer surfaces {
  .app-shell .page.domains-page.active {
    display: grid;
    gap: var(--nv-space-4);
  }

  .domains-page > .page-header {
    margin-bottom: var(--nv-space-2);
  }

  .domain-card {
    display: grid;
    gap: var(--nv-space-5);
    padding: var(--nv-space-6);
  }

  /* ---- Stepper ----------------------------------------------------------------- */
  .stepper {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--nv-space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: step;
  }

  .step {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    min-width: 0;
    padding-bottom: var(--nv-space-3);
    border-bottom: 2px solid var(--nv-line);
  }

  .step > div {
    display: grid;
    min-width: 0;
  }

  .step b {
    overflow: hidden;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .step small {
    overflow: hidden;
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .step-dot {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--nv-line-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--nv-text-3);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
  }

  /* One stroke (1.5) like every 16px icon; only 12px glyphs in discs take 2 (editor.css .ed-visual-check). */
  .step-dot .nv-icon {
    width: 16px;
    height: 16px;
    stroke-width: 1.5;
  }

  .step.is-current {
    border-bottom-color: var(--nv-accent);
  }

  .step.is-current .step-dot {
    border-color: var(--nv-accent);
    background: var(--nv-accent);
    color: var(--nv-on-accent);
  }

  .step.is-current b {
    color: var(--nv-text);
  }

  .step.is-done {
    border-bottom-color: var(--nv-line-strong);
  }

  .step.is-done .step-dot {
    color: var(--nv-success);
  }

  .step.is-done b {
    color: var(--nv-text);
  }

  .domain-step {
    display: grid;
    gap: var(--nv-space-4);
  }

  .domain-step .input-group.large .input-prefix {
    font-size: var(--nv-fs-13);
  }

  .domain-step .input-group input {
    font-size: var(--nv-fs-16);
  }

  /* ---- Summary ----------------------------------------------------------------- */
  .domain-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nv-space-3);
    padding: var(--nv-space-3) var(--nv-space-4);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-2);
  }

  .domain-summary > div:not(.domain-summary-actions) {
    display: grid;
    flex: 1;
    min-width: 0;
  }

  .domain-summary b {
    overflow: hidden;
    color: var(--nv-text);
    font-size: var(--nv-fs-16);
    font-weight: var(--nv-fw-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .domain-summary small {
    color: var(--nv-text-3);
  }

  .domain-globe {
    display: grid;
    flex: none;
    place-items: center;
    width: 24px;
    height: 24px;
    color: var(--nv-text-3);
  }

  .domain-globe .nv-icon {
    width: 20px;
    height: 20px;
  }

  .domain-summary-actions {
    display: flex;
    gap: var(--nv-space-1);
  }

  .danger-text {
    --btn-fg: var(--nv-danger);
  }

  .danger-text:hover {
    background: var(--nv-danger-soft);
    color: var(--nv-danger);
  }

  .danger-text .nv-icon {
    width: 16px;
    height: 16px;
  }

  /* ---- DNS records -------------------------------------------------------------- */
  .provider-tabs {
    justify-self: start;
  }

  .provider-hint {
    display: flex;
    align-items: flex-start;
    gap: var(--nv-space-2);
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    line-height: var(--nv-lh-ui);
  }

  /* 1px centres the 16px icon on the first 18px line. */
  .provider-hint .nv-icon {
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    color: var(--nv-text-3);
  }

  .dns-table {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-bg-deep);
  }

  .dns-row {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1.4fr);
    align-items: center;
    gap: var(--nv-space-3);
    min-height: 52px;
    padding: var(--nv-space-2) var(--nv-space-4);
  }

  .dns-row + .dns-row {
    border-top: 1px solid var(--nv-line-soft);
  }

  .dns-head {
    min-height: 40px;
    background: var(--nv-surface-2);
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
  }

  .dns-cell {
    display: flex;
    align-items: center;
    gap: var(--nv-space-1);
    min-width: 0;
  }

  .dns-cell code {
    overflow: hidden;
    border: 0;
    background: transparent;
    color: var(--nv-text);
    font-size: var(--nv-fs-13);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dns-cell .icon-btn .nv-icon {
    width: 16px;
    height: 16px;
  }

  /* ---- Verification ------------------------------------------------------------- */
  .verify-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nv-space-3) var(--nv-space-5);
    padding: var(--nv-space-4);
    border: 1px solid var(--nv-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-2);
  }

  .verify-panel > .notice {
    flex-basis: 100%;
    order: 3;
  }

  .verify-state {
    display: flex;
    flex: 1;
    align-items: center;
    gap: var(--nv-space-3);
    min-width: 220px;
  }

  .verify-state > div {
    display: grid;
  }

  .verify-state b {
    color: var(--nv-text);
    font-weight: var(--nv-fw-medium);
  }

  .verify-state small {
    color: var(--nv-text-3);
  }

  .verify-state [data-countdown] {
    font-family: var(--nv-font-mono);
    font-variant-numeric: tabular-nums;
  }

  .check-results {
    display: flex;
    flex-wrap: wrap;
    gap: var(--nv-space-2) var(--nv-space-4);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--nv-fs-13);
  }

  .check-results li {
    display: inline-flex;
    align-items: center;
    gap: var(--nv-space-2);
  }

  .check-results .nv-icon {
    width: 16px;
    height: 16px;
    stroke-width: 1.5;
  }

  .check-results .ok {
    color: var(--nv-success);
  }

  .check-results .bad {
    color: var(--nv-danger);
  }

  .domain-ssl {
    display: grid;
    gap: var(--nv-space-3);
    padding: var(--nv-space-5);
    border: 1px solid var(--nv-info-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-info-soft);
  }

  .domain-ssl h3 {
    font-size: var(--nv-fs-16);
    letter-spacing: 0;
  }

  .domain-ssl p {
    color: var(--nv-text-2);
  }

  .domain-done {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nv-space-4);
    padding: var(--nv-space-5);
    border: 1px solid var(--nv-success-line);
    border-radius: var(--nv-r-md);
    background: var(--nv-success-soft);
  }

  .domain-done > div {
    flex: 1;
    min-width: 220px;
  }

  .domain-done h2 {
    font-size: var(--nv-fs-18);
    letter-spacing: 0;
  }

  .domain-done p {
    margin-top: var(--nv-space-1);
    color: var(--nv-text-2);
  }

  /* Connected: one green check (no filled disc). */
  .done-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 24px;
    height: 24px;
    color: var(--nv-success);
  }

  .done-icon .nv-icon {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
  }

  /* ---- Locked (Free) ------------------------------------------------------------ */
  .domain-locked {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--nv-space-6);
    align-items: center;
  }

  /* A locked preview of the real DNS table: dimmed and softened. */
  .domain-preview {
    filter: blur(1.5px);
    opacity: .7;
    pointer-events: none;
    user-select: none;
  }

  .domain-locked-copy {
    display: grid;
    justify-items: start;
    gap: var(--nv-space-3);
  }

  .domain-locked-copy h2 {
    font-size: var(--nv-fs-22);
    letter-spacing: 0;
  }

  .domain-locked-copy p {
    color: var(--nv-text-2);
    line-height: var(--nv-lh-body);
  }

  .domain-card.is-locked .stepper {
    opacity: .6;
  }

  /* ---- Help -------------------------------------------------------------------- */
  .domain-help .card-head h2 {
    font-size: var(--nv-fs-16);
  }

  .help-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--nv-space-4);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .help-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--nv-space-3);
  }

  .help-list li > .nv-icon {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    color: var(--nv-text-3);
  }

  .help-list div {
    display: grid;
    gap: var(--nv-space-1);
  }

  .help-list b {
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-medium);
  }

  .help-list small {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
    line-height: var(--nv-lh-ui);
  }

  /* ---- Responsive -------------------------------------------------------------- */
  @media (max-width: 900px) {
    .help-list {
      grid-template-columns: minmax(0, 1fr);
    }

    .domain-locked {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  @media (max-width: 640px) {
    .domain-card {
      padding: var(--nv-space-4);
    }

    .stepper {
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: var(--nv-space-2);
    }

    .step {
      flex-direction: column;
      align-items: flex-start;
      gap: var(--nv-space-2);
    }

    .step small {
      display: none;
    }

    .step b {
      font-size: var(--nv-fs-12);
    }

    .dns-row {
      grid-template-columns: minmax(0, 1fr);
      gap: var(--nv-space-1);
      padding: var(--nv-space-3);
    }

    .dns-head {
      display: none;
    }

    .domain-summary-actions {
      width: 100%;
      justify-content: flex-end;
    }
  }

  /* ---- Phones: compact + calm (r160) -------------------------------------------- */
  @media (max-width: 640px) {
    .app-shell .page.domains-page.active {
      gap: var(--nv-space-3);
    }

    /* r181: the page title is for screen readers only on phones: the one page-title rule in app-shell.css. */
    .domain-card {
      gap: var(--nv-space-4);
    }

    .step {
      padding-bottom: var(--nv-space-2);
    }

    .step-dot {
      width: 24px;
      height: 24px;
      font-size: var(--nv-fs-12);
    }

    .domain-step {
      gap: var(--nv-space-3);
    }
  }
}

/* ---- r180: phones ------------------------------------------------------------------------ */
@layer surfaces {
  /* A long host never widens the card past the screen. */
  .domain-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .domain-done > div {
    flex: 1 1 220px;
    min-width: 0;
  }

  .domain-done p a {
    overflow-wrap: anywhere;
  }

  @media (max-width: 640px) {
    /* The host gets the whole line; the status chip drops under it (past the 24px icon). */
    .domain-summary > div:not(.domain-summary-actions) {
      flex: 1 1 calc(100% - 24px - var(--nv-space-3));
    }

    .domain-summary > .chip {
      margin-left: calc(24px + var(--nv-space-3));
    }

    .domain-summary b {
      white-space: normal;
      overflow-wrap: anywhere;
    }
  }

  /* Step labels wrap (DNS-/записи) instead of being cut. */
  @media (max-width: 400px) {
    .step b {
      font-size: var(--nv-fs-12);
      line-height: 1.2;
      white-space: normal;
      overflow-wrap: anywhere;
      hyphens: auto;
    }
  }
}
