/**
 * Homepage industrial data-loop interaction.
 *
 * This file intentionally sits after theme.css. The general homepage layout
 * remains in the visual system; the stateful factory component owns its
 * routes, scan points, result badges and motion here.
 */

.home-hero__demo.is-playing {
  border-color: #d78f17;
  background: #e59a1b;
  box-shadow: 0 10px 26px rgba(173, 105, 0, 0.24);
}

.home-hero__demo.is-playing i {
  animation: alnet-factory-spin 1s linear infinite;
}

.factory-scene-picker {
  display: grid;
  width: min(100%, 500px);
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.32);
  box-shadow: 0 10px 24px rgba(24, 65, 101, 0.08);
  grid-template-columns: auto repeat(3, minmax(0, 1fr));
  backdrop-filter: blur(12px);
}

.factory-scene-picker > strong {
  padding-inline: 6px;
  color: #173b5b;
  font-size: 11px;
  white-space: nowrap;
}

.factory-scene-picker button {
  display: inline-flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid rgba(41, 96, 139, 0.18);
  border-radius: 6px;
  color: #284057;
  background: rgba(255, 255, 255, 0.54);
  font-size: 11px;
  font-weight: 680;
  white-space: nowrap;
}

.factory-scene-picker button:hover,
.factory-scene-picker button:focus-visible,
.factory-scene-picker button.is-active {
  border-color: var(--alnet-blue-500);
  outline: 0;
  color: var(--alnet-blue-700);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 14px rgba(8, 119, 229, 0.12);
}

.home-hero__actions {
  margin-top: 14px;
  column-gap: 18px;
  row-gap: 8px;
}

.factory-feedback {
  display: flex;
  width: min(100%, 585px);
  min-height: 22px;
  flex: 0 0 100%;
  align-items: center;
  gap: 7px;
  margin-top: 0;
  order: 3;
  color: rgba(255, 255, 255, 0.96);
  font-size: 11px;
  line-height: 1.45;
  text-shadow: 0 2px 9px rgba(19, 60, 95, 0.26);
}

.factory-feedback > i {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--alnet-blue-700);
  background: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  text-shadow: none;
}

.factory-feedback > span {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
}

.factory-feedback strong,
.factory-feedback small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.factory-feedback strong {
  flex: 0 1 auto;
  font-size: 11px;
}

.factory-feedback small {
  flex: 1 1 auto;
  color: rgba(255, 255, 255, 0.82);
  font-size: 10px;
}

.factory-feedback small::before {
  margin-right: 7px;
  content: "·";
}

.factory-feedback.is-complete > i {
  color: #fff;
  background: #178a55;
  box-shadow: 0 0 0 4px rgba(23, 138, 85, 0.12);
}

.home-hero__value-list {
  margin-top: 20px;
}

.factory-experience {
  position: relative;
  min-width: 0;
  isolation: isolate;
}

.factory-stage-viewport {
  position: absolute;
  inset: 0 54px 84px 0;
  min-width: 740px;
  overflow: visible;
  outline: 0;
}

.factory-stage-viewport:focus-visible {
  border-radius: 12px;
  box-shadow: 0 0 0 4px rgba(6, 105, 212, 0.24);
}

.factory-stage-scroll-hint {
  position: absolute;
  z-index: 12;
  top: 4px;
  right: 6px;
  display: none;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  color: #244764;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 20px rgba(27, 70, 105, 0.12);
  font-size: 10px;
  font-weight: 650;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.factory-stage {
  position: absolute;
  inset: 10px 0 0;
  min-width: 740px;
}

.factory-device {
  --factory-focus: #23c7e8;
  color: var(--factory-focus);
}

.factory-device::before {
  position: absolute;
  z-index: -1;
  inset: -7px;
  border: 2px solid transparent;
  border-radius: 18px;
  content: "";
  opacity: 0;
  pointer-events: none;
}

.factory-device--gateway,
.factory-device--platform {
  --factory-focus: #0877e5;
}

.factory-device--motor {
  --factory-focus: #f2a51f;
}

.factory-device.is-lit::before {
  border-color: var(--factory-focus);
  box-shadow:
    0 0 0 8px color-mix(in srgb, var(--factory-focus) 12%, transparent),
    0 0 30px color-mix(in srgb, var(--factory-focus) 38%, transparent);
  opacity: 1;
  animation: alnet-factory-focus-wave 1.65s ease-out infinite;
}

.factory-device.is-muted {
  opacity: 0.48;
}

.factory-device--gateway.is-muted {
  opacity: 0.78;
}

.factory-route {
  --factory-route-color: #168cf1;
  position: absolute;
  z-index: 1;
  height: 5px;
  overflow: visible;
  border: 0;
  border-radius: 999px;
  color: var(--factory-route-color);
  background: repeating-linear-gradient(
    90deg,
    rgba(22, 140, 241, 0.24) 0 8px,
    rgba(22, 140, 241, 0.92) 8px 17px
  );
  box-shadow: 0 0 13px rgba(32, 183, 232, 0.28);
  filter: none;
  opacity: 0.12;
  transform-origin: left center;
  transition: opacity 180ms ease, filter 180ms ease;
}

.factory-route::after {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 16px currentColor;
  content: "";
  opacity: 0;
  transform: translateY(-50%);
}

.factory-route.is-active {
  border: 0;
  opacity: 1;
  filter: none;
}

.factory-route.is-active::after {
  opacity: 1;
  animation: alnet-factory-packet 1.55s linear infinite;
}

.factory-route--command-platform,
.factory-route--command-motor {
  --factory-route-color: #f2a51f;
  background: repeating-linear-gradient(
    90deg,
    rgba(242, 165, 31, 0.24) 0 8px,
    rgba(242, 165, 31, 0.94) 8px 17px
  );
  box-shadow: 0 0 13px rgba(242, 165, 31, 0.32);
}

.factory-route--command-platform.is-active::after,
.factory-route--command-motor.is-active::after {
  animation-direction: reverse;
}

.factory-route--command-platform {
  top: 140px;
  left: 490px;
  width: 150px;
  transform: rotate(-42deg);
}

.factory-route--command-motor {
  top: 308px;
  left: 144px;
  width: 222px;
  transform: rotate(-17deg);
}

.scan-dot {
  z-index: 5;
  width: 13px;
  height: 13px;
  border: 3px solid rgba(255, 255, 255, 0.94);
  color: var(--alnet-cyan);
  background: currentColor;
  box-shadow: 0 0 0 6px rgba(32, 199, 232, 0.14), 0 0 18px currentColor;
}

.scan-dot.is-active {
  animation: alnet-factory-scan-pulse 1.2s ease-in-out infinite;
}

.scan-dot--plc {
  top: 132px;
  left: 118px;
}

.scan-dot--sensor {
  top: 166px;
  right: 84px;
  animation-delay: 150ms;
}

.scan-dot--meter {
  right: 87px;
  bottom: 68px;
  animation-delay: 300ms;
}

.scan-dot--motor {
  bottom: 67px;
  left: 92px;
  animation-delay: 450ms;
}

.factory-badge {
  position: absolute;
  z-index: 7;
  display: none;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  padding: 7px 10px;
  border: 1px solid currentColor;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 9px 22px rgba(18, 65, 113, 0.14);
  font-size: 10px;
  font-weight: 780;
  line-height: 1.25;
  backdrop-filter: blur(10px);
}

.factory-badge.is-visible {
  display: inline-flex;
}

.factory-badge--abnormal {
  top: 116px;
  right: 9px;
  color: #d34242;
}

.factory-badge--energy {
  right: 17px;
  bottom: 90px;
  color: #0877e5;
}

.factory-badge--remote {
  bottom: 88px;
  left: 24px;
  color: #178a55;
}

.factory-legend {
  position: absolute;
  z-index: 6;
  bottom: 112px;
  left: 164px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 7px;
  color: #31516d;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 9px 22px rgba(18, 65, 113, 0.1);
  font-size: 9px;
  backdrop-filter: blur(12px);
}

.factory-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.factory-legend b {
  width: 27px;
  height: 3px;
  border-radius: 999px;
  background: #168cf1;
  box-shadow: 0 0 7px rgba(22, 140, 241, 0.4);
}

.factory-legend span:last-child b {
  background: #f2a51f;
  box-shadow: 0 0 7px rgba(242, 165, 31, 0.42);
}

.factory-scene-picker button.is-playing i {
  animation: alnet-factory-spin 1.2s linear infinite;
}

.factory-steps button:not(:disabled) {
  cursor: pointer;
}

.factory-steps button:not(:disabled):hover,
.factory-steps button:not(:disabled):focus-visible {
  border-radius: 7px;
  outline: 0;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(8, 119, 237, 0.18);
}

.factory-steps button[aria-current="step"] {
  color: var(--alnet-blue-700);
}

@keyframes alnet-factory-packet {
  from { left: 0; }
  to { left: calc(100% - 12px); }
}

@keyframes alnet-factory-focus-wave {
  0% { transform: scale(0.94); opacity: 0.74; }
  100% { transform: scale(1.14); opacity: 0; }
}

@keyframes alnet-factory-scan-pulse {
  0%, 100% { transform: scale(0.84); }
  50% { transform: scale(1.16); }
}

@keyframes alnet-factory-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1360px) {
  .factory-stage-viewport {
    transform: scale(0.91);
    transform-origin: center right;
  }

  .factory-stage {
    transform: none;
  }
}

@media (max-width: 1120px) {
  .factory-experience {
    min-height: 540px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
  }

  .factory-stage-viewport {
    inset: 0 auto 90px 0;
    width: 800px;
    min-width: 800px;
    overflow: visible;
    transform: none;
  }

  .factory-stage {
    inset: 0;
    width: 800px;
    min-width: 800px;
    transform: none;
  }

  .factory-stage-scroll-hint {
    display: inline-flex;
  }

  .factory-scene-picker button {
    min-height: 44px;
  }
}

@media (max-width: 760px) {
  .factory-experience {
    min-height: 486px;
    overflow: hidden;
  }

  .factory-stage-viewport {
    width: 100%;
    min-width: 0;
    height: 360px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  .factory-stage {
    position: relative;
    width: 800px;
    min-width: 800px;
    height: 430px;
    transform: scale(0.8);
    transform-origin: left top;
    scroll-snap-align: start;
  }

  .factory-stage-scroll-hint {
    position: sticky;
    left: calc(100% - 112px);
    width: max-content;
  }

  .factory-steps {
    right: 0;
    bottom: 24px;
    left: 0;
    display: flex;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    padding: 6px;
    transform: none;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  .factory-steps button {
    min-height: 58px;
    flex: 0 0 146px;
    scroll-snap-align: start;
  }

  .factory-legend {
    bottom: 120px;
  }

  .factory-scene-picker button {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .factory-experience {
    min-height: 410px;
    overflow: hidden;
  }

  .factory-stage-viewport {
    height: 208px;
    overflow: hidden;
  }

  .factory-stage {
    transform: scale(0.46);
  }

  .factory-stage-scroll-hint {
    display: none;
  }

  .factory-scene-picker {
    width: 100%;
    padding: 6px;
  }

  .factory-scene-picker button {
    min-height: 44px;
    padding-inline: 4px;
  }

  .home-hero__demo {
    order: 1;
  }

  .factory-feedback {
    order: 2;
  }

  .factory-feedback small {
    display: none;
  }

  .home-hero__actions .button--ghost {
    order: 3;
  }

  .factory-steps {
    top: 310px;
    bottom: auto;
  }

  .factory-legend {
    left: 50%;
    transform: translateX(-50%);
  }

  .factory-disclaimer {
    bottom: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .factory-device.is-lit::before,
  .factory-route.is-active::after,
  .scan-dot.is-active,
  .factory-scene-picker button.is-playing i,
  .home-hero__demo.is-playing i {
    animation: none !important;
  }

  .factory-route.is-active::after {
    left: calc(100% - 12px);
  }
}
