:root {
  --bg:          #f4f6f8;
  --bg-alt:      #eaeef2;
  --card:        #ffffff;
  --text:        #2d3748;
  --muted:       #5f6b7a;
  --primary:     #5a7a8f;
  --primary-dark:#3f5a6b;
  --gold:        #b99252;
  --line:        #d1d9e0;
  --shadow:      0 8px 28px rgba(30, 45, 60, 0.07);
  --radius:      18px;
  --container:   1180px;
  --header-h:    80px;
  --strip-h:     40px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
}

img { max-width: 100%; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.container {
  width: min(var(--container), calc(100% - 32px));
  margin: 0 auto;
}

/* Отступ для секций с фиксированной шапкой (шапка 80px + строка 40px = 120px).
   Только section[id] — не трогаем div#lightbox, div#candleWrap и др. */
section[id] {
  scroll-margin-top: calc(var(--header-h) + var(--strip-h) + 8px);
}

.section { padding: 80px 0; }
.section-alt { background: var(--bg-alt); }

.section-header { margin-bottom: 40px; text-align: center; }
.section-label {
  color: var(--gold); font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; font-size: 0.9rem; margin: 0 0 8px;
  display: block;
}
.section-header h2 { margin: 0 0 10px; font-family: "Playfair Display", serif; font-size: 2.2rem; color: var(--primary-dark); }
.section-subtext { color: var(--muted); font-size: 1.1rem; max-width: 600px; margin: 0 auto; }

/* HEADER */
#site-header {
  position: fixed; top: 0; width: 100%;
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.header-inner { display: flex; justify-content: space-between; align-items: center; height: var(--header-h); }
.brand { text-decoration: none; color: inherit; }
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--primary-dark); }
.brand-sub { font-size: 0.8rem; color: var(--muted); }

.main-nav a { margin-left: 24px; font-weight: 500; transition: color 0.3s; color: var(--text); }
.main-nav a:hover { color: var(--gold); }

.header-right { display: flex; align-items: center; gap: 16px; }
.lang-switcher { display: flex; gap: 4px; }
.lang-switcher button {
  background: none; border: 1px solid var(--line);
  padding: 4px 8px; cursor: pointer; border-radius: 4px; font-size: 0.8rem;
  transition: background 0.2s, color 0.2s;
}
.lang-switcher button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.lang-switcher button:hover:not(.active) { background: var(--bg-alt); }

.header-cta {
  background: var(--primary); color: #fff;
  padding: 8px 16px; border-radius: var(--radius); font-size: 0.9rem;
  transition: background 0.3s;
}
.header-cta:hover { background: var(--primary-dark); color: #fff; }

.burger { display: none; background: none; border: none; cursor: pointer; }
.burger span { display: block; width: 25px; height: 3px; background: var(--primary-dark); margin: 5px 0; }

.prayer-strip {
  background: var(--primary-dark); color: #fff;
  padding: 10px 0; text-align: center; font-size: 0.9rem;
  margin-top: var(--header-h);
}
.prayer-strip a { color: var(--gold); font-weight: 600; text-decoration: underline; }

/* HERO */
#hero {
  position: relative; height: calc(100vh - var(--header-h) - var(--strip-h));
  min-height: 500px; display: flex; align-items: center; justify-content: center;
  text-align: center; color: #fff; overflow: hidden;
}
.hero-image-wrap { position: absolute; inset: 0; z-index: -1; }
.hero-img { width: 100%; height: 100%; object-fit: cover; }
.hero-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.hero-content { position: relative; z-index: 1; padding: 0 20px; }
.hero-title { font-family: "Playfair Display", serif; font-size: clamp(2.5rem, 5vw, 4rem); margin: 10px 0 20px; line-height: 1.1; }
.hero-welcome { font-size: 1.1rem; color: var(--gold); font-weight: 600; text-transform: uppercase; letter-spacing: 2px; }
.hero-subtitle { font-size: 1.2rem; max-width: 600px; margin: 0 auto 30px; opacity: 0.9; }

/* Кнопки в герое — исправлен flex-контейнер */
.hero-actions {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 12px; margin-top: 10px;
}
.btn-primary {
  background: var(--gold); color: #fff;
  padding: 12px 28px; border-radius: var(--radius); font-weight: 600;
  display: inline-block; transition: background 0.3s, transform 0.2s;
}
.btn-primary:hover { background: #a07e3f; color: #fff; transform: translateY(-1px); }
.btn-outline-white {
  border: 2px solid #fff; color: #fff;
  padding: 10px 28px; border-radius: var(--radius); font-weight: 600;
  display: inline-block; transition: background 0.3s, transform 0.2s;
}
.btn-outline-white:hover { background: rgba(255,255,255,0.15); color: #fff; transform: translateY(-1px); }

/* TWO COLUMNS (About & Priest) */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.two-col-image img { border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; height: auto; object-fit: cover; }
.stats-row { display: flex; gap: 30px; margin-top: 30px; }
.stat-item strong { display: block; font-size: 1.5rem; color: var(--primary-dark); }
.stat-item span { font-size: 0.9rem; color: var(--muted); }

/* GRIDS */
.planner-grid, .resources-grid, .sacraments-grid, .life-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px;
}

/* CARDS */
.planner-card, .resource-card, .sacrament-card, .life-card {
  background: var(--card); border-radius: var(--radius); padding: 30px;
  box-shadow: var(--shadow); transition: transform 0.3s;
}
.planner-card:hover, .resource-card:hover, .sacrament-card:hover, .life-card:hover { transform: translateY(-5px); }
.plan-icon { font-size: 2rem; margin-bottom: 15px; display: block; }
.planner-card h3 { color: var(--primary-dark); margin-top: 0; }
.planner-card ul { padding-left: 20px; color: var(--muted); }

/* SACRAMENTS & LIFE IMAGES */
.sacrament-card, .life-card, .resource-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.sacrament-img img, .life-card img, .resource-card img {
  width: 100%; height: 220px; object-fit: cover; display: block;
}
.sacrament-body, .life-body, .resource-body { padding: 24px; flex-grow: 1; }
.sacrament-body h3, .life-body h3, .resource-body h3 { margin: 0 0 10px; color: var(--primary-dark); }
.sacrament-body p, .life-body p, .resource-body p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.resource-btn {
  display: block; text-align: center; padding: 12px;
  background: var(--bg-alt); color: var(--primary-dark); font-weight: 600;
  transition: background 0.3s, color 0.3s;
}
.resource-btn:hover { background: var(--primary); color: #fff; }

/* GALLERY */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; }
.gallery-item {
  position: relative; border-radius: var(--radius); overflow: hidden;
  cursor: pointer; aspect-ratio: 4/3;
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
.gallery-item:hover img, .gallery-item:focus img { transform: scale(1.05); }
.gallery-caption {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.7); color: #fff; padding: 10px;
  font-size: 0.85rem; text-align: center; opacity: 0; transition: opacity 0.3s;
}
.gallery-item:hover .gallery-caption,
.gallery-item:focus .gallery-caption { opacity: 1; }
.gallery-item:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* PRAYER CARDS */
.prayer-cards-grid { display: grid; gap: 20px; max-width: 800px; margin: 0 auto; }
.prayer-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.prayer-card-trigger { width: 100%; display: flex; align-items: center; padding: 20px; background: none; border: none; cursor: pointer; text-align: left; }
.prayer-card-icon { font-size: 1.5rem; margin-right: 15px; }
.prayer-card-meta h3 { margin: 0; color: var(--primary-dark); font-size: 1.1rem; }
.prayer-card-meta p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.prayer-card-arrow { margin-left: auto; transition: transform 0.3s; }
.prayer-card.active .prayer-card-arrow { transform: rotate(180deg); }
.prayer-card-panel { display: none; padding: 0 20px 20px; border-top: 1px solid var(--line); }
.prayer-card.active .prayer-card-panel { display: block; }
.prayer-reading-toolbar { padding: 10px 0; display: flex; gap: 10px; border-bottom: 1px solid var(--line); margin-bottom: 15px; justify-content: flex-end; }
.font-size-btn { background: var(--bg-alt); border: none; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-weight: 600; }
.prayer-scroll { max-height: 400px; overflow-y: auto; padding-right: 10px; line-height: 1.8; }
.prayer-rubric { color: #d32f2f; font-style: italic; font-size: 0.9rem; margin-top: 15px; margin-bottom: 5px; }

/* SCHEDULE
   Исправление: border-radius и box-shadow на таблице с border-collapse:collapse
   не работают — переносим их на обёртку .schedule-wrap.
   Также добавлен background: var(--card) на wrap, иначе область под таблицей
   (schedule-note) имела бы фон секции, а не белый цвет карточки. */
.schedule-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--card);
  -webkit-overflow-scrolling: touch;
}
.schedule-table {
  width: 100%; border-collapse: collapse;
  background: var(--card);
  min-width: 380px; /* предотвращает сжатие на узких экранах */
}
.schedule-table th, .schedule-table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--line); }
.schedule-table th { background: var(--primary-dark); color: #fff; }
.schedule-table th:first-child { border-radius: var(--radius) 0 0 0; }
.schedule-table th:last-child  { border-radius: 0 var(--radius) 0 0; }
.schedule-table tbody tr:last-child td { border-bottom: none; }
.schedule-note { text-align: center; margin: 0; padding: 12px 15px 16px; color: var(--muted); font-size: 0.9rem; }

/* DONATE & CONTACTS */
.donate-box { background: var(--card); padding: 40px; border-radius: var(--radius); text-align: center; max-width: 600px; margin: 0 auto; box-shadow: var(--shadow); }
.iban-wrap { display: flex; justify-content: space-between; align-items: center; background: var(--bg-alt); padding: 15px; border-radius: 8px; margin-top: 15px; font-family: monospace; font-size: 1.1rem; }
.iban-wrap button { background: var(--primary); color: #fff; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-family: "Inter", sans-serif; font-size: 0.85rem; font-weight: 600; transition: background 0.3s; }
.iban-wrap button:hover { background: var(--gold); }

.contacts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.contacts-info h3 { color: var(--primary-dark); margin-top: 0; }
.contacts-info p { margin-bottom: 20px; }

/* CANDLE CSS ANIMATIONS */
.candle-container { text-align: center; margin-top: 30px; padding: 20px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.candle { position: relative; width: 60px; height: 120px; background: linear-gradient(to right, #e0e0e0, #f5f5f5, #e0e0e0); margin: 30px auto; border-radius: 4px; cursor: pointer; }
.candle::after { content: ''; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 4px; height: 10px; background: #333; }
.candle-flame { display: none; position: absolute; top: -35px; left: 50%; width: 20px; height: 35px; background: radial-gradient(ellipse at bottom, #fff 10%, #fbd341 40%, #ff8c00 80%, transparent 100%); border-radius: 50% 50% 35% 35%; transform: translateX(-50%); animation: flicker 1.4s ease-in-out infinite alternate-reverse; }
.flame-glow { display: none; position: absolute; top: -45px; left: 50%; width: 50px; height: 70px; background: radial-gradient(ellipse, rgba(251, 191, 36, 0.4) 0%, transparent 70%); transform: translateX(-50%); border-radius: 50%; animation: glow-pulse 2s ease-in-out infinite alternate; }
.candle.lit .candle-flame, .candle.lit .flame-glow { display: block; }
.candle-label { font-style: italic; color: var(--muted); font-size: 0.95rem; }

@keyframes flicker {
  0%   { transform: translateX(-50%) scaleX(1) scaleY(1) rotate(-1deg); }
  33%  { transform: translateX(-50%) scaleX(0.95) scaleY(1.04) rotate(1deg); }
  66%  { transform: translateX(-50%) scaleX(1.04) scaleY(0.97) rotate(-0.5deg); }
  100% { transform: translateX(-50%) scaleX(0.97) scaleY(1.03) rotate(1.5deg); }
}
@keyframes glow-pulse {
  from { opacity: 0.6; transform: translateX(-50%) scale(0.95); }
  to   { opacity: 1;   transform: translateX(-50%) scale(1.05); }
}

/* FOOTER */
.site-footer { background: var(--primary-dark); color: #fff; padding: 40px 0; text-align: center; }
.footer-content { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.footer-name { font-weight: 700; font-size: 1.2rem; }
.footer-city { color: var(--gold); font-size: 0.9rem; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 15px; }
.footer-nav a { color: #fff; font-size: 0.9rem; opacity: 0.8; transition: opacity 0.3s; }
.footer-nav a:hover { opacity: 1; }
.footer-copy { font-size: 0.8rem; opacity: 0.7; }

/* LIGHTBOX */
.lightbox { display: none; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; }
.lightbox.active { display: flex; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.9); cursor: pointer; }
.lightbox-content { position: relative; z-index: 1; max-width: 90%; max-height: 90%; }
.lightbox-content img { max-width: 100%; max-height: 80vh; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.lightbox-close { position: absolute; top: -40px; right: 0; background: none; border: none; color: #fff; font-size: 2.5rem; cursor: pointer; line-height: 1; transition: opacity 0.2s; }
.lightbox-close:hover { opacity: 0.7; }
.lightbox-caption { color: #fff; text-align: center; margin-top: 15px; font-size: 1.1rem; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .burger { display: block; }
  .main-nav {
    display: none; position: absolute; top: var(--header-h); left: 0;
    width: 100%; background: #fff; flex-direction: column;
    padding: 20px; box-shadow: 0 10px 10px rgba(0,0,0,0.1); z-index: 999;
  }
  .main-nav.active { display: flex; }
  .main-nav a { margin: 10px 0; font-size: 1.1rem; }

  .header-cta { display: none; }
  .header-right { display: flex; gap: 10px; }

  .two-col, .contacts-grid { grid-template-columns: 1fr; }
  .two-col-rev .two-col-image { order: 2; }
  .two-col-rev .two-col-text { order: 1; }

  .iban-wrap { flex-direction: column; gap: 10px; text-align: center; font-size: 1rem; }
  .iban-wrap button { width: 100%; }

  /* На мобильных — таблица с горизонтальным скроллом через обёртку */
  .schedule-wrap { -webkit-overflow-scrolling: touch; }

  .hero-actions { flex-direction: column; align-items: center; }
  .btn-primary, .btn-outline-white { width: 100%; max-width: 280px; text-align: center; }
}

@media (max-width: 480px) {
  .section { padding: 50px 0; }
  .section-header h2 { font-size: 1.7rem; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .stats-row { flex-wrap: wrap; gap: 16px; }
}
