/* Centro Dental Innova — responsive overrides.
   The design uses inline CSS-in-JS, so we target inline-style substrings with !important.
   All grid selectors are kept at equal specificity [style*=...] so source order + media
   width decide the winner (never mix in a tag qualifier — it silently out-specifies these). */

html { scroll-padding-top: 84px; }               /* fixed-header offset for anchor jumps */
html, body { overflow-x: hidden; max-width: 100vw; }
img, video, iframe { max-width: 100%; }

/* ---------- Grid collapse (target the ORIGINAL inline value strings) ---------- */
@media (max-width: 1024px) {
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 760px) {
  [style*="grid-template-columns:1.05fr .95fr"]  { grid-template-columns: 1fr !important; }
  /* #doctor puts the grid on the data-reveal element itself; reveal JS re-serializes its
     inline style (.85fr -> 0.85fr), breaking a [style*=] match — target by id instead. */
  section#doctor { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1.1fr .9fr"]    { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1fr 1fr"]       { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:1.4fr 1fr 1fr"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 640px) {
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: 1fr !important; }
  /* reveal JS re-serializes tile styles (span 2 -> "span 2"), so reset spans structurally,
     not by [style*=] — otherwise a spanning tile forces an implicit 2nd column under 1fr */
  #clinica [data-stagger] > * { grid-column: auto !important; grid-row: auto !important; }
  [style*="grid-auto-rows:200px"] { grid-auto-rows: 240px !important; }
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  /* --- Header: compact, single-line, aligned --- */
  header > div { padding: 11px 16px !important; gap: 12px !important; }
  header a[href="#top"] span:first-child { font-size: 8px !important; letter-spacing: .3em !important; }
  header a[href="#top"] span:last-child  { font-size: 20px !important; letter-spacing: .1em !important; }
  header nav { display: none !important; }
  header .langbtn { padding: 5px 10px !important; }
  header a[href="tel:+34956110058"][style*="padding:11px 22px"] {
    padding: 10px 16px !important; font-size: 13px !important;
    white-space: nowrap !important; line-height: 1 !important;
  }

  /* --- Trust bar: drop the stray separators, clean vertical list --- */
  section[style*="background:var(--sage,#3E6B63)"] { padding: 22px 20px !important; }
  section[style*="background:var(--sage,#3E6B63)"] [data-stagger] {
    flex-direction: column !important; gap: 12px !important;
  }
  /* separators are the even-position children; reveal JS rewrites their inline style, so target by position */
  section[style*="background:var(--sage,#3E6B63)"] [data-stagger] > div:nth-child(even) { display: none !important; }

  /* --- Doctor specialty cards: stack full-width so headings don't clip --- */
  #doctor div[style*="display:flex;gap:14px;flex-wrap:wrap"] { flex-direction: column !important; }

  /* --- Hero --- */
  section[style*="min-height:100vh"] { min-height: auto !important; padding-top: 104px !important; }
  div[style*="display:flex;gap:34px;margin-top:44px"] { flex-wrap: wrap !important; gap: 20px 26px !important; }
  #tilt-wrap [style*="left:-34px"] { left: -6px !important; }
  #tilt-wrap [style*="right:-30px"] { right: -8px !important; }
  #tilt-wrap [style*="width:114%"] { width: 100% !important; }

  /* --- Section padding trims --- */
  section[style*="padding:110px 28px"] { padding-top: 62px !important; padding-bottom: 62px !important; }
  section[style*="padding:100px 28px"] { padding-top: 58px !important; padding-bottom: 58px !important; }
  section[style*="padding:132px 28px 60px"] { padding: 104px 22px 48px !important; }
  section[style*="padding:132px 28px 70px"] { padding: 104px 22px 48px !important; }
  div[style*="padding:60px 56px"] { padding: 34px 22px !important; }
  div[style*="padding:64px 56px"] { padding: 36px 24px !important; }
  div[style*="border-radius:32px"] { border-radius: 22px !important; }
  footer div[style*="grid-template-columns:1.4fr 1fr 1fr"] { text-align: left !important; gap: 30px !important; }
  h1[style*="font-size:clamp"] { line-height: 1.03 !important; }
}

/* ============ Clinic gallery lightbox ============ */
#clinica img { cursor: zoom-in; }
.cdi-lb {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 18, 16, .93);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.cdi-lb.open { display: flex; }
.cdi-lb img {
  max-width: 92vw; max-height: 86vh; border-radius: 10px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); object-fit: contain;
}
.cdi-lb button {
  position: absolute; background: rgba(255, 255, 255, .14); border: none; color: #fff;
  width: 48px; height: 48px; border-radius: 50%; font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .2s ease;
}
.cdi-lb button:hover { background: rgba(255, 255, 255, .3); }
.cdi-lb .cdi-lb-close { top: 18px; right: 18px; }
.cdi-lb .cdi-lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.cdi-lb .cdi-lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.cdi-lb .cdi-lb-count {
  position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
  color: rgba(255, 255, 255, .8); font-size: 13px; letter-spacing: .1em;
}
@media (max-width: 600px) {
  .cdi-lb { padding: 12px; }
  .cdi-lb button { width: 42px; height: 42px; font-size: 20px; }
  .cdi-lb .cdi-lb-prev { left: 6px; }
  .cdi-lb .cdi-lb-next { right: 6px; }
}
