/* ── Reset & Base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0c0e12;
  --bg-surface: #141720;
  --bg-hover:   #1a1e28;
  --bg-card:    #171b24;
  --border:     #252a36;
  --border-dim: #1c2029;
  --text:       #c9cdd6;
  --text-dim:   #6b7280;
  --text-muted: #4a5060;
  --text-bright:#eef0f4;
  --accent:     #6ea1ff;

  /* branch colors */
  --branch-v42:      #58a6ff;
  --branch-v43:      #3fb950;
  --branch-v44:      #d2a8ff;
  --branch-v41:      #8b949e;
  --branch-hotfix:   #f0883e;

  --font-mono:  'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;
  --font-sans:  'DM Sans', system-ui, -apple-system, sans-serif;

  --rail-width:  2px;
  --node-size:   10px;
  --row-gap:     0px;
  --rail-spacing: 24px;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
}

/* ── Header ──────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 14, 18, 0.85);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--border-dim);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-glyph {
  color: var(--accent);
  font-size: 1.2rem;
}

.site-header h1 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.01em;
}

.header-thin {
  font-weight: 400;
  color: var(--text-dim);
}

.header-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.header-sep {
  margin: 0 6px;
  color: var(--text-muted);
}

.tag-count {
  color: var(--accent);
  font-weight: 600;
}

/* ── Toolbar ─────────────────────────────────────────── */
.toolbar {
  position: sticky;
  top: 53px;
  z-index: 99;
  background: rgba(12, 14, 18, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
}

.toolbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  transition: border-color 0.15s;
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-icon {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.search-box:focus-within .search-hint {
  display: none;
}

/* Branch filter chips */
.branch-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.branch-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.branch-chip:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.branch-chip.active {
  border-color: var(--chip-color, var(--accent));
  color: var(--chip-color, var(--accent));
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 10%, transparent);
}

/* ── Tree Container ──────────────────────────────────── */
.tree-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 60px 0;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

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

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

/* ── Tree Layout ─────────────────────────────────────── */
.tree-section {
  margin-top: 32px;
}

.tree-section-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border-dim);
  margin-bottom: 4px;
}

/* Rail area — the graph lines on the left */
.tree-row {
  display: grid;
  grid-template-columns: var(--rail-area-width, 80px) 1fr;
  min-height: 40px;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 4px;
}

.tree-row:hover {
  background: var(--bg-hover);
}

.tree-row.filtered-out {
  display: none;
}

.rail-area {
  position: relative;
  height: 100%;
}

/* Vertical rail lines */
.rail-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--rail-width);
  background: var(--rail-color, var(--border));
  opacity: 0.5;
}

.rail-line.active {
  opacity: 1;
}

/* Node dot */
.rail-node {
  position: absolute;
  top: 50%;
  width: var(--node-size);
  height: var(--node-size);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--node-color, var(--accent));
  border: 2px solid var(--bg);
  z-index: 2;
  box-shadow: 0 0 0 2px var(--node-color, var(--accent));
}

.rail-node.root-node {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* Branch connector — horizontal line from parent rail to child rail */
.rail-connector {
  position: absolute;
  top: 50%;
  height: var(--rail-width);
  background: var(--connector-color, var(--border));
  z-index: 1;
}

/* Fork connector — elbow line from main rail up to side branch */
.fork-connector {
  position: absolute;
  top: 0;
  height: 50%;
  border: none;
  pointer-events: none;
  z-index: 1;
}

/* ── Release Info (right side) ───────────────────────── */
.release-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 0;
  min-width: 0;
}

.release-tag {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--tag-color, var(--text-bright));
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
}

.release-date {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 80px;
}

.release-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.release-desc.bump-only {
  font-style: italic;
  color: var(--text-muted);
}

/* ── Dialog ──────────────────────────────────────────── */
dialog {
  background: none;
  border: none;
  padding: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

dialog[open] {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  cursor: pointer;
}

.dialog-panel {
  position: relative;
  z-index: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 12px 0 0 12px;
  width: 560px;
  max-width: 90vw;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 32px;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.dialog-tag {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-bright);
}

.dialog-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.dialog-close:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-muted);
}

.dialog-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.dialog-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.dialog-author {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

.dialog-author:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.dialog-parent {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border-dim);
}

.dialog-parent:empty { display: none; }

.dialog-areas {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.dialog-areas:empty { display: none; }

.area-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid;
  font-weight: 500;
}

.area-badge[data-area="Kiosk"]       { color: #f0883e; border-color: #f0883e40; background: #f0883e10; }
.area-badge[data-area="Hub"]         { color: #58a6ff; border-color: #58a6ff40; background: #58a6ff10; }
.area-badge[data-area="Standalone"]  { color: #d2a8ff; border-color: #d2a8ff40; background: #d2a8ff10; }
.area-badge[data-area="Console"]     { color: #3fb950; border-color: #3fb95040; background: #3fb95010; }
.area-badge[data-area="Payments"]    { color: #f778ba; border-color: #f778ba40; background: #f778ba10; }
.area-badge[data-area="Android"]     { color: #79c0ff; border-color: #79c0ff40; background: #79c0ff10; }
.area-badge[data-area="Libraries"]   { color: #ffa657; border-color: #ffa65740; background: #ffa65710; }
.area-badge[data-area="Workflows"]   { color: #56d364; border-color: #56d36440; background: #56d36410; }
.area-badge[data-area="Go Services"] { color: #8b949e; border-color: #8b949e40; background: #8b949e10; }
.area-badge[data-area="DevOps"]      { color: #8b949e; border-color: #8b949e40; background: #8b949e10; }
.area-badge[data-area="APIs"]        { color: #8b949e; border-color: #8b949e40; background: #8b949e10; }
.area-badge[data-area="Ingest"]      { color: #8b949e; border-color: #8b949e40; background: #8b949e10; }
.area-badge[data-area="Keeper"]      { color: #8b949e; border-color: #8b949e40; background: #8b949e10; }
.area-badge[data-area="Other"]       { color: #8b949e; border-color: #8b949e40; background: #8b949e10; }

.dialog-body {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.65;
}

.dialog-body h3 {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-bright);
  margin: 16px 0 6px;
}

.dialog-body h3:first-child { margin-top: 0; }

.dialog-body ul {
  padding-left: 20px;
  margin: 4px 0;
}

.dialog-body li {
  margin: 3px 0;
  color: var(--text-dim);
}

.dialog-body li::marker {
  color: var(--text-muted);
}

.dialog-body p {
  margin: 8px 0;
}

.dialog-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--accent);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .toolbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .release-info {
    flex-wrap: wrap;
    gap: 4px 12px;
  }

  .release-desc {
    flex-basis: 100%;
  }

  .dialog-panel {
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
  }

  .tree-row {
    grid-template-columns: var(--rail-area-width, 48px) 1fr;
  }
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Empty state ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
