/* layout.css - GNB, 3-Column Responsive Layout, Accordion LNB, TOC, Footer */

/* Top GNB Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-menu-btn {
  display: none;
  font-size: 1.25rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  line-height: 1;
}

.mobile-menu-btn:hover {
  background-color: var(--bg-hover);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  text-decoration: none;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  background-color: var(--badge-bg);
  color: var(--badge-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--primary-color);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Theme Preset Dropdown */
.theme-preset-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.theme-preset-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.35rem 1.8rem 0.35rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-speed) ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}

.theme-preset-select:hover {
  border-color: var(--primary-color);
  background-color: var(--bg-hover);
}

.theme-preset-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-light);
}

@media (max-width: 768px) {
  .theme-preset-select {
    padding: 0.3rem 1.4rem 0.3rem 0.5rem;
    font-size: 0.75rem;
    max-width: 110px;
    text-overflow: ellipsis;
  }
}

/* Rainbow Color Picker Bar */
.color-picker-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: border-color var(--transition-speed), background-color var(--transition-speed);
}

.color-picker-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 2px;
  user-select: none;
  display: none;
}

@media (min-width: 640px) {
  .color-picker-label {
    display: inline-block;
  }
}

.color-dot-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  outline: none;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.color-dot-btn:hover {
  transform: scale(1.35);
  z-index: 2;
  box-shadow: 0 0 10px currentColor;
}

.color-dot-btn.active {
  transform: scale(1.22);
  border-color: var(--bg-surface);
  box-shadow: 0 0 0 2px currentColor, 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* 7 Rainbow Color Dots */
.color-dot-btn[data-color-val="red"] {
  background-color: #f43f5e;
  color: #f43f5e;
}
.color-dot-btn[data-color-val="orange"] {
  background-color: #f97316;
  color: #f97316;
}
.color-dot-btn[data-color-val="yellow"] {
  background-color: #f59e0b;
  color: #f59e0b;
}
.color-dot-btn[data-color-val="green"] {
  background-color: #10b981;
  color: #10b981;
}
.color-dot-btn[data-color-val="blue"] {
  background-color: #3b82f6;
  color: #3b82f6;
}
.color-dot-btn[data-color-val="indigo"] {
  background-color: #6366f1;
  color: #6366f1;
}
.color-dot-btn[data-color-val="purple"] {
  background-color: #a855f7;
  color: #a855f7;
}

/* Dark Mode Toggle */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.theme-toggle-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

/* Layout Wrapper */
.layout-container {
  display: flex;
  width: 100%;
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
}

/* Left Sidebar (LNB) */
.site-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform var(--transition-speed) ease, background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
  
  /* 스크롤 동작은 유지하고 스크롤바는 시각적으로 숨김 */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE, Edge */
}

.site-sidebar::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera, Webkit */
  width: 0;
  height: 0;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background-color: var(--bg-surface);
  z-index: 2;
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.2rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--text-muted);
  pointer-events: none;
}

.sidebar-nav {
  padding: 0.75rem 0.5rem 2rem 0.5rem;
  flex: 1;
}

/* Multi-level Accordion Menu */
.menu-group {
  margin-bottom: 0.5rem;
}

.menu-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s, color 0.15s;
  text-align: left;
}

.menu-group-header:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.menu-group-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.accordion-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.menu-group.open > .menu-group-header .accordion-arrow {
  transform: rotate(90deg);
}

.menu-sublist {
  display: none;
  padding-left: 0.75rem;
  margin-top: 0.2rem;
  border-left: 1px solid var(--border-color);
  margin-left: 0.75rem;
}

.menu-group.open > .menu-sublist {
  display: block;
}

.menu-item-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.75rem;
  font-size: 0.825rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  line-height: 1.4;
}

.menu-item-link:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.menu-item-link.active {
  background-color: var(--primary-light);
  color: var(--primary-text);
  font-weight: 600;
  border-left: 3px solid var(--primary-color);
}

.menu-item-badge {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  color: var(--text-muted);
}

/* Center Main Content */
.main-content {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: 2rem 3rem 4rem 3rem;
  display: flex;
  flex-direction: column;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb-item {
  color: var(--text-muted);
}

.breadcrumb-separator {
  color: var(--border-color);
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.article-body {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  min-height: 60vh;
  flex: 1;
}

/* Loading Spinner */
.loading-spinner-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-muted);
  gap: 1rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Bottom Document Pager (Prev/Next) */
.doc-pager {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 3rem auto 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.pager-btn {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease, transform 0.15s ease;
  max-width: 48%;
}

.pager-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--bg-hover);
  transform: translateY(-1px);
}

.pager-btn.pager-next {
  margin-left: auto;
  text-align: right;
}

.pager-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.pager-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Right TOC */
.site-toc {
  width: var(--toc-width);
  min-width: var(--toc-width);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  padding: 2rem 1rem 2rem 1.5rem;
  overflow-y: auto;
  border-left: 1px solid var(--border-subtle);
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
  
  /* 스크롤바 숨김 */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.site-toc::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.toc-wrapper {
  position: sticky;
  top: 1rem;
}

.toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
}

.toc-nav ul {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc-nav a {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  padding: 0.2rem 0;
  line-height: 1.4;
  transition: color 0.15s ease, transform 0.15s ease;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
}

.toc-nav a:hover {
  color: var(--primary-color);
}

.toc-nav a.active {
  color: var(--primary-color);
  font-weight: 600;
  border-left-color: var(--primary-color);
}

.toc-nav .toc-h3 {
  padding-left: 1.25rem;
  font-size: 0.75rem;
}

/* Footer */
.site-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
  transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.footer-content {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.footer-links a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

.footer-links .divider {
  color: var(--border-color);
}

.copyright {
  font-size: 0.775rem;
  color: var(--text-muted);
}

/* Backdrop for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* Dialog / Modal (Privacy & Terms) */
.legal-modal {
  margin: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  max-width: 680px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  padding: 0;
  outline: none;
}

.legal-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
  font-size: 0.9rem;
}

/* Mobile In-Article TOC (Visible only on < 1200px) */
.mobile-toc-container {
  display: none;
  margin-bottom: 2rem;
}

.mobile-toc-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-speed), background-color var(--transition-speed);
}

.mobile-toc-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background-color: var(--bg-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  outline: none;
}

.mobile-toc-header:hover {
  background-color: var(--bg-hover);
}

.mobile-toc-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-toc-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background-color: var(--primary-light);
  color: var(--primary-text);
}

.mobile-toc-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.mobile-toc-card.open .mobile-toc-arrow {
  transform: rotate(180deg);
}

.mobile-toc-body {
  display: none;
  padding: 0.75rem 1rem 1rem 1rem;
  border-top: 1px solid var(--border-subtle);
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: none;
}

.mobile-toc-body::-webkit-scrollbar {
  display: none;
}

.mobile-toc-card.open .mobile-toc-body {
  display: block;
}

.mobile-toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mobile-toc-item a {
  display: block;
  font-size: 0.825rem;
  color: var(--text-secondary);
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1.4;
  transition: all 0.15s ease;
}

.mobile-toc-item a:hover {
  background-color: var(--bg-hover);
  color: var(--primary-color);
}

.mobile-toc-item.toc-h3 {
  padding-left: 1rem;
  font-size: 0.775rem;
}

/* Sidebar Drawer Close Button (Mobile only) */
.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  color: var(--text-muted);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  line-height: 1;
}

.sidebar-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-hover);
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
  .site-toc {
    display: none;
  }
  .mobile-toc-container {
    display: block;
  }
  .main-content {
    padding: 2rem 2.5rem 4rem 2.5rem;
  }
}

@media (max-width: 868px) {
  .site-header {
    padding: 0 1rem;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    font-size: 1.15rem;
  }

  .brand-logo {
    font-size: 1rem;
    max-width: 160px;
  }

  .brand-logo span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-nav {
    display: none;
  }

  /* Drawer Sidebar */
  .site-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(320px, 85vw);
    min-width: unset;
    height: 100vh;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color var(--transition-speed);
    z-index: 1000;
  }

  .site-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .sidebar-close-btn {
    display: flex;
  }

  .main-content {
    padding: 1.5rem 1rem 3.5rem 1rem;
  }

  .color-picker-label {
    display: none;
  }

  .color-picker-bar {
    padding: 3px 6px;
    gap: 4px;
  }

  .color-dot-btn {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 540px) {
  .site-header {
    padding: 0 0.65rem;
  }

  .header-left {
    gap: 0.5rem;
  }

  .brand-badge {
    display: none;
  }

  .header-right {
    gap: 0.4rem;
  }

  .color-picker-bar {
    padding: 2px 4px;
    gap: 3px;
  }

  .color-dot-btn {
    width: 14px;
    height: 14px;
  }

  .theme-toggle-btn {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .mobile-menu-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .breadcrumb {
    font-size: 0.75rem;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }
  .breadcrumb::-webkit-scrollbar {
    display: none;
  }

  .doc-pager {
    flex-direction: column;
    gap: 0.75rem;
  }

  .pager-btn {
    max-width: 100%;
    width: 100%;
  }

  .pager-btn.pager-next {
    margin-left: 0;
    text-align: left;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
  }
}
