/* ============================================================
   Community browser
   Three views (registry → repo → workout) sharing one shell.
   Inherits typography + tokens from ../styles.css.
   ============================================================ */

.community-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s-7) var(--s-5) var(--s-10);
}

/* ─── Breadcrumbs ─────────────────────────────────────────── */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-3);
  margin-bottom: var(--s-5);
  min-height: 16px;
}
.crumbs a {
  color: var(--fg-2);
  text-decoration: none;
  border-bottom: 1px dotted var(--line-3);
}
.crumbs a:hover { color: var(--fg-1); }
.crumbs span.sep { color: var(--fg-4); }

.view { animation: fade-in 200ms var(--ease-out); }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-title {
  font-weight: 800;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1;
  letter-spacing: -0.03em;
  margin: var(--s-2) 0 var(--s-4);
  color: var(--fg-1);
}

/* Page header row - title on the left, secondary action (Publish your own)
   on the right. Stacks on narrow screens so the title doesn't get squeezed. */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.page-head > div { flex: 1 1 auto; min-width: 0; }
.head-action {
  flex: 0 0 auto;
  align-self: flex-end;
  margin-bottom: var(--s-4);
  font-weight: 700;
  font-size: 13px;
  color: var(--fg-1);
  text-decoration: none;
  padding: 9px 16px;
  border: 1px solid var(--line-3);
  border-radius: var(--r-pill);
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.head-action:hover {
  color: var(--fg-2);
  border-color: var(--fg-1);
}
.head-action .arrow { display: inline-block; margin-left: 4px; }
.page-lead {
  font-size: 16px;
  color: var(--fg-2);
  max-width: 60ch;
  margin: 0 0 var(--s-7);
}

/* ─── Status / state blocks ───────────────────────────────── */
.status {
  border: 1px dashed var(--line-3);
  border-radius: var(--r-md);
  padding: var(--s-6);
  text-align: center;
  color: var(--fg-3);
  background: var(--bg-1);
}
.status.is-error {
  border-color: rgba(239,107,98,0.45);
  background: rgba(239,107,98,0.10);
  color: var(--danger);
}
.status .status-action { margin-top: var(--s-3); }

/* ─── Repository grid ─────────────────────────────────────── */
.repo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-4);
}
.repo-card {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-decoration: none;
  color: inherit;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.repo-card, .workout-card, .route-card {
  transition: transform var(--dur-base) var(--ease-out),
              background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.repo-card:hover, .workout-card:hover, .route-card:hover { transform: translateY(-3px); }
.repo-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-3);
}
.repo-card h3 {
  font-weight: 800;
  font-size: 24px;
  line-height: 1.1;
  margin: 0;
  color: var(--fg-1);
}
.repo-card p { margin: 0; color: var(--fg-2); font-size: 14px; line-height: 1.5; }
.repo-card .author { color: var(--fg-3); font-size: 12px; }
.repo-card .repo-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}
.tag-chip {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  color: var(--fg-3);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

/* ─── Repo detail: meta line + workout grid ───────────────── */
.repo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
  font-size: 13px;
  color: var(--fg-3);
  margin: 0 0 var(--s-7);
}
.repo-meta a { color: var(--fg-1); text-decoration: none; border-bottom: 1px dotted var(--line-3); }
.repo-meta a:hover { color: var(--fg-2); }

.workout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s-4);
}
.workout-card {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-decoration: none;
  color: inherit;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.workout-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-3);
}
.workout-card h3 {
  font-weight: 800;
  font-size: 22px;
  margin: 0;
  color: var(--fg-1);
  line-height: 1.1;
}
.workout-card .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin: 0;
}
.workout-bar {
  display: flex;
  height: 24px;
  border-radius: var(--r-pill);
  overflow: hidden;
  gap: 1px;
  background: var(--bg-0);
}
.workout-bar > div { height: 100%; }
.workout-card .workout-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ─── Workout detail ──────────────────────────────────────── */
.workout-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-6);
}
@media (min-width: 760px) {
  .workout-detail { grid-template-columns: 1.5fr 1fr; }
}
.detail-chart {
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: var(--s-5);
}
.detail-chart-bar {
  display: flex;
  align-items: flex-end;
  height: 220px;
  gap: 1px;
  background: var(--bg-0);
  border-radius: var(--r-sm);
  padding: 4px;
}
.detail-chart-bar > div { border-radius: 4px 4px 0 0; min-width: 2px; }
.detail-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin-top: 6px;
}
.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-5);
}
.detail-stat {
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.detail-stat .stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
}
.detail-stat .stat-value {
  font-weight: 800;
  font-size: 28px;
  color: var(--fg-1);
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
.detail-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}
.detail-actions .btn { width: 100%; }
.detail-side h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  margin: var(--s-2) 0 0;
}

/* Step list - same vibe as the editor's segment rows. */
.detail-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-step {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--fg-2);
}
.detail-step .step-rail {
  width: 4px;
  height: 22px;
  border-radius: 2px;
}
.detail-step .step-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  white-space: nowrap;
}

/* ─── Contribute CTA on the registry view ─────────────────── */
.contribute-cta {
  margin-top: var(--s-7);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line-1);
  text-align: center;
  font-size: 14px;
  color: var(--fg-3);
}
.contribute-cta a {
  color: var(--fg-1);
  text-decoration: none;
  border-bottom: 1px dotted var(--line-3);
}
.contribute-cta a:hover { color: var(--fg-2); }

/* ─── Skeleton placeholder while fetching ─────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-1) 100%);
  background-size: 200% 100%;
  animation: shimmer 1400ms linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Routes ─────────────────────────────────────────────────────────────
   A route card carries a shape and a profile rather than a zone bar: what a
   rider is choosing between is roads, and the two thumbnails are the fastest
   way to tell one road from another. Both come from the listing, so a grid of
   fifty of them still costs one small JSON and no GPX at all. */

.section-head {
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  margin: var(--s-6, 24px) 0 var(--s-3, 12px);
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s-4, 16px);
}

.route-card {
  display: flex;
  gap: var(--s-3, 12px);
  align-items: flex-start;
  padding: var(--s-4, 16px);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md, 12px);
  background: var(--bg-1);
  text-decoration: none;
  transition: border-color 120ms ease, transform 120ms ease;
}

.route-card:hover {
  border-color: var(--line-3);
  transform: translateY(-1px);
}

.route-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--fg-1);
}

.route-card-body { min-width: 0; flex: 1; }

.route-place {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--fg-3);
}

.route-card .meta {
  margin: var(--s-2, 8px) 0 var(--s-2, 8px);
  font-size: 0.82rem;
  color: var(--fg-2);
}

.route-shape {
  flex: 0 0 auto;
  width: 96px;
  height: 64px;
  background: var(--bg-2);
  border-radius: var(--r-sm, 8px);
}

.spark { display: block; width: 100%; height: auto; }

/* ── Route detail ─────────────────────────────────────────────────────── */
.route-detail-graphics {
  display: flex;
  gap: var(--s-4, 16px);
  flex-wrap: wrap;
  align-items: stretch;
  margin-bottom: var(--s-4, 16px);
}

.route-detail-graphics .route-shape { flex: 0 0 220px; width: 220px; height: 150px; }

.route-detail-graphics .spark {
  flex: 1 1 320px;
  min-width: 260px;
  background: var(--bg-2);
  border-radius: var(--r-sm, 8px);
}

.route-estimate {
  color: var(--fg-3);
  font-size: 0.85rem;
  max-width: 66ch;
  margin: var(--s-4, 16px) 0;
}

.route-actions {
  display: flex;
  gap: var(--s-2, 8px);
  flex-wrap: wrap;
  margin-bottom: var(--s-4, 16px);
}

.route-credit {
  color: var(--fg-4);
  font-size: 0.78rem;
  margin: 0;
}

.route-credit a { color: var(--fg-3); }
