/* xpost post: faithful X-style post replica */
/* CONTRACT: uses base.css tokens for design tokens (:text, :bg, :surface, :border, :accent, --r-*) */
/*           uses [data-theme="light|dim|dark"] attribute for post-specific colors */

/* Base post styles */
.x-post {
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: #0f1419;
  background: #ffffff;
}

/* Header styles */
.x-row {
  display: flex;
  padding: 12px 12px 8px 12px;
}

.x-avatar,
.x-avatar-gradient,
.x-avatar-initials {
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  flex-shrink: 0;
}

.x-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
}

.x-header {
  margin-left: 12px;
  line-height: 1.2;
}

.x-name {
  font-size: 15px;
  font-weight: 700;
  color: #0f1419;
}

.x-handle,
.x-sep,
.x-time,
.x-src {
  font-size: 15px;
  color: #657786;
}

.x-handle { color: #657786; }
.x-sep { color: #657786; margin: 0 4px; }
.x-time { color: #657786; }
.x-src { color: #657786; }

/* Text content */
.x-text {
  font-size: 15px;
  line-height: 1.4;
  margin: 4px 0 12px 0;
  word-wrap: break-word;
}

.x-text br {
  content: '';
  display: block;
}

.x-link {
  color: #1d9bf0;
  text-decoration: none;
}

.x-link:hover {
  text-decoration: underline;
}

/* Verified badge */
.x-verified {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  vertical-align: text-bottom;
}

.x-verified-blue { color: #1d9bf0; }
.x-verified-gold { color: #d97706; }
.x-verified-gray { color: #6b7280; }

/* Media grid */
.x-media {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  border-radius: 16px;
  overflow: hidden;
}

.x-media[data-count="1"] {
  grid-template-columns: 1fr;
}

.x-media[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}

.x-media[data-count="3"] {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
}

.x-media[data-count="3"] .x-mg-cell-large {
  grid-column: 1 / 2;
  grid-row: 1 / 3;
}

.x-media[data-count="3"] .x-mg-cell-large + .x-mg-cell {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.x-media[data-count="3"] .x-mg-cell-large + .x-mg-cell + .x-mg-cell {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
}

.x-media[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

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

/* Engagement row */
.x-eng {
  display: flex;
  border-top: 1px solid #eff3f4;
  padding-top: 8px;
  margin-top: 8px;
}

.x-eng-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  color: #657786;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.x-eng-cell:hover {
  color: #1d9bf0;
}

.x-eng svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.x-count {
  color: #657786;
}

/* Watermark for exported image */
.x-watermark {
  display: block;
  text-align: center;
  font-size: 11px;
  color: #657786;
  margin-top: 16px;
  letter-spacing: 0.5px;
}

/* Theme overrides for light */
[data-theme="light"] {
  color: #0f1419;
}

[data-theme="light"] .x-name {
  color: #0f1419;
}

[data-theme="light"] .x-handle,
[data-theme="light"] .x-sep,
[data-theme="light"] .x-time,
[data-theme="light"] .x-src {
  color: #536471;
}

[data-theme="light"] .x-text .x-link {
  color: #1d9bf0;
}

[data-theme="light"] .x-verified-blue { color: #1d9bf0; }
[data-theme="light"] .x-verified-gold { color: #d97706; }
[data-theme="light"] .x-verified-gray { color: #6b7280; }

[data-theme="light"] .x-eng {
  border-top-color: #eff3f4;
}

[data-theme="light"] .x-eng-cell {
  color: #536471;
}

[data-theme="light"] .x-eng-cell:hover {
  color: #1d9bf0;
}

[data-theme="light"] .x-count {
  color: #536471;
}

[data-theme="light"] .x-watermark {
  color: #536471;
}

/* Theme overrides for dim (X dim mode colors) */
[data-theme="dim"] {
  background: #15202b;
  color: #e7e9ea;
}

[data-theme="dim"] .x-name {
  color: #e7e9ea;
}

[data-theme="dim"] .x-handle,
[data-theme="dim"] .x-sep,
[data-theme="dim"] .x-time,
[data-theme="dim"] .x-src {
  color: #71767b;
}

[data-theme="dim"] .x-text .x-link {
  color: #1d9bf0;
}

[data-theme="dim"] .x-verified-blue { color: #1d9bf0; }
[data-theme="dim"] .x-verified-gold { color: #d97706; }
[data-theme="dim"] .x-verified-gray { color: #6b7280; }

[data-theme="dim"] .x-eng {
  border-top-color: #38444d;
}

[data-theme="dim"] .x-eng-cell {
  color: #71767b;
}

[data-theme="dim"] .x-eng-cell:hover {
  color: #1d9bf0;
}

[data-theme="dim"] .x-count {
  color: #71767b;
}

[data-theme="dim"] .x-watermark {
  color: #71767b;
}

/* Theme overrides for dark (X dark mode - pure #000) */
[data-theme="dark"] {
  background: #000000;
  color: #e7e9ea;
}

[data-theme="dark"] .x-name {
  color: #e7e9ea;
}

[data-theme="dark"] .x-handle,
[data-theme="dark"] .x-sep,
[data-theme="dark"] .x-time,
[data-theme="dark"] .x-src {
  color: #71767b;
}

[data-theme="dark"] .x-text .x-link {
  color: #1d9bf0;
}

[data-theme="dark"] .x-verified-blue { color: #1d9bf0; }
[data-theme="dark"] .x-verified-gold { color: #d97706; }
[data-theme="dark"] .x-verified-gray { color: #6b7280; }

[data-theme="dark"] .x-eng {
  border-top-color: #2f3336;
}

[data-theme="dark"] .x-eng-cell {
  color: #71767b;
}

[data-theme="dark"] .x-eng-cell:hover {
  color: #1d9bf0;
}

[data-theme="dark"] .x-count {
  color: #71767b;
}

[data-theme="dark"] .x-watermark {
  color: #71767b;
}

/* Accessibility: focus-visible for keyboard navigation */
:focus-visible {
  outline: 3px solid rgba(29, 155, 240, 0.4);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .x-eng-cell {
    transition: none;
  }
}

/* Responsive */
@media (max-width: 600px) {
  .x-avatar,
  .x-avatar-gradient,
  .x-avatar-initials {
    width: 40px;
    height: 40px;
  }

  .x-avatar-initials {
    font-size: 16px;
  }

  .x-header {
    margin-left: 10px;
  }
}
