/* ──────────────────────────────────────────────────────────────────────
 * Account shell — auth, profile, invite, and studio-create surfaces.
 *
 * Reuses the design tokens + universal components from `admin.css`
 * (loaded alongside this file). What's here is just the layout chrome
 * for centered, single-column pages: a minimal top bar and a card-stack
 * shell.
 * ──────────────────────────────────────────────────────────────────── */

@layer ac-components;

@layer ac-components {
  /* Minimal top bar. The brand wordmark anchors the page; an optional
   * account-nav slot lives on the right (logged-in pages override it). */
  /* The account shell never scrolls sideways; narrow phones reflow instead. */
  .page--account { overflow-x: clip; }

  .ac-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.95rem var(--ad-gutter);
    border-block-end: 1px solid var(--ad-line-soft);
    background: var(--ad-surface);
  }
  .ac-topbar__brand {
    font-family: "Fraunces", serif;
    font-size: 1.5rem;
    color: var(--ad-ink);
    letter-spacing: -0.005em;
    border: 0;
  }
  .ac-topbar__brand:hover { border: 0; color: var(--ad-ink); }
  .ac-topbar__brand em {
    font-style: italic;
    color: var(--ad-accent);
  }
  .ac-topbar__nav {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem 1rem;
    min-inline-size: 0;
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--1);
  }
  .ac-topbar__nav a { color: var(--ad-ink-soft); border: 0; }
  .ac-topbar__nav a:hover { color: var(--ad-ink); border: 0; }

  /* Centered shell. Default narrow (32rem) for auth/single-form pages;
   * `.ac-shell--wide` opens up for profile pages with multiple cards. */
  .ac-shell {
    max-inline-size: 32rem;
    margin-inline: auto;
    padding: clamp(2rem, 1rem + 4vw, 4rem) var(--ad-gutter);
    display: flex;
    flex-direction: column;
    gap: var(--ad-stack);
  }
  .ac-shell--wide {
    max-inline-size: 60rem;
  }

  /* Page-level title + lede sit ABOVE any cards; the card itself is
   * usually a `.ad-section` with `__head` + `__body`. */
  .ac-pagehead {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-block-end: 0.5rem;
  }
  .ac-pagehead h1 {
    font-size: var(--ad-step-3);
    color: var(--ad-ink);
  }
  .ac-pagehead h1 em { font-style: italic; color: var(--ad-accent); }
  .ac-pagehead p {
    color: var(--ad-ink-soft);
    margin-inline: auto;
    max-inline-size: 48ch;
  }

  /* The auth card is just a `.ad-section` whose head is text-centered
   * and whose body sits flush with the typography. We keep `.ac-card`
   * as a thin alias so future tweaks don't have to touch every page. */
  .ac-card {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: 16px;
    padding: clamp(1.5rem, 1rem + 2vw, 2.25rem);
    box-shadow: var(--ad-shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .ac-card--quiet {
    box-shadow: none;
  }
  .ac-card__alt {
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--1);
    text-align: center;
  }
  .ac-card__alt a {
    color: var(--ad-accent-deep);
    border-bottom: 1px solid var(--ad-line);
  }
  .ac-card__alt a:hover {
    color: var(--ad-accent);
    border-bottom-color: var(--ad-accent);
  }

  /* Profile head — used on /me as a two-column block: avatar + upload
   * form on the left, name/headline/bio on the right. */
  .ac-profile-head {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    align-items: start;
  }
  @media (max-width: 36rem) {
    .ac-profile-head { grid-template-columns: 1fr; }
  }
  .ac-profile-head__avatarcol {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    min-inline-size: 9rem;
  }
  .ac-profile-head__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .ac-profile-head__avatar {
    inline-size: 88px;
    block-size: 88px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--ad-line);
    background: var(--ad-surface);
  }
  .ac-profile-head__avatar--empty {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--ad-accent), var(--ad-accent-deep));
    color: var(--ad-accent-fg);
    font-family: "Fraunces", serif;
    font-size: 2.4rem;
    line-height: 1;
    text-transform: uppercase;
  }
  .ac-profile-head__name {
    font-family: "Fraunces", serif;
    font-size: var(--ad-step-2);
    line-height: 1.1;
    color: var(--ad-ink);
  }
  .ac-profile-head__meta {
    color: var(--ad-ink-soft);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    font-size: var(--ad-step--1);
  }
  .ac-profile-head__meta strong { color: var(--ad-ink); font-weight: 500; }

  /* Avatar form: visible file input + submit. No JS. */
  .ac-avatar-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  .ac-avatar-form__field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .ac-avatar-form__hint {
    font-size: var(--ad-step--2);
    color: var(--ad-ink-mute);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
  }
  .ac-avatar-form__file {
    font: inherit;
    font-size: var(--ad-step--2);
    color: var(--ad-ink-soft);
    padding: 0.35rem 0;
    border: 0;
    background: transparent;
    max-inline-size: 100%;
  }
  .ac-avatar-form__file::file-selector-button {
    font: inherit;
    font-size: var(--ad-step--2);
    margin-inline-end: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--ad-line-strong);
    background: var(--ad-surface);
    color: var(--ad-ink);
    cursor: pointer;
  }
  .ac-avatar-form__file::file-selector-button:hover {
    border-color: var(--ad-ink);
    background: var(--ad-surface-2);
  }

  /* Step guide rendered on /me when the user has no studios yet. */
  .ad-stepguide {
    list-style: none;
    counter-reset: ad-stepguide;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.6rem;
  }
  .ad-stepguide li {
    counter-increment: ad-stepguide;
    display: grid;
    grid-template-columns: 1.75rem 1fr;
    align-items: baseline;
    gap: 0.75rem;
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--1);
    line-height: 1.5;
  }
  .ad-stepguide li::before {
    content: counter(ad-stepguide);
    display: grid;
    place-items: center;
    inline-size: 1.75rem;
    block-size: 1.75rem;
    border-radius: 50%;
    background: var(--ad-accent-soft);
    color: var(--ad-accent-deep);
    font-family: "Fraunces", serif;
    font-size: 1rem;
    line-height: 1;
  }
  .ad-stepguide strong { color: var(--ad-ink); font-weight: 600; }

  /* Studio cards on /me. Each card shows the studio name + role + setup
   * progress + a "next action" CTA so users can resume onboarding. */
  .ac-studio-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }
  .ac-studio {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 0.75rem;
    row-gap: 0.35rem;
    padding: 1rem 1.25rem;
    border-block-start: 1px solid var(--ad-line-soft);
  }
  .ac-studio:first-child { border-block-start: 0; }
  .ac-studio__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--ad-step-0);
    color: var(--ad-ink);
    text-decoration: none;
    border: 0;
  }
  .ac-studio__title:hover { color: var(--ad-accent-deep); }
  .ac-studio__title strong { font-weight: 600; }
  .ac-studio__progress {
    grid-column: 1 / -1;
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--1);
  }
  .ac-studio__cta {
    justify-self: end;
    grid-row: 1 / 2;
    grid-column: 2 / 3;
  }
  @media (max-width: 28rem) {
    .ac-studio { grid-template-columns: 1fr; }
    .ac-studio__cta { justify-self: start; grid-column: 1 / -1; grid-row: auto; }
  }

  /* ── /me welcome state (no studios yet) ─────────────────────────────
   * Big, calm hero. One job: get them to create a studio. No fake
   * "next steps" list — every step after #1 needs a studio that
   * doesn't exist yet, so listing them is dishonest. */
  .ac-welcome {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: 20px;
    padding: clamp(2rem, 1.25rem + 4vw, 3.5rem);
    box-shadow: var(--ad-shadow-md);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    position: relative;
    overflow: hidden;
  }
  .ac-welcome::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline-end: 0;
    inline-size: 18rem;
    block-size: 18rem;
    background: radial-gradient(closest-side, var(--ad-accent-soft), transparent 70%);
    transform: translate(35%, -45%);
    pointer-events: none;
  }
  .ac-welcome__eyebrow {
    font-size: var(--ad-step--2);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ad-accent-deep);
  }
  .ac-welcome__title {
    font-family: "Fraunces", serif;
    font-weight: 400;
    font-size: var(--ad-step-3);
    line-height: 1.05;
    letter-spacing: -0.01em;
    color: var(--ad-ink);
    max-inline-size: 22ch;
  }
  .ac-welcome__title em { font-style: italic; color: var(--ad-accent); }
  .ac-welcome__lede {
    color: var(--ad-ink-soft);
    max-inline-size: 56ch;
    font-size: var(--ad-step-0);
    line-height: 1.55;
  }
  .ac-welcome__cta {
    margin-block-start: 0.5rem;
    padding-block: 0.95rem;
    padding-inline: 1.75rem;
    font-size: var(--ad-step-0);
    justify-content: center;
  }
  /* On phones the primary action stretches edge to edge so it can never be
   * pushed off-screen or overlooked. */
  @media (max-width: 40rem) {
    .ac-welcome__cta { align-self: stretch; }
    .ac-studios__head .ad-btn { flex: 1 1 100%; justify-content: center; }
  }

  /* ── /me populated state (at least one studio) ──────────────────── */
  .ac-studios {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }
  .ac-studios__head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
  }
  .ac-studios__title {
    font-family: "Fraunces", serif;
    font-weight: 400;
    font-size: var(--ad-step-2);
    color: var(--ad-ink);
  }
  .ac-studios__sub {
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--1);
    margin-block-start: 0.25rem;
    max-inline-size: 52ch;
  }

  .ac-studio-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  }

  /* The studio card: visible setup checklist + a primary "next action"
   * CTA. Once the studio is ready, the checklist collapses into a
   * single line so the card stays compact in steady state. */
  .ac-studio-card {
    background: var(--ad-surface);
    border: 1px solid var(--ad-line);
    border-radius: 16px;
    padding: 1.25rem 1.25rem 1.1rem;
    box-shadow: var(--ad-shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-block-size: 100%;
  }
  .ac-studio-card--ready {
    background: linear-gradient(180deg, var(--ad-surface), var(--ad-success-soft) 220%);
    border-color: color-mix(in srgb, var(--ad-success) 25%, var(--ad-line));
  }
  .ac-studio-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
  }
  .ac-studio-card__name {
    font-family: "Fraunces", serif;
    font-weight: 400;
    font-size: var(--ad-step-1);
    color: var(--ad-ink);
    text-decoration: none;
    border: 0;
    line-height: 1.1;
  }
  .ac-studio-card__name:hover { color: var(--ad-accent-deep); }
  .ac-studio-card__status {
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--1);
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }
  .ac-studio-card__status-dot {
    inline-size: 0.55rem;
    block-size: 0.55rem;
    border-radius: 50%;
    background: var(--ad-success);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ad-success) 18%, transparent);
  }
  .ac-studio-card__actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-block-start: auto;
  }

  /* The setup checklist inside a studio card. Each row collapses into
   * a strikethrough when complete; the open rows lead with a faint
   * circle that flips to a filled checkmark once done. */
  .ac-checklist {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }
  .ac-checklist__item {
    display: grid;
    grid-template-columns: 1.4rem 1fr;
    gap: 0.6rem;
    align-items: start;
    font-size: var(--ad-step--1);
    color: var(--ad-ink);
    line-height: 1.45;
  }
  .ac-checklist__mark {
    inline-size: 1.15rem;
    block-size: 1.15rem;
    border-radius: 50%;
    border: 1.5px solid var(--ad-line-strong);
    background: var(--ad-surface);
    margin-block-start: 0.1rem;
    position: relative;
  }
  .ac-checklist__item.is-done .ac-checklist__mark {
    background: var(--ad-success);
    border-color: var(--ad-success);
  }
  .ac-checklist__item.is-done .ac-checklist__mark::after {
    content: "";
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    inline-size: 0.42rem;
    block-size: 0.7rem;
    border-inline-end: 2px solid #ffffff;
    border-block-end: 2px solid #ffffff;
    transform: translate(-50%, -65%) rotate(45deg);
  }
  .ac-checklist__item.is-done .ac-checklist__label {
    color: var(--ad-ink-mute);
    text-decoration: line-through;
    text-decoration-color: color-mix(in srgb, var(--ad-ink-mute) 50%, transparent);
  }
  .ac-checklist__hint {
    color: var(--ad-ink-soft);
    font-size: var(--ad-step--2);
  }

  /* The demoted profile card under the studios. Compact, quiet — your
   * own details should not be the loudest thing on this page. */
  .ac-profile {
    padding: 1.25rem 1.5rem;
    gap: 0.75rem;
  }
  .ac-profile__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
  }
  .ac-profile__body {
    display: flex;
    gap: 1rem;
    align-items: center;
  }
  .ac-profile__detail { min-inline-size: 0; }
  .ac-profile__name {
    font-family: "Fraunces", serif;
    font-size: var(--ad-step-1);
    line-height: 1.1;
    color: var(--ad-ink);
  }
  .ac-profile__meta {
    color: var(--ad-ink-soft);
    margin-block-start: 0.2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    font-size: var(--ad-step--1);
  }
  .ac-profile__meta strong { color: var(--ad-ink); font-weight: 500; }
  .ac-profile__photo summary {
    cursor: pointer;
    color: var(--ad-accent-deep);
    font-size: var(--ad-step--2);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: inline-block;
    padding-block-end: 1px;
    border-bottom: 1px solid var(--ad-line);
    list-style: none;
  }
  .ac-profile__photo summary::-webkit-details-marker { display: none; }
  .ac-profile__photo summary:hover { color: var(--ad-accent); border-color: var(--ad-accent); }
  .ac-profile__photo[open] summary { color: var(--ad-ink); }
  .ac-profile__photo form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-block-start: 0.6rem;
  }

  /* Generic data list — a stack of rows, each with an optional leading
   * avatar, an identity column (name + sub), and a trailing action or meta.
   * Used by the platform-admin people and studios tables. */
  .ac-list { list-style: none; margin: 0; padding: 0; }
  .ac-list__item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    padding: 0.85rem 0;
    border-block-start: 1px solid var(--ad-line-soft);
  }
  .ac-list__item:first-child { border-block-start: 0; }
  .ac-list__avatar {
    inline-size: 40px;
    block-size: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--ad-surface-2);
    flex: none;
  }
  .ac-list__avatar--empty {
    display: grid;
    place-items: center;
    font-family: "Fraunces", serif;
    color: var(--ad-accent-fg);
    background: linear-gradient(135deg, var(--ad-accent), var(--ad-accent-deep));
    text-transform: uppercase;
  }
  .ac-list__identity {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-inline-size: 0;
    flex: 1 1 12rem;
  }
  .ac-list__name { color: var(--ad-ink); font-weight: 600; }
  .ac-list__name a { color: inherit; border: 0; }
  .ac-list__name a:hover { color: var(--ad-accent-deep); }
  .ac-list__sub { color: var(--ad-ink-soft); font-size: var(--ad-step--1); }
  .ac-list__action {
    margin-inline-start: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
  }

  /* Changelog — the embedded CHANGELOG.md, rendered verbatim. Keep it a
   * readable monospace column; wrap long lines rather than scroll. */
  .ac-changelog {
    margin: 0;
    font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
    font-size: var(--ad-step--1);
    line-height: 1.65;
    color: var(--ad-ink-soft);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    tab-size: 2;
  }

  /* Reveal — match admin.css's stagger so the visual transition feels
   * like one design system rather than two. */
  @media (prefers-reduced-motion: no-preference) {
    .ac-pagehead, .ac-card, .ac-profile-head, .ad-section,
    .ac-welcome, .ac-studios, .ac-studio-card, .ac-profile {
      animation: ac-rise 0.5s cubic-bezier(.2,.7,.2,1) both;
    }
    .ac-pagehead    { animation-delay: 0.04s; }
    .ac-welcome     { animation-delay: 0.06s; }
    .ac-studios     { animation-delay: 0.06s; }
    .ac-studio-card { animation-delay: 0.10s; }
    .ac-card        { animation-delay: 0.10s; }
    .ad-section     { animation-delay: 0.10s; }
    .ac-profile     { animation-delay: 0.16s; }
    @keyframes ac-rise {
      from { transform: translateY(8px); }
      to   { transform: translateY(0); }
    }
  }
}
