/* Profile Timeline V2 — premium Posts chrome + compact modals */
#ptv2-root {
  /*
   * REF = chrome → composer gap (List/Grid tabs to publisher).
   * Every layer below must use the same distance.
   */
  --ptv2-gap: 8px;
  --ptv2-accent: #e40d0d;
  --ptv2-muted: rgba(255, 255, 255, 0.55);
  --ptv2-line: rgba(255, 255, 255, 0.08);
  position: relative;
  margin-top: 0;
}

html:not([data-mode="night"]):not(.night_mode) #ptv2-root,
body:not(.night_mode) #ptv2-root {
  --ptv2-muted: rgba(0, 0, 0, 0.5);
  --ptv2-line: rgba(0, 0, 0, 0.08);
}

/*
 * Keep the Posts column top flush with the left profile sidebar.
 * Both use .page-margin { margin: 30px 0 }. Shrinking only middlecol
 * pulled the Posts chrome above "Search for posts" / Dreamer card.
 */
.wo_user_profile .middlecol > .page-margin:has(#ptv2-root) {
  margin-top: 30px;
  margin-bottom: 0;
}

.wo_user_profile .profile-completion-bar.page-margin {
  margin-bottom: 0 !important;
}

/* Posts chrome — floating dock (List/Grid + All + Jump + Filters) */
.ptv2-chrome.ptv2-chrome-dock {
  padding: 0;
  margin: 0 0 var(--ptv2-gap);
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
  position: relative;
}

.ptv2-chrome.ptv2-chrome-dock::before {
  display: none;
}

.ptv2-chrome-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ptv2-dock {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 6px 8px;
  border-radius: 18px;
  background: rgba(32, 32, 32, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html:not([data-mode="night"]):not(.night_mode) .ptv2-dock,
body:not(.night_mode) .ptv2-dock {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.06);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.ptv2-view-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.ptv2-view-switch-single {
  gap: 0;
}

.ptv2-dock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.16);
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

html:not([data-mode="night"]):not(.night_mode) .ptv2-dock-btn,
body:not(.night_mode) .ptv2-dock-btn {
  color: rgba(0, 0, 0, 0.55);
  background: rgba(0, 0, 0, 0.06);
}

.ptv2-dock-btn:hover,
.ptv2-dock-btn:focus {
  color: inherit;
  background: rgba(127, 127, 127, 0.28);
  outline: none;
}

.ptv2-dock-btn:active {
  transform: scale(0.96);
}

.ptv2-dock-btn.ptv2-view-tab.active,
.ptv2-dock-btn.ptv2-view-tab[aria-pressed="true"],
.ptv2-dock-btn.ptv2-view-tab[aria-selected="true"] {
  color: #fff;
  background: var(--ptv2-accent);
  box-shadow: 0 2px 8px rgba(228, 13, 13, 0.35);
}

.ptv2-dock-btn svg {
  flex: 0 0 auto;
  display: block;
}

.ptv2-dock-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.16);
  color: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease;
}

html:not([data-mode="night"]):not(.night_mode) .ptv2-dock-select,
body:not(.night_mode) .ptv2-dock-select {
  background: rgba(0, 0, 0, 0.06);
}

.ptv2-dock-select:hover,
.ptv2-dock-select:focus {
  background: rgba(127, 127, 127, 0.28);
  outline: none;
}

.ptv2-dock-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.ptv2-dock-select svg {
  flex: 0 0 auto;
  opacity: 0.7;
}

#ptv2-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 var(--ptv2-gap);
}

.ptv2-chip {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 30px;
  font-size: 12px;
}

html:not([data-mode="night"]):not(.night_mode) .ptv2-chip,
body:not(.night_mode) .ptv2-chip {
  background: rgba(0, 0, 0, 0.06);
}

.ptv2-chip-clear {
  background: rgba(192, 57, 43, 0.22);
}

#ptv2-results {
  min-height: 120px;
  margin-top: 0;
  padding-top: 0;
  /* Flex gap owns layer spacing — beats collapsed margins from .panel / .post-container */
  display: flex;
  flex-direction: column;
  gap: var(--ptv2-gap, 8px);
}

.ptv2-list-item {
  display: block;
  overflow: visible;
  margin: 0 !important;
}

/* Real story cards bring site feed margins (panel 20px / #posts 15px). Zero them here. */
#ptv2-results .ptv2-list-item .post-container,
#ptv2-results .ptv2-list-item .post_wrapper,
#ptv2-results .ptv2-list-item .post,
#ptv2-results .ptv2-list-item .panel,
#ptv2-results > .post-container,
#ptv2-results > .post_wrapper,
#ptv2-results .post-container,
#ptv2-results .post_wrapper,
#ptv2-results .post .panel {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

#ptv2-results > .ptv2-skel {
  margin: 0;
}

/* Skeleton matches the same flex-gap rhythm as real posts */
.ptv2-skel {
  display: flex;
  flex-direction: column;
  gap: var(--ptv2-gap, 8px);
  padding: 0;
  text-align: left;
  opacity: 1;
}

#ptv2-results .ptv2-skel-list-card {
  margin: 0 !important;
}

.ptv2-load-more-wrap {
  margin: 12px 0 4px;
}

.ptv2-loading,
.ptv2-empty,
.ptv2-end,
.ptv2-error {
  padding: 24px 12px;
  text-align: center;
  opacity: 0.9;
}

/* Skeleton loading must not inherit the 24px status padding */
#ptv2-results > .ptv2-loading.ptv2-skel {
  padding: 0;
  text-align: left;
  opacity: 1;
}

.ptv2-skel-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.ptv2-skel-list-card {
  display: block;
  margin: 0;
  padding: 15px 0 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--ptv2-line);
}

.ptv2-skel-list-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 0 15px 12px;
}

.ptv2-skel-avatar {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
}

.ptv2-skel-list-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.ptv2-skel-list-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 15px 0;
}

.ptv2-skel-media {
  display: block;
  width: 100%;
  min-height: 180px;
  background: rgba(255, 255, 255, 0.08);
}

.ptv2-skel-list-card .ptv2-skel-media {
  aspect-ratio: 16 / 10;
  min-height: 160px;
}

.ptv2-skel-line {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.ptv2-skel-line-lg { width: 55%; }
.ptv2-skel-line-md { width: 72%; }
.ptv2-skel-line-sm { width: 34%; height: 10px; }

.ptv2-skel-month-header {
  display: block;
  width: 42%;
  height: 14px;
  margin: 8px 0 14px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.ptv2-skel-grid-card .ptv2-skel-media {
  min-height: 100px;
  border-radius: 8px;
}

.ptv2-skel-grid-card .ptv2-grid-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ptv2-skel-avatar,
.ptv2-skel-media,
.ptv2-skel-line,
.ptv2-skel-month-header {
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(255, 255, 255, 0.14) 45%,
    rgba(255, 255, 255, 0.06) 90%
  );
  background-size: 200% 100%;
  animation: ptv2-skel-shimmer 1.35s ease-in-out infinite;
}

@keyframes ptv2-skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ptv2-skel-avatar,
  .ptv2-skel-media,
  .ptv2-skel-line,
  .ptv2-skel-month-header {
    animation: none;
  }
}

/* Grid — neat card tiles */
.ptv2-month-section {
  display: block;
  width: 100%;
  clear: both;
}

.ptv2-month-header {
  display: block;
  width: 100%;
  margin: 16px 2px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.7;
  grid-column: 1 / -1;
}

.ptv2-grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: var(--ptv2-gap);
  margin-bottom: 8px;
  width: 100%;
}

.ptv2-grid-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 10px;
  background: var(--surface, #212121);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.ptv2-grid-media {
  display: block;
  position: relative;
  overflow: hidden;
  background: rgba(127, 127, 127, 0.12);
  width: 100%;
}

.ptv2-grid-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: rgba(255, 255, 255, 0.04);
  transition: transform 0.25s ease;
}

.ptv2-grid-card:hover .ptv2-grid-media img {
  transform: scale(1.03);
}

.ptv2-grid-placeholder {
  width: 100%;
  height: 100%;
  min-height: 100px;
  background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(255,255,255,0.1));
}

.ptv2-type-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  padding: 3px 7px;
  border-radius: 999px;
}

.ptv2-grid-meta {
  padding: 8px 9px 10px;
}

.ptv2-grid-excerpt {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ptv2-grid-foot {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
  opacity: 0.72;
}

#ptv2-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
}

/* Compact filter / jump modals (desktop card; mobile follows site full-bleed) */
.ptv2-modal-compact {
  width: min(400px, calc(100% - 24px));
  max-width: 400px;
  margin: 1.75rem auto;
}

.ptv2-modal-compact .modal-content {
  border-radius: 12px;
  overflow: hidden;
}

.ptv2-modal-compact .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(127, 127, 127, 0.18);
}

.ptv2-modal-compact .modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
}

.ptv2-modal-compact .modal-body {
  padding: 12px 14px 4px;
  max-height: min(65vh, 480px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ptv2-modal-compact .modal-footer {
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(127, 127, 127, 0.18);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ptv2-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ptv2-field {
  margin-bottom: 12px;
}

.ptv2-field-last {
  margin-bottom: 8px;
}

.ptv2-field > label,
.ptv2-field-label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: 0.75;
}

.ptv2-field select.form-control {
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  font-size: 13px;
}

.ptv2-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 0;
  min-height: 34px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  opacity: 1;
}

.ptv2-ctypes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ptv2-ctype-pill {
  display: inline-flex;
  align-items: center;
  margin: 0;
  cursor: pointer;
  font-weight: 500;
}

.ptv2-ctype-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ptv2-ctype-pill span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.14);
  font-size: 12px;
  transition: background 0.15s ease, color 0.15s ease;
}

.ptv2-ctype-pill input:checked + span {
  background: rgba(192, 57, 43, 0.28);
  color: inherit;
  box-shadow: inset 0 0 0 1px var(--ptv2-accent);
}

.ptv2-ctype-pill input:focus-visible + span {
  outline: 2px solid var(--ptv2-accent);
  outline-offset: 2px;
}

#ptv2-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/*
 * Publisher → first post must equal REF (chrome → publisher).
 * Site .tag_pub_box_bg { margin-bottom: 20px } and mobile post rules use
 * !important — beat them here.
 */
#ptv2-root > .wow_content.tag_pub_box_bg,
#ptv2-root > .tag_pub_box_bg {
  margin-top: 0 !important;
  margin-bottom: var(--ptv2-gap) !important;
}

#ptv2-root > .publisher-box,
#ptv2-root > [class*="tag_pub"] {
  margin-top: 0;
}

#ptv2-chips:not([style*="display: none"]):not([hidden]) {
  margin-top: 0;
  margin-bottom: var(--ptv2-gap);
}

@media (max-width: 768px) {
  #ptv2-root {
    margin-top: 0;
  }

  /* Floating dock keeps inset padding on mobile (not full-bleed card) */
  .ptv2-chrome.ptv2-chrome-dock {
    margin: 0 0 var(--ptv2-gap);
    border-radius: 0;
    box-shadow: none;
  }

  .ptv2-dock {
    gap: 6px;
    min-height: 48px;
    padding: 5px 6px;
    border-radius: 16px;
  }

  .ptv2-dock-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  .ptv2-dock-select {
    min-height: 38px;
    padding: 0 12px;
    font-size: 13.5px;
    border-radius: 11px;
  }

  #ptv2-root > .wow_content.tag_pub_box_bg,
  #ptv2-root > .tag_pub_box_bg {
    margin-bottom: var(--ptv2-gap) !important;
  }

  #ptv2-chips {
    padding: 0 2px;
    margin-bottom: 8px;
  }

  .ptv2-grid-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 2px;
  }

  .ptv2-grid-card {
    border-radius: 8px;
  }

  .ptv2-month-header {
    margin: 12px 4px 8px;
    font-size: 0.75rem;
  }

  .ptv2-load-more-wrap {
    margin: 10px 0 6px;
  }

  /*
   * Match site mobile wow_mat_mdl modals (style.css):
   * full-bleed edge-to-edge, no border-radius.
   */
  #ptv2-filter-modal.modal.fade,
  #ptv2-jump-modal.modal.fade {
    padding: 0 !important;
  }

  #ptv2-filter-modal .ptv2-modal-compact,
  #ptv2-jump-modal .ptv2-modal-compact {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  #ptv2-filter-modal .ptv2-modal-compact .modal-content,
  #ptv2-jump-modal .ptv2-modal-compact .modal-content {
    border-radius: 0 !important;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  #ptv2-filter-modal .ptv2-modal-compact .modal-body,
  #ptv2-jump-modal .ptv2-modal-compact .modal-body {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-left: 15px;
    padding-right: 15px;
  }

  #ptv2-filter-modal .ptv2-modal-compact .modal-header,
  #ptv2-jump-modal .ptv2-modal-compact .modal-header,
  #ptv2-filter-modal .ptv2-modal-compact .modal-footer,
  #ptv2-jump-modal .ptv2-modal-compact .modal-footer {
    flex: 0 0 auto;
    padding-left: 15px;
    padding-right: 15px;
  }
}

@media (max-width: 600px) {
  .ptv2-dock {
    gap: 5px;
    padding: 4px 5px;
    border-radius: 15px;
  }

  .ptv2-dock-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .ptv2-dock-select {
    min-height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  .ptv2-field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

@media (max-width: 380px) {
  .ptv2-dock {
    gap: 4px;
  }

  .ptv2-dock-select-label {
    max-width: 4.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #ptv2-root * {
    scroll-behavior: auto !important;
  }

  .ptv2-grid-card:hover .ptv2-grid-media img {
    transform: none;
  }
}
