/* ============================================================
   Habitris landing — цветовые токены зеркалят AppTheme приложения
   (fatmike_tracker2/Theme.swift): light по умолчанию, dark по
   data-theme="dark" на <html>.
   ============================================================ */

:root {
  --bg: #F0F4F1;
  --card: #FFFFFF;
  --card-border: #E6EAE7;
  --surface: #F8FAF8;
  --text: #0E100F;
  --subtext: #5F6B65;          /* чуть темнее subtext приложения — для контраста на вебе */
  --accent: #16A050;
  --accent-strong: #0E8C44;    /* акцентный текст мелким кеглем */
  --accent-fill: #128A47;      /* заливка кнопок: белый текст даёт ≥4.5:1 */
  --accent-dim: rgba(22, 160, 80, 0.10);
  --red: #D94040;
  --yellow: #E39A12;
  --empty: #E6EAE7;
  --toggle: #E2E8E4;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
  --header-bg: rgba(240, 244, 241, 0.85);
}

[data-theme="dark"] {
  --bg: #0E100F;
  --card: #181C1A;
  --card-border: #252926;
  --surface: #1F2421;
  --text: #F0F2F0;
  --subtext: #98A29C;
  --accent: #22D97A;
  --accent-strong: #22D97A;
  --accent-fill: #22D97A;
  --accent-dim: rgba(34, 217, 122, 0.14);
  --red: #E05454;
  --yellow: #F2B33D;
  --empty: #252926;
  --toggle: #252926;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --header-bg: rgba(14, 16, 15, 0.85);
}

/* ---------- База ---------- */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

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

a { color: var(--accent-strong); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow { max-width: 780px; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; letter-spacing: -0.01em; }

h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 800; }
h3 { font-size: 1.06rem; font-weight: 700; }

h1 em, .wordmark-text em {
  font-style: normal;
  color: var(--accent-strong);
}

p { margin: 0 0 1em; }

/* Клетка-«тетромино» — базовый визуальный атом сайта */
.cell {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex: none;
}
.c-green  { background: var(--accent); }
.c-yellow { background: var(--yellow); }
.c-red    { background: var(--red); }
.c-empty  { background: var(--empty); }

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--card-border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
}

/* Направленные отступы/позиции заданы логическими свойствами
   (inline-start/end) — они сами зеркалятся при dir="rtl" (ar). */
.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--text);
  margin-inline-end: auto;
}

.wordmark-icon { border-radius: 8px; }

.wordmark-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  text-decoration: none;
  color: var(--subtext);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 10px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
  background: var(--accent-dim);
}

.site-nav a.active {
  color: var(--accent-strong);
  background: var(--accent-dim);
}

.site-nav a.nav-cta {
  color: #fff;
  background: var(--accent-fill);
}

[data-theme="dark"] .site-nav a.nav-cta { color: #0E100F; }

.site-nav a.nav-cta:hover,
.site-nav a.nav-cta:focus-visible {
  filter: brightness(1.08);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle,
.burger {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--card-border);
  background: var(--toggle);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover,
.burger:hover { transform: scale(1.06); }

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

/* Переключатель языка */
.lang-switcher { position: relative; }

.lang-switcher summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1.5px solid var(--card-border);
  background: var(--toggle);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 0.15s ease;
}

.lang-switcher summary::-webkit-details-marker { display: none; }
.lang-switcher summary:hover { transform: scale(1.06); }

.lang-switcher summary svg { width: 17px; height: 17px; }

.lang-switcher ul {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  margin: 0;
  padding: 6px;
  list-style: none;
  min-width: 160px;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 60;
}

.lang-switcher ul a {
  display: block;
  padding: 9px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.15s ease;
}

.lang-switcher ul a:hover,
.lang-switcher ul a:focus-visible { background: var(--accent-dim); }

.lang-switcher ul a.current {
  color: var(--accent-strong);
  background: var(--accent-dim);
}

.burger { display: none; flex-direction: column; gap: 4px; }

.burger span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(48px, 8vw, 96px) 0 0;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 40px;
  align-items: center;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
  background: var(--accent-dim);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero-lead {
  font-size: 1.08rem;
  color: var(--subtext);
  max-width: 34em;
}

.hero-facts {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 0;
  margin: 22px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--subtext);
}

.hero-facts li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-facts li::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent);
}

/* плавающие клетки на фоне hero */
.hero-decor { position: absolute; inset: 0; pointer-events: none; }

.hero-decor .cell {
  position: absolute;
  opacity: 0.55;
  animation: floatCell 7s ease-in-out infinite;
}

.hero-decor .d1 { top: 14%; left: 4%;  width: 22px; height: 22px; border-radius: 6px; }
.hero-decor .d2 { top: 68%; left: 9%;  width: 14px; height: 14px; animation-delay: -2s; }
.hero-decor .d3 { top: 26%; left: 44%; width: 18px; height: 18px; border-radius: 5px; animation-delay: -4s; }
.hero-decor .d4 { top: 80%; left: 52%; width: 24px; height: 24px; border-radius: 6px; animation-delay: -1s; }
.hero-decor .d5 { top: 10%; right: 6%; width: 16px; height: 16px; animation-delay: -3s; }
.hero-decor .d6 { top: 58%; right: 3%; width: 20px; height: 20px; border-radius: 6px; animation-delay: -5s; }

@keyframes floatCell {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-16px) rotate(8deg); }
}

/* ---------- Телефон ---------- */

.phone {
  position: relative;
  width: min(310px, 78vw);
  margin: 0 auto;
  border-radius: 44px;
  border: 10px solid #101311;
  background: #101311;
  box-shadow: var(--shadow), 0 30px 60px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  aspect-ratio: 1206 / 2622;
}

.hero-visual .phone {
  transform: rotate(2.5deg);
  margin-bottom: -12%;
}

.phone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  border-radius: 34px;
}

.only-dark { display: none; }
[data-theme="dark"] .only-dark { display: block; }
[data-theme="dark"] .only-light { display: none; }

/* ---------- Секции ---------- */

.section {
  padding: clamp(56px, 8vw, 96px) 0;
  scroll-margin-top: 72px;
}

.section-alt {
  background: var(--surface);
  border-top: 1.5px solid var(--card-border);
  border-bottom: 1.5px solid var(--card-border);
}

/* заголовок-разделитель — как SectionDivider в приложении */
.section-label {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  color: var(--subtext);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-label::before,
.section-label::after {
  content: "";
  height: 1.5px;
  background: var(--card-border);
  flex: 1;
}

.section h2 { text-align: center; margin-bottom: 40px; }

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 36px;
  align-items: start;
}

.about-text { font-size: 1.02rem; color: var(--subtext); }
.about-text p:first-child { color: var(--text); }

.problem-cards { display: grid; gap: 14px; }

.problem-card {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.problem-card h3 { font-size: 1rem; margin-bottom: 6px; }
.problem-card p { margin: 0; font-size: 0.94rem; color: var(--subtext); }

/* ---------- Features ---------- */

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.feature-card {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 22px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-dim);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.feature-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.feature-card p { margin: 0; font-size: 0.94rem; color: var(--subtext); }

/* ---------- How it works ---------- */

.hiw-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 44px;
  align-items: center;
}

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
  display: grid;
  gap: 26px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-inline-start: 62px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 2px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-fill);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="dark"] .steps li::before { color: #0E100F; }

.steps p { margin: 0; font-size: 0.96rem; color: var(--subtext); }

/* демо-поле «тетриса» */
.tetris-demo {
  margin: 0;
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.tetris-caption {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--subtext);
  margin-bottom: 16px;
}

.tetris-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  max-width: 300px;
  margin: 0 auto;
  /* фигура тетромино нарисована по колонкам — не зеркалим её в RTL */
  direction: ltr;
}

.tetris-grid .cell {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 5px;
  opacity: 0;
  transform: scale(0.5);
}

.tetris-grid.animate .cell {
  animation: popCell 0.4s ease forwards;
}

@keyframes popCell {
  to { opacity: 1; transform: scale(1); }
}

.tetris-demo figcaption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin-top: 18px;
  font-size: 0.84rem;
  color: var(--subtext);
}

.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-item .cell { width: 13px; height: 13px; border-radius: 4px; }
.legend-item .c-empty { border: 1px solid var(--card-border); }

/* ---------- Instructions ---------- */

.instructions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.instruction {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 22px 24px;
}

.instruction h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.instruction .num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent-strong);
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.instruction p { margin: 0; font-size: 0.94rem; color: var(--subtext); }
.instruction strong { color: var(--text); }

/* ---------- Screenshots ---------- */

.shots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  justify-items: center;
}

.shot { margin: 0; text-align: center; }

.phone-small { width: min(250px, 70vw); }

.shot figcaption {
  margin-top: 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--subtext);
}

/* ---------- FAQ ---------- */

.faq-item {
  background: var(--card);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  padding-block: 16px;
  padding-inline: 20px 48px;
  font-weight: 700;
  font-size: 0.98rem;
  position: relative;
  transition: background 0.15s ease;
}

.faq-item summary::-webkit-details-marker { display: none; }

.faq-item summary:hover { background: var(--accent-dim); }

.faq-item summary::after {
  content: "";
  position: absolute;
  inset-inline-end: 20px;
  top: 50%;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--subtext);
  border-bottom: 2px solid var(--subtext);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after { transform: translateY(-30%) rotate(225deg); }

.faq-item p {
  margin: 0;
  padding: 0 20px 18px;
  font-size: 0.94rem;
  color: var(--subtext);
}

/* ---------- Download ---------- */

.download-section {
  text-align: center;
  background:
    radial-gradient(ellipse 70% 90% at 50% 110%, var(--accent-dim), transparent);
}

.download-inner { max-width: 620px; }

.download-icon {
  margin: 0 auto 20px;
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.download-section p { color: var(--subtext); }

.download-note {
  font-size: 0.84rem;
  margin-top: 18px;
}

/* ---------- Кнопки сторов ---------- */

.store-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.download-section .store-buttons { justify-content: center; }

.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding-block: 10px;
  padding-inline: 16px 20px;
  border-radius: 14px;
  border: 1.5px solid var(--text);
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.store-btn:hover,
.store-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.store-btn svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
  flex: none;
}

.store-btn span {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-weight: 700;
  font-size: 1.02rem;
  text-align: start;
}

.store-btn small {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.75;
}

.store-btn-solid {
  background: var(--accent-fill);
  border-color: var(--accent-fill);
  color: #fff;
}

[data-theme="dark"] .store-btn-solid { color: #0E100F; }

/* ---------- Подвал ---------- */

.site-footer {
  border-top: 1.5px solid var(--card-border);
  padding: 36px 0;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 32px;
}

.footer-brand { margin-inline-end: auto; }
.footer-brand p { margin: 2px 0 0; font-size: 0.85rem; color: var(--subtext); }

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-size: 0.9rem;
}

.footer-nav a {
  color: var(--subtext);
  text-decoration: none;
  font-weight: 600;
}

.footer-nav a:hover,
.footer-nav a:focus-visible { color: var(--accent-strong); }

.footer-copy {
  width: 100%;
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--subtext);
}

/* ---------- Внутренние страницы (privacy / terms) ---------- */

.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(40px, 6vw, 72px) 20px;
}

.legal-page h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.legal-page h2 { font-size: 1.2rem; text-align: start; margin: 1.6em 0 0.5em; }
.legal-page p, .legal-page li { color: var(--subtext); font-size: 0.98rem; }
.legal-page .back-link {
  display: inline-block;
  margin-bottom: 28px;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- Адаптив ---------- */

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-copy { display: flex; flex-direction: column; align-items: center; }
  .hero-visual .phone { transform: none; margin-bottom: -18%; }
  .store-buttons { justify-content: center; }
  .about-grid, .hiw-grid { grid-template-columns: 1fr; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .tetris-demo { max-width: 420px; margin: 0 auto; }
}

/* Порог схлопывания меню подобран по самой длинной локали (ru/de):
   иначе длинные пункты не влезают и переносятся на две строки. */
@media (max-width: 1140px) {
  .burger { display: inline-flex; }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 16px 16px;
    background: var(--bg);
    border-bottom: 1.5px solid var(--card-border);
    box-shadow: var(--shadow);
  }

  .site-nav.open { display: flex; }

  .site-nav a { padding: 12px 14px; font-size: 1rem; }
  .site-nav a.nav-cta { text-align: center; margin-top: 6px; }
}

@media (max-width: 640px) {
  .features-grid,
  .instructions-grid,
  .shots-grid { grid-template-columns: 1fr; }
  .shots-grid { gap: 36px; }
  .section h2 { margin-bottom: 28px; }
}

/* ---------- Доступность: движение ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-decor .cell { animation: none; }
  .tetris-grid .cell,
  .tetris-grid.animate .cell {
    animation: none;
    opacity: 1;
    transform: none;
  }
  * { transition-duration: 0.01ms !important; }
}
