/*
 * Shared mobile footer rules for the exported pages.
 *
 * The desktop footer is intentionally outside this media query.  This file is
 * loaded after the existing export overrides, so the compact mobile order and
 * the 18px rhythm are consistent on every HTML route without changing the
 * source markup.
 */

/* Legal links expose one label per mode while keeping both approved texts in
   the DOM for the shared HTML footer. */
.legal-mobile-label {
  display: none;
}

/* The footer SVG still contains the former wordmark below the bear artwork.
 * On compact desktops the exported SVG lets that out-of-view drawing bleed
 * beneath its image box.  The wide desktop lockup already shows bear only;
 * clip the same obsolete drawing for every desktop footer. */
@media screen and (min-width: 768px) {
  .section.is-footer-1st .logo_wrapper_footer_1st {
    overflow: hidden;
  }
}

@media screen and (min-width: 992px) and (max-width: 1439px) {
  .section.is-footer-1st .logo_wrapper_footer_1st {
    height: 3.75rem !important;
  }
}

/* Tablet desktop footer (768–991px).
 * Keep the desktop's four-column structure in this interval.  The former
 * max-width:991px fallback erased named grid areas while the child nodes still
 * used them, which sent every footer block into one implicit cell.  The map is
 * deliberately the only elastic column: it gives up horizontal space before
 * contacts or navigation labels do. */
@media screen and (min-width: 768px) and (max-width: 991px) {
  .grid_footer_1st {
    display: grid !important;
    grid-template-areas:
      "brand map services patients"
      "contacts map services patients" !important;
    grid-template-columns: max-content minmax(0, 1fr) max-content max-content !important;
    column-gap: clamp(.75rem, 2vw, 1.25rem) !important;
    row-gap: 1rem !important;
    align-items: start;
  }

  .grid_footer_1st > * {
    min-width: 0;
  }

  .grid_footer_1st > .area-1_grid_ft_1st { grid-area: brand !important; }
  .grid_footer_1st > .area-2_grid_ft_1st_map_wrp {
    grid-area: map !important;
    width: 100%;
    min-width: 0;
  }
  .grid_footer_1st > .area-3_grid_ft_1st { grid-area: services !important; }
  .grid_footer_1st > .area-4_grid_ft_1st { grid-area: patients !important; }
  .grid_footer_1st > .area-5_grid_ft_1st { grid-area: contacts !important; }

  .area-2_grid_ft_1st_map_wrp,
  .area-2_grid_ft_1st_map_wrp .ya_map_code_emb_block,
  .area-2_grid_ft_1st_map_wrp .ya_map_code_emb_block > div,
  .area-2_grid_ft_1st_map_wrp iframe {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* The exported compact rule also replaced this grid's named areas with a
   * two-column placeholder, while its children retained notice/copyright/maker
   * names. Keep the desktop legal-footer sequence explicit in this range. */
  .grid-2_footer_2nd {
    display: grid !important;
    grid-template-areas:
      "notice notice notice"
      "copyright copyright maker" !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto !important;
    gap: clamp(.75rem, 1.5vw, 1.5rem) !important;
    align-items: end;
    padding-top: clamp(.875rem, 2vw, 1.5rem) !important;
  }

  .grid-2_footer_2nd > * { min-width: 0; }
  .grid-2_footer_2nd > .area-1_grid-2_footer_2nd { grid-area: notice !important; }
  .grid-2_footer_2nd > .area-2_grid-2_footer_2nd { grid-area: copyright !important; }
  .grid-2_footer_2nd > .area-3_grid-2_footer_2nd { grid-area: maker !important; }
}

.compact-footer-socials { display: none; }

/* Shared desktop social block below the patients navigation. */
@media screen and (min-width: 768px) {
  .compact-footer-socials {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: auto;
    padding-top: max(0px, calc(var(--compact-social-gap, 6px) - 4px));
    padding-bottom: 1px;
    gap: var(--compact-social-gap, 6px);
  }
  .compact-footer-socials .text-1_grid_footer_2nd { margin: 0; }
  .compact-footer-social-icons { display: flex; align-items: center; gap: 16px; }
  .compact-footer-social-icons a {
    display: block;
    width: 28px;
    height: 28px;
    margin: 0;
    background: #f5e3c4;
    mask: var(--social-mask) center / contain no-repeat;
    -webkit-mask: var(--social-mask) center / contain no-repeat;
  }
  .compact-footer-social-icons a img { visibility: hidden; }
  .compact-footer-social-icons a[href*="max.ru"] {
    --social-mask: url('../images/MaX_Logo_32x32_footer.svg');
    background: linear-gradient(120deg, #d0b17c, #f5e3c4);
  }
  .compact-footer-social-icons a[href*="t.me"] { --social-mask: url('../images/TG_Logo_32x32_footer.svg'); }
  .compact-footer-social-icons a[href*="vk.ru"] { --social-mask: url('../images/VK_Logo_32x32_footer.svg'); }
  .compact-footer-social-icons a:focus-visible { background-color: #fff; filter: drop-shadow(0 0 2px #fff); }
  .grid_footer_2nd > .area-6_grid_footer_2nd { display: none !important; }
}

@media screen and (min-width: 900px) {
  .grid_footer_1st > .area-4_grid_ft_1st {
    height: 100%;
    justify-content: flex-start;
    gap: 4px;
  }
  .grid_footer_2nd {
    grid-template-columns: 1.1fr 1.5fr 1.3fr .8fr !important;
  }
}

/* 900–1023px: keep the desktop labels intact and let only the map shrink.
   The 1024px+ optical-line rules live in october-01-updates.css. */
@media screen and (min-width: 900px) and (max-width: 1023px) {
  .grid_footer_1st {
    grid-template-columns: max-content minmax(0, 1fr) max-content max-content !important;
    column-gap: 1rem !important;
    row-gap: 1rem !important;
  }

  .area-5_grid_ft_1st .txt_phone_footer_1st,
  .area-3_grid_ft_1st .txt_link_serv_01_footer_1st,
  .area-4_grid_ft_1st .txt_link_serv_01_footer_1st {
    white-space: nowrap;
  }

  .area-3_grid_ft_1st {
    height: 100% !important;
    gap: 0 !important;
    justify-content: space-between;
  }

  .area-2_grid_ft_1st_map_wrp {
    align-self: stretch !important;
    height: 100% !important;
    min-height: 0;
  }

  .section.is-footer-1st .area-2_grid_ft_1st_map_wrp,
  .section.is-footer-1st .area-2_grid_ft_1st_map_wrp .ya_map_code_emb_block,
  .section.is-footer-1st .area-2_grid_ft_1st_map_wrp .ya_map_code_emb_block > div,
  .section.is-footer-1st .area-2_grid_ft_1st_map_wrp .ya_map_code_emb_block iframe {
    height: 100% !important;
  }

  .area-3_grid_ft_1st > .link_serv_01_footer_1st:last-child .txt_link_serv_01_footer_1st {
    transform: translateY(3px);
  }
}

/* Match the wide-desktop legal strip without changing the other footer rows. */
@media screen and (min-width: 900px) and (max-width: 1439px) {
  .grid_footer_2nd_wrapper { padding: .75rem 0 !important; }
  .grid_footer_2nd { margin: 0; }
  .grid_footer_2nd .txt_link_grid_footer_2nd {
    font-size: .55rem !important;
    line-height: 1.2 !important;
    white-space: nowrap;
  }
}

/* Compact desktop keeps its existing map visibility and column offsets. */
@media screen and (min-width: 768px) and (max-width: 899px) {
  /* Move the complete outer columns equally toward the services column. */
  .grid_footer_1st > :is(.area-1_grid_ft_1st, .area-5_grid_ft_1st) {
    translate: 30px 0;
  }

  .grid_footer_1st > .area-4_grid_ft_1st {
    translate: -30px 0;
  }

  /* One icon rail and one text rail for the bear lockup and every contact row.
   * The exported flex margins made the clinic name begin farther right than
   * the phones, while the address icon was allowed to shrink to nothing. */
  .section.is-footer-1st .area-1_grid_ft_1st,
  .section.is-footer-1st :is(.div_1_area-5_grid_ft_1st, .div_2_area-5_grid_ft_1st, .div_3_area-5_grid_ft_1st) {
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr);
    column-gap: 12px !important;
    align-items: center;
    padding-left: 0 !important;
  }

  .section.is-footer-1st .logo_wrapper_footer_1st {
    width: 40px !important;
    height: 40px !important;
    margin-left: 0 !important;
  }

  .section.is-footer-1st .logo_img_footer_1st {
    display: block;
    width: 40px !important;
    height: 40px !important;
    object-fit: contain;
  }

  .section.is-footer-1st .compname_wrapper_footer_1st {
    margin-left: 0 !important;
    align-self: center;
  }

  .section.is-footer-1st .txt_dmc_footer_1st {
    font-size: 12px !important;
    line-height: 14px !important;
    white-space: nowrap;
  }

  .section.is-footer-1st .compname_h2_footer_1st {
    margin-top: 2px !important;
    font-size: 18px !important;
    line-height: 22px !important;
    white-space: nowrap;
  }

  .section.is-footer-1st :is(.div_1-1_area-5_grid_ft_1st, .div_2-1_area-5_grid_ft_1st) {
    width: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 4px;
  }

  .section.is-footer-1st .area-5_grid_ft_1st {
    margin-top: 16px !important;
  }

  .section.is-footer-1st .area-5_grid_ft_1st :is(.phone_ico_ft, .mail_ico_ft) {
    display: block;
    flex: 0 0 auto;
    width: 22px !important;
    height: 22px !important;
  }

  .section.is-footer-1st .area-5_grid_ft_1st .txt_phone_footer_1st {
    font-size: 12px !important;
    line-height: 16px !important;
    white-space: nowrap;
  }

  .grid_footer_1st {
    grid-template-areas:
      "brand services patients"
      "contacts services patients" !important;
    /* Size each visible column by its content, then share the remaining
     * width evenly between the two optical gaps. Equal-width tracks left
     * the services text too close to the contact column. */
    grid-template-columns: repeat(3, max-content) !important;
    justify-content: space-between !important;
    column-gap: clamp(1rem, 2.75vw, 1.5rem) !important;
    row-gap: 0 !important;
    align-items: stretch;
  }

  .grid_footer_1st > .area-2_grid_ft_1st_map_wrp {
    display: none !important;
  }

  .grid_footer_1st > :is(.area-1_grid_ft_1st, .area-3_grid_ft_1st, .area-4_grid_ft_1st, .area-5_grid_ft_1st) {
    min-width: 0;
  }

  /* The lower edge of the three upper columns is the bottom of the address
   * pin. Services use the available height so their final label reaches that
   * shared optical line rather than ending above or below the address. */
  .area-3_grid_ft_1st,
  .area-4_grid_ft_1st {
    height: 100% !important;
    margin-left: 0 !important;
    gap: 0 !important;
    justify-content: space-between;
  }

  /* Five patient rows must follow the same compact vertical step as the
   * nine service rows, rather than spreading across the full column height.
   * Align the rightmost text edge with the contact-icon inset on the left. */
  .grid_footer_1st > .area-4_grid_ft_1st {
    width: max-content;
    justify-self: end;
    margin-right: 4px;
    gap: 4px !important;
    justify-content: flex-start;
  }

  .area-3_grid_ft_1st .txt_link_serv_01_footer_1st,
  .area-4_grid_ft_1st .txt_link_serv_01_footer_1st,
  .area-5_grid_ft_1st .txt_phone_footer_1st {
    white-space: nowrap;
  }

  /* All legal-navigation entries stay in one visual row. */
  .grid_footer_2nd_wrapper {
    /* Reduce only the vertical breathing room between the two horizontal
     * divider lines; text and social icons retain their approved size. */
    padding-top: .375rem !important;
    padding-bottom: .375rem !important;
  }

  .grid_footer_2nd {
    display: grid !important;
    grid-template-columns: repeat(4, max-content) !important;
    padding-inline: 1rem;
    grid-template-areas: none !important;
    justify-content: space-between !important;
    align-items: center;
    column-gap: clamp(.25rem, 1vw, .5rem) !important;
    margin-top: .25rem;
    margin-bottom: .25rem;
  }

  .grid_footer_2nd > * {
    grid-area: auto !important;
    min-width: 0;
  }

  .grid_footer_2nd :is(.txt_link_grid_footer_2nd, .text-1_grid_footer_2nd) {
    font-size: clamp(.5rem, 1.05vw, .58rem) !important;
    line-height: 1.2 !important;
    white-space: nowrap;
  }

  .area-6_grid_footer_2nd {
    flex-wrap: nowrap;
    gap: clamp(.2rem, .65vw, .35rem) !important;
    white-space: nowrap;
  }

  .area-6_grid_footer_2nd :is(.link-soc-1_grid_footer_2nd, .link-soc-2_grid_footer_2nd) {
    flex: 0 0 auto;
  }
}

/* Intermediate desktop legal footer (992–1439px).
 *
 * october-01-updates.css contains a later generic desktop declaration that
 * replaces this grid's named areas with the exported placeholder "Area Area".
 * The child nodes still request notice/copyright/maker, so the browser creates
 * implicit tracks and the legal texts visually overlap.  Keep the same named
 * composition that is already used on 768–991px and from 1440px upward. */
@media screen and (min-width: 992px) and (max-width: 1439px) {
  .grid-2_footer_2nd {
    display: grid !important;
    grid-template-areas:
      "notice notice notice"
      "copyright copyright maker" !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto !important;
    gap: clamp(.75rem, 1.5vw, 1.5rem) !important;
    align-items: end;
    padding-top: clamp(.875rem, 2vw, 1.5rem) !important;
  }

  .grid-2_footer_2nd > * {
    min-width: 0;
  }

  .grid-2_footer_2nd > .area-1_grid-2_footer_2nd {
    grid-area: notice !important;
  }

  .grid-2_footer_2nd > .area-2_grid-2_footer_2nd {
    grid-area: copyright !important;
  }

  .grid-2_footer_2nd > .area-3_grid-2_footer_2nd {
    grid-area: maker !important;
  }
}

@media screen and (max-width: 767px) {
  :root {
    --mobile-footer-rhythm: 1.125rem;
    --mobile-footer-brand-top: 1.75rem;
    --mobile-footer-legal-row-gap: .4625rem;
    --mobile-footer-line: rgb(245 227 196 / 38%);
    --mobile-footer-text: #f5e3c4;
    --mobile-footer-heading: #fff3e0;
    --mobile-footer-navigation: #debb81;
  }

  section.is-footer-1st,
  section.is-footer-2nd {
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
  }

  section.is-footer-1st,
  body > section.section.is-footer-1st {
    padding: var(--mobile-footer-brand-top) 0 0 !important;
  }

  section.is-footer-2nd {
    padding: var(--mobile-footer-rhythm) 0 0 !important;
  }

  .cont-is-footer-1st,
  .cont-is-footer-2nd {
    width: min(100%, 74rem);
    min-width: 0;
    padding-inline: clamp(1rem, 5.5vw, 2rem);
    box-sizing: border-box;
    font-family: "Instrument Sans", sans-serif !important;
  }

  .cont-is-footer-1st *,
  .cont-is-footer-2nd * {
    font-family: "Instrument Sans", sans-serif !important;
  }

  /* Brand, services and the four patient links are one vertical stack. */
  .grid_footer_1st {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: none !important;
    row-gap: var(--mobile-footer-rhythm) !important;
    margin: 0;
  }

  .grid_footer_1st > * {
    grid-area: auto !important;
    grid-column: 1 !important;
    grid-row: auto !important;
    min-width: 0;
    margin: 0;
  }

  .area-2_grid_ft_1st_map_wrp,
  .area-5_grid_ft_1st {
    display: none !important;
  }

  .area-1_grid_ft_1st {
    display: flex;
    align-items: center;
    gap: .75rem;
  }

  .logo_wrapper_footer_1st,
  .logo_img_footer_1st {
    width: 2.5rem;
    height: 2.5rem;
  }

  .logo_wrapper_footer_1st {
    flex: 0 0 2.5rem;
  }

  .logo_img_footer_1st {
    display: block;
    object-fit: contain;
  }

  .compname_wrapper_footer_1st {
    min-width: 0;
    margin: 0;
    text-align: left;
  }

.compname_h2_footer_1st {
  margin: 0;
  color: var(--mobile-footer-heading) !important;
  font-size: .9rem;
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
}

.txt_dmc_footer_1st {
  margin: 0;
  color: var(--mobile-footer-heading) !important;
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.25;
  text-align: left;
}

  .area-3_grid_ft_1st,
  .area-4_grid_ft_1st {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .5rem;
    min-width: 0;
  }

  .div-1_area-3_grid_ft_1st,
  .div-1_area-4_grid_ft_1st-copy {
    margin: 0;
  }

  .txt_area-3-grid-footer_1st,
  .area-4_grid_ft_1st > .div-1_area-4_grid_ft_1st-copy .txt_phone_footer_1st {
    color: var(--mobile-footer-navigation) !important;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: left;
  }

  .area-3_grid_ft_1st > .link_serv_01_footer_1st,
  .area-4_grid_ft_1st > .link_serv_01_footer_1st {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    color: var(--mobile-footer-navigation) !important;
    font-size: .7rem;
    font-weight: 400;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
  }

  .area-3_grid_ft_1st .txt_link_serv_01_footer_1st,
  .area-4_grid_ft_1st .txt_link_serv_01_footer_1st {
    color: var(--mobile-footer-navigation) !important;
    font-size: .7rem !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
  }

  .area-3_grid_ft_1st > .link_serv_01_footer_1st:focus-visible,
  .area-4_grid_ft_1st > .link_serv_01_footer_1st:focus-visible,
  .link-1_grid_footer_2nd:focus-visible,
  .area-6_grid_footer_2nd a:focus-visible {
    border-radius: .2rem;
    outline: 2px solid var(--mobile-footer-heading);
    outline-offset: 3px;
  }

  /* The export has the full patient list in every page.  Keep only the four
     approved destinations and order them by their stable hrefs. */
  .area-4_grid_ft_1st > .link_serv_01_footer_1st {
    display: none;
  }

  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="team.html"],
  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="chiefdoctor.html"],
  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="faq.html"],
  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="actions.html"] {
    display: block;
  }

  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="team.html"] { order: 1; }
  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="chiefdoctor.html"] { order: 2; }
  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="faq.html"] { order: 3; }
  .area-4_grid_ft_1st > .link_serv_01_footer_1st[href="actions.html"] { order: 4; }

  .patient-desktop-label { display: none; }
  .patient-mobile-label { display: inline; }

  /* Legal list, social row and their three separate thin dividers. */
  .footer-2nd-line {
    display: none !important;
    height: 0 !important;
  }

  .footer-2nd-line-bottom,
  .area-1_grid-2_footer_2nd,
  .area-5_grid_footer_2nd,
  .footer-mobile-attention {
    display: none !important;
  }

  .grid_footer_2nd_wrapper {
    margin: 0;
    padding: var(--mobile-footer-rhythm) 0 0;
    border-top: 1px solid var(--mobile-footer-line);
    border-bottom: 0;
  }

  .grid_footer_2nd {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: none !important;
    row-gap: var(--mobile-footer-legal-row-gap);
    margin: 0;
  }

  .grid_footer_2nd > [class*="area-"] {
    grid-area: auto !important;
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
    width: 100%;
    min-width: 0;
  }

  .area-2_grid_footer_2nd,
  .area-3_grid_footer_2nd,
  .area-4_grid_footer_2nd {
    border: 0;
  }

  .link-1_grid_footer_2nd {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    text-align: left;
  }

  .txt_link_grid_footer_2nd {
    color: #a27228 !important;
    font-size: .65rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left !important;
  }

  .area-2_grid_footer_2nd {
    display: grid;
    gap: .5rem;
  }

  .legal-desktop-label {
    display: none !important;
  }

  .legal-mobile-label {
    display: inline !important;
  }

  .area-6_grid_footer_2nd {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: .75rem;
    min-height: 3.25rem;
    margin-top: calc(var(--mobile-footer-rhythm) - var(--mobile-footer-legal-row-gap));
    padding: var(--mobile-footer-rhythm) 0;
    border-top: 1px solid var(--mobile-footer-line);
    border-bottom: 1px solid var(--mobile-footer-line);
  }

  .text-1_grid_footer_2nd {
    flex: 0 1 auto;
    color: #a27228 !important;
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    white-space: nowrap;
  }

  .link-soc-1_grid_footer_2nd,
  .link-soc-2_grid_footer_2nd {
    display: inline-flex;
    flex: 0 0 1.875rem;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
  }

  .img_link-soc-1_grid_footer_2nd,
  .img_link-soc-2_grid_footer_2nd {
    display: block;
    width: 1.875rem;
    height: 1.875rem;
    object-fit: contain;
    filter: none;
  }

  /* Copyright and the final MakArt row use the same 18px token. */
  .grid-2_footer_2nd {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: none !important;
    row-gap: 0;
    margin: 0;
  }

  .grid-2_footer_2nd > [class*="area-"] {
    grid-column: 1 / -1 !important;
    grid-row: auto !important;
  }

  .area-2_grid-2_footer_2nd {
    display: block;
    width: 100%;
    min-width: 0;
    padding: var(--mobile-footer-rhythm) 0;
    text-align: center;
  }

  .footer-2nd_img_bg_16x16,
  .txt_copyright_footer_2nd-copy {
    display: none !important;
  }

  .footer-2nd_copyright_bg {
    display: block;
    width: 100%;
    height: auto;
    color: var(--mobile-footer-text);
    font-size: .65rem;
    line-height: 1.35;
    text-align: center;
  }

  .footer-mobile-copyright {
    display: block !important;
    width: 100%;
    color: #a27228 !important;
    font-size: .5rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
  }

  .area-3_grid-2_footer_2nd {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0 0 var(--mobile-footer-rhythm);
    text-align: center;
  }

  .area-3_grid-2_footer_2nd::before {
    content: "";
    display: block;
    width: 30%;
    height: 1px;
    margin: 0 auto var(--mobile-footer-rhythm);
    background: var(--mobile-footer-line);
  }

  .txt_area-3_grid-2_footer_2nd {
    color: #a27228 !important;
    font-size: .425rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: center;
  }
}
