.m3x-section { position: relative; isolation: isolate; }

.m3x-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Grid */
.m3x-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2.5vw, 28px);
  perspective: 1000px; /* subtle 3D on hover */
  padding: 5%;
}
@media (max-width: 1100px) {
  .m3x-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .m3x-grid { grid-template-columns: 1fr; }
}

/* Card */
.m3x-card {
  --m3x-radius: 16px;
  --m3x-shadow: 0 10px 24px rgba(0,0,0,.15);
  --m3x-shadow-hover: 0 18px 40px rgba(0,0,0,.22);
  --m3x-border: rgba(255,255,255,.08);
  border-radius: var(--m3x-radius);
  box-shadow: var(--m3x-shadow);
  transform-style: preserve-3d;
  transform: translateY(10px) scale(.98);
  animation: m3x-rise .8s cubic-bezier(.2,.7,.2,1) both;
  animation-delay: var(--m3x-delay, 0ms);
  overflow: clip; /* modern, avoids leaking shadows on radius */
  border: 1px solid var(--m3x-border);
  background: transparent; /* no background color to avoid site impact */
}
.m3x-card:hover {
  transform: translateY(-2px) scale(1) rotateX(0.6deg) rotateY(-0.6deg);
  box-shadow: var(--m3x-shadow-hover);
}

/* Media (image wrapper) */
.m3x-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.m3x-media img {
  width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.04);
  transition: transform .8s cubic-bezier(.2,.7,.2,1), filter .6s ease;
  will-change: transform;
}
.m3x-card:hover .m3x-media img {
  transform: scale(1.12) translateY(-2px);
  filter: saturate(1.05) contrast(1.02);
}

/* Shimmer/glow sweep */
.m3x-glow {
  position: absolute; inset: -20% -40%;
  background: radial-gradient(60% 60% at 50% 50%, rgba(255,255,255,.18), transparent 60%),
              linear-gradient(110deg, transparent 40%, rgba(255,255,255,.18) 50%, transparent 60%);
  mix-blend-mode: screen; pointer-events: none;
  transform: translateX(-60%);
  animation: m3x-sheen 3.2s ease-in-out infinite;
  opacity: .0;
}
.m3x-card:hover .m3x-glow { opacity: .9; }

/* Meta */
.m3x-meta { padding: clamp(12px, 2.2vw, 18px); }
.m3x-title {
  margin: 0 0 .35em; font-weight: 700; letter-spacing: .2px;
  line-height: 1.2;
}
.m3x-desc {
  margin: 0 0 1rem; opacity: .85; line-height: 1.55;
}

/* Button (underline → pill morph + ripple) */
.m3x-btn {
  --m3x-accent: currentColor; /* inherits your theme color */
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5em;
  padding: .7em 1.15em;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  outline: none;
  border: 1px solid color-mix(in srgb, currentColor 28%, transparent);
  transition: transform .2s ease, box-shadow .3s ease, background .3s ease, border-color .3s ease;
  box-shadow: 0 6px 14px rgba(0,0,0,.06);
  background: linear-gradient(0deg, color-mix(in srgb, currentColor 6%, transparent), transparent);
}
.m3x-btn:before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(120% 120% at 0% 0%, color-mix(in srgb, currentColor 16%, transparent), transparent 70%);
  opacity: 0; transition: opacity .3s ease;
}
.m3x-btn:after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.18), transparent 40%);
  mix-blend-mode: soft-light; opacity: .6; pointer-events: none;
}
.m3x-btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, currentColor 40%, transparent);
  box-shadow: 0 10px 22px rgba(0,0,0,.12);
}
.m3x-btn:hover:before { opacity: 1; }
.m3x-btn:active { transform: translateY(0); }

/* Ripple (CSS-only illusion) */
.m3x-btn span {
  position: relative;
  z-index: 1;
}
.m3x-btn:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 30%, transparent);
}

/* Keyframes */
@keyframes m3x-rise {
  from { opacity: 0; transform: translateY(24px) scale(.98) rotateX(2deg); }
  to   { opacity: 1; transform: translateY(10px) scale(.98) rotateX(0deg); }
}
@keyframes m3x-sheen {
  0%, 20%   { transform: translateX(-60%) skewX(-8deg); opacity: .0; }
  30%, 50%  { transform: translateX(0%)   skewX(-8deg); opacity: .6; }
  60%, 100% { transform: translateX(80%)  skewX(-8deg); opacity: .0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .m3x-card, .m3x-media img, .m3x-glow, .m3x-btn,
  .m3x-btn:before, .m3x-btn:after { animation: none !important; transition: none !important; }
  .m3x-card { transform: none; }
}