/* Public creator profile, page-scoped under .creator-profile. Laid out like a
 * social profile: one narrow column, a header of identity and counts, then a tight
 * square grid of work. The grid is the page; everything else stays quiet.
 * Tokens live in tokens.css (loaded via base.html).
 *
 * The circular avatars are the one deliberate exception to radius-0 in the design
 * system: a round face over a square grid is what makes this layout read as a profile.
 */

.creator-profile {
  /* No background: body paints it, and a second coat would cover the motif. */
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  max-width: 935px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 32px 0 64px;
}

/* ---------- Header ---------- */
.cp-head {
  display: grid;
  grid-template-columns: 290px 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 8px;
  row-gap: 20px;
  padding: 0 16px 44px;
}

.cp-head__avatar {
  grid-row: 1 / 4;
  justify-self: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-subtle);
  display: grid;
  place-items: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.cp-head__avatar img,
.cp-related__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cp-head__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.cp-head__handle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.cp-head__handle i { color: var(--blue-ink); font-size: 1.125rem; }

.cp-head__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cp-head__actions .ds-btn {
  height: 44px;
  padding: 0 20px;
  white-space: nowrap;
}

.cp-head__note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.cp-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.875rem;
  cursor: not-allowed;
}

.cp-head__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 40px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
}

.cp-head__stats strong {
  color: var(--text-primary);
  font-weight: 600;
}

.cp-head__bio {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  line-height: 1.5;
  max-width: 60ch;
}

.cp-head__bio p { margin: 0; }

.cp-head__name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.cp-head__top-creator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--copper-ink);
}

.cp-head__cats,
.cp-head__meta { color: var(--text-secondary); }

.cp-head__text {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.cp-head__bio .cp-head__socials {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 1.25rem;
  color: var(--text-secondary);
}

/* ---------- Tabs: radio buttons, so no script is involved ---------- */
.cp-tab-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.cp-tabs {
  display: flex;
  justify-content: center;
  gap: 56px;
  border-top: 1px solid var(--border-subtle);
}

.cp-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  /* Sits on the rule above, so the active tab's line replaces that stretch of it. */
  margin-top: -1px;
  border-top: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .cp-tab:hover { color: var(--text-primary); }
}

#cp-tab-work:checked ~ .cp-tabs .cp-tab--work,
#cp-tab-packages:checked ~ .cp-tabs .cp-tab--packages {
  border-top-color: var(--text-primary);
  color: var(--text-primary);
}

#cp-tab-work:checked ~ .cp-panel--packages,
#cp-tab-packages:checked ~ .cp-panel--work { display: none; }

#cp-tab-work:focus-visible ~ .cp-tabs .cp-tab--work,
#cp-tab-packages:focus-visible ~ .cp-tabs .cp-tab--packages,
.cp-related__card:focus-visible {
  outline: 2px solid var(--copper-ink);
  outline-offset: 2px;
}

/* ---------- Grid of work ---------- */
/* Above the fixed motif layer, which would otherwise tint people's work and faces. */
.cp-grid,
.cp-head__avatar,
.cp-related__avatar {
  position: relative;
  z-index: 1;
}

.cp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.cp-tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-subtle);
  color: inherit;
}

.cp-tile img,
.cp-tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cp-tile:focus-visible {
  outline: 2px solid var(--copper-ink);
  outline-offset: -2px;
}

.cp-tile__play {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #FFFFFF;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.8));
}

.cp-tile__title {
  position: absolute;
  inset: auto 0 0;
  padding: 12px;
  background: rgb(0 0 0 / 0.72);
  color: #FFFFFF;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease-lux);
}

/* Touch has no hover: there, the viewer is where a piece's title shows. */
.cp-tile:focus-visible .cp-tile__title { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .cp-tile:hover .cp-tile__title { opacity: 1; }
}

/* A row with no file yet, as on the demo profile. */
.cp-tile--empty {
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--text-tertiary);
  font-size: 0.875rem;
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---------- The whole piece, opened from a tile ---------- */
.cp-viewer[open] {
  display: flex;
  flex-direction: column;
}

.cp-viewer {
  width: min(935px, 100vw);
  max-width: 100vw;
  max-height: 100dvh;
  padding: 0;
  border: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.cp-viewer::backdrop { background: rgb(0 0 0 / 0.85); }

.cp-viewer img,
.cp-viewer video {
  /* Takes what the close button and title leave, whatever the title's length. */
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  background: #000000;
}

.cp-viewer form {
  flex: none;
  display: flex;
  justify-content: flex-end;
}

.cp-viewer__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}

.cp-viewer__close:focus-visible {
  outline: 2px solid var(--copper-ink);
  outline-offset: -2px;
}

.cp-viewer__title {
  flex: none;
  margin: 0;
  padding: 12px 16px;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

/* ---------- Packages ---------- */
.cp-packages {
  margin: 0 auto;
  padding: 0 16px;
  list-style: none;
  max-width: 640px;
}

.cp-package {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.cp-package:last-child { border-bottom: 0; }

.cp-package__body {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cp-package__icon {
  font-size: 1.5rem;
  color: var(--text-secondary);
}

.cp-package__title {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
}

.cp-package__summary,
.cp-package__meta {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.cp-package__price {
  margin: 0;
  font-weight: 600;
  white-space: nowrap;
}

.cp-empty {
  margin: 0;
  padding: 64px 16px;
  text-align: center;
  color: var(--text-secondary);
}

/* ---------- Similar creators ---------- */
.cp-related {
  margin-top: 56px;
  padding: 0 16px;
}

.cp-related__title {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 600;
}

.cp-related__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cp-related__card {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  align-items: center;
  gap: 2px;
  padding: 16px 8px;
  border: 1px solid var(--border-subtle);
  color: inherit;
  text-align: center;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .cp-related__card:hover { border-color: var(--border-hover); }
}

.cp-related__avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-subtle);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.cp-related__name {
  max-width: 100%;
  font-size: 0.875rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cp-related__loc {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* ---------- Phone: the header's lower half drops to full width ---------- */
@media (max-width: 735px) {
  .creator-profile { padding-top: 16px; }

  .cp-head {
    grid-template-columns: 77px 1fr;
    grid-template-rows: auto;
    column-gap: 20px;
    row-gap: 16px;
    padding-bottom: 20px;
  }

  .cp-head__avatar {
    grid-row: auto;
    width: 77px;
    height: 77px;
    font-size: 2rem;
  }

  .cp-head__top { flex-direction: column; align-items: stretch; }
  .cp-head__actions { flex-wrap: wrap; }
  .cp-head__actions > * { flex: 1 1 auto; justify-content: center; }

  .cp-head__stats {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-content: space-around;
    gap: 8px 16px;
    margin: 0 -16px;
    padding: 12px 16px 0;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.875rem;
    text-align: center;
  }

  .cp-head__bio { grid-column: 1 / -1; grid-row: 2; }

  .cp-tabs { gap: 40px; }
  .cp-grid { gap: 2px; }
  .cp-related__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .cp-tile__title { transition: none; }
}
