/* ============================================================
   BYBEIT SUPPORT — Article Page Styles
   Mirrors Apple Developer documentation styling
   ============================================================ */

/* ── Page Layout ──────────────────────────────────────────── */
.article-page {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.article-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  max-width: var(--content-wide);
  margin: 0 auto;
  width: 100%;
  min-height: calc(100vh - var(--nav-height));
  align-items: start;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 32px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  background-color: var(--bg);
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border-radius: 2px;
}

/* Sidebar search */
.sidebar__search {
  padding: 0 16px 20px;
}

.sidebar__search-input {
  width: 100%;
  height: 34px;
  padding: 0 10px 0 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--duration-base) var(--ease),
              box-shadow var(--duration-base) var(--ease);
}

.sidebar__search-input:focus {
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.15);
}

.sidebar__search-wrap {
  position: relative;
}

.sidebar__search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  display: flex;
}

.sidebar__search-icon ion-icon {
  font-size: 14px;
}

/* Sidebar navigation */
.sidebar__nav {
  padding: 0;
}

.sidebar__group {
  margin-bottom: 4px;
}

.sidebar__group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
  cursor: pointer;
  user-select: none;
  transition: color var(--duration-fast) var(--ease);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.sidebar__group-title:hover {
  color: var(--link);
}

.sidebar__group-chevron {
  color: var(--text-tertiary);
  transition: transform var(--duration-base) var(--ease);
  flex-shrink: 0;
}

.sidebar__group-chevron ion-icon {
  font-size: 14px;
}

.sidebar__group.is-open .sidebar__group-chevron {
  transform: rotate(90deg);
}

.sidebar__group-items {
  display: none;
  padding-bottom: 4px;
}

.sidebar__group.is-open .sidebar__group-items {
  display: block;
}

.sidebar__group-items a {
  display: block;
  padding: 7px 16px 7px 26px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.4;
  border-radius: var(--radius-xs);
  transition: color var(--duration-fast) var(--ease),
              background-color var(--duration-fast) var(--ease);
}

.sidebar__group-items a:hover {
  color: var(--link);
  background-color: var(--bg-hover);
}

.sidebar__group-items a.is-active {
  color: var(--link);
  font-weight: 500;
  background-color: rgba(0, 113, 227, 0.07);
}

/* TOC in sidebar (when on article page) */
.sidebar__toc {
  padding: 20px 16px 0;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.sidebar__toc-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.sidebar__toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__toc-list a {
  display: block;
  padding: 5px 16px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-xs);
  line-height: 1.4;
  transition: color var(--duration-fast) var(--ease),
              background-color var(--duration-fast) var(--ease);
}

.sidebar__toc-list a:hover {
  color: var(--link);
  background-color: var(--bg-hover);
}

.sidebar__toc-list a.is-active {
  color: var(--link);
  font-weight: 500;
  background-color: rgba(0, 113, 227, 0.07);
}

.sidebar__toc-list li.is-h3 a {
  padding-left: 22px;
  font-size: var(--text-xs);
}

/* ── Article Content Area ─────────────────────────────────── */
.article-content-wrap {
  padding: 40px 40px 80px 56px;
  min-width: 0;
  max-width: 800px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 28px;
  list-style: none;
}

.breadcrumb li {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.breadcrumb li a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

.breadcrumb li a:hover {
  color: var(--link);
}

.breadcrumb li:last-child {
  color: var(--text-tertiary);
}

.breadcrumb__sep {
  color: var(--text-tertiary);
  font-size: 11px;
}

/* Category label above title */
.article-category-label {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 10px;
  letter-spacing: 0.1px;
}

/* Article header */
.article-header__title {
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.article-header__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.article-header {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}

.article-header__date {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* ── Article Body Typography ──────────────────────────────── */
.article-body {
  font-size: var(--text-md);
  line-height: 1.7;
  color: var(--text-primary);
}

.article-body p {
  margin-bottom: 20px;
}

.article-body p:last-child {
  margin-bottom: 0;
}

.article-body h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 48px 0 16px;
  padding-top: 8px;
}

.article-body h2:first-child {
  margin-top: 0;
}

.article-body h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.3px;
  line-height: 1.3;
  color: var(--text-primary);
  margin: 32px 0 12px;
}

.article-body h4 {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 8px;
}

/* Ordered & unordered lists */
.article-body ol,
.article-body ul {
  margin: 0 0 20px 0;
  padding-left: 28px;
}

.article-body ol li,
.article-body ul li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.article-body ol li:last-child,
.article-body ul li:last-child {
  margin-bottom: 0;
}

.article-body ul {
  list-style-type: disc;
}

.article-body ol {
  list-style-type: decimal;
}

/* Nested lists */
.article-body ol ol,
.article-body ul ul,
.article-body ol ul,
.article-body ul ol {
  margin-top: 8px;
  margin-bottom: 0;
}

/* Strong / em */
.article-body strong {
  font-weight: 600;
  color: var(--text-primary);
}

.article-body em {
  font-style: italic;
}

/* Inline code */
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background-color: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

/* Callout blocks */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  margin: 28px 0;
  font-size: var(--text-base);
  line-height: 1.6;
}

.callout--note {
  background-color: rgba(0, 113, 227, 0.06);
  border: 1px solid rgba(0, 113, 227, 0.2);
}

.callout--important {
  background-color: rgba(255, 149, 0, 0.06);
  border: 1px solid rgba(255, 149, 0, 0.25);
}

.callout--tip {
  background-color: rgba(3, 255, 0, 0.05);
  border: 1px solid rgba(3, 255, 0, 0.2);
}

.callout--warning {
  background-color: rgba(255, 59, 48, 0.05);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.callout__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  display: flex;
  align-items: flex-start;
}

.callout__icon ion-icon {
  font-size: 18px;
}

.callout--note .callout__icon { color: var(--link); }
.callout--important .callout__icon { color: #ff9500; }
.callout--tip .callout__icon { color: var(--brand-dark); }
.callout--warning .callout__icon { color: #ff3b30; }

.callout__body {
  flex: 1;
  min-width: 0;
}

.callout__label {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 4px;
}

.callout--note .callout__label { color: var(--link); }
.callout--important .callout__label { color: #d47500; }
.callout--tip .callout__label { color: var(--brand-dark); }
.callout--warning .callout__label { color: #ff3b30; }

.callout__body p {
  margin-bottom: 0;
  color: var(--text-primary);
}

/* Step list (numbered instruction steps) */
.step-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.step-list__item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.step-list__item:first-child {
  padding-top: 0;
}

.step-list__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.step-list__num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--link);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  margin-top: 1px;
}

.step-list__content {
  flex: 1;
  min-width: 0;
  font-size: var(--text-md);
  line-height: 1.6;
  color: var(--text-primary);
}

.step-list__content strong {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

/* Horizontal rule */
.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ── Article Feedback Bar ─────────────────────────────────── */
.article-feedback {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 0 0;
  margin-top: 48px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.article-feedback__label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-right: 4px;
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background-color: var(--bg-secondary);
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
}

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

.feedback-btn ion-icon {
  font-size: 16px;
}

.feedback-btn.is-active {
  background-color: var(--brand-subtle);
  border-color: var(--brand);
  color: var(--brand-dark);
}

/* ── Article Bottom Actions ───────────────────────────────── */
.article-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.article-action-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-align: center;
  background-color: var(--bg-card);
  transition: color var(--duration-base) var(--ease);
  line-height: 1.4;
}

.article-action-link:hover {
  color: var(--link);
}

.article-action-link ion-icon {
  font-size: 24px;
  color: var(--text-tertiary);
  transition: color var(--duration-base) var(--ease);
  flex-shrink: 0;
}

.article-action-link:hover ion-icon {
  color: var(--link);
}

/* ── Mobile TOC inline dropdown ──────────────────────────── */
.mobile-toc-dropdown {
  display: none;
}

@media (max-width: 900px) {
  .mobile-toc-dropdown {
    display: block;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 8px 6px;
    margin-bottom: 4px;
  }

  .mobile-toc-dropdown[hidden] {
    display: none;
  }

  .mobile-toc-dropdown .sidebar__toc-list a {
    border-radius: var(--radius-full);
    padding: 9px 16px;
    font-size: var(--text-base);
  }
}

/* ── Mobile sidebar toggle ────────────────────────────────── */
.sidebar-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  margin: 16px 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  width: 100%;
}

.sidebar-toggle ion-icon {
  font-size: 18px;
  color: var(--text-secondary);
}

.sidebar-toggle__chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform var(--duration-base) var(--ease);
}

.sidebar-toggle__chevron ion-icon {
  font-size: 16px;
}

.sidebar-toggle.is-open .sidebar-toggle__chevron {
  transform: rotate(180deg);
}

/* ── Loading / Error states ───────────────────────────────── */
.article-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  color: var(--text-secondary);
  gap: 16px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.article-error {
  padding: 60px 40px;
  text-align: center;
}

.article-error h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.article-error p {
  font-size: var(--text-md);
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  background-color: var(--link);
  color: #ffffff;
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease);
}

.btn-primary:hover {
  background-color: var(--link-hover);
  color: #ffffff;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .article-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    border-right: none;
    display: none;
    padding: 16px 0 20px;
  }

  .sidebar.is-open {
    display: block;
  }

  .sidebar-toggle {
    display: flex;
  }

  .sidebar__toc-list a {
    border-radius: var(--radius-full);
    padding: 7px 16px;
  }

  .sidebar__toc-list li.is-h3 a {
    padding-left: 28px;
  }

  .article-content-wrap {
    padding: 32px 22px 60px;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .article-header__title {
    font-size: var(--text-2xl);
    letter-spacing: -0.6px;
  }

  .article-feedback {
    flex-wrap: wrap;
  }

  .article-feedback__label {
    width: 100%;
    margin-right: 0;
  }

  .article-feedback .feedback-btn {
    flex: 1;
    justify-content: center;
  }

  .article-body h2 {
    font-size: var(--text-xl);
    margin: 36px 0 14px;
  }

  .article-body {
    font-size: var(--text-base);
  }

  .article-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .article-action-link {
    flex-direction: row;
    padding: 14px 16px;
    text-align: left;
    gap: 12px;
  }
}
