/* ============================================================================
   TT audio player — "The Rule" + sticky dock (2026-07-18)
   Restyles Ghost's stock kg-audio-card. Loaded from default.hbs after app.css.
   Fill mechanism: Ghost cards.min.js maintains --seek-before-width on
   .kg-audio-player-container; the played rule is drawn from that var.
   marker: tt-audio-rule-v1
   ========================================================================== */

/* ---- the strip ----
   Ghost core draws the card box via inset box-shadow + min-height + #fff bg,
   so each must be explicitly neutralized; .kg-card.kg-audio-card outranks both
   core (0-1-0) and the theme's card rule (0-2-0). */
.ghost-content .kg-card.kg-audio-card {
  position: relative;
  display: flex;
  min-height: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  border-top: 2px solid currentColor; /* article ink — --color-brd goes soft inside prose */
  padding: 4px 0 18px;
}

/* ---- fuse with the post-hero ----
   When a post opens with the audio strip, the strip's 2px top rule replaces the
   hero's bottom hairline: kill the hero's border + trailing padding and the
   article's top gap. Anchored on the card OR the dock sentinel (first-child
   flips to the sentinel once tt-audio.js runs). */
*:has(+ article.ghost-content > .kg-card.kg-audio-card:first-child),
*:has(+ article.ghost-content > .tt-audio-sentinel:first-child) {
  padding-bottom: 0;
}
*:has(+ article.ghost-content > .kg-card.kg-audio-card:first-child) .border-b.border-brd-soft,
*:has(+ article.ghost-content > .tt-audio-sentinel:first-child) .border-b.border-brd-soft {
  border-bottom: 0;
  padding-bottom: 18px;
}
article.ghost-content:has(> .kg-card.kg-audio-card:first-child),
article.ghost-content:has(> .tt-audio-sentinel:first-child) {
  padding-top: 0;
  margin-top: 0;
}
.ghost-content .kg-card.kg-audio-card { margin-top: 0; }

/* no thumbnail, no volume cluster */
.ghost-content .kg-audio-card .kg-audio-thumbnail,
.ghost-content .kg-audio-card .kg-audio-thumbnail.placeholder,
.ghost-content .kg-audio-card .kg-audio-unmute-icon,
.ghost-content .kg-audio-card .kg-audio-mute-icon,
.ghost-content .kg-audio-card .kg-audio-volume-slider {
  display: none;
}

/* title line becomes the eyebrow */
.ghost-content .kg-audio-card .kg-audio-title {
  margin: 6px 0 2px;
  padding: 0;
  font-size: 0;
  line-height: 1;
}
.ghost-content .kg-audio-card .kg-audio-title::before {
  content: "Listen to this article";
  display: block;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-typ-tone, var(--color-typ));
  line-height: 1.4;
}

/* controls row */
.ghost-content .kg-audio-card .kg-audio-player {
  padding: 8px 0 6px;
  gap: 10px;
}
.ghost-content .kg-audio-card .kg-audio-play-icon,
.ghost-content .kg-audio-card .kg-audio-pause-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-typ);
  color: var(--color-bgr);
  bottom: 0;
}
.ghost-content .kg-audio-card .kg-audio-play-icon svg,
.ghost-content .kg-audio-card .kg-audio-pause-icon svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}
.ghost-content .kg-audio-card .kg-audio-play-icon svg { margin-left: 2px; }

.ghost-content .kg-audio-card .kg-audio-current-time,
.ghost-content .kg-audio-card .kg-audio-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 400;
}
.ghost-content .kg-audio-card .kg-audio-current-time {
  color: var(--color-typ);
  margin-left: auto;
  min-width: 0;
  padding: 0;
}
.ghost-content .kg-audio-card .kg-audio-time {
  color: var(--color-typ-tone, #777);
  width: auto;
}
.ghost-content .kg-audio-card .kg-audio-playback-rate {
  min-width: 0;
  margin-left: 4px;
  padding: 3px 7px;
  border: 1px solid var(--color-brd-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 400;
  color: var(--color-typ-tone, var(--color-typ));
}
.ghost-content .kg-audio-card .kg-audio-playback-rate:hover {
  border-color: var(--color-brd);
  color: var(--color-typ);
}

/* ---- the rule itself: base track + inked fill, drawn on the card bottom ---- */
.ghost-content .kg-audio-card .kg-audio-player-container::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -18px; /* card padding-bottom */
  height: 3px;
  background: var(--color-brd-soft);
}
.ghost-content .kg-audio-card .kg-audio-player-container::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -18px;
  height: 3px;
  width: var(--seek-before-width, 0%);
  background: var(--color-typ);
}

/* the real range input sits invisibly over the rule for seeking */
.ghost-content .kg-audio-card .kg-audio-seek-slider {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -25px;
  height: 16px;
  margin: 0;
  z-index: 2;
}
.ghost-content .kg-audio-card .kg-audio-seek-slider::before { display: none; }
.ghost-content .kg-audio-card .kg-audio-seek-slider::-webkit-slider-runnable-track {
  height: 16px;
  background: transparent;
  border-radius: 0;
}
.ghost-content .kg-audio-card .kg-audio-seek-slider::-webkit-slider-thumb {
  width: 2px;
  height: 12px;
  margin: 2px 0 0;
  border-radius: 0;
  background: var(--color-typ);
  box-shadow: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.ghost-content .kg-audio-card:hover .kg-audio-seek-slider::-webkit-slider-thumb { opacity: 1; }
.ghost-content .kg-audio-card .kg-audio-seek-slider::-moz-range-track {
  height: 16px;
  background: transparent;
  border-radius: 0;
}
.ghost-content .kg-audio-card .kg-audio-seek-slider::-moz-range-progress {
  background: transparent;
}
.ghost-content .kg-audio-card .kg-audio-seek-slider::-moz-range-thumb {
  width: 2px;
  height: 12px;
  border-radius: 0;
  background: var(--color-typ);
  box-shadow: none;
  opacity: 0;
}
.ghost-content .kg-audio-card:hover .kg-audio-seek-slider::-moz-range-thumb { opacity: 1; }

/* ============================================================================
   Sticky dock: while playing and scrolled past, the card fixes to the
   viewport bottom as a slim bar. Class toggled by tt-audio.js.
   ========================================================================== */
.tt-audio-sentinel { height: 0; }

.ghost-content .kg-card.kg-audio-card.tt-docked {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  margin: 0;
  background: var(--color-bgr);
  border-top: 2px solid var(--color-brd);
  padding: 8px max(20px, env(safe-area-inset-left))
           calc(10px + env(safe-area-inset-bottom))
           max(20px, env(safe-area-inset-right));
}
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-player-container {
  max-width: 760px;
  margin: 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-title {
  order: 1;
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-title::before { content: none; }
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-player {
  order: 0;
  flex: 1;
  padding: 0;
}
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-play-icon,
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-pause-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
}
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-play-icon svg,
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-pause-icon svg {
  width: 10px;
  height: 10px;
}
/* in the dock, the rule runs along the dock's top edge */
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-player-container::before,
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-player-container::after {
  bottom: auto;
  top: -10px;
}
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-player-container::before { left: -100vw; right: -100vw; }
.ghost-content .kg-card.kg-audio-card.tt-docked .kg-audio-seek-slider {
  bottom: auto;
  top: -18px;
}
@media (prefers-reduced-motion: no-preference) {
  .ghost-content .kg-card.kg-audio-card.tt-docked { animation: tt-dock-in 0.25s ease; }
  @keyframes tt-dock-in {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}
