/* ==========================================================================
   main.css — відтворення стилю PlainWhite Jekyll theme для org-publish сайту
   Двоколонковий лейаут: фіксований сайдбар зліва + контент справа.
   Світла/темна тема через CSS-змінні + JS-перемикач (localStorage).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif:ital,wght@0,400;0,700;1,400&display=swap');

/* ---- Кольорові теми (CSS custom properties) ---- */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6e6e73;
  --link: #2b6cb0;
  --link-hover: #1a4d80;
  --border: #e5e5e5;
  --tag-bg: #f0f0f0;
  --tag-text: #333333;
  --toggle-bg: #d0d0d0;
  --toggle-circle: #ffffff;
  --sidebar-width: 300px;
  --content-max-width: 46em;
}

html.dark {
  --bg: #1a1a1a;
  --text: #e8e8e8;
  --text-muted: #9a9a9a;
  --link: #5b9bd5;
  --link-hover: #7fb3e0;
  --border: #333333;
  --tag-bg: #3a3a3c;
  --tag-text: #eeeeee;
  --toggle-bg: #3a5a7a;
  --toggle-circle: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Serif', Georgia, 'Times New Roman', serif;
  line-height: 1.6;
  transition: background-color 0.2s ease, color 0.2s ease;

  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-areas:
    "sidebar content"
    "footer   footer";
  min-height: 100vh;
}

/* ---- Сайдбар (preamble) ---- */
#site-header {
  grid-area: sidebar;
  padding: 3em 2em;
  text-align: center;
  border-right: 1px solid var(--border);
}

#site-header .avatar {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1em;
}

#site-header .site-name {
  font-size: 1.4em;
  font-weight: 700;
  margin: 0.3em 0;
}

#site-header .site-tagline {
  color: var(--text-muted);
  font-size: 0.95em;
  margin-bottom: 1.2em;
}

#site-header .social-links {
  display: flex;
  justify-content: center;
  gap: 0.9em;
  margin-bottom: 1.5em;
}

#site-header .social-links a {
  color: var(--text);
  display: inline-flex;
}

#site-header .social-links svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#site-header .copyright {
  color: var(--text-muted);
  font-size: 0.85em;
  margin-bottom: 1em;
}

/* ---- Перемикач теми ---- */
.theme-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  font-size: 0.85em;
  color: var(--text-muted);
}

.theme-toggle {
  position: relative;
  width: 42px;
  height: 24px;
}

.theme-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--toggle-bg);
  border-radius: 24px;
  transition: background-color 0.2s ease;
}

.theme-toggle .slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--toggle-circle);
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.theme-toggle input:checked + .slider::before {
  transform: translateX(18px);
}

/* ---- Контент ---- */
#content {
  grid-area: content;
  padding: 3em 2.5em;
  max-width: var(--content-max-width);
}

#content h1.title {
  font-size: 2em;
  margin-top: 0;
}

.posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.8em;
  margin-bottom: 1.5em;
}

.post-entry {
  margin-bottom: 2.2em;
}

.post-date {
  display: flex;
  align-items: center;
  gap: 0.4em;
  color: var(--text-muted);
  font-size: 0.9em;
  margin-bottom: 0.3em;
}

.post-entry h2, .post-entry h3 {
  margin: 0.2em 0 0.4em;
}

.post-entry h2 a, .post-entry h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-entry h2 a:hover, .post-entry h3 a:hover {
  color: var(--link);
}

.post-tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  padding: 0.3em 0.9em;
  border-radius: 4px;
  font-size: 0.8em;
  text-decoration: none;
  float: right;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

pre, code {
  background: var(--tag-bg);
  border-radius: 4px;
}

pre {
  padding: 1em;
  overflow-x: auto;
}

code {
  padding: 0.15em 0.4em;
}

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

blockquote {
  border-left: 3px solid var(--border);
  margin-left: 0;
  padding-left: 1.2em;
  color: var(--text-muted);
}

/* ---- Підвал (postamble) ---- */
#site-footer {
  grid-area: footer;
  text-align: center;
  padding: 1.5em;
  font-size: 0.8em;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

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

/* ---- Мобільна адаптація ---- */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "content"
      "footer";
  }

  #site-header {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 2em 1.5em;
  }

  #content {
    padding: 2em 1.5em;
    max-width: 100%;
  }
}
