/* Paleta de CuaderNOTE: una barra de colores con una flecha que señala el color.
   Un único componente para todos los selectores de color; se ajusta al ancho disponible. */

/* El encabezado de CuaderNOTE conserva exactamente sus colores originales,
   sin importar el color global que se elija en Configuración → Apariencia. */
body .notebooks-hero {
  --accent: #00FF66;
  --ian-global-accent: #00FF66;
  --library-accent: #00FF66;
  --cyan: #00FF66;
  --green: #00FF66;
  --accent-contrast: #101820;
  --accent-rgb: 0, 255, 102;
  --accent-soft: rgba(0, 255, 102, .16);
  --accent-line: rgba(0, 255, 102, .48);
  --accent-glow: rgba(0, 255, 102, .32);
  --panel: color-mix(in srgb, #00FF66 7%, #111C2B);
  --panel-2: color-mix(in srgb, #00FF66 12%, #16283C);
  --line: color-mix(in srgb, #00FF66 32%, #2A3A4F);
  /* Variables que la hoja de CuaderNOTE calcula en un contenedor superior con el color global. */
  --muted: color-mix(in srgb, #FFFFFF 67%, #00FF66);
  --cuadernote-neon: #00FF66;
  --cuadernote-secondary: color-mix(in srgb, #00FF66 78%, #0A6B47);
  --cuadernote-deep: color-mix(in srgb, #00FF66 58%, #121c44);
  --cuadernote-energy: color-mix(in srgb, #00FF66 78%, #FFFFFF);
}
:root[data-theme="light"] body .notebooks-hero {
  --panel: color-mix(in srgb, #00FF66 7%, #FFFFFF);
  --panel-2: color-mix(in srgb, #00FF66 12%, #EEF3F8);
  --line: color-mix(in srgb, #00FF66 32%, #C4D0DE);
}

/* Contenedores antiguos que ahora alojan la barra de colores: se liberan de carruseles y alturas fijas. */
body :is(.notebook-color-swatches, .notebook-create-color-choices, .note-color-options, .library-card-color-swatches, .multimedia-color-options, .appearance-palette-swatches, .editor-palette):has(> .ian-bar) {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 10px !important;
  overflow: visible !important;
  max-height: none !important;
  scroll-snap-type: none !important;
  padding: 0 !important;
}
/* En Ajustes → Apariencia la barra ocupa todo el ancho posible (menos relleno en las cajas que la rodean). */
body fieldset.appearance-palette:has(.ian-bar) { padding: 10px 8px !important; min-width: 0 !important; }

/* Los contenedores antiguos dimensionan a sus hijos como muestras de 34 px; la barra debe ocupar todo el ancho. */
body .ian-bar {
  position: relative !important;
  isolation: isolate;
  flex: 0 0 100% !important;
  grid-column: 1 / -1;
  box-sizing: border-box;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  justify-items: stretch !important;
  align-items: start !important;
  gap: 6px;
  width: 100% !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 520px !important;
  margin: 6px auto !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
  outline: 0 !important;
  outline-offset: 0 !important;
  transform: none !important;
  aspect-ratio: auto !important;
  color: inherit !important;
  font-size: 1rem !important;
  line-height: 1.25 !important;
  opacity: 1 !important;
  overflow: visible !important;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Rótulo superior: nombre y código del color señalado o elegido. */
body .ian-bar .ian-bar-caption {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin: 0;
  font-size: .86rem;
  line-height: 1.25;
}
body .ian-bar .ian-bar-caption i {
  display: block !important;
  flex: 0 0 auto;
  width: 26px !important;
  height: 26px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid rgba(128, 128, 128, .5) !important;
  border-radius: 6px !important;
  background: var(--hc, transparent) !important;
  box-shadow: none !important;
  filter: none !important;
}
body .ian-bar .ian-bar-caption strong { font-weight: 700; }
body .ian-bar .ian-bar-caption code {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: .04em;
  background: transparent;
}

/* La barra: una sola fila de barras altas de un solo color, con un espacio mínimo entre ellas.
   Se corre con las flechitas de los lados o acercando el puntero (o el dedo) a un borde. */
body .ian-bar { --sw: 24px; --g: 2px; }
body .ian-bar .ian-bar-body {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
}
body .ian-bar .ian-bar-scroll {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
}
body .ian-bar .ian-bar-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
body .ian-bar .ian-bar-track {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: var(--g);
  width: max-content;
  box-sizing: border-box;
  margin: 0;
  padding: 19px 4px 7px;
}

/* Flechitas de los lados. */
body .ian-bar .ian-bar-nav {
  all: unset;
  position: relative;
  box-sizing: border-box;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 36px;
  margin-top: 26px;
  border: 1px solid rgba(128, 128, 128, .5);
  border-radius: 8px;
  background: rgba(128, 128, 128, .16);
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, transform .1s ease, opacity .15s ease;
}
body .ian-bar .ian-bar-nav::before { content: ""; width: 0; height: 0; border-style: solid; }
body .ian-bar .ian-bar-nav.is-prev::before { border-width: 6px 8px 6px 0; border-color: transparent currentColor transparent transparent; }
body .ian-bar .ian-bar-nav.is-next::before { border-width: 6px 0 6px 8px; border-color: transparent transparent transparent currentColor; }
body .ian-bar .ian-bar-nav::after { content: ""; position: absolute; inset: -8px -5px; }
body .ian-bar .ian-bar-nav:hover:not(:disabled) { background: rgba(128, 128, 128, .32); }
body .ian-bar .ian-bar-nav:active:not(:disabled) { transform: scale(.92); }
body .ian-bar .ian-bar-nav:disabled { opacity: .28; cursor: default; }
body .ian-bar .ian-bar-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

body .ian-bar .ian-bar-swatch {
  position: relative;
  flex: 0 0 var(--sw) !important;
  box-sizing: border-box;
  width: var(--sw) !important;
  height: 50px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease;
}
/* Los contenedores antiguos pintan todos sus <i> como círculos con !important: aquí cada <i> es una barra de su color. */
body .ian-bar .ian-bar-swatch i {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 2px !important;
  background: var(--hc) !important;
  box-shadow: none !important;
  filter: none !important;
  outline: 0 !important;
  transition: box-shadow .12s ease;
}
body .ian-bar .ian-bar-swatch b { display: none; }

/* Color señalado (puntero, dedo o teclado): la barra sube un poco. */
body .ian-bar .ian-bar-swatch.is-point,
body .ian-bar .ian-bar-swatch:focus-visible {
  z-index: 3;
  transform: translateY(-4px) scaleY(1.08);
}
/* Color elegido: anillo doble (blanco y oscuro) visible sobre cualquier fondo. */
body .ian-bar .ian-bar-swatch.selected,
body .ian-bar .ian-bar-swatch[aria-pressed="true"] { z-index: 4; transform: translateY(-2px) scaleY(1.06); }
body .ian-bar .ian-bar-swatch.selected i,
body .ian-bar .ian-bar-swatch[aria-pressed="true"] i,
body .ian-bar .ian-bar-swatch:focus-visible i { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #101820 !important; }

/* Flecha: se desliza sobre la barra; su forma es blanca por fuera y oscura por dentro para verse sobre cualquier fondo. */
body .ian-bar .ian-bar-arrow {
  position: absolute;
  top: 0;
  left: calc(4px + var(--i, 0) * (var(--sw) + var(--g)) + var(--sw) / 2);
  z-index: 5;
  width: 18px;
  height: 13px;
  margin: 0;
  padding: 0;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: left .09s ease-out, opacity .12s ease, transform .12s ease;
}
body .ian-bar .ian-bar-arrow.is-on { opacity: 1; }
body .ian-bar.is-pointing .ian-bar-arrow { transform: translateX(-50%) scale(1.18); }
body .ian-bar .ian-bar-arrow::before,
body .ian-bar .ian-bar-arrow::after {
  content: "";
  position: absolute;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
body .ian-bar .ian-bar-arrow::before { inset: 0; background: #fff; }
body .ian-bar .ian-bar-arrow::after { left: 4px; top: 1.5px; width: 10px; height: 7px; background: #101820; }

body .ian-bar.ian-bar-dragging .ian-bar-track { cursor: grabbing; }

/* Botón "Sin resaltado" del menú de formato de texto (va junto a la barra de colores). */
body .editor-palette:has(> .ian-bar) > .editor-clear-highlight {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line, rgba(128, 128, 128, .5));
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  body .ian-bar .ian-bar-swatch,
  body .ian-bar .ian-bar-swatch i,
  body .ian-bar .ian-bar-arrow { transition: none; }
}
