/* ===== Переменные и темы ===== */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f8fb;
  --text: #1a1a2e;
  --text-muted: #4a5568;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #dbeafe;
  --border: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.95);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-edit: 0 0 0 2px var(--accent), 0 8px 24px rgba(37, 99, 235, 0.2);
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-light: #1e3a5f;
  --border: #334155;
  --header-bg: rgba(15, 23, 42, 0.95);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-edit: 0 0 0 2px var(--accent), 0 8px 24px rgba(96, 165, 250, 0.25);
}

/* Базовые сбросы */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; cursor: pointer; }

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.btn_primary {
  background: var(--accent);
  color: #fff;
}
.btn_primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
}
.btn_outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn_outline:hover {
  background: var(--accent-light);
  text-decoration: none;
}
.btn_large { padding: 16px 32px; font-size: 17px; }
.btn_full { width: 100%; }

/* ===== Шапка ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  gap: 24px;
}
.logo {
  color: var(--text);
  flex-shrink: 0;
}
.logo:hover { color: var(--accent); text-decoration: none; }
.logo__svg { width: 140px; height: 28px; }

.nav {
  display: flex;
  gap: 32px;
}
.nav__link {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
  transition: color 0.2s;
}
.nav__link:hover { color: var(--accent); text-decoration: none; }

.header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header__tg {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 15px;
}
.header__tg:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 18px;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--border); }
.theme-toggle::before { content: '☀'; }
[data-theme="dark"] .theme-toggle::before { content: '☽'; }

.admin-entry {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s, color 0.2s;
}
.admin-entry:hover { opacity: 1; color: var(--accent); }

.burger {
  display: none;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.burger span {
  display: block;
  width: 24px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.header__mobile {
  display: none;
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  padding: 20px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  flex-direction: column;
  gap: 12px;
}
.header__mobile.is-open { display: flex; }

/* ===== Hero ===== */
.hero {
  padding: 100px 0 80px;
  background: linear-gradient(180deg, var(--bg-alt) 0%, var(--bg) 100%);
}
.hero__inner {
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}
.hero__title {
  margin: 0 0 20px;
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s ease forwards;
}
.hero__subtitle {
  margin: 0 0 32px;
  font-size: 18px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s ease 0.1s forwards;
  animation-fill-mode: both;
}
.hero__cta {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s ease 0.2s forwards;
  animation-fill-mode: both;
}
.hero__cta:hover { text-decoration: none; }

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Секции ===== */
.section {
  padding: 80px 0;
  opacity: 0;
  transform: translateY(24px);
}
.section.is-visible {
  animation: fadeUp 0.6s ease forwards;
}
.section__title {
  margin: 0 0 16px;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
}
.section__lead {
  margin: 0 0 48px;
  font-size: 17px;
  color: var(--text-muted);
  text-align: center;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

/* Услуги: градиент в стиле Apple (светлая тема) */
.services {
  position: relative;
  overflow: hidden;
}
.services::before {
  content: '';
  position: absolute;
  inset: 0;
  /* Светлая тема: мягкий градиент в стиле Apple — белый, светло-серый, едва голубой */
  background: linear-gradient(
    180deg,
    #ffffff 0%,
    #fbfbfd 18%,
    #f5f5f7 40%,
    #f0f4f8 60%,
    #f5f5f7 78%,
    #ffffff 100%
  );
  background-size: 100% 200%;
  animation: gradientFlow 14s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
[data-theme="dark"] .services::before {
  background: linear-gradient(
    135deg,
    rgba(30, 58, 95, 0.5) 0%,
    rgba(15, 23, 42, 0.95) 30%,
    rgba(59, 130, 246, 0.15) 50%,
    rgba(15, 23, 42, 0.9) 70%,
    rgba(30, 58, 95, 0.4) 100%
  );
}
.services .container { position: relative; z-index: 1; }
@keyframes gradientFlow {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 0% 100%; }
}
.services__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
}
.card {
  background: var(--bg-alt);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover { box-shadow: var(--shadow); }
.card_service { padding-bottom: 24px; }
.card__image-wrap {
  aspect-ratio: 3/2;
  overflow: hidden;
  background: var(--border);
}
.card__image { width: 100%; height: 100%; object-fit: cover; }
.card__title {
  margin: 20px 20px 0;
  font-size: 18px;
  font-weight: 600;
}
.card__text {
  margin: 8px 20px 20px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}
.card__btn { margin: 0 20px; }

/* Обо мне */
.about { background: var(--bg-alt); }
.about .section__title { margin-bottom: 48px; }
.about__inner { max-width: 900px; margin: 0 auto; }
.about__content {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  align-items: start;
}
.about__photo-wrap {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 4/5;
  max-height: 400px;
}
.about__photo { width: 100%; height: 100%; object-fit: cover; }
.about__text { display: flex; flex-direction: column; gap: 20px; }
.about__p {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
}
.about__p:first-of-type { font-size: 17px; font-weight: 500; }
@media (max-width: 700px) {
  .about__content { grid-template-columns: 1fr; }
  .about__photo-wrap { max-width: 280px; margin: 0 auto; }
}

/* Редактируемые блоки — тень при hover (админ) */
html.edit-mode [data-editable-block]:hover,
html.edit-mode [data-editable]:hover {
  box-shadow: var(--shadow-edit);
}
html.edit-mode [data-editable-block],
html.edit-mode [data-editable] {
  border-radius: 8px;
  transition: box-shadow 0.2s;
}
html.edit-mode .card__image-wrap,
html.edit-mode .portfolio__thumb-wrap {
  cursor: pointer;
}

/* Портфолио */
.portfolio { background: var(--bg-alt); }
.portfolio__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}
.portfolio__item {
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.portfolio__item:hover { box-shadow: var(--shadow); }
.portfolio__thumb-wrap {
  aspect-ratio: 2/3;
  overflow: hidden;
  background: var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}
.portfolio__thumb-wrap:hover { transform: scale(1.02); }
.portfolio__item:hover .portfolio__thumb-wrap { transform: scale(1.02); }
.portfolio__thumb { width: 100%; height: 100%; object-fit: cover; }
.portfolio__name {
  display: block;
  padding: 12px 0 0;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

/* Контакты */
.contacts { background: var(--bg); text-align: center; }
.contacts__lead {
  margin: 0 0 24px;
  font-size: 18px;
  color: var(--text-muted);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.contacts__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
  margin-bottom: 28px;
}
.contacts__link {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}
.contacts__link:hover { text-decoration: underline; }
.contacts__note {
  margin: 0 0 28px;
  font-size: 15px;
  color: var(--text-muted);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* Footer */
.footer {
  padding: 32px 0;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.logo_footer .logo__svg { width: 120px; height: 24px; }
.footer__contacts {
  display: flex;
  gap: 24px;
}
.footer__contacts a { color: var(--text-muted); font-weight: 500; }
.footer__contacts a:hover { color: var(--accent); text-decoration: none; }
.footer__copy { margin: 0; font-size: 14px; color: var(--text-muted); }

/* ===== Модальные окна ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, visibility 0.25s;
}
.modal.is-open {
  opacity: 1;
  visibility: visible;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.modal__box {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: var(--bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: scale(0.95);
  transition: transform 0.25s;
}
.modal.is-open .modal__box { transform: scale(1); }
.modal__box_sm { max-width: 360px; }
.modal__close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.modal__close:hover { background: var(--border); color: var(--text); }
.modal__close::before { content: '×'; }
.modal__title {
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 700;
}

/* Форма */
.form__honey {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.form__label { display: block; margin-bottom: 20px; }
.form__label-text {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}
.form__input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s;
}
.form__input:focus {
  outline: none;
  border-color: var(--accent);
}
.form__input::placeholder { color: var(--text-muted); opacity: 0.7; }
.form__error {
  margin: 0 0 16px;
  font-size: 14px;
  color: #dc2626;
}
.form__error[hidden] { display: none; }
.form button[type="submit"] { margin-top: 8px; }

/* ===== Адаптив ===== */
@media (max-width: 900px) {
  .nav { display: none; }
  .header__tg { display: none; }
  .burger { display: flex; }
  .header__mobile.is-open { display: flex; }
}
@media (max-width: 600px) {
  .header__inner { height: 64px; }
  .header__order { padding: 10px 18px; font-size: 14px; }
  .hero { padding: 60px 0 60px; }
  .section { padding: 56px 0; }
  .services__grid { grid-template-columns: 1fr; }
  .portfolio__grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .footer__inner { flex-direction: column; text-align: center; }
}

/* Intersection Observer: появление секций */
.reveal { opacity: 0; transform: translateY(24px); }
.reveal.is-visible { animation: fadeUp 0.6s ease forwards; }

/* Тосты */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 24px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 300;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.toast.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast[hidden] { display: none; }

/* Шлейф курсора */
.cursor-trail {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
.cursor-trail__dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
  transform: translate(-50%, -50%);
}

/* Перестановка секций в режиме правки */
.section-drag-handle {
  display: none;
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--accent);
  cursor: grab;
  opacity: 0.8;
  padding: 8px;
  line-height: 1;
  z-index: 2;
}
html.edit-mode .section-drag-handle { display: block; }
html.edit-mode [data-section-id] { position: relative; }
html.edit-mode .section-drag-handle:active { cursor: grabbing; }
html.edit-mode [data-section-id].is-dragging { opacity: 0.7; }
html.edit-mode [data-section-id].drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}
