/*
  Body Currents Tool – WordPress-safe styling

  Problem addressed
  - The original CSS contained global selectors (html, body, *, h2, button, etc.) which can
    override a WordPress theme (and vice-versa).
  - The tool also relied on an inline <style> block in body-current-tool.html, but the
    plugin embed.php deliberately strips everything outside <body>, so those styles were
    never applied on WordPress.

  Fix
  - Scope ALL styles to the wrapper emitted by embed.php: .body-currents-embed
  - Move the tool’s inline styles into this file.
*/

/* Scope the design tokens to the tool wrapper (not :root) */
.body-currents-embed{
  --bc-bg: #ffffff;
  --bc-ink: #111827;
  --bc-ink-soft: #374151;
  --bc-muted: #6b7280;
  --bc-accent: #6557A2;
  --bc-grid: rgba(17,24,39,0.10);

  background: var(--bc-bg);
  color: var(--bc-ink);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Ensure internal layout does not depend on theme defaults */
.body-currents-embed,
.body-currents-embed *{
  box-sizing: border-box;
}

.body-currents-embed a{ color: inherit; }

/* Tool layout (moved from the stripped <style> block in body-current-tool.html) */
.body-currents-embed .tool-wrap{ max-width:1100px; margin:0 auto; padding:12px; }

.body-currents-embed .canvas-wrap{
  position:relative;
  display:grid;
  grid-template-columns: 60px 1fr;
  grid-template-rows: 1fr auto;
  gap:8px;
  align-items:stretch;
}

.body-currents-embed .plot.plot-area{ grid-column:2; grid-row:1; position:relative; }
.body-currents-embed .plot-canvas{ display:block; width:100%; height:520px; }

.body-currents-embed .slider-vertical-wrap{ grid-column:1; grid-row:1; display:block; position:relative; }
.body-currents-embed .slider-vertical{
  writing-mode: vertical-lr;
  direction: rtl;

  /* In vertical writing-mode, WIDTH controls the visual thickness. */
  width: 10px;

  /* HEIGHT controls the slider length (fills the wrapper column). */
  height: 100%;

  appearance: none;
  -webkit-appearance: none;

  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.body-currents-embed .slider-horizontal-wrap{ grid-column:2; grid-row:2; position:relative; width:100%; height:36px; }
.body-currents-embed .slider-horizontal{
  margin:0;
  display:block;
  box-sizing:border-box;
  appearance: none;
  -webkit-appearance: none;
  position:absolute;
  left:0;
  width:100%;
}

.body-currents-embed .controls{ display:flex; flex-wrap:wrap; gap:12px; align-items:center; margin:8px 0 12px; }
.body-currents-embed .controls label{ font-size:14px; color:var(--bc-ink-soft); }
.body-currents-embed .controls input,
.body-currents-embed .controls select{
  padding:8px 10px;
  border:1px solid var(--bc-grid);
  border-radius:10px;
  background:#fff;
  color:var(--bc-ink);
  font: inherit;
  line-height: 1.2;
}

.body-currents-embed .row{ display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.body-currents-embed .field{ display:flex; gap:6px; align-items:center; }

.body-currents-embed .legend{ display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.body-currents-embed .legend .item{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  color:var(--bc-ink-soft);
  border:1px solid var(--bc-grid);
  padding:6px 8px;
  border-radius:999px;
  background:#fff;
}
.body-currents-embed .legend .swatch{ width:14px; height:14px; border-radius:3px; border:1px solid var(--bc-grid); }

.body-currents-embed .note{ font-size:12px; color:var(--bc-muted); margin-top:6px; }
.body-currents-embed #plot{ cursor:crosshair; }
.body-currents-embed .layer{ padding:0; border:none; background:transparent; }

/* Canvas container styling (keep it minimal; do not mimic theme containers) */
.body-currents-embed .plot{
  width:100%;
  height:520px;
  background:#fff;
  border:1px solid var(--bc-grid);
  border-radius:12px;
  overflow:hidden;
}

/* WordPress themes sometimes apply max-width/height:auto to canvas/img globally */
.body-currents-embed canvas{ max-width:100%; height:520px; }

/* --- Range slider normalization (scoped) --- */
.body-currents-embed input[type="range"]{
  width:100%;
  appearance:none;
  -webkit-appearance:none;
  background:transparent;
  outline:none;
  margin:0;
  padding:0;
}

/* Size the sliders explicitly (horizontal vs vertical) */
.body-currents-embed .slider-horizontal{ height:22px; }
.body-currents-embed .slider-vertical{ width:10px; height:100%; }

.body-currents-embed input[type="range"]::-webkit-slider-runnable-track{
  height:6px;
  background: rgba(101,87,162,0.25);
  border-radius:999px;
}
.body-currents-embed input[type="range"]::-moz-range-track{
  height:6px;
  background: rgba(101,87,162,0.25);
  border-radius:999px;
}

.body-currents-embed input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none;
  width:16px;
  height:16px;
  border-radius:50%;
  background: var(--bc-accent);
  border:2px solid #fff;
  box-shadow: 0 0 0 2px rgba(101,87,162,0.30);
  margin-top:-5px;
}
.body-currents-embed input[type="range"]::-moz-range-thumb{
  width:16px;
  height:16px;
  border-radius:50%;
  background: var(--bc-accent);
  border:2px solid #fff;
  box-shadow: 0 0 0 2px rgba(101,87,162,0.30);
}

.body-currents-embed input[type="range"]:focus-visible::-webkit-slider-runnable-track{
  box-shadow: 0 0 0 3px rgba(101,87,162,0.20);
}
.body-currents-embed input[type="range"]:focus-visible::-moz-range-track{
  box-shadow: 0 0 0 3px rgba(101,87,162,0.20);
}

/* --- Vertical range slider (duration) – make track visually slimmer --- */
/* For vertical sliders, the element's height becomes the thickness. */
.body-currents-embed input[type="range"].slider-vertical{
  width:10px; /* thickness */
  height:100%; /* length */
}

/* WebKit (Chrome/Edge/Safari) */
.body-currents-embed input[type="range"].slider-vertical::-webkit-slider-runnable-track{
  height:3px;               /* track thickness */
  border-radius:999px;
  box-shadow:none;          /* prevent "fat" glow/shadow */
}

/* Firefox */
.body-currents-embed input[type="range"].slider-vertical::-moz-range-track{
  height:3px;
  border-radius:999px;
  box-shadow:none;
}

/* Remove focus halo for vertical track (keeps thumb ring as-is) */
.body-currents-embed input[type="range"].slider-vertical:focus-visible::-webkit-slider-runnable-track{
  box-shadow:none;
}
.body-currents-embed input[type="range"].slider-vertical:focus-visible::-moz-range-track{
  box-shadow:none;
}
