/* ==========================================================================
   My Account (WooCommerce): not in the static template, built from its
   tokens and components (form-card, field, btn, review-items, totals-table).
   Loaded with content.css + cart.css on account pages (inc/enqueue.php).
   ========================================================================== */
@layer pages {
  /* ------------------------------------------------------------------------
     Shell: profile + menu | content
     ------------------------------------------------------------------------ */
  .account-section { padding-block: var(--space-6) var(--section-space-sm); }

  .account-layout { display: grid; gap: var(--space-5); align-items: start; }

  .account-content { container-type: inline-size; display: grid; gap: var(--space-5); min-width: 0; }

  @media (min-width: 960px) {
    .account-layout { grid-template-columns: 264px minmax(0, 1fr); gap: var(--space-7); }
    .account-side { position: sticky; inset-block-start: calc(var(--header-h-compact) + var(--space-5)); }
  }

  /* minmax(0, 1fr): the scrolling chip row must not widen the column (and the profile card) */
  .account-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); min-width: 0; }

  .account-profile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }

  .account-profile__avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--coral-100);
    color: var(--coral-700);
    font-family: var(--font-serif);
    font-size: var(--fs-md);
  }

  .account-profile__text { display: grid; min-width: 0; line-height: 1.35; }
  .account-profile__text strong { font-weight: var(--fw-semibold); }
  .account-profile__text span { overflow: hidden; color: var(--text-muted); font-size: var(--fs-xs); text-overflow: ellipsis; white-space: nowrap; }

  .account-nav__list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    list-style: none;
  }

  .account-nav__list li { margin: 0; }

  .account-nav__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 44px;
    padding-inline: var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-soft);
    font-size: var(--fs-sm);
    text-decoration: none;
    transition: background-color var(--dur-fast), color var(--dur-fast);
  }

  .account-nav__link .icon { --icon-size: 1.1rem; flex: none; color: var(--text-muted); }
  .account-nav__link:hover { background: var(--surface-2); color: var(--text); }
  .account-nav__link[aria-current="page"] { background: var(--ink); color: var(--paper); font-weight: var(--fw-medium); }
  .account-nav__link[aria-current="page"] .icon { color: var(--coral-300); }

  .account-nav__logout { margin-block-start: var(--space-2) !important; padding-block-start: var(--space-2); border-block-start: 1px solid var(--border); }

  /* Phones / tablets: the menu is a row of chips that scrolls sideways */
  @media (max-width: 959px) {
    .account-profile { padding: var(--space-3) var(--space-4); }
    .account-nav { margin-inline: calc(-1 * var(--gutter)); }
    .account-nav__list {
      display: flex;
      gap: var(--space-2);
      overflow-x: auto;
      padding: 2px var(--gutter);
      border: 0;
      background: none;
      scroll-padding-inline: var(--gutter);
      scrollbar-width: none;
    }
    .account-nav__list::-webkit-scrollbar { display: none; }
    .account-nav__list li { flex: none; }
    .account-nav__link { min-height: 40px; padding-inline: var(--space-4); border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--surface); white-space: nowrap; }
    .account-nav__logout { margin: 0 !important; padding: 0; border: 0; }
  }

  /* ------------------------------------------------------------------------
     Dashboard
     ------------------------------------------------------------------------ */
  .account-hello {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: clamp(var(--space-5), 4vw, var(--space-6));
    border-radius: var(--radius-lg);
    background: var(--surface-2);
  }

  .account-hello__title { margin: 0 0 var(--space-1); font-family: var(--font-serif); font-size: var(--fs-xl); font-weight: var(--fw-regular); line-height: 1.15; }
  .account-hello p { margin: 0; color: var(--text-soft); max-width: 46ch; }

  .account-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .account-tiles li { margin: 0; }

  .account-tile {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: 100%;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  }

  .account-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm, 0 2px 10px rgb(43 38 36 / 0.06)); }
  .account-tile__icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); color: var(--coral-700); }
  .account-tile__text { display: grid; gap: 2px; min-width: 0; line-height: 1.35; }
  .account-tile__text strong { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
  .account-tile__text span { color: var(--text-muted); font-size: var(--fs-xs); }
  .account-tile__go { --icon-size: 1rem; flex: none; margin-inline-start: auto; color: var(--text-muted); }

  .account-block { display: grid; gap: var(--space-3); }
  .account-block__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .account-block__title { margin: 0; font-family: var(--font-serif); font-size: var(--fs-lg); font-weight: var(--fw-regular); }

  /* ------------------------------------------------------------------------
     Orders
     ------------------------------------------------------------------------ */
  .order-list { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }

  .order-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3) var(--space-4);
    margin: 0;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }

  .order-row__main { display: grid; gap: var(--space-1); min-width: 0; }
  .order-row__number { color: var(--text); font-weight: var(--fw-semibold); text-decoration: none; }
  .order-row__number:hover { text-decoration: underline; text-underline-offset: 0.2em; }
  .order-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--text-muted); font-size: var(--fs-xs); }
  .order-row__extra { color: var(--text-muted); font-size: var(--fs-xs); }
  .order-row__total { display: grid; justify-items: end; line-height: 1.3; text-align: end; }
  .order-row__total strong { font-weight: var(--fw-semibold); }
  .order-row__total del { color: var(--text-muted); font-weight: var(--fw-regular); }
  .order-row__total ins { text-decoration: none; }
  .order-row__total span { color: var(--text-muted); font-size: var(--fs-xs); }
  .order-row__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); grid-column: 1 / -1; }

  .order-thumbs { display: flex; align-items: center; }
  .order-thumbs img,
  .order-thumbs__more { width: 40px; height: 50px; border: 2px solid var(--surface); border-radius: var(--radius-sm); background: var(--surface-3); object-fit: cover; }
  .order-thumbs > * + * { margin-inline-start: -10px; }
  .order-thumbs__more { display: grid; place-items: center; background: var(--surface-2); color: var(--text-soft); font-size: var(--fs-2xs); font-weight: var(--fw-medium); }

  @container (max-width: 559px) {
    .order-row .order-thumbs { grid-row: 2; grid-column: 1; }
    .order-row__actions { grid-row: 2; grid-column: 2; align-self: end; }
    .order-row:not(:has(.order-thumbs)) .order-row__actions { grid-column: 1 / -1; justify-content: flex-start; }
  }

  @container (min-width: 560px) {
    .order-row { grid-template-columns: minmax(0, 1fr) auto auto; }
    .order-row__actions { grid-column: 1 / -1; }
  }

  @container (min-width: 820px) {
    .order-row { grid-template-columns: minmax(0, 1fr) auto 9rem auto; }
    .order-row__actions { grid-column: auto; flex-wrap: nowrap; }
  }

  .order-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.2em 0.7em;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    line-height: 1.5;
    white-space: nowrap;
  }

  .order-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .order-status--success { background: color-mix(in oklch, var(--success) 13%, var(--surface)); color: var(--success); }
  .order-status--warning { background: color-mix(in oklch, var(--warning) 13%, var(--surface)); color: var(--warning); }
  .order-status--info { background: color-mix(in oklch, #2f5f86 12%, var(--surface)); color: #2f5f86; }
  .order-status--error { background: var(--coral-50); color: var(--coral-700); }
  .order-status--muted { color: var(--text-muted); }

  .account-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); }
  .account-pager__info { color: var(--text-muted); font-size: var(--fs-sm); }

  .account-empty {
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    padding: var(--space-8) var(--space-5);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    text-align: center;
  }

  .account-empty h2 { margin: 0; font-family: var(--font-serif); font-size: var(--fs-lg); font-weight: var(--fw-regular); }
  .account-empty p { margin: 0; color: var(--text-soft); max-width: 42ch; }
  .account-empty__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); color: var(--coral-700); }
  .account-empty__icon .icon { --icon-size: 26px; }

  /* ------------------------------------------------------------------------
     One order
     ------------------------------------------------------------------------ */
  .order-view { display: grid; gap: var(--space-5); }
  .order-view__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .order-view__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: 0; color: var(--text-soft); font-size: var(--fs-sm); }
  .order-view__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .order-view__grid { display: grid; gap: var(--space-5); align-items: start; }
  .order-view__side { display: grid; gap: var(--space-5); min-width: 0; }
  .order-view .form-card { display: grid; gap: var(--space-4); }
  .order-view__back { margin: 0; }

  @container (min-width: 760px) {
    .order-view__grid { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
  }

  .order-view__after { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  .order-view__after p { margin: 0; }
  .order-view__after .button {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.5em 1.2em;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    color: var(--text);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    text-decoration: none;
  }
  .order-view__after .button:hover { border-color: var(--text); background: var(--text); color: var(--paper); }

  .account-address { display: grid; gap: 2px; margin: 0; color: var(--text-soft); font-size: var(--fs-sm); font-style: normal; line-height: 1.6; }
  .account-address__line { display: flex; align-items: center; gap: 0.5em; margin-block-start: var(--space-1); }
  .account-address__line:first-of-type { margin-block-start: var(--space-3); }
  .account-address__empty { color: var(--text-muted); }
  .account-address__sub { margin: 0; font-size: var(--fs-sm); font-weight: var(--fw-semibold); }

  .order-updates { display: grid; gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
  .order-updates__item { display: grid; gap: var(--space-1); margin: 0; padding-inline-start: var(--space-4); border-inline-start: 2px solid var(--coral-200); }
  .order-updates__item time { color: var(--text-muted); font-size: var(--fs-xs); }
  .order-updates__text { font-size: var(--fs-sm); }
  .order-updates__text p { margin: 0; }

  /* ------------------------------------------------------------------------
     Addresses, forms
     ------------------------------------------------------------------------ */
  .account-intro { margin: 0; color: var(--text-soft); }

  .account-addresses { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--space-4); }
  .account-address-card { display: grid; gap: var(--space-4); align-content: start; }
  .account-address-card__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
  .account-address-card .checkout-card__title { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--fs-lg); }
  .account-address-card .checkout-card__title .icon { color: var(--coral-700); }

  .account-forms { display: grid; gap: var(--space-5); }
  .account-form .checkout-card__title { margin-block-end: var(--space-5); }
  .account-forms > .form-actions,
  .account-form .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }

  /* ------------------------------------------------------------------------
     Signed out: login / register, lost + reset password
     ------------------------------------------------------------------------ */
  .account-guest .section--tight { padding-block: var(--space-6) var(--section-space-sm); }
  .account-guest > .woocommerce > :is(.woocommerce-notices-wrapper, .woocommerce-error, .woocommerce-message, .woocommerce-info):not(:empty) {
    max-width: calc(var(--container-max) + 2 * var(--gutter));
    margin: var(--space-6) auto 0;
    padding-inline: var(--gutter);
  }
  .account-auth { display: grid; gap: var(--space-5); align-items: start; max-width: 480px; margin-inline: auto; }
  .account-auth--2 { max-width: 980px; }
  @media (min-width: 860px) {
    .account-auth--2 { grid-template-columns: 1fr 1fr; }
  }
  .account-auth .form-card { display: grid; gap: var(--space-4); }
  .account-auth .checkout-card__title { margin: 0; }
  .account-auth .woocommerce-privacy-policy-text p { margin: 0; color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.5; }
  .account-perks { display: grid; gap: var(--space-2); margin: 0; padding: 0; color: var(--text-soft); font-size: var(--fs-sm); list-style: none; }
  .account-perks li { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
  .account-perks .icon { flex: none; color: var(--success); }

  .account-narrow { max-width: 480px; margin-inline: auto; }
  .account-narrow .form-card { display: grid; gap: var(--space-4); }
  .account-narrow .checkout-card__title { margin: 0; }
  .account-narrow .form-success { justify-items: start; padding: clamp(var(--space-5), 4vw, var(--space-7)); }
}
