.video {
  padding: unset;
  --video-controls-bg: rgba(0, 0, 0, 0.4);
  --video-controls-color: #fff;
  --video-glow-color: rgba(255, 255, 255, 0.6);
  --video-overlay-gradient: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.5),
    transparent
  );

  .content {
    /* max-width: var(--max-section-grid-width); */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
  }

  .video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    transition: transform 0.5s ease, box-shadow 0.5s ease;

    &:hover {
      transform: scale(1);
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    /* Effetto di caricamento */
    @keyframes videoFadeIn {
      from {
        opacity: 0;
        transform: scale(0.95);
      }
      to {
        opacity: 1;
        transform: scale(1);
      }
    }

    animation: videoFadeIn 0.8s ease-out forwards;
  }

  .video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;

    iframe,
    video {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      border: none;
      object-fit: cover;
    }

    &.direct {
      cursor: pointer;

      .video-controls-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--video-overlay-gradient);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        transition: opacity 0.4s ease;
        z-index: 2;

        &::after {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.4);
          pointer-events: none;
        }

        .play-pause-btn {
          width: 6rem;
          aspect-ratio: 1;
          border-radius: 50%;
          background: var(--video-controls-bg);
          border: 2px solid rgba(255, 255, 255, 0.8);
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
            background-color 0.3s ease, box-shadow 0.3s ease;
          box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);

          &::before {
            content: '';
            border-style: solid;
            border-width: 18px 0 18px 32px;
            border-color: transparent transparent transparent
              var(--video-controls-color);
            display: block;
            margin-left: 8px;
            transition: all 0.3s ease;
          }

          &:hover {
            transform: scale(1.15);
            background-color: rgba(0, 0, 0, 0.7);
            box-shadow: 0 0 40px rgba(255, 255, 255, 0.5);
          }

          &:focus {
            outline: none;
            box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5),
              0 0 30px rgba(255, 255, 255, 0.3);
          }
        }
      }

      &:hover .video-controls-overlay {
        opacity: 1;
      }

      &.playing .video-controls-overlay {
        opacity: 0;

        &:hover {
          opacity: 1;
        }

        .play-pause-btn::before {
          content: '';
          border-style: double;
          border-width: 0 0 0 18px;
          height: 2.25rem;
          margin-left: 0;
        }
      }

      /* Focus visibile per accessibilità */
      video:focus {
        outline: none;
        box-shadow: inset 0 0 0 3px white;
      }
    }
  }

  .video-cta {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-md);
    transition: transform 0.3s ease;

    &:hover {
      transform: translateY(-3px);
    }
  }

  .text-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    transition: opacity 0.5s ease;

    /* Animazione di entrata per il testo */
    @keyframes textSlideIn {
      from {
        opacity: 0;
        transform: translateY(20px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    animation: textSlideIn 0.8s ease-out forwards;
    animation-delay: 0.3s;
    opacity: 0;
  }

  /* Per screen reader */
  .screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
  }

  .video-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f8f8;
    color: #666;
    text-align: center;
    padding: 2rem;
  }

  @media screen and (min-width: 768px) {
    .content {
      flex-direction: row;
      align-items: center;
      gap: var(--spacing-xxl);

      .video-wrapper {
        flex: 3;
      }

      .text-content {
        flex: 2;
      }
    }

    .direct .video-controls-overlay .play-pause-btn {
      transform: scale(1.2);

      &:hover {
        transform: scale(1.4);
      }
    }

    .video-wrapper::after {
      content: '';
      position: absolute;
      inset: 0;
      border-radius: 8px;
      pointer-events: none;
      transition: opacity 0.4s ease;
      opacity: 0;
      box-shadow: 0 0 60px 5px var(--video-glow-color);
    }

    .video-wrapper:hover::after {
      opacity: 0.6;
    }
  }

  @media screen and (max-width: 48rem) {
    .direct .video-controls-overlay .play-pause-btn {
      width: 4.5rem;
      aspect-ratio: 1;

      &::before {
        border-width: 14px 0 14px 24px;
      }
    }

    .video-wrapper {
      border-radius: 6px;
    }
  }

  /* Per utenti che preferiscono movimento ridotto */
  @media (prefers-reduced-motion: reduce) {
    .video-container .play-pause-btn,
    .video-container.direct .video-controls-overlay,
    .video-wrapper,
    .text-content,
    .video-cta {
      transition: none;
      animation: none;
      transform: none;
    }

    .video-wrapper::after {
      display: none;
    }

    .video-wrapper:hover {
      transform: none;
    }
  }

  @media (prefers-color-scheme: dark) {
    .video-error {
      background: #333;
      color: #ccc;
    }
  }
}
