/* Single post layout — inspired by SEONGON knowledge pages, Hatena colors */

.hatena-single.single-post-page {
  padding-top: 32px;
  padding-bottom: 80px;
}

.hatena-article-head {
  /* max-width: 920px; */
  margin-bottom: 28px;
}

.hatena-article-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #737373;
  margin-bottom: 16px;
}

.hatena-article-breadcrumb a {
  color: #737373;
  text-decoration: none;
}

.hatena-article-breadcrumb a:hover {
  color: #2f0874;
}

.hatena-bc-sep {
  color: #bbb;
}

.hatena-article-title {
  font-size: 32px;
  line-height: 1.3;
  font-weight: 700;
  color: #111;
  text-transform: none;
  border: 0;
  padding: 0;
  margin: 0 0 14px;
}

.hatena-article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  font-size: 13px;
  color: #737373;
}

.hatena-article-cat {
  display: inline-flex;
  align-items: center;
  background: #f3eefe;
  color: #2f0874 !important;
  font-weight: 600;
  font-style: normal !important;
  text-decoration: none !important;
  padding: 4px 10px;
  border-radius: 4px;
}

.hatena-article-cat:hover {
  background: #2f0874;
  color: #fff !important;
}

.hatena-article-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 290px;
  gap: 36px;
  align-items: start;
}

.hatena-article-cats {
  position: sticky;
  top: 88px;
  margin-top: 18px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  align-self: start;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d4 transparent;
}

.hatena-article-cats::-webkit-scrollbar {
  width: 4px;
}

.hatena-article-cats::-webkit-scrollbar-track {
  background: transparent;
}

.hatena-article-cats::-webkit-scrollbar-thumb {
  background: #d4d4d4;
  border-radius: 8px;
}

.hatena-article-cats::-webkit-scrollbar-thumb:hover {
  background: #bdbdbd;
}

.hatena-article-aside {
  position: sticky;
  top: 88px;
  margin-top: 18px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* WordPress admin bar adds 32px above the 70px sticky site header. */
.admin-bar .hatena-article-cats,
.admin-bar .hatena-article-aside {
  top: 120px;
}

.admin-bar .hatena-article-cats {
  max-height: calc(100vh - 136px);
}

.admin-bar .hatena-article-aside {
  max-height: calc(100vh - 136px);
}

.hatena-article-cats-inner {
  position: static;
  max-height: none;
}

.hatena-article-aside-inner {
  position: static;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.hatena-cats-title {
  font-size: 16px;
  font-weight: 700;
  color: #111;
  margin: 0 0 12px;
}

.hatena-cat-list,
.hatena-cat-posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hatena-cat-item {
  border-bottom: 1px solid #eee;
}

.hatena-cat-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  padding: 12px 6px 12px 10px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: #222;
  cursor: pointer;
  line-height: 1.35;
  text-transform: none;
}

.hatena-cat-item.is-current .hatena-cat-toggle,
.hatena-cat-item.is-open .hatena-cat-toggle {
  border-left-color: #2f0874;
  color: #2f0874;
}

.hatena-cat-chevron {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-right: 4px;
}

.hatena-cat-item.is-open .hatena-cat-chevron {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.hatena-cat-posts {
  display: none;
  padding: 0 0 10px 12px;
}

.hatena-cat-item.is-open .hatena-cat-posts,
.hatena-cat-posts.is-flat {
  display: block;
}

.hatena-cat-posts.is-flat {
  padding: 0;
}

.hatena-cat-post,
.hatena-cat-more {
  display: block;
  padding: 6px 4px;
  font-size: 13px;
  line-height: 1.45;
  color: #444;
  text-decoration: none;
}

.hatena-cat-post:hover,
.hatena-cat-more:hover {
  color: #2f0874;
}

.hatena-cat-post.is-active {
  color: #f96c01;
  font-weight: 600;
}

.hatena-cat-more {
  font-weight: 600;
  color: #2f0874;
}

/* Right TOC */
.hatena-toc-card {
  border: 1px solid #e4d7ff;
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px 12px;
  margin-bottom: 18px;
  box-shadow: 0 6px 20px rgba(47, 8, 116, 0.04);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hatena-toc-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  margin: 0 !important;
  padding: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: #111;
  cursor: pointer;
  flex: 0 0 auto;
}

.hatena-toc-card:not(.is-open) .hatena-toc-head {
  padding-bottom: 0;
}

.hatena-toc-card:not(.is-open) .hatena-toc-list {
  display: none;
}

.hatena-toc-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f3eefe;
  color: #2f0874;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  line-height: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.hatena-toc-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.hatena-toc-head:hover .hatena-toc-icon {
  background: #2f0874;
  color: #fff;
}

.hatena-toc-card:not(.is-open) .hatena-toc-icon {
  background: #2f0874;
  color: #fff;
}

.hatena-toc-list {
  list-style: none !important;
  margin: 0;
  padding: 0 4px 0 0 !important;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: none;
  min-height: 0;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d4 transparent;
}

.hatena-toc-list::-webkit-scrollbar {
  width: 4px;
}

.hatena-toc-list::-webkit-scrollbar-track {
  background: transparent;
}

.hatena-toc-list::-webkit-scrollbar-thumb {
  background: #d4d4d4;
  border-radius: 8px;
}

.hatena-toc-list::-webkit-scrollbar-thumb:hover {
  background: #bdbdbd;
}

.hatena-toc-list li {
  margin: 0;
  padding: 0;
}

.hatena-toc-link {
  display: flex;
  gap: 6px;
  padding: 7px 4px;
  font-size: 13.5px;
  line-height: 1.4;
  color: #333;
  text-decoration: none;
  border-radius: 6px;
}

.hatena-toc-list .is-h3 .hatena-toc-link {
  padding-left: 18px;
  font-size: 13px;
  color: #555;
}

.hatena-toc-link:hover,
.hatena-toc-link.is-active {
  color: #2f0874;
  font-weight: 600;
}

.hatena-toc-num {
  flex: 0 0 auto;
  color: inherit;
}

/* CTA */
.hatena-cta-card {
  background: linear-gradient(180deg, #4a1aad 0%, #2f0874 100%);
  color: #fff;
  border-radius: 16px;
  padding: 22px 20px 20px;
  flex: 0 0 auto;
}

.hatena-cta-title {
  font-size: 18px;
  line-height: 1.4;
  font-weight: 800;
  color: #fff;
  margin: 0 0 12px;
}

.hatena-cta-desc {
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.92);
  margin: 0 0 18px;
}

.hatena-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #1f0560;
  color: #fff !important;
  font-style: normal !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 14px 10px 18px;
  border-radius: 999px;
  box-shadow: none;
}

.hatena-cta-btn:hover {
  background: #160447;
  color: #fff !important;
}

.hatena-cta-arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

/* Content tweaks inside new layout */
.hatena-article-content h2,
.hatena-article-content h3 {
  scroll-margin-top: 110px;
}

.hatena-article-content h2 {
  font-size: 26px;
  line-height: 1.35;
  margin: 1.6em 0 0.7em;
  color: #111;
}

.hatena-article-content h3 {
  font-size: 20px;
  margin: 1.35em 0 0.55em;
}

.hatena-article-body #ez-toc-container,
.hatena-article-body .ez-toc-container {
  display: none !important;
}

.hatena-related {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px solid #eee;
}

.hatena-related-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  color: #111;
}

.hatena-related-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.hatena-related-item {
  display: block;
  text-decoration: none !important;
  font-style: normal !important;
  color: #111 !important;
}

.hatena-related-thumb {
  display: block;
  margin-bottom: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: #f4f4f4;
  aspect-ratio: 16 / 10;
}

.hatena-related-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hatena-related-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #111;
}

.hatena-related-item:hover .hatena-related-name {
  color: #2f0874;
}

@media (max-width: 1199px) {
  .hatena-article-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .hatena-article-cats {
    grid-column: 1 / -1;
    order: 3;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .hatena-article-cats-inner {
    position: static;
    max-height: none;
  }
}

@media (max-width: 767px) {
  .hatena-article-title {
    font-size: 24px;
  }

  .hatena-article-layout {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .hatena-article-aside,
  .hatena-article-cats {
    position: static;
    margin-top: 0;
    max-height: none;
    overflow: visible;
  }

  .hatena-article-aside,
  .hatena-article-aside-inner {
    display: contents;
  }

  .hatena-toc-card {
    order: -1;
    margin-bottom: 0;
    flex: none;
    max-height: none;
    overflow: hidden;
  }

  .hatena-toc-list {
    max-height: min(48vh, 340px);
  }

  .hatena-article-body {
    order: 0;
  }

  .hatena-cta-card {
    order: 2;
  }

  .hatena-article-cats {
    order: 3;
  }

  .hatena-related-list {
    grid-template-columns: 1fr;
  }

  .hatena-article-content h2 {
    font-size: 22px;
  }
}
