/* Мир Якоба — light editorial design system.
   Single stylesheet for all public pages. Admin pages use admin_base.html. */

/* ─── tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:      #fbf8f1;
  --surface: #ffffff;
  --fg:      #211d16;
  --muted:   #5b5344;
  --faint:   #a89e8c;
  --border:  rgba(33, 29, 22, 0.13);
  --accent:  #a16207;
  --accent-strong: #8a5306;
  --accent-soft: rgba(161, 98, 7, 0.13);
  --fg-soft: rgba(33, 29, 22, 0.055);
  --ok:      #3f6212;
  --err:     #a13c1a;
  --shadow-card: 0 1px 2px rgba(33, 29, 22, 0.05), 0 10px 28px rgba(33, 29, 22, 0.07);

  --font-display: 'Literata', Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --fs-h1: clamp(30px, 5.4vw, 54px);
  --fs-h2: clamp(22px, 3.4vw, 32px);
  --fs-h3: 19px;
  --fs-lead: 18px;
  --fs-body: 16px;
  --fs-meta: 13px;

  --gap-sm: 12px;
  --gap-md: 20px;
  --gap-lg: 32px;
  --gap-xl: 56px;
  --gap-2xl: 88px;
  --container: 1080px;
  --article: 700px;
  --gutter: 24px;

  --radius: 10px;
  --radius-lg: 16px;
}

/* ─── reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }

/* ─── a11y ─────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--fg); color: var(--bg);
  padding: 12px 20px; font-size: 14px; font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(161, 98, 7, 0.25); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  ::view-transition-group(*), ::view-transition-image-pair(*),
  ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ─── utilities ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.linklike { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.linklike:hover { text-decoration-color: var(--fg); }

/* ─── layout ───────────────────────────────────────────────────────── */
.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.article-col { max-width: var(--article); margin-inline: auto; padding-inline: var(--gutter); }
.narrow-col { max-width: 440px; margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(40px, 6.5vw, var(--gap-2xl)); }
.section + .section { border-top: 1px solid var(--border); }
.section-head { margin-bottom: var(--gap-md); }
.row { display: flex; align-items: center; gap: var(--gap-md); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-md); }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: var(--gap-xl); align-items: center; }
@media (max-width: 920px) { .grid-1-2 { grid-template-columns: 1fr; gap: var(--gap-lg); } }

/* ─── type ─────────────────────────────────────────────────────────── */
h1 { font-family: var(--font-display); font-size: var(--fs-h1); line-height: 1.12; letter-spacing: -0.01em; margin: 0; font-weight: 700; }
h2 { font-family: var(--font-display); font-size: var(--fs-h2); line-height: 1.18; margin: 0; font-weight: 700; }
h3 { font-size: var(--fs-h3); font-weight: 650; line-height: 1.35; margin: 0; }
.lead { font-size: var(--fs-lead); line-height: 1.6; color: var(--muted); max-width: 58ch; margin: 0; }
.dek { color: var(--muted); }
.kicker {
  font-family: var(--font-mono);
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 var(--gap-md);
}
.kicker-accent { color: var(--accent); }
.meta { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--faint); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ─── chrome: nav + footer ─────────────────────────────────────────── */
.topnav {
  position: sticky; top: 0; z-index: 30;
  background: rgba(251, 248, 241, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topnav-inner { display: flex; align-items: center; justify-content: space-between; padding-block: 14px; gap: var(--gap-md); }
.topnav .logo { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.topnav nav.desktop { display: flex; gap: var(--gap-lg); align-items: center; }
.topnav nav.desktop a { font-size: 14px; color: var(--muted); padding-block: 10px; transition: color 0.15s ease; }
.topnav nav.desktop a:hover, .topnav nav.desktop a[aria-current="page"] { color: var(--fg); }
.topnav form { display: inline; }
.topnav .logout-btn { background: none; border: 0; padding: 10px 0; font-size: 14px; color: var(--faint); }
.topnav .logout-btn:hover { color: var(--fg); }
.nav-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px; color: var(--fg);
  min-height: 44px; align-items: center; gap: 8px;
}
.mobile-nav { display: none; border-top: 1px solid var(--border); padding-block: var(--gap-sm) var(--gap-md); }
.mobile-nav a, .mobile-nav .logout-btn {
  display: block; width: 100%; text-align: left; padding: 12px 0;
  font-size: 16px; color: var(--fg); border: 0; border-bottom: 1px solid var(--border);
  background: none; min-height: 44px;
}
.mobile-nav.open { display: block; }
@media (max-width: 920px) {
  .topnav nav.desktop { display: none; }
  .nav-toggle { display: inline-flex; }
}
.pagefoot { padding-block: var(--gap-xl); color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); margin-top: var(--gap-2xl); }
.pagefoot .row-between { flex-wrap: wrap; gap: var(--gap-md); align-items: flex-start; }
.pagefoot .foot-logo { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--fg); }
.pagefoot a { display: inline-block; padding-block: 6px; }
.pagefoot a:hover { color: var(--fg); }

/* ─── buttons & tags ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 15px; font-weight: 600; min-height: 44px;
  transition: transform 0.05s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--fg); }
.btn-ghost { background: transparent; color: var(--fg); border-color: transparent; padding-inline: 8px; }
.btn-ghost:hover { color: var(--accent); }
.btn-arrow::after { content: '→'; transition: transform 0.15s ease; }
.btn-arrow:hover::after { transform: translateX(3px); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { min-height: 40px; padding: 8px 16px; }
.tag {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
.tag-accent { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }

/* ─── hero ─────────────────────────────────────────────────────────── */
.hero { position: relative; padding-block: clamp(56px, 9vw, 120px) clamp(40px, 6vw, 72px); overflow: hidden; }
.hero::before {
  content: "";
  position: absolute; inset: -40% -20% auto -20%; height: 130%;
  background: radial-gradient(ellipse 55% 60% at 50% 0%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: 640px; }
.hero .lead { margin-top: 18px; }
.hero-avatar { width: 64px; height: 64px; border-radius: 999px; object-fit: cover; border: 1px solid var(--border); margin-bottom: 22px; }
.hero-actions { margin-top: 26px; flex-wrap: wrap; }

/* ─── pinned card ──────────────────────────────────────────────────── */
.pinned {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: clamp(22px, 4vw, 36px);
  margin-bottom: var(--gap-lg);
}
.pinned h2 a:hover { color: var(--accent); }
.pinned .dek { margin: 12px 0 0; max-width: 60ch; }
.pinned-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); margin-top: 20px; }

/* ─── journal feed ─────────────────────────────────────────────────── */
.log-row {
  display: grid; grid-template-columns: 112px 1fr 150px;
  gap: var(--gap-lg); padding: 24px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.log-row h3 { font-size: 18px; }
.log-row h3 a { transition: color 0.15s ease; }
.log-row h3 a:hover { color: var(--accent); }
.log-row .dek { margin: 6px 0 0; font-size: 14px; max-width: 62ch; }
.log-row .pull { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
@media (max-width: 920px) {
  .log-row { grid-template-columns: 1fr; gap: 8px; padding: 20px 0; }
  .log-row .pull { flex-direction: row; align-items: center; text-align: left; order: -1; justify-content: space-between; width: 100%; }
}
.thumb-strip { display: flex; gap: 8px; margin-top: 12px; }
.thumb-strip img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
  transition: transform 0.4s ease;
}
.log-row:hover .thumb-strip img { transform: scale(1.04); }
.doc-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 8px 12px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
}
.doc-chip svg { width: 14px; height: 14px; flex: none; }
.feed-sentinel { display: flex; justify-content: center; padding-block: 40px; }
.spinner {
  width: 24px; height: 24px; border-radius: 999px;
  border: 2px solid var(--border); border-top-color: var(--fg);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
.empty-state { text-align: center; padding-block: 64px; color: var(--faint); }

/* ─── gallery strip & masonry tiles ────────────────────────────────── */
.gallery-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-sm); }
@media (max-width: 920px) { .gallery-strip { grid-template-columns: repeat(2, 1fr); } }
.gallery-strip a {
  display: block; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border); transition: border-color 0.2s ease;
}
.gallery-strip a:hover { border-color: var(--accent); }
.gallery-strip img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; transition: transform 0.5s ease; }
.gallery-strip a:hover img { transform: scale(1.03); }
.masonry { columns: 2; column-gap: var(--gap-sm); }
@media (min-width: 768px) { .masonry { columns: 3; } }
.masonry > * { break-inside: avoid; margin-bottom: var(--gap-sm); }
.tile {
  display: block; border-radius: var(--radius-lg); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.tile:hover { box-shadow: var(--shadow-card); border-color: var(--accent); }
.tile img { width: 100%; transition: transform 0.5s ease; }
.tile:hover img { transform: scale(1.03); }
.tile-ph {
  aspect-ratio: 1 / 1; display: grid; place-items: center;
  background: var(--fg-soft);
  font-family: var(--font-display); font-size: 44px; color: var(--faint);
  font-weight: 700;
}
.tile-caption { padding: 12px 14px; }
.tile-caption h3 { font-size: 15px; line-height: 1.35; }
.tile-caption .meta { margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── author block ─────────────────────────────────────────────────── */
.author-photo { width: 100%; max-width: 260px; aspect-ratio: 1/1; object-fit: cover; border-radius: var(--radius-lg); border: 1px solid var(--border); }
@media (max-width: 920px) { .author-photo { max-width: 180px; } }

/* ─── article ──────────────────────────────────────────────────────── */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 40; }
@supports (animation-timeline: scroll()) {
  .progress {
    width: 100%; transform: scaleX(0); transform-origin: 0 50%;
    animation: progress-grow auto linear;
    animation-timeline: scroll(root);
  }
  @keyframes progress-grow { to { transform: scaleX(1); } }
}
.article-head { padding-block: clamp(40px, 7vw, 80px) clamp(24px, 4vw, 44px); }
.article-head h1 { font-size: clamp(26px, 4.6vw, 44px); margin-bottom: var(--gap-md); }
.article-head .dek { font-size: var(--fs-lead); max-width: 56ch; margin: 0; line-height: 1.6; }
.byline { display: flex; align-items: center; gap: 14px; margin-top: var(--gap-lg); padding-top: var(--gap-md); border-top: 1px solid var(--border); }
.byline .who { font-size: 14px; font-weight: 650; }
.byline .when { font-family: var(--font-mono); font-size: 12px; color: var(--faint); margin-top: 2px; }
.ava {
  width: 40px; height: 40px; border-radius: 999px; flex: none;
  display: grid; place-items: center;
  background: var(--fg-soft); border: 1px solid var(--border);
  font-weight: 700; font-size: 15px;
}
.cover { margin: 0 0 clamp(24px, 4.5vw, 48px); }
.cover img { border-radius: var(--radius-lg); border: 1px solid var(--border); width: 100%; max-height: 520px; object-fit: cover; }
.cover figcaption { font-family: var(--font-mono); font-size: 12px; color: var(--faint); margin-top: 8px; }
.article-body { padding-bottom: clamp(36px, 5.5vw, 64px); font-size: 17px; line-height: 1.7; }

/* Editor.js / markdown content */
.prose p { margin: 0 0 1.35em; }
.prose h2 { font-family: var(--font-display); font-size: var(--fs-h2); line-height: 1.25; margin: 1.9em 0 0.7em; font-weight: 700; }
.prose h3 { font-family: var(--font-display); font-size: 20px; margin: 1.6em 0 0.6em; font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.2em; margin: 0 0 1.35em; }
.prose li { margin-bottom: 0.4em; }
.prose blockquote {
  font-size: clamp(19px, 2.2vw, 23px); line-height: 1.5; font-weight: 550;
  margin: 1.6em 0; padding: 4px 0 4px 22px;
  border-left: 3px solid var(--accent);
}
.prose code {
  font-family: var(--font-mono); font-size: 0.85em;
  background: var(--fg-soft); padding: 2px 6px; border-radius: 6px;
}
.prose pre {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; margin: 0 0 1.35em;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6;
}
.prose pre code { background: none; padding: 0; }
.prose a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.prose a:hover { text-decoration-color: var(--fg); }
.prose img { border-radius: var(--radius-lg); }
.prose figure { margin: 2rem 0; }
.prose figcaption { text-align: center; color: var(--faint); margin-top: 0.5rem; font-family: var(--font-mono); font-size: 12px; }

/* post media attachments */
.media-list { display: grid; gap: var(--gap-md); margin-top: var(--gap-xl); }
.media-list figure { margin: 0; }
.media-list img, .media-list video { width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.media-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.media-block .meta { margin-bottom: 10px; display: block; }
.media-block audio { width: 100%; }
.pdf-viewer { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); background: var(--fg-soft); }
.pdf-pages { display: grid; gap: 8px; padding: 8px; }
.pdf-pages canvas { width: 100%; display: block; }
.pdf-error { color: var(--err); padding: 16px; }

/* ─── comments ─────────────────────────────────────────────────────── */
.comments { border-top: 1px solid var(--border); padding-block: var(--gap-xl); }
.comments h2 { margin-bottom: var(--gap-lg); }
.comment { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 20px 0; border-top: 1px solid var(--border); }
.comment .head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.comment .name { font-size: 14px; font-weight: 650; }
.comment p { margin: 6px 0 0; font-size: 15px; white-space: pre-wrap; }
.comment .actions { margin-top: 6px; display: flex; gap: 14px; }
.comment .actions button { background: none; border: 0; padding: 0; font-size: 12px; color: var(--faint); }
.comment .actions button:hover { color: var(--accent); }
.comment .actions .danger:hover { color: var(--err); }
.comment-replies { border-left: 1px solid var(--border); padding-left: 16px; margin-top: 4px; }
.comment-replies .comment { border-top: 0; padding: 12px 0; }
.reply-form-container form { margin-top: 10px; }
.comment ~ .no-comments { display: none; }
.comment-replies:empty { display: none; }

/* ─── forms ────────────────────────────────────────────────────────── */
.field {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font: inherit; line-height: 1.55;
}
.field:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field:focus-visible { outline: 2px solid var(--accent); }
textarea.field { resize: vertical; min-height: 96px; }
.field-lg { padding: 16px 20px; font-size: 18px; }
.code-input {
  text-align: center; font-family: var(--font-mono);
  font-size: 24px; letter-spacing: 0.3em; text-transform: uppercase;
}
.form-label {
  display: block; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 8px;
}
.form-hint { font-family: var(--font-mono); font-size: 12px; color: var(--faint); }
.notice { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; font-size: 14px; }
.notice-error { color: var(--err); border-color: rgba(161, 60, 26, 0.4); background: rgba(161, 60, 26, 0.07); }
.notice-success { color: var(--ok); border-color: rgba(63, 98, 18, 0.4); background: rgba(63, 98, 18, 0.07); }

/* ─── login steps ──────────────────────────────────────────────────── */
.steps { display: grid; gap: var(--gap-md); margin-bottom: var(--gap-lg); }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step .n {
  flex: none; width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--fg); color: var(--bg);
  font-family: var(--font-mono); font-size: 12px;
}
.step p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }

/* ─── profile ──────────────────────────────────────────────────────── */
.profile-head { text-align: center; margin-bottom: var(--gap-lg); }
.profile-head .ava { width: 72px; height: 72px; font-size: 26px; margin-inline: auto; margin-bottom: 14px; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; padding-block: 8px; font-size: 14px; }
.stat-row .k { color: var(--faint); }
.xp-bar { height: 8px; background: var(--fg-soft); border-radius: 999px; overflow: hidden; }
.xp-bar > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }
.ach-row { display: flex; gap: 12px; align-items: flex-start; padding-block: 10px; }
.ach-row img, .ach-row .ach-ph { width: 48px; height: 48px; border-radius: var(--radius); object-fit: cover; flex: none; }
.ach-row .ach-ph { display: grid; place-items: center; background: var(--fg-soft); font-weight: 700; color: var(--faint); }
.ach-row h4 { margin: 0; font-size: 14px; }
.ach-row p { margin: 2px 0 0; font-size: 12px; color: var(--faint); }
.divider { border: 0; border-top: 1px solid var(--border); margin-block: var(--gap-lg); }

/* ─── animations: scroll reveal + view transitions ─────────────────── */
/* Hidden state only when JS confirmed IntersectionObserver support
   (html.has-reveal set by site.js), so content is never lost without JS. */
.has-reveal [data-reveal] {
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.has-reveal [data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .has-reveal [data-reveal] { opacity: 1; transform: none; transition: none; }
}
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
}
