:root {
  color-scheme: light;
  --paper: #f7f1e6;
  --paper-deep: #efe5d2;
  --ink: #11100e;
  --ink-soft: #2f2d29;
  --muted: #6b665d;
  --hairline: #c9bea8;
  --rule: #171512;
  --accent: #7f1d1d;
  --accent-soft: #f3dfd7;
  --max-width: 1180px;
  --serif: Georgia, "Times New Roman", Times, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 0, 0, 0.035), transparent 28rem),
    linear-gradient(90deg, rgba(0,0,0,0.025) 1px, transparent 1px),
    linear-gradient(var(--paper), var(--paper-deep));
  background-size: auto, 7px 7px, auto;
  color: var(--ink);
  font-family: var(--serif);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.35;
  background-image:
    radial-gradient(rgba(17,16,14,0.08) 0.7px, transparent 0.7px),
    radial-gradient(rgba(17,16,14,0.05) 0.6px, transparent 0.6px);
  background-position: 0 0, 4px 5px;
  background-size: 9px 9px, 13px 13px;
}

.skip-link {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 10;
  padding: 8px 12px;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.background-glow {
  display: none;
}

.shell {
  width: min(var(--max-width), calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.glass {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.hero {
  position: relative;
  padding: 18px 0 20px;
  border-top: 4px double var(--rule);
  border-bottom: 4px double var(--rule);
  text-align: center;
}

.hero::before,
.hero::after {
  position: absolute;
  top: 16px;
  width: 22%;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  height: 4px;
  content: "";
}

.hero::before {
  left: 0;
}

.hero::after {
  right: 0;
}

.brand {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  text-decoration: none;
}

.brand__icon {
  order: 2;
  display: inline-grid;
  min-width: 0;
  width: auto;
  height: auto;
  margin-top: 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 1.05rem;
  filter: grayscale(1);
}

.brand__title,
.brand__subtitle {
  display: block;
}

.brand__title {
  font-family: var(--serif);
  font-size: clamp(3.2rem, 10vw, 7.3rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.075em;
  text-rendering: optimizeLegibility;
}

.brand__subtitle {
  position: relative;
  margin-top: 10px;
  font-family: var(--sans);
  color: var(--ink-soft);
  font-size: clamp(0.72rem, 1.6vw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.brand__subtitle::before {
  content: "THE KNOWLEDGE JOURNAL • ";
}

.hero__text {
  max-width: none;
  margin: 15px auto 0;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 0.98rem;
  font-style: italic;
  line-height: 1.45;
}

.hero__text::before {
  content: "Published for practical lessons and field notes. ";
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rss-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  padding: 7px 13px 6px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-decoration: none;
  text-transform: uppercase;
}

.rss-button:hover,
.rss-button:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.controls {
  margin-top: 18px;
  padding: 12px 0 14px;
  border-top: 2px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: transparent;
}

.tags,
.type-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.type-tabs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}

.chip,
.type-tab,
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.18);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transition: 140ms ease;
}

.chip,
.type-tab {
  padding: 7px 10px 6px;
  font-size: 0.68rem;
}

.chip:hover,
.type-tab:hover,
.back-link:hover,
.card:hover {
  border-color: var(--rule);
  background: rgba(17, 16, 14, 0.055);
}

.chip.is-active,
.type-tab.is-active {
  border-color: var(--rule);
  background: var(--rule);
  color: var(--paper);
}

.search-form {
  display: flex;
  max-width: 760px;
  gap: 0;
  margin: 12px auto 0;
}

.search-input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--rule);
  border-right: 0;
  border-radius: 0;
  outline: none;
  background: rgba(255, 255, 255, 0.34);
  color: var(--ink);
  padding: 11px 12px;
  font: 0.92rem var(--serif);
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  background: #fffaf0;
  box-shadow: inset 0 0 0 2px rgba(17,16,14,0.08);
}

.search-button {
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--rule);
  color: var(--paper);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  padding: 0 18px;
  text-transform: uppercase;
}

.content {
  margin-top: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-title::before,
.section-title::after {
  flex: 1;
  border-top: 1px solid var(--rule);
  content: "";
}

.feed {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 2px solid var(--rule);
  border-bottom: 2px solid var(--rule);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 20px 18px 22px;
  border: 0;
  border-right: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  transition: 140ms ease;
}

.card__image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin-bottom: 14px;
  border-radius: 0;
}

.card__link {
  color: inherit;
  text-decoration: none;
}

.card__link::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card__tags .tag,
.card__image,
.card__meta,
.card__title,
.card__excerpt {
  position: relative;
  z-index: 2;
}

.card:nth-child(3n) {
  border-right: 0;
}

.card:first-child {
  grid-column: span 2;
  min-height: 300px;
  padding: 24px 26px 28px;
}

.card:first-child .card__image {
  aspect-ratio: 21 / 9;
}

.card:hover {
  transform: none;
}

.card__meta,
.post__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.card__title {
  margin: 10px 0 9px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: -0.052em;
}

.card:first-child .card__title {
  font-size: clamp(2.3rem, 5.2vw, 4.15rem);
  line-height: 0.92;
}

.card__excerpt {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.48;
}

.card:first-child .card__excerpt {
  columns: 2 16rem;
  column-gap: 24px;
  font-size: 1.05rem;
}

.card__tags,
.post__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 14px;
}

.tag {
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--rule);
  padding: 2px 6px 1px;
  font-family: var(--sans);
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post {
  max-width: 900px;
  margin: 0 auto;
  padding: 26px 0 0;
  border-top: 2px solid var(--rule);
}

.related-posts {
  max-width: 1000px;
  margin: 42px auto 0;
  padding-top: 24px;
  border-top: 4px double var(--rule);
}

.related-posts h2 {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.related-posts .feed {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.related-posts .card:first-child {
  grid-column: auto;
  min-height: 100%;
  padding: 20px 18px 22px;
}

.related-posts .card:first-child .card__title {
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  line-height: 0.98;
}

.related-posts .card:first-child .card__excerpt {
  columns: auto;
  font-size: 1rem;
}


.back-link {
  margin-bottom: 22px;
  padding: 8px 10px 7px;
  font-size: 0.68rem;
}

.post__title {
  margin: 13px 0 11px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(3rem, 8.7vw, 6.4rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.072em;
  text-align: center;
}

.post__tags {
  justify-content: center;
  margin-bottom: 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.post__meta {
  justify-content: center;
}

.markdown {
  max-width: 760px;
  margin: 0 auto;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.08rem, 2vw, 1.24rem);
  line-height: 1.72;
}

.markdown > *:first-child {
  margin-top: 0;
}

.markdown > p:first-of-type::first-letter {
  float: left;
  margin: 0.08em 0.08em 0 0;
  font-size: 4.2em;
  font-weight: 900;
  line-height: 0.78;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.markdown h2 {
  margin: 2.1rem 0 0.75rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.95rem;
}

.markdown h3 {
  margin-top: 1.6rem;
  font-size: 0.82rem;
}

.markdown a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.markdown ul,
.markdown ol {
  padding-left: 1.25rem;
}

.markdown li + li {
  margin-top: 0.35rem;
}

.markdown code {
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.46);
  color: var(--accent);
  padding: 0.1em 0.28em;
  font-family: var(--mono);
  font-size: 0.86em;
}

.markdown pre {
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: #fdf8ed;
  padding: 16px;
}

.markdown pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.markdown img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 1.6rem auto;
  border: 1px solid var(--hairline);
  background: #fffaf0;
  box-shadow: 0 10px 26px rgba(17, 16, 14, 0.09);
}

.markdown picture.responsive-image {
  display: block;
  margin: 1.85rem auto;
  aspect-ratio: 16 / 9;
}

.markdown picture.responsive-image img {
  width: 100%;
  height: auto;
  margin: 0 auto;
}

.markdown .image-caption,
.markdown p.caption {
  max-width: 92%;
  margin: -0.9rem auto 1.6rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
}

.markdown blockquote {
  margin: 1.8rem 0;
  border-top: 2px solid var(--rule);
  border-bottom: 2px solid var(--rule);
  background: transparent;
  padding: 16px 8px;
  color: var(--ink);
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.35;
  text-align: center;
}

.empty,
.error {
  padding: 24px;
  border: 2px solid var(--rule);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.26);
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.empty code,
.error code {
  font-family: var(--mono);
}

.error {
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 900px) {
  .feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card:nth-child(3n) {
    border-right: 1px solid var(--hairline);
  }

  .card:nth-child(2n) {
    border-right: 0;
  }

  .card:first-child {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, var(--max-width));
    padding-top: 12px;
  }

  .hero {
    padding-top: 14px;
  }

  .hero::before,
  .hero::after {
    display: none;
  }

  .brand__title {
    font-size: clamp(2.7rem, 16vw, 4.6rem);
  }

  .hero__text::before {
    display: block;
    margin-bottom: 4px;
  }

  .feed {
    grid-template-columns: 1fr;
  }

  .card,
  .card:first-child,
  .card:nth-child(2n),
  .card:nth-child(3n) {
    grid-column: auto;
    min-height: 0;
    border-right: 0;
    padding: 18px 0;
  }

  .card:first-child .card__title,
  .related-posts .card:first-child .card__title {
    font-size: 1.15rem;
    line-height: 1.25;
  }

  .card:first-child .card__excerpt {
    columns: auto;
  }

  .search-form {
    flex-direction: column;
  }

  .search-input {
    border-right: 1px solid var(--rule);
    border-bottom: 0;
  }

  .search-button {
    min-height: 42px;
  }

  .post__title {
    font-size: clamp(2.5rem, 15vw, 4rem);
  }

  .markdown > p:first-of-type::first-letter {
    font-size: 3.2em;
  }

  .markdown img {
    width: 100%;
    max-width: 100%;
    margin: 1.25rem auto;
    box-shadow: 0 7px 18px rgba(17, 16, 14, 0.08);
  }

  .markdown picture.responsive-image {
    margin: 1.35rem auto;
  }

  .markdown .image-caption,
  .markdown p.caption {
    max-width: 100%;
    margin: -0.65rem auto 1.35rem;
    font-size: 0.78rem;
  }
}

/* TOC */
.toc {
  background: rgba(45, 42, 38, 0.04);
  border: 1px solid rgba(45, 42, 38, 0.08);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.toc__title {
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
  color: #6b6358;
}
.toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  column-count: 2;
  column-gap: 1.5rem;
}
.toc__item {
  break-inside: avoid;
}
.toc__item--3 {
  padding-left: 1rem;
}
.toc__link {
  font-size: 0.85rem;
  color: #8a7f72;
  text-decoration: none;
  display: block;
  padding: 0.15rem 0;
}
.toc__link:hover {
  color: #2d2a26;
  text-decoration: underline;
}
@media (max-width: 600px) {
  .toc__list { column-count: 1; }
}

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1rem 0;
}
.pager__link {
  padding: 0.5rem 1rem;
  background: rgba(45, 42, 38, 0.06);
  border-radius: 6px;
  color: #2d2a26;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.pager__link:hover {
  background: rgba(45, 42, 38, 0.12);
}
.pager__info {
  font-size: 0.85rem;
  color: #8a7f72;
}
