/* profile/responsive.css - MUST load last in the profile cascade so it wins. */

/* below 1440 the header stacks into one centred column; display:contents
   flattens the info wrappers so children reorder via `order` */
@media (max-width: 1440px) {
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* per-block margins below; gap mis-spaces because order + display:contents
       make the visually-adjacent badges/meta non-DOM-adjacent */
    gap: 0;
  }

  .profile-info,
  .profile-info-left-col,
  .profile-info-right-col,
  .bio-edit {
    display: contents;
  }

  /* reset desktop flex-grow so stacked blocks don't expand vertically and collide */
  .profile-avatar-container,
  .profile-username,
  .bio-edit,
  .profile-meta,
  .profile-badges {
    flex: 0 0 auto;
  }

  .profile-avatar-container {
    order: 0;
    justify-content: center;
  }
  .profile-avatar {
    width: 180px;
  }

  .profile-username {
    order: 1;
    justify-content: center;
    text-align: center;
    margin-top: 28px;
  }

  .profile-bio {
    order: 2;
    padding-top: 0;
    max-width: 600px;
    margin-top: 14px;
  }

  .profile-badges {
    order: 3;
    width: 100%;
    min-height: 0;
    margin-top: 44px;
  }

  .profile-meta {
    order: 4;
    align-items: center;
    min-height: 0;
    gap: 18px;
    margin-top: 44px;
  }
  .profile-meta > p {
    text-align: center;
    margin: 0;
  }

  .view-badges-container {
    margin-top: 0;
  }
}

@media (max-width: 1024px) {
  .profile-main {
    padding: 16px 16px 64px;
  }

  .badge-tooltip {
    display: none;
  }

  .collections-row {
    column-gap: 32px;
  }
}

@media (max-width: 768px) {
  .profile-header {
    gap: 18px;
  }

  .profile-avatar {
    width: 128px;
  }

  .profile-username {
    font-size: 30px;
  }

  .prog-badges-header {
    font-size: 28px;
  }

  .profile-badges {
    gap: 30px;
  }

  .badges-display {
    gap: 22px;
  }

  .new-collection-btn,
  .view-badges-btn {
    max-width: 340px;
  }

  .collection-name {
    font-size: 16px;
  }

  .collection-stats {
    font-size: 15px;
    padding: 8px 4px;
  }

  .collection-stats .stat-icon {
    width: 18px;
    height: 18px;
  }

  .collections-stats-left {
    gap: 18px;
  }

  .collections-stats-left > * {
    gap: 5px;
  }
}

/* condense the header into a compact identity block: avatar beside name+bio on
   row 1, badges + meta full-width below. wrappers stay display:contents (from the
   <=1440 rule) so children place by grid area; the right-hand text column is
   restored to a real box so name + bio stack inside it. */
@media (max-width: 1440px) {
  .profile-header {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "avatar identity"
      "badges badges"
      "meta meta";
    align-items: start;
    column-gap: 16px;
    row-gap: 22px;
    text-align: left;
  }

  .profile-avatar-container {
    grid-area: avatar;
    justify-content: center;
  }
  .profile-avatar {
    width: 92px;
  }
  .avatar-pic {
    border-width: 4px;
  }
  .upload-new-pic {
    width: 32px;
    top: -2px;
    right: -2px;
  }

  .profile-info-right-col {
    grid-area: identity;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    padding-left: 0;
    text-align: left;
    min-width: 0;
  }
  .profile-username {
    order: 0;
    margin-top: 0;
    min-height: 0;
    text-align: left;
    font-size: 22px;
  }
  .bio-edit {
    display: block; /* re-anchor the absolute edit button (was display:contents) */
    position: relative;
    padding-top: 0;
  }
  .profile-bio {
    order: 0;
    margin-top: 0;
    text-align: left;
    font-size: 15px;
    padding-right: 32px; /* clear of the edit button top-right */
  }
  .bio-edit-btn {
    width: 28px;
    height: 28px;
    top: 0;
    right: 0;
    border-radius: 6px;
  }
  .bio-edit-btn img {
    width: 14px;
    height: 14px;
  }

  /* badges band: own grid so View All rides the heading's row, shields on row 2 */
  .profile-badges {
    grid-area: badges;
    display: grid;
    grid-template-columns: minmax(0, max-content) 1fr;
    align-items: center;
    column-gap: 12px;
    row-gap: 14px;
    margin-top: 0;
    width: 100%;
  }
  .prog-badges-header {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
    text-align: left;
    white-space: normal;
    font-size: 22px; /* match the username */
  }
  .view-badges-container {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
    width: auto;
    margin-top: 0;
  }
  .badges-display {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-evenly;
    gap: 0;
  }
  /* the 0x0 gradient-defs svg is also a grid child; park it on a 0-height row */
  .badge-gradient-defs {
    grid-column: 1;
    grid-row: 3;
  }
  .badge-shield {
    flex: 0 0 92px; /* fixed size so space-evenly can spread them */
    width: 92px;
    max-width: 92px;
  }
  .badge-shield svg {
    max-width: 92px;
  }
  .badge-title {
    font-size: 8px;
    line-height: 1.2;
    letter-spacing: 0.2px;
    width: 76%;
  }

  .profile-meta {
    grid-area: meta;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 0;
    gap: 12px;
  }
  .profile-meta > p {
    text-align: left;
    margin: 0;
    font-size: 18px;
  }

  /* identical button pair: same font/padding/width (border-box) */
  .view-badges-btn,
  .new-collection-btn {
    box-sizing: border-box;
    width: 150px;
    max-width: none;
    font-size: 14px;
    padding: 9px 8px;
    border-radius: 10px;
  }
  .new-collection-btn {
    gap: 6px;
    justify-content: center;
  }
  .new-collection-btn img {
    width: 14px;
    height: 14px;
  }
  .new-collection-btn span {
    flex: 0 0 auto;
  }
}

/* phone: one full-width card per row with a horizontal banner cover */
@media (max-width: 600px) {
  .collections-row {
    grid-template-columns: 1fr;
    column-gap: 0;
    padding-top: 8px;
  }

  .collection-card {
    margin-bottom: 0;
  }

  /* buildCollectionCover swaps the layout class; here we only reshape the box */
  .collection-cover {
    aspect-ratio: 5 / 2;
  }
}
