/* =============================================================================
   modal.css — Code viewer modal (dialog)
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Overlay
   --------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: rgba(10, 14, 25, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Dialog panel
   --------------------------------------------------------------------------- */
.modal {
  position: relative;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: 0 24px 64px -16px rgba(10, 14, 25, 0.35);
  width: 100%;
  max-width: 56rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* When modal is hidden */
.modal[hidden],
.modal-overlay[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */
.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.1rem;
  /* border-bottom: 1px solid var(--border); */
  flex-shrink: 0;
}

.modal__header-text {
  min-width: 0;
}

.modal__title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.modal__filename {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal__close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--fg-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}

.modal__close:hover {
  background-color: var(--surface);
  color: var(--fg);
}

/* ---------------------------------------------------------------------------
   Code modal — widen to accommodate the permanent two-pane compare layout
   --------------------------------------------------------------------------- */
#code-modal {
  max-width: min(96vw, 92rem);
}

/* ---------------------------------------------------------------------------
   Single-file view tabs (Top-Level / In-Depth / smart) — pill buttons
   --------------------------------------------------------------------------- */
.modal__tabs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal__tabs[hidden] {
  display: none;
}

.modal__tab {
  appearance: none;
  cursor: pointer;
  padding: 0.4rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-muted);
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}

.modal__tab[hidden] {
  display: none;
}

.modal__tab:hover {
  color: var(--fg);
  border-color: var(--accent);
}

.modal__tab.is-active {
  color: var(--accent-fg);
  background-color: var(--accent);
  border-color: var(--accent);
}

/* "Compare ⇄" tab — pinned to the end of the tab bar, same pill shape as
   the file tabs but accent-tinted at rest so it still reads as an action */
.modal__tab--compare {
  margin-left: auto;
  color: var(--accent);
  background-color: color-mix(in oklch, var(--accent) 10%, transparent);
  border-color: var(--accent);
}

.modal__tab--compare:hover {
  color: var(--accent-fg);
  background-color: oklch(0.50 0.085 185);
}

.modal__tab--compare.is-active {
  color: var(--accent-fg);
  background-color: var(--accent);
  border-color: var(--accent);
}

/* Single-file pane fills the modal body */
.modal__single {
  --code-bg: oklch(0.18 0.02 250);
  --code-fg: oklch(0.96 0.005 240);

  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.modal__single[hidden] {
  display: none;
}

.modal__single .modal__compare-pane {
  flex: 1 1 auto;
}

/* Dropdown used in compare-mode pane headers to pick which file to show */
.modal__pane-select {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--card);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 1.4rem 0.2rem 0.5rem;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%),
                     linear-gradient(135deg, var(--fg-muted) 50%, transparent 50%);
  background-position: calc(100% - 0.85rem) center, calc(100% - 0.6rem) center;
  background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
  background-repeat: no-repeat;
}

.modal__pane-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ---------------------------------------------------------------------------
   Compare pane (side-by-side, file per side picked via dropdown)
   --------------------------------------------------------------------------- */
.modal__compare {
  /* Restore dark editor palette regardless of the global --code-* tokens */
  --code-bg: oklch(0.18 0.02 250);
  --code-fg: oklch(0.96 0.005 240);

  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.modal__compare[hidden] {
  display: none;
}

.modal__compare-pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 50%;
  min-width: 0;
}

.modal__compare-pane:first-child {
  border-right: 1px solid var(--border);
}

.modal__compare-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background-color: oklch(0.965 0.008 240 / 0.4);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal__compare-pane-heading {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.30rem;
}

.modal__compare-pane-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.modal__compare-pane-label--top {
  color: var(--accent);
}

.modal__compare-pane-label--depth {
  color: var(--accent);
}

.modal__compare-pane-filename {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal__compare-pane-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-shrink: 0;
}

.btn--tiny {
  padding: 0.25rem 0.55rem;
  font-size: 0.68rem;
  border-radius: var(--radius-sm);
}

.modal__compare-pane-code {
  flex: 1;
  overflow: auto;
  min-height: 0;
  background-color: var(--code-bg);
  color: var(--code-fg);
}

@media (max-width: 720px) {
  .modal__compare {
    flex-direction: column;
    overflow: auto;
  }

  .modal__compare-pane {
    flex: 0 0 auto;
    height: 45vh;
  }

  .modal__compare-pane:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* Proof-results modal tabs (top-level / in-depth / smart) reuse the shared
   .modal__tab pill styling defined above with the code modal's tab bar. */

/* ---------------------------------------------------------------------------
   Proof-results modal body + header meta
   --------------------------------------------------------------------------- */
.modal__body {
  flex: 1;
  overflow: auto;
  min-height: 12rem;
}

.proof-modal__meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.2rem;
}

.proof-modal__desc {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--fg-muted2);
  line-height: 1.5;
}

.proof-modal__badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  background-color: oklch(0.54 0.12 155 / 0.12);
  color: oklch(0.38 0.12 155);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.proof-modal__badge-time {
  font-family: var(--font-mono);
  margin-left: 0.4rem;
  padding-left: 0.5rem;
  border-left: 1px solid oklch(0.38 0.12 155 / 0.3);
  opacity: 0.85;
}

.proof-modal__badge--incomplete {
  background-color: oklch(0.85 0.14 95 / 0.25);
  color: oklch(0.4 0.12 95);
}

.proof-modal__badge--incomplete .proof-modal__badge-time {
  border-left-color: oklch(0.4 0.12 95 / 0.3);
}

/* ---------------------------------------------------------------------------
   Proof results table
   --------------------------------------------------------------------------- */
.proof-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.proof-th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  background-color: var(--surface);
  z-index: 1;
}

.proof-th:last-child {
  border-right: none;
}

.proof-th--obligation { width: 60%; }

.proof-row {
  border-bottom: 1px solid oklch(0.91 0.012 245 / 0.5);
}

.proof-row--goal .proof-cell--name {
  color: var(--fg);
}

.proof-row--transf {
  background-color: oklch(0.965 0.008 240 / 0.6);
}

.proof-cell--transf {
  font-style: italic;
  color: var(--fg-muted);
  font-size: 0.75rem;
}

.proof-row--leaf:hover {
  background-color: oklch(0.965 0.008 240 / 0.4);
}

.proof-cell {
  padding: 0.45rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-right: 1px solid var(--border);
}

.proof-cell:last-child {
  border-right: none;
}

.proof-cell--name { color: var(--fg); }

.proof-arrow {
  color: var(--fg-muted2);
  font-style: normal;
  margin-right: 0.1rem;
}

.proof-cell--valid {
  color: oklch(0.38 0.12 155);
  font-weight: 500;
  background-color: oklch(0.54 0.12 155 / 0.07);
}

.proof-cell--empty {
  color: var(--fg-muted2);
}

.proof-loading,
.proof-error {
  padding: 2rem 1.5rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* The pre/code rendered inside */
.code-pre {
  margin: 0 !important;
  padding: 1.5rem !important;
  background: transparent !important;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  overflow: visible;
  white-space: pre;
}

/* Highlight.js overrides — keep background transparent */
.modal__compare-pane-code .hljs {
  background: transparent !important;
  padding: 0 !important;
  font-size: 0.82rem;
  line-height: 1.65;
}
