/* Advertising frame only. Never style, clip or cover the supplied creative. */
tn-ad-slot { display: none; box-sizing: border-box; }
html[data-tn-ads="on"] tn-ad-slot {
  display: block;
  margin: 24px auto;
  width: 100%;
  max-width: 728px;
  min-width: 0;
  min-height: 106px;
  background: #121615;
  color: #9da8a0;
  border-radius: 12px;
}
.tn-ad-label { height: 16px; padding: 0 8px; font: 10px/16px system-ui, sans-serif; color: #9da8a0; }
.tn-ad-creative { width: 100%; height: 90px; }
/* A second map placement fits in an existing panel, only when it adds no scrollbar. */
html[data-tn-ads="on"] .sidebar > tn-ad-slot[data-placement="map-sidebar"] { display: none; }
@media (min-width: 1440px) and (min-height: 900px) {
  html[data-tn-ads="on"] .sidebar > tn-ad-slot[data-placement="map-sidebar"] {
    display: block; flex: 0 0 116px; min-height: 116px; width: 100%; margin: 12px 0 0;
  }
  tn-ad-slot[data-placement="map-sidebar"] .tn-ad-creative { height: 100px; }
}
html[data-tn-ads="on"] .sidebar > tn-ad-slot[data-placement="map-sidebar"][hidden],
html[data-tn-ads="on"] .sidebar > tn-ad-slot[data-placement="map-sidebar"][data-state="skipped"] { display: none; }
/* A catalog break spans the grid, never splitting one region's list. */
.regions > tn-ad-slot { grid-column: 1 / -1; }
html[data-tn-ads="on"] tn-ad-slot[data-state="skipped"] { display: none; }
html[data-tn-ads="on"] tn-ad-slot[data-placement="article-video"] { max-width: 320px; min-height: 266px; }
tn-ad-slot[data-placement="article-video"] .tn-ad-creative { height: 250px; }
.tn-content-ad:is([data-placement="article"], [data-placement="statistics"], [data-placement="city-catalog"], [data-placement="district-catalog"]) {
  container: tn-reading-ad / inline-size;
}
@container tn-reading-ad (min-width: 320px) {
  .tn-content-ad > .tn-ad-creative { height: 250px; }
  /* Hold the label and creative space while the ad module is loading. */
  .tn-content-ad:empty::before { content: ""; display: block; height: 266px; }
}
html[data-tn-ads="on"] tn-ad-slot[data-placement$="-feed"] { margin-top: 32px; min-height: 296px; }
html[data-tn-ads="on"] tn-ad-slot[data-placement="summary"] { min-height: 82px; position: relative; }
tn-ad-slot[data-placement="summary"] .tn-ad-label { height: 32px; line-height: 32px; }
.tn-ad-dismiss { position: absolute; top: 0; right: 0; width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: #121615; color: #9da8a0; font: 22px/1 system-ui; cursor: pointer; }
.tn-ad-dismiss:focus-visible { outline: 2px solid #f2b765; outline-offset: -2px; }
html[data-tn-ads="on"] :is(.sidebar, .about-card) > tn-ad-slot:is([data-placement="map-settings-banner"], [data-placement="map-about-video"]) {
  position: relative; flex: none; max-width: 320px; min-height: 0; margin: 12px auto 0;
  container: tn-panel-ad / inline-size;
}
:is([data-placement="map-settings-banner"], [data-placement="map-about-video"]) > .tn-ad-label {
  height: 32px; line-height: 32px;
}
:is([data-placement="map-settings-banner"], [data-placement="map-about-video"]) > .tn-ad-creative { height: 90px; }
@container tn-panel-ad (min-width: 320px) {
  [data-placement="map-about-video"] > .tn-ad-creative { height: 250px; }
  @media (min-height: 580px) {
    .sidebar.mobile-places > [data-placement="map-settings-banner"] > .tn-ad-creative { height: 180px; }
  }
}
html[data-tn-ads="on"] .sidebar > tn-ad-slot[data-placement="map-settings-banner"]:is([hidden], [data-state="skipped"]),
html[data-tn-ads="on"] .about-card > tn-ad-slot[data-placement="map-about-video"][data-state="skipped"] { display: none; }
.sidebar > tn-ad-slot[data-covered="true"] { visibility: hidden; pointer-events: none; }
tn-ad-slot[data-placement$="-feed"] .tn-ad-creative { height: auto; min-height: 280px; }
tn-ad-slot[data-placement="summary"] .tn-ad-creative { height: 50px; }
.tn-map-ad { display: none; }
html[data-tn-ads="on"][data-tn-ad-map="true"] { --tn-ad-rail: 123px; }
html[data-tn-ads="on"] .app-shell { height: calc(100dvh - var(--tn-ad-rail)); }
html[data-tn-ads="on"] .tn-map-ad {
  display: block; position: fixed; bottom: var(--shell-bottom, 0px); left: 0; right: 0;
  height: var(--tn-ad-rail); background: #0e1211; z-index: 18;
  padding: 16px 16px 0; border-top: 1px solid #252b28;
}
html[data-tn-ads="on"] .tn-map-ad tn-ad-slot { margin: 0 auto; min-height: 106px; }
html[data-tn-ads="on"] .tn-map-ad tn-ad-slot[data-placement="map-video"] { display: none; }
.tn-map-ad[data-covered="true"], .tn-map-ad[data-closed="true"] { visibility: hidden; pointer-events: none; }
.tn-ad-close { position: absolute; right: 8px; top: 0; width: 32px; height: 32px;
  border: 0; background: #0e1211; color: #9da8a0; font: 22px/1 system-ui; cursor: pointer; }
.tn-ad-close:focus-visible { outline: 2px solid #f2b765; outline-offset: -2px; }

@media (min-width: 1440px) and (min-height: 720px) {
  html[data-tn-ads="on"][data-tn-ad-map="true"] { --tn-ad-rail: 0px; }
  html[data-tn-ads="on"] .tn-map-ad {
    left: auto; right: calc(14px + var(--shell-right, 0px)); bottom: calc(100px + var(--shell-bottom, 0px));
    /* Preserve 320px inside the border so the creative meets Yandex's 320×180 video minimum. */
    width: 336px; height: 222px; padding: 24px 7px 0; border: 1px solid #252b28; border-radius: 14px;
  }
  html[data-tn-ads="on"] .tn-map-ad tn-ad-slot[data-placement="map-banner"] { display: none; }
  html[data-tn-ads="on"] .tn-map-ad tn-ad-slot[data-placement="map-video"] { display: block; }
  html[data-tn-ads="on"] .tn-map-ad tn-ad-slot[data-placement="map-video"] { min-height: 196px; }
  tn-ad-slot[data-placement="map-video"] .tn-ad-creative { height: 180px; }
  html[data-tn-ads="on"] .app-shell .details-panel { max-height: calc(100dvh - var(--panel-top) - 338px - var(--shell-bottom)); }
}
@media (max-width: 760px), (max-height: 500px) and (orientation: landscape) {
  .tn-content-ad[data-placement="date-archive"] { container: tn-reading-ad / inline-size; }
  html[data-tn-ads="on"][data-tn-ad-map="true"] {
    --tn-ad-rail: 91px;
    --dock-height: calc(var(--tabbar-height) + var(--shell-bottom) + var(--tn-ad-rail));
  }
  html[data-tn-ads="on"] .mobile-tabs { height: calc(var(--tabbar-height) + var(--shell-bottom)); }
  html[data-tn-ads="on"] .tn-map-ad {
    --tn-ad-left: max(env(safe-area-inset-left, 0px), var(--shell-left, 0px));
    --tn-ad-right: max(env(safe-area-inset-right, 0px), var(--shell-right, 0px));
    bottom: calc(var(--tabbar-height) + var(--shell-bottom));
    padding: 0 var(--tn-ad-right) 0 var(--tn-ad-left);
    container: tn-mobile-rail / inline-size;
  }
  html[data-tn-ads="on"] tn-ad-slot { min-height: 116px; }
  html[data-tn-ads="on"] .tn-map-ad tn-ad-slot { max-width: 320px; min-height: 82px; }
  .tn-map-ad .tn-ad-label { height: 32px; line-height: 32px; }
  .tn-map-ad .tn-ad-creative, tn-ad-slot[data-placement="summary"] .tn-ad-creative { height: 50px; }
  .tn-ad-creative { height: 100px; }
  .tn-map-ad .tn-ad-close { top: 0; right: calc(8px + var(--tn-ad-right)); width: 32px; height: 32px; }
  html[data-tn-ads="on"] .app-shell[data-mobile-tab] .map-feed-status { bottom: calc(var(--dock-height) + 48px - var(--tn-ad-rail)); }
  html[data-tn-ads="on"] .app-shell[data-mobile-tab] .ol-attribution.ol-uncollapsible { bottom: calc(var(--dock-height) + 5px - var(--tn-ad-rail)); }
  html[data-tn-ads="on"] .app-shell .analytics-card { bottom: calc(var(--tabbar-height) + var(--shell-bottom)); }
  html[data-tn-ads="on"] .app-shell .sidebar.mobile-places:has(> tn-ad-slot[data-placement="map-settings-banner"]:not([hidden])) {
    bottom: calc(var(--tabbar-height) + var(--shell-bottom));
  }
  :is([data-placement="map-settings-banner"], [data-placement="map-about-video"]) > .tn-ad-label { height: 44px; line-height: 44px; }
  :is([data-placement="map-settings-banner"], [data-placement="map-about-video"]) > .tn-ad-dismiss { width: 44px; height: 44px; }
}

/* Measure short banners with enough usable width for a 320px ad and a 44px control. */
@container tn-mobile-rail (364px <= width < 384px) {
  .tn-map-ad tn-ad-slot[data-placement="map-banner"] { --tn-ad-usable-width-range: compact; }
}

/* In the existing 91px rail, put the controls beside the creative when both fit. */
@container tn-mobile-rail (min-width: 384px) {
  html[data-tn-ads="on"] .tn-map-ad tn-ad-slot[data-placement="map-banner"]:not([hidden], [data-state="skipped"]) {
    display: grid;
    grid-template: 90px / 320px 64px;
    max-width: 384px;
    min-height: 90px;
  }
  .tn-map-ad [data-placement="map-banner"] .tn-ad-creative {
    grid-area: 1 / 1;
    height: 90px;
  }
  .tn-map-ad [data-placement="map-banner"] .tn-ad-label {
    grid-area: 1 / 2;
    align-self: end;
    height: 24px;
    padding: 0;
    text-align: center;
    line-height: 24px;
  }
  .tn-map-ad .tn-ad-close {
    top: 6px;
    right: calc(var(--tn-ad-right) + (100cqw - 384px) / 2 + 10px);
    width: 44px;
    height: 44px;
  }
}
