/* ==========================================================================
   XDMicrobotics — components layer (loads after neotix.css)
   Carousel, dedicated service cards, sub-nav, display explorer, tech cards,
   gallery slides, pillars.
   ========================================================================== */

/* ---------- 1. Carousel ---------- */
.carousel { --per: 3; --gap: clamp(14px, 1.8vw, 24px); position: relative; }
.carousel--wide { --per: 2; }
.carousel__viewport {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  /* room for card shadows without clipping */
  padding: 18px 4px 34px;
  margin: -18px -4px -34px;
  -webkit-overflow-scrolling: touch;
}
.carousel__viewport::-webkit-scrollbar { display: none; }
.carousel__viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }
.carousel__track { display: flex; gap: var(--gap); }
.carousel__slide {
  flex: 0 0 calc((100% - var(--gap) * (var(--per) - 1)) / var(--per));
  min-width: 0;
  scroll-snap-align: start;
  display: flex;
}
.carousel__slide > * { width: 100%; }
@media (hover: hover) {
  .carousel__viewport { cursor: grab; }
}
.carousel__viewport.is-dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; user-select: none; }
.carousel__viewport.is-dragging a { pointer-events: none; }
.carousel__viewport img { -webkit-user-drag: none; user-select: none; }

.carousel__ui { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-top: clamp(26px, 3vw, 40px); }
.carousel__dots { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.carousel__dot {
  width: 10px; height: 10px;
  padding: 0;
  background: var(--border-strong);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: width .35s var(--ease), background .25s var(--ease);
}
.carousel__dot:hover { background: var(--text-subtle); }
.carousel__dot[aria-current="true"] { width: 32px; background: var(--accent); }
.carousel__arrows { display: flex; gap: .6rem; }
.carousel__btn {
  display: grid; place-items: center;
  width: 52px; height: 52px;
  color: var(--text);
  background: var(--bg-solid);
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease), opacity .25s var(--ease);
}
.carousel__btn svg { width: 20px; height: 20px; }
.carousel__btn:hover:not(:disabled) { color: #fff; background: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.carousel__btn:disabled { opacity: .35; cursor: not-allowed; }
.carousel--dark .carousel__dot { background: rgb(255 255 255 / .22); }
.carousel--dark .carousel__dot[aria-current="true"] { background: var(--accent); }
.carousel--dark .carousel__btn { color: #fff; background: rgb(255 255 255 / .06); border-color: rgb(255 255 255 / .22); }
@media (max-width: 1020px) { .carousel { --per: 2; } .carousel--wide { --per: 1; } }
@media (max-width: 640px)  { .carousel { --per: 1; } .carousel__btn { width: 46px; height: 46px; } }

/* ---------- 2. Sub-nav (sticky section chips) ---------- */
.subnav {
  position: sticky;
  top: 84px;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.subnav__inner { display: flex; gap: .5rem; padding-block: .8rem; overflow-x: auto; scrollbar-width: none; }
.subnav__inner::-webkit-scrollbar { display: none; }
.subnav a {
  display: inline-flex; align-items: center; gap: .5rem;
  flex-shrink: 0;
  padding: .55rem 1.1rem;
  font-size: .88rem; font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-solid);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: background .25s var(--ease), color .25s var(--ease), transform .25s var(--ease);
}
.subnav a svg { width: 16px; height: 16px; }
.subnav a:hover { color: var(--accent); transform: translateY(-1px); }
.subnav a.is-active { color: #fff; background: var(--accent); }
@media (max-width: 860px) { .subnav { top: 72px; } }

/* ---------- 3. Dedicated service cards (bento) ---------- */
.bento { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 2vw, 24px); }
.svc {
  position: relative;
  display: flex; flex-direction: column;
  padding: clamp(24px, 2.6vw, 36px);
  color: var(--text);
  background: var(--bg-solid);
  border-radius: clamp(22px, 2.4vw, 32px);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  isolation: isolate;
  scroll-margin-top: 150px;
  transition: transform .45s var(--ease-out), box-shadow .45s var(--ease-out);
}
.svc:hover { transform: translateY(-6px); box-shadow: var(--shadow-xl); }
.svc--wide { grid-column: span 2; }
.svc--full { grid-column: 1 / -1; }
.svc__top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.svc__num { font-size: 3.2rem; font-weight: 700; letter-spacing: -.06em; line-height: 1; color: currentColor; opacity: .16; }
.svc__icon {
  display: grid; place-items: center;
  width: 58px; height: 58px;
  color: var(--accent);
  background: var(--bg);
  border-radius: 50%;
  transition: transform .45s var(--ease-out), background .3s var(--ease), color .3s var(--ease);
}
.svc__icon svg { width: 26px; height: 26px; }
.svc:hover .svc__icon { transform: rotate(-10deg) scale(1.08); background: var(--accent); color: #fff; }
.svc h3 { font-size: clamp(1.4rem, 2.2vw, 1.85rem); letter-spacing: -.04em; margin-bottom: .6rem; }
.svc p { color: var(--text-muted); font-size: .97rem; margin-bottom: 1.2rem; }
.svc__body { display: flex; flex-direction: column; min-width: 0; }
.svc__list { display: grid; gap: .6rem; margin-bottom: 1.4rem; }
.svc__list li { display: flex; align-items: center; gap: .65rem; font-size: .93rem; font-weight: 500; }
.svc__list li::before {
  content: "";
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fa5005' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.svc .tags { margin-top: auto; padding-top: 1.1rem; border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent); }
.svc .tag { background: color-mix(in srgb, currentColor 8%, transparent); color: inherit; opacity: .9; }
.svc__cta {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: .5rem;
  margin-top: 1.3rem;
  padding: .7rem 1.2rem;
  font-size: .86rem; font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border-radius: 999px;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.svc__cta svg { width: 14px; height: 14px; }
.svc__cta:hover { background: var(--accent); color: #fff; }

/* Visual well shared by all six */
.svc__visual {
  position: relative;
  margin-bottom: 1.3rem;
  padding: 14px;
  border-radius: 20px;
  background: color-mix(in srgb, currentColor 5%, transparent);
  overflow: hidden;
}
.viz { display: block; width: 100%; height: auto; max-height: 190px; }

/* Variants */
.svc--dark {
  color: #fff;
  background:
    radial-gradient(70% 90% at 100% 0%, rgb(250 80 5 / .32), transparent 65%),
    radial-gradient(60% 70% at 0% 100%, rgb(120 48 10 / .4), transparent 70%),
    var(--panel);
}
.svc--dark p { color: rgb(255 255 255 / .74); }
.svc--dark .svc__icon { background: rgb(255 255 255 / .1); }
.svc--dark .svc__cta { color: #fff; background: rgb(255 255 255 / .1); }
.svc--accent {
  color: #fff;
  background:
    radial-gradient(80% 70% at 100% 0%, rgb(255 190 140 / .55), transparent 60%),
    linear-gradient(150deg, #ff7a3d 0%, #fa5005 55%, #d63f00 100%);
}
.svc--accent p { color: rgb(255 255 255 / .88); }
.svc--accent .svc__icon { color: #fff; background: rgb(255 255 255 / .2); }
.svc--accent:hover .svc__icon { color: var(--accent); background: #fff; }
.svc--accent .svc__list li::before {
  background: rgb(255 255 255 / .25) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4 8-9'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.svc--accent .svc__cta { color: var(--accent); background: #fff; }
.svc--accent .svc__cta:hover { color: #fff; background: var(--panel); }
.svc--dark .svc__cta:hover { background: var(--accent); }
.svc--sand { background: var(--bg-alt); box-shadow: none; border: 1px solid var(--border); }
.svc--sand .svc__icon { background: var(--bg-solid); }

/* Two-column layout for wide/full cards */
.svc--wide, .svc--full { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 44px); align-items: stretch; }
.svc--wide > .svc__visual-col, .svc--full > .svc__visual-col { display: flex; flex-direction: column; justify-content: center; gap: 1rem; min-width: 0; }
.svc--wide .svc__visual-col .svc__visual, .svc--full .svc__visual-col .svc__visual { margin-bottom: 0; }
.svc--full .svc__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* --- viz: chip --- */
.chip__pin { stroke: currentColor; stroke-width: 3; stroke-linecap: round; opacity: .55; animation: pinPulse 2.6s ease-in-out infinite; }
.chip__pin:nth-child(2n) { animation-delay: .5s; }
.chip__pin:nth-child(3n) { animation-delay: 1.1s; }
.chip__body { fill: rgb(255 255 255 / .07); stroke: rgb(255 255 255 / .35); stroke-width: 1.5; }
.chip__die { fill: var(--accent); }
.chip__txt { fill: #fff; font: 700 13px 'Plus Jakarta Sans', sans-serif; letter-spacing: .08em; }
@keyframes pinPulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; stroke: #ff8a54; } }
.svc__code {
  margin: 0;
  padding: 14px 16px;
  font: 500 .8rem/1.7 ui-monospace, 'Cascadia Code', Consolas, monospace;
  color: rgb(255 255 255 / .82);
  background: rgb(0 0 0 / .35);
  border-radius: 14px;
  overflow: hidden;
  white-space: pre;
}
.svc__code .k { color: #ff8a54; }
.svc__code .f { color: #ffd2b8; }
.svc__code .c { color: rgb(255 255 255 / .42); }

/* --- viz: AI vision --- */
.vz-grid { stroke: rgb(255 255 255 / .22); stroke-width: 1; }
.vz-box { fill: none; stroke: #fff; stroke-width: 2.4; rx: 4; }
.vz-lbl { fill: #fff; font: 700 10.5px 'Plus Jakarta Sans', sans-serif; }
.vz-lblbg { fill: rgb(0 0 0 / .45); }
.vz-scan { fill: rgb(255 255 255 / .35); animation: scanMove 3.4s ease-in-out infinite alternate; }
@keyframes scanMove { from { transform: translateY(0); } to { transform: translateY(150px); } }

/* --- viz: HMI --- */
.hmi__screen { fill: #0d0a08; stroke: var(--border-strong); stroke-width: 2; }
.hmi__arc { fill: none; stroke: rgb(255 255 255 / .16); stroke-width: 10; stroke-linecap: round; }
.hmi__arc--on { stroke: var(--accent); stroke-dasharray: 86 400; }
.hmi__needle { stroke: #fff; stroke-width: 3; stroke-linecap: round; transform-origin: 115px 122px; animation: needle 4s ease-in-out infinite alternate; }
.hmi__btn { fill: rgb(255 255 255 / .1); }
.hmi__btn--on { fill: var(--accent); }
.hmi__txt { fill: rgb(255 255 255 / .7); font: 600 9px 'Plus Jakarta Sans', sans-serif; }
@keyframes needle { from { transform: rotate(-55deg); } to { transform: rotate(48deg); } }

/* --- viz: IoT --- */
.iot__node { fill: var(--bg-solid); stroke: var(--border-strong); stroke-width: 1.5; }
.iot__node--hot { fill: var(--accent); stroke: none; }
.iot__lbl { fill: var(--text); font: 700 10.5px 'Plus Jakarta Sans', sans-serif; text-anchor: middle; }
.iot__lbl--w { fill: #fff; }
.iot__link { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 3 9; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -24; } }

/* --- viz: app --- */
.app__phone { fill: var(--bg-solid); stroke: var(--text); stroke-width: 3; opacity: .9; }
.app__screen { fill: var(--bg); }
.app__bar { fill: var(--accent); transform-box: fill-box; transform-origin: bottom; animation: barGrow 2.8s ease-in-out infinite alternate; }
.app__bar:nth-of-type(2) { animation-delay: .25s; fill: #ff8a54; }
.app__bar:nth-of-type(3) { animation-delay: .5s; }
.app__bar:nth-of-type(4) { animation-delay: .75s; fill: #ff8a54; }
.app__bar:nth-of-type(5) { animation-delay: 1s; }
.app__chip { fill: color-mix(in srgb, var(--text) 12%, transparent); }
@keyframes barGrow { from { transform: scaleY(.35); } to { transform: scaleY(1); } }

/* --- viz: PID --- */
.pid__axis { stroke: rgb(255 255 255 / .35); stroke-width: 1.5; fill: none; }
.pid__set { stroke: rgb(255 255 255 / .55); stroke-width: 1.5; stroke-dasharray: 6 6; }
.pid__curve { fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; stroke-dasharray: 1000; stroke-dashoffset: 0; }
.pid__lbl { fill: rgb(255 255 255 / .75); font: 600 10px 'Plus Jakarta Sans', sans-serif; }
.js-reveal .svc--robotics:not(.is-in) .pid__curve { stroke-dashoffset: 1000; }
.svc--robotics.is-in .pid__curve { animation: drawPid 2.6s var(--ease-out) .2s both; }
@keyframes drawPid { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }

@media (max-width: 1020px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .svc--wide, .svc--full { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .bento { grid-template-columns: 1fr; }
  .svc--wide, .svc--full { grid-template-columns: 1fr; }
  .svc--full .svc__list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .chip__pin, .vz-scan, .hmi__needle, .iot__link, .app__bar { animation: none !important; }
  .svc--robotics.is-in .pid__curve { animation: none; }
}

/* ---------- 4. Display explorer (HMI sizes) ---------- */
.explorer {
  padding: clamp(20px, 2.4vw, 32px);
  background: rgb(255 255 255 / .06);
  border: 1px solid rgb(255 255 255 / .12);
  border-radius: 26px;
  backdrop-filter: blur(14px);
}
.seg { display: inline-flex; gap: .3rem; padding: .3rem; background: rgb(0 0 0 / .35); border-radius: 999px; margin-bottom: 1.4rem; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  padding: .6rem 1.2rem;
  font-size: .86rem; font-weight: 700;
  color: rgb(255 255 255 / .75);
  background: transparent;
  border: 0; border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.seg button:hover { color: #fff; }
.seg button[aria-selected="true"] { color: #fff; background: var(--accent); }
.explorer__stage { display: grid; place-items: center; min-height: 250px; padding: 12px 0 8px; }
.disp {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  padding: 10px;
  background: #1c1713;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgb(0 0 0 / .45), inset 0 0 0 2px rgb(255 255 255 / .08);
  transition: width .6s var(--ease-out);
}
.explorer[data-size="s"] .disp { width: 46%; aspect-ratio: 4 / 3; }
.explorer[data-size="m"] .disp { width: 78%; }
.explorer[data-size="l"] .disp { width: 100%; }
.disp__screen {
  height: 100%;
  display: grid; gap: 8px;
  padding: 10px;
  background: linear-gradient(160deg, #0d0a08, #1f140d);
  border-radius: 9px;
  align-content: start;
  overflow: hidden;
}
.disp__bar { display: flex; align-items: center; justify-content: space-between; font-size: .66rem; font-weight: 700; letter-spacing: .08em; color: rgb(255 255 255 / .7); text-transform: uppercase; }
.disp__bar i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.disp__row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.explorer[data-size="m"] .disp__row { grid-template-columns: repeat(3, 1fr); }
.explorer[data-size="l"] .disp__row { grid-template-columns: repeat(4, 1fr); }
.tile { padding: 6px 9px; background: rgb(255 255 255 / .07); border-radius: 8px; }
.tile b { display: block; font-size: .95rem; line-height: 1.3; color: #fff; letter-spacing: -.03em; }
.tile span { font-size: .6rem; color: rgb(255 255 255 / .55); text-transform: uppercase; letter-spacing: .08em; }
.tile--hot b { color: var(--accent); }
.disp__spark { width: 100%; height: 28px; }
.w-m, .w-l { display: none; }
.explorer[data-size="m"] .w-m, .explorer[data-size="l"] .w-m, .explorer[data-size="l"] .w-l { display: grid; }
.explorer[data-size="m"] .disp__btns.w-m, .explorer[data-size="l"] .disp__btns.w-m { display: flex; }
.explorer[data-size="m"] .disp__spark.w-m, .explorer[data-size="l"] .disp__spark.w-m { display: block; }
.disp__btns { gap: 8px; }
.disp__btns span { flex: 1; padding: 6px 0; text-align: center; font-size: .62rem; font-weight: 700; color: #fff; background: rgb(255 255 255 / .1); border-radius: 7px; }
.disp__btns span:first-child { background: var(--accent); }
.explorer__cap { margin-top: 1.1rem; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.explorer__cap strong { font-size: 1.15rem; letter-spacing: -.03em; color: #fff; }
.explorer__cap span { font-size: .9rem; color: rgb(255 255 255 / .7); }

/* ---------- 5. Technology cards (carousel) ---------- */
.tech {
  display: flex; flex-direction: column; gap: 1rem;
  padding: clamp(22px, 2.4vw, 30px);
  background: var(--bg-solid);
  border-radius: 26px;
  box-shadow: var(--shadow-sm);
  transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out);
}
.tech:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.tech__logo { display: grid; place-items: center; width: 84px; height: 84px; background: #fff; border: 1px solid var(--border); border-radius: 20px; }
.tech__logo img { width: 56px; height: 44px; object-fit: contain; }
.tech h3 { font-size: 1.3rem; }
.tech p { color: var(--text-muted); font-size: .92rem; flex: 1; }
.tech__use { display: inline-flex; align-items: center; gap: .45rem; align-self: flex-start; padding: .45rem .95rem; font-size: .78rem; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 999px; transition: background .25s var(--ease), color .25s var(--ease); }
.tech__use svg { width: 13px; height: 13px; flex-shrink: 0; }
.tech__use:hover { color: #fff; background: var(--accent); }

/* ---------- 6. Pillars ---------- */
.pillars { display: grid; gap: 14px; }
.pillar-card {
  display: grid; grid-template-columns: 56px 1fr; gap: 1.1rem; align-items: start;
  padding: clamp(18px, 2vw, 26px);
  background: var(--bg-solid);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease-out), box-shadow .35s var(--ease-out);
}
.pillar-card:hover { transform: translateX(6px); box-shadow: var(--shadow-md); }
.pillar-card__n { display: grid; place-items: center; width: 56px; height: 56px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 50%; }
.pillar-card h3 { font-size: 1.15rem; margin-bottom: .3rem; }
.pillar-card p { font-size: .92rem; color: var(--text-muted); }

/* ---------- 7. Gallery slides ---------- */
.shot { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 28px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow-md); }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .9s var(--ease-out); }
.shot:hover img { transform: scale(1.06); }
.shot::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgb(12 8 6 / .88) 100%); }
.shot figcaption { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: clamp(18px, 2.2vw, 28px); color: #fff; }
.shot figcaption small { display: inline-block; margin-bottom: .6rem; padding: .3rem .8rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: var(--accent); border-radius: 999px; }
.shot figcaption strong { display: block; font-size: clamp(1.15rem, 1.9vw, 1.5rem); letter-spacing: -.03em; line-height: 1.2; }
.shot figcaption span { display: block; margin-top: .3rem; font-size: .88rem; color: rgb(255 255 255 / .78); }

/* Home carousel cards stay equal height */
.carousel .card { height: 100%; }
