/* ==========================================================================
   components.css — Botones, tarjetas, formularios, avisos y cookies
   Grup SUERC
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Botones
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.82rem 1.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn__icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: currentColor;
}

.btn--primary {
  background-color: var(--accent-500);
  color: #fff;
  box-shadow: 0 4px 14px rgb(157 74 36 / 0.28);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background-color: var(--accent-600);
  box-shadow: 0 8px 22px rgb(157 74 36 / 0.34);
}

.btn--secondary {
  background-color: var(--ink-800);
  color: var(--cream-100);
}

.btn--secondary:hover,
.btn--secondary:focus-visible { background-color: var(--ink-900); }

.btn--ghost {
  background-color: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  background-color: var(--ink-800);
  border-color: var(--ink-800);
  color: var(--cream-100);
}

.btn--on-dark {
  background-color: transparent;
  border-color: rgb(248 243 236 / 0.42);
  color: var(--cream-50);
}

.btn--on-dark:hover,
.btn--on-dark:focus-visible {
  background-color: var(--cream-50);
  border-color: var(--cream-50);
  color: var(--ink-900);
}

.btn--small { padding: 0.55rem 1.1rem; font-size: 0.82rem; }
.btn--block { width: 100%; }

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* Enlace con flecha ----------------------------------------------------- */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  color: var(--accent-600);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
}

.link-arrow svg {
  width: 0.95em;
  height: 0.95em;
  fill: currentColor;
  transition: transform var(--dur) var(--ease);
}

.link-arrow:hover svg,
.link-arrow:focus-visible svg { transform: translateX(0.28rem); }

/* --------------------------------------------------------------------------
   2. Tarjetas de proyecto
   -------------------------------------------------------------------------- */
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  overflow: hidden;
  box-shadow: var(--shadow-s);
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.project-card:hover,
.project-card:focus-within {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-l);
}

.project-card__media {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background-color: var(--cream-200);
}

.project-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-slow) var(--ease);
}

/* Velo oscuro suave sobre la fotografía: mantiene legible la etiqueta
   superpuesta sea cual sea la imagen que se cargue. */
.project-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgb(16 14 12 / 0.42) 0%,
    rgb(16 14 12 / 0.14) 38%,
    rgb(16 14 12 / 0.10) 100%
  );
}

.project-card:hover .project-card__img,
.project-card:focus-within .project-card__img { transform: scale(1.06); }

/* Encuadre alternativo para fotografías verticales, donde el motivo
   interesante queda por encima del centro y un recorte centrado lo perdería. */
.project-card__img--top { object-position: center 35%; }

.project-card__tag {
  position: absolute;
  z-index: 2; /* por encima del velo */
  top: var(--space-xs);
  left: var(--space-xs);
  padding: 0.32rem 0.75rem;
  background-color: rgb(16 14 12 / 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-pill);
  color: var(--cream-50);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.project-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-m);
}

.project-card__title {
  font-size: var(--step-1);
  letter-spacing: -0.01em;
}

.project-card__title a {
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

.project-card__title a:hover { color: var(--accent-600); }

/* Toda la tarjeta es clicable a través del título */
.project-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.project-card__text {
  flex: 1;
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.65;
}

.project-card__foot {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-top: var(--space-2xs);
  color: var(--accent-600);
  font-size: var(--step--1);
  font-weight: 600;
}

.project-card__foot svg {
  width: 0.9em;
  height: 0.9em;
  fill: currentColor;
  transition: transform var(--dur) var(--ease);
}

.project-card:hover .project-card__foot svg { transform: translate(0.2rem, -0.2rem); }

/* --------------------------------------------------------------------------
   3. Tarjetas de valor / acción
   -------------------------------------------------------------------------- */
.feature {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.feature__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: var(--space-2xs);
  background-color: var(--cream-200);
  border-radius: var(--radius-m);
  color: var(--accent-600);
}

.section--inverse .feature__icon {
  background-color: rgb(248 243 236 / 0.08);
  color: var(--accent-300);
}

.feature__icon svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: currentColor;
}

.feature__title { font-size: var(--step-1); }

.feature__text {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.section--inverse .feature__text { color: var(--ink-300); }

/* Tarjeta de acción (enlace grande) ------------------------------------- */
.action-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-m);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  text-decoration: none;
  box-shadow: var(--shadow-s);
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.action-card:hover,
.action-card:focus-visible {
  transform: translateY(-5px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-m);
}

.action-card__title {
  font-size: var(--step-1);
  font-family: var(--font-display);
  font-weight: 600;
}

.action-card__text {
  color: var(--text-muted);
  font-size: var(--step--1);
}

/* Panel de datos -------------------------------------------------------- */
.panel {
  padding: clamp(1.25rem, 3vw, 2rem);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
}

.panel--muted {
  background-color: var(--bg-alt);
  box-shadow: none;
}

.panel--accent {
  border-left: 4px solid var(--accent-500);
  background-color: var(--cream-100);
  box-shadow: none;
}

/* Lista de datos -------------------------------------------------------- */
.data-list {
  display: grid;
  gap: 0.65rem 1.5rem;
  margin: 0;
}

@media (min-width: 40rem) {
  .data-list { grid-template-columns: minmax(9rem, auto) 1fr; }
}

.data-list dt {
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 600;
}

.data-list dd { margin: 0; }

@media (max-width: 39.999rem) {
  .data-list dd { margin-bottom: 0.4rem; }
}

/* Pasos numerados ------------------------------------------------------- */
.steps {
  display: grid;
  gap: var(--space-m);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps__item {
  position: relative;
  padding-left: 3.4rem;
  counter-increment: step;
}

.steps__item::before {
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  background-color: var(--accent-500);
  border-radius: var(--radius-pill);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.steps__title {
  margin-bottom: 0.25rem;
  font-size: var(--step-1);
}

.steps__item p { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   3 bis. Tarjeta de documento descargable
   -------------------------------------------------------------------------- */
.doc-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-s) var(--space-m);
  align-items: start;
  margin-top: var(--space-xl);
  padding: clamp(1.25rem, 3vw, 1.85rem);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-500);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-s);
}

.doc-card__icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  background-color: var(--cream-200);
  border-radius: var(--radius-m);
  color: var(--accent-600);
}

.doc-card__icon svg {
  width: 1.9rem;
  height: 1.9rem;
  fill: currentColor;
}

.doc-card__title {
  margin-bottom: 0.35rem;
  font-size: var(--step-1);
}

.doc-card__text {
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.7;
}

.doc-card__meta {
  margin-top: 0.5rem;
  color: var(--ink-300);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

/* El botón va debajo: el contenedor de esta sección es estrecho y en una
   sola fila dejaría la columna de texto sin espacio. */
.doc-card__action {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: var(--space-2xs);
}

/* A partir de tablet se alinea bajo el texto, no bajo el icono */
@media (min-width: 40rem) {
  .doc-card__action {
    grid-column: 2;
    margin-top: var(--space-s);
  }
}

/* --------------------------------------------------------------------------
   4. Formularios
   -------------------------------------------------------------------------- */
.form {
  display: grid;
  gap: var(--space-m);
}

.form__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-s) var(--space-m);
}

@media (min-width: 44rem) {
  .form__grid--2 { grid-template-columns: repeat(2, 1fr); }
  .form__field--full { grid-column: 1 / -1; }
}

.form__fieldset {
  padding: clamp(1.15rem, 3vw, 1.75rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background-color: var(--surface);
}

.form__legend {
  padding-inline: 0.5rem;
  margin-left: -0.5rem;
  color: var(--accent-600);
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form__label {
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-700);
}

.form__label .req {
  color: var(--danger);
  margin-left: 0.15em;
}

.form__hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.form__control {
  width: 100%;
  padding: 0.72rem 0.9rem;
  background-color: var(--cream-50);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  font-size: var(--step-0);
  line-height: 1.5;
  transition:
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.form__control::placeholder { color: var(--ink-300); }

.form__control:hover { border-color: var(--ink-300); }

.form__control:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--accent-500);
  box-shadow: 0 0 0 3px rgb(180 85 45 / 0.16);
}

textarea.form__control {
  min-height: 9rem;
  resize: vertical;
}

select.form__control {
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b6058' d='M8 11.2 2.8 6l1.1-1.1L8 9l4.1-4.1L13.2 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem;
  cursor: pointer;
}

input[type="file"].form__control {
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

input[type="file"].form__control::file-selector-button {
  margin-right: 0.9rem;
  padding: 0.4rem 0.9rem;
  background-color: var(--ink-800);
  border: 0;
  border-radius: var(--radius-pill);
  color: var(--cream-100);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

/* Estados de validación ------------------------------------------------- */
.form__control[aria-invalid="true"] {
  border-color: var(--danger);
  background-color: #fdf6f5;
}

.form__control[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgb(168 50 43 / 0.16);
}

.form__error {
  display: none;
  align-items: center;
  gap: 0.4em;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
}

.form__error.is-active { display: flex; }

.form__error::before {
  content: "";
  flex: none;
  width: 0.95em;
  height: 0.95em;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1zm.75 10.5h-1.5V10h1.5zm0-2.75h-1.5v-4h1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Casillas y radios ----------------------------------------------------- */
.form__check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: start;
  cursor: pointer;
}

.form__check input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
  accent-color: var(--accent-500);
  cursor: pointer;
}

.form__check-text {
  font-size: var(--step--1);
  line-height: 1.6;
}

.form__check-text a {
  color: var(--accent-600);
  font-weight: 600;
}

.form__check-group {
  display: grid;
  gap: 0.75rem;
}

/* Opciones tipo tarjeta ------------------------------------------------- */
.option-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: start;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background-color: var(--cream-50);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.option-card:hover { border-color: var(--ink-300); }

.option-card:has(input:checked) {
  border-color: var(--accent-500);
  background-color: #fff;
  box-shadow: 0 0 0 2px rgb(180 85 45 / 0.14);
}

.option-card input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
  accent-color: var(--accent-500);
  cursor: pointer;
}

.option-card__title {
  display: block;
  font-weight: 600;
  font-size: var(--step--1);
}

.option-card__text {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

/* Honeypot antispam ----------------------------------------------------- */
.form__hp {
  position: absolute !important;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Avisos de formulario -------------------------------------------------- */
.form__status {
  display: none;
  gap: 0.75rem;
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius-m);
  font-size: var(--step--1);
  line-height: 1.6;
}

.form__status.is-active { display: flex; }

.form__status--error {
  background-color: #fdf3f2;
  border: 1px solid #e8c4c1;
  color: #7d241f;
}

.form__status--info {
  background-color: #f2f5f8;
  border: 1px solid #ccd8e2;
  color: #2c455e;
}

.form__status--success {
  background-color: #f1f6f2;
  border: 1px solid #c3ddc9;
  color: #2c5238;
}

.form__status strong { display: block; }

/* --------------------------------------------------------------------------
   5. Avisos genéricos
   -------------------------------------------------------------------------- */
.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-s);
  padding: var(--space-m);
  background-color: var(--cream-100);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-500);
  border-radius: var(--radius-m);
  font-size: var(--step--1);
  line-height: 1.7;
}

.notice__icon {
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 0.15rem;
  fill: var(--accent-600);
}

.notice--dev {
  background-color: #f4f6f9;
  border-left-color: #5c7a99;
}

.notice--dev .notice__icon { fill: #4a6785; }

/* --------------------------------------------------------------------------
   6. Banner y panel de cookies
   -------------------------------------------------------------------------- */
.cookie-banner {
  position: fixed;
  z-index: 150;
  left: var(--space-s);
  right: var(--space-s);
  bottom: var(--space-s);
  max-width: 40rem;
  margin-inline: auto;
  padding: clamp(1.15rem, 3vw, 1.6rem);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-l);
  transform: translateY(130%);
  visibility: hidden;
  /* Igual que el menú: `visibility` debe ser inmediata al abrir para que
     focus() alcance los botones del aviso. */
  transition:
    transform var(--dur-slow) var(--ease),
    visibility 0s linear var(--dur-slow);
}

.cookie-banner.is-visible {
  transform: translateY(0);
  visibility: visible;
  transition:
    transform var(--dur-slow) var(--ease),
    visibility 0s linear 0s;
}

.cookie-banner__title {
  margin-bottom: 0.35rem;
  font-size: var(--step-1);
}

.cookie-banner__text {
  margin-bottom: var(--space-s);
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.65;
}

.cookie-banner__text a {
  color: var(--accent-600);
  font-weight: 600;
}

.cookie-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.cookie-banner__actions .btn { flex: 1 1 9rem; }

/* Preferencias ---------------------------------------------------------- */
.cookie-prefs {
  display: none;
  margin-block: var(--space-s);
  padding-top: var(--space-s);
  border-top: 1px solid var(--border);
}

.cookie-prefs.is-open { display: block; }

.cookie-prefs__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-s);
  padding-block: 0.7rem;
}

.cookie-prefs__row + .cookie-prefs__row { border-top: 1px dashed var(--border); }

.cookie-prefs__name {
  display: block;
  font-size: var(--step--1);
  font-weight: 600;
}

.cookie-prefs__desc {
  display: block;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Interruptor ----------------------------------------------------------- */
.switch {
  position: relative;
  flex: none;
  width: 2.9rem;
  height: 1.6rem;
  margin-top: 0.1rem;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch__track {
  display: block;
  width: 100%;
  height: 100%;
  background-color: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background-color var(--dur-fast) var(--ease);
  pointer-events: none;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.2rem;
  height: 1.2rem;
  background-color: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow-s);
  transition: transform var(--dur-fast) var(--ease);
}

.switch input:checked ~ .switch__track { background-color: var(--accent-500); }
.switch input:checked ~ .switch__track::after { transform: translateX(1.3rem); }

.switch input:disabled ~ .switch__track {
  background-color: var(--olive-500);
  opacity: 0.55;
  cursor: not-allowed;
}

.switch input:focus-visible ~ .switch__track {
  outline: 3px solid var(--accent-400);
  outline-offset: 3px;
}

/* Botón flotante para reabrir preferencias ------------------------------ */
.cookie-reopen {
  position: fixed;
  z-index: 80;
  left: var(--space-s);
  bottom: var(--space-s);
  display: none;
  align-items: center;
  gap: 0.45em;
  padding: 0.5rem 0.95rem;
  background-color: var(--ink-800);
  border-radius: var(--radius-pill);
  color: var(--cream-100);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-m);
  transition: background-color var(--dur-fast) var(--ease);
}

.cookie-reopen.is-visible { display: inline-flex; }
.cookie-reopen:hover { background-color: var(--accent-500); }

.cookie-reopen svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
}

/* --------------------------------------------------------------------------
   7. Botón «volver arriba»
   -------------------------------------------------------------------------- */
.to-top {
  position: fixed;
  z-index: 80;
  right: var(--space-s);
  bottom: var(--space-s);
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  background-color: var(--ink-800);
  border-radius: var(--radius-pill);
  color: var(--cream-100);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.75rem);
  box-shadow: var(--shadow-m);
  transition:
    opacity var(--dur) var(--ease),
    visibility var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    background-color var(--dur-fast) var(--ease);
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.to-top:hover { background-color: var(--accent-500); }

.to-top svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}
