/* Site-wide adjustments on top of the design's inline styles. The design was drawn for desktop
   (1440 px); these rules adapt its type scale and gutters to phones. Inline styles win over
   stylesheets, hence the !important on every override.
   Selectors match the style attribute as the runtime writes it: it re-serializes every inline
   style, so colours read rgb(17, 66, 71) (never #114247) and zeros read 0px. */

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
/* The design's base font, for the few blocks that do not set one inline. */
body { font-family: 'Source Sans 3', sans-serif; }
/* Decorative shapes bleed off the edge by design; their container clips them so they never
   widen the page (the body rule is the backstop). */
:has(> svg[aria-hidden="true"][style*="position: absolute"]) { overflow: hidden; }
body { overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Links still waiting for real data (js/enlaces.js): social profiles not set yet, and the English
   version, which does not exist yet — the ES | EN switch goes as a whole. */
a[href="#instagram"], a[href="#facebook"], a[href="#en"],
:has(> a[href="#es"]):has(> a[href="#en"]) { display: none !important; }

/* In-page anchors land below the top edge, not flush against it. */
[id] { scroll-margin-top: 24px; }

@media (max-width: 640px) {
  /* Gutters: 32 px containers become 20 px. */
  [style*="max-width: 1200px"],
  [style*="max-width: 1100px"],
  [style*="max-width: 960px"],
  [style*="max-width: 880px"],
  [style*="max-width: 760px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* Type scale: 48–54 px page titles and 30–38 px section titles are desktop sizes. */
  h1 { font-size: clamp(34px, 9.6vw, 40px) !important; line-height: 1.12 !important; }
  h2[style*="font-size: 3"] { font-size: 28px !important; line-height: 1.2 !important; }
  p[style*="font-size: 21px"], p[style*="font-size: 22px"] { font-size: 19px !important; }

  /* Section rhythm: 80–104 px vertical padding is generous on a 390 px screen. */
  [style*="padding: 72px 32px"], [style*="padding: 80px 32px"],
  [style*="padding: 88px 32px"], [style*="padding: 96px 32px"] { padding-top: 56px !important; }
  [style*="padding: 72px 32px;"], [style*="padding: 88px 32px;"], [style*="padding: 96px 32px;"],
  [style*="32px 88px"], [style*="32px 96px"], [style*="32px 104px"] { padding-bottom: 64px !important; }

  /* The hero's decorative arcs: smaller and pushed into the corner, clear of the title. */
  svg[aria-hidden="true"][style*="position: absolute"][style*="right: -"] {
    width: 260px !important;
    height: 260px !important;
    top: -150px !important;
    right: -150px !important;
  }

  /* Buttons in a hero row fill the width: easier to hit with a thumb. */
  section [style*="flex-wrap: wrap; gap: 14px"] > a { flex: 1 1 100%; justify-content: center; }

  /* Fixed-column grids (the photo galleries) stack on a phone. */
  [style*="grid-template-columns: repeat(3, minmax(0px, 1fr))"],
  [style*="grid-template-columns: repeat(2, minmax(0px, 1fr))"] { grid-template-columns: minmax(0, 1fr) !important; }
  [style*="grid-column: span 2"] { grid-column: auto !important; }

  /* Doctor cards (Especialidades): portrait on top, details at full width. */
  section[id] article[style*="padding: 20px"] { flex-direction: column !important; gap: 16px !important; }
  section[id] article[style*="padding: 20px"] > img,
  section[id] article[style*="padding: 20px"] > div[aria-hidden="true"] { width: 96px !important; height: 120px !important; }

  /* Tables scroll inside their box instead of widening the page. */
  table, sc-raw-table { display: block; max-width: 100%; overflow-x: auto; }
}

@media (min-width: 641px) and (max-width: 900px) {
  [style*="grid-template-columns: repeat(3, minmax(0px, 1fr))"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* ── Motion (js/animaciones.js runs the entrances; this holds the states) ─────────────────── */

/* A block waiting to be revealed on scroll. Only js/animaciones.js sets this, so without the
   script nothing is ever hidden. */
[data-revelar="pendiente"] { opacity: 0; }

/* Contact form: the field you are in is clear at a glance; the button rests while sending. */
form[data-wix] input:not([type="checkbox"]):not([type="radio"]),
form[data-wix] textarea,
form[data-wix] select { transition: border-color 160ms ease, box-shadow 160ms ease; }
form[data-wix] input:not([type="checkbox"]):not([type="radio"]):focus,
form[data-wix] textarea:focus,
form[data-wix] select:focus { border-color: #13625C !important; box-shadow: 0 0 0 3px rgba(19, 98, 92, 0.12); }
form[data-wix] [aria-invalid="true"] { border-color: #A4262C !important; }
form[data-wix] button { transition: transform 160ms var(--ease-out), background-color 160ms ease, opacity 160ms ease; }
form[data-wix] button:disabled { opacity: 0.6; cursor: progress; }
@media (hover: hover) and (pointer: fine) {
  form[data-wix] button[type="submit"]:not(:disabled):hover { background: #0E3A3E !important; }
}

/* ── Hover (mouse only: touch screens fire a false hover on tap) ─────────────────────────────
   Hover happens dozens of times per visit, so the motion is near-imperceptible: a 1 px lift and
   a soft shadow on buttons, a 3 px nudge on arrows. Transforms ride the design's global
   transition (transform 160ms var(--ease-out)); the shadow fades in on its own layer so the
   button itself is never repainted. */
@media (hover: hover) and (pointer: fine) {
  /* Buttons: every pill-shaped call to action in the design (8 px corners and a fixed height). */
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled) {
    position: relative;
  }
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled)::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 8px 18px -8px rgba(17, 66, 71, 0.45);
    opacity: 0;
    transition: opacity 160ms ease;
    pointer-events: none;
  }
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled):hover {
    transform: translateY(-1px);
  }
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled):hover::after {
    opacity: 1;
  }
  /* Pressing still reads as a press: the lift gives way to the design's scale-down. */
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled):hover:active {
    transform: scale(0.97);
  }
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:hover:active::after { opacity: 0; }

  /* The design's hover colours (its own rules look for hex values, which the rendered page never
     contains): the same colours, matched as rgb(). */
  a[style*="background: rgb(184, 90, 53)"]:hover { background: #A34E2D !important; }
  a[style*="background: rgb(17, 66, 71)"]:hover { background: #0E3A3E !important; }
  a[style*="solid rgb(17, 66, 71)"]:hover,
  a[style*="solid rgb(159, 193, 189)"]:hover { background: #F2F6F5 !important; }
  a[style*="solid rgb(255, 255, 255)"]:hover { background: rgba(255, 255, 255, 0.12) !important; }
  a[style*="background: rgb(255, 255, 255); color: rgb(17, 66, 71)"]:hover { background: #EEF4F3 !important; }
  a[style*="solid rgb(220, 230, 229)"]:hover { border-color: #8DB3AE !important; }

  /* Links ending in an arrow: the arrow leans the way the link goes (the design did this on
     its cards only; now every arrow link does). */
  a:has(> svg:last-child > path[d^="M5 12l14 0"]) > svg:last-child {
    transition: transform 200ms var(--ease-out);
  }
  a:has(> svg:last-child > path[d^="M5 12l14 0"]):hover > svg:last-child {
    transform: translateX(3px);
  }

  /* Specialty filter chips: the ones you can pick tint on hover; the active one stays put. */
  button[aria-pressed="false"]:hover {
    border-color: #8DB3AE !important;
    background: #F2F6F5 !important;
  }

  /* The mobile "Menú" button, for a narrow window on a computer. */
  .btn-menu:hover { background: #F2F6F5 !important; border-color: #8DB3AE !important; }

  /* Footer links: an underline that fades in rather than snapping on. */
  footer a[style*="text-decoration: none"] {
    text-decoration: underline transparent !important;
    text-underline-offset: 4px;
    transition: text-decoration-color 160ms ease;
  }
  footer a[style*="text-decoration: none"]:hover {
    text-decoration-color: rgba(255, 255, 255, 0.75) !important;
  }
}

/* Reduced motion: hover keeps its colour and shadow, loses the movement. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: reduce) {
  /* Same selectors as above (same specificity, later in the file), so these win. */
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled):hover,
  :is(a, button)[style*="border-radius: 8px"][style*="min-height"]:not(.btn-menu):not(:disabled):hover:active,
  a:has(> svg:last-child > path[d^="M5 12l14 0"]):hover > svg:last-child {
    transform: none;
  }
}
