/* ==========================================================================
   Surface: alliances page + alliance dialogs (alliances.js)
   --------------------------------------------------------------------------
   Owns: #page-alliances .al-* (slot summary + meter + CTA, concept steps,
   list rows with URL / views / actions) and dialog.al-dialog (checkout,
   create). Everything sits on the dark --nv-* tokens: this replaces the
   legacy light-theme leak that rendered text at 1.29:1.
   Tokens only, no !important.
   r181 (unslop): a plain card, figures in the figure face at 500, the taken places in the solid accent,
   every address in the signature (.nv-address: mono, the host dim, the name bright), one line icon per row
   with no tile behind it; a chosen payment method is a surface step with an accent hairline and the dot.
   ========================================================================== */

@layer surfaces {
  /* ---- Summary: slot meter + one CTA ---------------------------------------- */
  .al-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--nv-space-5) var(--nv-space-6);
    margin-bottom: var(--nv-space-8);
  }

  .al-summary[aria-busy="true"] {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--nv-space-3);
  }

  .al-summary-copy {
    display: grid;
    gap: var(--nv-space-2);
    min-width: 0;
  }

  .al-label {
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
  }

  /* «2 / 3»: the figure face (Onest, tabular), 500, the limit a step quieter than the count. */
  .al-value {
    display: flex;
    align-items: baseline;
    gap: var(--nv-space-2);
    color: var(--nv-text);
    font-family: var(--nv-font-figure);
    font-size: var(--nv-fs-36);
    font-weight: var(--nv-fw-medium);
    line-height: 1;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
  }

  .al-value span {
    color: var(--nv-text-3);
    font-weight: var(--nv-fw-regular);
  }

  .al-value b:last-child {
    color: var(--nv-text-2);
  }

  .al-status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--nv-space-2) var(--nv-space-3);
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
  }

  /* One cell per place: taken = the accent, free = a surface step. */
  .al-meter {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--nv-space-1);
  }

  .al-meter i {
    flex: 1;
    height: 8px;
    border-radius: var(--nv-r-round);
    background: var(--nv-surface-3);
  }

  .al-meter i.is-on {
    background: var(--nv-accent);
  }

  .al-cta {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    justify-items: end;
    gap: var(--nv-space-1);
  }

  .al-cta svg {
    width: 16px;
    height: 16px;
  }

  /* Concept steps (shown until the first slot is bought). */
  .al-steps {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--nv-space-3);
    margin: 0;
    padding: var(--nv-space-5) 0 0;
    border-top: 1px solid var(--nv-line-soft);
    list-style: none;
  }

  .al-steps li {
    display: flex;
    align-items: flex-start;
    gap: var(--nv-space-3);
    min-width: 0;
  }

  /* The step number: a quiet mono figure in a hairline ring, not an orange disc. */
  .al-steps li > b {
    flex: none;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-round);
    color: var(--nv-text-2);
    font-family: var(--nv-font-mono);
    font-size: var(--nv-fs-12);
    font-weight: var(--nv-fw-medium);
  }

  .al-steps li > span {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .al-steps strong {
    color: var(--nv-text);
    font-size: var(--nv-fs-14);
  }

  .al-steps small {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
    line-height: 1.45;
  }

  /* ---- List ------------------------------------------------------------------ */
  .al-section {
    display: grid;
    gap: var(--nv-space-3);
  }

  .al-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--nv-space-2);
  }

  .al-section-head h2 {
    font-size: var(--nv-fs-18);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
  }

  .al-count {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
  }

  .al-count b {
    color: var(--nv-text);
    font-family: var(--nv-font-figure);
    font-weight: var(--nv-fw-medium);
    font-variant-numeric: tabular-nums;
  }

  .al-list {
    border-radius: var(--nv-r-lg);
  }

  .al-row {
    min-height: 72px;
    padding: var(--nv-space-3) var(--nv-space-4);
  }

  /* One bare line icon per row in the muted role (components.css: no tile behind it). */
  .al-row-icon {
    width: 40px;
    height: 40px;
  }

  .al-url {
    display: flex;
    align-items: center;
    gap: var(--nv-space-2);
    min-width: 0;
  }

  /* The address: mono, the host dim, the name bright (.nv-address-* in components.css). */
  .al-url b {
    overflow: hidden;
    font-family: var(--nv-address-font);
    font-size: var(--nv-fs-14);
    font-weight: var(--nv-fw-regular);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .al-url .nv-address-name {
    font-weight: var(--nv-fw-medium);
  }

  .al-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px var(--nv-space-2);
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
  }

  .list-row-body > .al-meta {
    white-space: normal;
  }

  .al-views {
    display: inline-flex;
    align-items: center;
    gap: var(--nv-space-1);
  }

  .al-views svg {
    width: 16px;
    height: 16px;
  }

  .al-views b {
    color: var(--nv-text-2);
    font-family: var(--nv-font-figure);
    font-weight: var(--nv-fw-medium);
    font-variant-numeric: tabular-nums;
  }

  .al-row .list-row-actions svg {
    width: 16px;
    height: 16px;
  }

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

  .al-hint {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-13);
  }

  .al-skel-lines {
    display: grid;
    flex: 1;
    gap: var(--nv-space-2);
  }

  .al-skel-short {
    width: 45%;
  }

  /* ---- Dialogs ----------------------------------------------------------------- */
  .al-dialog .dialog-header .eyebrow {
    margin-bottom: var(--nv-space-1);
  }

  .al-dialog .dialog-close svg {
    width: 18px;
    height: 18px;
  }

  .al-form {
    display: block;
  }

  .al-stepper {
    display: flex;
    align-items: center;
    gap: var(--nv-space-2);
  }

  .al-stepper input {
    max-width: 96px;
    font-family: var(--nv-font-figure);
    font-size: var(--nv-fs-16);
    font-variant-numeric: tabular-nums;
    text-align: center;
    -moz-appearance: textfield;
  }

  .al-stepper input::-webkit-inner-spin-button,
  .al-stepper input::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
  }

  .al-stepper .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .al-total {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    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-bg-deep);
  }

  .al-total span {
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
  }

  .al-total strong {
    font-family: var(--nv-font-figure);
    font-size: var(--nv-fs-22);
    font-weight: var(--nv-fw-medium);
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
  }

  .al-pay {
    display: grid;
    gap: var(--nv-space-2);
    margin: 0;
    padding: 0;
    border: 0;
  }

  .al-pay legend {
    margin-bottom: var(--nv-space-2);
    padding: 0;
    color: var(--nv-text-2);
    font-size: var(--nv-fs-13);
    font-weight: var(--nv-fw-medium);
  }

  .al-providers {
    display: grid;
    gap: var(--nv-space-2);
  }

  /* Same radio rows as the Premium checkout: the chosen one is a surface step, an accent hairline and the dot. */
  .al-provider {
    display: flex;
    align-items: center;
    gap: var(--nv-space-3);
    width: 100%;
    min-height: 56px;
    padding: var(--nv-space-3) var(--nv-space-4);
    border: 1px solid var(--nv-line-strong);
    border-radius: var(--nv-r-md);
    background: var(--nv-surface-2);
    color: var(--nv-text);
    text-align: left;
    transition: border-color var(--nv-dur-1) var(--nv-ease), background-color var(--nv-dur-1) var(--nv-ease);
  }

  .al-provider:hover {
    border-color: var(--nv-field-line-hover);
    background: var(--nv-surface-3);
  }

  .al-provider > i {
    flex: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--nv-text-disabled);
    border-radius: var(--nv-r-round);
  }

  .al-provider[aria-checked="true"] {
    border-color: var(--nv-accent-line);
    background: var(--nv-surface-3);
  }

  .al-provider[aria-checked="true"] > i {
    border-color: var(--nv-accent);
    background: radial-gradient(circle, var(--nv-accent) 0 4px, transparent 4.5px);
  }

  .al-provider > span {
    display: grid;
    gap: 2px;
  }

  .al-provider small {
    color: var(--nv-text-3);
    font-size: var(--nv-fs-12);
  }

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

    .al-cta {
      grid-column: 1;
      grid-row: auto;
      justify-items: stretch;
    }

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

    .al-row {
      flex-wrap: wrap;
    }

    .al-row .list-row-body {
      flex-basis: calc(100% - 56px);
    }

    .al-row .list-row-actions {
      width: 100%;
      justify-content: flex-end;
      padding-left: 52px;
    }

    /* r180: the action row wraps instead of running under the list's clipped edge (delete was
       unreachable at 320 px); the main-address chip and the date move to their own line. */
    .al-row .list-row-actions {
      flex-wrap: wrap;
      padding-left: 0;
    }

    .al-url {
      flex-wrap: wrap;
      row-gap: var(--nv-space-1);
    }
  }

  /* r180: an extra page that is off (no paid place) or taken down by moderation: its name dims a step. */
  .al-row:is(.is-off, .is-down) .al-url .nv-address-name {
    color: var(--nv-text-2);
  }

  .al-row:is(.is-off, .is-down) .al-row-icon {
    opacity: .6;
  }

  @media (max-width: 640px) {
    /* The host is the same on every row; the slug is the part that tells pages apart. */
    .al-host {
      display: none;
    }
  }

  @media (pointer: coarse) {
    .al-row .list-row-actions :is(a, button) {
      min-width: var(--nv-hit);
      min-height: var(--nv-hit);
    }
  }

  /* ---- Phones: compact + calm (r160, r181) ------------------------------------------ */
  @media (max-width: 640px) {
    .al-summary {
      gap: var(--nv-space-3);
      margin-bottom: var(--nv-space-5);
    }

    .al-meter i {
      height: 6px;
    }

    .al-steps {
      gap: var(--nv-space-2);
      padding-top: var(--nv-space-3);
    }

    .al-steps li {
      gap: var(--nv-space-2);
    }

    .al-steps li > b {
      width: 24px;
      height: 24px;
    }

    .al-steps strong {
      font-size: var(--nv-fs-13);
    }

    .al-steps small {
      font-size: var(--nv-fs-12);
    }
  }
}
