/* === pochitayte.ru — teletype-style design === */

:root {
  --bg: #ffffff;
  --bg-alt: #f7f7f7;
  --bg-card: #ffffff;
  --bg-hover: #fafafa;
  --text: #1a1a1a;
  --text-2: #555555;
  --text-3: #999999;
  --border: #ebebeb;
  --accent: #1a8917;
  --accent-hover: #156d13;
  --link: #1a8917;
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 8px rgba(0,0,0,0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 8px;
  --max-w: 680px;
  --header-h: 52px;
  --transition: 0.15s ease;
}

[data-theme="dark"] {
  --bg: #141414;
  --bg-alt: #1a1a1a;
  --bg-card: #1e1e1e;
  --bg-hover: #242424;
  --text: #e6e6e6;
  --text-2: #a0a0a0;
  --text-3: #666666;
  --border: #2a2a2a;
  --accent: #2ea043;
  --accent-hover: #3fb950;
  --link: #3fb950;
  --shadow: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-hover: 0 2px 8px rgba(0,0,0,0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

a { color: inherit; text-decoration: none; }
button { border: none; background: none; cursor: pointer; font-family: inherit; color: inherit; }

::selection { background: var(--accent); color: #fff; }
::-webkit-scrollbar { width: 0; }

/* === HEADER === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 120px;
}

.header-right { justify-content: flex-end; }

.header-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  transition: color var(--transition);
}
.header-link:hover, .header-link.active { color: var(--text); }

.header-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.logo-dot { color: var(--text-3); font-weight: 400; }

.theme-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-3);
  transition: all var(--transition);
}
.theme-btn:hover { color: var(--text); background: var(--bg-alt); }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* === TABS === */
.tabs {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  transition: background var(--transition), border-color var(--transition);
}

.tabs-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs-inner::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}
.tab:hover { color: var(--text-2); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.tab svg { opacity: 0.6; }
.tab.active svg { opacity: 1; }

/* === MAIN === */
.main {
  min-height: calc(100vh - var(--header-h) - 60px);
}

/* === FEED === */
.feed {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* === POST CARD with cover preview === */
.post-card {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition);
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.post-card-content {
  flex: 1;
  min-width: 0;
}

.post-cover-link {
  flex-shrink: 0;
  display: block;
  margin-top: 8px;
}

.post-cover {
  width: 120px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.post-cover-link:hover .post-cover img {
  transform: scale(1.04);
  opacity: 0.9;
}

.post-cover-placeholder {
  opacity: 0.3;
}

.post-author {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.post-author:hover .post-author-name { color: var(--accent); }

.post-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.post-avatar--photo {
  padding: 0;
  background: transparent !important;
  overflow: hidden;
}

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

.post-author-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-author-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: color var(--transition);
}

.post-date {
  font-size: 13px;
  color: var(--text-3);
}

.post-body { display: block; }
.post-body:hover .post-title { color: var(--text-2); }

.post-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
  transition: color var(--transition);
}

.post-excerpt {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

.post-read-time {
  font-size: 13px;
  color: var(--text-3);
}

.post-views {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-3);
}
.post-views svg { opacity: 0.5; }

/* Infinite scroll loader */
.feed-loader {
  display: flex;
  justify-content: center;
  padding: 32px 0;
}

.loader-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.feed-loader.hidden { display: none; }

.feed-end {
  text-align: center;
  padding: 24px 0 32px;
  font-size: 13px;
  color: var(--text-3);
}

/* Post card animation */
.post-card {
  animation: fadeUp 0.35s ease both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === AUTHOR CARD === */
.author-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--transition);
}
.author-card:hover { opacity: 0.8; }

.author-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.author-card-info { flex: 1; min-width: 0; }

.author-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.author-card-bio {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.author-card-stats {
  font-size: 13px;
  color: var(--text-3);
}

/* === PROFILE === */
.profile {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 20px;
}

.profile-header {
  text-align: center;
  padding: 40px 0 32px;
  border-bottom: 1px solid var(--border);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: #fff;
  margin: 0 auto 16px;
}

.profile-name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.profile-bio {
  font-size: 15px;
  color: var(--text-2);
  max-width: 440px;
  margin: 0 auto 12px;
}

.profile-stats-row {
  font-size: 14px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.meta-dot { color: var(--text-3); opacity: 0.4; }

.profile-posts { }

.profile-post {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity var(--transition);
}
.profile-post:hover { opacity: 0.75; }

.profile-post-content {
  flex: 1;
  min-width: 0;
}

.profile-post-cover {
  width: 100px;
  height: 68px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

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

.profile-post-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.profile-post-excerpt {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.profile-post-meta {
  font-size: 13px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* === ARTICLE === */
.article {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.article-head { margin-bottom: 24px; }

.article-author-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.article-author-link:hover .article-author-name { color: var(--accent); }

.article-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.article-avatar--photo {
  padding: 0;
  background: transparent !important;
  overflow: hidden;
}

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

.article-author-name {
  font-size: 15px;
  font-weight: 600;
  transition: color var(--transition);
}

.article-meta {
  font-size: 13px;
  color: var(--text-3);
}

.article-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

/* Article Cover */
.article-cover {
  margin-bottom: 32px;
  border-radius: var(--radius);
  overflow: hidden;
}

.article-cover img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 400px;
  object-fit: cover;
}

/* Article Content */
.article-content {
  font-size: 18px;
  line-height: 1.8;
  color: var(--text);
}

.article-content p {
  margin-bottom: 1.2em;
}

.article-content h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 1.8em 0 0.6em;
  letter-spacing: -0.02em;
}

.article-content blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 20px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--text-2);
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.article-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1.2em 0;
}

/* Article Footer */
.article-foot {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all var(--transition);
  cursor: pointer;
}
.share-btn:hover {
  color: var(--text);
  border-color: var(--text-3);
  background: var(--bg-hover);
}
.share-btn svg { opacity: 0.6; flex-shrink: 0; }
.share-btn:hover svg { opacity: 1; }

.share-btn.copied {
  color: var(--accent);
  border-color: var(--accent);
}
.share-btn.copied svg { opacity: 1; }

/* Related */
.related {
  margin-top: 32px;
  padding-top: 24px;
  padding-bottom: 24px;
  border-top: 1px solid var(--border);
}

.related-heading {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-2);
}

/* Те же карточки, что на главной (.post-card); без лишних отступов контейнера ленты */
.related-feed {
  margin: 0;
  padding: 0;
  max-width: none;
}

/* После последней рекомендации не дублируем линию — граница уже у подвала */
.related-feed .post-card:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Без лишнего «воздуха» перед подвалом: нижний padding статьи обычно 64px */
.article:has(.related) {
  padding-bottom: 28px;
}

/* Reading bar */
.reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 200;
  transition: width 80ms linear;
}

/* === ABOUT === */
.about {
  max-width: 640px;
  margin: 0 auto;
  padding: 60px 20px 80px;
  text-align: center;
}

.about-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.about-subtitle {
  font-size: 17px;
  color: var(--text-2);
  margin-bottom: 48px;
}

.about-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  text-align: left;
  margin-bottom: 48px;
}

.about-feature-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  border-radius: 10px;
  color: var(--accent);
  margin-bottom: 12px;
}

.about-feature h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.about-feature p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
}

/* === LOGIN === */
.login {
  max-width: 400px;
  margin: 0 auto;
  padding: 80px 20px;
  text-align: center;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 16px;
}

.login-hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-3);
}

/* === 404 === */
.not-found {
  text-align: center;
  padding: 100px 20px;
}
.not-found h1 {
  font-size: 72px;
  font-weight: 200;
  color: var(--text-3);
  margin-bottom: 8px;
}
.not-found p {
  font-size: 16px;
  color: var(--text-2);
  margin-bottom: 24px;
}
.not-found a {
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}

/* === FOOTER === */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  transition: all var(--transition);
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-3);
}
.footer-inner a { transition: color var(--transition); }
.footer-inner a:hover { color: var(--text-2); }
.footer-dot { opacity: 0.3; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .header-left { min-width: auto; gap: 10px; }
  .header-right { min-width: auto; }
  .header-logo { font-size: 16px; }
  .header-link { font-size: 13px; }

  .tab { padding: 10px 12px; font-size: 13px; }

  .post-card { gap: 14px; }
  .post-cover { width: 96px; height: 64px; }
  .post-title { font-size: 16px; }
  .post-excerpt { font-size: 14px; -webkit-line-clamp: 2; }
  .post-avatar { width: 24px; height: 24px; font-size: 11px; }

  .article-title { font-size: 24px; }
  .article-content { font-size: 16px; }
  .article-content h2 { font-size: 20px; }
  .article-cover img { max-height: 240px; }

  .about-features { grid-template-columns: 1fr; gap: 24px; }
  .about-title { font-size: 28px; }

  .profile-name { font-size: 20px; }
  .profile-post-cover { width: 80px; height: 54px; }

  .article:has(.related) {
    padding-bottom: 24px;
  }
}

@media (max-width: 380px) {
  .header-inner { padding: 0 12px; }
  .feed { padding: 0 12px; }
  .profile { padding: 0 12px; }
  .article { padding: 24px 12px 48px; }
  .article:has(.related) {
    padding-bottom: 20px;
  }

  .post-cover { width: 80px; height: 54px; }
}
