/* Баннер mo-rois.ru — новая вёрстка
   Подключается на главной и на странице предпросмотра.
   Старые правила #cookie_notification не используются. */

.sb-overlay[hidden] { display: none; }

.sb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 18, 38, 0.55);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.sb-overlay.is-open { opacity: 1; }

/* ---------- окно ---------- */

.sb-dialog {
  position: relative;
  width: min(960px, 92vw);
  max-height: 85vh;
  overflow: hidden;
  display: grid;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(12, 18, 38, 0.35);
  transform: translateY(16px);
  transition: transform 0.35s ease;

  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr) minmax(180px, 36%);
  grid-template-areas:
    "logo    logo"
    "content media";
}

.sb-overlay.is-open .sb-dialog { transform: translateY(0); }

/* подсказка, что текст продолжается */
.sb-dialog::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  background: linear-gradient(rgba(255,255,255,0), #fff);
  pointer-events: none;
}

/* ---------- раскладки ---------- */

.sb-pos-left {
  grid-template-columns: minmax(180px, 36%) minmax(0, 1fr);
  grid-template-areas:
    "logo logo"
    "media content";
}

.sb-pos-top,
.sb-pos-full {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "logo" "media" "content";
}

.sb-pos-bottom {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "logo" "content" "media";
}

.sb-pos-none {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "logo" "content";
}

/* подстраховка: в раскладке «без картинки» блок изображения не показываем */
.sb-pos-none .sb-media { display: none; }

/* ---------- части ---------- */

.sb-logo {
  grid-area: logo;
  height: auto;
  max-width: 220px;
  padding: 32px 40px 8px;
}

.sb-media {
  grid-area: media;
  overflow: hidden;
  min-width: 0;
}

.sb-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sb-pos-top .sb-media img,
.sb-pos-bottom .sb-media img {
  height: clamp(140px, 22vh, 260px);
}

/* готовая открытка — показываем целиком, ничего не обрезаем */
.sb-pos-full .sb-media img {
  height: auto;
  object-fit: contain;
}

.sb-content {
  grid-area: content;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 40px 48px;
  min-width: 0;
}

/* ---------- типографика ---------- */

.sb-title {
  margin: 0 0 18px;
  font-family: 'Montserrat', Arial, sans-serif;
  font-weight: 500;
  font-style: italic;
  font-size: clamp(20px, 2.4vw, 35px);
  line-height: 1.25;
  color: #222B4A;
}

.sb-text {
  font-family: 'Montserrat', Arial, sans-serif;
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.6;
  color: #333;
}

/* Гасим инлайновые стили, приезжающие вместе с текстом из Word.
   Начертание сохраняем — жирный и курсив остаются. */
.sb-text * {
  font-family: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
  color: inherit !important;
  background: none !important;
  max-width: none !important;
  width: auto !important;
  letter-spacing: normal !important;
}

.sb-text p { margin: 0 0 0.8em !important; }
.sb-text p:last-child { margin-bottom: 0 !important; }
.sb-text ul, .sb-text ol { margin: 0 0 0.8em !important; padding-left: 1.4em !important; }
.sb-text strong, .sb-text b { font-weight: 700 !important; }
.sb-text em, .sb-text i { font-style: italic !important; }
.sb-text a { color: #8b0000 !important; text-decoration: underline; }

/* ---------- оформление по типу ---------- */

.sb-type-congrat .sb-title { color: #8b0000; }
.sb-type-announce .sb-title { color: #222B4A; font-style: normal; }
.sb-type-condolence .sb-title { color: #4a4f5c; font-style: normal; }
.sb-type-condolence .sb-dialog { border-radius: 8px; }

/* ---------- подпись ---------- */

.sb-signature {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 28px;
  font-size: 14px;
  color: #4a4f5c;
}

.sb-signature-img img {
  display: block;
  max-width: 170px;
  height: auto;
}

/* ---------- ссылка ---------- */

.sb-link {
  display: inline-block;
  margin-top: 24px;
  padding: 12px 28px;
  border-radius: 999px;
  background: #222B4A;
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.sb-link:hover { background: #8b0000; color: #fff; }

/* ---------- закрытие ---------- */

.sb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(12, 18, 38, 0.18);
  color: #222B4A;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.sb-close:hover { background: #8b0000; color: #fff; }
.sb-close:focus-visible { outline: 3px solid #8b0000; outline-offset: 2px; }

/* ---------- узкие экраны ---------- */

@media (max-width: 760px) {
  .sb-overlay { padding: 12px; }

  .sb-dialog,
  .sb-pos-left,
  .sb-pos-right {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "logo" "media" "content";
    max-height: 92vh;
    border-radius: 16px;
  }

  .sb-media img { height: clamp(120px, 18vh, 180px); }
  .sb-pos-full .sb-media img { height: auto; }

  .sb-logo { padding: 20px 20px 4px; max-width: 160px; }
  .sb-content { padding: 12px 20px 36px; }

  .sb-close { width: 40px; height: 40px; top: 10px; right: 10px; }

  .sb-signature { justify-content: flex-start; }
}

/* ---------- уважение к настройкам пользователя ---------- */

@media (prefers-reduced-motion: reduce) {
  .sb-overlay,
  .sb-dialog { transition: none; }
}
