/* Popup shell */
#wiki-popup {
  display: none;
  position: fixed;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 999;
  padding: 0;              /* no interior padding; handled below */
  overflow: hidden;        /* kills the unwanted outer scroll bar */
  
}

/* Small red X close button (absolute in top-right) */
#wiki-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  line-height: 26px;
  text-align: center;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  z-index: 1000;
}
#wiki-close:hover {
  opacity: 0.9;
}

/* Body wrapper that holds nav + content */
#wiki-body {
  flex: 1;
  display: flex;
  flex-direction: column;  /* mobile default */
  height: 100%;
  gap: 12px;
  padding: 20px 20px 20px 20px;
  overflow: hidden;        /* contain nested scroll areas */
}

/* Sidebar nav column */
#wiki-nav {
  background: #f3f4f6;
  padding: 16px;
  overflow-y: auto;
  border-right: none;
  max-height: 200px;       /* mobile: cap height so content is visible */
}

.wiki-title {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.wiki-nav-heading {
  font-weight: bold;
  margin-bottom: 12px;
}

#wiki-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
#wiki-nav ul li {
  margin-bottom: 8px;
}
#wiki-nav ul li a {
  text-decoration: none;
  color: #2563eb;
  font-weight: 600;
}
#wiki-nav ul li a:hover {
  text-decoration: underline;
}

/* Content column */
#wiki-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 4px 0 0; /* avoid scroll overlay on right */
  position: relative;
}

/* Desktop: side-by-side */
@media (min-width: 768px) {
  #wiki-body {
    flex-direction: row;
    gap: 20px;
    padding: 20px 24px;
  }

  #wiki-nav {
    width: 240px;
    flex-shrink: 0;
    max-height: none;       /* let it grow full height */
    border-right: 1px solid #ccc;
    margin-right: 0;
  }

  #wiki-content {
    padding-left: 0;
  }
}

/* Optional Q&A styling */
#wiki-content details {
  margin-bottom: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}
#wiki-content summary {
  font-weight: bold;
  font-size: 16px;
  cursor: pointer;
  outline: none;
}
#wiki-content details[open] summary {
  color: #2563eb;
}
#wiki-content p {
  margin: 8px 0 0;
  line-height: 1.4;
}

#wiki-content .wiki-markdown { font-size: 15px; line-height: 1.6; }
#wiki-content .wiki-markdown h1,
#wiki-content .wiki-markdown h2,
#wiki-content .wiki-markdown h3 { margin: 0.8em 0 0.4em; line-height: 1.25; }
#wiki-content .wiki-markdown p { margin: 0.5em 0; }
#wiki-content .wiki-markdown ul,
#wiki-content .wiki-markdown ol { margin: 0.5em 0 0.5em 1.2em; }
#wiki-content .wiki-markdown a { text-decoration: underline; color: #2563eb; }
#wiki-content .wiki-markdown code { background: #f3f4f6; padding: 0.1em 0.25em; border-radius: 4px; }
#wiki-content .wiki-markdown pre code { display:block; padding:12px; overflow-x:auto; }


/* Responsive YouTube/video wrapper */
.wiki-video-wrapper {
  position: relative;
  width: 100%;
  max-width: 560px;      /* adjust if you want wider/narrower on desktop */
  margin: 12px auto;     /* center it */
  aspect-ratio: 16 / 9;  /* modern browsers */
  background: #000;      /* letterbox background while loading */
}

/* Fallback for older browsers that don't support aspect-ratio */
.wiki-video-wrapper::before {
  content: "";
  display: block;
  padding-top: 56.25%;   /* 16:9 (9/16 * 100) */
}

.wiki-video-wrapper iframe,
.wiki-video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- Core Flow inline header button --- */
.wiki-h2-wrap { position: relative; display: flex; align-items: center; gap: 10px; }
.wiki-h2-actions { display: inline-flex; align-items: center; gap: 8px; }

/* Better contrast for icon chips */
.flowchip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 9999px;
  background: #e8f1ff;             /* light blue */
  border: 1px solid #bfd3ff;        /* blue border */
  color: #1e3a8a;                   /* dark blue icon/text */
  cursor: pointer;
}
.flowchip:hover { background: #dbe8ff; border-color: #9db9ff; }

/* ensure SVGs inherit the dark color */
.flowchip svg, .flowchip svg path, .flowchip svg * { fill: currentColor; stroke: none; }


/* Modal/overlay (only injected when clicked) */
.cf-modal[hidden] { display:none; }
.cf-modal { position:fixed; inset:0; z-index:1000; }
.cf-backdrop { position:absolute; inset:0; background:rgba(0,0,0,0.5); }
.cf-dialog { position:relative; margin:4vh auto; width:min(1200px,92vw); background:#fff; border-radius:14px; box-shadow:0 20px 60px rgba(0,0,0,.25); overflow:hidden; }
.cf-header { display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-bottom:1px solid #eee; }
.cf-close { background:transparent; border:none; font-size:20px; cursor:pointer; }

/* container with padding around the canvas */
.cf-canvas-wrap { position: relative; padding: 10px; }

/* scrollable area for big images (both axes) */
.cf-canvas-scroll {
  max-height: calc(90vh - 120px); /* fits under the modal header */
  overflow: auto;                  /* shows scrollbars as needed */
  background: #fff;
}

/* the element that matches the image’s rendered size */
.cf-canvas { position: relative; display: inline-block; }

/* let the image render at its natural size (so you can scroll) */
#cfFlowImg { display: block; height: auto; max-width: none; }

/* overlays that always match the image box */
.cf-hotspots,
.cf-mark-layer,
.cf-tooltip { position: absolute; left: 0; top: 0; }
.cf-hotspots, .cf-mark-layer { right: 0; bottom: 0; }

/* (keep your existing hotspot/tooltip styles as-is) */

/* Hotspots: invisible by default */
.cf-hotspot {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  /* important bits: */
  background: transparent;         /* no fill */
  border: 2px dashed transparent;  /* no border visible */
  padding: 0;
  cursor: pointer;
}

/* Optional: show outline only while debugging
.cf-hotspot:hover { border-color: rgba(74,144,226,0.6); } */

/* Keyboard focus ring if you want it visible
.cf-hotspot:focus-visible { outline: 2px solid #4a90e2; } */


/* === Core Flow tooltip (restores background) === */
.cf-tooltip {
  position: absolute;           /* you already have this from earlier */
  max-width: min(360px, 80vw);
  background: rgba(17,17,17,.96);
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  pointer-events: none;         /* tooltip itself doesn't capture mouse */
  z-index: 3;                   /* sit above hotspots/mark layer */
}

/* Header row inside the tooltip */
.cf-tip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Small info button inside tooltip must be clickable */
.cf-info {
  pointer-events: auto;         /* override tooltip's none */
  border: none;
  background: #fff;
  color: #111;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-weight: 700;
  cursor: pointer;
  line-height: 22px;
  text-align: center;
}

.cf-tip-summary { font-size: 0.95rem; opacity: 0.95; }
.cf-tip-note    { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.2); font-size: 0.92rem; opacity: 0.95; }

/* Ensure stacking order for overlays */
.cf-hotspots, .cf-mark-layer { z-index: 1; }

.cf-hotspot {
  position: absolute;
  left: 0; top: 0;
  width: 0; height: 0;
  background: transparent;
  border: 2px dashed transparent;
  padding: 0;
  cursor: pointer;
}

/* tooltip stays the same, but allow clicks when 'locked' */
.cf-tooltip.locked { pointer-events: auto; z-index: 3; }

/* when locked, allow long notes to scroll if needed */
.cf-tooltip.locked { max-height: 60vh; overflow: auto; }

.cf-click-hint { opacity:.7; font-style: italic; margin-left: 6px; }

.flowchip.active {
  background: #1e3a8a;
  border-color: #1e3a8a;
  color: #fff;
}

/* Labeled slider switch */
.cf-switch {
  display: inline-flex; align-items: center; gap: 8px;
  height: 28px;          /* match flowchip height */
  user-select: none;
}
.cf-switch-label { font-weight: 600; font-size: 12px; line-height: 1; }

/* hide native checkbox but keep it accessible */
.cf-switch input[type="checkbox"] {
  position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none;
}

/* track + thumb sized to 28px */
.cf-switch .track {
  position: relative;
  width: 46px; height: 28px; border-radius: 9999px;
  background: #e5e7eb; border: 1px solid #d1d5db;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  transition: background .18s ease, border-color .18s ease;
  cursor: pointer; display: inline-block;
}
.cf-switch .thumb {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform .18s ease;
}

/* checked state */
.cf-switch input:checked + .track {
  background: #1e3a8a; border-color: #1e3a8a;
}
.cf-switch input:checked + .track .thumb {
  transform: translateX(18px); /* 46 - 22 - 6 = 18 */
}

/* keyboard focus outline */
.cf-switch input:focus-visible + .track {
  outline: 2px solid #2563eb; outline-offset: 2px;
}

/* Header actions row (chips + switch) */
.cf-actions{
  display:flex;
  gap:10px;
  align-items:center;   /* vertically center all children */
  flex-wrap:wrap;
}

/* Make chips and the switch share the same 28px geometry */
.cf-actions .flowchip,
.cf-actions .cf-switch{
  height:28px;
}

/* Switch group alignment */
.cf-switch{
  display:inline-flex;
  align-items:center;    /* centers label + track */
  gap:8px;
  margin:0;
  padding:0;
}

/* Label sits on the same vertical center as chips */
.cf-switch-label{
  display:flex;
  align-items:center;
  height:28px;
  line-height:28px;      /* match chip height */
  margin:0;
}

/* Track/thumb sized to 28px (matches earlier switch styling) */
.cf-switch .track{ width:46px; height:28px; border-radius:9999px; }
.cf-switch .thumb{ width:22px; height:22px; top:3px; left:3px; }
/* If your fonts still look 1px off, you can gently nudge: */
/* .cf-switch{ transform: translateY(1px); } */

/* Header actions row (chips + switch) */
.cf-actions{
  display:flex;
  gap:10px;
  align-items:center;   /* vertically center ALL children */
  flex-wrap:wrap;
}

/* Make chips and the switch share the same 28px geometry */
.cf-actions .flowchip,
.cf-actions .cf-switch{
  height:28px;
}

/* Switch group alignment */
.cf-switch{
  display:inline-flex;
  align-items:center;    /* centers label + track */
  gap:8px;
  margin:0;
  padding:0;
}

.cf-switch-label{
  display:flex;
  align-items:center;
  height:28px;
  line-height:28px;      /* match chip height */
  margin:0;
}

/* Track/thumb sized to 28px */
.cf-switch .track{ width:46px; height:28px; border-radius:9999px; }
.cf-switch .thumb{ width:22px; height:22px; top:3px; left:3px; }

/* Optional 1–2px optical nudge if your font renders a hair off */
.cf-actions .cf-switch{ transform: translateY(1px); } /* try 2px if needed */

/* ===== Final alignment fixes for header row ===== */

/* Make the actions row center everything */
.cf-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

/* Chips: include border in the 28px box so centering is true */
.flowchip{
  height:28px;
  box-sizing:border-box;            /* important */
  line-height:28px;                 /* keeps icons/text centered */
}

/* Switch group uses the same 28px geometry */
.cf-switch{
  display:inline-flex;
  align-items:center;
  gap:8px;
  height:28px;
  margin:0;
  padding:0;
}

/* Label matches chip height exactly */
.cf-switch-label{
  display:flex;
  align-items:center;
  height:28px;
  line-height:28px;
  margin:0;
}

/* Track: count border inside the 28px box */
.cf-switch .track{
  width:46px;
  height:28px;
  box-sizing:border-box;            /* important */
  border:1px solid #d1d5db;
  border-radius:9999px;
  background:#e5e7eb;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
  transition: background .18s ease, border-color .18s ease;
  cursor:pointer;
  display:inline-block;
  position:relative;
}

/* Thumb centered vertically in that 28px track */
.cf-switch .thumb{
  width:22px; height:22px;
  position:absolute; left:3px; top:3px;   /* (28 - 22) / 2 = 3 */
  border-radius:50%;
  background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.25);
  transition: transform .18s ease;
}

/* Checked state */
.cf-switch input:checked + .track{
  background:#1e3a8a; border-color:#1e3a8a;
}
.cf-switch input:checked + .track .thumb{
  transform: translateX(18px); /* 46 - 22 - 6 = 18 */
}

/* FINAL tiny optical nudge (if you still see it 1–2px high, increase to 2px or 3px) */
.cf-actions .cf-switch{ position: relative; top: 2px; }

/* Make text icons inside flowchips readable and centered */
.flowchip-texticon {
  color: #1e3a8a;           /* dark blue */
}
.flowchip-texticon span {
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

/* === Mark Mode visuals (crosshair + live selection box) === */

/* The overlay that captures drag should show a crosshair */
.cf-mark-layer{
  /* you already position it absolutely with left/top/right/bottom elsewhere */
  cursor: crosshair;
  z-index: 2;            /* above hotspots, below tooltip */
  user-select: none;     /* prevent text/image selection while dragging */
}

/* The rectangle you draw while dragging */
.cf-mark-box{
  position: absolute;
  pointer-events: none;  /* don’t steal mousemove/up from the layer */
  border: 2px dashed #3b82f6;                 /* dotted/dashed outline */
  background: rgba(59,130,246,0.15);          /* faint fill so you can see it */
  box-shadow: 0 0 0 1px rgba(255,255,255,.8) inset; /* subtle inner edge */
  border-radius: 4px;                          /* optional */
}

/* If you want *only* the outline (no fill), comment the background line above:
   background: transparent;
*/
