/* ── Proof Explorer: Split-pane layout with STLC proof editor ── */

/* ── Hide Jekyll chrome ───────────────────────────────── */
.proof-explorer-page .site-header { display: none; }
.proof-explorer-page .site-footer { display: none; }
.proof-explorer-page .page-content { padding: 0; }
.proof-explorer-page .wrapper { max-width: none; padding: 0; }

/* ── Top bar ──────────────────────────────────────────── */
#pe-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 20px;
  background: #fff;
  color: #374151;
  font-size: 0.875rem;
  z-index: 10;
  flex-shrink: 0;
  border-bottom: 1px solid #e5e7eb;
}
.pe-back-link {
  color: #6b7280;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s;
}
.pe-back-link:hover { color: #F76900; }
.pe-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pe-topbar-spacer { flex: 1; }
.pe-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.78rem;
  font-family: inherit;
  white-space: nowrap;
}
.pe-toggle-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}
.pe-toggle-btn.pe-active {
  background: #F76900;
  border-color: #F76900;
  color: #fff;
}

/* ── Split pane container ─────────────────────────────── */
#pe-split {
  display: flex;
  height: calc(100vh - 44px);
  overflow: hidden;
}
.pe-pane {
  overflow: hidden;
  min-width: 0;
}

/* ── Notes pane (left) ────────────────────────────────── */
#pe-notes {
  width: 45%;
  min-width: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
}
#pe-notes.pe-full {
  width: 100% !important;
  min-width: 0;
}
.pe-notes-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 36px 80px;
  font-size: 0.95rem;
  line-height: 1.72;
  color: #1f2937;
}

/* ── Typography overrides for notes pane ───────────────── */
.pe-notes-inner h2 {
  margin: 2em 0 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid #e5e7eb;
  font-size: 1.4em;
  font-weight: 700;
  color: #111827;
}
.pe-notes-inner h2:first-child { margin-top: 0; }
.pe-notes-inner h3 {
  margin: 1.6em 0 0.5em;
  font-size: 1.15em;
  font-weight: 600;
  color: #1f2937;
}
.pe-notes-inner p { margin: 0.75em 0; }
.pe-notes-inner ul, .pe-notes-inner ol {
  margin: 0.6em 0;
  padding-left: 1.6em;
}
.pe-notes-inner li { margin: 0.35em 0; }
.pe-notes-inner hr {
  margin: 2em 0;
  border: none;
  border-top: 1px solid #e5e7eb;
}
.pe-notes-inner pre {
  margin: 1em 0;
  padding: 14px 18px;
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.55;
}
.pe-notes-inner table {
  margin: 1em 0;
  border-collapse: collapse;
  font-size: 0.9em;
  width: 100%;
}
.pe-notes-inner th, .pe-notes-inner td {
  padding: 8px 14px;
  border: 1px solid #e5e7eb;
  text-align: left;
}
.pe-notes-inner th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}
.pe-notes-inner strong {
  font-weight: 600;
  color: #111827;
}

/* ── Clickable typing judgements ───────────────────────── */
.pe-clickable {
  cursor: pointer;
  position: relative;
  border-bottom: 2px dashed rgba(79, 70, 229, 0.35);
  transition: border-color 0.15s, background-color 0.15s;
}
.pe-clickable:hover {
  border-bottom-color: #4f46e5;
  background-color: rgba(79, 70, 229, 0.06);
}
.pe-clickable::after {
  content: "Prove in explorer \2192";
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  background: #374151;
  color: #fff;
  font-size: 0.7rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-style: normal;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.pe-clickable:hover::after { opacity: 1; }

/* ── "Try it" button for exercises ────────────────────── */
button.pe-try-btn,
.pe-try-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  margin: 0.4em 4px 0.4em 0;
  font-size: 0.84em;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  background: #4f46e5;
  border: 1px solid #4f46e5;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  line-height: 1.4;
}
button.pe-try-btn:hover,
.pe-try-btn:hover {
  background: #4338ca;
  border-color: #4338ca;
}

/* ── Divider ──────────────────────────────────────────── */
#pe-divider {
  width: 8px;
  background: #f9fafb;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 5;
  transition: background 0.15s;
  touch-action: none;
}
#pe-divider:hover,
#pe-divider.pe-dragging { background: #e5e7eb; }
.pe-divider-grip {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pe-divider-grip span {
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #9ca3af;
}
#pe-divider:hover .pe-divider-grip span,
#pe-divider.pe-dragging .pe-divider-grip span { background: #6b7280; }

/* ── Explorer pane (right) ────────────────────────────── */
#pe-explorer {
  flex: 1;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  background: #fafbfc;
}
#pe-explorer.pe-hidden { display: none; }
#pe-divider.pe-hidden { display: none; }

/* ── Toolbar ──────────────────────────────────────────── */
#pe-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.pe-toolbar-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}
.pe-toolbar-title i {
  color: #4f46e5;
  margin-right: 4px;
}
.pe-toolbar-actions {
  margin-left: auto;
  display: flex;
  gap: 5px;
}
.pe-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  color: #6b7280;
  background: #f9fafb;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pe-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}
.pe-btn-primary {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}
.pe-btn-primary:hover {
  background: #4338ca;
  border-color: #4338ca;
  color: #fff;
}

/* ── Editor area ──────────────────────────────────────── */
#pe-editor-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#pe-editor-wrap {
  width: 100%;
  height: 100%;
}
#pe-editor-wrap .proof-tree-viewport {
  width: 100%;
  height: 100%;
}

/* ── Status bar ───────────────────────────────────────── */
#pe-status {
  padding: 4px 14px;
  font-size: 0.72rem;
  color: #9ca3af;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
  min-height: 22px;
}
#pe-status.pe-status-valid { color: #059669; }
#pe-status.pe-status-error { color: #dc2626; }

/* ── Rules reference panel ────────────────────────────── */
#pe-rules-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 340px;
  height: 100%;
  background: #fff;
  border-left: 1px solid #e5e7eb;
  box-shadow: -4px 0 12px rgba(0,0,0,0.06);
  z-index: 20;
  overflow-y: auto;
  transition: transform 0.25s ease;
}
#pe-rules-panel.pe-panel-hidden {
  transform: translateX(100%);
}
.pe-rules-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #111827;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.pe-btn-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 3px;
  transition: all 0.15s;
}
.pe-btn-close:hover {
  background: #f3f4f6;
  color: #374151;
}
#pe-rules-content {
  padding: 12px 16px;
}
.pe-rule-card {
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.pe-rule-card .pe-rule-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #4f46e5;
  margin-bottom: 6px;
}
.pe-rule-card .proof-tree-canvas {
  font-size: 0.82rem;
}
.pe-rule-card .pe-rule-condition {
  font-size: 0.72rem;
  color: #6b7280;
  font-style: italic;
  margin-top: 6px;
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 700px) {
  #pe-notes {
    width: 100% !important;
    min-width: 0;
  }
  #pe-explorer {
    width: 100%;
    min-width: 0;
  }
  .pe-notes-inner { padding: 20px 18px 48px; }
  #pe-split.pe-mobile-split { flex-direction: column; }
  #pe-split.pe-mobile-split #pe-notes {
    height: 50%;
    overflow-y: auto;
  }
  #pe-split.pe-mobile-split #pe-explorer { height: 50%; }
  #pe-divider { display: none; }
  #pe-rules-panel { width: 100%; }
}
