/* Westward — admin in-place editor styles.
   All affordances are visibility-gated by body.is-admin, so visitors see
   nothing even if the markup is present (defensive against JS race
   conditions when admin detect resolves after a render). */

.ed-edit-header,
.ed-add-block,
.ed-block-toolbar,
.ed-picker,
.ed-form { display: none; }

.can-edit .ed-edit-header,
.can-edit .ed-add-block { display: inline-flex; }

.can-edit .ed-picker,
.can-edit .ed-form { display: flex; }

/* ---- buttons ---- */
.ed-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 7px 12px;
  border: 1px solid var(--line-bright);
  border-radius: 2px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.ed-btn:hover { background: var(--line-bright); color: var(--accent); }
.ed-save {
  background: var(--accent-deep);
  border-color: var(--accent-dim);
  color: var(--bg);
}
.ed-save:hover { background: var(--accent-dim); color: var(--bg); }

/* ---- edit-header button at top of Marker body ---- */
.ed-edit-header {
  display: none;
  margin: 0 0 14px;
  border-style: dashed;
  background: transparent;
}
.can-edit .ed-edit-header { display: inline-flex; }

/* ---- add-block button at bottom of .ov-blocks ---- */
.ed-add-block {
  display: none;
  margin-top: 10px;
  width: 100%;
  border-style: dashed;
  justify-content: center;
}

/* ---- per-block hover toolbar ---- */
.ov-block { position: relative; }
.ov-block + .ov-block { margin-top: 6px; }

.ed-block-toolbar {
  position: absolute;
  top: -6px;
  right: -6px;
  display: none;
  gap: 1px;
  background: rgba(9, 12, 18, 0.94);
  border: 1px solid var(--line-bright);
  border-radius: 2px;
  padding: 2px;
  opacity: 0;
  z-index: 2;
  transition: opacity 0.15s var(--ease);
}
.can-edit .ov-block:hover > .ed-block-toolbar,
.can-edit .ed-block-toolbar:hover { display: flex; opacity: 1; }
.ed-block-toolbar button {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1;
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 1px;
}
.ed-block-toolbar button:hover {
  background: var(--line-bright);
  color: var(--accent);
}

/* ---- inline forms ---- */
.ed-form {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  margin: 8px 0;
  background: rgba(15, 20, 29, 0.62);
  border: 1px solid var(--line-bright);
  border-radius: 3px;
}

.ed-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ed-lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ed-form input[type="text"],
.ed-form input[type="file"],
.ed-form select,
.ed-form textarea {
  font-family: var(--font-sans);
  font-size: 14px;
  background: rgba(9, 12, 18, 0.7);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 7px 9px;
  color: var(--ink);
  width: 100%;
}
.ed-form textarea {
  min-height: 80px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
}
.ed-form input[type="text"]:focus,
.ed-form textarea:focus,
.ed-form select:focus,
.ed-form input[type="file"]:focus {
  outline: none;
  border-color: var(--accent-dim);
}

/* ---- drag-to-reorder blocks (⠿ handle on the block toolbar) ---- */
.ed-drag { cursor: grab; }
.ed-drag:active { cursor: grabbing; }
.ov-block.is-dragging { opacity: 0.35; }
/* landing glow — the block settles into its new slot without a re-render */
.ov-block.is-moved { animation: ed-moved 0.85s var(--ease); }
@keyframes ed-moved {
  0% { background: rgba(236, 202, 140, 0.1); }
  100% { background: transparent; }
}
.ed-drop-line {
  height: 0; margin: 4px 0;
  border-top: 2px solid var(--accent);
  box-shadow: 0 0 8px rgba(236, 202, 140, 0.45);
  pointer-events: none;
}

/* ---- table block editor: label/value row pairs ---- */
.ed-table-rows { display: flex; flex-direction: column; gap: 6px; }
.ed-table-row { display: flex; gap: 6px; align-items: center; }
.ed-table-row .ed-tr-label { flex: 0 0 38%; }
.ed-table-row .ed-tr-value { flex: 1; min-width: 0; }
.ed-tr-del {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0;
  font-size: 11px; line-height: 1;
  color: var(--ink-mute); background: none;
  border: 1px solid var(--line); border-radius: 2px; cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.ed-tr-del:hover { color: var(--warn); border-color: var(--warn); }
.ed-tr-add { align-self: flex-start; }

/* non-public blocks: hairline tier cue for whoever can see them */
.ov-block-vis-crew,
.ov-block-vis-private { position: relative; padding-left: 10px; }
.ov-block-vis-crew    { border-left: 1px solid var(--accent-deep); }
.ov-block-vis-private { border-left: 1px solid var(--line-bright); }
.ov-vis-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 8.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent-dim);
  margin-bottom: 4px;
}

.ed-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.ed-status {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-dim);
  margin: 0;
}

/* ---- add-block type picker ---- */
.ed-picker {
  display: none;
  gap: 8px;
  padding: 12px;
  margin: 8px 0;
  background: rgba(15, 20, 29, 0.62);
  border: 1px solid var(--line-bright);
  border-radius: 3px;
}
.ed-picker .ed-btn { flex: 1; justify-content: center; }

/* ---- image picker (upload + existing grid) ---- */
.ed-image-preview {
  display: block;
  max-width: 100%;
  border-radius: 2px;
  border: 1px solid var(--line);
}

.ed-image-existing-toggle {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  background: none;
  border: 0;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
}
.ed-image-existing-toggle:hover { color: var(--accent-dim); }

.ed-image-existing {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
  background: rgba(9, 12, 18, 0.6);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.ed-image-existing img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease);
}
.ed-image-existing img:hover { border-color: var(--accent-dim); }

.ed-hint {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
  margin: -4px 0 0;
}

/* ---- image block (rendered, not editor) ---- */
.ov-figure { margin: 0; }
.ov-figure img {
  display: block;
  width: 100%;
  border-radius: 2px;
  border: 1px solid var(--line);
}
.ov-figure figcaption {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
  margin-top: 6px;
}

/* ---- video block (rendered, not editor) ---- */
.ov-video video {
  display: block;
  width: 100%;
  border-radius: 2px;
  border: 1px solid var(--line);
  background: #000;
}
.ov-video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 2px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #000;
}
.ov-video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- map block (rendered, not editor) ---- */
.ov-map-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 2px;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #0b0e14;
}
.ov-map-embed iframe,
.ov-map-embed .ov-map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- activity block (imported .fit summary) ---- */
.ov-activity {
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.12));
}
.ov-activity-trace {
  display: block;
  width: 100%;
  aspect-ratio: 100 / 60;
  background: #0b0e14;
  border-bottom: 1px solid var(--line);
}
/* trace riding on top of the map panel (removed once the keyed polyline draws) */
.ov-activity-map .ov-activity-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  background: transparent;
  border-bottom: 0;
  z-index: 1;
  pointer-events: none;
}
.ov-activity-map { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.ov-activity-route {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.ov-activity-start { fill: var(--accent); }
.ov-activity-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 12px 0;
}
.ov-activity-sport {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent);
}
.ov-activity-when {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.ov-activity-stats {
  display: flex; flex-wrap: wrap; gap: 18px;
  padding: 8px 12px 12px;
}
.ov-activity-stat { display: flex; flex-direction: column; gap: 1px; }
.ov-activity-val {
  font-family: var(--font-mono);
  font-size: 15px; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.ov-activity-lbl {
  font-family: var(--font-mono);
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-dim, var(--ink-soft));
}
/* ---- HR / pace progression graphs ---- */
.ov-activity-graphs { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 12px 12px; }
.ov-graph {
  flex: 1 1 140px; min-width: 130px;
  border: 1px solid var(--line); border-radius: 3px;
  background: rgba(255, 255, 255, 0.015);
  cursor: pointer; overflow: hidden;
  transition: border-color 0.2s var(--ease);
}
.ov-graph:hover, .ov-graph:focus-visible { border-color: var(--accent-deep); outline: none; }
.ov-graph.is-big { flex-basis: 100%; }
.ov-graph-head { display: flex; align-items: baseline; gap: 8px; padding: 7px 9px 2px; }
.ov-graph-label {
  font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute);
}
.ov-graph-range {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 9px; font-variant-numeric: tabular-nums;
  color: var(--ink-mute); white-space: nowrap;
}
.ov-graph-read {
  visibility: hidden;
  font-family: var(--font-mono); font-size: 10.5px; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ov-graph-read .v { color: var(--ink); }
.ov-graph-read .t { color: var(--ink-mute); }
.ov-graph svg { display: block; width: 100%; }
.ov-graph-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ov-graph-area { fill: var(--accent); opacity: 0.1; stroke: none; }
.ov-graph-grid { stroke: var(--line); stroke-width: 1; }
.ov-graph-tick { font-family: var(--font-mono); font-size: 8px; fill: var(--ink-mute); font-variant-numeric: tabular-nums; }
.ov-graph-lone { fill: var(--accent); }
.ov-graph-ext-dot { fill: var(--accent); stroke: #0a0e16; stroke-width: 1.5; }
.ov-graph-ext { font-family: var(--font-mono); font-size: 8.5px; fill: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ov-graph-cross { stroke: var(--line-bright); stroke-width: 1; }
.ov-graph-dot { fill: var(--accent); stroke: #0a0e16; stroke-width: 2; }

.ov-activity figcaption {
  font-family: var(--font-sans);
  font-size: 13px; line-height: 1.45; color: var(--ink-soft);
  padding: 0 12px 12px;
}
