/* public/assets/css/post-card.css
   Shared post card styles for feed.html and profile.html. */

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  position: relative;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.post-header {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.post-avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-500);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
}

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

.post-author-info {
  min-width: 0;
}

.post-author-link {
  display: inline-block;
  color: inherit;
  text-decoration: none;
  position: relative;
  z-index: 2;
}

.post-author-link:hover h4,
.post-author-link:focus-visible h4 {
  text-decoration: underline;
}

.post-author-info h4 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--heading);
  overflow-wrap: anywhere;
}

.post-author-info time,
.post-author-info span {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Keep the uploaded image's own aspect ratio instead of cropping it into a
   fixed 220px band. `contain` guarantees the photo is never stretched, while
   `max-height` stops very tall portrait photos from dominating the feed. */
.post-media {
  position: relative;
  overflow: hidden;
  background: var(--surface-alt);
}

.post-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 450px;
  object-fit: contain;
  background: var(--surface-alt);
  transition: transform 0.35s ease;
}

.post-card:hover .post-image {
  transform: scale(1.03);
}

.post-media__badge {
  position: absolute;
  top: 0.7rem;
  inset-inline-start: 0.7rem;
  z-index: 2;
  margin-bottom: 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(8px);
}

.post-media__count {
  position: absolute;
  bottom: 0.7rem;
  inset-inline-end: 0.7rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
}

.post-body {
  padding: 0.95rem 1rem 0.85rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.post-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.post-category-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.post-code-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.3);
  color: var(--brand-600);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.post-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
}

.post-type-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.badge-offer {
  background: rgba(255, 247, 237, 0.94);
  color: #c2410c;
  border: 1px solid rgba(249, 115, 22, 0.28);
}

html.dark .badge-offer {
  background: rgba(249, 115, 22, 0.22);
  color: #fdba74;
  border-color: rgba(249, 115, 22, 0.35);
}

.badge-request {
  background: rgba(239, 246, 255, 0.94);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.28);
}

html.dark .badge-request {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.35);
}

.post-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 0.5rem;
  overflow-wrap: anywhere;
}

.post-title-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* Stretched link: clicking anywhere on the card opens the detail page. */
.post-title-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.post-title-link:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

.post-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

.post-price-box {
  margin-top: auto;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  margin-block-start: 0.85rem;
}

.post-price-box--plain {
  padding: 0.55rem 0.85rem;
}

.post-price-box__label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.post-price-box__value {
  font-size: 1.08rem;
  font-weight: 900;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.post-price-box--plain .post-price-box__value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--brand-600);
}

/* ------------------------------------------------------------ post actions */
.post-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 1rem 0.9rem;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 2;
}

.post-actions__group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.post-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease,
    transform 0.2s ease;
}

.post-action:hover {
  border-color: var(--brand-500);
  background: rgba(249, 115, 22, 0.08);
  color: var(--brand-600);
}

.post-action:active {
  transform: scale(0.97);
}

.post-action:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

.post-action--like.is-liked {
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(244, 63, 94, 0.1);
  color: #e11d48;
}

.post-action--like.is-liked:hover {
  border-color: rgba(244, 63, 94, 0.7);
  background: rgba(244, 63, 94, 0.16);
  color: #be123c;
}

html.dark .post-action--like.is-liked {
  color: #fb7185;
}

html.dark .post-action--like.is-liked:hover {
  color: #fda4af;
}

.post-action--contact {
  flex: 1 1 auto;
  padding: 0.52rem 0.9rem;
  border-color: transparent;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  font-size: 0.84rem;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.24);
}

.post-action--contact:hover {
  border-color: transparent;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.34);
}

.post-action__count {
  min-width: 1ch;
  font-variant-numeric: tabular-nums;
}

/* Small toast used when a like write fails. */
.post-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 2000;
  max-width: min(90vw, 26rem);
  padding: 0.7rem 1rem;
  border: 1px solid rgba(244, 63, 94, 0.4);
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 1rem);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.post-toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

@media (max-width: 480px) {
  .post-image {
    max-height: 380px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .post-card,
  .post-card:hover,
  .post-card:hover .post-image {
    transform: none;
  }

  .post-image,
  .post-action,
  .post-toast {
    transition: none;
  }
}

/* Request states shown on feed cards */
.badge-closed {
  margin-inline-start: 0.35rem;
  background: rgba(100, 116, 139, 0.18);
  color: var(--muted);
}

.badge-negotiating {
  margin-inline-start: 0.35rem;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

html.dark .badge-negotiating {
  color: #fcd34d;
}

.post-qty {
  margin: 0.4rem 0 0;
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 700;
}

/* Owner "⋯" menu on own post cards */
.post-menu {
  position: relative;
  margin-inline-start: auto;
  z-index: 3;
  flex-shrink: 0;
}

.post-menu__toggle {
  list-style: none;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease;
}

.post-menu__toggle::-webkit-details-marker { display: none; }

.post-menu__toggle:hover,
.post-menu__toggle:focus-visible,
.post-menu[open] .post-menu__toggle {
  background: var(--surface-alt);
  color: var(--heading);
}

.post-menu__list {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 170px;
  max-width: min(260px, 80vw);
  padding: 0.35rem;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.post-menu__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--heading);
  font: inherit;
  font-size: 0.9rem;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.post-menu__item:hover,
.post-menu__item:focus-visible { background: var(--surface-alt); }
.post-menu__item--danger { color: #ef4444; }
.post-menu__item:disabled { opacity: 0.6; cursor: progress; }

.post-menu__note {
  margin: 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}
