/* Shared styles for annotated posts */

/* Code blocks */
pre.code,
.lean {
  background: var(--color-code-bg);
  color: var(--color-text);
  padding: var(--spacing-xl);
  overflow-x: auto;
  line-height: 1.6;
}
pre.code code,
.lean code {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

/* Inline code */
:not(pre) > code {
  color: var(--color-link);
  font-weight: 500;
  font-size: var(--font-size-sm);
}

/* Syntax highlighting — Lean */
.lean .kw,
.lean .cmd { color: var(--color-syntax-keyword); font-weight: 500; }
.lean .type { color: var(--color-syntax-function); }
.lean .out { color: var(--color-syntax-comment); }
.lean .comment { color: var(--color-syntax-comment); }
.lean .str { color: var(--color-syntax-string); }

/* Syntax highlighting — pre.code (Python / general) */
pre.code .kw { color: var(--color-syntax-keyword); font-weight: 500; }
pre.code .cls { color: var(--color-syntax-function); }
pre.code .fn { color: var(--color-syntax-function); }
pre.code .comment { color: var(--color-syntax-comment); }
pre.code .builtin { color: var(--color-syntax-keyword); }
pre.code .str { color: var(--color-syntax-string); }

/* Sidenote references */
.sn-ref {
  font-size: var(--font-size-xs);
  color: var(--color-text);
  font-weight: bold;
  cursor: pointer;
  vertical-align: super;
  line-height: 0;
}
.sn-ref:hover { color: var(--color-gray-500); }
.sn-ref:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}
.sn-content { display: none; }

/* Sidenote dl — flex column of dt/dd pairs, each wrapped in a div */
.sn-dl {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}
.sn-dl > div {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}
.sn-dl dt { font-weight: bold; }
.sn-dl dd { margin-left: 0; }

/* Desktop: margin sidenotes */
#sn-column { display: none; }
@media (min-width: 1100px) {
  #sn-column {
    display: block;
    position: absolute;
    top: 0;
    right: calc((var(--sn-width) + var(--sn-gap)) * -1);
    width: var(--sn-width);
  }
  .sn-placed {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    position: absolute;
    left: 0;
    width: 100%;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.5;
    border-left: 2px solid var(--color-text);
    padding-left: var(--spacing-md);
  }
  .sn-placed .sn-label {
    font-weight: bold;
    color: var(--color-text);
    display: block;
    font-family: var(--font-heading);
  }
  .sn-placed code { font-size: var(--font-size-xs); }
}

/* Narrow: slide-up bottom sheet */
.sn-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sn-backdrop.visible { opacity: 1; }
.sn-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--color-code-bg);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  padding: 0 var(--spacing-3xl) var(--spacing-3xl);
  border-top: 1px solid var(--color-gray-300);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.sn-popup.visible { transform: translateY(0); }
.sn-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xl) 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--spacing-xl);
  position: sticky;
  top: 0;
  background: var(--color-code-bg);
}
.sn-popup-header .sn-label {
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-gray-600);
}
.sn-popup .sn-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: var(--spacing-sm);
  line-height: 1;
}
.sn-popup .sn-close:hover { color: var(--color-gray-600); }
.sn-popup .sn-close:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}
.sn-popup-body {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}
.sn-popup code {
  color: var(--color-link);
  font-size: var(--font-size-xs);
}
