/* CSS variables — светлая тема */
:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-text: #1a1d24;
  --color-text-muted: #5c6473;
  --color-border: #e2e6ef;
  --color-accent: #004b6b;
  --color-accent-hover: #003852;
  --color-tag-bg: #e6f0f4;
  --color-tag-text: #004b6b;
  --shadow-card: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-modal: 0 24px 48px rgba(15, 23, 42, 0.18);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition: 0.2s ease;
}

body.dark-theme {
  --color-bg: #12151c;
  --color-surface: #1c212b;
  --color-text: #eef1f7;
  --color-text-muted: #9aa3b5;
  --color-border: #2d3545;
  --color-accent: #5a9bb5;
  --color-accent-hover: #7ab8cf;
  --color-tag-bg: #1a3340;
  --color-tag-text: #9ec9db;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background:  #FFF;
  transition: background var(--transition), color var(--transition);
}

body.modal-open {
  overflow: hidden;
}

.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* Header — календарь (тёмная тема и переключатель) */
.site-header--calendar {
  background: var(--color-surface);
  border-bottom-color: var(--color-border);
  box-shadow: var(--shadow-card);
}

.site-header--calendar .site-header__divider {
  background: var(--color-border);
}

.site-header--calendar .site-header__phone {
  color: var(--color-text);
}

.site-header--calendar .site-header__phone:hover {
  color: var(--color-accent);
}

.site-header--calendar .site-header__address {
  color: var(--color-text-muted);
}

.site-header--calendar .site-header__social-link {
  color: var(--color-text);
  background: var(--color-bg);
  border-color: var(--color-border);
}

.site-header--calendar .site-header__social-link:hover {
  color: var(--color-accent);
  background: var(--color-tag-bg);
  border-color: var(--color-accent);
}

.site-header--calendar .site-header__nav-list a {
  color: var(--color-text);
}

.site-header--calendar .site-header__nav-list a:hover {
  color: var(--color-accent);
}

.site-header--calendar .site-header__panel-inner,
.site-header--calendar .site-header__panel-head {
  background: var(--color-surface);
}

.site-header--calendar .site-header__panel-close,
.site-header--calendar .site-header__burger {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

.site-header--calendar .site-header__panel-close:hover,
.site-header--calendar .site-header__burger:hover {
  background: var(--color-tag-bg);
}

.site-header--calendar .site-header__nav-list--stack a {
  color: var(--color-text);
  border-bottom-color: var(--color-border);
}

.site-header--calendar .site-header__nav-list--stack a:hover {
  color: var(--color-accent);
}

.site-header--calendar .site-header__panel-meta {
  border-top-color: var(--color-border);
  background: var(--color-surface);
}

.site-header--calendar .site-header__panel-inner {
  background: var(--color-surface);
}

.site-header--calendar .site-header__panel-head {
  background: var(--color-surface);
}

.site-header--calendar.site-header--nav-stuck .site-header__bottom--desktop {
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
}

.site-header--calendar .site-header__panel-theme .theme-toggle--panel {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text);
}

header .site-header__logo-img--dark {
  display: none;
}

body.dark-theme .site-header__logo-img--light {
  display: none;
}

body.dark-theme .site-header__logo-img--dark {
  display: block;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}

.theme-toggle:hover {
  border-color: var(--color-accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-toggle__icon--moon {
  display: none;
}

body.dark-theme .theme-toggle__icon--sun {
  display: none;
}

body.dark-theme .theme-toggle__icon--moon {
  display: inline;
}

html.calendar-embed-root,
body.calendar-embed-body {
  min-height: 0 !important;
  height: auto !important;
  overflow: visible;
}

html.calendar-embed-root.modal-open,
body.calendar-embed-body.modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

body.calendar-embed-body .main {
  padding-top: 1rem;
  padding-bottom: 1.5rem;
}

body.calendar-embed-body .modal-overlay,
body.calendar-embed-body .modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 1rem;
  box-sizing: border-box;
}

body.calendar-embed-body .modal-overlay {
  z-index: 100;
}

body.calendar-embed-body .modal {
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body.calendar-embed-body .modal__inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: calc(100% - 2rem);
  margin: 0;
  overflow: hidden;
}

body.calendar-embed-body .modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.toolbar--embed {
  position: relative;
}

.toolbar--embed .toolbar__row--filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem 0.75rem;
  width: 100%;
}

.toolbar--embed .tags-filter {
  flex: 0 0 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 2.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.toolbar--embed #reset-filters {
  flex: 0 0 auto;
}

.toolbar--embed .toolbar__row--view {
  justify-content: center;
  width: 100%;
}

/* Main */
.main {
  max-width: 1660px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.toolbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.toolbar__row--filters {
  gap: 0.5rem 1rem;
}

.view-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tags-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: 100%;
}

.tag-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.tag-btn:hover {
  border-color: var(--color-accent);
}

.tag-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.tag-btn.is-active {
  background: var(--color-tag-bg);
  border-color: var(--color-accent);
  color: var(--color-tag-text);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9375rem;
  font-family: inherit;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: var(--color-tag-bg);
}

#reset-filters {
  transition: opacity var(--transition);
}

#reset-filters:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-accent);
  color: #fff;
  width: 100%;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.btn--small {
  padding: 1rem 1rem;
  font-size: 0.8125rem;
}

.view-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
}

.view-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.view-toggle__btn + .view-toggle__btn {
  border-left: 1px solid var(--color-border);
}

.view-toggle__btn:hover {
  color: var(--color-text);
}

.view-toggle__btn.is-active {
  background: var(--color-tag-bg);
  color: var(--color-accent);
  font-weight: 600;
}

.view-toggle__btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  z-index: 1;
}

.view-toggle__grid-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 5px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 9px 0 / 5px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 0 9px / 5px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 9px 9px / 5px 5px no-repeat;
}

.view-toggle__icon {
  font-size: 1rem;
  line-height: 1;
}

/* Events: только одна панель (сетка или календарь) видима */
.events-view-panel[hidden] {
  display: none !important;
}

.events-section {
  min-height: 200px;
}

.events-grid-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  align-items: stretch;
}

.events-grid-container.is-empty {
  justify-content: center;
  padding: 2rem;
  color: var(--color-text-muted);
}

.event-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 280px;
  max-width: 360px;
  min-width: 260px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  transition: transform var(--transition), box-shadow var(--transition);
}

.event-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-modal);
}

.event-card__media {
  position: relative;
  flex-shrink: 0;
  height: 180px;
  overflow: hidden;
}

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

.event-card__date-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
}

.event-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1rem 1rem 1.1rem;
  gap: 0.5rem;
}

.event-card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.event-card__desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.event-card__tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border-radius: 4px;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
}

.event-card__footer {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 0.5rem;
}

/* Calendar */
.calendar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.calendar__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.calendar__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.calendar__nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar__nav-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.calendar__nav-btn:hover {
  border-color: var(--color-accent);
}

.calendar__nav-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Месячная сетка — CSS Grid (разрешено ТЗ) */
.calendar__grid-wrap {
  display: none;
  width: 100%;
  overflow-x: auto;
}

.calendar__weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 4px;
}

.calendar__weekday {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.35rem 0;
}

.calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar__cell {
  display: flex;
  flex-direction: column;
  min-height: 100px;
  padding: 0.35rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.calendar__cell:hover:not(.calendar__cell--empty) {
  border-color: var(--color-accent);
}

.calendar__cell--empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  min-height: 0;
  padding: 0;
}

.calendar__cell--muted {
  opacity: 0.45;
}

.calendar__cell--expanded {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-card);
  z-index: 1;
}

.calendar__cell-day {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.calendar__cell-summary {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.calendar__cell-events {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.35rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.calendar__cell--expanded .calendar__cell-events {
  max-height: 480px;
}

.calendar__cell-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.35rem;
  font-size: 0.72rem;
  background: var(--color-bg);
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.calendar__cell-item-title {
  font-weight: 600;
  color: var(--color-text);
}

.calendar__cell-item-meta {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

/* Mobile list (календарь на узком экране) */
.calendar__mobile {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
}

.calendar__mobile-day {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
}

.calendar__mobile-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  font: inherit;
  text-align: left;
  border: none;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
}

.calendar__mobile-day-header:hover {
  background: var(--color-bg);
}

.calendar__mobile-day-header:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}

.calendar__mobile-day-date {
  font-weight: 700;
}

.calendar__mobile-day-chevron {
  transition: transform 0.2s ease;
}

.calendar__mobile-day.is-open .calendar__mobile-day-chevron {
  transform: rotate(180deg);
}

.calendar__mobile-day-body {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--color-border);
}

.calendar__mobile-day.is-open .calendar__mobile-day-body {
  display: flex;
}

.calendar__mobile-event {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}

.calendar__mobile-event-title {
  font-weight: 600;
  font-size: 0.9rem;
}

/* Breakpoints: показ сетки календаря / мобильного списка */
@media (min-width: 768px) {
  .calendar__grid-wrap {
    display: block;
  }

  .calendar__mobile {
    display: none;
  }
}

@media (max-width: 767px) {
  .calendar__grid-wrap {
    display: none;
  }

  .calendar__mobile {
    display: flex;
  }
}

/* Tablet: чуть меньше шрифт в ячейках */
@media (min-width: 768px) and (max-width: 1023px) {
  .calendar__cell {
    min-height: 88px;
    font-size: 0.85em;
  }

  .calendar__cell-summary,
  .calendar__cell-item {
    font-size: 0.68rem;
  }
}

/* Адаптив: карточки */
@media (min-width: 1024px) {
  .event-card {
    flex: 1 1 calc(25% - 1rem);
    max-width: calc(33.333% - 0.85rem);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .event-card {
    flex: 1 1 calc(50% - 0.75rem);
    max-width: calc(50% - 0.65rem);
  }
}

@media (max-width: 767px) {
  .event-card {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  opacity: 0;
  transition: opacity var(--transition);
}

.modal-overlay.is-visible {
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  max-height: min(92vh, 900px);
  margin: auto;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  line-height: 1;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  transition: background var(--transition);
}

.modal__close:hover {
  background: rgba(0, 0, 0, 0.65);
}

.modal__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.modal__hero {
  position: relative;
  flex-shrink: 0;
  height: 200px;
  overflow: hidden;
}

.modal__hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.modal__hero-date {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  border-radius: var(--radius-sm);
}

.modal__body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1.5rem;
  overflow-y: auto;
}

.modal__title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.modal__description {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--color-text-muted);
}

.signup-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.25rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.875rem;
  font-weight: 600;
}

.form-field input[type="text"],
.form-field input[type="tel"],
.form-field input[type="email"] {
  padding: 0.55rem 0.65rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color var(--transition);
}

.form-field input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-field input:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.form-field--checkbox .checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

.form-field--checkbox input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.field-error {
  min-height: 1.1em;
  font-size: 0.8rem;
  color: #dc2626;
}

body.dark-theme .field-error {
  color: #f87171;
}
