/* =========================
   Services Grid (Centered + Responsive)
   ========================= */

#services {
  scroll-margin-top: calc(var(--nav-h, 88px) + 12px);
}

#services .section-content {
  max-width: 1200px;
  margin-inline: auto;
  display: grid;
  justify-items: center;
  row-gap: clamp(16px, 2.5vw, 28px);
}

/* Grid */
.services-grid {
  display: grid;
  grid-template-columns: repeat(4, 280px);
  gap: 30px;
  justify-content: center;
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 20px;
  perspective: 1000px;
  transform-style: preserve-3d;
}

@media (max-width: 1024px) {
  .services-grid {
    grid-template-columns: repeat(2, 280px);
  }
}

@media (max-width: 600px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================
   Card
   ========================= */
.service-card {
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;

  width: 100%;
  min-height: 280px;
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .06);

  display: flex;
  flex-direction: column;
  gap: 12px;

  transition: transform .3s ease, box-shadow .3s ease;
  will-change: transform, box-shadow;
}

.service-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .12);
}

/* Focus ring */
.service-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent-color, #24a0ff) 35%, #fff);
}

/* --------- NEW: flag on top (center) --------- */
.svc-flag {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 2px;
}

.flag-top {
  width: 22px;
  height: auto;
  opacity: .95;
}

/* --------- NEW: Title row = name (left) + region (right) --------- */
.svc-head {
  margin-top: 0;
}

.svc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.svc-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .2px;
}

.service-title {
  display: inline-block;
}

.svc-region .region {
  font-size: .95rem;
  font-weight: 700;
  color: #6b7280;
  white-space: nowrap;
}

/* Description centered */
.svc-blurb,
.service-card p {
  flex-grow: 1;
  font-size: .95rem;
  color: #4b5563;
  margin: 0;
  line-height: 1.6;
  text-align: center;
  /* ✅ ตามภาพตัวอย่าง */
}

/* Status badge centered (under description) */
.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  align-self: center;
  /* ✅ กึ่งกลางใน card */
  margin-top: 2px;
  /* ระยะห่างเล็กน้อยใต้ blurb */
}

.badge.coming {
  background: #fff8e1;
  color: #e69500;
  border-color: #ffe29c;
}

.badge.inactive {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #e5e7eb;
}

/* Country Identity (accent bar) */
.service-card.thailand {
  border-left: 6px solid #2ca02c;
}

.service-card.usa {
  border-left: 6px solid #1f77b4;
}

.service-card.global {
  border-left: 6px solid #ff7f0e;
}

.service-card.beta {
  border-left: 6px solid #888;
}

.service-card.thailand:hover {
  border-left-color: #2ca02c;
}

.service-card.usa:hover {
  border-left-color: #1f77b4;
}

.service-card.global:hover {
  border-left-color: #ff7f0e;
}

.service-card.beta:hover {
  border-left-color: #888;
}

/* Tooltip */
.service-card::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 6px;
  padding: 6px 10px;
  background-color: #111827;
  color: #fff;
  font-size: .75rem;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 10;
}

.service-card:focus::after,
.service-card:hover::after {
  opacity: 1;
}

/* Details */
.svc-details {
  margin-top: 4px;
}

.svc-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: .9rem;
  color: #0b74e3;
  user-select: none;
}

.svc-summary::-webkit-details-marker {
  display: none;
}

.svc-summary::before {
  content: "▸";
  transition: transform .25s ease;
  font-size: .9rem;
}

.svc-details[open] .svc-summary::before {
  transform: rotate(90deg);
}

.svc-points {
  margin: 10px 0 4px;
  padding-left: 18px;
  color: #374151;
  font-size: .9rem;
}

.svc-points li {
  margin: 6px 0;
}

/* CTAs */
.services-grid .btn,
.service-card .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 800;
  font-size: .9rem;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  color: #0b74e3;
  background: #fff;
  transition: transform .18s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
}

.services-grid .btn:hover {
  transform: translateY(-1px);
}

.services-grid .btn.primary {
  color: #052a41;
  border-color: transparent;
  background: linear-gradient(90deg, var(--accent-color, #22b8ff), #4cc9ff);
  box-shadow: 0 6px 22px rgba(34, 184, 255, .25);
}

.services-grid .btn.primary:hover {
  box-shadow: 0 10px 28px rgba(34, 184, 255, .35);
}

.services-grid .btn.ghost {
  background: #fff;
}

.svc-ctas {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Scrollbar (optional horizontal) */
.services-grid::-webkit-scrollbar {
  height: 8px;
}

.services-grid::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 4px;
}

/* Section spacing */
#services.section-placeholder {
  padding-top: clamp(12px, 1.4vw, 22px);
  padding-bottom: clamp(56px, 6vw, 96px);
}

#services .section-content {
  row-gap: clamp(8px, 1.2vw, 14px);
}

#services h2,
#services .section-title {
  margin-top: 0;
  margin-bottom: 10px;
}

#services .section-subtext {
  margin-bottom: 18px;
}

#services .services-grid {
  margin-top: 10px;
}

/* Animations */
.service-card.slide {
  animation: slideUp 600ms cubic-bezier(.25, .9, .35, 1) both;
  animation-delay: var(--d, 0ms);
  will-change: transform, opacity, filter;
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(24px);
    filter: blur(4px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
    filter: none;
  }
}

.service-card.play {
  animation: cardLift 680ms cubic-bezier(.22, 1, .36, 1) both;
  animation-delay: var(--d, 0ms);
  will-change: transform, opacity, filter;
}

.service-card.play::before {
  content: "";
  position: absolute;
  inset: -20% -40%;
  border-radius: 20px;
  background: linear-gradient(120deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 35%);
  transform: translateX(-130%);
  animation: sheen 900ms ease-out forwards;
  animation-delay: calc(var(--d, 0ms) + 120ms);
  pointer-events: none;
  z-index: 2;
}

@keyframes cardLift {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(.96) rotateX(6deg);
    filter: blur(6px);
  }

  55% {
    opacity: 1;
    transform: translateY(-6px) scale(1.02) rotateX(0);
    filter: blur(0);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sheen {
  to {
    transform: translateX(135%);
  }
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-allow-motion="true"]) .service-card.slide {
    animation: none !important;
  }

  :root:not([data-allow-motion="true"]) .service-card,
  :root:not([data-allow-motion="true"]) .service-card * {
    transition: none !important;
  }
}

/* Responsive: stack title/region on small screens */
@media (max-width: 480px) {
  .svc-row {
    flex-direction: column;
    gap: 6px;
  }

  .svc-region .region {
    text-align: center;
  }
}