/* ==========================================================================
   SHARED CARD SYSTEM (dh-card) — single source of truth for border, radius,
   shadow, hover motion and material across every content card on the site.
   Loaded on every page, after component-specific stylesheets.

   Usage: add `dh-card` plus one variant to any eligible content card.
     dh-card dh-card--surface  → card with no photograph (text/number/icon)
     dh-card dh-card--media    → card whose surface is a photo/thumbnail
   ========================================================================== */
.dh-card {
  position: relative;
  isolation: isolate;
  border: 1px solid var(--dh-card-border);
  border-radius: 14px;
  box-shadow: var(--dh-card-shadow);
  transition:
    transform 1100ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 1100ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 1100ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dh-card--surface {
  background-color: var(--dh-card-bg-mid);
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='.18'/%3E%3C/svg%3E"),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 22%),
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.03) 0%, transparent 44%),
    linear-gradient(145deg, var(--dh-card-bg-start) 0%, var(--dh-card-bg-mid) 47%, var(--dh-card-bg-end) 100%);
  background-size: 180px 180px, auto, auto, auto;
  background-blend-mode: soft-light, normal, normal, normal;
}

/* Mouse-follow highlight — extremely subtle light moving across dark
   titanium, set via --mx/--my custom properties (js/mouse-glow.js).
   Opacity stays low; disabled entirely under prefers-reduced-motion or on
   coarse/touch pointers (see media query below + the JS feature check). */
.dh-card::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    300px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.08),
    transparent 68%
  );
  opacity: 0;
  transition: opacity var(--transition-med);
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .dh-card:hover::before { opacity: 1; }
}

.dh-card--media {
  overflow: hidden;
  background: var(--dh-card-bg-end);
}

.dh-card--media::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 18%),
    var(--dh-card-media-gradient);
  opacity: 1;
  pointer-events: none;
  transition: opacity 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dh-card--media > img,
.dh-card--media > picture,
.dh-card--media > video {
  position: relative;
  z-index: 0;
}

.dh-card--media > :not(img):not(picture):not(video) {
  position: relative;
  z-index: 2;
}

@media (hover: hover) and (pointer: fine) {
  .dh-card:hover {
    transform: translateY(-4px);
    border-color: var(--dh-card-border-hover);
    box-shadow:
      0 30px 62px -30px rgba(0, 0, 0, 0.9),
      0 0 20px rgba(255, 255, 255, 0.06),
      inset 0 1px 0 rgba(255, 255, 255, 0.06);
  }

  .dh-card--media:hover::after {
    opacity: 0;
  }
}

.dh-card--media:focus-within::after {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .dh-card,
  .dh-card--media::after,
  .dh-card::before {
    transition: none;
  }

  .dh-card:hover {
    transform: none;
  }

  .dh-card::before {
    display: none;
  }
}
