/* 2P ENGINEERING — v3 features
   1. services: 3D service landing (.s3d)
   2. contact: step-by-step contact box (.cbox)
   3. projects: rotating 3D ring (.ring) */

/* ================= 1 · 3D SERVICE LANDING ================= */
.s3d-section { padding: clamp(28px, 4vw, 48px) 0 0; }
.s3d-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; margin-bottom: 22px; }
.s3d-head .h-section { margin: 10px 0 0; }
.s3d-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 5px; background: var(--surface-2); border-radius: 999px; }
.s3d-tab { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--muted); transition: background .25s ease, color .25s ease; }
.s3d-tab span { font-size: 11px; opacity: .6; }
.s3d-tab:hover { color: var(--text); }
.s3d-tab.on { background: #fff; color: var(--text); box-shadow: 0 4px 14px -6px rgba(14, 27, 66, .25); }
.s3d-tab:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }

.s3d-stage {
  position: relative; overflow: hidden; isolation: isolate;
  height: clamp(520px, 52vw, 680px); border-radius: var(--radius-lg);
  background: #EEF1F6 url(../images/map-poster.jpg) center / cover no-repeat; touch-action: pan-y; outline: none;
}
.s3d-stage:focus-visible { box-shadow: 0 0 0 3px var(--steel); }
.s3d-canvas, .s3d-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.s3d-canvas { opacity: 0; transition: opacity .8s ease; }
.s3d.is-3d .s3d-canvas { opacity: 1; }
.s3d.is-3d .s3d-veil { position: absolute; inset: 0; background: #EEF0F5; opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 5; }
.s3d-veil.on { opacity: 1; }

.s3d-slide { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease; }
.s3d-slide.active { opacity: 1; }
.s3d-slide.active .s3d-panel, .s3d-slide.active .s3d-panel a { pointer-events: auto; }

/* pop-up labels pinned to the 3D scene (theme 2) */
.s3d-labels { position: absolute; inset: 0; }
.s3d:not(.is-3d) .s3d-labels { display: none; }
.s3d-lbl { position: absolute; left: 0; top: 0; will-change: transform; }
.s3d-lbl .s3d-chip {
  position: absolute; left: 0; bottom: 14px; transform: translateX(calc(-50% + var(--dx, 0px))) translateY(10px) scale(.7);
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 9px 15px 9px 9px; border-radius: 999px;
  background: rgba(226, 248, 233, .94); border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 10px 28px -10px rgba(20, 60, 40, .35);
  color: #17331F; font-size: 13.5px; font-weight: 600; letter-spacing: -.005em;
  opacity: 0; filter: blur(6px); transition: opacity .45s ease, transform .55s cubic-bezier(.2, 1.4, .4, 1), filter .45s ease;
}
.s3d-lbl .s3d-chip i {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: #2FBF62
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.3 8.3 2.4 2.4 5-5.2' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.s3d-lbl::before { content: ""; position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: #2FBF62; box-shadow: 0 0 0 4px rgba(47, 191, 98, .25); opacity: 0; transform: scale(0); transition: opacity .3s ease, transform .4s ease; }
.s3d-lbl::after { content: ""; position: absolute; left: -.5px; bottom: 4px; width: 1px; height: 10px; background: rgba(23, 51, 31, .35); opacity: 0; transition: opacity .3s ease; }
.s3d-lbl.on .s3d-chip { opacity: 1; filter: none; transform: translateX(calc(-50% + var(--dx, 0px))) translateY(0) scale(1); }
.s3d-lbl.on::before { opacity: 1; transform: scale(1); }
.s3d-lbl.on::after { opacity: 1; }
.s3d-lbl:nth-child(2).on .s3d-chip, .s3d-lbl:nth-child(2).on::before { transition-delay: .14s; }
.s3d-lbl:nth-child(3).on .s3d-chip, .s3d-lbl:nth-child(3).on::before { transition-delay: .28s; }
.s3d-lbl:nth-child(4).on .s3d-chip, .s3d-lbl:nth-child(4).on::before { transition-delay: .42s; }

/* glass panel with the sub-services */
.s3d-panel {
  position: absolute; left: 18px; bottom: 18px; z-index: 3; width: min(360px, calc(100% - 36px));
  padding: 18px 18px 16px; border-radius: 20px;
  background: rgba(255, 255, 255, .8); border: 1px solid rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px -20px rgba(14, 27, 66, .35);
}
.s3d-panel .en { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.s3d-panel h3 { margin: 6px 0 12px; font-size: 20px; font-weight: 600; letter-spacing: -.015em; line-height: 1.25; }
.s3d-panel ol { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 7px; }
.s3d-panel li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text); }
.s3d-panel li span {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--surface-2);
  transition: background .3s ease, color .3s ease;
}
.s3d-panel li.on span { background: #2FBF62; color: transparent; }
.s3d-panel li.on span::after { content: ""; position: absolute; width: 24px; height: 24px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.3 8.3 2.4 2.4 5-5.2' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.s3d-panel li span { position: relative; }
.s3d-panel li:nth-child(2) span { transition-delay: .14s; }
.s3d-panel li:nth-child(3) span { transition-delay: .28s; }
.s3d-panel li:nth-child(4) span { transition-delay: .42s; }
.s3d-panel a { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--navy); }
.s3d-panel a::after { content: "→"; transition: transform .2s ease; }
.s3d-panel a:hover::after { transform: translateX(3px); }

.s3d-status {
  position: absolute; top: 18px; left: 18px; z-index: 3;
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); font-size: 13px; color: var(--muted);
  box-shadow: 0 8px 22px -12px rgba(14, 27, 66, .3); white-space: nowrap;
}
.s3d-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); animation: s3d-blink 1.6s ease-in-out infinite; }
.s3d-status .live { display: none; color: #17331F; }
.s3d.is-live .s3d-status i { background: #2FBF62; }
.s3d.is-live .s3d-status .idle { display: none; }
.s3d.is-live .s3d-status .live { display: inline; }
.s3d:not(.is-3d) .s3d-status { display: none; }
@keyframes s3d-blink { 50% { opacity: .35; } }

.s3d-cta {
  position: absolute; top: 16px; right: 16px; z-index: 3;
  padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 600; color: #fff;
  background: var(--navy); box-shadow: 0 10px 24px -10px rgba(28, 53, 126, .6); transition: transform .2s ease;
}
.s3d-cta:hover { transform: translateY(-2px); }
.s3d-nav { position: absolute; right: 16px; bottom: 16px; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 5px; border-radius: 999px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); }
.s3d-nav button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; color: var(--text); cursor: pointer; display: grid; place-items: center; box-shadow: 0 2px 8px -3px rgba(14, 27, 66, .25); transition: background .2s ease, color .2s ease; }
.s3d-nav button:hover { background: var(--ink); color: #fff; }
.s3d-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.s3d-canvas canvas { cursor: grab; }
.s3d-canvas canvas:active { cursor: grabbing; }
.s3d-zoom { position: absolute; right: 16px; bottom: 76px; z-index: 3; display: grid; gap: 6px; padding: 5px; border-radius: 999px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); }
.s3d-zoom button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; color: var(--text); cursor: pointer; display: grid; place-items: center; box-shadow: 0 2px 8px -3px rgba(14, 27, 66, .25); transition: background .2s ease, color .2s ease; }
.s3d-zoom button:hover { background: var(--ink); color: #fff; }
.s3d-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 3; margin: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; white-space: nowrap;
  background: rgba(255, 255, 255, .8); backdrop-filter: blur(10px); font-size: 12.5px; color: var(--muted);
}
.s3d:not(.is-3d) .s3d-zoom, .s3d:not(.is-3d) .s3d-hint { display: none; }
.s3d-count b { color: var(--text); font-weight: 600; }

@media (max-width: 720px) {
  .s3d-stage { height: 600px; }
  .s3d-tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .s3d-tab { white-space: nowrap; padding: 8px 13px; font-size: 13px; }
  .s3d-panel { padding: 14px; }
  .s3d-panel h3 { font-size: 17px; margin-bottom: 8px; }
  .s3d-panel li { font-size: 12.5px; }
  .s3d-panel ol { display: none; }
  .s3d-panel { left: 12px; bottom: 12px; width: calc(100% - 24px); }
  .s3d-nav { bottom: 132px; right: 12px; }
  .s3d-zoom { right: auto; left: 12px; bottom: 132px; grid-auto-flow: column; }
  .s3d-zoom button { width: 36px; height: 36px; }
  .s3d-hint { bottom: auto; top: 58px; left: 14px; transform: none; font-size: 11.5px; padding: 6px 11px; }
  .s3d-cta { top: 12px; right: 12px; padding: 9px 15px; font-size: 13px; }
  .s3d-status { top: 14px; left: 14px; transform: none; font-size: 12px; padding: 8px 12px; }
  .s3d-lbl .s3d-chip { font-size: 11.5px; padding: 6px 11px 6px 6px; gap: 6px; }
  .s3d-lbl .s3d-chip i { width: 18px; height: 18px; background-size: 12px; }
}

/* ================= 3 · PROJECTS RING ================= */
.ring-section { padding: clamp(28px, 4vw, 48px) 0 0; overflow: hidden; }
.ring-stage { position: relative; height: clamp(300px, 34vw, 440px); cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ring-stage.drag { cursor: grabbing; }
.ring { position: absolute; left: 50%; top: 50%; }
.ring-card {
  position: absolute; left: 0; top: 0; margin: 0; overflow: hidden; backface-visibility: hidden;
  width: var(--rw, 240px); height: var(--rh, 300px); margin-left: calc(var(--rw, 240px) / -2); margin-top: calc(var(--rh, 300px) / -2);
  border-radius: 6px; background: #ddd center / cover no-repeat; will-change: transform;
}
.ring-card figcaption {
  position: absolute; left: 10px; right: 10px; bottom: 10px; padding: 8px 10px; border-radius: 10px;
  background: rgba(10, 14, 30, .55); backdrop-filter: blur(8px); color: #fff; font-size: 12.5px; line-height: 1.35;
  opacity: 0; transform: translateY(8px); transition: opacity .3s ease, transform .3s ease;
}
.ring-card:hover figcaption, .ring-card:focus-visible figcaption { opacity: 1; transform: none; }
.ring-card:focus-visible { outline: 3px solid var(--steel); outline-offset: -3px; }
.ring-hint { display: flex; justify-content: center; gap: 8px; align-items: center; margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.ring-hint svg { opacity: .7; }
@media (max-width: 600px) { .ring-stage { height: 230px; } }
/* phones / touch screens: no caption pops up when a ring photo is touched */
@media (max-width: 600px), (hover: none) { .ring-card figcaption { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .cbox-step, .cbox-done, .s3d-lbl .s3d-chip { transition: none; }
}

/* 3D map loading indicator */
.s3d-loading {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 4; margin: 0;
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 999px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(10px); font-size: 13.5px; color: var(--muted);
  box-shadow: 0 10px 30px -14px rgba(14, 27, 66, .35);
}
.s3d-loading i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #D5D2EC; border-top-color: #7B6CFF; animation: s3d-spin .8s linear infinite; }
.s3d-loading b { color: var(--text); font-variant-numeric: tabular-nums; }
@keyframes s3d-spin { to { transform: rotate(360deg); } }
.s3d.is-3d .s3d-loading { display: none; }
/* services intro pills steer the 3D map: the selected one keeps its hover colours */
.svc-pills a[data-s3d-tab] { cursor: pointer; }
.svc-pills .sp1.on { background: #FFF1CC; color: #7A4A00; }
.svc-pills .sp2.on { background: var(--grad-warm); color: var(--ink); }
.svc-pills .sp3.on { background: #E1F1FA; color: var(--steel); }
.svc-pills .sp4.on { background: var(--ink); color: #fff; }
.svc-pills .sp4.on span { background: rgba(255, 255, 255, .16); color: #fff; }
.svc-pills a.on { box-shadow: 0 10px 22px -12px rgba(14, 27, 66, .45); }
/* hint: mouse vs touch wording */
.s3d-hint .touch { display: none; }
@media (hover: none) { .s3d-hint .mouse { display: none; } .s3d-hint .touch { display: inline; } }

/* services showcase: facts the 3D map doesn't show */
.show-card .facts { margin: 10px 0 0; display: grid; gap: 0; border-top: 1px solid rgba(14, 27, 66, .08); }
.show-card .facts > div { display: grid; grid-template-columns: 9.5em 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid rgba(14, 27, 66, .08); font-size: 14px; }
.show-card .facts dt { color: var(--muted); }
.show-card .facts dd { margin: 0; color: var(--text); }
.show-card .facts a { font-weight: 600; color: var(--navy); }
.show-card .facts a::after { content: " →"; }
@media (max-width: 560px) { .show-card .facts > div { grid-template-columns: 1fr; gap: 2px; font-size: 13px; } }
/* the cards grew (scope list + facts): let the photo fill the card's full height on wide screens */
@media (min-width: 901px) {
  .show-card .media { height: auto !important; min-height: 300px; align-self: stretch; }
  .show-card .media img { position: absolute; inset: 0; height: 100%; }
}
/* service pills now sit between the 3D heading and the map */
.s3d .svc-pills { margin: 0 0 16px; padding-top: 0; border-top: 0; }
.s3d .s3d-head { margin-bottom: 18px; }
@media (max-width: 600px) { .s3d .svc-pills { gap: 6px; margin-bottom: 12px; } }

/* once the 3D map is running the preview image must not show behind it (it did when orbiting) */
.s3d.is-3d .s3d-stage { background: linear-gradient(180deg, #E9EDF4 0%, #F1F3F7 55%, #F4F5F8 100%); }
/* projects page: clients block between the ring and the project grid */
@media (min-width: 901px) { #clients .client-grid { grid-template-columns: repeat(5, 1fr); } }
#clients + #works-grid { padding-top: 16px; }
/* ---- fixed-camera map: labels are laid out by js/svc3d.js (no overlaps) ---- */
.s3d-lbl .s3d-chip, .s3d-lbl.on .s3d-chip {
  left: var(--cx, 0px); top: var(--cy, -48px); bottom: auto;
  transform-origin: 50% 100%;
}
.s3d-lbl .s3d-chip { transform: scale(.82); }
.s3d-lbl.on .s3d-chip { transform: none; }
.s3d-lbl::after { top: var(--st, -14px); bottom: auto; height: var(--sh, 10px); }
.s3d-canvas canvas, .s3d-canvas canvas:active { cursor: default; }
.s3d-zoom, .s3d-hint { display: none !important; }
@media (max-width: 720px) {
  .s3d-lbl .s3d-chip { white-space: normal; max-width: min(230px, 64vw); line-height: 1.3; font-size: 11.5px; }
}/* phones: chips keep their natural width (they were shrinking to one word per line) */
@media (max-width: 720px) {
  .s3d-lbl .s3d-chip { width: max-content; max-width: 58vw; white-space: normal; font-size: 11px; padding: 6px 10px 6px 6px; gap: 6px; }
  .s3d-lbl .s3d-chip i { width: 16px; height: 16px; background-size: 11px; }
  .s3d-stage { height: 640px; }
}
/* 3D BANNER: the site model (pilot3d/, rendered in Blender) as a full-width banner at the top of the services page.
   The glass bar merges the section heading with the four service pills (they open the matching zone in the model). */
.p3d-banner { position: relative; margin: -8px 0 clamp(28px, 4vw, 48px); }
.p3d { position: relative; width: 100%; height: clamp(520px, calc(100svh - 104px), 56.25vw); background: #E9ECF2; overflow: hidden; }
.p3d iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.p3d-bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 2; max-width: calc(100% - 200px);
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .62); border: .5px solid rgba(255, 255, 255, .7);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 10px 30px -14px rgba(14, 27, 66, .35);
}
.p3d-bar { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Noto Sans Thai", sans-serif; }
.p3d-bar .svc-pills a { font-family: inherit; }
.p3d-eyebrow { font-size: 12.5px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.p3d-bar .svc-pills { margin: 0; padding: 0; border: 0; gap: 6px; flex-wrap: nowrap; }
.p3d-bar .svc-pills a { padding-block: 7px; font-size: 13.5px; white-space: nowrap; }
.p3d-bar .svc-pills a:hover { transform: none; }
@media (max-width: 1100px) { .p3d-eyebrow { display: none; } .p3d-bar { padding-left: 6px; } }
@media (max-width: 900px) {   /* tablet / phone: the bar sits under the model so it never covers it */
  /* overview: 16:9 so the whole model frame shows (no crop / zoom); a zone's detail view needs the taller box */
  .p3d { height: 56.25vw; transition: height .45s cubic-bezier(.2,.8,.2,1); }
  .p3d.zone-open { height: calc(56.25vw + 300px); }   /* full 16:9 video + the service box below it */
  .p3d-bar { position: static; transform: none; max-width: none; margin: 10px 12px 0; border-radius: 18px; padding: 6px; overflow-x: auto; background: var(--surface-2); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  .p3d-bar .svc-pills { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .p3d-bar .svc-pills a { white-space: normal; font-size: 12.5px; line-height: 1.25; justify-content: flex-start; }
}