/* =============================================
   COMPONENTS — TOC, Social Share, Author Box,
                Related Posts, Misc UI
   ============================================= */

/* ---- FLOATING TABLE OF CONTENTS ---- */
.toc-wrapper {
  position: fixed;
  right: max(1rem, calc((100vw - var(--content-w)) / 2 - 280px));
  top: 100px;
  width: 240px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  z-index: 50;
  transition: opacity .3s;
}
.toc-wrapper::-webkit-scrollbar { width: 4px; }
.toc-wrapper::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

@media (max-width: 1300px) {
  .toc-wrapper { display: none; }
}

.toc-box {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.toc-box .toc-list {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}
.toc-box .toc-list::-webkit-scrollbar { width: 4px; }
.toc-box .toc-list::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }
.toc-box__title {
  font-family: var(--font-heading);
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
  margin-bottom: .85rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-list li { margin-bottom: .1rem; }
.toc-list a {
  display: block;
  padding: .3rem .5rem;
  font-size: .8rem;
  color: var(--gray-500);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  transition: color .15s, border-color .15s, background .15s;
  line-height: 1.4;
}
.toc-list a:hover { color: var(--primary); background: #fff7ed; }
.toc-list a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: #fff7ed;
  font-weight: 600;
}
/* Nested headings indent */
.toc-list .toc-h3 a { padding-left: 1.25rem; font-size: .75rem; }
.toc-list .toc-h4 a { padding-left: 2rem; font-size: .72rem; }

/* ---- FLOATING SOCIAL SHARE (left side) ---- */
.social-share-float {
  position: fixed;
  left: max(1rem, calc((100vw - var(--content-w)) / 2 - 64px));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: .6rem;
  z-index: 50;
}
@media (max-width: 1200px) {
  .social-share-float { display: none; }
}
.social-share-float__label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gray-400);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  text-align: center;
  margin-bottom: .25rem;
}
.social-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: transform .2s, opacity .2s;
  text-decoration: none;
}
.social-share-btn:hover { transform: scale(1.1); opacity: .9; }
.social-share-btn svg { width: 18px; height: 18px; fill: #fff; display: block; }
.social-share-btn--twitter   { background: #000000; }
.social-share-btn--facebook  { background: #1877f2; }
.social-share-btn--linkedin  { background: #0a66c2; }
.social-share-btn--whatsapp  { background: #25d366; }
.social-share-btn--pinterest { background: #e60023; }
.social-share-btn--reddit    { background: #ff4500; }

/* Inline social share (below post, mobile fallback) */
.social-share-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  margin: 2.5rem 0;
}
.social-share-inline__label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-500);
  margin-right: .25rem;
}
.social-share-inline .social-share-btn {
  width: 36px;
  height: 36px;
}
.social-share-inline .social-share-btn svg { width: 16px; height: 16px; }

/* ---- AUTHOR BOX ---- */
.author-box {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 4rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.author-box__avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--white);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.author-box__content { flex: 1; min-width: 220px; }
.author-box__name {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .25rem;
}
.author-box__role {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--primary);
  margin-bottom: .75rem;
}
.author-box__bio {
  font-size: .95rem;
  color: var(--secondary);
  line-height: 1.75;
  margin-bottom: 1rem;
}
.author-box__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}
.author-box__social a {
  font-size: .875rem;
  font-weight: 600;
  color: var(--primary);
  transition: color .2s;
}
.author-box__social a:hover { color: var(--accent); }
.author-box__all-posts {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--accent);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 2px;
}
.author-box__all-posts:hover { color: var(--primary); }

/* ---- RELATED POSTS ---- */
.related-posts { margin-top: 4rem; }
.related-posts__title {
  font-size: 1.4rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}
.related-posts__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}
@media (max-width: 680px) {
  .related-posts__grid { grid-template-columns: 1fr; }
}
.related-post-card { cursor: pointer; }
.related-post-card__thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  filter: grayscale(50%);
  transition: filter .3s;
}
.related-post-card:hover .related-post-card__thumb { filter: grayscale(0); }
.related-post-card__title {
  font-family: var(--font-heading);
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.4;
  transition: color .2s;
}
.related-post-card:hover .related-post-card__title { color: var(--primary); }
.related-post-card__date { font-size: .75rem; color: var(--gray-400); margin-top: .4rem; }

/* ---- CATEGORY / AUTHOR ARCHIVE AUTHOR HEADER ---- */
.author-archive-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 3rem;
}
.author-archive-header img {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow);
}
.author-archive-header h1 { font-size: 1.75rem; margin-bottom: .25rem; }
.author-archive-header p { font-size: .9rem; color: var(--gray-500); }

/* ---- NOTICE BOXES ---- */
.notice {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}
.notice--info    { background: #eff6ff; border-left: 4px solid #3b82f6; color: #1e40af; }
.notice--warning { background: #fffbeb; border-left: 4px solid #f59e0b; color: #92400e; }
.notice--success { background: #f0fdf4; border-left: 4px solid #22c55e; color: #166534; }
.notice--error   { background: #fef2f2; border-left: 4px solid #ef4444; color: #991b1b; }

/* ---- NO POSTS ---- */
.no-posts {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--gray-500);
}
.no-posts h2 { font-size: 1.4rem; margin-bottom: .75rem; color: var(--accent); }

/* ---- MOBILE INLINE TOC (accordion) ---- */
.toc-mobile {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 2rem;
  display: none;
}
@media (max-width: 1300px) {
  .toc-mobile { display: block; }
}
.toc-mobile__toggle {
  width: 100%;
  padding: .85rem 1.25rem;
  background: none;
  border: none;
  text-align: left;
  font-family: var(--font-heading);
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-mobile__toggle svg { transition: transform .25s; }
.toc-mobile.is-open .toc-mobile__toggle svg { transform: rotate(180deg); }
.toc-mobile__body {
  display: none;
  padding: .5rem 1.25rem 1rem;
}
.toc-mobile.is-open .toc-mobile__body { display: block; }
.toc-mobile .toc-list a { font-size: .85rem; }

/* ---- SCROLL TO TOP ---- */
.scroll-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  box-shadow: var(--shadow);
  z-index: 99;
}
.scroll-top-btn.visible { opacity: 1; pointer-events: auto; }
.scroll-top-btn:hover { transform: translateY(-3px); }
.scroll-top-btn svg { width: 20px; height: 20px; fill: #fff; }

/* ---- SIDEBAR AD BOX ---- */
.sidebar-ad-box {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 2.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.sidebar-ad-box img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity .2s;
}
.sidebar-ad-box:hover img { opacity: .9; }
.sidebar-ad-placeholder {
  width: 300px;
  height: 300px;
  max-width: 100%;
  background: var(--gray-50);
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: var(--gray-400);
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
  margin: 0 auto 2.5rem;
}
.sidebar-ad-placeholder svg { opacity: .35; }

/* ---- AUTHOR SOCIAL ICONS ---- */
.author-social-icons {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .5rem;
}
.author-social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-700);
  transition: background .2s, color .2s;
  text-decoration: none;
}
.author-social-icon:hover { background: var(--primary); color: #fff; }
.author-social-icon svg { width: 15px; height: 15px; fill: currentColor; }

/* ---- READING PROGRESS BAR ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--primary);
  z-index: 9999;
  width: 0%;
  transition: width .1s linear;
}
