/* Interactive blog widgets (tap / press / slide).
   Design language matches getdroppy.app exactly: flat solid surfaces, no
   outlines, no borders, no gradients, no full caps, no decorative dots.
   Surfaces are separated by fill contrast only. The one moving highlight in
   a segmented control glides like the homepage shelf picker rather than
   blinking. Every widget reads as static content without JS; JS only adds the
   switching, dragging, and sync motion, and all motion is skipped under
   prefers-reduced-motion. */

.pi {
  margin: 2.2em 0;
  padding: clamp(18px, 3vw, 26px);
  border-radius: var(--radius-3xl);
  background: var(--glass-bg);
}

.pi__head {
  display: flex;
  justify-content: flex-end;
  min-height: 18px;
  margin-bottom: 14px;
}

/* The small "tap here / drag this / press this" affordance. Muted, sentence
   case, no pill and no accent, so it reads as a quiet hint, not a badge. */
.pi__cue {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-tertiary);
  font-size: 12.5px;
  font-weight: 500;
}

.pi__cue svg { width: 13px; height: 13px; opacity: 0.85; }
.pi__cue.is-done { color: var(--text-quaternary); }

/* ---- Segmented control (tap): flat text segments, one gliding chip ---- */

.pi-seg {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  padding: 4px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.24);
  overflow-x: auto;
  scrollbar-width: none;
}

.pi-seg::-webkit-scrollbar { display: none; }

.pi-seg__ind {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  width: 0;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .pi-seg__ind { transition: left var(--dur-base) var(--ease-out), width var(--dur-base) var(--ease-out); }
}

.pi-seg__btn {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  height: 34px;
  padding: 0 15px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-tertiary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.pi-seg__btn:hover { color: var(--text-secondary); }
.pi-seg__btn.is-active { color: var(--text-primary); }
.pi-seg__btn:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .pi-seg__btn { transition: color var(--dur-fast) var(--ease-out); }
}

/* ---- Swappable panels ---- */

.pi-panels { margin-top: 18px; }
.pi-panel { display: none; }
.pi-panel.is-active { display: block; }
.pi-panels:not([data-ready]) .pi-panel:first-child { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .pi-panels[data-ready] .pi-panel.is-active { animation: piFade var(--dur-base) var(--ease-out); }
  @keyframes piFade {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

.pi-panel__lead {
  margin: 0 0 13px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.pi-panel__lead strong { color: var(--text-primary); font-weight: 600; }

/* ---- Flat chips (converter formats) ---- */

.pi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pi-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.pi-chip--muted {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-quaternary);
  font-weight: 500;
}

/* ---- Step list (HEIC routes) ---- */

.pi-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: pi-step;
  display: grid;
  gap: 10px;
}

.pi-steps li {
  position: relative;
  padding: 3px 0 3px 36px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  counter-increment: pi-step;
}

.pi-steps li::before {
  content: counter(pi-step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.pi-steps kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85em;
}

/* ---- Slider (HEIC quality against size) ---- */

.pi-slider__readouts {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.pi-metric__label {
  display: block;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
}

.pi-metric__value {
  display: block;
  margin-top: 4px;
  color: var(--text-primary);
  font-family: "Inter Tight", var(--font-display);
  font-size: clamp(24px, 4.5vw, 30px);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.pi-metric--right { text-align: right; }

.pi-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  /* Hard two-tone fill, not a blended gradient: a solid accent block up to
     the thumb, a solid muted track after it. */
  background: linear-gradient(90deg, var(--accent) 0 var(--pi-fill, 70%), rgba(255, 255, 255, 0.1) var(--pi-fill, 70%) 100%);
  cursor: pointer;
}

.pi-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: grab;
}

.pi-range::-webkit-slider-thumb:active { cursor: grabbing; }

.pi-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: grab;
}

.pi-range:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 6px; }

.pi-slider__note {
  margin: 14px 0 0;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.55;
}

/* ---- Sync flow (press) ---- */

.pi-sync {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(8px, 2.5vw, 22px);
}

.pi-device {
  padding: 13px;
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.05);
}

.pi-device__cap {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: var(--text-tertiary);
  font-size: 12.5px;
  font-weight: 500;
}

.pi-device__cap svg { width: 14px; height: 14px; }

.pi-note {
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
}

.pi-note__title { color: var(--text-primary); font-size: 13px; font-weight: 600; }
.pi-note__body { margin-top: 4px; color: var(--text-tertiary); font-size: 12px; line-height: 1.45; }

.pi-device--phone .pi-note--ghost { opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .pi-device--phone .pi-note--ghost { transition: opacity var(--dur-base) var(--ease-out); }
}

.pi-sync.is-synced .pi-device--phone .pi-note--ghost { opacity: 1; }

.pi-sync__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(28px, 8vw, 56px);
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
}

.pi-sync__pulse {
  position: absolute;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  opacity: 0;
}

.pi-sync__cloud {
  position: absolute;
  top: -27px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-quaternary);
}

.pi-sync__cloud svg { width: 22px; height: 22px; }
.pi-sync.is-synced .pi-sync__cloud { color: var(--accent-text); }

@media (prefers-reduced-motion: no-preference) {
  .pi-sync.is-syncing .pi-sync__pulse { animation: piTravel 0.9s var(--ease-out); }
  @keyframes piTravel {
    0% { left: 0; opacity: 0; }
    15%, 85% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
  }
  .pi-sync__cloud svg { transition: color var(--dur-base) var(--ease-out); }
}

.pi-sync__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}

.pi-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-full);
  background: #e9ebee;
  color: #0b0c0e;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.pi-btn svg { width: 15px; height: 15px; }
.pi-btn:hover { background: #ffffff; }
.pi-btn:disabled { background: rgba(255, 255, 255, 0.08); color: var(--text-tertiary); cursor: default; }
.pi-btn:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .pi-btn { transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
  .pi-btn:active { transform: scale(0.97); }
  .pi-sync.is-syncing .pi-btn svg { animation: piSpin 0.9s linear; }
  @keyframes piSpin { to { transform: rotate(360deg); } }
}

.pi-sync__status { color: var(--text-tertiary); font-size: 13px; }
.pi-sync__status strong { color: var(--text-primary); font-weight: 600; }

/* ---- Downloads queue (tap to clear) ---- */

.pi-queue__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 14px;
}

.pi-queue__count { color: var(--text-tertiary); font-size: 13px; }
.pi-queue__count strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.pi-sort {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.24);
}

.pi-sort__btn {
  height: 30px;
  padding: 0 13px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-tertiary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.pi-sort__btn:hover { color: var(--text-secondary); }
.pi-sort__btn.is-active { background: rgba(255, 255, 255, 0.12); color: var(--text-primary); }

@media (prefers-reduced-motion: no-preference) {
  .pi-sort__btn { transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
}

.pi-rows { display: grid; gap: 8px; }

.pi-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
}

@media (prefers-reduced-motion: no-preference) {
  .pi-row { transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
}

.pi-row.is-cleared { opacity: 0; transform: translateX(26px); pointer-events: none; }

.pi-row__icon {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-tertiary);
}

.pi-row__icon svg { width: 16px; height: 16px; }

.pi-row__name {
  min-width: 0;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pi-row__meta { display: block; margin-top: 2px; color: var(--text-quaternary); font-size: 11.5px; font-weight: 400; }

.pi-row__act {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.pi-row__act:hover { background: rgba(255, 255, 255, 0.14); color: var(--text-primary); }
.pi-row__act:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 2px; }

.pi-queue__done {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 17px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
}

.pi-queue__done svg { width: 18px; height: 18px; color: var(--accent-text); flex: none; }
.pi-queue.is-clear .pi-queue__done { display: flex; }
.pi-queue.is-clear .pi-rows { display: none; }

.pi-reset {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  -webkit-appearance: none;
  appearance: none;
}

.pi-reset:hover { background: rgba(255, 255, 255, 0.14); color: var(--text-primary); }

/* ---- Caption: same quiet voice and look as a figcaption ---- */

.pi-caption {
  margin: 16px 0 0;
  color: var(--text-quaternary);
  font-size: var(--text-xs);
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 620px) {
  .pi-slider__readouts { gap: 10px; }
  .pi-sync { gap: 7px; }
  .pi-device { padding: 10px; }
  .pi-sort { margin-left: 0; }
  .pi-queue__bar { gap: 8px; }
}
