/* =========================================================================
 * bin-compare.css — Layout rules for /static/bin-compare HEX view + friends
 *
 * Loaded only by bin-compare.html + en/bin-compare.html + gpec2a-unlock pages.
 * Only the rules that fall outside tailwind.min.css / theme.css live here.
 *
 * Design notes
 * ------------
 * - RTL-safe by design: the page is dir="rtl". Grid column ordering follows
 *   document order, so with [original first, modified second] the visual
 *   order is [original on the right, modified on the left] — which IS the
 *   natural Arabic reading order. We never need explicit grid-row/column
 *   re-assignment to flip the panes.
 * - Each `.hex-line` is a 3-column mini-grid: [address][hex bytes][ascii].
 *   We use logical word-spacing so the line breathes the same in either dir.
 * - `.hex-byte` sizes are tuned for monospace 16 bytes/line at ~14px.
 * ========================================================================= */

/* ---------- 2-column side-by-side panes for the comparison result -------- */

/* #comparisonResult is a plain block container — it has exactly ONE child
   (.comparison-panel) which is the actual 2-column grid. Making BOTH of them
   grids caused a double-nesting bug: the panel received 616px, then split its
   own 616px into two 298px viewers. Only .comparison-panel is the grid. */
#comparisonResult.comparison-grid {
  display: block;
  width: 100%;
  max-width: 100%;
}

/* The immediate parent grid that holds both viewers. */
.comparison-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  width: 100%;
}

/* Stays usable on tablets / phones: panes collapse to a single column
   below 900px so each viewer can scroll independently. */
@media (max-width: 900px) {
  .comparison-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------------------
 * Hex viewer column container
 * - max-height is set by the inline style attribute on #hexViewer1/2 (600px).
 * - We force overflow: auto so each pane scrolls INDEPENDENTLY when the panes
 *   are side-by-side at desktop widths. Without this, the panes can't be
 *   scrolled separately and look like one tall column.
 * ------------------------------------------------------------------------- */
.hex-viewer {
  display: block;
  overflow: auto;
  background: #fafafa;
  font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas",
               "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  padding-block: 0.5rem;
  padding-inline: 0.75rem;
  text-align: start;
  border-top: 1px solid #e5e7eb;
}

/* Make the inner rows honour the LTR direction of hex byte columns even when
   the page is RTL. The byte sequence "00 0B 11 ... | A B C" is always LTR. */
.hex-viewer,
.hex-line,
.hex-bytes {
  direction: ltr;
  unicode-bidi: isolate;
}

/* -------------------------------------------------------------------------
 * Hex line grid: [offset][hex bytes][ascii] = 3 columns
 * - Keep column widths fixed in ch units so both viewers line up byte-for-byte.
 * ------------------------------------------------------------------------- */
.hex-line {
  display: grid;
  grid-template-columns: 11ch minmax(0, 1fr) 18ch;
  align-items: center;
  gap: 0.5rem;
  padding-inline: 0.25rem;
  border-block-end: 1px solid #f1f5f9;
  min-height: 1.7em;
}

/* Perf fix: skip layout/paint work for rows outside the viewport.
   The browser reserves the intrinsic size so scrollbar height stays correct,
   and rendering thousands of `.hex-line` rows stops costing main-thread time. */
.hex-viewer .hex-line {
  content-visibility: auto;
  contain-intrinsic-size: auto 26px;
}

.hex-line:hover {
  background: #eef2ff;
}

.hex-address {
  color: #6366f1;
  font-weight: 700;
  white-space: nowrap;
}

.hex-bytes {
  display: inline-flex;
  flex-wrap: nowrap;
  white-space: pre;
}

.hex-byte {
  display: inline-block;
  min-width: 2.35ch;
  padding-inline: 0.2ch;
  cursor: pointer;
  border-radius: 2px;
  transition: background 120ms ease;
}

.hex-byte:hover {
  background: #ede9fe;
  outline: 1px solid #c4b5fd;
}

.hex-byte.selected {
  background: #fbbf24;
  color: #1f2937;
  font-weight: 700;
}

.hex-ascii {
  color: #475569;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Diff colouring for inline byte-level highlights */
.hex-byte.modified {
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 700;
}
.hex-byte.added {
  background: #dcfce7;
  color: #15803d;
  font-weight: 700;
}
.hex-byte.deleted {
  background: #fed7aa;
  color: #c2410c;
  font-weight: 700;
}

/* ASCII pane diff colouring (mirrors byte diffs) */
.char-modified { background: #fee2e2; color: #b91c1c; }
.char-added    { background: #dcfce7; color: #15803d; }
.char-deleted  { background: #fed7aa; color: #c2410c; }

/* Search-result highlight (JS adds .search-highlight during find).
   Defined here so the highlight is actually visible — previously the class
   was applied but had no CSS rule. */
.hex-byte.search-highlight {
  background: #fef08a;
  color: #713f12;
  outline: 1px solid #facc15;
  font-weight: 700;
}

/* Pagination sentinel inside hex panes */
.load-more-sentinel {
  height: 28px;
  margin-block: 0.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
}

/* -------------------------------------------------------------------------
 * Format toggle pill buttons (Hex / ASCII / Both)
 * ------------------------------------------------------------------------- */
.format-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
}

.format-toggle button {
  background: transparent;
  border: 0;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 120ms ease;
}

.format-toggle button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.format-toggle button.active {
  background: rgba(255, 255, 255, 0.32);
}

/* -------------------------------------------------------------------------
 * Sync scroll bar
 * ------------------------------------------------------------------------- */
.sync-scroll-bar {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f1f5f9;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  margin-block: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.scroll-slider {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  margin-block: 0.5rem;
  cursor: pointer;
}

.scroll-thumb {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 30px;
  height: 8px;
  background: linear-gradient(90deg, #38bdf8, #6366f1);
  border-radius: 999px;
  cursor: grab;
  transition: transform 100ms ease;
}

.scroll-thumb:active { cursor: grabbing; }

.sync-scroll-btn {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-end: 24px;
  background: #6366f1;
  color: #fff;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.5);
  cursor: pointer;
  z-index: 40;
}

/* -------------------------------------------------------------------------
 * Generic modal + drop zone + progress bar styles already live in theme.css,
 * but we re-declare drop-zone here so theme.css doesn't need touching.
 * ------------------------------------------------------------------------- */
.drop-zone {
  border: 2px dashed #cbd5e1;
  transition: background 150ms ease, border-color 150ms ease;
}

.drop-zone.drag-over {
  background: #e0f2fe;
  border-color: #38bdf8;
}

/* -------------------------------------------------------------------------
 * GPEC2/A standalone page layout helpers
 * (also reused on /static/gpec2a-unlock and /static/en/gpec2a-unlock)
 * ------------------------------------------------------------------------- */
.unlock-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  max-width: 920px;
  margin-inline: auto;
}

@media (min-width: 900px) {
  .unlock-page-grid.two-col {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.unlock-op-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.unlock-op-card:hover {
  border-color: #6366f1;
  background: #f8fafc;
}

.unlock-op-card input[type="checkbox"] {
  margin-block-start: 0.2rem;
}

.unlock-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.unlock-summary > div {
  background: #f1f5f9;
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
}

.unlock-summary .num {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
}

.unlock-summary .lbl {
  font-size: 0.74rem;
  color: #475569;
  margin-block-start: 0.25rem;
}

.unlock-mod-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  font-size: 0.83rem;
}

.unlock-mod-row .addr {
  color: #6366f1;
  font-family: ui-monospace, monospace;
  font-weight: 700;
}

.unlock-mod-row .before { color: #dc2626; font-family: ui-monospace, monospace; }
.unlock-mod-row .after  { color: #16a34a; font-family: ui-monospace, monospace; }
