/* ==========================================================================
   Component: mobile-apps — "Ứng dụng di động" (Homepage, 2026-10-09)

   Six DATPRO phone apps on one stage: pick an app on the left, its screens
   fan out as three floating phones that keep rotating (assets/js/mobile-apps.js).
   Every screen is an approved image in content/product-visuals.js, group
   "apps-v1" — real S22 captures (DAT CAR, DATCARE+, DATLIFE, DATEDU KIDS) or
   the client's design mockups (DATWORK, DAT HOME). Each panel says which of
   the two it is, so a design never reads as a shipped screen.

   Light theme on purpose (client: no dark navy, "lấy màu gốc"): the stage is
   tinted with the active app's own brand colours via --c / --c2, which the
   markup sets per app. Every selector is .ma- prefixed.
   ========================================================================== */

.ma {
  --ma-text: #0f2140;
  --ma-muted: #5b6b86;
  --ma-line: rgba(15, 33, 64, 0.1);
  --c: #1d5ee8;
  --c2: #5aa2ff;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding-block: var(--hv-py, 6rem);
  background: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
}

/* soft dotted field that fades toward the edges */
.ma::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(rgba(15, 33, 64, 0.09) 1px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse at 60% 50%, #000 15%, transparent 65%);
  mask-image: radial-gradient(ellipse at 60% 50%, #000 15%, transparent 65%);
}

/* this block also carries the old ecosystem heading + "Tất cả sản phẩm"
   link: keep that button on one line beside a lead that may run long */
.ma .hv-head--split { gap: 1.5rem 2rem; }
@media (min-width: 1024px) { .ma .hv-head--split { align-items: flex-end; } }
.ma .hv-head--split > .hv-btn { flex: none; white-space: nowrap; }
.ma .hv-head__main .hv-lead { max-width: 40rem; margin-top: 1rem; }

.ma-stage {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  margin-top: clamp(2rem, 4vw, 3rem);
}

/* ---------- App list ------------------------------------------------------ */
.ma-list {
  display: grid;
  gap: 0.5rem;
}

.ma-app {
  position: relative;
  display: grid;
  grid-template-columns: 2.75rem 1fr;
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--ma-text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}

.ma-app:hover { background: rgba(255, 255, 255, 0.7); }

.ma-app:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
}

.ma-app.is-on {
  background: #fff;
  border-color: var(--ma-line);
  box-shadow: 0 12px 30px -14px color-mix(in srgb, var(--c) 45%, transparent);
  transform: translateX(4px);
}

.ma-app__mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--c), var(--c2));
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 14px -6px var(--c);
}

.ma-app b {
  display: block;
  font-size: 1rem;
  line-height: 1.25;
}

.ma-app small {
  display: block;
  margin-top: 0.15rem;
  color: var(--ma-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

/* auto-advance progress, restarted by JS on every app switch */
.ma-app__bar {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.4rem;
  height: 2px;
  border-radius: 2px;
  background: var(--ma-line);
  opacity: 0;
  overflow: hidden;
}

.ma-app__bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--c), var(--c2));
  transform: scaleX(0);
  transform-origin: left;
}

.ma.is-auto .ma-app.is-on .ma-app__bar { opacity: 1; }

.ma.is-auto.is-live .ma-app.is-on .ma-app__bar::after {
  animation: ma-progress var(--ma-dur, 8s) linear forwards;
}

@keyframes ma-progress { to { transform: scaleX(1); } }

/* ---------- Stage: glow + phones ----------------------------------------- */
.ma-show {
  position: relative;
  min-height: clamp(34rem, 50vw, 42rem);
}

.ma-glow {
  position: absolute;
  inset: 6% 8%;
  z-index: -1;
  border-radius: 50%;
  background:
    radial-gradient(45% 50% at 35% 45%, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%),
    radial-gradient(40% 45% at 68% 60%, color-mix(in srgb, var(--c2) 32%, transparent), transparent 70%);
  filter: blur(18px);
  transition: background 0.6s;
}

.ma-panel {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.ma-panel[hidden] { display: none; }

.ma-panel.is-enter .ma-phone { animation: ma-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.ma-panel.is-enter .ma-phone[data-pos="1"] { animation-delay: 0.08s; }
.ma-panel.is-enter .ma-phone[data-pos="2"] { animation-delay: 0.14s; }

@keyframes ma-rise {
  from { opacity: 0; translate: 0 40px; }
  to { opacity: 1; translate: 0 0; }
}

.ma-phones {
  position: relative;
  perspective: 1400px;
}

/* phone: CSS-only frame around a 720×1440 screen (1:2) */
.ma-phone {
  --w: clamp(13rem, 20vw, 17rem);
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--w);
  aspect-ratio: 1 / 2;
  margin: calc(var(--w) * -1) 0 0 calc(var(--w) / -2);
  padding: calc(var(--w) * 0.035);
  border-radius: calc(var(--w) * 0.16);
  background: linear-gradient(145deg, #f8fafc, #cbd5e1 45%, #f1f5f9);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    0 0 0 1px rgba(15, 33, 64, 0.12),
    0 30px 60px -24px rgba(15, 33, 64, 0.45),
    0 12px 24px -12px color-mix(in srgb, var(--c) 40%, transparent);
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.9s, filter 0.9s;
  will-change: transform;
}

.ma-phone img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--w) * 0.13);
  background: #fff;
}

/* glass sheen that sweeps across the centre phone */
.ma-phone::after {
  content: "";
  position: absolute;
  inset: calc(var(--w) * 0.035);
  border-radius: calc(var(--w) * 0.13);
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.35) 48%, transparent 60%);
  background-size: 250% 100%;
  background-position: 120% 0;
  pointer-events: none;
}

.ma-phone[data-pos="0"] { z-index: 3; transform: translateY(-2%) rotateY(0) scale(1); }
.ma-phone[data-pos="0"]::after { animation: ma-sheen 2.4s 0.3s ease-out; }
.ma-phone[data-pos="1"] { z-index: 2; transform: translateX(62%) translateY(4%) rotateY(-18deg) scale(0.84); filter: saturate(0.92); }
.ma-phone[data-pos="2"] { z-index: 1; transform: translateX(-62%) translateY(4%) rotateY(18deg) scale(0.84); filter: saturate(0.92); }

@keyframes ma-sheen { from { background-position: 120% 0; } to { background-position: -40% 0; } }

/* idle float on the centre phone */
.ma.is-live .ma-phone[data-pos="0"] img { animation: ma-float 6s ease-in-out infinite; }
@keyframes ma-float { 50% { translate: 0 -4px; } }

/* ---------- Floating feature chips --------------------------------------- */
.ma-chips {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
  z-index: 4;
}

.ma-chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 15rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 30px -14px rgba(15, 33, 64, 0.35);
  color: var(--ma-text);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
}

.ma-chip::before {
  content: "";
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c), var(--c2));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent);
}

.ma-chip:nth-child(1) { top: 12%; left: 0; }
.ma-chip:nth-child(2) { top: 46%; right: 0; }
.ma-chip:nth-child(3) { bottom: 14%; left: 4%; }

.ma-panel.is-enter .ma-chip { animation: ma-pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; }
.ma-panel.is-enter .ma-chip:nth-child(1) { animation-delay: 0.35s; }
.ma-panel.is-enter .ma-chip:nth-child(2) { animation-delay: 0.5s; }
.ma-panel.is-enter .ma-chip:nth-child(3) { animation-delay: 0.65s; }

@keyframes ma-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.ma.is-live .ma-chip { animation-name: ma-pop, ma-bob; animation-duration: 0.6s, 5s; animation-timing-function: cubic-bezier(0.2, 0.9, 0.3, 1.3), ease-in-out; animation-iteration-count: 1, infinite; animation-fill-mode: both, none; }
.ma.is-live .ma-chip:nth-child(2) { animation-delay: 0.5s, 1.2s; }
.ma.is-live .ma-chip:nth-child(3) { animation-delay: 0.65s, 2.4s; }
@keyframes ma-bob { 50% { translate: 0 -6px; } }

/* ---------- Caption under the phones ------------------------------------- */
.ma-cap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  padding-top: 1rem;
  text-align: center;
  color: var(--ma-muted);
  font-size: 0.92rem;
}

.ma-cap strong { color: var(--ma-text); }

.ma-src {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 10%, #fff);
  color: color-mix(in srgb, var(--c) 75%, #0f2140);
  font-size: 0.75rem;
  font-weight: 600;
}

.ma-cap a {
  color: var(--c);
  font-weight: 700;
  text-decoration: none;
}

.ma-cap a:hover { text-decoration: underline; }

/* ---------- Responsive ---------------------------------------------------- */
@media (max-width: 1023px) {
  .ma-stage { grid-template-columns: 1fr; }

  /* the list turns into one swipeable row of app pills */
  .ma-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.25rem 0.25rem 0.75rem;
    margin-inline: -0.25rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .ma-list::-webkit-scrollbar { display: none; }

  .ma-app {
    flex: none;
    width: auto;
    grid-template-columns: 2.25rem auto;
    gap: 0.6rem;
    padding: 0.5rem 0.9rem 0.5rem 0.5rem;
    border-color: var(--ma-line);
    background: rgba(255, 255, 255, 0.7);
    scroll-snap-align: start;
  }
  .ma-app.is-on { transform: none; }
  .ma-app__mark { width: 2.25rem; height: 2.25rem; border-radius: 10px; font-size: 0.9rem; }
  .ma-app small { display: none; }
  .ma-app__bar { bottom: 0.25rem; }

  .ma-show { min-height: 36rem; }
}

@media (max-width: 640px) {
  .ma-show { min-height: 31rem; }
  .ma-phone { --w: 11.5rem; }
  .ma-phone[data-pos="1"] { transform: translateX(52%) translateY(5%) rotateY(-18deg) scale(0.8); }
  .ma-phone[data-pos="2"] { transform: translateX(-52%) translateY(5%) rotateY(18deg) scale(0.8); }
  .ma-chip { max-width: 11rem; font-size: 0.78rem; padding: 0.45rem 0.65rem; }
  .ma-chip:nth-child(1) { top: 4%; }
  .ma-chip:nth-child(2) { top: auto; bottom: 22%; }
  .ma-chip:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ma *, .ma *::before, .ma *::after {
    animation: none !important;
    transition: none !important;
  }
}
