/* μ Notes - Additional styles for the notes page */

/* Note buttons in sidebar - styled to match example buttons */
.note-btn {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: 'Newsreader', Georgia, serif;
  width: 100%;
  text-align: left;
  color: var(--ink-soft, #4a4038);
  transition: color 0.12s, background 0.12s;
  line-height: 1.4;
}

.note-btn:hover {
  color: var(--accent, #7a1f1f);
  background: var(--paper-deep, #e8dfc9);
}

/* Notes sidebar specific - match playground examples-sidebar width */
.notes-sidebar {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  background: var(--paper, #f1ead9);
  border-right: 1px solid var(--rule-soft, #c8bda3);
  overflow: hidden;
  transition: flex-basis 0.2s ease, opacity 0.2s ease;
}

.notes-sidebar.collapsed {
  flex-basis: 0;
  opacity: 0;
  pointer-events: none;
}

/* Sidebar header matching playground style */
.notes-sidebar .sidebar-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--rule-soft, #c8bda3);
}

.notes-sidebar .sidebar-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft, #4a4038);
}

.notes-sidebar .sidebar-categories {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule, #a89c80) transparent;
}

.notes-sidebar .sidebar-categories::-webkit-scrollbar { width: 4px; }
.notes-sidebar .sidebar-categories::-webkit-scrollbar-thumb { background: var(--rule, #a89c80); }

.notes-sidebar .category {
  padding: 0 14px;
  margin-bottom: 12px;
}

.notes-sidebar .category h4 {
  font-family: 'JetBrains Mono', monospace;
  margin: 10px 0 5px 0;
  font-size: 9px;
  color: var(--ink-soft, #4a4038);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 400;
}

.notes-sidebar .category ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notes-sidebar .category li {
  margin: 2px 0;
}

/* Loading separator styling in REPL - using data attributes set by JS */
.repl-entry[data-entry-type="loading"] {
  border-left: 3px solid var(--accent, #7a1f1f);
  background: var(--paper-deep, #e8dfc9);
  padding-left: 8px;
  margin-left: -2px;
}

.repl-entry[data-entry-type="loading"] .repl-entry-input {
  color: var(--accent, #7a1f1f);
  font-style: italic;
}

.repl-entry[data-entry-type="loaded"] {
  border-left: 3px solid #22c55e;
  background: var(--paper-deep, #e8dfc9);
  padding-left: 8px;
  margin-left: -2px;
}

.repl-entry[data-entry-type="loaded"] .repl-entry-input {
  color: #22c55e;
  font-style: italic;
}

/* ── Note prose rendering ───────────────────────────────────── */

/* Section headings (# Act N: … / # ===…===) */
.note-section-heading {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 15px;
  font-style: italic;
  font-weight: 600;
  color: var(--ink, #1a1612);
  margin: 20px 0 4px;
  padding: 8px 0 6px;
  border-top: 1px solid var(--rule, #a89c80);
  letter-spacing: 0.01em;
}

.note-section-heading:first-child {
  margin-top: 4px;
  border-top: none;
}

/* Inline prose comments */
.note-comment {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 14px;
  font-style: italic;
  color: #7a7060;
  margin: 1px 0 3px 0;
  line-height: 1.5;
}

/* Silent definitions (name: value with no output) — very subdued */
.repl-entry.entry-definition {
  margin: 1px 0 1px;
}

.repl-entry.entry-definition .repl-entry-input {
  font-size: 11px;
  font-weight: 400;
  color: #b0a48c;
}

.repl-entry.entry-definition .repl-entry-output {
  color: #b0a48c;
  border-left-color: #cec4ae;
}

.repl-entry.entry-definition .repl-entry-input::before {
  display: none;
}

/* Key result lines (bare echo of a variable) — prominent */
.repl-entry.entry-result {
  margin: 6px 0 8px;
  background: var(--paper, #f1ead9);
  border-radius: 2px;
  padding: 4px 8px 4px 6px;
}

.repl-entry.entry-result .repl-entry-input {
  font-size: 11px;
  font-weight: 400;
  color: #b0a48c;
  margin-bottom: 1px;
}

.repl-entry.entry-result .repl-entry-input::before {
  color: var(--rule, #a89c80);
  font-weight: 400;
}

.repl-entry.entry-result .repl-entry-output {
  font-weight: 400;
  font-size: 14px;
  color: var(--ink, #1a1612);
  border-left: 3px solid var(--accent, #7a1f1f);
  padding-left: 10px;
  margin-left: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Desktop: larger toggle button */
.sidebar-toggle {
  width: 24px;
  font-size: 12px;
}

/* Mobile responsive - overlay drawer on small screens */
@media (max-width: 640px) {
  /* Keep toggle button visible */
  .sidebar-toggle {
    display: flex !important;
    position: fixed;
    left: 0;
    top: calc(44px + env(safe-area-inset-top));
    height: 40px;
    width: 40px;
    z-index: 110;
    writing-mode: horizontal-tb;
    border-right: 1px solid var(--rule-soft, #c8bda3);
    border-bottom: 1px solid var(--rule-soft, #c8bda3);
    font-size: 14px;
  }

  /* Sidebar becomes fixed overlay */
  .notes-sidebar {
    position: fixed;
    left: 0;
    top: calc(44px + env(safe-area-inset-top));
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--rule, #a89c80);
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }

  .notes-sidebar.open {
    transform: translateX(0);
  }

  /* Backdrop for clicking outside to close */
  .notes-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: calc(44px + env(safe-area-inset-top)) 0 0 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
  }

  .notes-sidebar-backdrop.visible {
    display: block;
  }

  /* Fix plot margins on mobile - remove left margin that causes overflow */
  .plot-output {
    margin: 6px 0 4px 0 !important;
    max-width: 100%;
  }

  /* Ensure plot canvas/svg doesn't overflow */
  .plot-output canvas,
  .plot-output svg {
    max-width: 100% !important;
  }
}
