/* ===================================================================
   VED Telegram Mirror — Design System
   Navy #25315e  ·  Red #cc1e24  ·  Lora + Inter
   =================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg:           #f3f5f9;
  --bg-elevated:  rgba(255, 255, 255, 0.88);
  --bg-strong:    #ffffff;
  --text:         #1e2338;
  --muted:        #5d6478;
  --border:       rgba(37, 49, 94, 0.10);
  --accent:       #25315e;
  --accent-soft:  rgba(37, 49, 94, 0.10);
  --accent-strong:#1a2345;
  --signal:       #cc1e24;
  --signal-soft:  rgba(204, 30, 36, 0.10);
  --shadow:       0 18px 50px rgba(37, 49, 94, 0.12);
  --shadow-sm:    0 4px 16px rgba(37, 49, 94, 0.08);
  --radius-xl:    28px;
  --radius-lg:    20px;
  --radius-md:    14px;
  --radius-sm:    10px;
  --heading:      "Lora", "Georgia", serif;
  --sans:         "Inter", "Segoe UI", sans-serif;
  --transition:   0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #111827;
  --bg-elevated:  rgba(30, 35, 56, 0.92);
  --bg-strong:    #1e2338;
  --text:         #f0f2f8;
  --muted:        #9ca3b8;
  --border:       rgba(160, 170, 200, 0.12);
  --accent:       #8fa8d8;
  --accent-soft:  rgba(143, 168, 216, 0.14);
  --accent-strong:#b3c8f0;
  --signal:       #f28181;
  --signal-soft:  rgba(242, 129, 129, 0.14);
  --shadow:       0 18px 50px rgba(0, 0, 0, 0.36);
  --shadow-sm:    0 4px 16px rgba(0, 0, 0, 0.24);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 49, 94, 0.14), transparent 32%),
    radial-gradient(circle at 90% 0%, rgba(204, 30, 36, 0.06), transparent 28%),
    linear-gradient(180deg, rgba(37, 49, 94, 0.06), transparent 18%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a, button, input, label, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ---------- Layout Shell ---------- */
.site-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

/* ---------- Hero ---------- */
.hero {
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  animation: hero-in 0.6s var(--transition) both;
}

@keyframes hero-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero__brand {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.hero__avatar {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--accent-soft);
  background: white; /* Фон для логотипа */
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero__avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.hero__avatar img.is-logo {
  object-fit: contain;
  padding: 12px;
}

.hero__copy {
  min-width: 0;
}

.hero__title {
  font-family: var(--heading);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 4px;
  color: var(--text);
}

.hero__description {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Actions row */
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn--accent {
  background: linear-gradient(135deg, #25315e 0%, #1a2345 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 49, 94, 0.24);
}

.btn--accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(37, 49, 94, 0.32);
  text-decoration: none;
}

.btn--outline {
  border: 1px solid var(--border);
  background: var(--bg-strong);
  color: var(--text);
}

.btn--outline:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.btn--icon-only {
  padding: 10px;
}

.btn--icon-only span { display: none; }

/* Toolbar row */
.hero__toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: all var(--transition);
}

.tool-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-btn svg {
  width: 20px;
  height: 20px;
}

/* Theme toggle icons */
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
:root:not([data-theme="dark"]) .icon-sun  { display: none; }
:root:not([data-theme="dark"]) .icon-moon { display: block; }

.toolbar__updated {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- Post Feed ---------- */
.post-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Post Card */
.post-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-strong);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--transition);
  animation: card-in 0.5s var(--transition) both;
}

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

@keyframes card-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger animation */
.post-card:nth-child(1)  { animation-delay: 0.00s; }
.post-card:nth-child(2)  { animation-delay: 0.06s; }
.post-card:nth-child(3)  { animation-delay: 0.12s; }
.post-card:nth-child(4)  { animation-delay: 0.16s; }
.post-card:nth-child(5)  { animation-delay: 0.20s; }
.post-card:nth-child(6)  { animation-delay: 0.24s; }
.post-card:nth-child(7)  { animation-delay: 0.26s; }
.post-card:nth-child(8)  { animation-delay: 0.28s; }
.post-card:nth-child(9)  { animation-delay: 0.30s; }
.post-card:nth-child(10) { animation-delay: 0.32s; }

/* Card media */
.post-card__media {
  position: relative;
}

.post-card__media img,
.post-card__media video {
  width: 100%;
  display: block;
  cursor: pointer;
}

.post-card__media video {
  max-height: 480px;
  object-fit: contain;
  background: #000;
}

/* Media gallery */
.post-card__gallery {
  display: grid;
  gap: 2px;
}

.post-card__gallery--2 { grid-template-columns: 1fr 1fr; }
.post-card__gallery--3 { grid-template-columns: 1fr 1fr; }
.post-card__gallery--3 > :first-child { grid-column: 1 / -1; }
.post-card__gallery--4 { grid-template-columns: 1fr 1fr; }

.post-card__gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
  transition: filter 0.2s;
}
.post-card__gallery img:hover {
  filter: brightness(0.92);
}

/* Card body */
.post-card__body {
  position: relative;
  padding: 20px 68px 16px 20px;
}

.post-card__text {
  font-size: 0.94rem;
  line-height: 1.65;
  word-break: break-word;
}

.post-card__text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-card__text b,
.post-card__text strong {
  font-weight: 700;
}

.post-card__text i,
.post-card__text em {
  font-style: italic;
}

.post-card__text pre,
.post-card__text code {
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.85em;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

.post-card__text pre {
  padding: 12px 16px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
}

.post-card__text blockquote {
  margin: 8px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--signal);
  background: var(--signal-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--muted);
}

/* Forwarded tag */
.post-card__forwarded {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
}

.post-card__forwarded svg {
  width: 14px;
  height: 14px;
}

/* Copy button */
.post-card__copy {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
}

.post-card__copy:hover {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.post-card__copy svg {
  width: 18px;
  height: 18px;
}

.post-card__copy.is-copied {
  color: #16a34a;
  border-color: #16a34a;
  background: rgba(22, 163, 74, 0.08);
}

/* Card footer */
.post-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.post-card__date {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-card__date svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.post-card__views {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.post-card__views svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.post-card__tg-link {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition);
  margin-left: auto;
}

.post-card__tg-link:hover {
  color: var(--signal);
  text-decoration: none;
}

.post-card__tg-link svg {
  width: 14px;
  height: 14px;
}

/* Document attachment */
.post-card__document {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin: 10px 0;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.post-card__document:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.post-card__document svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--accent);
}

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

.post-card__doc-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-card__doc-size {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------- Comments Section ---------- */
.post-card__comments {
  border-top: 1px solid var(--border);
}

.comments__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.comments__toggle:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.comments__toggle svg:first-child {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.comments__chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  transition: transform var(--transition);
}

.comments__toggle.is-open .comments__chevron {
  transform: rotate(180deg);
}

.comments__list {
  padding: 0 20px 16px;
}

.comment {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  animation: comment-in 0.3s ease both;
}

.comment:first-child {
  border-top: none;
}

@keyframes comment-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.comment__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.comment__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment__avatar-initials {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
}

.comment__body {
  min-width: 0;
  flex: 1;
}

.comment__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.comment__author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.comment__date {
  font-size: 0.7rem;
  color: var(--muted);
}

.comment__text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.comment__text a {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- State Messages ---------- */
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}

.state-message h2 {
  font-family: var(--heading);
  font-size: 1.2rem;
  margin: 16px 0 8px;
  color: var(--text);
}

.state-message p {
  font-size: 0.88rem;
  margin: 0;
}

.state-icon {
  width: 48px;
  height: 48px;
  stroke: var(--muted);
  opacity: 0.5;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Load More */
.load-more-btn {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 28px auto 0;
  padding: 14px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-strong);
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.load-more-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(12px);
  animation: lightbox-in 0.3s ease;
  cursor: zoom-out;
}

@keyframes lightbox-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox__img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  cursor: default;
  animation: lightbox-img-in 0.3s ease;
}

@keyframes lightbox-img-in {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.lightbox__close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background 0.2s;
  cursor: pointer;
}

.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox__close svg {
  width: 22px;
  height: 22px;
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 48px 24px 24px;
  color: var(--muted);
}

.footer__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.footer__logo {
  font-family: var(--heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.footer__tagline {
  font-size: 0.8rem;
  color: var(--muted);
}

.footer__links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
  font-size: 0.82rem;
}

.footer__links a {
  color: var(--muted);
  transition: color var(--transition);
}
.footer__links a:hover {
  color: var(--accent);
}

.footer__copy {
  font-size: 0.72rem;
  margin: 0;
  opacity: 0.6;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  z-index: 2000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-shell {
    width: calc(100% - 20px);
    padding: 16px 0 32px;
  }

  .hero {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  .hero__brand {
    gap: 14px;
  }

  .hero__avatar {
    width: 60px;
    height: 60px;
  }

  .hero__title {
    font-size: 1.3rem;
  }

  .hero__description {
    font-size: 0.82rem;
  }

  .hero__actions {
    gap: 8px;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .btn--icon-only {
    padding: 8px;
  }

  .post-card__body {
    padding: 16px 56px 14px 16px;
  }

  .post-card__copy {
    top: 16px;
    right: 14px;
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .post-card__footer {
    padding: 10px 16px;
    flex-wrap: wrap;
  }

  .post-card__text {
    font-size: 0.9rem;
  }
}

/* Selection */
::selection {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
