/* ============================================================================
   curvas-bezier-vetorial/app.css — styles for the Bézier playground only.
   Scoped under .bez; inherits BPSO Lab 2026 tokens from blog.css. Loaded by the
   post page. Works in both dark (default) and [data-theme="light"].
   ========================================================================== */

.bez {
  /* Local render tokens read by app.js via getComputedStyle. */
  --bez-bg: #0b1220;
  --bez-grid: rgba(255, 255, 255, .05);
  --bez-curve: var(--brand-light, #60a5fa);
  --bez-glow: rgba(37, 99, 235, .5);
  --bez-poly: rgba(148, 163, 184, .55);
  --bez-anchor: var(--brand-blue, #2563eb);
  --bez-control: var(--cat-tools, #8b5cf6);
  --bez-l1: #8b5cf6;        /* first construction level */
  --bez-l2: #22c55e;        /* second construction level */
  --bez-rider: #f8fafc;
  --bez-active: #f8fafc;

  display: grid;
  gap: 1.1rem;
}
[data-theme="light"] .bez {
  --bez-bg: #0f172a;        /* keep the canvas dark for curve contrast in light theme */
  --bez-grid: rgba(255, 255, 255, .055);
  --bez-poly: rgba(203, 213, 225, .5);
}

/* ----------------------------------------------------------------- Stage */
.bez__stage {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm, 10px);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bez-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
  /* The canvas self-sizes via width + aspect-ratio; we must NOT cap the stage
     height here. A max-height + overflow:hidden would clip the canvas AND the
     absolutely-positioned handle layer (whose top/left % map to the full,
     uncapped height H), desyncing the keyboard/drag handles from the drawn
     points on short/landscape viewports. Let the stage track the canvas. */
}

.bez__canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;        /* let pointer-drag own the gesture */
  cursor: crosshair;
}

/* Focusable point handles overlaid on the canvas (keyboard + a11y). */
.bez__handles {
  position: absolute;
  inset: 0;
  pointer-events: none;       /* canvas owns pointer; handles still focusable via Tab */
}
.bez__handle {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;    /* center on its x/y */
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: grab;
  pointer-events: auto;       /* but the handle itself is interactive */
  -webkit-tap-highlight-color: transparent;
}
.bez__handle:active { cursor: grabbing; }
.bez__handle:focus-visible {
  outline: 3px solid var(--brand-light);
  outline-offset: 0;
}

/* --------------------------------------------------------------- Controls */
.bez__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .9rem 1.4rem;
}

.bez__field {
  display: grid;
  gap: .4rem;
  min-width: 0;               /* never let it overflow a flex row */
  flex: 1 1 260px;
}
.bez__field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  font-size: .82rem;
}
.bez__field-label { font-weight: 600; color: var(--text-muted); }
.bez__t-value {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: .82rem;
  color: var(--brand-light);
  white-space: nowrap;
}
[data-theme="light"] .bez__t-value { color: var(--brand-blue); }

.bez__range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-light));
  cursor: pointer;
  outline-offset: 4px;
}
.bez__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.bez__range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.bez__range::-moz-range-track { background: transparent; }

/* Toggles */
.bez__toggles {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem 1.2rem;
  align-items: center;
}
.bez__toggle {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.bez__toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .18s, border-color .18s;
}
.bez__toggle input::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transform: translateY(-50%);
  transition: transform .18s, background .18s;
}
.bez__toggle input:checked {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
}
.bez__toggle input:checked::after {
  transform: translate(16px, -50%);
  background: #fff;
}
.bez__toggle input:focus-visible {
  outline: 3px solid var(--brand-light);
  outline-offset: 2px;
}
.bez__toggle-text { min-width: 0; }

/* ---------------------------------------------------------------- Presets */
.bez__presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.bez__presets-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: .15rem;
}
.bez__chip {
  appearance: none;
  border: 1px dashed color-mix(in srgb, var(--brand-blue) 45%, var(--border));
  background: color-mix(in srgb, var(--brand-blue) 8%, transparent);
  color: var(--text-main);
  font-family: var(--font-body, system-ui);
  font-weight: 500;
  font-size: .82rem;
  padding: .42rem .8rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 0;
  transition: background .15s, border-color .15s, transform .15s;
}
.bez__chip:hover {
  background: color-mix(in srgb, var(--brand-blue) 18%, transparent);
  border-style: solid;
  transform: translateY(-1px);
}
.bez__chip:active { transform: translateY(0); }

/* ----------------------------------------------------------- CSS output */
.bez__out {
  display: grid;
  gap: .5rem;
}
.bez__out-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.bez__copy {
  appearance: none;
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  background: var(--surface-2);
  color: var(--text-main);
  padding: .7rem .9rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.bez__copy:hover {
  border-color: color-mix(in srgb, var(--brand-blue) 55%, var(--border));
}
.bez__code {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: .88rem;
  color: var(--brand-light);
  background: none;
  border: 0;
  padding: 0;
}
[data-theme="light"] .bez__code { color: var(--brand-blue); }
.bez__copy i { font-size: 1.1rem; line-height: 1; flex: 0 0 auto; color: var(--text-muted); }
.bez__copy:hover i { color: var(--brand-blue); }
.bez__copy-text {
  flex: 0 0 auto;
  font-family: var(--font-head, system-ui);
  font-weight: 600;
  font-size: .82rem;
  color: var(--text-muted);
}

/* Visually hidden live region. */
.bez__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------- Responsive */
@media (max-width: 600px) {
  .bez__field { flex-basis: 100%; }
  .bez__code { font-size: .8rem; }
  .bez__copy-text { display: none; }   /* keep the copy button compact on phones */
}

@media (max-width: 360px) {
  .bez__chip { font-size: .78rem; padding: .4rem .65rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bez__toggle input,
  .bez__toggle input::after,
  .bez__chip,
  .bez__copy { transition: none; }
}
