.navigation-widget {
  display: flex;
  justify-content: center;
  background-color: #161616;
  padding: 128px 32px;
}



.navigation-widget__area {
  width: 100%;
  max-width: 1152px;
  display: flex;
  flex-direction: column;
  gap: 64px;
  opacity: 0;
  transform: translateY(12px);
}

.navigation-widget__area--visible {
  animation: navigation-reveal 400ms ease-out forwards;
}

.navigation-widget__header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 16px;
  width: 100%;
}

@media (min-width: 833px) {
  .navigation-widget__header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }
}

.navigation-widget__title {
  margin: 0;
  font-size: 40px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #FEF8E8;
}

/* Carousel controls */
.navigation-widget__controls {
  display: none;
  gap: 12px;
}

@media (min-width: 833px) {
  .navigation-widget__controls {
    display: flex;
    align-items: center;
  }
}

.navigation-widget__btn {
  background-color: #2E2E2E;
  border: none;
  color: #FEF8E8;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  /* slight border radius, square shape */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: background-color 2s ease, border-color 2s ease, color 2s ease;
  padding: 0;
  font-size: 16px;
}

.navigation-widget__btn:hover:not([disabled]) {
  border-color: #F44A22;
  color: #F44A22;
}

.navigation-widget__btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: #333333;
  color: #777777;
}

/* Grid layout transformed to horizontal scrolling snap container */
.navigation-widget__grid {
  display: flex;
  gap: 32px;
  /* standard desktop gap for spacing */
  margin: 0;
  padding: 16px 0;
  list-style: none;
  overflow-x: hidden;
  /* Hide overflow on desktop/tablet to prevent peeking & dragging */
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  /* Hide scrollbar for Firefox */
  -ms-overflow-style: none;
  /* Hide scrollbar for IE/Edge */
  width: 100%;
}

.navigation-widget__grid::-webkit-scrollbar {
  display: none;
  /* Hide scrollbar for Chrome/Safari */
}

.navigation-widget__item {
  display: flex;
  opacity: 0;
  transform: translateY(16px);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  /* Force horizontal scroll to snap on each card instead of skipping items */
  flex-shrink: 0;
  width: calc((100% - 3 * 32px) / 4);
  /* 4 columns on desktop, dynamic sizing, smaller squares */
  margin: 0;
  padding: 0;
  perspective: 1000px;
}

.navigation-widget__item--visible {
  animation: navigation-card-reveal 400ms ease-out forwards;
}

/* 3D Cube Card structure */
.navigation-cube {
  width: 100%;
  height: var(--cube-size, 264px);
  /* square height dynamically computed in JS */
  position: relative;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  /* Rotate around center of 3D box to prevent perspective projection stretching */
  transform-origin: 50% 50% calc(-1 * var(--cube-half, 132px));
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  text-decoration: none;
  background-color: transparent;
  border-radius: 24px;
  /* Softened card corners */
  display: block;
}

/* Only enable 3D rotation hover on desktop devices */
@media (hover: hover) and (min-width: 833px) {

  .navigation-cube:hover,
  .navigation-cube:focus-within {
    transform: rotateX(90deg);
  }
}

.navigation-cube__face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 24px;
  /* Softened card corners */
  box-sizing: border-box;
  display: flex;
  overflow: hidden;
  /* Prevent background bleeding */
}

/* Front Face Styling */
.navigation-cube__face--front {
  background-color: #2E2E2E;
  border: 1px solid rgba(254, 248, 232, 0.15);
  /* Elegant soft cream border */
  padding: 24px 16px;
  /* Compact padding for smaller cards */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
  /* Compact gap */
  transform: rotateX(0deg) translateZ(0);
  /* Anchored to flat layout box */
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

@media (min-width: 833px) {
  .navigation-cube:hover .navigation-cube__face--front {
    border-color: #F44A22;
  }
}

/* Bottom Face Styling */
.navigation-cube__face--bottom {
  background: linear-gradient(135deg, #F44A22, #D33611);
  border: 1px solid rgba(254, 248, 232, 0.25);
  /* Elegant border for bottom face */
  padding: 24px 16px;
  /* Compact padding */
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 12px;
  /* Compact gap */
  /* Translate in global axes, then rotate around its center to align perfectly */
  transform: translateY(var(--cube-half, 132px)) translateZ(calc(-1 * var(--cube-half, 132px))) rotateX(-90deg);
  box-shadow: 0 8px 24px rgba(244, 74, 34, 0.25);
}

.navigation-widget__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  /* Compact icon size */
  height: 48px;
  flex-shrink: 0;
  font-size: 22px;
  color: #F44A22;
  background-color: #161616;
  border-radius: 12px;
}

.navigation-cube__text-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  /* Small gap between title and subtitle */
  text-align: center;
  width: 100%;
  /* Constrain width to prevent text from overflowing card edge */
}

.navigation-widget__card-title {
  margin: 0;
  font-size: 17px;
  /* Compact title size */
  font-weight: 600;
  color: #FEF8E8;
}

.navigation-cube__subtitle {
  margin: 0;
  font-size: 13px;
  /* Compact subtitle size */
  line-height: 1.35;
  color: #FEF8E8;
  opacity: 0.75;
  font-weight: 400;
  text-align: center;
}

.navigation-cube__description {
  margin: 0;
  font-size: 13px;
  /* Compact description size */
  line-height: 1.35;
  color: #FEF8E8;
  font-weight: 500;
  opacity: 0.95;
  text-align: center;
}

.navigation-cube__cta {
  font-size: 12px;
  /* Compact CTA size */
  font-weight: 700;
  color: #FEF8E8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

/* Responsiveness media queries */
@media (max-width: 1152px) {
  .navigation-widget {
    padding: 96px 24px;
  }

  .navigation-widget__area {
    gap: 32px;
  }

  .navigation-widget__title {
    font-size: 32px;
  }

  .navigation-widget__grid {
    gap: 24px;
    /* tablet spacing */
    padding: 16px 0;
  }

  .navigation-widget__item {
    width: calc((100% - 2 * 24px) / 3);
    /* 3 cards visible on tablet, smaller squares */
  }
}

@media (max-width: 832px) {
  .navigation-widget {
    padding: 64px 0px 64px 24px;
  }

  .navigation-widget__title {
    font-size: 28px;
  }

  .navigation-widget__grid {
    gap: 16px;
    /* mobile spacing */
    overflow-x: auto;
    /* enable touch scroll on mobile devices */
    padding: 16px 0px;
    /* Add margin on sides for mobile snap peeking */
    scroll-padding: 8px;
  }

  .navigation-widget__item {
    width: 200px;
    /* fixed smaller width on mobile */
  }
}

@keyframes navigation-reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes navigation-card-reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {

  .navigation-widget__area,
  .navigation-widget__item {
    opacity: 1;
    transform: none;
  }

  .navigation-widget__area--visible,
  .navigation-widget__item--visible {
    animation: none;
  }

  .navigation-cube {
    transition: none;
  }

  .navigation-cube:hover,
  .navigation-cube:focus-within {
    transform: none;
  }

  .navigation-widget__btn {
    transition: none;
  }

  .navigation-widget__btn i {
    transition: none;
  }
}