/**
 * Post / discussion page — PostView.tsx
 * Scoped to #post-view-page
 */

#post-view-page {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  --pv-bg: #f1f5f9;
  --pv-card: #ffffff;
  --pv-text: #0f172a;
  --pv-text-sub: #374151;
  --pv-text-muted: #6b7280;
  --pv-border: #e2e8f0;
  --pv-border-light: #f1f5f9;
  --pv-blue: #1d4ed8;
  --pv-blue-light: #eff6ff;
  --pv-red: #dc2626;
  --pv-red-light: #fef2f2;
  --pv-topbar-sticky: 0;
  --pv-topbar-h: 2.75rem;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  background: var(--pv-bg);
  color: var(--pv-text);
  font-family: Inter, system-ui, sans-serif;
}

/* Full-bleed в колонке main (как docs-view): без зазора под site header */
body.eidoc-public.eidoc-route-post-view #page-component.eidoc-main-post-view,
body.eidoc-public.eidoc-route-post-view #page-component.eidoc-main-with-sidebar.eidoc-main-post-view {
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

body.eidoc-public.eidoc-route-post-view #page-component.eidoc-main-post-view > #post-view-page.eidoc-page,
body.eidoc-public.eidoc-route-post-view #page-component.eidoc-main-with-sidebar.eidoc-main-post-view > #post-view-page.eidoc-page {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.eidoc-public.eidoc-route-post-view .eidoc-layout-row {
  padding-top: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* ── Sticky sub-bar: на всю ширину main, сразу под site header ── */
.post-view-topbar {
  position: sticky;
  top: var(--pv-topbar-sticky);
  z-index: 20;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  flex-shrink: 0;
  background: var(--pv-card);
  border-bottom: 1px solid var(--pv-border);
  padding: 0 1.25rem;
  margin: 0;
}

.post-view-topbar__inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
}

.post-view-topbar__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  width: 100%;
}

.post-view-topbar__back,
.post-view-topbar__crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--pv-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.375rem;
  border-radius: 0.375rem;
  text-decoration: none;
  flex-shrink: 0;
}

.post-view-topbar__back:hover,
.post-view-topbar__crumb:hover {
  color: var(--pv-blue);
}

.post-view-topbar__sep {
  width: 1px;
  height: 1rem;
  background: var(--pv-border);
  flex-shrink: 0;
}

.post-view-topbar__title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--pv-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 22rem;
}

.post-view-topbar__spacer {
  flex: 1;
}

.post-view-topbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.35rem 0.625rem;
  border-radius: 0.4375rem;
  border: 1px solid var(--pv-border);
  background: var(--pv-card);
  color: var(--pv-text-muted);
  cursor: pointer;
  text-decoration: none;
}

.post-view-topbar__btn:hover {
  border-color: var(--pv-blue);
  color: var(--pv-blue);
  background: var(--pv-blue-light);
}

.post-view-topbar__btn--saved {
  border-color: var(--pv-blue);
  background: var(--pv-blue-light);
  color: var(--pv-blue);
}

/* ── Layout ── */
.post-view-shell {
  padding: 1.5rem 1.25rem 3.75rem;
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}

.post-view-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-view-aside {
  width: 17rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  position: sticky;
  top: calc(var(--pv-topbar-sticky) + var(--pv-topbar-h) + 0.5rem);
}

@media (max-width: 1023px) {
  .post-view-aside {
    display: none;
  }
}

/* ── DS card shell ── */
.post-view-card {
  background: var(--pv-card);
  border-radius: 0.75rem;
  border: 1px solid var(--pv-border);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.post-view-card__body {
  padding: 1.5rem 1.75rem;
}

/* Post card inside page — flatten feed chrome */
#post-view-page .post-view-post-wrap .ds-card {
  border-radius: 0.75rem !important;
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

#post-view-page .post-view-post-wrap .ds-card:hover {
  box-shadow: none !important;
  border-color: transparent !important;
}

/* ── Comment form card ── */
.post-view-comment-form__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--pv-text);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.post-view-comment-form__head strong {
  color: var(--pv-blue);
  font-weight: 600;
}

.post-view-comment-form__avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.post-view-comment-form__textarea {
  width: 100%;
  padding: 0.75rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
  border: 1px solid var(--pv-border);
  resize: vertical;
  min-height: 6rem;
  color: var(--pv-text);
  line-height: 1.6;
  font-family: inherit;
  box-sizing: border-box;
  background: var(--pv-card);
}

.post-view-comment-form__textarea:focus {
  outline: none;
  border-color: var(--pv-blue);
}

.post-view-comment-form__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

.post-view-comment-form__icon-btn {
  padding: 0.4375rem;
  border-radius: 0.4375rem;
  border: 1px solid var(--pv-border);
  background: var(--pv-card);
  color: var(--pv-text-muted);
  cursor: pointer;
  display: inline-flex;
}

.post-view-comment-form__submit {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5625rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--pv-blue);
  color: #fff;
  cursor: pointer;
  margin-left: auto;
}

.post-view-comment-form__submit:disabled {
  background: var(--pv-border);
  color: var(--pv-text-muted);
  cursor: default;
}

.post-view-guest-cta {
  text-align: center;
  padding: 2rem 1.5rem;
}

.post-view-guest-cta h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.post-view-guest-cta p {
  font-size: 0.8125rem;
  color: var(--pv-text-muted);
  margin: 0 0 1rem;
}

.post-view-guest-cta__actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Comments block ── */
.post-view-comments__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.25rem;
  border-bottom: 1px solid var(--pv-border);
}

.post-view-comments__title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--pv-text);
  margin: 0;
}

.post-view-comments__title i {
  color: var(--pv-blue);
}

.post-view-comments__count {
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.625rem;
  background: var(--pv-blue-light);
  color: var(--pv-blue);
  font-weight: 600;
}

.post-view-comments__sort {
  display: flex;
  gap: 0.125rem;
}

.post-view-comments__sort-btn {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3125rem 0.75rem;
  border-radius: 0.4375rem;
  border: none;
  background: transparent;
  color: var(--pv-text-muted);
  cursor: pointer;
}

.post-view-comments__sort-btn--active {
  background: var(--pv-blue-light);
  color: var(--pv-blue);
}

.post-view-comments__body {
  padding: 0 1.25rem 1rem;
}

#post-view-page #comment-thread .comment-item,
#post-view-page #comment-thread > div {
  border-bottom: 1px solid var(--pv-border-light);
}

/* ── Sidebar author ── */
.post-view-author-card__cover {
  height: 4.5rem;
  border-radius: 0.75rem 0.75rem 0 0;
  background: linear-gradient(135deg, #1d4ed8 0%, #7c3aed 100%);
  overflow: hidden;
}

.post-view-author-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-view-author-card__body {
  padding: 0 1rem 1rem;
  position: relative;
}

.post-view-author-card__avatar {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  border: 3px solid var(--pv-card);
  margin-top: -1.625rem;
  margin-bottom: 0.5rem;
  object-fit: cover;
  background: var(--pv-blue);
}

.post-view-author-card__name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--pv-text);
  margin: 0 0 0.125rem;
}

.post-view-author-card__meta {
  font-size: 0.75rem;
  color: var(--pv-text-muted);
  margin-bottom: 0.75rem;
}

.post-view-author-card__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.post-view-author-card__stat {
  text-align: center;
  padding: 0.5rem 0.25rem;
  border-radius: 0.5rem;
  background: var(--pv-bg);
}

.post-view-author-card__stat-val {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--pv-text);
}

.post-view-author-card__stat-label {
  font-size: 0.625rem;
  color: var(--pv-text-muted);
}

.post-view-author-card__btn {
  width: 100%;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.5625rem;
  border-radius: 0.5rem;
  border: 1px solid var(--pv-border);
  background: var(--pv-card);
  color: var(--pv-text-sub);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  box-sizing: border-box;
}

.post-view-author-card__btn:hover {
  background: var(--pv-blue-light);
  color: var(--pv-blue);
  border-color: var(--pv-blue);
}

/* Related + meta sidebar */
.post-view-side-section__label {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--pv-border);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pv-text-muted);
}

.post-view-side-meta__row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  padding: 0.3125rem 0;
  border-bottom: 1px solid var(--pv-border-light);
}

.post-view-side-meta__row:last-child {
  border-bottom: none;
}

.post-view-side-meta__label {
  color: var(--pv-text-muted);
}

.post-view-side-meta__value {
  font-weight: 500;
  color: var(--pv-text);
}

/* Related posts — same card pattern as «О публикации» */
.post-view-related-card {
  overflow: hidden;
}

.post-view-related-card__list {
  padding: 0;
}

.post-view-related-card__item {
  display: block;
  padding: 0.6875rem 0.875rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.post-view-related-card__item--bordered {
  border-bottom: 1px solid var(--pv-border-light);
}

.post-view-related-card__item:hover {
  background: var(--pv-bg);
}

.post-view-related-card__title {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--pv-text);
  margin-bottom: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-view-related-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6875rem;
  color: var(--pv-text-muted);
}

.post-view-related-card__type {
  font-weight: 600;
  padding: 0.0625rem 0.4375rem;
  border-radius: 0.5rem;
  background: var(--pv-blue-light);
  color: var(--pv-blue);
}

.post-view-related-card__stat {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.post-view-related-card__stat i {
  font-size: 0.625rem;
}

/* Community sidebar card on post page */
#post-view-page .post-view-community-card {
  border-radius: 0.75rem;
  overflow: hidden;
}

/* Deleted state */
.post-view-deleted {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
  background: var(--pv-card);
  border-radius: 0.75rem;
  border: 1px dashed var(--pv-border);
}

/* Mobile related */
.post-view-related-mobile {
  display: none;
}

@media (max-width: 1023px) {
  .post-view-related-mobile {
    display: block;
  }
}

/* Skeleton */
.post-view-skeleton .post-view-card {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
