/*
 * Leather R2 mobile proof override.
 * Loaded after the accepted Phase 1 fidelity layer so the R2 source of truth
 * wins without changing tablet, desktop, or non-Leather themes.
 */
html[data-theme="leather"] {
  --leather-r2-black: #0f0f0f;
  --leather-r2-dark: #1a1716;
  --leather-r2-sand: #dcc8b1;
  --leather-r2-light-sand: #e7d7c5;
  --leather-r2-champagne: #c9a47c;
  --leather-r2-edge: #3b2e27;
  --leather-r2-text-dark: #2f241d;
  --leather-r2-text-warm: #e8d8c7;
  --leather-r2-stitch-a-black: url("/app/assets/leather/stitch/machine-stitch-level-a-on-black-r2-1.svg");
  --leather-r2-stitch-a-sand: url("/app/assets/leather/stitch/machine-stitch-level-a-on-sand-r2-1.svg");
  --leather-r2-stitch-b-black: url("/app/assets/leather/stitch/machine-stitch-level-b-on-black-r2-1.svg");
  --leather-r2-stitch-b-sand: url("/app/assets/leather/stitch/machine-stitch-level-b-on-sand-r2-1.svg");
}

html[data-theme="leather"] body.public-mode .leather-hero-r2-plate {
  display: none;
}

@media (max-width: 599px) {
  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-residential-hero,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-hero {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: 2 / 1;
    overflow: hidden;
    border-color: transparent;
    border-radius: 18px;
    background: var(--leather-r2-black);
    box-shadow: 0 11px 22px rgba(0, 0, 0, 0.48);
  }

  html[data-theme="leather"] body.public-mode .leather-hero-layers,
  html[data-theme="leather"] body.public-mode .leather-hero-r2-plate,
  html[data-theme="leather"] body.public-mode .leather-hero-r2-plate-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  html[data-theme="leather"] body.public-mode .leather-hero-r2-plate {
    z-index: 1;
    display: block;
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }

  html[data-theme="leather"] body.public-mode .leather-hero-r2-plate-image {
    display: block;
    object-fit: fill;
  }

  html[data-theme="leather"] body.public-mode .leather-hero-layers.is-r2-ready .leather-hero-r2-plate {
    opacity: 1;
  }

  html[data-theme="leather"] body.public-mode .leather-hero-layers.is-r2-ready .leather-hero-girl-pocket,
  html[data-theme="leather"] body.public-mode .leather-hero-layers.is-r2-ready .leather-hero-girl-clip,
  html[data-theme="leather"] body.public-mode .leather-hero-layers.is-r2-ready .leather-hero-girl-seam,
  html[data-theme="leather"] body.public-mode .leather-hero-layers.is-r2-ready .leather-hero-trust-pocket,
  html[data-theme="leather"] body.public-mode .leather-hero-layers.is-r2-ready .leather-hero-trust-seam {
    display: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero.leather-hero-r2-ready,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-residential-hero.leather-hero-r2-ready,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-hero.leather-hero-r2-ready {
    border-color: transparent;
    background: var(--leather-r2-black);
    box-shadow: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero.leather-hero-r2-ready::after,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-residential-hero.leather-hero-r2-ready::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-hero.leather-hero-r2-ready::after {
    content: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-content,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-content,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-hero-content {
    position: absolute;
    z-index: 6;
    inset: 0;
    display: block;
    width: auto;
    height: auto;
    padding: 0;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-eyebrow {
    position: absolute;
    top: 6%;
    left: 37%;
    width: 57%;
    height: 16%;
    margin: 0;
    gap: 5px;
    align-items: flex-start;
    color: #dfb78e;
    font-size: 11.5px;
    font-weight: 650;
    line-height: 1.23;
    letter-spacing: 0;
    text-shadow: none;
    transform: none;
    filter: none;
    opacity: 1;
    overflow: hidden;
  }

  html[data-theme="leather"][lang="en"] body.public-mode .residential-hero-eyebrow {
    left: 33%;
    width: 64%;
    height: 15px;
    gap: 4px;
    font-size: clamp(9.25px, 2.44vw, 10px);
    line-height: 1.2;
    white-space: nowrap;
  }

  html[data-theme="leather"][lang="en"] body.public-mode .residential-hero-eyebrow .residential-hero-sparkle {
    flex-basis: 8px;
    width: 8px;
    height: 8px;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-sparkle {
    flex: 0 0 11px;
    width: 11px;
    height: 11px;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-primary {
    position: absolute;
    top: 22%;
    left: 38%;
    display: flex;
    width: 53.5%;
    height: 43%;
    margin: 0;
    flex-direction: column;
    justify-content: space-between;
    transform: none;
    filter: none;
    opacity: 1;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-title,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-hero h1 {
    margin: 0;
    color: #e8bd94;
    font-size: clamp(28px, 7.7vw, 32px);
    font-weight: 600;
    line-height: 0.96;
    letter-spacing: 0;
    text-shadow: none;
    transform: none;
    filter: none;
    opacity: 1;
    overflow-wrap: normal;
  }

  html[data-theme="leather"][lang="ru"] body.public-mode .residential-hero-title,
  html[data-theme="leather"][lang="ru"] body.public-mode #seo-initial-content .seo-public-hero h1 {
    font-size: clamp(20px, 5.65vw, 23px);
    line-height: 1;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-subtitle {
    margin: 0;
    color: #d7a878;
    font-size: clamp(11.5px, 3vw, 12px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-shadow: none;
    transform: none;
    filter: none;
    opacity: 1;
    white-space: nowrap;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-trust {
    position: absolute;
    top: 69.5%;
    left: 16%;
    display: grid;
    width: 78%;
    height: 25%;
    margin: 0;
    padding: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    align-items: center;
    transform: none;
    filter: none;
    opacity: 1;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-divider {
    display: none;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-trust-copy {
    display: grid;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    margin: 0;
    gap: 4px;
    grid-template-columns: 14px minmax(0, 1fr);
    align-items: center;
    color: var(--leather-r2-text-warm);
    font-size: clamp(10.5px, 2.78vw, 11.25px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-shadow: none;
    transform: none;
    filter: none;
    opacity: 1;
    overflow: hidden;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-trust-copy > span:last-child {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  html[data-theme="leather"][lang="ru"] body.public-mode .residential-hero-trust-copy > span:last-child {
    -webkit-line-clamp: 3;
  }

  html[data-theme="leather"] body.public-mode .residential-hero-shield {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    color: var(--leather-r2-champagne);
  }

  /* Match the high-specificity SSR fidelity rules before app.js hydrates. */
  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-eyebrow {
    top: 6%;
    left: 37%;
    width: 57%;
    height: 16%;
    margin: 0;
    gap: 5px;
    color: #dfb78e;
    font-size: 11.5px;
    line-height: 1.23;
    text-shadow: none;
  }

  html[data-theme="leather"][lang="en"] body.public-mode #seo-initial-content .residential-hero-eyebrow {
    left: 33%;
    width: 64%;
    height: 15px;
    gap: 4px;
    font-size: clamp(9.25px, 2.44vw, 10px);
    line-height: 1.2;
    white-space: nowrap;
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-primary {
    top: 22%;
    left: 38%;
    width: 53.5%;
    height: 43%;
    margin: 0;
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-subtitle {
    margin: 0;
    color: #d7a878;
    font-size: clamp(11.5px, 3vw, 12px);
    line-height: 1.2;
    text-shadow: none;
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-trust {
    top: 69.5%;
    left: 16%;
    width: 78%;
    height: 25%;
    margin: 0;
    padding: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-divider {
    display: none;
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-trust-copy {
    display: grid;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    margin: 0;
    gap: 4px;
    grid-template-columns: 14px minmax(0, 1fr);
    align-items: center;
    color: var(--leather-r2-text-warm);
    font-size: clamp(10.5px, 2.78vw, 11.25px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0;
    text-shadow: none;
    transform: none;
    filter: none;
    opacity: 1;
    overflow: hidden;
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .residential-hero-shield {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    color: var(--leather-r2-champagne);
  }

  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-property-type strong,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-areas strong {
    color: var(--leather-r2-text-dark);
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-language,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-language,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-hero-language {
    z-index: 7;
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 104px;
    min-width: 104px;
    max-width: 104px;
    height: 44px;
    align-self: center;
    justify-self: end;
    transform: none;
    filter: none;
    opacity: 1;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-language .lang-switch,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-language .lang-switch,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-language-links {
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    position: relative;
    z-index: 0;
    isolation: isolate;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-language .lang-option,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-language .lang-option,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-language-links a {
    position: relative;
    z-index: 0;
    isolation: isolate;
    display: grid;
    width: auto;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--leather-r2-text-warm);
    font-size: 11.5px;
    transform: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-language .lang-option::before,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-language .lang-option::before,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-language-links a::before {
    position: absolute;
    inset: 2px;
    border: 1px solid transparent;
    border-radius: 999px;
    content: "";
    z-index: -1;
    opacity: 0;
    pointer-events: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-language .lang-option.is-active,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-language .lang-option.is-active,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-language-links a.is-active {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: var(--leather-r2-text-dark);
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell .telegram-home-hero-language .lang-option.is-active::before,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-hero-language .lang-option.is-active::before,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-language-links a.is-active::before {
    border-color: #9b6e4e;
    background-color: var(--leather-r2-sand);
    background-image:
      linear-gradient(145deg, rgba(255, 239, 219, 0.18), rgba(121, 69, 39, 0.12)),
      url("/app/assets/leather/textures/leather-sand-seamless-512.webp");
    background-size: 100% 100%, 180px 180px;
    box-shadow:
      0 2px 5px rgba(0, 0, 0, 0.28),
      inset 0 1px 0 rgba(255, 245, 231, 0.28),
      inset 0 -2px 3px rgba(86, 47, 27, 0.18);
    opacity: 1;
  }

  /* R2.1 A: one closed machine-stitch perimeter on primary plates. */
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="search"]::before,
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="newdev"]::before,
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="commercial"]::before,
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-mobile-primary-navigation .public-web-navigation-button::after,
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .telegram-residential-purpose-choice.is-selected::after,
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .residential-location-mode.is-selected::after,
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .public-web-desktop-search-submit::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-primary-navigation .seo-public-navigation-button::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-purpose-choice.is-selected::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-location-modes span.is-selected::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-search-link::after,
  html[data-theme="leather"] body.public-mode.public-client-tabs .appearance-option[data-theme-option="leather"]::before {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    border-radius: inherit;
    background: var(--leather-r2-stitch-a-black) no-repeat 0 0 / 100% 100%;
    box-shadow: none;
    content: "";
    opacity: 1;
    pointer-events: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="search"].is-active::before,
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="newdev"].is-active::before,
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="commercial"].is-active::before {
    content: "";
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="search"].is-active::after,
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="newdev"].is-active::after,
  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs > .tab[data-view="commercial"].is-active::after {
    content: none;
    background: none;
    box-shadow: none;
  }

  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .telegram-residential-purpose-choice:not(.is-selected)::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-purpose-choice:not(.is-selected)::after {
    content: none;
  }

  /* R2.1 B: one closed, quieter perimeter on major sand pockets. */
  html[data-theme="leather"] body.public-mode.browser-public-mode.public-web-shell .public-web-mobile-service-actions::after,
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .telegram-residential-core-filters::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-service-actions::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-filter::after {
    position: absolute;
    inset: 0;
    border: 0;
    border-radius: inherit;
    background: var(--leather-r2-stitch-b-sand) no-repeat 0 0 / 100% 100%;
    box-shadow: none;
    content: "";
    opacity: 1;
    pointer-events: none;
  }

  html[data-theme="leather"] body.public-mode.telegram-hero-shell.public-client-tabs .tabs::before {
    background-image:
      var(--leather-r2-stitch-b-sand),
      linear-gradient(145deg, rgba(255, 241, 224, 0.16), rgba(132, 73, 41, 0.17)),
      url("/app/assets/leather/textures/leather-sand-seamless-512.webp");
    background-repeat: no-repeat, no-repeat, repeat;
    background-position: 0 0, 0 0, center;
    background-size: 100% 100%, 100% 100%, 210px 210px;
    box-shadow:
      0 7px 14px rgba(0, 0, 0, 0.42),
      inset 0 1px 0 rgba(255, 245, 231, 0.2),
      inset 0 -3px 5px rgba(81, 44, 25, 0.22);
  }

  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .residential-location-mode:not(.is-selected)::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-location-modes span:not(.is-selected)::after {
    content: none;
  }

  /* C: ordinary rows retain edge/depth and have no perimeter stitch. */
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .telegram-residential-property-type::after,
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .residential-district-filter::after,
  html[data-theme="leather"] body.public-mode:is(.telegram-client-shell, .public-web-shell) .residential-location-filter::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-property-type::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-location::after,
  html[data-theme="leather"] body.public-mode #seo-initial-content .seo-public-areas::after {
    content: none;
  }
}
