/*
Theme Name: Время
Description: Персональная тема Ивана Хайдурова в духе Эгеи: лента полных постов, системный шрифт, крупный текст, вынос аватара, светлая и тёмная темы с автопереключением.
Author: Ivan Khaydurov
Version: 1.9.0
Requires PHP: 7.4
Text Domain: vremya
*/

/* ===== Токены ===== */
:root {
  --bg: #FFFFFF;
  --fg: #333333;
  --heading: #000000;
  --muted: #999999;
  --link: #0080D4;
  --hairline: #E8E8E8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #202020;
    --fg: #C0C0C0;
    --heading: #FFFFFF;
    --muted: #8A8A8A;
    --link: #339CDD;
    --hairline: #383838;
  }
}
:root[data-mode="dark"] {
  --bg: #202020;
  --fg: #C0C0C0;
  --heading: #FFFFFF;
  --muted: #8A8A8A;
  --link: #339CDD;
  --hairline: #383838;
}
:root[data-mode="light"] {
  --bg: #FFFFFF;
  --fg: #333333;
  --heading: #000000;
  --muted: #999999;
  --link: #0080D4;
  --hairline: #E8E8E8;
}

/* ===== База ===== */
:root {
  --col: 720px;
  --font-body: system-ui, -apple-system, "SF UI Text", "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-head: var(--font-body);
  --post-size: 20px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  transition: background 0.2s ease, color 0.2s ease;
}
.site-title, .post-title, .archive-title, .al-year, .comments-title, .featured-name, .page-title,
.entry-content h1, .entry-content h2, .entry-content h3 { font-family: var(--font-head); }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 2px; }
img { max-width: 100%; height: auto; }

.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px); word-wrap: normal;
}

/* ===== Каркас ===== */
.page { max-width: var(--col); margin: 0 auto; padding: 40px 22px 80px; }

/* ===== Шапка: аватар вынесен влево, за границу колонки =====
   Внутри шапки — воздух между строками, а до ленты — умеренный отступ,
   чтобы шапка не выглядела ни склеенной, ни оторванной. */
.site-header-block { position: relative; margin-bottom: 48px; }
.avatar {
  position: absolute; left: -56px; top: -2px;
  width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
  background: var(--hairline); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mode-btn {
  position: absolute; right: 0; top: 0;
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font: inherit; font-size: 16px; line-height: 1;
  color: var(--muted); background: none;
  border: 1px solid var(--hairline); border-radius: 50%;
  cursor: pointer;
}
.mode-btn:hover { color: var(--fg); border-color: var(--muted); }
.site-title { margin: 0 0 8px; font-size: 20px; font-weight: 700; color: var(--heading); line-height: 1.25; padding-right: 90px; }
.site-title a { color: var(--heading); }
.site-title a:hover { text-decoration: none; }
.site-desc { font-size: 15px; line-height: 1.5; }
.site-desc p { margin: 0 0 4px; }
.site-links { margin-top: 16px; font-size: 15px; line-height: 1.6; }
.site-links p { margin: 0 0 6px; }
.site-links b { color: var(--heading); font-weight: 700; margin-right: 2px; }
.inline-menu { display: inline; margin: 0; padding: 0; list-style: none; }
.inline-menu li { display: inline; }
.inline-menu li + li::before { content: "·"; color: var(--muted); padding: 0 7px; }
@media (max-width: 840px) {
  .avatar { position: static; margin-bottom: 10px; }
}

/* ===== «Избранное»: карточки прилеплённых записей ===== */
.featured { margin-bottom: 72px; }
.featured-heading { margin: 0 0 18px; font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.featured-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; }
.featured-card { display: block; color: var(--heading); }
.featured-card:hover { text-decoration: none; }
.featured-cover {
  display: block; aspect-ratio: 16 / 10; overflow: hidden;
  border-radius: 6px; background: rgba(127, 127, 127, 0.12);
  margin-bottom: 10px;
}
.featured-cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: 0; transition: transform 0.25s ease;
}
.featured-card:hover .featured-cover img { transform: scale(1.03); }
.featured-cover-plain { display: flex; align-items: center; justify-content: center; }
.featured-emoji { font-size: 52px; line-height: 1; }
.featured-name { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; color: var(--heading); }
.featured-card:hover .featured-name { color: var(--link); }
@media (max-width: 560px) {
  .featured-grid { grid-template-columns: 1fr; }
}

/* ===== Заголовки страниц архивов/поиска ===== */
.archive-title { margin: 0 0 40px; font-size: 24px; font-weight: 700; color: var(--heading); }
.archive-title span { color: var(--muted); font-weight: 400; }

/* ===== Посты ===== */
.post-item { margin-bottom: 88px; }
.post-title {
  margin: 0 0 18px;
  font-size: clamp(26px, 5vw, 36px);
  line-height: 1.17;
  font-weight: 700;
  color: var(--heading);
  text-wrap: balance;
}
.post-title a { color: var(--heading); }
.post-title a:hover { color: var(--link); text-decoration: none; }

.entry-content { font-size: var(--post-size); line-height: 1.4; }
.entry-content > p { margin: 0 0 1em; }
.entry-content > p:last-child { margin-bottom: 0; }
.entry-content figure { margin: 0 0 1em; max-width: 100%; }
.entry-content img { max-width: 100%; height: auto; border-radius: 3px; }

/* Режим фото выбирается в Настройщике («Тема Время» → «Как показывать фото»),
   тема ставит класс photo-... на body. */

/* Режимы «растягивать» и «матовое стекло»: фото во всю ширину колонки. */
body.photo-stretch .entry-content figure img,
body.photo-glass .entry-content figure img { width: 100%; }

/* Режим «естественный размер»: ничего не растягиваем, фото по центру. */
body.photo-natural .entry-content figure { display: flex; flex-direction: column; align-items: center; }

/* Режим «матовое стекло»: маленькие фото по центру, позади — оно же,
   размытое. Класс ставит скрипт темы, измерив картинку. */
body.photo-glass .entry-content figure.vremya-small {
  position: relative; overflow: hidden; border-radius: 3px;
  display: flex; justify-content: center; align-items: center;
}
body.photo-glass .entry-content figure.vremya-small::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: var(--small-img) center / cover no-repeat;
  filter: blur(28px) saturate(1.15);
  transform: scale(1.25);
  opacity: 0.55;
}
body.photo-glass .entry-content figure.vremya-small img {
  position: relative; z-index: 1;
  width: auto; max-width: 100%;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.22);
}
body.photo-glass .entry-content figure.vremya-small figcaption { position: relative; z-index: 1; }
.entry-content ol, .entry-content ul { padding-left: 1.3em; margin: 0 0 1em; }
.entry-content li { margin-bottom: 0.45em; }
.entry-content blockquote {
  margin: 0 0 1em; padding: 0 0 0 18px;
  border-left: 3px solid var(--hairline);
  color: var(--muted);
}
.entry-content pre {
  background: rgba(127, 127, 127, 0.08);
  padding: 14px 16px; border-radius: 4px;
  overflow-x: auto; font-size: 15px; line-height: 1.5;
}
.entry-content code { font-size: 0.85em; background: rgba(127, 127, 127, 0.1); padding: 1px 5px; border-radius: 3px; }
.entry-content pre code { background: none; padding: 0; }
.entry-content .wp-video, .entry-content video { max-width: 100% !important; margin-bottom: 1em; }
.entry-content audio { width: 100%; margin-bottom: 1em; }
.entry-content iframe { max-width: 100%; }
.entry-content .wp-caption { max-width: 100%; }
.entry-content .wp-caption-text, .entry-content figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; }
.entry-content hr { border: 0; height: 1px; background: var(--hairline); margin: 1.6em 0; }
.entry-content hr.stars { background: none; height: auto; text-align: left; margin: 1.4em 0; }
.entry-content hr.stars::before { content: "* * *"; color: var(--muted); font-size: 16px; letter-spacing: 0.25em; }

/* Мета под постом */
.post-meta {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: baseline;
}
.post-meta a { color: var(--link); }
.post-meta .pm-date { color: var(--muted); }
.post-meta .pm-date:hover { color: var(--link); }
.post-meta .tags a { font-size: 13.5px; }

/* ===== Пагинация и навигация ===== */
.pager { display: flex; justify-content: space-between; gap: 16px; font-size: 16px; margin-bottom: 56px; }
.pager .right { margin-left: auto; }
.post-nav { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; margin: 64px 0; }
.post-nav a { max-width: 46%; }
.post-nav .right { margin-left: auto; text-align: right; }

/* ===== Комментарии ===== */
.comments { margin-top: 72px; border-top: 1px solid var(--hairline); padding-top: 32px; }
.comments-title { font-size: 18px; font-weight: 700; color: var(--heading); margin: 0 0 24px; }
.comment-list { list-style: none; margin: 0 0 32px; padding: 0; }
.comment-list .children { list-style: none; padding-left: 28px; }
.comment { margin-bottom: 24px; }
.comment-meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.comment-meta img.avatar { position: static; width: 24px; height: 24px; border-radius: 50%; }
.comment-meta .fn { font-style: normal; font-weight: 600; color: var(--fg); }
.comment-content { font-size: 16px; }
.comment-content p { margin: 0 0 0.6em; }
.reply { font-size: 13px; }
.comment-form label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.comment-form input[type="text"], .comment-form input[type="email"], .comment-form input[type="url"], .comment-form textarea {
  width: 100%; font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--hairline); border-radius: 4px;
  padding: 8px 10px; margin-bottom: 14px;
}
.comment-form .submit {
  font: inherit; cursor: pointer;
  background: var(--fg); color: var(--bg);
  border: 0; border-radius: 4px; padding: 9px 18px;
}

/* ===== Страница «Написать пост» ===== */
.write-form input[type="text"], .write-form textarea {
  width: 100%; font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--hairline); border-radius: 6px;
  padding: 12px 14px; margin-bottom: 14px;
}
.write-form textarea { font-size: 18px; line-height: 1.5; resize: vertical; }
.write-form input[type="text"] { font-size: 20px; font-weight: 700; }
.write-photo { display: block; font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.write-buttons { display: flex; gap: 10px; }
.write-publish {
  font: inherit; cursor: pointer;
  background: var(--link); color: #fff;
  border: 0; border-radius: 6px; padding: 11px 22px;
}
.write-draft {
  font: inherit; cursor: pointer;
  background: none; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 6px; padding: 11px 18px;
}
.write-draft:hover { color: var(--fg); }
.write-notice { color: var(--muted); }
.write-error { color: #C0392B; }

/* ===== Оглавление на полях (включается в Настройщике) ===== */
:root { --toc-max: 1; }
.vremya-rail {
  position: fixed; top: 120px; width: 215px;
  font-size: 12px; line-height: 1.45; z-index: 5;
}
body.toc-right .vremya-rail { left: calc(50% + var(--col) / 2 + 25px); }
body.toc-left .vremya-rail { left: calc(50% - var(--col) / 2 - 240px); }
.vremya-rail .rail-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); opacity: calc(0.6 * var(--toc-max)); margin: 0 0 10px;
}
.vremya-rail a {
  display: block; color: var(--muted);
  padding: 3px 0 3px 12px;
  border-left: 1.5px solid transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-height: 26px; opacity: calc(0.35 * var(--toc-max));
  transition: opacity 0.45s ease, max-height 0.45s ease, padding 0.45s ease, color 0.2s ease;
}
.vremya-rail a:hover { color: var(--link); text-decoration: none; opacity: 1 !important; }
.vremya-rail a.sub { padding-left: 26px; font-size: 11.5px; }
.vremya-rail a.d0 { color: var(--heading); opacity: 1; }
body.toc-accent .vremya-rail a.d0 { color: var(--link); border-left-color: var(--link); }
.vremya-rail a.d1 { opacity: calc(0.62 * var(--toc-max)); }
.vremya-rail a.d2 { opacity: calc(0.44 * var(--toc-max)); }
.vremya-rail a.d3 { opacity: calc(0.3 * var(--toc-max)); }
.vremya-rail a.d4 { opacity: calc(0.2 * var(--toc-max)); }
.vremya-rail a.d5 { opacity: calc(0.12 * var(--toc-max)); }
.vremya-rail a.dh { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; pointer-events: none; }
@media (max-width: 1000px) { .vremya-rail { display: none !important; } }

/* ===== Архив всех постов ===== */
.al-year { font-size: 22px; font-weight: 700; color: var(--heading); margin: 44px 0 14px; }
.al-year span { color: var(--muted); font-weight: 400; font-size: 15px; }
.al-list { list-style: none; margin: 0; padding: 0; }
.al-list li {
  display: flex; align-items: baseline; gap: 12px;
  padding: 7px 0; border-bottom: 1px solid var(--hairline);
  font-size: 17px;
}
.al-list li:last-child { border-bottom: 0; }
.al-list a { flex: 1; min-width: 0; }
.al-date { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ===== Поиск в шапке ===== */
.search-btn {
  position: absolute; right: 42px; top: 0;
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font: inherit; font-size: 15px; line-height: 1;
  color: var(--muted); background: none;
  border: 1px solid var(--hairline); border-radius: 50%;
  cursor: pointer;
}
.search-btn:hover { color: var(--fg); border-color: var(--muted); }
.header-search { display: none; margin-top: 18px; }
.header-search.open { display: block; }

/* ===== Поиск и подвал ===== */
.search-form { display: flex; gap: 8px; margin-bottom: 48px; }
.search-form input[type="search"] {
  flex: 1; font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--hairline); border-radius: 4px;
  padding: 8px 10px;
}
.search-form button { font: inherit; cursor: pointer; background: var(--fg); color: var(--bg); border: 0; border-radius: 4px; padding: 8px 16px; }

.site-footer {
  color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--hairline);
  margin-top: 40px; padding-top: 20px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.site-footer a { color: var(--muted); }

@media (max-width: 480px) {
  .entry-content { font-size: 18px; }
  .post-item { margin-bottom: 72px; }
  .site-header-block { margin-bottom: 48px; }
}
