/* RuReefTools — базовые стили и мобильная версия */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  /* Светлая тема: приглушённые тона, комфортные для глаз */
  --primary: #4a6fa5;
  --primary-light: #6b8cbe;
  --accent: #7eb8da;
  --aqua: #5ba3b0;
  --bg: #f4f5f6;
  --card: #fafbfc;
  --text: #374151;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --success: #4caf50;
  --warning: #d97706;
  --danger: #dc2626;
  --bubble: rgba(74, 111, 165, 0.08);
  --transition: all 0.3s ease;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}
[data-theme="dark"] {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --text-light: #94a3b8;
  --border: #334155;
  --bubble: rgba(30, 58, 138, 0.2);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

html {
  scroll-behavior: smooth;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  min-height: 100%;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
}

.bubbles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}
.bubble {
  position: absolute;
  bottom: -100px;
  border-radius: 50%;
  background: var(--bubble);
  box-shadow: 0 0 8px var(--aqua);
  animation: rise 15s infinite ease-in;
}
@media (max-width: 768px) {
  .bubble { animation: none; opacity: 0.15; }
}
@media (prefers-reduced-motion: reduce) {
  .bubble { animation: none; }
}
@keyframes rise {
  0% { transform: translateY(0) scale(0.8); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-100vh) scale(1.2); opacity: 0; }
}
.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 40px;
  background: radial-gradient(circle at 10% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 30% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 50% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 70% 50%, transparent 45%, var(--aqua) 50%),
    radial-gradient(circle at 90% 50%, transparent 45%, var(--aqua) 50%);
  background-size: 20% 100%;
  animation: wave 8s linear infinite;
  opacity: 0.12;
  pointer-events: none;
}
[data-theme="dark"] .wave { opacity: 0.2; }
@media (max-width: 768px) {
  .wave { animation: none; opacity: 0.08; }
}
@media (prefers-reduced-motion: reduce) {
  .wave { animation: none; }
}
@keyframes wave {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.container {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  width: 100%;
  min-width: 0;
  padding-top: calc(10px + var(--safe-top));
  padding-bottom: 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-center {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  min-width: 0;
}
.nav-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 4px 0;
}
.nav-link:hover { text-decoration: underline; }
[data-theme="dark"] .nav-link { color: var(--aqua); }
.lang-switcher .nav-link.lang-link { padding: 4px 8px; border-radius: 8px; }
.lang-link.is-active { color: var(--primary); }
[data-theme="dark"] .lang-link.is-active { color: var(--aqua); }

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  z-index: 1000;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 16px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

header {
  text-align: center;
  padding: 12px 0 14px;
  position: relative;
  flex-shrink: 0;
}
.logo { font-size: 1.85rem; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.logo-link { color: inherit; text-decoration: none; }
.logo-link:hover { text-decoration: underline; }
[data-theme="dark"] .logo-link { color: var(--aqua); }
[data-theme="dark"] .logo { color: var(--aqua); }
.subtitle {
  font-size: 1rem;
  color: var(--text-light);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}
.protection-badge {
  display: inline-block;
  background: var(--accent);
  color: #2c5282;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 6px;
}
[data-theme="dark"] .protection-badge { color: #e3f2fd; }

.theme-toggle {
  background: var(--card);
  border: 1px solid var(--border);
  width: 52px;
  height: 26px;
  border-radius: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  transition: var(--transition);
  flex-shrink: 0;
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
.lang-link { color: var(--text-light); transition: var(--transition); }
.lang-link:hover { color: var(--primary); }
.lang-sep { color: var(--border); user-select: none; margin: 0 2px; }
.toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.3s;
}
[data-theme="dark"] .toggle-thumb {
  transform: translateX(26px);
  background: #94a3b8;
}

/* Сетка карточек */
.grid {
  display: grid;
  gap: 14px;
  padding: 8px 0 12px;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  align-content: start;
  grid-auto-rows: minmax(min-content, auto);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.grid-2x3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 899px) {
  .grid-2x3 { grid-template-columns: repeat(2, 1fr); gap: 16px; }
}
@media (max-width: 599px) {
  .grid-2x3 { grid-template-columns: 1fr; gap: 10px; }
  header { padding: 8px 0 10px; }
  .logo { font-size: 1.6rem; }
  .subtitle { font-size: 0.9rem; max-width: 100%; padding: 0 4px; }
  .container { padding: 0 12px; }
  .nav-row { padding-top: calc(8px + var(--safe-top)); padding-bottom: 8px; gap: 8px 12px; }
  .nav-center { gap: 8px 12px; }
  .nav-link { font-size: 0.9rem; }
  .card { padding: 16px 12px; }
  .card-icon { width: 44px; height: 44px; font-size: 22px; margin-bottom: 8px; }
  .card h3 { font-size: 1.08rem; min-height: 1.5em; margin-bottom: 6px; }
  .card p { font-size: 0.8rem; margin-bottom: 8px; -webkit-line-clamp: 2; }
  .card-hint { font-size: 0.7rem; }
  .card:hover { transform: none; }
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px 14px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  min-height: min-content;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  overflow-y: visible;
}
.card:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06); }
.card:active { transform: translateY(0); }
.card--in-progress { opacity: 0.92; }
.card-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 10px;
  padding: 0;
  background: var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
  overflow: visible;
}
[data-theme="dark"] .card-icon { background: var(--primary); }
.card-badge {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--warning);
  background: rgba(255, 152, 0, 0.15);
  padding: 2px 8px;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow-wrap: break-word;
}
[data-theme="dark"] .card-badge { color: #ffb74d; }
.card h3 {
  font-size: 1.15rem;
  margin: 0 0 8px;
  padding: 0 4px;
  color: var(--primary);
  line-height: 1.4;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  width: 100%;
  min-height: 1.6em;
  text-align: center;
  display: block;
}
[data-theme="dark"] .card h3 { color: var(--aqua); }
.card p {
  font-size: 0.82rem;
  color: var(--text-light);
  margin: 0 0 10px;
  padding: 0 2px;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  min-width: 0;
  width: 100%;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
[data-theme="dark"] .card p { color: #94a3b8; }
.card-hint {
  font-size: 0.72rem;
  color: var(--text-light);
  opacity: 0.9;
  overflow-wrap: break-word;
  margin-top: auto;
  padding: 0 2px;
}
[data-theme="dark"] .card-hint { color: #94a3b8; }


footer {
  text-align: center;
  padding: 10px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  font-size: 0.85rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
  line-height: 1.45;
}

/* Модальное окно */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--safe-top));
  padding-bottom: calc(16px + var(--safe-bottom));
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.25s, opacity 0.25s ease;
}
.modal.is-open {
  visibility: visible;
  opacity: 1;
}
.modal.is-open .modal-box {
  transform: scale(1);
  opacity: 1;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.modal-box {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  max-height: calc(100vh - 32px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.modal-title {
  font-size: 1.35rem;
  color: var(--primary);
  margin-bottom: 12px;
}
[data-theme="dark"] .modal-title { color: var(--aqua); }
.modal-desc {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 16px;
}
.modal-in-progress {
  font-size: 0.9rem;
  color: var(--warning);
  margin-bottom: 12px;
}
.btn-modal {
  display: inline-block;
  width: 100%;
  text-align: center;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}
.btn-modal:hover { background: var(--primary-light); }
.btn-modal:disabled,
.btn-modal.btn-modal--disabled {
  background: var(--text-light);
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 479px) {
  .modal { padding: 12px; }
  .modal-box { padding: 24px 20px; }
  .modal-close { top: 8px; right: 8px; width: 32px; height: 32px; font-size: 24px; }
}

/* Блок топа голосования: одна строка на широких экранах, столбик на узких */
.golos-top {
  background: linear-gradient(135deg, rgba(74, 111, 165, 0.05) 0%, rgba(91, 163, 176, 0.03) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  min-width: 0;
  overflow: hidden;
}
[data-theme="dark"] .golos-top {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.2) 0%, rgba(59, 130, 246, 0.08) 100%);
}
.golos-top-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}
.golos-top-title-icon { font-size: 1.1em; }
[data-theme="dark"] .golos-top-title { color: var(--aqua); }
.golos-top-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.golos-top-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.8rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: var(--transition);
}
.golos-top-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] .golos-top-item:hover { border-color: var(--aqua); box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15); }
.golos-top-rank {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 50%;
  line-height: 1;
}
[data-theme="dark"] .golos-top-rank { background: var(--aqua); color: #0f172a; }
.golos-top-icon {
  flex-shrink: 0;
  font-size: 1.15rem;
  line-height: 1;
}
.golos-top-name {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.golos-top-votes {
  flex-shrink: 0;
  margin-left: 4px;
  padding: 2px 6px;
  background: var(--border);
  color: var(--text-light);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 8px;
}
[data-theme="dark"] .golos-top-votes { background: #334155; color: #94a3b8; }
.golos-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff !important;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 12px;
  transition: var(--transition);
  border: none;
}
.golos-top-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  text-decoration: none !important;
}
/* Узкий экран: все пункты в один столбик */
@media (max-width: 768px) {
  .golos-top { padding: 8px 12px; }
  .golos-top-list {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .golos-top-item {
    flex: none;
    width: 100%;
    min-width: 0;
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .golos-top-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Страницы О проекте и Обратная связь */
.page-content { padding: 0 0 40px; max-width: 640px; margin: 0 auto; }
.about-block, .feedback-block { margin-bottom: 28px; }
.about-block h1 { font-size: 1.5rem; margin-bottom: 12px; color: var(--primary); }
.about-block h2 { font-size: 1.2rem; margin: 20px 0 8px; color: var(--primary); }
[data-theme="dark"] .about-block h1, [data-theme="dark"] .about-block h2 { color: var(--aqua); }
.about-block ul { margin: 8px 0 0 1.2em; }
.about-block li { margin-bottom: 6px; }
.about-block a, .feedback-block a { color: var(--primary); font-weight: 600; text-decoration: none; }
.about-block a:hover, .feedback-block a:hover { text-decoration: underline; }
.about-back { margin-top: 24px; }
.about-back a { color: var(--text-light); text-decoration: none; font-size: 0.95rem; }
.about-back a:hover { color: var(--primary); text-decoration: underline; }
.feedback-cta { margin: 20px 0; }
.btn-telegram {
  display: inline-block;
  padding: 14px 24px;
  background: #0088cc;
  color: #fff !important;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}
.btn-telegram:hover { background: #006699; text-decoration: none !important; }
.feedback-note { font-size: 0.9rem; color: var(--text-light); margin-top: 12px; }

/* Контраст для фокуса (доступность) */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] button:focus-visible {
  outline-color: var(--aqua);
}
