/* ---- design tokens ---- */
:root {
  --bg: #eceae3;
  --card: #f8f7f3;
  --ink: #262520;
  --body-color: #46443b;
  --soft: #7a786c;
  --line: rgba(40,38,28,0.12);
  --terra: #a8623f;
  --terra-soft: rgba(168,98,63,0.10);
  --head-bg: rgba(236,234,227,0.82);
  --shadow: 0 1px 2px rgba(40,36,24,0.05), 0 16px 36px -22px rgba(40,36,24,0.42);
  --shadow-hi: 0 2px 8px rgba(40,36,24,0.09), 0 30px 60px -26px rgba(40,36,24,0.55);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #1a1a17;
  --card: #232320;
  --ink: #ecebe2;
  --body-color: #c6c4b8;
  --soft: #8e8c7f;
  --line: rgba(225,222,205,0.13);
  --terra: #d09063;
  --terra-soft: rgba(208,144,99,0.15);
  --head-bg: rgba(26,26,23,0.82);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 18px 40px -22px rgba(0,0,0,0.6);
  --shadow-hi: 0 2px 8px rgba(0,0,0,0.4), 0 30px 60px -26px rgba(0,0,0,0.7);
  color-scheme: dark;
}

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

body {
  background: var(--bg);
  color: var(--body-color);
  font-family: "Onest", system-ui, sans-serif;
  transition: background .3s ease;
  min-height: 100vh;
}

::selection { background: rgba(168,98,63,0.20); }

/* ---- layout ---- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- sticky header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--head-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: background .3s ease, border-color .3s ease;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.site-logo-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
  flex-shrink: 0;
}

.site-logo-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-logo-name {
  font-family: "Onest", sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}

.site-logo-name .dot { color: var(--terra); }

.site-logo-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  line-height: 1;
  color: var(--soft);
  margin-top: 3px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.site-nav nav {
  display: flex;
  gap: 22px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  line-height: 1;
}

.site-nav a {
  color: var(--soft);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s;
}

.site-nav a:hover { color: var(--ink); }
.site-nav a.active { color: var(--ink); font-weight: 600; }

/* theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--soft);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}

.theme-toggle:hover { color: var(--terra); border-color: var(--terra); }

/* CSS-controlled icon visibility */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ---- main content ---- */
main.container {
  padding-top: 40px;
  padding-bottom: 20px;
}

/* ---- section label ---- */
.section-label {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--soft);
  text-transform: uppercase;
  margin: 4px 0 18px;
}

/* ---- card base ---- */
.card {
  display: block;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.2,.7,.3,1), box-shadow .18s;
}

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

/* ---- shared card meta ---- */
.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 11px;
}

.kicker {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--terra);
  text-transform: uppercase;
}

.meta {
  font-family: "JetBrains Mono", monospace;
  font-weight: 400;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--soft);
  white-space: nowrap;
}

/* ---- card-l: big feature card ---- */
.card-l {
  background: var(--card);
  border-radius: 22px;
  overflow: hidden;
}

.card-l-cover {
  height: 380px;
  overflow: hidden;
}

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

.card-l-cover-ph {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    135deg, #e2e0d6 0, #e2e0d6 12px,
    rgba(90,84,64,0.10) 12px, rgba(90,84,64,0.10) 24px
  );
}

[data-theme="dark"] .card-l-cover-ph {
  background: repeating-linear-gradient(
    135deg, #2c2c27 0, #2c2c27 12px,
    rgba(220,200,160,0.07) 12px, rgba(220,200,160,0.07) 24px
  );
}

.card-l-body { padding: 26px 30px 30px; }

.card-l-body h2 {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  color: var(--ink);
}

.card-l-body .dek {
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 17.5px;
  line-height: 1.55;
  color: var(--body-color);
  margin: 0;
}

/* ---- card-m: medium horizontal card ---- */
.card-m {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 22px;
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  padding: 14px;
  align-items: center;
}

.card-m-thumb {
  border-radius: 12px;
  overflow: hidden;
  height: 156px;
  flex-shrink: 0;
}

.card-m-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-m-thumb-ph {
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    135deg, #e8e6dc 0, #e8e6dc 12px,
    rgba(90,84,64,0.09) 12px, rgba(90,84,64,0.09) 24px
  );
}

[data-theme="dark"] .card-m-thumb-ph {
  background: repeating-linear-gradient(
    135deg, #262622 0, #262622 12px,
    rgba(220,200,160,0.06) 12px, rgba(220,200,160,0.06) 24px
  );
}

.card-m-body {
  padding: 8px 16px 8px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-m-body h2 {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.14;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--ink);
}

.card-m-body .dek {
  font-family: "Onest", sans-serif;
  font-weight: 400;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--soft);
  margin: 0;
}

/* ---- card-s: compact list card ---- */
.card-s {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border-radius: 14px;
  padding: 18px 22px;
}

.card-s-thumb {
  width: 62px;
  height: 62px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.card-s-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-s-body { flex: 1; min-width: 0; }

.card-s-body .kicker { display: block; margin-bottom: 8px; }

.card-s-body h2 {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
  /* Prevent overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-s .meta { flex-shrink: 0; }

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

/* ---- pagination ---- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 40px 0 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
}

.pager {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--soft);
  border: 1px solid var(--line);
  transition: color .15s, border-color .15s, background .15s;
  line-height: 1;
}

a.pager:hover {
  color: var(--terra);
  border-color: var(--terra);
}

.pager-active {
  background: var(--terra);
  color: #fff;
  border-color: var(--terra);
}

.pager-off {
  opacity: 0.3;
  cursor: default;
}

/* ---- single post ---- */
.post-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
  font-size: 13px;
  color: var(--soft);
  text-decoration: none;
  margin-bottom: 26px;
  transition: color .15s;
}

.post-back:hover { color: var(--terra); }

.post-header { margin-bottom: 26px; }

.post-header h1 {
  font-family: "Onest", sans-serif;
  font-weight: 700;
  font-size: 44px;
  line-height: 1.06;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-wrap: balance;
}

.post-cover {
  height: 440px;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 32px;
  box-shadow: var(--shadow);
}

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

.post-body { margin-bottom: 40px; }

.post-body p {
  font-size: 18.5px;
  line-height: 1.62;
  color: var(--body-color);
  margin: 0 0 22px;
}

.post-body h2 {
  font-family: "Onest", sans-serif;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 36px 0 14px;
}

.post-body h3 {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 28px 0 12px;
}

.post-body h4 {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
  margin: 22px 0 10px;
}

.post-body a {
  color: var(--terra);
  text-decoration: underline;
  text-decoration-color: var(--terra-soft);
  transition: text-decoration-color .15s;
}

.post-body a:hover { text-decoration-color: var(--terra); }

.post-body code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.88em;
  background: var(--terra-soft);
  color: var(--terra);
  padding: 2px 6px;
  border-radius: 5px;
}

.post-body pre {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  overflow-x: auto;
  margin: 0 0 24px;
  box-shadow: var(--shadow);
}

.post-body pre code {
  background: none;
  color: var(--body-color);
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
}

.post-body blockquote {
  border-left: 3px solid var(--terra);
  padding: 4px 0 4px 20px;
  margin: 0 0 22px;
  color: var(--soft);
}

.post-body img:not(.photo-grid img) {
  max-width: 100%;
  border-radius: 14px;
  display: block;
  margin: 8px 0 24px;
  box-shadow: var(--shadow);
}

.post-body video {
  max-width: 100%;
  border-radius: 14px;
  display: block;
  margin: 8px 0 24px;
}

.post-body ul,
.post-body ol {
  padding-left: 24px;
  margin: 0 0 22px;
}

.post-body li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

/* ---- photo grid (Telegram posts) ---- */
.photo-grid {
  display: grid;
  gap: 2px;
  max-width: 600px;
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
}

.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  /* override post-body img styles */
  margin: 0;
  box-shadow: none;
}

.photo-grid.photos-1 { grid-template-columns: 1fr; }
.photo-grid.photos-1 img { border-radius: 8px; }
.photo-grid.photos-2 { grid-template-columns: 1fr 1fr; aspect-ratio: 2/1; }
.photo-grid.photos-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 3/2; }
.photo-grid.photos-3 img:first-child { grid-row: span 2; }
.photo-grid.photos-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 1/1; }
.photo-grid.photos-5,
.photo-grid.photos-6,
.photo-grid.photos-7,
.photo-grid.photos-8,
.photo-grid.photos-9 { grid-template-columns: repeat(3, 1fr); aspect-ratio: 3/2; }

/* ---- post tags ---- */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 28px;
}

.post-tags a {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--terra);
  background: var(--terra-soft);
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.post-tags a:hover { background: var(--terra); color: #fff; }

/* ---- more posts ---- */
.more-posts { margin-top: 12px; }

.more-posts-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 18px;
}

.more-posts-label {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--soft);
  text-transform: uppercase;
  white-space: nowrap;
}

.more-posts-line {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.more-posts-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.more-posts-feed .card-s { padding: 16px 22px; }

.more-posts-feed .card-s h3 {
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ink);
}

/* ---- tags taxonomy ---- */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "Onest", sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--terra);
  background: var(--terra-soft);
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.tag-chip:hover { background: var(--terra); color: #fff; }

.tag-chip .count {
  font-family: "JetBrains Mono", monospace;
  font-weight: 400;
  font-size: 11px;
  color: var(--soft);
}

.tag-chip:hover .count { color: rgba(255,255,255,0.75); }

/* ---- page title (for list/tag pages) ---- */
.page-title {
  font-family: "Onest", sans-serif;
  font-weight: 700;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 24px;
}

/* ---- footer ---- */
.site-footer {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px 56px;
}

.site-footer-line {
  height: 1px;
  background: var(--line);
  margin-bottom: 22px;
}

.site-footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--soft);
}

.site-footer-inner a {
  color: var(--soft);
  text-decoration: none;
  transition: color .15s;
}

.site-footer-inner a:hover { color: var(--terra); }

.site-footer-social {
  display: flex;
  gap: 14px;
}

/* ---- 404 ---- */
.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-page h1 {
  font-family: "Onest", sans-serif;
  font-size: 80px;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: var(--ink);
  margin-bottom: 16px;
}

.error-page p {
  font-size: 18px;
  color: var(--soft);
  margin-bottom: 32px;
}

.error-page a { color: var(--terra); text-decoration: none; }
.error-page a:hover { text-decoration: underline; }

/* ---- responsive ---- */
@media (max-width: 640px) {
  .site-nav nav { display: none; }

  .card-l-body h2 { font-size: 26px; }
  .card-l-cover { height: 240px; }

  .card-m {
    grid-template-columns: 130px 1fr;
    gap: 14px;
  }
  .card-m-thumb { height: 110px; }
  .card-m-body h2 { font-size: 18px; }

  .post-header h1 { font-size: 32px; }
  .post-cover { height: 220px; }
  .post-body p { font-size: 16.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .theme-toggle,
  .post-back,
  body { transition: none; }
}
