/* ── Detail view ── */

.workout-detail {
  padding: 14px 16px;
  overflow-wrap: anywhere;
}
.workout-detail .workout-name {
  font-size: 1rem;
  text-transform: none;
  letter-spacing: normal;
}
.workout-detail summary { cursor: pointer; }
.workout-steps { padding-inline-start: 2rem; }
.workout-steps li { margin-block: .5rem; }
.workout-steps p { margin-block: .25rem; }
.workout-note, .workout-hover {
  font-size: .8rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.workout-hover { min-height: 2.5em; margin: .25rem 0; }
.workout-step-block:focus { outline: none; stroke: currentColor; stroke-width: 2; }

/* The climbs of a climbing activity: one row per climb, grade first. */
.climbs-detail { margin-block: 1rem; }
.climb-list { list-style: none; padding: 0; margin: .5rem 0; }
.climb-row {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  padding-block: .4rem;
  border-block-end: 1px solid var(--border, currentColor);
}
.climb-grade { font-weight: 600; min-width: 6rem; }
.climb-details, .climb-note { color: var(--text-muted); font-size: .85rem; overflow-wrap: anywhere; }
.climb-row[data-completed="true"] .climb-status { font-weight: 600; }

/* When <main> is on an activity route, drop the feed column cap so the
   detail page can span the full viewport and host a side-by-side layout
   on wide screens. */
.activity-main {
  width: 100%;
}

.activity-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

/* The wall→detail morph pairs the tapped card's thumbnail with this pane, so
   the card grows into the map instead of the page cutting. The pane rather
   than the placeholder inside it: a `view-transition-name` has to be in the
   DOM when the browser captures the new state, and the placeholder is not —
   it waits on the GPS trace, which the wall never loaded. Naming it produced
   an unpaired `::view-transition-old` and no morph at all. */
.activity-detail-map-pane {
  position: relative;
  height: 60vh;
  background: var(--surface-alt);
  overflow: hidden;
  view-transition-name: activity-hero;
}

/* ActivityMapDetail wraps the map in a relative div; make it fill the pane
   so the inner `.maplibre-map` (height: 100%) actually resolves to a real
   height. */
.activity-detail-map-pane > div,
.activity-detail-map-pane .maplibre-map,
.activity-detail-map-pane .map-no-gps {
  height: 100%;
}

/* Frame for the static map PNG held over the live map until it paints. Fills
   the pane and clips: the image inside is scaled up and offset to register
   against the live map's camera, so it overflows this box on nearly every
   route. */
.detail-map-placeholder {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  opacity: 1;
  transition: opacity 220ms ease-out;
}

.detail-map-placeholder.faded {
  opacity: 0;
}

/* `syncStaticOverlay` overwrites width/height/transform on every frame the
   live map draws, putting the image's route exactly where the live map's is,
   and reveals the image once it has. Hidden until then — the fallback framing
   below is a whole zoom step out, and showing it first would put back the
   jump this is here to remove. The same call reveals it unchanged if no map
   ever appears, so a failure degrades to the letterboxed framing rather than
   to nothing. */
.detail-map-placeholder-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  opacity: 0;
}

/* The card side of the morph, set only while that card is opening — a
   `view-transition-name` must be unique in the document, and every other card
   carries the same class. */
.activity-card.opening .card-map-img {
  view-transition-name: activity-hero;
}

/* The card thumbnail is 3:1 and the pane it grows into is nearer square.
   Default `fill` would stretch the snapshot flat during the tween; `cover`
   crops it towards the centre instead, which is the direction the pane's own
   framing is already heading — so the whole open reads as one push into the
   route. */
::view-transition-old(activity-hero),
::view-transition-new(activity-hero) {
  object-fit: cover;
}

.activity-detail-content-pane {
  padding: 16px 16px 32px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  /* A grid item's automatic minimum is its content's: a native select sizes
     to its longest option, which would widen the track past a 320px screen. */
  min-width: 0;
  box-sizing: border-box;
  animation: detail-panel-in 320ms cubic-bezier(0.22, 0.8, 0.2, 1) backwards;
}

/* The panel arrives from the viewport edge it sits against while the map pane
   morphs out of the tapped card: from below on narrow screens, from the side
   on wide ones.
   A plain animation on the element rather than a `view-transition-name` and
   `::view-transition-new`: naming it makes it a containing block for its
   `position: fixed` descendants, which pins the photo lightbox and the menu
   backdrop to the panel instead of the viewport. This also gives the slide to
   browsers without view transitions, where the pane simply appears mid-slide
   with nothing to morph out of.

   `backwards`, never `forwards`/`both`: a filled `transform: none` end state
   computes to the identity matrix, not to `none`, so the pane stays a
   containing block for the whole life of the page and pins those same fixed
   descendants it was written this way to spare. Without the forwards fill the
   pane simply keeps its own (untransformed) style once the run is over, which
   is what the last keyframe says anyway. */
@keyframes detail-panel-in {
  from {
    transform: translateY(24vh);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes detail-panel-in-side {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (min-width: 1024px) {
  .activity-detail {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    align-items: start;
    min-height: calc(100vh - var(--chrome-h));
  }

  .activity-detail-map-pane {
    position: sticky;
    top: var(--chrome-h);
    height: calc(100vh - var(--chrome-h));
    border-right: 1px solid var(--border);
  }

  .activity-detail-content-pane {
    max-width: 560px;
    padding: 28px 24px 56px;
    animation-name: detail-panel-in-side;
  }
}

/* The ⋯ menu is all this bar holds: a detail's way back is the app bar's
   back link (activity.allium: BackLeadsWhereTheReaderCameFrom). Flush
   right. */
.detail-top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
}

.detail-menu-wrapper {
  position: relative;
}

.detail-menu-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
  letter-spacing: 2px;
}

.detail-menu-btn:hover {
  background: var(--surface-alt);
}

.detail-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
}

.detail-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 100;
  padding: 4px 0;
}

.detail-menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.detail-menu-item:hover {
  background: var(--surface-alt);
}

.detail-menu-item.danger {
  color: var(--danger);
}

.detail-menu-item.danger:hover {
  background: var(--danger-soft);
}

.detail-header {
  background: var(--surface);
  padding: 16px 16px 12px;
  border-radius: 14px 14px 0 0;
}

.detail-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

/* ── Charts ── */

.chart-section {
  background: var(--surface);
  padding: 14px 16px 10px;
  border-top: 1px solid var(--border);
}

.chart-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-subtle);
  margin-bottom: 6px;
}

.line-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-tick {
  font-size: 11px;
  fill: var(--text-subtle);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Stats bar ── */

/* Wraps instead of overflowing: an activity with many metrics (HR,
   cadence, …) gets a second row rather than clipping at the pane edge. */
.activity-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  gap: 2px;
}

.stat-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.detail-device {
  margin: 8px 16px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.detail-description {
  margin: 12px 16px 0;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 4px;
  padding: 4px 6px;
  color: var(--text);
}

/* ── A description drawn as markdown (MarkdownText) ──
   Its line breaks are <br>s and its paragraphs <p>s, so the text itself
   wraps normally; only a code block keeps its spacing. */

.markdown-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.markdown-text > :first-child {
  margin-top: 0;
}

.markdown-text > :last-child {
  margin-bottom: 0;
}

.markdown-text p,
.markdown-text ul,
.markdown-text ol,
.markdown-text blockquote,
.markdown-text pre {
  margin: 0 0 0.6em;
}

.markdown-text ul,
.markdown-text ol {
  padding-left: 1.4em;
}

.markdown-text blockquote {
  margin-left: 0;
  padding-left: 0.8em;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.markdown-text pre {
  white-space: pre-wrap;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--surface-alt);
}

.markdown-text code {
  font-size: 0.9em;
}

.markdown-text .md-heading {
  margin: 0.6em 0 0.3em;
  font-size: 1em;
  font-weight: 600;
}

.markdown-text .md-photo {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  margin: 0.4em 0;
  border-radius: 6px;
}

.markdown-text a {
  color: var(--brand);
}

/* ── The count under a field kept to a bound (CapCounter) ── */

.cap-counter {
  margin: 4px 16px 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cap-over {
  color: var(--danger);
  font-weight: 600;
}

/* ── Reading view: gear and tags, read (Activity Detail) ──
   Text, not controls: reading never edits (specs/activity.allium,
   ReadingNeverEdits). Changed in the edit mode below. */

.detail-gear {
  margin: var(--space-2) var(--space-4) 0;
  font-size: var(--fs-small);
  color: var(--ink-muted);
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
}

.detail-tags {
  margin: var(--space-2) var(--space-4) 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-small);
  background: var(--surface-alt);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--ink);
}

/* ── Edit mode (Activity Detail) ──
   A bar that stays at the top of the pane while the form scrolls under it:
   what is being edited, and the two ways out (Discard, Done). Every field
   below is a native control under a visible label (forms.md). */

.detail-edit-bar {
  position: sticky;
  top: var(--chrome-top);   /* under the app bar, which is sticky too */
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.detail-edit-bar-title {
  flex: 1 1 12rem;
  min-width: 0;
}

.detail-edit-kicker {
  display: block;
  font-size: var(--fs-kicker);
  color: var(--ink-muted);
}

.detail-edit-title {
  margin: 0;
  font-size: var(--fs-lead);
  font-weight: var(--fw-bold);
  color: var(--ink);
  line-height: var(--lh-snug);
  overflow-wrap: anywhere;
}

.detail-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-inline-start: auto;
}

.detail-edit-actions .route-btn {
  min-height: 44px; /* LOOK-8 */
}

.detail-edit-form {
  padding: var(--space-1) var(--space-4) var(--space-4);
}

.detail-edit-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  padding: 0;
  border: none;
  min-width: 0;
}

.detail-edit-field > label,
.detail-edit-field > legend,
.tag-picker-add > label,
.detail-edit-heading {
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--ink-muted);
  padding: 0;
}

.detail-edit-heading {
  margin: 0 0 var(--space-2);
}

.detail-title-input {
  min-height: 44px; /* LOOK-8 */
  width: 100%;
  box-sizing: border-box;
  padding: 0 var(--space-3);
  font-size: var(--fs-body);
  font-weight: var(--fw-bold);
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
}

.detail-title-input[aria-invalid="true"] {
  border-color: var(--danger);
}

.detail-edit-field .cap-counter {
  margin: 0;
}

.detail-edit-error {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--danger);
}

.detail-description-textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  box-sizing: border-box;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-small);
  font-family: inherit;
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  resize: vertical;
}

.sport-picker select,
.gear-picker select {
  min-height: 44px; /* LOOK-8 */
  max-width: 100%;
  padding: 0 var(--space-3);
  font-size: var(--fs-small);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
}

.tag-picker-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-picker-option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px; /* LOOK-8 */
  font-size: var(--fs-small);
  color: var(--ink);
  cursor: pointer;
}

.tag-picker-option input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.tag-picker-empty {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--ink-muted);
}

.tag-picker-add {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.tag-picker-add-row {
  display: flex;
  gap: var(--space-2);
}

.tag-picker-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px; /* LOOK-8 */
  padding: 0 var(--space-3);
  font-size: var(--fs-small);
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
}

.tag-picker-add-row .route-btn {
  min-height: 44px; /* LOOK-8 */
}

.detail-edit-photos {
  margin: var(--space-4) 0 0;
}

.detail-edit-form .share-section {
  margin: var(--space-4) 0 0;
}

/* The reading view's Share control: the heading itself, as a button that
   opens the audience choice (specs/social.allium, ActivitySharing). */
.share-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px; /* LOOK-8 */
  padding: 0 var(--space-3);
  font: inherit;
  font-weight: var(--fw-semibold);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.share-toggle::after {
  content: "▾";
  color: var(--ink-muted);
}

.share-toggle[aria-expanded="true"]::after {
  content: "▴";
}

/* ── Share section (Activity Detail) ── */
/* Under the charts and above the comments, framed as the comments are: who
   this activity reaches, one toggle chip per audience (src/activity_share.rs).
   The chips are the wall filter's `.type-chip`; a pressed one carries a tick
   as well as the accent, so its state does not rest on colour alone. */

.share-section {
  margin: 16px 16px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.share-heading {
  font-size: 0.9rem;
  margin: 0 0 10px;
  color: var(--text-muted);
}

.share-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.share-chip.active::before {
  content: "✓ ";
}

.share-chip.working,
.share-chip:disabled {
  opacity: 0.55;
  cursor: progress;
}

.share-hint,
.share-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 8px 0 0;
}

.share-notice-club {
  font-weight: 600;
}

/* ── Reading layout (Activity Detail, issue #2311) ──
   The reading view is laid out by the page's weight, which the page carries
   as `data-weight` (specs/activity.allium:
   ThePageScalesWithWhatTheActivityHolds). The sections are always the same
   and in the same order; the reading pane takes no box of its own, so each
   section and the map pane beside them are cells of one grid, and a change
   of weight moves them without drawing the map again. The edit mode carries
   no weight and keeps the layout above.

   Narrow screens read in one column. From 1024px the page is a centred
   column of two tracks — the wider one for the words, the map or the
   figures, the other beside it — with the story's hero and ribbon running
   the full width. */

.activity-detail[data-weight] {
  /* The inline padding a full-width band gives its content, so it lines up
     with the centred column. A percentage, resolved where it is used. */
  --bleed-pad: max(var(--space-4), calc((100% - 74rem) / 2));
  --reading-gutter: var(--space-4);
  --story-map-h: clamp(10rem, 28vh, 16rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "head"
    "words"
    "gallery"
    "map"
    "figures"
    "profile"
    "numbers"
    "stage"
    "after";
  align-items: start;
  min-height: 0;
  padding-block-end: var(--space-7);
}

.activity-detail[data-weight] > .reading-pane {
  display: contents;
}

.activity-detail[data-weight] .reading-head { grid-area: head; }
.activity-detail[data-weight] .reading-words { grid-area: words; }
.activity-detail[data-weight] .reading-gallery { grid-area: gallery; }
.activity-detail[data-weight] .reading-figures { grid-area: figures; }
.activity-detail[data-weight] .reading-profile { grid-area: profile; }
.activity-detail[data-weight] .reading-numbers { grid-area: numbers; }
.activity-detail[data-weight] .reading-stage { grid-area: stage; }
.activity-detail[data-weight] .reading-after { grid-area: after; }

/* Each section stands apart from the one before it; one with nothing in it
   (no stage, no comments) takes no room. */
.activity-detail[data-weight] > .reading-pane > :not(:empty) {
  min-width: 0;
  margin-block-start: var(--space-6);
  margin-inline: var(--reading-gutter);
}

.activity-detail[data-weight] > .reading-pane > .reading-head {
  margin-block-start: var(--space-5);
}

/* The map: full width on a narrow screen, and sticky there only on a story.
   A pane settled with no trace gives its room away. */
.activity-detail[data-weight] > .activity-detail-map-pane {
  grid-area: map;
  position: relative;
  top: auto;
  height: clamp(15rem, 45vh, 26rem);
  margin-block-start: var(--space-6);
  border-right: none;
}

.activity-detail[data-weight] > .activity-detail-map-pane.map-pane-empty {
  display: none;
}

/* ── The header: kicker, title, whose it is, and the actions ── */

.activity-detail[data-weight] .reading-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0;
  background: none;
  border-radius: 0;
}

.reading-title {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.reading-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-1);
  margin: 0;
  color: var(--ink-muted);
}

/* The sport reads as part of the kicker here, not as the card's pill. */
.reading-kicker .activity-type-badge,
.reading-kicker .activity-date {
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border-radius: 0;
}

.activity-detail[data-weight] .detail-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.activity-detail[data-weight] .reading-byline {
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin: 0;
}

.reading-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline-start: auto;
}

.reading-actions .detail-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;   /* LOOK-8 */
  min-height: 44px;
  padding: 0 var(--space-2);
  color: var(--ink);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-pill);
}

.activity-detail[data-weight] .detail-tags {
  margin: 0;
}

/* The cover: the first photo, or the story's, across the column. Full width
   on a narrow screen. Pressing it opens the lightbox. */
.reading-cover {
  margin-inline: calc(-1 * var(--reading-gutter));
}

.reading-cover-btn {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  max-height: 70vh;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--surface-alt);
  border: 0;
}

.reading-cover-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── The headline figures ── */

.activity-detail[data-weight] .reading-figures .activity-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

.activity-detail[data-weight] .reading-figures .stat-item {
  align-items: flex-start;
  gap: var(--space-1);
  padding: 0;
  min-width: 0;
}

.activity-detail[data-weight] .reading-figures .stat-value {
  font-family: var(--font-display);
  font-size: clamp(var(--fs-heading), 7vw, var(--fs-title));
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.activity-detail[data-weight] .reading-figures .stat-label,
.activity-detail[data-weight] .number-group-stats .stat-label {
  font-size: var(--fs-kicker);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-kicker);
  color: var(--ink-muted);
}

/* ── The words and the gallery ── */

.activity-detail[data-weight] .reading-words {
  max-width: 44rem;
  padding: 0;
  font-size: var(--fs-body);
  color: var(--ink-body);
  border-radius: 0;
}

.reading-prose {
  font-family: var(--font-prose);
  font-size: var(--fs-lead);
  line-height: var(--lh-prose);
  color: var(--ink-body);
}

.activity-detail[data-weight="story"] .reading-prose {
  font-size: var(--fs-prose);
}

.reading-prose .md-heading {
  font-family: var(--font-display);
  color: var(--ink);
}

.activity-detail[data-weight] .reading-gallery {
  padding: 0;
}

/* ── The elevation profile and "The numbers" ── */

.activity-detail[data-weight] .reading-profile .chart-section {
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

.reading-section-heading {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: var(--fs-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  color: var(--ink);
}

/* Folded, the groups sit side by side as cards; an open one takes the whole
   row, for its charts. */
.number-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3);
  align-items: start;
}

.number-group {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

.number-group[open] {
  grid-column: 1 / -1;
}

.number-group-summary {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 44px;   /* LOOK-8 */
  padding: var(--space-4) var(--space-7) var(--space-4) var(--space-5);
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius-lg);
}

.number-group-summary::-webkit-details-marker {
  display: none;
}

/* Whether the group is open is said by the control itself (a native
   disclosure); the chevron only echoes it. */
.number-group-summary::after {
  content: "▾";
  position: absolute;
  inset-inline-end: var(--space-5);
  top: var(--space-4);
  color: var(--ink-muted);
}

.number-group[open] > .number-group-summary::after {
  content: "▴";
}

.number-group-label {
  color: var(--ink-muted);
}

.number-group-value {
  font-family: var(--font-display);
  font-size: var(--fs-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.number-group-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-4);
  min-width: 0;
}

.number-group-body:empty {
  display: none;
}

.number-group-note {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-small);
  color: var(--ink-muted);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
}

.number-group-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
}

.number-group .number-group-stats .stat-item {
  align-items: flex-start;
  padding: var(--space-2) 0;
}

.number-group .chart-section,
.number-group .workout-detail {
  padding-inline: 0;
  background: none;
  border-top: 1px solid var(--hairline);
}

.number-group .activity-stats {
  border-top: 0;
}

.number-group .detail-device {
  margin: 0;
}

/* ── After the numbers: the stage band, sharing and the comments ── */

.activity-detail[data-weight] .reading-stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.activity-detail[data-weight] .reading-stage .stage-band,
.activity-detail[data-weight] .reading-stage .stage-suggestion {
  margin: 0;
}

.activity-detail[data-weight] .reading-after {
  max-width: 45rem;
}

.activity-detail[data-weight] .reading-after > .share-section,
.activity-detail[data-weight] .reading-after > .kudos-row,
.activity-detail[data-weight] .reading-after > .kudos-givers,
.activity-detail[data-weight] .reading-after > .comments-section {
  margin-inline: 0;
}

/* ── A story on a narrow screen: the hero, the ribbon, then the map pinned
   above the words while they are read ── */

.activity-detail[data-weight="story"] {
  grid-template-areas:
    "head"
    "figures"
    "map"
    "words"
    "gallery"
    "profile"
    "numbers"
    "stage"
    "after";
  grid-template-rows: auto auto var(--story-map-h);
}

/* The map spans the words and the gallery, so it stays in view while they
   scroll under it, and lets go when they end. */
.activity-detail[data-weight="story"] > .activity-detail-map-pane {
  grid-row: map-start / gallery-end;
  position: sticky;
  top: var(--chrome-top);
  z-index: 2;
  height: var(--story-map-h);
  margin-block-start: 0;
  border-block-end: 1px solid var(--hairline);
}

.activity-detail[data-weight="story"]:has(> .map-pane-empty) {
  grid-template-rows: none;
}

/* The hero and the ribbon run the full width; their content lines up with
   the column. */
.activity-detail[data-weight="story"] > .reading-pane > .reading-head,
.activity-detail[data-weight="story"] > .reading-pane > .reading-figures {
  margin-inline: 0;
}

.activity-detail[data-weight="story"] > .reading-pane > .reading-head {
  margin-block-start: 0;
}

.activity-detail[data-weight="story"] .reading-head {
  display: grid;
  grid-template-areas: "title" "byline" "tags";
  gap: var(--space-4);
  padding-block-start: var(--space-6);
}

.activity-detail[data-weight="story"] .reading-head.has-cover {
  grid-template-areas: "cover" "byline" "tags";
  padding-block-start: 0;
}

.activity-detail[data-weight="story"] .reading-title,
.activity-detail[data-weight="story"] .reading-byline,
.activity-detail[data-weight="story"] .reading-head .detail-tags {
  padding-inline: var(--bleed-pad);
}

.activity-detail[data-weight="story"] .reading-title { grid-area: title; }
.activity-detail[data-weight="story"] .reading-byline { grid-area: byline; }
.activity-detail[data-weight="story"] .reading-head .detail-tags { grid-area: tags; }

.activity-detail[data-weight="story"] .detail-title {
  font-size: var(--fs-hero);
  line-height: var(--lh-hero);
  letter-spacing: var(--tracking-hero);
}

/* With a cover, the title is set over it, on a scrim of the dark band's
   colour that keeps it legible on any photo, in either theme. The title lets
   a press through to the cover beneath. */
.activity-detail[data-weight="story"] .reading-cover {
  position: relative;
  grid-area: cover;
  margin-inline: 0;
}

.activity-detail[data-weight="story"] .reading-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--band-bg) 88%, transparent),
    transparent 65%
  );
  pointer-events: none;
}

.activity-detail[data-weight="story"] .reading-cover-btn {
  aspect-ratio: auto;
  height: clamp(22rem, 70vh, 40rem);
  max-height: none;
  background: var(--band-bg);
}

.activity-detail[data-weight="story"] .has-cover .reading-title {
  grid-area: cover;
  align-self: end;
  z-index: 1;
  padding-block: var(--space-6);
  pointer-events: none;
  color: var(--on-dark);
}

.activity-detail[data-weight="story"] .has-cover .reading-kicker {
  color: var(--on-dark-accent);
}

.activity-detail[data-weight="story"] .has-cover .detail-title {
  color: var(--on-dark);
}

/* The ribbon of headline figures. */
.activity-detail[data-weight="story"] .reading-figures {
  padding: var(--space-5) var(--bleed-pad);
  background: var(--surface);
  border-block: 1px solid var(--hairline);
}

.activity-detail[data-weight="story"] .reading-figures .activity-stats {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

.activity-detail[data-weight="story"] .reading-figures .stat-value {
  font-size: clamp(var(--fs-heading), 8vw, var(--fs-figure));
}

/* ── "This route" (#2321): the owner's repeated route, under the figures ── */

.activity-detail[data-weight] .reading-figures {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.reading-route {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
}

.reading-route-kicker {
  margin: 0;
  color: var(--ink-muted);
}

.reading-route-times {
  margin: 0;
  font-size: var(--fs-lead);
  font-weight: var(--fw-semibold);
  color: var(--ink);
}

.reading-route-rank,
.reading-route-note {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--ink-muted);
}

.route-chart {
  width: 100%;
  height: auto;
  max-height: 5rem;
}

.route-chart-bar {
  fill: var(--border-control);
}

.route-chart-this {
  fill: var(--accent);
}

/* ── The story reader (#2314): the blocks, one under the other ── */

.story-reader {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

.story-block {
  min-width: 0;
}

/* A chapter opens with its number, the time and the distance, then its
   heading. Space above it marks the break the heading opens. */
.story-block-chapter:not(:first-child) {
  margin-block-start: var(--space-5);
}

.story-kicker,
.story-place {
  margin: 0 0 var(--space-2);
  color: var(--accent);
}

.story-heading {
  margin: 0 0 var(--space-4);
  font-family: var(--font-display);
  font-size: clamp(var(--fs-heading), 6vw, var(--fs-title));
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.story-media,
.story-gallery {
  margin: 0;
}

.story-photo-btn {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  overflow: hidden;
  cursor: zoom-in;
}

.story-photo-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.story-photo {
  display: block;
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: cover;
}

.story-photo-waiting {
  aspect-ratio: 3 / 2;
}

.story-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr));
  gap: var(--space-2);
}

.story-gallery-grid .story-photo {
  aspect-ratio: 1;
  height: 100%;
}

.story-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin-block-start: var(--space-2);
  font-size: var(--fs-small);
  line-height: var(--lh-snug);
  color: var(--ink-muted);
}

.story-caption .story-place {
  margin: 0;
}

.story-quote {
  margin: 0;
  padding-inline-start: var(--space-5);
  border-inline-start: 3px solid var(--accent);
  font-family: var(--font-prose);
  font-size: clamp(var(--fs-prose), 4.5vw, var(--fs-quote));
  font-style: italic;
  line-height: var(--lh-snug);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.story-quote p {
  margin: 0;
}

/* A big number: its name, the figure, and the line beside it. */
.story-figure {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}

.story-figure p {
  margin: 0;
}

.story-figure-name {
  font-size: var(--fs-small);
  color: var(--ink-muted);
}

.story-figure-value {
  font-family: var(--font-display);
  font-size: clamp(var(--fs-heading), 9vw, var(--fs-figure));
  font-weight: var(--fw-semibold);
  line-height: var(--lh-heading);
  color: var(--ink);
}

.story-figure-line {
  font-family: var(--font-prose);
  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
  color: var(--ink-body);
  overflow-wrap: anywhere;
}

.story-chart .chart-section {
  margin: 0;
}

.story-note {
  margin-block-start: var(--space-2);
}

/* The profile's marks: a chapter as a dashed rule with its number, a photo
   as a dot on the line. */
.chart-mark-rule {
  stroke: var(--ink-muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.chart-mark-label {
  fill: var(--ink-muted);
  pointer-events: none;
}

.chart-mark-photo {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1.5;
  pointer-events: none;
}

/* ── Wide screens ── */

@media (min-width: 1024px) {
  .activity-detail[data-weight] {
    --reading-gutter: 0px;
    grid-template-columns:
      [full-start] minmax(var(--space-6), 1fr)
      [main-start] minmax(0, 44rem)
      minmax(0, 30rem)
      [main-end] minmax(var(--space-6), 1fr)
      [full-end];
    grid-template-areas:
      ". head    head    ."
      ". words   words   ."
      ". gallery gallery ."
      ". map     figures ."
      ". profile profile ."
      ". numbers numbers ."
      ". stage   stage   ."
      ". after   after   .";
  }

  .activity-detail[data-weight] > .activity-detail-map-pane {
    height: clamp(20rem, 55vh, 32rem);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-lg);
  }

  /* Beside the map. A story's ribbon runs the full width instead. */
  .activity-detail[data-weight]:not([data-weight="story"]) > .reading-pane > .reading-figures {
    padding-inline-start: var(--space-6);
  }

  /* No trace: the figures take the map's room as well. */
  .activity-detail[data-weight]:not([data-weight="story"]):has(> .map-pane-empty)
    > .reading-pane > .reading-figures {
    grid-column: main-start / main-end;
    padding-inline-start: 0;
  }

  .activity-detail[data-weight] .reading-cover-btn {
    border-radius: var(--radius-lg);
  }

  .activity-detail[data-weight="story"] {
    grid-template-rows: none;
    grid-template-areas:
      "head    head    head    head"
      "figures figures figures figures"
      ".       words   map     ."
      ".       gallery map     ."
      ".       profile profile ."
      ".       numbers numbers ."
      ".       stage   stage   ."
      ".       after   after   .";
  }

  /* The map beside the reading column, kept in view while it is read. */
  .activity-detail[data-weight="story"] > .activity-detail-map-pane {
    grid-area: map;
    top: calc(var(--chrome-top) + var(--space-5));
    height: min(calc(100vh - var(--chrome-top) - var(--space-7)), 40rem);
    margin-block-start: var(--space-6);
    margin-inline-start: var(--space-6);
  }

  .activity-detail[data-weight="story"] .reading-cover-btn {
    border-radius: 0;
  }

  .activity-detail[data-weight="story"] .reading-figures .activity-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
