/*
 * Post Carousel (port sin React de la plantilla de Scrolltide, oct-2026).
 *
 * Slides and neighbours are placed entirely by `data-d` — their distance from
 * the current slide — so changing slide is one attribute per element and the
 * transitions below do the choreography.
 *
 * Las vecinas salen ~0,8 del ancho del post hacia cada lado: el contenedor
 * tiene que llevar overflow-x: clip para no abrir scroll lateral.
 */

.pc {
  --pc-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --pc-time: 0.55s;
  --pc-head: 56px;

  display: flex;
  justify-content: center;
  color: var(--pc-text);
  font-size: 14px;
  text-align: left;
  outline: none;
}

.pc:focus-visible .pc__post {
  box-shadow: 0 0 0 2px var(--pc-focus);
}

.pc__inner {
  position: relative;
  width: var(--pc-w);
  max-width: 100%;
}

/* --- the post --------------------------------------------------------------- */

.pc__post {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border-radius: var(--pc-radius);
  background: var(--pc-card);
  box-shadow: 0 0 0 1px var(--pc-border), 0 30px 80px -30px rgba(0, 0, 0, 0.45);
}

.pc__head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--pc-head);
  padding: 0 12px;
}

.pc__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--pc-control);
  color: var(--pc-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px var(--pc-border);
}
.pc__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pc__who {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.pc__name {
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}
a.pc__name:hover {
  text-decoration: underline;
}
.pc__subline {
  overflow: hidden;
  color: var(--pc-muted);
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pc__icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: inherit;
  cursor: pointer;
}
.pc__icon-btn svg {
  width: 24px;
  height: 24px;
}
.pc__icon-btn:focus-visible,
.pc__arrow:focus-visible,
a.pc__name:focus-visible {
  outline: 2px solid var(--pc-focus);
  outline-offset: 1px;
}

/* --- media ------------------------------------------------------------------ */

.pc__media {
  position: relative;
  height: var(--pc-media-h);
  overflow: hidden;
  background: #000;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.pc__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  translate: 0 0;
  transition:
    opacity var(--pc-time) var(--pc-ease),
    translate var(--pc-time) var(--pc-ease);
}
.pc__slide[data-d='-1'] {
  translate: -50px 0;
}
.pc__slide[data-d='1'] {
  translate: 50px 0;
}
.pc__slide[data-d='0'] {
  opacity: 1;
  z-index: 1;
}
.pc__slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.pc__arrow {
  position: absolute;
  z-index: 3;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(20 20 22 / 0.55);
  color: #fff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background 0.2s ease;
}
.pc__arrow:hover {
  background: rgb(20 20 22 / 0.75);
}
.pc__arrow svg {
  width: 18px;
  height: 18px;
}
.pc__arrow[hidden] {
  display: none;
}
.pc__arrow--prev {
  left: 12px;
}
.pc__arrow--next {
  right: 12px;
}

.pc__dots {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 14px;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}
.pc__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.42);
  transition: background 0.3s ease;
}
.pc__dots span.is-active {
  background: #fff;
}

/* Con más de 10 fotos: contador arriba a la derecha, como en Instagram. */
.pc__contador {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgb(20 20 22 / 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

/* Double-tap heart. */
.pc__burst {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 88px;
  height: 88px;
  translate: -50% -50%;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 4px 18px rgb(0 0 0 / 0.35));
}
.pc__burst svg {
  width: 100%;
  height: 100%;
}
.pc__burst.is-on {
  animation: pc-burst 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pc-burst {
  0% { opacity: 0; scale: 0.3; }
  18% { opacity: 1; scale: 1.12; }
  32% { scale: 0.94; }
  45% { scale: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; scale: 1.05; }
}

/* --- actions and caption ---------------------------------------------------- */

.pc__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 0;
}
.pc__save {
  margin-left: auto;
}
.pc__like svg {
  transition: color 0.2s ease;
}
.pc__like.is-liked {
  color: var(--pc-like);
}
.pc__like.is-liked svg {
  animation: pc-pop 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pc-pop {
  35% { scale: 1.3; }
  60% { scale: 0.92; }
}

.pc__caption {
  margin: 0;
  padding: 6px 12px 14px;
  line-height: 1.4;
}
.pc__caption strong {
  font-weight: 600;
}

/* --- neighbours ---------------------------------------------------------------
   Behind the post, centred on its media. The current slide's copy waits
   hidden behind the post, so a slide becoming a neighbour visibly travels out
   from under it. */

.pc__sides {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: calc(var(--pc-head) + var(--pc-media-h) / 2);
  width: 0;
  height: 0;
}

.pc__side {
  position: absolute;
  left: calc(var(--pc-w) / -2);
  top: calc(var(--pc-media-h) / -2);
  width: var(--pc-w);
  height: var(--pc-media-h);
  overflow: hidden;
  border-radius: calc(var(--pc-radius) / var(--pc-side-scale) * 0.5);
  opacity: 0;
  pointer-events: none;
  transition:
    translate var(--pc-time) var(--pc-ease),
    scale var(--pc-time) var(--pc-ease),
    opacity var(--pc-time) var(--pc-ease);
}
.pc__side img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}

.pc__side[data-d='-1'],
.pc__side[data-d='1'] {
  opacity: var(--pc-side-op);
  scale: var(--pc-side-scale);
  pointer-events: auto;
  cursor: pointer;
}
.pc__side[data-d='-1'] {
  translate: calc(var(--pc-side-x) * -1) 0;
}
.pc__side[data-d='1'] {
  translate: var(--pc-side-x) 0;
}
.pc__side[data-d='-2'],
.pc__side[data-d='2'] {
  scale: calc(var(--pc-side-scale) * 0.8);
}
.pc__side[data-d='-2'] {
  translate: calc(var(--pc-side-far) * -1) 0;
}
.pc__side[data-d='2'] {
  translate: var(--pc-side-far) 0;
}

@media (prefers-reduced-motion: reduce) {
  .pc {
    --pc-time: 0.01s;
  }
  .pc__burst.is-on,
  .pc__like.is-liked svg {
    animation: none;
  }
}
