/* Floating TOC Styles for Production */
.progress-ring-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1000;
  cursor: pointer;
  background: white;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 5px;
  transition: transform 0.3s ease;
}

.progress-ring-container:hover {
  transform: scale(1.05);
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.35s;
  stroke-dasharray: 169.65;
  stroke-dashoffset: 0;
}

.progress-ring__progress {
  stroke-dasharray: 169.65;
  stroke-dashoffset: 169.65;
  transition: stroke-dashoffset 0.35s;
}

.progress-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: bold;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.floating-toc.modern {
  position: fixed;
  top: 50%;
  right: -300px;  /* 기본으로 숨김 */
  transform: translateY(-50%);
  width: 280px;
  max-height: 70vh;
  background: white;
  border-radius: 16px 0 0 16px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  display: none;
  flex-direction: column;
}

.floating-toc.modern.show {
  right: 0;  /* 표시 상태 */
}

.floating-toc.modern.hide {
  right: -300px;  /* 숨김 상태 */
}

.floating-toc .toc-header {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 16px 0 0 0;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: center;
  align-items: center;
}

.floating-toc .toc-title {
  font-size: 18px;
  font-weight: bold;
  color: #374151;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 8px;
}

.floating-toc .toc-title::before {
  content: "📚";
  font-size: 20px;
  -webkit-text-fill-color: initial;
}

/* X 버튼 제거됨 */

.floating-toc nav {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.floating-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.floating-toc li {
  margin: 0;
}

.floating-toc a {
  display: block;
  padding: 10px 15px;
  color: #4b5563;
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s;
  font-size: 14px;
  border: none !important;
}

.floating-toc a:hover {
  background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
  color: #667eea;
  transform: translateX(5px);
  border: none !important;
}

.floating-toc a.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}

.floating-toc li ul {
  margin-left: 15px;
  margin-top: 5px;
}

.floating-toc li ul a {
  font-size: 13px;
  padding: 8px 12px;
  color: #6b7280;
}

.floating-toc li ul a.active {
  background: linear-gradient(135deg, rgba(102,126,234,0.2) 0%, rgba(118,75,162,0.2) 100%);
  color: #667eea;
  font-weight: 500;
}

/* Mobile TOC Styles */
.toc-toggle {
  display: none;
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
  z-index: 999;
  transition: transform 0.3s ease;
}

.toc-toggle:hover {
  transform: scale(1.1);
}

.mobile-toc {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-toc.active {
  opacity: 1;
  visibility: visible;
}

.mobile-toc .toc-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  max-height: 70vh;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-toc.active .toc-content {
  transform: translateY(0);
}

.mobile-toc .close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0,0,0,0.05);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.mobile-toc .close-btn:hover {
  background: rgba(0,0,0,0.1);
}

.mobile-toc .toc-title {
  padding: 20px;
  font-size: 20px;
  font-weight: bold;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-align: center;
}

.mobile-toc nav {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(70vh - 100px);
}

.mobile-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-toc a {
  display: block;
  padding: 15px;
  color: #374151;
  text-decoration: none;
  border-bottom: 1px solid #f3f4f6;
  transition: all 0.3s;
  border: none !important;
}

.mobile-toc a:hover {
  background: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
  padding-left: 25px;
  border: none !important;
}

.mobile-toc a.active {
  color: #667eea;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(102,126,234,0.05) 0%, rgba(118,75,162,0.05) 100%);
}

.mobile-toc li ul {
  margin-left: 20px;
  margin-top: 5px;
}

.mobile-toc li ul a {
  font-size: 14px;
  padding: 12px 15px;
  color: #6b7280;
}

/* Responsive Design */

/* 대형 화면 (1700px+) - 목차 항상 표시 */
@media (min-width: 1700px) {
  .floating-toc.modern {
    right: 20px;
    display: flex !important;
  }
  
  .floating-toc.modern.hide {
    right: -300px;
  }
  
  .progress-ring-container {
    display: flex !important;
  }
  
  .toc-toggle {
    display: none !important;
  }
}

/* 중형 화면 (1024px-1699px) - 플로팅 버튼으로 토글 */
@media (min-width: 1024px) and (max-width: 1699px) {
  .floating-toc.modern {
    width: 280px;
    right: -300px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
  }
  
  .floating-toc.modern.show {
    right: 0;
  }
  
  .progress-ring-container {
    display: none !important;
  }
  
  .toc-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    z-index: 999;
    transition: transform 0.3s ease;
  }
  
  .toc-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  }
}

/* 소형 화면 (768px-1023px) - 플로팅 버튼으로 토글 */  
@media (min-width: 768px) and (max-width: 1023px) {
  .floating-toc.modern {
    width: 260px;
    right: -280px;
    display: flex !important;
  }
  
  .floating-toc.modern.show {
    right: 0;
  }
  
  .progress-ring-container {
    display: none !important;
  }
  
  .toc-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
}

/* 모바일 (768px 미만) - 모바일 TOC 사용 */
@media (max-width: 767px) {
  .progress-ring-container,
  .floating-toc.modern {
    display: none !important;
  }
  
  .toc-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  
  .mobile-toc {
    display: block;
  }
  
  .content {
    max-width: 100% !important;
  }
}

/* Main content width adjustment */
@media (min-width: 1440px) {
  .layout-post .content {
    max-width: 42rem;
  }
  
  .floating-toc.modern.show ~ main .content,
  .has-toc .content {
    max-width: 42rem;
  }
}

/* Ensure proper z-index stacking */
.navbar {
  z-index: 1001;
}

/* Hide permalink text in TOC */
.floating-toc a .permalink-symbol,
.floating-toc a .sr-only,
.mobile-toc a .permalink-symbol,
.mobile-toc a .sr-only {
  display: none !important;
}

/* Hide any text that says "Permalink" */
.floating-toc a:contains("Permalink"),
.mobile-toc a:contains("Permalink") {
  font-size: 0;
}

.floating-toc a:contains("Permalink")::before,
.mobile-toc a:contains("Permalink")::before {
  content: attr(data-heading-text);
  font-size: 14px;
}

/* More specific permalink hiding */
.floating-toc .permalink,
.mobile-toc .permalink,
.floating-toc [aria-label*="permalink"],
.mobile-toc [aria-label*="permalink"],
.floating-toc [title*="permalink"], 
.mobile-toc [title*="permalink"],
.floating-toc [title*="Permalink"],
.mobile-toc [title*="Permalink"] {
  display: none !important;
  visibility: hidden !important;
}

/* Force hide any element containing "Permalink" text */
.floating-toc a *:contains("Permalink"),
.mobile-toc a *:contains("Permalink"),
.floating-toc a span:contains("Permalink"),
.mobile-toc a span:contains("Permalink") {
  display: none !important;
}

/* Generic permalink text hiding */
.floating-toc a::after,
.mobile-toc a::after {
  content: none !important;
}

/* Hide permalink symbols */
.floating-toc .anchor,
.mobile-toc .anchor,
.floating-toc .permalink-anchor,
.mobile-toc .permalink-anchor,
.floating-toc .header-link,
.mobile-toc .header-link {
  display: none !important;
}