/* ============================================================
   Figma @apple-style Layout — MkDocs-Material Adaptation
   Top ribbon, left bio sidebar, 4-col card gallery with tabs
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-secondary: #f5f5f5;
  --text: #1a1a1a;
  --text-muted: #6e6e6e;
  --text-light: #999999;
  --accent: #0d99ff;
  --accent-hover: #0b7fd6;
  --border: #e6e6e6;
  --card-bg: #f0f0f0;
  --card-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --sidebar-width: 280px;
  --ribbon-height: 56px;
  --transition: all .2s ease;
}

/* ─── Global ─── */
body,
[data-md-color-scheme="default"] {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  background-color: var(--bg) !important;
  color: var(--text);
}

[data-md-color-scheme="default"] {
  --md-primary-fg-color: #ffffff;
  --md-primary-fg-color--light: #f5f5f5;
  --md-primary-fg-color--dark: #e0e0e0;
  --md-accent-fg-color: var(--accent);
  --md-default-bg-color: var(--bg);
}

/* ─── Hide default MkDocs chrome on homepage ─── */
.homepage-layout .md-sidebar--primary,
.homepage-layout .md-sidebar--secondary,
.homepage-layout .md-header,
.homepage-layout .md-tabs {
  display: none !important;
}
.homepage-layout .md-content {
  max-width: 100% !important;
  margin: 0 !important;
}
.homepage-layout .md-main__inner {
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* ============================================================
   TOP RIBBON
   ============================================================ */
.top-ribbon {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--ribbon-height);
  padding: 0 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.ribbon-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ribbon-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--text);
}

.ribbon-site-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.ribbon-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ribbon-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.ribbon-search:hover {
  border-color: var(--text-light);
}
.ribbon-search svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
}

/* ============================================================
   MAIN WRAPPER (sidebar + gallery)
   ============================================================ */
.stack-wrapper {
  display: flex;
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: calc(100vh - var(--ribbon-height));
}

/* ============================================================
   LEFT SIDEBAR
   ============================================================ */
.stack-sidebar-left {
  position: sticky;
  top: var(--ribbon-height);
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  flex-shrink: 0;
  align-self: flex-start;
  height: calc(100vh - var(--ribbon-height));
  overflow-y: auto;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Biography Pane ── */
.bio-pane {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.bio-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 14px;
  border: 3px solid var(--text);
}

.bio-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--text);
  line-height: 1.2;
}

.bio-handle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.bio-follow-btn {
  display: inline-block;
  padding: 6px 20px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 14px;
}
.bio-follow-btn:hover {
  background: var(--accent-hover);
}

.bio-text {
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 6px;
}

.bio-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.bio-link:hover {
  text-decoration: underline;
}

.bio-followers {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin: 8px 0 0;
}
.bio-followers strong {
  color: var(--text);
}

/* ── Pane Headings ── */
.pane-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding: 0;
}

/* ── Tag Emoji Pane ── */
.tag-emoji-pane {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tag-list li {
  margin: 0;
}

.tag-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.tag-list a:hover {
  background: var(--bg-secondary);
}
.tag-list a.active {
  background: var(--accent);
  color: #fff;
}

.tag-emoji {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.tag-count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-light);
  background: var(--bg-secondary);
  padding: 1px 7px;
  border-radius: 10px;
  transition: var(--transition);
}
.tag-list a.active .tag-count {
  background: rgba(255,255,255,.25);
  color: #fff;
}

/* ── Knowledge Graph Pane (force-graph) ── */
.graph-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
}

#tag-graph {
  width: 100%;
  height: 280px;
  background: #1a1a2e;
  border-radius: 10px;
  overflow: hidden;
  flex: 1;
  min-height: 220px;
}

/* force-graph injects a canvas — ensure it fills the container */
#tag-graph canvas {
  border-radius: 10px;
}

/* Hide the default force-graph tooltip label bar */
#tag-graph .graph-tooltip {
  background: rgba(26, 26, 46, 0.92) !important;
  color: #e0e0e0 !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  border-radius: 6px !important;
  padding: 4px 10px !important;
  font-size: 0.75rem !important;
  font-family: 'Inter', sans-serif !important;
  pointer-events: none;
}

/* ============================================================
   CARD GALLERY SECTION
   ============================================================ */
.stack-gallery {
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
}

/* ── Gallery Navigation Tabs ── */
.gallery-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.gallery-tab {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.gallery-tab:hover {
  color: var(--text);
}
.gallery-tab.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--text);
}

/* ── Card Grid — 4 columns ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.card-grid .article-card {
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.card-grid .article-card:hover {
  transform: translateY(-3px);
}

.card-grid .article-card a {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ── Card Image with Label Strip ── */
.card-grid .article-card .card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--card-radius);
  overflow: hidden;
  position: relative;
  background: var(--card-bg);
}

.card-grid .article-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.card-grid .article-card:hover .card-image img {
  transform: scale(1.04);
}

/* Label strip at bottom of card image */
.card-label-strip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.45));
}

.card-label-tag {
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-label-year {
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255,255,255,.8);
}

/* ── Card Body (below image) ── */
.card-grid .article-card .card-body {
  padding: 10px 2px 0;
}

.card-grid .article-card .card-title {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0 0 3px;
  color: var(--text);
  line-height: 1.3;
}

.card-grid .article-card .card-byline {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

/* Hidden state for filtered-out cards */
.card-grid .article-card.hidden {
  display: none;
}

/* No results */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  display: none;
}
.no-results.visible {
  display: block;
}

/* ============================================================
   ARTICLE PAGES (non-homepage)
   ============================================================ */
.md-header {
  background: var(--bg) !important;
  box-shadow: none;
  border-bottom: 1px solid var(--border);
  color: var(--text) !important;
}
.md-header__title {
  color: var(--text) !important;
  font-weight: 600;
}
.md-header .md-icon,
.md-header .md-search__icon,
.md-header__button {
  color: var(--text) !important;
}

.md-content__inner {
  max-width: 860px;
  margin: 0 auto;
}
.md-typeset h1 {
  font-weight: 700;
  font-size: 2rem;
  color: var(--text);
}
.md-typeset img {
  border-radius: 8px;
}
.md-typeset .md-tag {
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1400px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1050px) {
  .stack-sidebar-left {
    width: 240px;
    min-width: 240px;
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 800px) {
  .stack-wrapper {
    flex-direction: column;
  }
  .stack-sidebar-left {
    position: static;
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 20px 16px;
  }
  .stack-gallery {
    padding: 16px;
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

@media (max-width: 500px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .top-ribbon {
    padding: 0 12px;
  }
  .gallery-tabs {
    overflow-x: auto;
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-grid .article-card {
  animation: fadeUp .35s ease backwards;
}
.card-grid .article-card:nth-child(1) { animation-delay: 0s; }
.card-grid .article-card:nth-child(2) { animation-delay: .04s; }
.card-grid .article-card:nth-child(3) { animation-delay: .08s; }
.card-grid .article-card:nth-child(4) { animation-delay: .12s; }
.card-grid .article-card:nth-child(5) { animation-delay: .16s; }
.card-grid .article-card:nth-child(6) { animation-delay: .20s; }
.card-grid .article-card:nth-child(7) { animation-delay: .24s; }
.card-grid .article-card:nth-child(8) { animation-delay: .28s; }
