/* Accesibilidad — variables alineadas al chatbot B/N */
:root {
  --a11y-surface: #ffffff;
  --a11y-surface-2: #fafafa;
  --a11y-border: #e0e0e0;
  --a11y-text: #020202;
  --a11y-text-muted: #666666;
  --a11y-text-faint: #999999;
  --a11y-accent: #020202;
  --a11y-overlay: rgba(0, 0, 0, 0.45);
}

body.active_dark {
  --a11y-surface: #0e0e0e;
  --a11y-surface-2: #141414;
  --a11y-border: rgba(255, 255, 255, 0.12);
  --a11y-text: #ffffff;
  --a11y-text-muted: #bebebe;
  --a11y-text-faint: #706c6c;
  --a11y-accent: #ffffff;
  --a11y-overlay: rgba(0, 0, 0, 0.65);
}

/* Ajustes globales — solo cuando el usuario activa opciones */
html {
  --a11y-font-scale: 100;
  --a11y-line-height: 100;
}

body {
  line-height: 1.5;
}

html.a11y-active {
  --a11y-fs-mul: calc(var(--a11y-font-scale) / 100);
  --a11y-lh-ratio: calc(var(--a11y-line-height) / 100 * 1.5);
}

html.a11y-active main {
  font-size: calc(100% * var(--a11y-font-scale) / 100);
}

html.a11y-active main p,
html.a11y-active main li,
html.a11y-active main h1,
html.a11y-active main h2,
html.a11y-active main h3,
html.a11y-active main h4,
html.a11y-active main .texto_secundario,
html.a11y-active main article p,
html.a11y-active main section p,
html.a11y-active main .projects-empty p,
html.a11y-active main .projects-count {
  line-height: var(--a11y-lh-ratio) !important;
}

html.a11y-active main p {
  font-size: calc(0.9rem * var(--a11y-fs-mul)) !important;
}

html.a11y-active main article p[data-astro-cid-44zkpkd5] {
  font-size: calc(0.75rem * var(--a11y-fs-mul)) !important;
}

html.a11y-active main h2.texto_secundario,
html.a11y-active main h2[data-astro-cid-anhloy43],
html.a11y-active main h3[data-astro-cid-sh445jdo] {
  line-height: var(--a11y-lh-ratio) !important;
}

html.a11y-dyslexia-on main {
  font-family: "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif;
  letter-spacing: 0.04em;
  word-spacing: 0.12em;
}

/* Contraste: normal → invertir → blanco y negro */
html.a11y-contrast-high main,
html.a11y-contrast-high #scroll-progress,
html.a11y-contrast-high #hyperdrive {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast-max main,
html.a11y-contrast-max #scroll-progress,
html.a11y-contrast-max #hyperdrive {
  filter: grayscale(1) contrast(1.25);
}

html.a11y-colorblind-on main,
html.a11y-colorblind-on #scroll-progress,
html.a11y-colorblind-on #hyperdrive {
  filter: saturate(1.35) contrast(1.1);
}

html.a11y-reduced-motion main *,
html.a11y-reduced-motion main *::before,
html.a11y-reduced-motion main *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

html.a11y-reduced-motion #hyperdrive {
  display: none !important;
}

html.a11y-large-cursor-on,
html.a11y-large-cursor-on * {
  cursor: none !important;
}

.a11y-large-cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 48px;
  height: auto;
  pointer-events: none;
  z-index: 100010;
  margin: 0;
  padding: 0;
  line-height: 0;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.a11y-large-cursor img {
  display: block;
  width: 48px;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.9)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

body.active_dark .a11y-large-cursor img {
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.35)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.7));
}

.a11y-reading-mask {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100008;
}

.a11y-reading-mask__shade {
  position: fixed;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.58);
  pointer-events: none;
  will-change: height, top;
}

.a11y-reading-mask__shade--top {
  top: 0;
}

.a11y-reading-mask__shade--bottom {
  bottom: auto;
}

html.a11y-panel-open,
body.a11y-panel-open {
  overflow: hidden;
  overscroll-behavior: none;
}

html:has(.a11y-shell) {
  overflow-x: clip;
}

/* Contenedor — recorta el panel fuera de pantalla sin scroll horizontal */
.a11y-shell {
  position: fixed;
  inset: 0;
  z-index: 100001;
  pointer-events: none;
  visibility: hidden;
  overflow: hidden;
}

.a11y-shell.is-open {
  pointer-events: auto;
  visibility: visible;
}

/* Overlay + panel lateral */
.a11y-overlay {
  position: absolute;
  inset: 0;
  background: var(--a11y-overlay);
  opacity: 0;
  transition: opacity 0.28s ease;
  backdrop-filter: blur(3px);
}

.a11y-shell.is-open .a11y-overlay {
  opacity: 1;
}

.a11y-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(340px, 100%);
  max-width: 100%;
  height: 100dvh;
  background: var(--a11y-surface);
  border-left: 1px solid var(--a11y-border);
  display: flex;
  flex-direction: column;
  transform: translate3d(100%, 0, 0);
  transition: transform 0.32s cubic-bezier(0.34, 1.1, 0.64, 1);
  color: var(--a11y-text);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  will-change: transform;
}

body.active_dark .a11y-panel {
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
}

.a11y-shell.is-open .a11y-panel {
  transform: translate3d(0, 0, 0);
}

.a11y-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--a11y-border);
  flex-shrink: 0;
}

.a11y-panel__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.a11y-panel__brand > span svg {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--a11y-text-muted);
}

.a11y-panel__title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
}

.a11y-panel__subtitle {
  margin: 1px 0 0;
  font-size: 0.7rem;
  color: var(--a11y-text-muted);
}

.a11y-panel__close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--a11y-border);
  border-radius: 7px;
  background: var(--a11y-surface-2);
  color: var(--a11y-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.a11y-panel__close:hover {
  color: var(--a11y-text);
  border-color: var(--a11y-text-muted);
}

.a11y-panel__body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.6rem 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Acordeones */
.a11y-accordion {
  border: 1px solid var(--a11y-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--a11y-surface-2);
}

.a11y-accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  user-select: none;
}

.a11y-accordion summary::-webkit-details-marker {
  display: none;
}

.a11y-accordion__chevron {
  flex-shrink: 0;
  transition: transform 0.25s ease;
  color: var(--a11y-text-faint);
}

.a11y-accordion[open] .a11y-accordion__chevron {
  transform: rotate(180deg);
}

.a11y-accordion__body {
  padding: 0 0.45rem 0.5rem;
  border-top: 1px solid var(--a11y-border);
}

.a11y-accordion--disabled .a11y-accordion__body {
  opacity: 0.55;
  pointer-events: none;
}

/* Lista de perfiles / idioma */
.a11y-radio-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0.3rem 0 0;
  padding: 0;
  list-style: none;
}

.a11y-radio-item {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--a11y-text);
  font: inherit;
  font-size: 0.74rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.a11y-radio-item:hover {
  background: var(--a11y-surface);
  border-color: var(--a11y-border);
}

.a11y-radio-item.is-active {
  background: var(--a11y-surface);
  border-color: var(--a11y-text-muted);
  font-weight: 600;
}

.a11y-radio-item__icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--a11y-text-muted);
}

.a11y-radio-item__dot {
  margin-left: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--a11y-border);
  flex-shrink: 0;
  position: relative;
}

.a11y-radio-item.is-active .a11y-radio-item__dot {
  border-color: var(--a11y-accent);
}

.a11y-radio-item.is-active .a11y-radio-item__dot::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--a11y-accent);
}

.a11y-badge {
  font-size: 0.62rem;
  padding: 1px 6px;
  border-radius: 20px;
  border: 1px solid var(--a11y-border);
  color: var(--a11y-text-faint);
}

/* Cubos de opciones */
.a11y-cubes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.a11y-cube {
  width: 100%;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid var(--a11y-border);
  border-radius: 7px;
  background: var(--a11y-surface-2);
  color: var(--a11y-text);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.a11y-cube:hover {
  border-color: var(--a11y-text-muted);
}

.a11y-cube.is-active {
  border-color: var(--a11y-accent);
  background: var(--a11y-surface);
}

.a11y-cube__icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--a11y-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--a11y-text-muted);
  background: var(--a11y-surface);
}

.a11y-cube.is-active .a11y-cube__icon {
  color: var(--a11y-text);
  border-color: var(--a11y-text-muted);
}

.a11y-cube__icon svg,
.a11y-toggle-row__icon svg,
.a11y-radio-item__icon svg {
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.a11y-cube__icon img,
.a11y-toggle-row__icon img {
  display: block;
  width: 16px;
  height: auto;
  filter: brightness(0.15);
}

body.active_dark .a11y-cube__icon img,
body.active_dark .a11y-toggle-row__icon img {
  filter: none;
}

.a11y-cube__label {
  font-weight: 600;
}

.a11y-micro-steps {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 2px 3px;
  background: var(--a11y-surface);
  border: 1px solid var(--a11y-border);
  border-radius: 5px;
  min-width: 44px;
  justify-content: center;
}

.a11y-micro-steps span {
  width: 10px;
  height: 4px;
  border-radius: 2px;
  background: var(--a11y-border);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.a11y-micro-steps span.is-active {
  background: var(--a11y-accent);
  transform: scaleY(1.35);
  box-shadow: 0 0 0 1px var(--a11y-accent);
}

.a11y-cube.is-active .a11y-micro-steps {
  border-color: var(--a11y-text-muted);
}

/* Filas con switch — toda la card es clicable */
button.a11y-toggle-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid var(--a11y-border);
  border-radius: 7px;
  background: var(--a11y-surface-2);
  color: var(--a11y-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.a11y-toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 1px solid var(--a11y-border);
  border-radius: 7px;
  background: var(--a11y-surface-2);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.a11y-toggle-row:hover {
  border-color: var(--a11y-text-muted);
}

.a11y-toggle-row.is-active {
  border-color: var(--a11y-accent);
  background: var(--a11y-surface);
}

.a11y-toggle-row__icon {
  width: 24px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--a11y-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--a11y-text-muted);
  background: var(--a11y-surface);
}

.a11y-toggle-row.is-active .a11y-toggle-row__icon {
  color: var(--a11y-text);
  border-color: var(--a11y-text-muted);
}

.a11y-toggle-row__label {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 0;
}

.a11y-switch {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  border: 1.5px solid var(--a11y-border);
  border-radius: 999px;
  background: var(--a11y-surface);
  padding: 0;
  pointer-events: none;
  transition: background 0.18s ease, border-color 0.18s ease;
}

button.a11y-toggle-row:focus-visible {
  outline: 2px solid var(--a11y-text-muted);
  outline-offset: 2px;
}

.a11y-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--a11y-text-muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s cubic-bezier(0.34, 1.2, 0.64, 1), background 0.18s ease;
}

.a11y-switch.is-on {
  background: var(--a11y-accent);
  border-color: var(--a11y-accent);
}

.a11y-switch.is-on::after {
  transform: translateX(16px);
  background: var(--a11y-surface);
}

body.active_dark .a11y-switch.is-on::after {
  background: #020202;
}

.a11y-switch:focus-visible {
  outline: none;
}

.a11y-reset {
  margin-top: auto;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--a11y-border);
  border-radius: 8px;
  background: transparent;
  color: var(--a11y-text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.a11y-reset:hover {
  background: var(--a11y-surface-2);
  border-color: var(--a11y-text-muted);
}

@media (max-width: 480px) {
  .a11y-panel {
    width: 100%;
  }
}

@media (hover: none), (pointer: coarse) {
  .a11y-large-cursor,
  html.a11y-large-cursor-on,
  html.a11y-large-cursor-on * {
    cursor: auto !important;
  }

  .a11y-large-cursor {
    display: none !important;
  }

  [data-a11y-toggle="largeCursor"] {
    display: none !important;
  }
}
