/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #0a0a14;
  color: #d0d0d0;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  padding: 1rem 2rem 0.75rem;
  flex-shrink: 0;
  border-bottom: 1px solid #1e1e2e;
}

header h1 {
  margin: 0 0 0.15rem;
  font-size: 1.6rem;
  color: #ffffff;
}

.subtitle {
  margin: 0;
  color: #666;
  font-size: 0.88rem;
}

/* ── Main layout ── */
#main-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#graph-canvas {
  width: 100%;
  height: 100%;
  background: #0a0a14;
}

/* ── Color legend (fixed overlay, bottom-left) ── */
#legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 18px;
  background: rgba(8, 8, 18, 0.82);
  border: 1px solid #2a2a40;
  border-radius: 7px;
  padding: 10px 14px;
  pointer-events: none;
  z-index: 5;
  backdrop-filter: blur(4px);
}

.legend-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.legend-heading {
  font-size: 0.68rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #aaa;
  white-space: nowrap;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex-shrink: 0;
}

.swatch.circle {
  border-radius: 50%;
}

.swatch.diamond {
  transform: rotate(45deg);
  border-radius: 1px;
}

/* ── Detail panel (overlay from right) ── */
#detail-panel {
  position: absolute;
  top: 0;
  right: -440px;
  width: 420px;
  height: 100%;
  overflow: hidden;
  transition: right 0.28s ease;
  background: #141428;
  border-left: 2px solid #2a2a50;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

#detail-panel.open {
  right: 0;
}

#panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.25rem 0.75rem;
  border-bottom: 1px solid #2a2a50;
  flex-shrink: 0;
}

#panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#panel-close {
  background: none;
  border: none;
  color: #666;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

#panel-close:hover { color: #ccc; }

#panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 1.25rem;
}

.panel-detail { }

.panel-detail .github-link {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.private-note {
  font-size: 0.85rem;
  color: #666;
  margin: 0.75rem 0 0;
  font-style: italic;
}

.domain-tag {
  margin-bottom: 0.75rem;
}

/* ── Card ── */
.card {
  background: #252525;
  border: 1px solid #333;
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: #555;
}

.card-face {
  padding: 1.25rem 1.25rem 1rem;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.card-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.github-link {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: #7ab3f5;
  text-decoration: none;
  border: 1px solid #3a5a8a;
  border-radius: 4px;
  padding: 2px 8px;
  white-space: nowrap;
  transition: background 0.15s;
}

.github-link:hover {
  background: #2a3f5a;
  color: #a5d6ff;
}

/* ── Inline README images ── */
.readme-figure {
  margin: 1rem 0;
  text-align: center;
}

.readme-inline-img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid #2a2a2a;
  display: block;
  margin: 0 auto;
  transition: border-color 0.15s, opacity 0.15s;
}

.readme-figure a:hover .readme-inline-img {
  border-color: #555;
  opacity: 0.9;
}

.readme-figure figcaption {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.35rem;
  font-style: italic;
}

/* ── Curated gallery (bottom of readme, for repos without inline images) ── */
.readme-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #2a2a2a;
}

.readme-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #333;
  display: block;
  transition: border-color 0.15s, opacity 0.15s;
}

.readme-gallery a:hover .readme-img {
  border-color: #666;
  opacity: 0.9;
}

.card-desc {
  font-size: 0.88rem;
  color: #b0b0b0;
  margin: 0 0 0.75rem;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Tech pills ── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: #1e3a2f;
  color: #6fcf97;
  border: 1px solid #2a5a3f;
  white-space: nowrap;
}

/* ── Expand toggle ── */
.expand-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.expand-btn:hover { color: #ccc; }

.expand-btn .arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 0.7rem;
}

.card.open .expand-btn .arrow {
  transform: rotate(90deg);
}

/* ── Expanded body ── */
.card-body {
  display: none;
  border-top: 1px solid #333;
}

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

/* ── README section ── */
.readme-section {
  padding: 1.25rem;
  border-bottom: 1px solid #2a2a2a;
  font-size: 0.85rem;
  color: #c0c0c0;
  overflow: hidden;
}

.readme-section h1 { display: none; } /* hide the title — already shown on card */

.readme-section h2 {
  font-size: 0.9rem;
  color: #aaa;
  margin: 1rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.readme-section h3, .readme-section h4 {
  font-size: 0.85rem;
  color: #bbb;
  margin: 0.75rem 0 0.2rem;
}

.readme-section p { margin: 0.4rem 0; }

.readme-section a {
  color: #7ab3f5;
  text-decoration: none;
}

.readme-section a:hover { text-decoration: underline; }

.readme-section code {
  background: #1a1a1a;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.82rem;
  color: #e0c06a;
}

.readme-section pre {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 5px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

.readme-section pre code {
  background: none;
  padding: 0;
}

/* ── File tree section ── */
.tree-section {
  padding: 1rem 1.25rem;
}

.tree-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 0.5rem;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.2em;
}

.tree > ul {
  padding-left: 0;
}

.tree li {
  padding: 1px 0;
  font-size: 0.82rem;
}

.tree .dir-label {
  cursor: pointer;
  color: #bbb;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tree .dir-label:hover { color: #fff; }

.tree .dir-label .tri {
  display: inline-block;
  font-size: 0.6rem;
  transition: transform 0.15s;
  color: #666;
}

.tree .dir-label.open .tri {
  transform: rotate(90deg);
}

.tree .dir-children {
  display: none;
}

.tree .dir-children.open {
  display: block;
}

.tree a {
  color: #7ab3f5;
  text-decoration: none;
  font-family: 'Courier New', monospace;
}

.tree a:hover {
  color: #a5d6ff;
  text-decoration: underline;
}
