/* =====================================================
   PRODUCT DETAIL — Euromed S.R.L.
   "Clinical Precision" — premium medical-instrument layout
   Featured hero · refined gallery · editorial overview · CTA
   Built on the global design tokens in index.css.
   ===================================================== */

.product-page {
  --ph-ink: var(--primary-950);
  --ph-line: rgba(17, 26, 69, 0.08);
  --ph-frame: rgba(17, 26, 69, 0.10);
  --ph-ease: cubic-bezier(0.22, 1, 0.36, 1);
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 88% -120px, rgba(56, 189, 248, 0.07), transparent 60%),
    var(--gray-50);
  overflow-x: clip;
}

/* =====================================================
   Loading state
   ===================================================== */
.ph-loading {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  color: var(--gray-500);
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
}
.ph-loading__spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary-100);
  border-top-color: var(--accent-500);
  animation: ph-spin 0.8s linear infinite;
}
@keyframes ph-spin { to { transform: rotate(360deg); } }

/* =====================================================
   HERO — split: featured product + intro
   ===================================================== */
.ph-hero {
  position: relative;
  isolation: isolate;
  background: var(--grad-hero);
  color: var(--white);
  padding: clamp(7rem, 12vw, 9.5rem) 0 clamp(3.5rem, 7vw, 6rem);
  overflow: hidden;
}

/* Blueprint grid — engineering precision, faded toward edges */
.ph-hero__grid-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
  background-position: center;
  -webkit-mask-image: radial-gradient(120% 100% at 70% 20%, #000 30%, transparent 78%);
          mask-image: radial-gradient(120% 100% at 70% 20%, #000 30%, transparent 78%);
}
/* Soft accent bloom */
.ph-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 560px;
  height: 560px;
  right: -160px;
  top: -180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.16) 0%, transparent 68%);
  animation: ph-float 12s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ph-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-36px, 28px) scale(1.12); }
}

.ph-hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
}

.ph-hero__content { max-width: 36rem; }

/* Staggered entrance */
.ph-hero__content > *,
.ph-hero__media {
  opacity: 0;
  transform: translateY(18px);
  animation: ph-rise 0.85s var(--ph-ease) forwards;
}
.ph-breadcrumb        { animation-delay: 0.05s; }
.ph-eyebrow           { animation-delay: 0.14s; }
.ph-hero__title       { animation-delay: 0.22s; }
.ph-hero__desc        { animation-delay: 0.32s; }
.ph-hero__actions     { animation-delay: 0.42s; }
.ph-hero__media       { animation-delay: 0.30s; transform: translateY(24px) scale(0.98); }
@keyframes ph-rise { to { opacity: 1; transform: translateY(0) scale(1); } }

/* Breadcrumb */
.ph-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: var(--fs-sm);
  margin-bottom: var(--space-5);
}
.ph-breadcrumb a {
  color: rgba(255, 255, 255, 0.62);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.ph-breadcrumb a:hover { color: var(--accent-300); }
.ph-breadcrumb__sep { color: rgba(255, 255, 255, 0.32); }
.ph-breadcrumb__current {
  color: rgba(255, 255, 255, 0.92);
  font-weight: var(--fw-medium);
}

/* Eyebrow label with leading tick */
.ph-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-300);
  margin-bottom: var(--space-4);
}
.ph-eyebrow::before {
  content: "";
  width: 28px;
  height: 1.5px;
  background: linear-gradient(90deg, var(--teal-400), transparent);
}
.ph-eyebrow--dark { color: var(--accent-600); }
.ph-eyebrow--dark::before { background: linear-gradient(90deg, var(--accent-500), transparent); }

.ph-hero__title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: clamp(2.3rem, 4.6vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-5);
  color: var(--white);
}
.ph-hero__desc {
  font-size: var(--fs-lg);
  line-height: var(--lh-relaxed);
  color: rgba(255, 255, 255, 0.82);
  max-width: 34rem;
  margin-bottom: var(--space-8);
}

.ph-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Featured product stage */
.ph-hero__media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph-stage {
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}
.ph-stage__glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, rgba(125, 211, 252, 0.32), rgba(45, 212, 191, 0.10) 45%, transparent 70%);
  filter: blur(6px);
  animation: ph-pulse 6s ease-in-out infinite;
}
@keyframes ph-pulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.ph-stage__img {
  position: relative;
  z-index: 2;
  max-width: 84%;
  max-height: 84%;
  object-fit: contain;
  filter: drop-shadow(0 30px 50px rgba(5, 10, 30, 0.55));
  animation: ph-bob 7s ease-in-out infinite;
}
@keyframes ph-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
/* Pedestal reflection */
.ph-stage__pedestal {
  position: absolute;
  z-index: 1;
  bottom: 7%;
  left: 50%;
  width: 62%;
  height: 26px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(5, 10, 30, 0.5), transparent 72%);
  filter: blur(4px);
}

/* =====================================================
   Buttons
   ===================================================== */
.ph-btn {
  --shine: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-full);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform var(--transition-base), box-shadow var(--transition-base),
              background var(--transition-base), border-color var(--transition-base), color var(--transition-base);
}
.ph-btn svg { width: 17px; height: 17px; transition: transform var(--transition-base); }
.ph-btn--primary {
  background: var(--grad-accent);
  color: #04263a;
  box-shadow: var(--shadow-glow);
}
.ph-btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.3), 0 22px 48px -14px rgba(14, 165, 233, 0.6);
}
.ph-btn--primary:hover svg { transform: translateX(3px); }
.ph-btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.24);
  color: var(--white);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}
.ph-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.45);
  transform: translateY(-2px);
}
.ph-btn--lg { padding: 1rem 2rem; font-size: var(--fs-base); }

/* =====================================================
   Section heads
   ===================================================== */
.ph-section-head { margin-bottom: clamp(2rem, 4vw, 3rem); }
.ph-section-head--center { text-align: center; }
.ph-section-head--center .ph-eyebrow::before { display: none; }
.ph-section-head--center .ph-eyebrow { padding: 0; }
.ph-section-title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ph-ink);
}

/* =====================================================
   CINEMATIC SHOWCASE — pinned SPLIT stage, scroll-driven
   Picture on one side, the active paragraph on the other.
   Sides alternate per paragraph "chapter"; the picture
   morphs through every image as you scroll. A single-image
   product keeps the picture fixed and just morphs the text.
   Driven by initCineScroll() (continuous) with an
   IntersectionObserver fallback for reduced motion.
   ===================================================== */
.ph-cine {
  position: relative;
  background: var(--primary-950);
}

/* Pinned stage */
.ph-cine__viewport {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

/* Dramatic backdrop + blueprint grid */
.ph-cine__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--grad-hero);
}
.ph-cine__bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 54px 54px;
  -webkit-mask-image: radial-gradient(120% 100% at 50% 35%, #000 25%, transparent 80%);
          mask-image: radial-gradient(120% 100% at 50% 35%, #000 25%, transparent 80%);
}

.ph-cine__overline {
  position: absolute;
  z-index: 4;
  top: clamp(1.25rem, 4.5vh, 2.75rem);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-300);
}

/* Two-column split. The columns swap sides via --flip (0 = picture left,
   1 = picture right), driven by the scroll engine. The picture and text
   never share a column, so text never overlaps the image. */
.ph-cine__split {
  --cine-gap: clamp(1.25rem, 4vw, 3.25rem);
  position: relative;
  z-index: 1;
  width: min(1180px, 92vw);
  height: min(640px, 76vh);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--cine-gap);
}
.ph-cine__col {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ph-cine__col--media { grid-column: 1; }
.ph-cine__col--text  { grid-column: 2; }

/* Live engine: the columns translate a full cell to swap sides, and JS sets
   the per-frame picture/text styles — so CSS transitions step aside. */
.ph-cine--live .ph-cine__col--media {
  transform: translateX(calc(var(--flip, 0) * (100% + var(--cine-gap))));
  will-change: transform;
}
.ph-cine--live .ph-cine__col--text {
  transform: translateX(calc(var(--flip, 0) * (-100% - var(--cine-gap))));
  will-change: transform;
}
.ph-cine--live .ph-cine__shot,
.ph-cine--live .ph-cine__block { transition: none; }
.ph-cine--live .ph-cine__shot {
  will-change: opacity, transform, filter, clip-path;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
}

/* Picture column: stacked image cards, only the active one resolves in. */
.ph-cine__media {
  position: relative;
  width: 100%;
  height: 100%;
}
.ph-cine__shot {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2.5vw, 2.25rem);
  background: radial-gradient(120% 100% at 50% 0%, var(--white), var(--gray-50));
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-2xl);
  opacity: 0;
  transform: scale(1.08);
  filter: blur(13px);
  clip-path: inset(8% 10% 8% 10% round 36px);
  transition:
    opacity 0.7s ease,
    transform 0.9s var(--ph-ease),
    filter 0.7s ease,
    clip-path 0.9s var(--ph-ease);
}
.ph-cine__shot.is-active {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
  clip-path: inset(0% 0% 0% 0% round 22px);
  z-index: 2;
}
.ph-cine__shot img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 32px rgba(11, 16, 32, 0.18));
}

/* Text column: stacked paragraph blocks, crossfaded by the engine. */
.ph-cine__textwrap {
  position: relative;
  width: 100%;
  height: 100%;
}
.ph-cine__block {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  padding: clamp(0.5rem, 2vw, 1.5rem);
  color: rgba(255, 255, 255, 0.92);
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.6s var(--ph-ease), transform 0.6s var(--ph-ease);
}
.ph-cine__block.is-active { opacity: 1; transform: translateY(0); }
.ph-cine__block::before {
  content: "";
  width: 42px;
  height: 2px;
  background: linear-gradient(90deg, var(--teal-400), transparent);
}
.ph-cine__block-index {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5.5vw, 3.5rem);
  font-weight: var(--fw-bold);
  line-height: 1;
  color: transparent;
  -webkit-background-clip: text;
          background-clip: text;
  background-image: linear-gradient(120deg, var(--accent-300), var(--teal-400));
}
.ph-cine__block p {
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  line-height: 1.85;
  max-width: 48ch;
}

/* Progress rail (one dot per image) */
.ph-cine__rail {
  position: absolute;
  z-index: 4;
  right: clamp(0.75rem, 2vw, 1.5rem);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ph-cine__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  transition: background 0.4s var(--ph-ease), height 0.4s var(--ph-ease);
}
.ph-cine__dot.is-active {
  background: var(--accent-400);
  height: 24px;
  border-radius: 5px;
}

/* Invisible scroll "steps" — one per beat — drive the stage. */
.ph-cine__step {
  height: var(--step-h, 72vh);
  pointer-events: none;
}
.ph-cine__step:first-child { height: 30vh; }
.ph-cine__step:last-child  { height: 42vh; }

/* Stack on narrow screens: picture above, text below — no side swap. */
@media (max-width: 820px) {
  .ph-cine__split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.05fr) minmax(0, 0.95fr);
    width: 92vw;
    height: min(82vh, 720px);
    gap: clamp(0.75rem, 3vw, 1.5rem);
  }
  .ph-cine__col--media { grid-column: 1; grid-row: 1; }
  .ph-cine__col--text  { grid-column: 1; grid-row: 2; }
  .ph-cine--live .ph-cine__col--media,
  .ph-cine--live .ph-cine__col--text { transform: none; }
  .ph-cine__block { justify-content: flex-start; gap: var(--space-3); }
  .ph-cine__block-index { font-size: clamp(2rem, 9vw, 2.6rem); }
  .ph-cine__rail { right: 0.5rem; }
}

/* Phones: the text cell is short, so a long paragraph used to be clipped and
   the next beat arrived before you could finish reading. Give the text the
   larger share of the stage and let the *active* block scroll within its cell
   — you read the whole paragraph first, then keep scrolling to advance the
   beat. Only the live block owns touch (set by the engine), so a swipe lands
   on the visible text rather than a faded-out block stacked on top of it. */
@media (max-width: 640px) {
  .ph-cine__split {
    grid-template-rows: minmax(0, 0.82fr) minmax(0, 1.18fr);
    height: min(86vh, 760px);
  }

  .ph-cine__block {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 0.85rem;          /* room for the scrollbar/thumb */
    pointer-events: none;            /* faded, stacked blocks ignore touch */
  }
  .ph-cine__block.is-current { pointer-events: auto; }

  .ph-cine__block p {
    font-size: 1rem;
    line-height: 1.6;
    max-width: none;
  }
}

/* Motion-safe: instant swaps, no morph/slide */
@media (prefers-reduced-motion: reduce) {
  .ph-cine__shot,
  .ph-cine__block {
    transition: opacity 0.25s linear !important;
    transform: none !important;
    filter: none !important;
    clip-path: none !important;
  }
  .ph-cine__col--media,
  .ph-cine__col--text { transform: none !important; }
}

/* =====================================================
   OVERVIEW — editorial article
   ===================================================== */
.ph-overview {
  position: relative;
  padding: clamp(3rem, 6vw, 5.5rem) 0 clamp(1rem, 3vw, 2rem);
}
.ph-overview__inner { max-width: 760px; margin: 0 auto; }

.ph-article {
  position: relative;
  padding-left: clamp(1.25rem, 3vw, 2rem);
  border-left: 2px solid;
  border-image: linear-gradient(to bottom, var(--accent-500), var(--teal-400), transparent) 1;
}
.ph-article__p {
  font-size: 1.075rem;
  line-height: 1.9;
  color: var(--gray-700);
  margin-bottom: var(--space-6);
}
.ph-article__p:last-child { margin-bottom: 0; }
.ph-article__p--lead {
  font-size: 1.22rem;
  line-height: 1.7;
  color: var(--gray-800);
  font-weight: var(--fw-medium);
}

/* =====================================================
   CONTACT CTA band
   ===================================================== */
.ph-cta {
  padding: clamp(3rem, 6vw, 5.5rem) 0 clamp(4rem, 8vw, 7rem);
}
.ph-cta__card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(1.5rem, 4vw, 3rem);
  background: var(--grad-brand);
  color: var(--white);
  border-radius: var(--radius-3xl);
  padding: clamp(2.25rem, 5vw, 3.5rem) clamp(2rem, 5vw, 4rem);
  box-shadow: var(--shadow-xl);
}
.ph-cta__card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(90% 120% at 100% 0%, #000, transparent 70%);
          mask-image: radial-gradient(90% 120% at 100% 0%, #000, transparent 70%);
}
.ph-cta__text { max-width: 38rem; }
.ph-cta__title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.18;
  margin: var(--space-2) 0 var(--space-3);
  color: var(--white);
}
.ph-cta__desc {
  color: rgba(255, 255, 255, 0.82);
  line-height: var(--lh-relaxed);
}
.ph-cta__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}
.ph-cta__phone {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: var(--fw-medium);
  transition: color var(--transition-fast);
}
.ph-cta__phone svg { width: 18px; height: 18px; color: var(--accent-300); }
.ph-cta__phone:hover { color: var(--white); }

/* =====================================================
   Scroll reveal
   ===================================================== */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity 0.8s var(--ph-ease), transform 0.8s var(--ph-ease);
}
.reveal-on-scroll.revealed { opacity: 1; transform: translateY(0); }

/* =====================================================
   Error state
   ===================================================== */
.product-error {
  text-align: center;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(6rem, 14vw, 9rem) var(--space-6);
}
.product-error__title {
  font-family: var(--font-display);
  font-size: var(--fs-4xl);
  color: var(--ph-ink);
  margin-bottom: var(--space-4);
}
.product-error__desc {
  font-size: var(--fs-lg);
  color: var(--gray-600);
  line-height: var(--lh-relaxed);
  margin-bottom: var(--space-8);
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 900px) {
  .ph-hero__inner {
    grid-template-columns: 1fr;
    text-align: center;
    gap: clamp(2rem, 6vw, 3rem);
  }
  .ph-hero__content { max-width: none; margin: 0 auto; }
  .ph-breadcrumb,
  .ph-hero__actions { justify-content: center; }
  .ph-eyebrow { justify-content: center; }
  .ph-hero__desc { margin-left: auto; margin-right: auto; }
  .ph-hero__media { order: -1; }
  .ph-stage { max-width: 320px; }
  .ph-cta__card { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
  .ph-hero__actions { flex-direction: column; align-items: stretch; }
  .ph-hero__actions .ph-btn { justify-content: center; }
  .ph-cta__actions { width: 100%; }
  .ph-cta__actions .ph-btn { width: 100%; justify-content: center; }
}

/* Motion-safe */
@media (prefers-reduced-motion: reduce) {
  .ph-hero__content > *,
  .ph-hero__media,
  .reveal-on-scroll {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .ph-stage__img,
  .ph-stage__glow,
  .ph-hero::after { animation: none !important; }
}
