/* =====================================================================
   SORAIN – tarjetas con hover tipo acordeón (Home)
   · What we do (.cards / .card)
   · Engineering experience (.tiles / .tile)
   · Enter at 01 / 03 / 05 (.entries / .entry)

   Al pasar el mouse (o enfocar con el teclado) la tarjeta crece y muestra su
   descripción; las demás se encogen. Transición de 480 ms con la curva
   cubic-bezier(.33, .01, .2, 1). La lógica (qué tarjeta está activa y el
   alto real de cada descripción, --dh) vive en js/accordion.js.
   ===================================================================== */

:root {
  --ease-acc: cubic-bezier(0.33, 0.01, 0.2, 1);
  --t-acc: 0.48s;
}

/* Contenido de las tarjetas (todas las pantallas)
   --------------------------------------------------------------------- */
.card .desc,
.tile .desc {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}
.card .desc {
  color: rgba(255, 255, 255, 0.92);
}
.tile .desc {
  margin-top: 6px;
  color: #c6cce3;
}

.card .go {
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.tile {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* Escritorio con mouse: acordeón
   --------------------------------------------------------------------- */
@media (min-width: 1001px) and (hover: hover) {
  /* --- What we do --- */
  .cards {
    --card-pad: 36px;
    display: flex;
    align-items: center;
    gap: 20px;
    height: 320px;
    margin-top: 40px;
    margin-bottom: -44px;
    container-type: inline-size;
  }

  .card {
    flex: 1 1 0;
    min-width: 0;
    height: 232px;
    min-height: 0;
    padding: var(--card-pad);
    transition:
      flex-grow var(--t-acc) var(--ease-acc),
      height var(--t-acc) var(--ease-acc),
      box-shadow var(--t-acc) var(--ease-acc),
      opacity 0.8s ease,
      transform 0.8s ease;
  }
  .card:hover {
    transform: none;
  }

  .cards.is-open .card.is-active {
    flex-grow: 2.1;
    height: 320px;
    box-shadow: 0 28px 60px -24px rgba(70, 40, 160, 0.85);
  }

  /* Título con saltos de línea fijos (una palabra por línea):
     no se re-acomoda mientras la tarjeta cambia de ancho. */
  /* Título con el ancho de la tarjeta CERRADA: los saltos de línea no cambian mientras la tarjeta
     se ensancha y ninguna palabra larga (p. ej. "Administrados") se sale de la tarjeta. */
  .card h3 {
    flex-shrink: 0;
    width: calc((100cqw - 60px) / 5.1 - 2 * var(--card-pad));
    line-height: 1.15;
    overflow-wrap: normal;
  }
  html[lang='es'] .card h3 {
    font-size: 19px;
  }

  /* La descripción tiene SIEMPRE el ancho de la tarjeta abierta:
     no cambia de número de líneas mientras la tarjeta se ensancha. */
  .card .desc {
    flex-shrink: 0;
    width: calc((100cqw - 60px) * 2.1 / 5.1 - 2 * var(--card-pad));
  }

  .card .go {
    transition: opacity 0.3s ease 0.12s;
  }
  .cards.is-open .card:not(.is-active) .go {
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  /* --- Engineering experience --- */
  .tiles {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 300px;
    margin-bottom: -40px;
    container-type: inline-size;
  }

  .tile {
    flex: 1 1 0;
    min-width: 0;
    height: 220px;
    min-height: 0;
    padding: 18px;
    transition:
      flex-grow var(--t-acc) var(--ease-acc),
      height var(--t-acc) var(--ease-acc),
      border-color var(--t-acc) ease,
      opacity 0.8s ease,
      transform 0.8s ease;
  }

  .tiles.is-open .tile.is-active {
    flex-grow: 1.94;
    height: 300px;
    border-color: rgba(185, 150, 245, 0.55);
  }

  .tile h3 {
    flex-shrink: 0;
    width: calc((100cqw - 32px) / 3.94 - 36px);
  }
  html[lang='es'] .tile h3 {
    font-size: 14px;
  }

  .tile .desc {
    flex-shrink: 0;
    width: calc((100cqw - 32px) * 1.94 / 3.94 - 36px);
  }

  /* --- Apertura de la descripción (tarjetas y tiles) ---
     .dw envuelve la descripción y se anima de 0 a su alto REAL (--dh), con la
     misma duración y curva que la tarjeta: el título se mueve en un solo
     movimiento continuo, sin rebote. */
  .card .dw,
  .tile .dw {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    height: 0;
    overflow: hidden;
    transition: height var(--t-acc) var(--ease-acc);
  }
  .card.is-active .dw,
  .tile.is-active .dw {
    height: var(--dh, auto);
  }

  .card .dw > .desc,
  .tile .dw > .desc {
    margin: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .card.is-active .dw > .desc,
  .tile.is-active .dw > .desc {
    opacity: 1;
    transition: opacity 0.32s ease 0.14s;
  }
  .tile .dw > .desc {
    padding-top: 8px;
  }
}

/* Escritorio angosto: tarjetas un poco más compactas */
@media (min-width: 1001px) and (max-width: 1240px) and (hover: hover) {
  .cards {
    --card-pad: 28px;
  }
  .card .ic {
    top: 28px;
    left: 28px;
  }
  .card h3 {
    font-size: 19px;
  }
  .card .go {
    font-size: 12.5px;
  }
  html[lang='es'] .card h3 {
    font-size: 17px;
  }
  /* más ancho para las tiles de experiencia: los títulos en español caben sin cortarse */
  .exp .wrap {
    grid-template-columns: 0.8fr 1.5fr;
    gap: 40px;
  }
}

/* Enter at 01 / 03 / 05
   Al pasar el mouse (o enfocar / tocar) la tarjeta se vuelve morada, se
   levanta un poco y aparece el texto extra (.more-info).
   --------------------------------------------------------------------- */
.entries {
  align-items: start;
}

.entry {
  transition:
    background-color var(--t-acc) var(--ease-acc),
    border-color var(--t-acc) var(--ease-acc),
    box-shadow var(--t-acc) var(--ease-acc),
    transform var(--t-acc) var(--ease-acc);
}
.entry .ic {
  transition:
    background-color var(--t-acc) var(--ease-acc),
    border-color var(--t-acc) var(--ease-acc);
}
.entry .ic .material-symbols-outlined,
.entry small,
.entry h3,
.entry p {
  transition: color var(--t-acc) var(--ease-acc);
}

.entry .more-info {
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  transition:
    max-height var(--t-acc) var(--ease-acc),
    margin-top var(--t-acc) var(--ease-acc),
    opacity 0.22s ease,
    color var(--t-acc) var(--ease-acc);
}

.entry:hover,
.entry.in-focus,
.entry:focus-within {
  border-color: rgba(255, 255, 255, 0.22);
  outline: none;
  background: #8b3dd9;
  box-shadow:
    0 0 11px rgba(165, 43, 235, 0.66),
    0 28px 60px -24px rgba(70, 40, 160, 0.85);
  transform: translateY(-6px);
}
.entry:hover .ic,
.entry.in-focus .ic,
.entry:focus-within .ic {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.16);
}
.entry:hover .ic .material-symbols-outlined,
.entry.in-focus .ic .material-symbols-outlined,
.entry:focus-within .ic .material-symbols-outlined,
.entry:hover h3,
.entry.in-focus h3,
.entry:focus-within h3 {
  color: #fff;
}
.entry:hover small,
.entry.in-focus small,
.entry:focus-within small {
  color: rgba(255, 255, 255, 0.85);
}
.entry:hover p,
.entry.in-focus p,
.entry:focus-within p {
  color: rgba(255, 255, 255, 0.9);
}
.entry:hover .more-info,
.entry.is-revealed .more-info,
.entry:focus-within .more-info {
  max-height: 12em;
  margin-top: 10px;
  opacity: 1;
  transition:
    max-height var(--t-acc) var(--ease-acc),
    margin-top var(--t-acc) var(--ease-acc),
    opacity 0.38s ease 0.16s,
    color var(--t-acc) var(--ease-acc);
}

/* Escritorio con mouse: acordeón horizontal igual que "What we do".
   La tarjeta activa se ensancha (1.8×) y crece desde el centro. */
@media (min-width: 1001px) and (hover: hover) {
  .entries {
    display: flex;
    align-items: center;
    height: 228px;
    margin-top: -22px;
    margin-bottom: -30px;
    container-type: inline-size;
  }

  .entry {
    flex: 1 1 0;
    min-width: 0;
    height: 168px;
    overflow: hidden;
    transition:
      flex-grow var(--t-acc) var(--ease-acc),
      height var(--t-acc) var(--ease-acc),
      background-color var(--t-acc) var(--ease-acc),
      border-color var(--t-acc) var(--ease-acc),
      box-shadow var(--t-acc) var(--ease-acc);
  }
  .entry > div {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }
  .entry:hover,
  .entry:focus-within {
    flex-grow: 1.8;
    height: 228px;
    transform: none;
  }

  /* Anchos fijos para que ningún texto se re-acomode mientras la tarjeta cambia de ancho:
     el párrafo principal conserva el ancho cerrado y el texto extra ya tiene el ancho abierto. */
  .entry > div > p:not(.more-info) {
    width: calc((100cqw - 40px) / 3 - 114px);
    transition:
      opacity 0.3s ease 0.12s,
      color var(--t-acc) var(--ease-acc);
  }
  .entry .more-info {
    width: calc((100cqw - 40px) * 1.8 / 3.8 - 114px);
    transition:
      max-height var(--t-acc) var(--ease-acc),
      margin-top var(--t-acc) var(--ease-acc),
      opacity 0.15s ease,
      color var(--t-acc) var(--ease-acc);
  }
  /* el texto extra aparece cuando la tarjeta ya casi terminó de abrirse */
  .entry:hover .more-info,
  .entry:focus-within .more-info {
    transition:
      max-height var(--t-acc) var(--ease-acc),
      margin-top var(--t-acc) var(--ease-acc),
      opacity 0.3s ease 0.3s,
      color var(--t-acc) var(--ease-acc);
  }

  /* las tarjetas que se encogen esconden su párrafo */
  .entries:has(.entry:hover) .entry:not(:hover) > div > p:not(.more-info),
  .entries:has(.entry:focus-within):not(:has(.entry:hover)) .entry:not(:focus-within) > div > p:not(.more-info) {
    opacity: 0;
    transition: opacity 0.2s ease;
  }
}

/* Escritorio más angosto: el texto ocupa más líneas, la tarjeta cerrada necesita más alto */
@media (min-width: 1001px) and (max-width: 1180px) and (hover: hover) {
  .entries {
    height: 250px;
    margin-top: -23px;
    margin-bottom: -31px;
  }
  .entry {
    height: 188px;
  }
  .entry:hover,
  .entry:focus-within {
    height: 250px;
  }
}

/* Táctil / pantallas ≤ 1000px: sin acordeón; deja espacio para el ícono
   --------------------------------------------------------------------- */
@media (max-width: 1000px), (hover: none) {
  .card {
    min-height: 0;
    padding-top: 112px;
  }
  .tile {
    padding-top: 80px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .tile,
  .card .desc,
  .tile .desc,
  .card .dw,
  .tile .dw,
  .entry,
  .entry .more-info {
    transition: none !important;
  }
  .entry:hover,
  .entry:focus-within {
    transform: none;
  }
}
