/* time-list: shared grid so all title columns align regardless of date width */
.time-list ul {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: var(--gap-base);
}

.time-list li {
  display: contents;
}

.time-list li > span,
.time-list li > div {
  padding: var(--spacing-sm) 0;
}

@media (max-width: 600px) {
  .time-list ul {
    grid-template-columns: 1fr;
  }
  .time-list li > span {
    padding-bottom: 0;
  }
  .time-list li > div {
    padding-top: 0;
  }
}

/* Lightbox */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-bg-primary);
  z-index: 9999;
  cursor: zoom-in;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

#lightbox.active {
  display: flex;
}

#lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  z-index: 1;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  letter-spacing: 0.05em;
  transition: color 0.15s ease;
}

#lightbox-close:hover {
  color: var(--color-text-primary);
}

#lightbox-hint {
  position: absolute;
  z-index: 1;
  bottom: 5vh;
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-text-muted);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#lightbox img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border: 1px solid var(--color-border);
  padding: 0;
  margin: 0;
  cursor: zoom-in;
  border-radius: var(--pre-border-radius);
}

:root {
  --container-width: min(92ch, 92vw);
  --font-size-base: 1.08em;
  --spacing-base: 1.7em;
  --bg-h: 40;
  --bg-s: 40%;
  --bg-l: 87%;
}

/* Dark mode — neutral grey instead of warm mud */
[data-theme="dark"] {
  --bg-h: 0;
  --bg-s: 0%;
  --bg-l: 12%;
  --color-border: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) + 10%));
  --color-bg-secondary: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) + 4%));
  --color-selection-bg: hsl(var(--bg-h) var(--bg-s) calc(var(--bg-l) + 20%));
}

/* Fallback cross-fade for browsers without View Transitions */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 0.4s ease,
    color 0.4s ease,
    border-color 0.4s ease,
    box-shadow 0.4s ease,
    outline-color 0.4s ease !important;
}

/* Ensure hr uses the theme border colour */
hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--spacing-base) 0;
}

/* View Transitions: scan wipe top-to-bottom (like a page being reprinted) */
::view-transition-old(root) {
  animation: none;
  z-index: 0;
}
::view-transition-new(root) {
  z-index: 1;
  animation: theme-scan 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes theme-scan {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0% 0); }
}

/* Cap the current breadcrumb so long titles truncate with ellipsis */
.path-nav li.current {
  max-width: min(36ch, 50vw);
}

/* Header row: breadcrumb + toggles on the same line */
.header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}


.header-row .path-nav {
  flex: 1;
  min-width: 0;
}

.header-toggles {
  flex-shrink: 0;
  display: flex;
  gap: 0.5em;
}

#theme-toggle {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease;
  white-space: nowrap;
}

#theme-toggle:hover {
  color: var(--color-text-primary);
}

h1, h2, h3, h4, h5, .path-nav, .terminal-nav {
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !important;
  text-transform: lowercase;
}

/* ── Home page: centered tree in the viewport ───────────────────── */

html:has(.home-container) {
  min-height: 100dvh;
}

body:has(.home-container) {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0;
  margin: 0;
}

/* No breadcrumbs on home; keep the box from taking flow space. */
body:has(.home-container) header {
  display: none;
}

body:has(.home-container) main {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 0;
  margin: 0;
  width: 100%;
}

body:has(.home-container) footer {
  display: none;
}

.home-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.home-tree {
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 1.05rem;
  line-height: 2;
  letter-spacing: 0.01em;
  text-align: left;
}

.home-tree .tree-root {
  color: var(--color-text-primary);
  margin-bottom: 0.1em;
}

.home-tree .tree-branch {
  color: var(--color-text-muted);
}

.home-tree .tree-branch a {
  color: var(--color-text-muted);
  border-bottom: 1px dotted currentColor;
  text-decoration: none;
  transition: color 0.15s ease, border-bottom-style 0.15s ease;
}

.home-tree .tree-branch a:hover {
  color: var(--color-text-primary);
  border-bottom: 1px solid currentColor;
}

/* Social icons below tree on home */
.home-social {
  display: flex;
  gap: 0.75em;
  margin-top: 1.5em;
}

.home-social a {
  color: var(--color-text-muted);
  border-bottom: none !important;
  text-decoration: none !important;
  transition: color 0.15s ease;
}

.home-social a:hover {
  color: var(--color-text-primary);
}

.home-social svg {
  width: 1.05em;
  height: 1.05em;
  display: block;
}

/* Theme toggle standalone below social icons on home */
.home-container #theme-toggle {
  margin-top: 1.25em;
}

/* ── Markdown: heading anchor links (deep links) ───────────────── */
/* # sits in the left gutter; heading text stays aligned with body copy. */
.content-heading {
  position: relative;
  display: block;
  width: 100%;
  box-sizing: border-box;
  scroll-margin-top: 1.25em;
  border: none;
}

.content-heading__text {
  display: block;
  width: 100%;
  text-align: left;
}

/* Hang the link in the margin left of the text column (outside the heading text box). */
/* Like e7b747d, with a small extra offset left (0.12em) — not the larger calc that followed. */
main .content-heading a.content-heading__anchor,
main .content-heading a.content-heading__anchor:hover {
  position: absolute;
  right: calc(100% + 0.12em);
  top: 0.15em;
  margin: 0 0.4em 0 0;
  width: 1.15em;
  text-align: right;
  white-space: nowrap;
  z-index: 1;
  font-weight: normal;
  text-decoration: none !important;
  border: none;
  color: var(--color-text-muted);
  opacity: 0;
  transition: color 0.15s ease, opacity 0.15s ease;
  font-size: 0.85em;
  line-height: 1.2;
}

/* Reset global link styles that fight gutter positioning. */
main .content-heading a.content-heading__anchor {
  display: block;
  margin-left: 0;
}

main .content-heading:hover a.content-heading__anchor,
main .content-heading:focus-within a.content-heading__anchor,
main .content-heading a.content-heading__anchor:focus-visible,
main .content-heading a.content-heading__anchor:hover {
  opacity: 0.85;
  color: var(--color-text-primary);
}

/* Narrow viewports: keep # usable if gutter would clip. */
@media (max-width: 36rem) {
  main .content-heading a.content-heading__anchor,
  main .content-heading a.content-heading__anchor:hover {
    position: static;
    display: inline;
    width: auto;
    text-align: left;
    margin: 0 0.2em 0 0;
    vertical-align: 0.05em;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ── Markdown: code blocks (copy) ────────────────────────────── */
/* Theme: `figure { text-align: center }` targets all figures. Code must stay left. */
figure.code-block {
  text-align: start;
}

/* Ensure nothing inside inherits centered lines from `figure` (stronger than theme figure). */
figure.code-block,
figure.code-block .code-block__meta,
figure.code-block .code-block__pre,
figure.code-block .highlight,
figure.code-block pre,
figure.code-block code {
  text-align: start;
}

.code-block {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--pre-border-radius);
  background: var(--color-bg-primary);
  box-shadow: 0 1px 2px 0 var(--color-border);
  margin: var(--spacing-base) 0;
  overflow: hidden;
  max-width: 100%;
  text-align: start;
}

.code-block__meta {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  gap: 0.75em;
  padding: 0.4em 0.65em;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  text-align: start;
  position: relative;
  z-index: 1;
}

.code-block__lang {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  text-align: start;
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  text-transform: lowercase;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.code-copy {
  flex-shrink: 0;
  margin-left: auto;
  position: relative;
  z-index: 2;
  background: var(--color-bg-primary);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--inline-border-radius);
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.4;
  padding: 0.25em 0.5em;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

button.code-copy:hover,
button.code-copy:focus-visible {
  color: var(--color-text-primary);
  border-color: var(--color-text-muted);
  outline: none;
}

.code-block__pre {
  /* contains Chroma .highlight; strips outer double borders */
  position: relative;
}

.code-block__pre .highlight,
.code-block__pre .highlight pre {
  margin: 0;
  border: none;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
}

.code-block__pre .highlight {
  background: var(--color-bg-primary);
  padding: 0;
}

.code-block__pre .highlight pre {
  padding: var(--spacing-sm) var(--spacing-md);
  max-width: 100%;
  overflow-x: auto;
  border: none;
  text-align: start !important;
}

.code-block__pre code,
.code-block__pre pre,
figure.code-block .highlight,
figure.code-block .highlight pre,
figure.code-block pre,
figure.code-block code {
  text-align: start !important;
}

/* Raw JSON for copy; hidden in layout (not display:none so JSON stays in a11y tree but off-screen) */
.code-block > script {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Playlist table */
.playlist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.playlist-table th,
.playlist-table td {
  text-align: left;
}

.playlist-table th {
  color: var(--color-text-muted);
  font-weight: normal;
  font-size: 0.78rem;
  padding: 0.5em 0.75em;
  border-bottom: 1px solid var(--color-border);
}

.playlist-table td {
  padding: 0.5em 0.75em;
  vertical-align: middle;
}

.playlist-table tbody tr:hover {
  background: var(--color-bg-secondary);
}

.col-num {
  width: 2.5em;
  color: var(--color-text-muted);
}

.col-duration {
  color: var(--color-text-muted);
}

.title-inner {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center;
  gap: 0.75em;
}

.title-inner span {
  min-width: 0;
}

.playlist-table img.album-art {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  border-radius: 8px;
  flex-shrink: 0;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid var(--color-border) !important;
  object-fit: cover;
}

@media (max-width: 480px) {
  .col-duration {
    display: none;
  }
  .col-artist {
    max-width: 30vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Now building card */
.now-building {
  border: 1px solid var(--color-border, currentColor);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  opacity: 0.9;
}

.now-building__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
  margin-bottom: 0.5rem;
}

.now-building__body > :first-child {
  margin-top: 0;
}

.now-building__body > :last-child {
  margin-bottom: 0;
}
