/* ============================================================
   ОБЪЯВЛЕНИЯ v456: фото с подписями (галерея и просмотр на весь экран),
   «Показать в календаре событий», код группы КИС МД. Поверх news-v433.
   ============================================================ */

/* ---- Форма: фотографии ---- */
.nw-photos-field { display: grid; gap: 10px; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 12px; }
.nw-photos-head b { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; font-weight: 800; }
.nw-photos-head .tk-ico { width: 16px; height: 16px; color: var(--tk-accent, var(--brand)); }
.nw-photos-head small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.nw-photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.nw-photos-grid.is-busy { opacity: .6; cursor: progress; }
.nw-photo-tile { display: grid; gap: 6px; margin: 0; min-width: 0; }
.nw-photo-thumb {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 10px;
  background: var(--surface-hover); box-shadow: inset 0 0 0 1px var(--line);
}
.nw-photo-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.nw-photo-missing { display: grid; place-items: center; height: 100%; color: var(--muted); }
.nw-photo-remove {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(15, 18, 24, .62); color: #fff; font-size: 17px; line-height: 1; cursor: pointer;
}
.nw-photo-remove:hover { background: rgba(15, 18, 24, .85); }
.nw-photo-badge, .nw-photo-first {
  position: absolute; left: 6px; bottom: 6px; padding: 3px 8px; border: 0; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; line-height: 1.3;
}
.nw-photo-badge { background: var(--brand); color: #fff; }
.nw-photo-first { background: rgba(15, 18, 24, .62); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s; }
.nw-photo-tile:hover .nw-photo-first, .nw-photo-first:focus-visible { opacity: 1; }
@media (hover: none) { .nw-photo-first { opacity: 1; } }
.nw-photo-tile input { min-width: 0; padding: 6px 8px !important; font-size: 12.5px !important; }
.nw-photo-add {
  display: grid; place-content: center; justify-items: center; gap: 2px; aspect-ratio: 4 / 3; padding: 8px;
  border: 1.5px dashed color-mix(in srgb, var(--brand) 40%, var(--line)); border-radius: 10px;
  background: color-mix(in srgb, var(--surface-selected) 55%, transparent); color: var(--tk-accent, var(--brand));
  text-align: center; cursor: pointer;
}
.nw-photo-add:hover { border-color: var(--brand); background: var(--surface-selected); }
.nw-photo-add .tk-ico { width: 22px; height: 22px; }
.nw-photo-add b { font-size: 12.5px; }
.nw-photo-add small { color: var(--muted); font-size: 11px; font-weight: 500; }
.nw-photo-add input { display: none; }

/* ---- Форма: код группы и календарь ---- */
.nw-code input { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.nw-cal { display: grid; gap: 0; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.nw-cal.is-on { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); background: color-mix(in srgb, var(--surface-selected) 45%, transparent); }
.nw-cal-toggle { display: flex !important; align-items: flex-start; gap: 10px; cursor: pointer; }
.nw-cal-toggle input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); }
.nw-cal-toggle b { display: block; color: var(--text); font-size: 13px; }
.nw-cal-toggle small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; line-height: 1.4; }
.nw-cal-fields { display: grid; grid-template-columns: 1fr 1.3fr 1.1fr; gap: 10px; margin-top: 12px; }
.nw-cal-fields[hidden] { display: none !important; }
.nw-cal-note { grid-column: 1 / -1; color: var(--muted); font-size: 11.5px; }

/* ---- Страница: где в календаре и код группы ---- */
.nw-extras { display: grid; gap: 8px; margin: -4px 0 14px; }
.nw-extra {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-card-2);
}
.nw-extra > .tk-ico { flex: none; width: 17px; height: 17px; color: var(--tk-accent, var(--brand)); }
.nw-extra > div { flex: 1 1 200px; min-width: 0; }
.nw-extra small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 700; }
.nw-extra b { display: block; color: var(--text); font-size: 14px; }
.nw-extra span { display: block; color: var(--text-soft); font-size: 12.5px; }
.nw-extra .tk-btn { flex: none; text-decoration: none; }
.nw-in-cal { color: var(--tk-accent, var(--brand)) !important; font-weight: 700; }

/* ---- Страница: галерея ---- */
.nw-media { display: grid; gap: 14px; margin-top: 16px; }
.nw-head .nw-media .portal-attachments { margin-top: 0; }
.nw-gallery { display: grid; gap: 10px; }
.nw-gallery.is-two { grid-template-columns: 1fr 1fr; align-items: start; }
.nw-g-item { min-width: 0; margin: 0; }
.nw-g-img {
  position: relative; display: block; width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: 14px;
  background: var(--surface-hover); cursor: zoom-in;
}
.nw-g-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.nw-g-img:hover img { transform: scale(1.015); }
.nw-g-img:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.nw-g-img.is-portrait img { object-fit: contain; }
.nw-gallery.is-one .nw-g-img, .nw-gallery.is-many > .nw-g-item .nw-g-img { height: clamp(220px, 40vw, 440px); }
.nw-gallery.is-two .nw-g-img { aspect-ratio: 4 / 3; }
.nw-g-rest { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.nw-g-rest .nw-g-img { aspect-ratio: 1 / 1; height: auto; }
.nw-g-rest .nw-g-img.is-portrait img { object-fit: cover; }
.nw-g-item figcaption { margin-top: 6px; color: var(--text-soft); font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.nw-g-rest figcaption {
  display: -webkit-box; overflow: hidden; font-size: 12px; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.nw-g-more {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(15, 18, 24, .5);
  color: #fff; font-size: 22px; font-weight: 800;
}
.nw-g-wait { height: 240px; cursor: default; animation: nw-wait 1.2s ease-in-out infinite alternate; }
@keyframes nw-wait { from { opacity: .55; } to { opacity: 1; } }

/* ---- Просмотр на весь экран ---- */
html.nw-lb-open { overflow: hidden; }
.nw-lb {
  position: fixed; inset: 0; z-index: 2147483000; display: grid; grid-template-rows: minmax(0, 1fr) auto;
  background: rgba(10, 12, 16, .94); color: #fff; animation: nw-lb-in .15s ease-out;
}
@keyframes nw-lb-in { from { opacity: 0; } to { opacity: 1; } }
.nw-lb-stage { display: grid; place-items: center; min-height: 0; padding: 60px 72px 8px; }
.nw-lb-stage img { max-width: 100%; max-height: calc(100vh - 160px); max-height: calc(100dvh - 160px); object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .45); }
.nw-lb-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 10px 24px 20px; }
.nw-lb-bar p { max-width: 70ch; margin: 0 0 4px; color: #fff; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.nw-lb-bar small { color: rgba(255, 255, 255, .65); font-size: 12.5px; }
.nw-lb-bar a {
  flex: none; padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 10px;
  color: #fff; font-size: 13px; font-weight: 700; text-decoration: none;
}
.nw-lb-bar a:hover { background: rgba(255, 255, 255, .12); }
.nw-lb-close, .nw-lb-nav {
  position: absolute; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff; line-height: 1; cursor: pointer;
}
.nw-lb-close:hover, .nw-lb-nav:hover { background: rgba(255, 255, 255, .24); }
.nw-lb-close { top: 12px; right: 14px; width: 42px; height: 42px; font-size: 28px; }
.nw-lb-nav { top: 50%; width: 48px; height: 48px; font-size: 34px; transform: translateY(-50%); }
.nw-lb-nav.is-prev { left: 14px; }
.nw-lb-nav.is-next { right: 14px; }

/* ---- Календарь: мероприятие из объявления ---- */
.cal-card-row.cal-card-news { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.cal-card-news p { margin: 2px 0 0; }
.cal-card-news > button { white-space: nowrap; }
@media (max-width: 560px) {
  .cal-card-row.cal-card-news { grid-template-columns: auto minmax(0, 1fr); }
  .cal-card-news > button { grid-column: 2; justify-self: start; }
}

@media (max-width: 720px) {
  .nw-cal-fields { grid-template-columns: 1fr; }
  .nw-photos-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nw-gallery.is-two { grid-template-columns: 1fr; }
  .nw-g-rest { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .nw-lb-stage { padding: 56px 8px 8px; }
  .nw-lb-nav { top: auto; bottom: 18px; width: 40px; height: 40px; font-size: 28px; transform: none; }
  .nw-lb-nav.is-prev { left: auto; right: 64px; }
  .nw-lb-nav.is-next { right: 16px; }
  .nw-lb-bar { padding: 10px 16px 20px; padding-right: 116px; flex-direction: column; align-items: flex-start; }
}
