/* Preguntas (#preguntas). Una sola columna estrecha y centrada: titular de 40 px, 7 preguntas en <details> y
   «¿Tu pregunta no está?». Cerradas, en Supreme 500 a 20 px; la abierta, en Excon 600 a 24 px, sin caja y con
   una línea verde a la izquierda. Fondo: lo pone base.css (data-tone="surface"). Todos los selectores empiezan por #preguntas. */

#preguntas {
  --faq-bleed: 14px;   /* lo que el fondo del hover sobresale de la columna */
}

/* ---------- Composición ---------- */
#preguntas .faq { display: grid; gap: clamp(24px, 3vw, 40px); max-width: 760px; margin-inline: auto; }
#preguntas .faq-head { display: grid; gap: 12px; }
#preguntas .faq-title { font-size: var(--fs-h2); }

/* ---------- Lista ---------- */
#preguntas .faq-item { position: relative; }
/* Abierta: sin caja; una línea verde a la izquierda, fuera de la columna. */
#preguntas .faq-item::after {
  content: ""; position: absolute; left: -18px; top: 18px; bottom: 22px; width: 2px; border-radius: 1px;
  background: var(--human); transform: scaleY(0); transform-origin: 50% 0;
  transition: transform 0.3s var(--ease-out);
  pointer-events: none;
}
#preguntas .faq-item[open]:not(.is-shut)::after { transform: scaleY(1); }

/* Línea fina sobre cada fila (y sobre el campo). Se dibuja de izquierda a derecha al entrar;
   se vuelve verde en la fila que coincide con lo que escribes y se apaga alrededor de la abierta. */
#preguntas .faq-line {
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: var(--line-2);
  transform-origin: 0 50%;
  pointer-events: none;
  transition: background-color 0.3s var(--ease-out), opacity 0.3s var(--ease-out);
}
#preguntas .faq-item.is-match .faq-line { background: var(--human); opacity: 1; }
/* La fila que ya responde a lo que escribes: verde, porque la pregunta es tuya. */
#preguntas .faq-item.is-match .faq-q::before { opacity: 1; background: rgba(125, 219, 140, 0.08); }
#preguntas .faq-item.is-match .faq-icon { color: var(--human); }

#preguntas .faq-q {
  position: relative; isolation: isolate;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 56px;
  padding: clamp(16px, 1.7vw, 24px) 0;
  list-style: none; cursor: pointer;
  font-family: var(--font-text);
  font-size: 1.25rem;
  font-weight: 500; line-height: 1.3; letter-spacing: -0.005em;
  color: var(--text-2);
  text-wrap: balance;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.25s var(--ease-out);
}
#preguntas .faq-q::-webkit-details-marker { display: none; }
#preguntas .faq-q::marker { content: ""; }
/* Fondo que aclara la fila (hover) o la marca un momento (al llegar desde una sugerencia). */
#preguntas .faq-q::before {
  content: ""; position: absolute; z-index: -1;
  inset: 1px calc(var(--faq-bleed) * -1) 0;
  border-radius: var(--radius-lg);
  background: rgba(238, 240, 247, 0.035);
  opacity: 0;
  transition: opacity 0.3s var(--ease-out), background-color 0.3s var(--ease-out);
}
#preguntas .faq-q:focus-visible { outline-offset: 2px; border-radius: 6px; }
#preguntas .faq-q-text { transition: transform 0.16s var(--ease-out); transform-origin: 0 50%; }
#preguntas .faq-q:active .faq-q-text { transform: scale(0.97); }

/* + que gira a × */
#preguntas .faq-icon {
  position: relative; flex: none; width: 22px; height: 22px;
  color: var(--text-3);
  transition: rotate 0.3s var(--ease-out), color 0.25s var(--ease-out), scale 0.16s var(--ease-out);
}
#preguntas .faq-icon::before,
#preguntas .faq-icon::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 16px; height: 1.75px; margin: -0.875px 0 0 -8px;
  border-radius: 1px; background: currentColor;
}
#preguntas .faq-icon::after { rotate: 90deg; }
#preguntas .faq-q:active .faq-icon { scale: 0.97; }

#preguntas .faq-item[open]:not(.is-shut) .faq-q {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; line-height: 1.2; letter-spacing: -0.018em;
  color: var(--text);
}
#preguntas .faq-item[open]:not(.is-shut) .faq-icon { rotate: 135deg; color: var(--text); }
#preguntas .faq-item.is-match .faq-q { color: var(--text); }

/* Respuesta: grid-template-rows de 0fr a 1fr en 0,3 s. Sin JS, [open] basta. */
#preguntas .faq-a {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s var(--ease-out);
}
#preguntas .faq-item[open] .faq-a { grid-template-rows: 1fr; }
#preguntas .faq-item.is-shut .faq-a { grid-template-rows: 0fr; }
#preguntas .faq-a-inner { min-height: 0; overflow: hidden; }
#preguntas .faq-a-inner > * {
  opacity: 1; translate: 0 0;
  transition: opacity 0.3s var(--ease-out), translate 0.3s var(--ease-out);
}
#preguntas .faq-item.is-shut .faq-a-inner > * { opacity: 0; translate: 0 -6px; transition-duration: 0.2s; }

#preguntas .faq-a p {
  max-width: 58ch;
  padding-right: clamp(0px, 5vw, 56px);
  padding-bottom: clamp(22px, 2.2vw, 30px);
  font-size: clamp(1rem, 0.94rem + 0.25vw, 1.125rem);
  line-height: 1.6; color: var(--text);
  text-wrap: pretty;
}
#preguntas .faq-a strong { font-weight: 700; color: var(--text); }
#preguntas .faq-a .human { color: var(--human); }
#preguntas .faq-a p:has(+ .faq-cta) { padding-bottom: 4px; }

/* El formato que elegiste en Formatos se marca en la respuesta de FUNDAE. */
#preguntas .faq-fmt { transition: color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out); }
#preguntas .faq-fmt.is-picked { color: var(--text); box-shadow: inset 0 -2px 0 var(--human); }

/* Enlace «Pedir propuesta» dentro de una respuesta */
#preguntas .faq-cta {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; margin-bottom: clamp(14px, 1.6vw, 20px);
  font-weight: 700; color: var(--ai); text-decoration: none;
  transition: color 0.25s var(--ease-out), transform 0.16s var(--ease-out);
}
#preguntas .faq-cta:active { transform: scale(0.97); }

/* ---------- Tu pregunta: la novena fila, la escribes tú ---------- */
#preguntas .faq-ask { position: relative; padding-top: clamp(22px, 2.2vw, 30px); }
#preguntas .faq-ask-label { display: block; font-size: var(--fs-small); font-weight: 500; color: var(--text-2); }
#preguntas .faq-ask-row { display: flex; align-items: flex-end; gap: clamp(16px, 2vw, 24px); margin-top: 4px; }
#preguntas .faq-ask-field { position: relative; flex: 1 1 auto; min-width: 0; }
#preguntas .faq-ask-field::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: var(--line-2);
  transition: background-color 0.25s var(--ease-out), height 0.2s var(--ease-out);
}
/* El foco del campo es su línea: pasa a verde (escribe una persona) y a 2 px. */
#preguntas .faq-ask-field:focus-within::after { height: 2px; background: var(--human); }
#preguntas .faq-ask.is-error .faq-ask-field::after { height: 2px; background: var(--error); }

#preguntas .faq-ask-input {
  display: block; width: 100%; min-height: 56px; padding: 8px 0 10px;
  border: 0; border-radius: 0; background: transparent; outline: none;
  font-family: var(--font-text);
  font-size: 1.25rem;
  font-weight: 500; line-height: 1.3;
  color: var(--text); caret-color: var(--human);
}
#preguntas .faq-ask-input::placeholder { color: var(--text-3); opacity: 1; }
#preguntas .faq-ask-input:focus-visible { outline: none; }

/* Cursor verde que espera tu pregunta: solo con el campo vacío y sin foco. */
#preguntas .faq-ask-caret {
  position: absolute; left: -7px; top: 50%; height: 1.15em; margin: 0;
  font-size: 1.25rem;
  translate: 0 -55%;
  pointer-events: none;
}
#preguntas .faq-ask-input:focus + .faq-ask-caret,
#preguntas .faq-ask-input:not(:placeholder-shown) + .faq-ask-caret { display: none; }

/* «Preguntar»: contorno con el campo vacío; se rellena en cuanto escribes. */
#preguntas .faq-ask-btn {
  flex: none;
  background: transparent; color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
#preguntas .faq-ask.has-text .faq-ask-btn { background: var(--text); color: var(--ink); box-shadow: none; }

#preguntas .faq-ask-status {
  margin-top: 10px;
  font-size: var(--fs-small); line-height: 1.5; color: var(--text-2);
}
#preguntas .faq-ask-status:empty { display: none; }
#preguntas .faq-ask-status > span { display: block; padding-block: 10px; animation: fade-in 0.3s var(--ease-out); }
#preguntas .faq-ask-status .is-error { color: var(--error); }
#preguntas .faq-ask-status .is-ok { color: var(--text); }
#preguntas .faq-ask-status .faq-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; padding-block: 0; }
#preguntas .faq-hint-go {
  display: inline-flex; align-items: center; min-height: 44px;
  font-weight: 700; color: var(--human); text-align: left;
  text-decoration: underline; text-decoration-color: rgba(125, 219, 140, 0.4);
  text-decoration-thickness: 1px; text-underline-offset: 4px;
  transition: text-decoration-color 0.25s var(--ease-out), transform 0.16s var(--ease-out);
}
#preguntas .faq-hint-go:active { transform: scale(0.97); }

/* Fila marcada un momento al llegar desde una sugerencia */
#preguntas .faq-item.is-flash .faq-q::before { opacity: 1; background: var(--human-soft); }

/* ---------- Escritorio: el aviso del campo no empuja nada ---------- */
@media (min-width: 1024px) {
  #preguntas .faq-ask-status { position: absolute; top: 100%; left: 0; right: 0; }
}

/* ---------- Solo con ratón ---------- */
@media (hover: hover) and (pointer: fine) {
  #preguntas .faq-q:hover { color: var(--text); }
  #preguntas .faq-q:hover::before { opacity: 1; }
  #preguntas .faq-q:hover .faq-icon { color: var(--text); }
  #preguntas .faq-cta:hover { color: var(--ai-2); }
  #preguntas .faq-cta:hover .btn-arrow { translate: 3px 0; }
  #preguntas .faq-ask-btn:hover { box-shadow: inset 0 0 0 1px var(--text-2); }
  #preguntas .faq-ask.has-text .faq-ask-btn:hover { translate: 0 -1px; background: #fff; }
  #preguntas .faq-hint-go:hover { text-decoration-color: currentColor; }
}

/* ---------- Móvil ---------- */
@media (max-width: 767px) {
  #preguntas .faq-item::after { left: -10px; }
  #preguntas .faq-q { gap: 16px; font-size: 1.0625rem; }
  #preguntas .faq-item[open]:not(.is-shut) .faq-q { font-size: 1.25rem; }
  #preguntas .faq-ask-input, #preguntas .faq-ask-caret { font-size: 1.0625rem; }
  #preguntas .faq-icon { width: 20px; height: 20px; }
  #preguntas .faq-icon::before, #preguntas .faq-icon::after { width: 14px; margin-left: -7px; }
  #preguntas .faq-ask-row { flex-direction: column; align-items: stretch; gap: 16px; }
  #preguntas .faq-ask-btn { width: 100%; }
  #preguntas .faq-ask-caret { left: -6px; }
}

/* Polvo de las respuestas (preguntas.js): encima de la lista y sin coger clics. */
#preguntas [data-faq-list] { position: relative; }
#preguntas .faq-dust { position: absolute; inset: -16px; width: calc(100% + 32px); height: calc(100% + 32px); pointer-events: none; z-index: 2; }

/* Enlaces dentro de una respuesta (FUNDAE → Niveles): subrayados siempre. */
#preguntas .faq-a-inner .link { color: var(--text); background-size: 100% 1px; }
