/* Profile dock: athlete header and aggregate statistics — plus the chrome the
   Strava import feature adds to the Saved Routes dock, since the two ship together.
   Mirrors .route-library-dock — same slot above the map, same glass tokens from
   styles/main.css, same show/hide transition — so the two docks feel like one
   surface that swaps content. */

/* index.html links this file but not the two stylesheets the Strava feature also
   ships (the brand mark, and the browser mounted into the library), and index.html
   is hand-edited. Pulling them in here keeps that UI styled without a second
   <link>; drop these two lines if index.html ever grows them. */
@import url('./strava-brand.css?v=20260805-auth-v1');
@import url('./strava-browser.css?v=20260805-auth-v1');

.profile-panel-dock {
  width: 100%;
  max-width: min(1100px, calc(100vw - 32px));
  margin-inline: auto;
  background: var(--glass-surface-strong);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--glass-shadow);
  color: #fff;
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  z-index: 90;
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  max-height: 0;
  margin-bottom: 0;
  overflow: hidden;
  transform: translateY(30px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.5s;
}

.profile-panel-dock.visible {
  opacity: 1;
  visibility: visible;
  max-height: 72vh;
  margin-bottom: 12px;
  transform: translateY(0);
}

.profile-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--glass-border);
}

.profile-panel__title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.profile-panel__close {
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.profile-panel__close:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--glass-border-strong);
}

.profile-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* --- Athlete header --- */

.profile-athlete {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.profile-athlete__identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 240px;
}

.profile-athlete__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.profile-athlete__text {
  min-width: 0;
}

.profile-athlete__name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-athlete__place {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

.profile-athlete__actions {
  display: flex;
  gap: 10px;
}

/* Required by Strava's brand guidelines on any view showing their data. The mark
   itself is sized by styles/strava-brand.css; nothing here may restate the wording
   — no text-transform, since "Powered by Strava" is a trademark we quote verbatim. */
.profile-strava-attribution {
  margin: 0;
  flex-basis: 100%;
}

.profile-strava-attribution__link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.profile-strava-attribution__link:hover {
  text-decoration: underline;
}

/* --- Buttons --- */

.profile-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-surface);
  backdrop-filter: blur(var(--glass-blur));
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.profile-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--glass-border-strong);
}

.profile-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.profile-btn:focus-visible {
  outline: 2px solid #f8b40b;
  outline-offset: 2px;
}

.profile-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* display: inline-flex above would otherwise beat the UA rule for [hidden]. */
.profile-btn[hidden] {
  display: none;
}

.profile-btn--danger {
  color: #ff9b8a;
}

/* --- Aggregates --- */

.profile-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  background: rgba(255, 255, 255, 0.04);
}

.profile-stat__value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}

.profile-stat__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
}

.profile-sports {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-sports__item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.profile-sports__count {
  color: rgba(255, 255, 255, 0.55);
  font-variant-numeric: tabular-nums;
}

.profile-sports__distance {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.profile-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  background: rgba(255, 255, 255, 0.04);
}

.profile-chart__caption {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
}

.profile-chart__svg {
  width: 100%;
  height: 72px;
  display: block;
}

/* --- Where the imports moved to --- */

/* One line and one button, laid out like the athlete row above it so the panel
   still reads as three stacked sections rather than a leftover. */
.profile-import-hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  background: rgba(252, 76, 2, 0.1);
}

.profile-import-hint__text {
  margin: 0;
  flex: 1 1 240px;
  font-size: 13px;
  line-height: 1.5;
}

/* --- Saved Routes: library tabs and import sources --- */

/* The row between the library header and the cards: what to look at on the left,
   where new tracks come from on the right. Sits outside .library-content so the
   horizontal card strip keeps scrolling on its own. */
.library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px 0;
}

.library-toolbar[hidden] {
  display: none;
}

/* Two lists, one strip of cards: a segmented control rather than two docks, so the
   search box and every card action stay shared. */
.library-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--glass-surface);
  backdrop-filter: blur(var(--glass-blur));
}

.library-tab {
  appearance: none;
  padding: 6px 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

/* The selected tab keeps its own background under the pointer: hovering what is
   already open must not read as "not selected". */
.library-tab:hover:not([aria-selected='true']) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.library-tab:focus-visible {
  outline: 2px solid #f8b40b;
  outline-offset: 2px;
}

.library-tabs .library-tab[aria-selected='true'] {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--glass-border-strong);
  color: #fff;
}

/* Only filled when the host page has no header actions for the Strava source to
   sit next to, so it must take no room in the common case. */
.library-sources {
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-sources:empty {
  display: none;
}

/* Sits next to the round "Import GPX" icon in the library header: same glass, but
   wider because it carries a word, and orange once it is the active source. */
.library-source-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.library-source-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.library-source-btn.active {
  background: rgba(252, 76, 2, 0.9);
  border-color: #fc4c02;
}

/* The Strava browser's slot. It replaces the card strip rather than sitting under
   it — the dock has one content area, and two scrollers in it would fight. */
.library-strava-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.library-strava-panel[hidden] {
  display: none;
}

.profile-empty {
  margin: 0;
  padding: 24px 12px;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 640px) {
  .profile-panel-dock {
    max-width: 100%;
    border-radius: var(--glass-radius);
  }

  .profile-panel-dock.visible {
    max-height: 80vh;
  }

  .profile-panel__body {
    padding: 16px;
    gap: 18px;
  }

  .profile-athlete__actions {
    width: 100%;
  }

  .profile-import-hint {
    align-items: stretch;
    flex-direction: column;
  }

  .library-toolbar {
    padding: 10px 16px 0;
  }

  /* One thumb, two targets: the switch takes the full width and splits it, and both
     halves grow to the 44px the rest of the mobile sheet uses. */
  .library-tabs {
    flex: 1 1 100%;
  }

  .library-tab {
    flex: 1 1 0;
    min-height: 40px;
  }

  .library-source-btn {
    height: 44px;
    border-radius: 12px;
  }

  .library-strava-panel {
    padding: 12px 16px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .profile-panel-dock {
    transition: none;
  }
}
