/*
 * Dedicated mobile layout pass for ViviSystem.
 * Keeps each page inside the device viewport, replaces sideways feature
 * scrollers with wrapping/stacked layouts, and restores comfortable spacing.
 */

*, *::before, *::after { box-sizing: border-box; }

html,
body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

html {
  overflow-x: clip;
  scroll-padding-top: 88px;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: clip;
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

/* ── Mobile landing page ─────────────────────────────────────────────── */
body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .wrap {
  width: 100%;
  max-width: 560px;
  padding-inline: clamp(14px, 4.5vw, 18px);
}

body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) header,
body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .navbar {
  width: 100%;
  min-width: 0;
}

body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .navbar {
  flex-wrap: wrap;
  row-gap: 10px;
}

body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .mobile-header-actions {
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* This was a sideways carousel. Stack feature cards so the page itself
   never inherits a horizontal scroll area. */
body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .hw-scroll {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  min-width: 0;
  gap: 14px;
  margin: 0;
  padding: 0 0 2px;
  overflow: visible;
  scroll-snap-type: none;
  overscroll-behavior: auto;
}

body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .hw-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 19px;
  flex: none;
  scroll-snap-align: none;
}

body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .process {
  gap: 15px;
}

body[data-vivi-chat-only="true"]:not(.vs-builder-mobile-page):not(.vs-hardware-mobile) .step-inner {
  padding: 20px 18px;
}

/* ── Mobile PC builder ───────────────────────────────────────────────── */
body.vs-builder-mobile-page {
  width: 100%;
  min-width: 0;
  overflow-x: clip;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
}

.vs-builder-mobile-page main,
.vs-builder-mobile-page .vb-hero,
.vs-builder-mobile-page .vb-hero-inner,
.vs-builder-mobile-page .vb-stat-strip,
.vs-builder-mobile-page .vb-section-intro,
.vs-builder-mobile-page .vb-workbench,
.vs-builder-mobile-page .vb-workbench-main,
.vs-builder-mobile-page .vb-sidebar,
.vs-builder-mobile-page .vb-workspace-section,
.vs-builder-mobile-page .vb-bottom-note,
.vs-builder-mobile-page .vb-footer {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.vs-builder-mobile-page .vb-header {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.vs-builder-mobile-page .vb-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 100%;
  gap: 5px 14px;
  padding: 8px 0 4px;
  overflow: visible;
  white-space: normal;
  overscroll-behavior: auto;
}

.vs-builder-mobile-page .vb-nav a {
  flex: 0 1 auto;
  min-width: 0;
  white-space: normal;
  padding-block: 7px;
}

.vs-builder-mobile-page .vb-hero-inner {
  padding: 34px clamp(16px, 5vw, 20px) 27px;
  gap: 18px;
}

.vs-builder-mobile-page .vb-hero-art {
  width: 100%;
  max-width: 330px;
  min-width: 0;
  margin: 0 auto;
  transform: none;
}

.vs-builder-mobile-page .vb-stat-strip {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 13px 8px;
}

.vs-builder-mobile-page .vb-stat-strip > div {
  min-width: 0;
  padding: 10px 7px;
  column-gap: 8px;
  border-right: 0;
}

.vs-builder-mobile-page .vb-stat-strip > div:nth-child(3),
.vs-builder-mobile-page .vb-stat-strip > div:nth-child(4) {
  padding-top: 13px;
  border-top: 1px solid rgba(190,151,255,.13);
}

.vs-builder-mobile-page .vb-section-intro {
  padding: 37px 16px 18px;
  gap: 11px;
}

.vs-builder-mobile-page .vb-workbench {
  padding: 0 14px 16px;
  gap: 17px;
}

.vs-builder-mobile-page .vb-slots {
  grid-template-columns: minmax(0, 1fr);
  gap: 13px;
}

.vs-builder-mobile-page .vb-slot-card {
  min-width: 0;
  padding: 15px;
}

.vs-builder-mobile-page .vb-sidebar {
  gap: 15px;
}

.vs-builder-mobile-page .vb-summary-card,
.vs-builder-mobile-page .vb-compat-card {
  min-width: 0;
  padding: 16px;
}

.vs-builder-mobile-page .vb-vivi-card {
  width: calc(100% - 28px);
  max-width: 100%;
  margin: 25px auto 0;
  padding: 16px;
  gap: 12px;
}

.vs-builder-mobile-page .vb-workspace-section {
  width: calc(100% - 28px);
  max-width: 1144px;
  padding: 32px 0 25px;
}

.vs-builder-mobile-page .vb-workspace-heading {
  padding-bottom: 16px;
}

.vs-builder-mobile-page .vb-workspace-tabs {
  gap: 6px;
}

.vs-builder-mobile-page .vb-workspace-tabs button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 5px;
  line-height: 1.25;
}

.vs-builder-mobile-page .vb-workspace-panel {
  min-width: 0;
  padding: 14px;
}

.vs-builder-mobile-page .vb-workspace-product {
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  padding-block: 14px;
}

.vs-builder-mobile-page .vb-workspace-product-actions {
  grid-column: 2;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 7px;
}

.vs-builder-mobile-page .vb-picker-dialog {
  width: 100%;
  max-width: 100%;
  max-height: 100dvh;
  min-width: 0;
}

.vs-builder-mobile-page .vb-picker-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 0 14px 18px;
}

.vs-builder-mobile-page .vb-footer {
  gap: 10px 16px;
  padding-inline: 14px;
}

/* ── Mobile hardware catalogue ───────────────────────────────────────── */
body.vs-hardware-mobile {
  width: 100%;
  min-width: 0;
  min-height: 100svh;
  overflow-x: clip;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
}

.vs-hardware-mobile .m-hardware-header,
.vs-hardware-mobile .m-main,
.vs-hardware-mobile .m-wrap,
.vs-hardware-mobile .m-footer {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.vs-hardware-mobile .m-wrap {
  max-width: 760px;
  margin-inline: auto;
  padding-inline: clamp(14px, 4vw, 20px);
}

.vs-hardware-mobile .m-actions {
  max-width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.vs-hardware-mobile .m-main .vs-catalog-panel {
  width: 100%;
  min-width: 0;
  margin-inline: auto;
  padding: 16px;
}

.vs-hardware-mobile .m-main .vs-catalog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0 0 13px;
  padding: 3px 0 11px;
  overflow: visible;
  overscroll-behavior: auto;
  white-space: normal;
  scrollbar-width: auto;
}

.vs-hardware-mobile .m-main .vs-filter-chip {
  flex: 0 1 auto;
  max-width: 100%;
  white-space: normal;
}

.vs-hardware-mobile .m-main .vs-catalog-results {
  min-width: 0;
  gap: 8px;
}

.vs-hardware-mobile .m-main .vs-product-grid {
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.vs-hardware-mobile .m-main .vs-product-card,
.vs-hardware-mobile .m-main .vs-product-card__content {
  width: 100%;
  min-width: 0;
}

.vs-hardware-mobile .m-main .vs-product-modal {
  width: 100%;
  max-width: 100%;
}

@media (min-width: 600px) {
  .vs-hardware-mobile .m-main .vs-product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }
}

@media (max-width: 380px) {
  .vs-builder-mobile-page .vb-vivi-card {
    grid-template-columns: 40px minmax(0, 1fr);
    padding: 13px;
    gap: 9px;
  }

  .vs-builder-mobile-page .vb-vivi-orb {
    width: 40px;
    height: 40px;
  }

  .vs-hardware-mobile .m-main .vs-catalog-panel {
    padding: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
