/* ============================================
   Learn Section — Directus-inspired docs layout
   Article layout, sticky ToC, prose, callouts,
   screenshot placeholders, tables, hub page
   ============================================ */

/* ---- Reading Progress Bar ---- */
.reading-progress {
  position: fixed;
  top: 64px;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: var(--z-sticky);
  pointer-events: none;
}

.reading-progress__bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 50ms linear;
}

/* ---- Article Header (inline, inside content column) ---- */
.article-header {
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-6);
  border-bottom: var(--border);
}

.article-header__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--gray-400);
}

.article-header__breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.article-header__breadcrumb a:hover {
  text-decoration: underline;
}

.article-header__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.article-header__subtitle {
  font-size: var(--text-base);
  color: var(--gray-500);
  margin-bottom: var(--space-4);
  line-height: var(--leading-relaxed);
}

.article-header__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--gray-400);
}

.article-header__reading-time {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.article-header__level {
  display: inline-flex;
  align-items: center;
  background: var(--success-light);
  color: var(--success);
  font-weight: 600;
  padding: 0.125rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
}

/* ---- Learn Hub Header (inline, inside hub section) ---- */
.learn-hub__header {
  margin-bottom: var(--space-8);
}

.learn-hub__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.learn-hub__subtitle {
  font-size: var(--text-base);
  color: var(--gray-500);
  max-width: 560px;
  line-height: var(--leading-relaxed);
}

/* ---- Article Layout (2-column: sidebar + content) ---- */
.article-layout {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.article-layout__inner {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-12);
  align-items: start;
  padding: calc(var(--space-10) + 64px) 0 var(--space-16);
}

/* ---- Table of Contents Sidebar ---- */
.article-toc {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}

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

.article-toc::-webkit-scrollbar-thumb {
  background: var(--gray-200);
  border-radius: var(--radius-full);
}

.article-toc__heading {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: var(--space-4);
}

.article-toc nav {
  display: flex;
  flex-direction: column;
}

.article-toc__link {
  display: block;
  padding: 5px 0 5px var(--space-3);
  font-size: 0.8125rem;
  color: var(--gray-500);
  text-decoration: none;
  border-left: 2px solid var(--gray-200);
  transition: all var(--transition-fast);
  line-height: 1.5;
}

.article-toc__link:hover {
  color: var(--gray-800);
  border-left-color: var(--gray-400);
}

.article-toc__link.is-active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* ---- Mobile ToC (collapsible bar below hero) ---- */
.article-toc-mobile {
  display: none;
  border-bottom: var(--border);
  background: var(--white);
  position: sticky;
  top: 64px;
  z-index: var(--z-dropdown);
}

.article-toc-mobile__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-3) var(--container-padding);
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
}

.article-toc-mobile__toggle svg {
  color: var(--gray-400);
  transition: transform var(--transition-fast);
}

.article-toc-mobile__toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.article-toc-mobile__list {
  padding: 0 var(--container-padding) var(--space-4);
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.article-toc-mobile__link {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--gray-500);
  text-decoration: none;
  border-left: 2px solid var(--gray-200);
}

.article-toc-mobile__link:hover {
  color: var(--gray-800);
}

.article-toc-mobile__link.is-active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* ---- Article Prose Content ---- */
.article-content {
  max-width: 740px;
  min-width: 0;
}

.article-content section {
  margin-bottom: var(--space-12);
  scroll-margin-top: 90px;
}

.article-content h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-4);
  padding-top: var(--space-4);
  border-top: var(--border);
  line-height: var(--leading-tight);
}

.article-content section:first-child h2 {
  border-top: none;
  padding-top: 0;
}

.article-content h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gray-800);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  line-height: var(--leading-tight);
}

.article-content h4 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--gray-800);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

.article-content p {
  margin-bottom: var(--space-4);
  color: var(--gray-700);
  line-height: var(--leading-relaxed);
}

.article-content ul,
.article-content ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
  color: var(--gray-700);
}

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

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

.article-content li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-relaxed);
}

.article-content li ul,
.article-content li ol {
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

.article-content strong {
  font-weight: 600;
  color: var(--gray-900);
}

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

.article-content code {
  background: var(--gray-100);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
  font-size: 0.875em;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  color: var(--primary-dark);
}

.article-content pre {
  background: var(--gray-900);
  color: var(--gray-100);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.article-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
}

.article-content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-content a:hover {
  color: var(--primary-dark);
}

/* ---- Callout Boxes ---- */
.callout {
  border-left: 4px solid var(--gray-300);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
  background: var(--gray-50);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--gray-700);
}

.callout p {
  margin-bottom: var(--space-2);
}

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

.callout ul,
.callout ol {
  margin-bottom: var(--space-2);
  padding-left: var(--space-5);
}

.callout ul:last-child,
.callout ol:last-child {
  margin-bottom: 0;
}

.callout strong {
  color: var(--gray-900);
}

.callout--insight {
  border-left-color: var(--primary);
  background: var(--primary-light);
}

.callout--tip {
  border-left-color: var(--warning);
  background: var(--warning-light);
}

.callout--in-app {
  border-left-color: var(--secondary);
  background: var(--secondary-light);
}

/* ---- In-App Navigation Path Badge ---- */
.app-path {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  background: var(--white);
  padding: 0.2em 0.6em;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  border: 1px solid rgba(101, 68, 247, 0.2);
  white-space: nowrap;
  font-family: var(--font-body);
}

/* ---- Screenshot Placeholders ---- */
.screenshot-placeholder {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  background: var(--gray-50);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  margin: var(--space-6) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.screenshot-placeholder svg {
  color: var(--gray-300);
  flex-shrink: 0;
}

.screenshot-placeholder span {
  font-size: var(--text-sm);
  color: var(--gray-400);
  max-width: 400px;
  line-height: var(--leading-normal);
}

/* ---- Article Tables ---- */
.article-table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--space-5);
  border-radius: var(--radius-lg);
  border: var(--border);
}

.article-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.article-table thead {
  background: var(--gray-50);
}

.article-table th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-600);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.article-table td {
  padding: var(--space-3) var(--space-4);
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  line-height: var(--leading-normal);
  vertical-align: top;
}

.article-table tbody tr:hover {
  background: var(--gray-50);
}

.article-table tbody tr:last-child td {
  border-bottom: none;
}

/* ---- Mid-Article CTA ---- */
.article-cta {
  text-align: center;
  padding: var(--space-10);
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-light) 100%);
  border-radius: var(--radius-xl);
  margin: var(--space-12) 0;
}

.article-cta h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.article-cta p {
  color: var(--gray-600);
  margin-bottom: var(--space-5);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Bottom Article CTA ---- */
.article-bottom-cta {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  background: var(--gray-900);
  border-radius: var(--radius-xl);
  margin-top: var(--space-12);
}

.article-bottom-cta h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--white);
  margin-bottom: var(--space-3);
  border-top: none !important;
  padding-top: 0 !important;
}

.article-bottom-cta p {
  color: var(--gray-400);
  max-width: 520px;
  margin: 0 auto var(--space-6);
  line-height: var(--leading-relaxed);
}

.article-bottom-cta__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ---- Learn Hub Page ---- */
.learn-hub {
  padding: calc(var(--space-10) + 64px) 0 var(--space-16);
}

.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-6);
}

.learn-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-base);
}

a.learn-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.learn-card--coming-soon {
  opacity: 0.55;
  cursor: default;
}

.learn-card--coming-soon:hover {
  border-color: var(--border-color);
  box-shadow: none;
  transform: none;
}

.learn-card__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: var(--space-4);
}

.learn-card__icon svg {
  width: 24px;
  height: 24px;
}

.learn-card__category {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
  width: fit-content;
}

.learn-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: var(--space-2);
  line-height: var(--leading-tight);
}

.learn-card__excerpt {
  font-size: var(--text-sm);
  color: var(--gray-500);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
  flex: 1;
}

.learn-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--gray-400);
  padding-top: var(--space-3);
  border-top: var(--border);
}

.learn-card__reading-time,
.learn-card__level {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.learn-card__level {
  background: var(--success-light);
  color: var(--success);
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full);
}

/* ---- Active Nav Link ---- */
.navbar__link--active {
  color: var(--primary);
}

/* ---- Responsive: Tablet ---- */
@media (max-width: 1024px) {
  .article-layout__inner {
    grid-template-columns: 200px 1fr;
    gap: var(--space-8);
  }
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 768px) {
  .article-layout__inner {
    grid-template-columns: 1fr;
    padding-top: 0;
  }

  .article-toc {
    display: none;
  }

  .article-toc-mobile {
    display: block;
  }

  .article-content h2 {
    font-size: var(--text-xl);
  }

  .article-content h3 {
    font-size: var(--text-lg);
  }

  .learn-grid {
    grid-template-columns: 1fr;
  }

  .article-cta {
    padding: var(--space-6);
  }

  .article-bottom-cta {
    padding: var(--space-8) var(--space-5);
    border-radius: var(--radius-lg);
  }

  .article-bottom-cta__actions {
    flex-direction: column;
  }

  .reading-progress {
    top: 56px;
  }
}

@media (max-width: 480px) {
  .article-table-wrapper {
    margin-left: calc(-1 * var(--container-padding));
    margin-right: calc(-1 * var(--container-padding));
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
