/* ══════════════════════════════════════════════════════════════════════
   MOON — общий фундамент: шрифты, палитра, типографика, базовые элементы.
   Подключается и публичным меню, и админкой, поэтому кафе выглядит
   одинаково по обе стороны экрана.
   ══════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Fixel Text";
  src: url("/fonts/FixelText-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fixel Text";
  src: url("/fonts/FixelText-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fixel Text";
  src: url("/fonts/FixelText-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fixel Display";
  src: url("/fonts/FixelDisplay-Light.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fixel Display";
  src: url("/fonts/FixelDisplay-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Палитра по умолчанию — шаблон «Луна». Остальные шаблоны переопределяют
     эти же переменные в styles/themes.css; значения здесь остаются запасными,
     если файл шаблонов почему-то не загрузился.

     Различать «текст на карточке» и «текст на странице» обязательно: в тёмных
     шаблонах страница тёмная, а карточки светлые, и одним цветом не обойтись. */
  --bg: #e7ded5;
  --bg-deep: #ddd2c6;
  --bg-glow: rgba(255, 253, 249, 0.85);
  --surface: #f7f3ee;
  --surface-raised: #fbf9f6;
  --ink: #2b251f;           /* текст на карточках и других поверхностях */
  --ink-soft: #5c5145;      /* 6.99 к surface — годится для мелкого текста */
  --on-bg: #2b251f;         /* текст прямо на фоне страницы */
  --on-bg-soft: #5c5145;
  --accent: #806b51;        /* кофейный: фон кнопок, крупные акценты */
  --accent-strong: #6a5a46; /* тот же кофе, но пригодный для мелкого текста */
  --accent-quiet: #b39473;  /* карамель: только декор и крупные элементы */
  --accent-on-bg: #6a5a46;  /* акцент поверх фона страницы: он темнее карточки */
  --line: rgba(43, 37, 31, 0.12);
  --line-strong: rgba(43, 37, 31, 0.2);
  --line-bg: rgba(43, 37, 31, 0.12);       /* линии прямо на фоне страницы */
  --line-bg-strong: rgba(43, 37, 31, 0.2);
  --footer-bg: color-mix(in srgb, var(--surface) 72%, var(--bg));
  --danger: #8a3f2e;
  --danger-soft: #f6e7e2;
  --success: #4a6b45;
  --success-soft: #e8efe4;
  --on-accent: #fdfbf8;
  --card-radius: 24px;
  --card-radius-lg: 30px;

  /* Тени — мягкие и тёплые, без «серого» оттенка. */
  --shadow-sm: 0 1px 2px rgba(59, 45, 30, 0.06), 0 2px 8px rgba(59, 45, 30, 0.05);
  --shadow-md: 0 2px 6px rgba(59, 45, 30, 0.07), 0 12px 28px rgba(59, 45, 30, 0.09);
  --shadow-lg: 0 8px 20px rgba(59, 45, 30, 0.1), 0 28px 60px rgba(59, 45, 30, 0.16);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --page-gutter: 16px;
  --page-max: 1180px;

  --font-text: "Fixel Text", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-display: "Fixel Display", "Fixel Text", ui-sans-serif, system-ui, sans-serif;

  /* Кривые и длительности — единый набор на весь проект.
     Значения взяты из проектного набора навыков (skills/animate),
     а не подобраны на глаз: встроенные CSS-плавности слишком вялые. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);        /* вход и выход */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);    /* движение по экрану */
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);     /* шторка снизу */
  --dur-fast: 140ms;   /* отклик на нажатие */
  --dur-base: 220ms;   /* переключения и всплывающие элементы */
  --dur-enter: 280ms;  /* появление карточек */
  --dur-slow: 380ms;   /* модальные окна и шторки */
}

@media (min-width: 640px) {
  :root {
    --page-gutter: 28px;
  }
}
@media (min-width: 1024px) {
  :root {
    --page-gutter: 40px;
  }
}

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

/* Атрибут hidden должен побеждать любой display из авторских стилей —
   иначе скрытые кнопки и панели продолжают показываться. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--on-bg);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

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

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

/* Видимый фокус — обязателен: меню и админкой пользуются с клавиатуры. */
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
  border-radius: 4px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Кнопки ─────────────────────────────────────────────────────────── */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.btn:active:not(:disabled) {
  transform: scale(0.975);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) {
  --btn-bg: var(--accent-strong);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-border: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) {
  --btn-bg: var(--surface-raised);
  --btn-border: var(--accent-quiet);
}

.btn-ghost {
  --btn-fg: var(--accent-strong);
  min-height: 40px;
  padding: 8px 14px;
}
.btn-ghost:hover:not(:disabled) {
  --btn-bg: rgba(128, 107, 81, 0.1);
}

.btn-danger {
  --btn-bg: transparent;
  --btn-fg: var(--danger);
  --btn-border: rgba(138, 63, 46, 0.35);
}
.btn-danger:hover:not(:disabled) {
  --btn-bg: var(--danger-soft);
  --btn-border: var(--danger);
}

.btn-small {
  /* 40px — нижняя граница, на которую ещё уверенно попадает палец. */
  min-height: 40px;
  padding: 6px 14px;
  font-size: 0.875rem;
}

/* Иконка-кнопка: всегда не меньше 44×44, чтобы в неё попадал палец. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.icon-btn:hover {
  background: rgba(43, 37, 31, 0.07);
}
.icon-btn:active {
  transform: scale(0.93);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* ─── Поля ввода ─────────────────────────────────────────────────────── */

.field {
  display: grid;
  gap: 6px;
}

.field > label,
.field-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}
.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--accent-quiet);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(128, 107, 81, 0.18);
}
.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  font-size: 0.82rem;
  color: var(--danger);
  min-height: 1em;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ─── Мелочи ─────────────────────────────────────────────────────────── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: moon-spin 700ms linear infinite;
}

@keyframes moon-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Лунный мотив: тонкая дуга-разделитель. */
.moon-arc {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(
    to right,
    transparent,
    var(--line-bg-strong) 20%,
    var(--accent-quiet) 50%,
    var(--line-bg-strong) 80%,
    transparent
  );
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
