/*
Theme Name: Dmitry Filatov
Theme URI: https://blog.dimafilatov.ru
Author: Dmitry Filatov
Author URI: https://dimafilatov.ru
Description: Clean, elegant, typography-focused personal blog theme based on Manrope and Monochrome aesthetic.
Version: 1.0.0
Requires at least: 5.8
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dimafilatov
Tags: blog, one-column, custom-menu, dark-mode, editor-style
*/

/* --------------------------------------------------------------------------
   1. ПЕРЕМЕННЫЕ И ДИЗАЙН-ТОКЕНЫ (ПРЕСЕТ: MANROPE ЖУРНАЛЬНЫЙ + МОНОХРОМ)
   -------------------------------------------------------------------------- */
:root {
  /* Размеры сетки и типографики */
  --site-max-width: 820px;
  --content-max-width: 680px;
  --header-spacing: clamp(2rem, 1.5rem + 2vw, 3.5rem);
  --section-spacing: clamp(2.5rem, 2rem + 2.5vw, 4.5rem);

  --font-size-base: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem); /* 17px - 19px */
  --line-height-body: 1.68;
  --line-height-heading: 1.24;
  --letter-spacing-heading: -0.025em;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-full: 9999px;

  --transition-smooth: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  /* Шрифты: Журнальный Manrope + JetBrains Mono */
  --font-family-display: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-ui: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-family-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --heading-font-weight: 700;
  --body-font-weight: 400;
  --h1-letter-spacing: -0.03em;
  --quote-style: normal;

  /* Палитра: Монохром Светлая (Default Light) */
  --bg-body: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f5f5f5;
  --text-main: #171717;
  --text-muted: #525252;
  --text-subtle: #737373;
  --border-subtle: #e5e5e5;
  --border-strong: #a3a3a3;

  --color-accent: #000000;
  --color-accent-hover: #404040;
  --color-accent-soft: rgba(0, 0, 0, 0.06);
  --color-accent-dot: #171717;
  --color-on-accent: #ffffff;

  --code-bg: #f8fafc;
  --code-border: #e2e8f0;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Тёмная тема (принудительно по data-theme="dark" или по системным настройкам) */
[data-theme="dark"] {
  --bg-body: #0d0d0d;
  --bg-surface: #141414;
  --bg-surface-subtle: #1c1c1c;
  --text-main: #f5f5f5;
  --text-muted: #a3a3a3;
  --text-subtle: #808080;
  --border-subtle: #262626;
  --border-strong: #404040;

  --color-accent: #ffffff;
  --color-accent-hover: #d4d4d4;
  --color-accent-soft: rgba(255, 255, 255, 0.08);
  --color-accent-dot: #ffffff;
  --color-on-accent: #0d0d0d;

  --code-bg: #141414;
  --code-border: #262626;
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-body: #0d0d0d;
    --bg-surface: #141414;
    --bg-surface-subtle: #1c1c1c;
    --text-main: #f5f5f5;
    --text-muted: #a3a3a3;
    --text-subtle: #808080;
    --border-subtle: #262626;
    --border-strong: #404040;

    --color-accent: #ffffff;
    --color-accent-hover: #d4d4d4;
    --color-accent-soft: rgba(255, 255, 255, 0.08);
    --color-accent-dot: #ffffff;
    --color-on-accent: #0d0d0d;

    --code-bg: #141414;
    --code-border: #262626;
    --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.4);
  }
}

/* --------------------------------------------------------------------------
   2. СБРОС И БАЗОВЫЙ ДОКУМЕНТ
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--body-font-weight);
  line-height: var(--line-height-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: 0;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Ссылки */
a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: var(--transition-smooth);
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration-thickness: 1.5px;
}

/* Доступность: скрытый текст для скринридеров */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  width: 1px;
  word-wrap: normal !important;
}

.screen-reader-text:focus {
  background-color: var(--bg-surface);
  clip: auto !important;
  clip-path: none;
  color: var(--text-main);
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  height: auto;
  left: 8px;
  line-height: normal;
  padding: 12px 20px;
  position: fixed !important;
  top: 8px;
  text-decoration: none;
  width: auto;
  z-index: 100000;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  border: 2px solid var(--color-accent);
}

/* --------------------------------------------------------------------------
   3. ОБЩИЙ МАКЕТ СТРАНИЦЫ
   -------------------------------------------------------------------------- */
.page-wrapper {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .page-wrapper {
    padding: 0 18px;
  }

  /* Интерактивная зона касания 44px на мобильных */
  .theme-toggle-btn,
  .tag-link,
  .page-numbers,
  .site-nav a,
  .brand-link,
  .post-card-title a,
  .next-post-title a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* --------------------------------------------------------------------------
   4. ШАПКА САЙТА (SITE HEADER)
   -------------------------------------------------------------------------- */
.site-header {
  padding: var(--header-spacing) 0 2rem 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--section-spacing);
}

.site-header-inner {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.site-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-link {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-title {
  font-family: var(--font-family-display);
  font-weight: 750;
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  letter-spacing: -0.03em;
  color: var(--text-main);
  transition: var(--transition-smooth);
}

.brand-link:hover .brand-title {
  opacity: 0.8;
}

.brand-tag {
  font-family: var(--font-family-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 7px;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.brand-bio {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 540px;
}

/* Навигация шапки */
.site-header-nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-family: var(--font-family-ui);
  font-size: 0.875rem;
  font-weight: 500;
}

.site-nav ul,
.site-nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.site-nav li {
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.site-nav a:hover,
.site-nav .current-menu-item > a,
.site-nav .current_page_item > a {
  color: var(--text-main);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

/* Кнопка переключения темы (Dark/Light mode) */
.theme-toggle-btn {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-family-ui);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.theme-toggle-btn:hover {
  background-color: var(--border-subtle);
  border-color: var(--border-strong);
}

.theme-icon {
  font-size: 0.875rem;
  line-height: 1;
}

[data-theme="dark"] .light-icon { display: none; }
[data-theme="dark"] .dark-icon { display: inline-block; }
:root:not([data-theme="dark"]) .dark-icon { display: none; }
:root:not([data-theme="dark"]) .light-icon { display: inline-block; }

/* --------------------------------------------------------------------------
   5. ЛЕНТА БЛОГА (INDEX / ARCHIVE)
   -------------------------------------------------------------------------- */
.feed-intro {
  margin-bottom: 2rem;
}

.feed-heading {
  font-family: var(--font-family-display);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 0.5rem;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.post-card {
  padding-bottom: 2.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.post-card:last-child {
  border-bottom: none;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-family-ui);
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-bottom: 0.5rem;
}

.meta-date {
  font-variant-numeric: tabular-nums;
}

.meta-dot {
  color: var(--border-strong);
}

.post-card-title {
  font-family: var(--font-family-display);
  font-size: clamp(1.25rem, 1.125rem + 0.5vw, 1.5rem);
  font-weight: var(--heading-font-weight);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
  margin-bottom: 0.65rem;
}

.post-card-title a {
  color: var(--text-main);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.post-card-title a:hover {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
}

.post-card-excerpt {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.post-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-family-ui);
  font-size: 0.8125rem;
}

.tag-list {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-link {
  color: var(--text-subtle);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.75rem;
  transition: var(--transition-smooth);
}

.tag-link:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
}

.reading-time {
  color: var(--text-subtle);
  font-size: 0.75rem;
}

/* --------------------------------------------------------------------------
   6. ПАГИНАЦИЯ
   -------------------------------------------------------------------------- */
.pagination,
.posts-navigation,
.navigation.pagination {
  margin-top: var(--section-spacing);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family-ui);
  font-size: 0.875rem;
}

.page-numbers {
  padding: 6px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.page-numbers:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.page-numbers.current {
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  border-color: var(--color-accent);
  font-weight: 600;
}

.page-numbers.dots {
  border: none;
  color: var(--text-subtle);
}

/* --------------------------------------------------------------------------
   7. ОДИНОЧНАЯ СТАТЬЯ (SINGLE POST / PAGE)
   -------------------------------------------------------------------------- */
.article-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.article-header {
  margin-bottom: 2.25rem;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-family-ui);
  font-size: 0.875rem;
  color: var(--text-subtle);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.article-title {
  font-family: var(--font-family-display);
  font-size: clamp(1.85rem, 1.45rem + 1.8vw, 2.5rem);
  font-weight: var(--heading-font-weight);
  line-height: 1.18;
  letter-spacing: var(--h1-letter-spacing);
  color: var(--text-main);
  margin-bottom: 1.25rem;
}

/* Типографика статьи (контент WordPress) */
.article-content {
  font-size: var(--font-size-base);
  line-height: var(--line-height-body);
  color: var(--text-main);
}

.article-content > * + * {
  margin-top: 1.5rem;
}

.article-content h2 {
  font-family: var(--font-family-display);
  font-size: clamp(1.35rem, 1.2rem + 0.7vw, 1.7rem);
  font-weight: var(--heading-font-weight);
  line-height: var(--line-height-heading);
  letter-spacing: -0.025em;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.article-content h3 {
  font-family: var(--font-family-display);
  font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.3rem);
  font-weight: var(--heading-font-weight);
  line-height: var(--line-height-heading);
  letter-spacing: -0.015em;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.article-content p {
  margin-bottom: 1.4rem;
}

.article-content ul,
.article-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content li::marker {
  color: var(--text-subtle);
}

/* Цитаты */
.article-content blockquote,
.article-content .wp-block-quote {
  border-left: 3px solid var(--border-strong);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 2rem 0;
  color: var(--text-muted);
  font-style: var(--quote-style);
}

.article-content blockquote cite,
.article-content .wp-block-quote cite {
  display: block;
  font-size: 0.84375rem;
  font-style: normal;
  color: var(--text-subtle);
  margin-top: 0.5rem;
}

/* Выделенная врезка (Pull quote / Callout) */
.callout,
.wp-block-pullquote {
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
}

/* Код и листинги */
code {
  font-family: var(--font-family-mono);
  font-size: 0.875em;
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.15em 0.35em;
  border-radius: var(--radius-sm);
  color: var(--text-main);
}

pre,
.wp-block-code {
  background-color: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 2rem 0;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.84375rem;
  line-height: 1.6;
}

/* Изображения WordPress */
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.wp-caption {
  max-width: 100%;
  margin: 1.5rem auto;
}

.wp-caption-text {
  font-family: var(--font-family-ui);
  font-size: 0.8125rem;
  color: var(--text-subtle);
  text-align: center;
  margin-top: 0.5rem;
}

.aligncenter {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.alignwide {
  max-width: var(--site-max-width);
  margin-left: auto;
  margin-right: auto;
}

.alignfull {
  max-width: 100vw;
  width: 100%;
}

/* Блок автора в конце статьи */
.author-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 3rem;
  margin-bottom: 2rem;
}

.author-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.author-name {
  font-family: var(--font-family-ui);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.author-desc {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Навигация к следующей/предыдущей записи */
.post-navigation {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.post-nav-box {
  padding: 1.25rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.next-caption {
  display: block;
  font-family: var(--font-family-ui);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  margin-bottom: 0.35rem;
}

.next-post-title {
  font-family: var(--font-family-display);
  font-size: 1.125rem;
  font-weight: var(--heading-font-weight);
  color: var(--text-main);
  text-decoration: none;
}

.next-post-title:hover {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   8. ПОДВАЛ САЙТА (SITE FOOTER)
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: var(--section-spacing);
  padding: 2.5rem 0 3.5rem 0;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-family-ui);
  font-size: 0.84375rem;
  color: var(--text-subtle);
}

.site-footer-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--text-main);
}
