/* ==========================================================================
   person.css — F1 Person page (?person=<Name>&role=<role>)
   Tokens only (see tokens.css). No hex colors.
   ========================================================================== */

.pp-view {
  min-height: calc(100dvh - var(--header-h));
}

/* ---- Sticky back bar ---- */
.pp-bar {
  justify-content: flex-start;
  gap: var(--space-3);
}

.pp-back {
  margin-left: calc(var(--space-2) * -1);
}

.pp-bar__title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  flex: 1 1 auto;
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: var(--text-1);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}

.pp-bar.is-condensed .pp-bar__title {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.pp-bar__count {
  flex: none;
  font-size: var(--fs-12);
  font-weight: var(--fw-regular);
  color: var(--text-3);
}

/* ---- Body & Hero ---- */
.pp-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-6) var(--space-16);
}

.pp-body--empty {
  padding: var(--space-8) var(--space-6);
}

.pp-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--hairline);
}

.pp-hero__main {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
  flex: 1 1 320px;
}

.pp-avatar {
  --avatar-size: 88px;
  font-size: var(--fs-28);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.pp-hero__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  flex: 1 1 auto;
}

.pp-title {
  font-size: var(--fs-28);
  line-height: var(--lh-28);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-display);
  color: var(--text-1);
}

.pp-meta {
  font-size: var(--fs-14);
  color: var(--text-2);
}

/* ---- Seen progress ---- */
.pp-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 320px;
  margin-top: var(--space-1);
}

.pp-progress__text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  color: var(--text-2);
}

.pp-progress__main strong {
  color: var(--text-1);
  font-weight: var(--fw-semibold);
}

.pp-progress__sub {
  color: var(--text-3);
}

.pp-progress__bar {
  height: 6px;
  width: 100%;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.pp-progress__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--dur-base) var(--ease);
}

/* ---- Actions ---- */
.pp-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

.pp-play-all__count {
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--on-accent) 18%, transparent);
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
}

/* ---- Sections & Toolbar ---- */
.pp-section {
  min-width: 0;
  scroll-margin-top: calc(var(--header-h) + var(--filterbar-h) + var(--space-4));
}

.pp-h {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.pp-count {
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

.pp-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.pp-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.pp-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.pp-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* ---- Unknown person suggestions ---- */
.pp-suggestions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  max-width: 560px;
  margin: 0 auto;
  text-align: center;
}

.pp-suggestions__title {
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

.pp-suggestions__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

/* ---- Skeletons ---- */
.pp-skel-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  flex: none;
}

.pp-skel-title {
  width: 220px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.pp-skel-line {
  height: 12px;
}

/* ---- Desktop default for mobile elements ---- */
.pp-bar__share {
  display: none;
}

.pp-toolbar__sep {
  display: none;
}

.pp-sort-btn,
button.chip.pp-sort-btn {
  display: none;
}

/* ---- Mobile (≤ 899 px or coarse landscape) ---- */
@media (max-width: 899px), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .pp-body {
    gap: var(--space-5);
    padding: var(--space-3) var(--space-4) calc(var(--tabbar-total, 64px) + var(--space-6));
  }

  .pp-view .view__header.pp-bar,
  body.layout-stacked .view__header.pp-bar {
    position: sticky;
    top: var(--dock-h, 0px);
    z-index: var(--z-sticky);
    height: var(--appbar-h, 52px);
    min-height: 52px;
    padding: 0 var(--space-3);
    justify-content: space-between;
    background: transparent;
    border-bottom: 1px solid transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: background-color var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
  }

  .pp-view .view__header.pp-bar.is-condensed,
  body.layout-stacked .view__header.pp-bar.is-condensed {
    background: var(--surface-1);
    border-bottom: 1px solid var(--hairline);
  }

  .pp-back,
  .pp-bar__share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin-left: 0;
    padding: 0;
    overflow: hidden;
    border-radius: var(--radius-full);
    background: color-mix(in srgb, var(--bg) 68%, transparent);
    border: 1px solid var(--border);
    color: var(--text-1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .pp-back__label {
    display: none;
  }

  .pp-bar__title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    justify-content: center;
    text-align: center;
    font-size: var(--fs-14);
    font-weight: var(--fw-semibold);
  }

  .pp-bar__title .truncate {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .pp-view .sr-only {
    overflow: hidden;
  }

  /* §8 Person page header: 96px photo, name 24px/600, roles and stats; Play all (amber) */
  .pp-hero {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
  }

  .pp-hero__main {
    align-items: center;
    gap: var(--space-4);
    flex: none;
  }

  .pp-avatar,
  .pp-skel-avatar {
    --avatar-size: 96px;
    width: 96px;
    height: 96px;
    font-size: var(--fs-28);
  }

  .pp-title {
    font-size: 1.5rem;
    line-height: 1.875rem;
    font-weight: var(--fw-semibold);
  }

  .pp-meta {
    gap: 4px 0;
  }

  .pp-meta > * + *::before {
    content: none;
  }

  .pp-meta > *:not(:last-child)::after {
    content: '\00a0·';
    margin-right: 6px;
    color: var(--text-3);
  }

  .pp-actions {
    width: 100%;
    display: flex;
    gap: var(--space-2);
  }

  .pp-play-all {
    flex: 1 1 auto;
    min-height: 48px;
    justify-content: center;
    font-size: var(--fs-14);
  }

  .pp-share {
    min-width: 48px;
    min-height: 48px;
    padding: 0 var(--space-3);
    justify-content: center;
  }

  /* §8 Sticky role tabs (top: var(--dock-h) + var(--appbar-h)), single horizontal scrolling row (~53px tall) */
  .pp-toolbar {
    position: sticky;
    top: calc(var(--dock-h, 0px) + var(--appbar-h, 52px));
    z-index: calc(var(--z-sticky) - 1);
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--space-2);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    margin: 0 calc(-1 * var(--space-4)) var(--space-4);
    padding: 6px var(--space-4);
    background: var(--surface-1);
    border-bottom: 1px solid var(--hairline);
    -webkit-mask-image: linear-gradient(to right, var(--text-1) calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, var(--text-1) calc(100% - 24px), transparent 100%);
  }

  .pp-toolbar::-webkit-scrollbar {
    display: none;
  }

  .pp-tabs,
  .pp-controls,
  .pp-toggles {
    display: contents;
  }

  .pp-toolbar__sep {
    display: block;
    flex: none;
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 2px;
  }

  .pp-tab,
  .pp-toggle {
    position: relative;
    height: 40px;
    min-height: 40px;
    min-width: 44px;
    padding: 0 var(--space-3);
    font-size: var(--fs-12);
    flex: none;
  }

  .pp-tab::before,
  .pp-toggle::before,
  .pp-sort-btn::before,
  button.chip.pp-sort-btn::before {
    content: '';
    position: absolute;
    inset: -2px 0;
    min-height: 44px;
  }

  .pp-sort {
    display: none;
  }

  .pp-sort-btn,
  button.chip.pp-sort-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    min-height: 40px;
    min-width: 44px;
    padding: 0 var(--space-3);
    flex: none;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--surface-1);
    color: var(--text-1);
    font-size: var(--fs-12);
    line-height: var(--lh-12);
    font-weight: var(--fw-medium);
    white-space: nowrap;
  }

  .pp-sort-btn__prefix {
    color: var(--text-2);
  }

  /* §8 Grid: 3 columns with merged role initials */
  .pp-grid .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3) var(--space-2);
  }

  .pp-suggest {
    min-height: 44px;
    min-width: 44px;
  }

  @media (min-width: 600px) {
    .pp-hero {
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
    }

    .pp-actions {
      width: auto;
    }

    .pp-grid .grid {
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: var(--space-4) var(--space-3);
    }
  }
}
