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

/* ---------- Theme tokens ---------- */
:root {
  --bg: #f5f4f1;
  --bg-elevated: #ffffff;
  --border: #e1ddd4;
  --text: #1c1b19;
  --text-dim: #6b6660;
  --accent: #9c6b1f;
  --shadow: 0 8px 24px rgba(60, 55, 45, 0.12);
  --font-mono: 'IBM Plex Mono', ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13151a;
    --bg-elevated: #1b1e26;
    --border: #2b2f3a;
    --text: #edeef0;
    --text-dim: #8b909c;
    --accent: #e0ab52;
    --shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #13151a;
  --bg-elevated: #1b1e26;
  --border: #2b2f3a;
  --text: #edeef0;
  --text-dim: #8b909c;
  --accent: #e0ab52;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }

/* ---------- Hero & Header ---------- */
.simple-header {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 8px;
  text-align: center;
}
.heading-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 24px;
}
.simple-header h1 {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 6vw + 0.9rem, 2.6rem);
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
  min-height: 1.2em;
}
.simple-header h1::before {
  content: "$ ";
  color: var(--accent);
}
.cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
  color: var(--accent);
  font-weight: 700;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.header-divider {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 0 0 24px 0;
}
.header-links .cta-row {
  justify-content: center;
  margin-bottom: 24px;
}
.view-switch {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}
.view-switch-track {
  position: relative;
  flex-shrink: 0;
  width: 34px;
  height: 20px;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s ease;
}
.view-switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--bg-elevated);
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.view-switch[aria-checked="true"] .view-switch-track { background: var(--accent); }
.view-switch[aria-checked="true"] .view-switch-knob { transform: translateX(14px); }
.view-switch:hover .view-switch-label { color: var(--text); }

/* ---------- Simple view ---------- */
.simple-view {
  max-width: 700px;
  margin: 0 auto;
  padding: 8px 20px 48px;
}
.simple-lead {
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0 0 28px;
}
.simple-section { margin: 0 0 32px; }
.simple-heading {
  font-size: 13px;
  color: var(--accent);
  margin: 0 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.simple-item { margin: 0 0 20px; }
.simple-item-title { font-size: 16px; margin: 0 0 4px; }
.simple-item-meta { color: var(--text-dim); font-size: 12px; margin: 0 0 8px; }
.simple-item-body { font-size: 14px; line-height: 1.6; margin: 0 0 6px; }
.simple-item-link { display: inline-block; font-size: 13px; margin-top: 4px; }
.simple-item .chip-row { margin-top: 8px; }

/* ---------- Graph ---------- */
.graph-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 20px 48px;
}


.main-graph { display: flex; }

.rail-col { position: relative; flex-shrink: 0; }
.connector-svg { position: absolute; top: 0; left: 0; }
.connector-line { stroke-width: 2; fill: none; }
.rail-dot--merge { fill: var(--bg); stroke: var(--text-dim); stroke-width: 2; }

/* hovering (or jumping to) a commit rings the one dot it belongs to */
.rail-dot.rail-hl-exact { stroke: var(--text); stroke-width: 3; }

.log-lines { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.log-row { display: flex; align-items: center; overflow: hidden; }

.log-line {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 3px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.log-line:hover { background: var(--bg-elevated); }
.log-line:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.log-line--merge { cursor: default; color: var(--text-dim); font-style: italic; opacity: 0.5; }
.log-line--merge:hover { background: transparent; }
.log-line--active {
  background: var(--bg-elevated);
  border-left: 3px solid var(--branch-color);
  padding-left: 5px; /* adjust for border */
}
.log-line--active .log-text strong {
  color: var(--branch-color);
}
.log-line--head .log-text,
.log-line--intro .log-text { color: var(--text); font-weight: 600; }

.rail-dot-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: pulse-ring 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.6; stroke-width: 1.5px; }
  100% { transform: scale(2.2); opacity: 0; stroke-width: 0.5px; }
}

.log-text {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
}
.log-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-meta {
  flex-shrink: 0;
  color: var(--text-dim);
  font-weight: 400;
  opacity: 0.7;
}
.merge-icon { flex-shrink: 0; opacity: 0.4; }

.branch-name-subtle {
  flex-shrink: 0;
  width: 100px;
  color: var(--text-dim);
  opacity: 0.7;
  font-size: 11px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
}
.branch-name-subtle--head {
  color: var(--accent);
  opacity: 1;
  font-weight: 600;
}
.branch-name-subtle::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--branch-color, var(--text-dim));
  margin-right: 6px;
}
.log-line--merge .branch-name-subtle::before {
  display: none;
}



.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  color: var(--text-dim);
}

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.cta-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.cta-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ---------- Footer ---------- */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 15;
}
.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 6px 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal-backdrop:not([hidden]) { display: flex; }
.modal-backdrop.open { opacity: 1; }
body.modal-open { overflow: hidden; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow);
  transform: translateY(8px);
  transition: transform 0.18s ease;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-heading { min-width: 0; flex: 1; }
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.modal-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
}
.modal-branch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--branch-color, var(--accent));
}
.modal-branch::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--branch-color, var(--accent));
}
.modal-date {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.modal-header h2 { margin: 0 0 6px; font-size: 19px; line-height: 1.3; }
.modal-meta {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}
.modal-divider { height: 1px; background: var(--border); margin: 14px 0; }
.modal-body p { margin: 0 0 10px; font-size: 15px; line-height: 1.6; }
.modal-tags { margin-top: 4px; }
.modal-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .simple-header { padding: 20px 16px 8px; }
  .graph-wrapper { padding: 4px 10px 48px; }

  /* Left-align the heading and keep the toggle + its label on the same row, to the right */
  .heading-row {
    justify-content: space-between;
  }
  .simple-header h1 {
    text-align: left;
  }
  .view-switch {
    position: static;
    transform: none;
    padding: 14px 0;
  }

  /* Hide branch names on mobile to maximize space for titles */
  .branch-name-subtle {
    display: none;
  }
  
  /* Force title and date onto separate lines on mobile */
  .log-text {
    font-size: 14px;
    line-height: 1.35;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 2px;
  }
  .log-text strong {
    white-space: normal;
  }
  .log-meta {
    font-size: 11px;
    margin-top: 0;
  }
  
  /* Header links stretch to fill the row instead of clustering in the middle */
  .cta-row {
    flex-wrap: nowrap !important;
    gap: 8px;
  }
  .cta-link {
    flex: 1;
    height: 44px;
    padding: 0 4px;
    font-size: 12px;
    gap: 6px;
    justify-content: center;
  }
  /* The graph lines will now inherit the exact same stroke-width as desktop */
}
