/* Happy Mail — дизайн-система. Референсы: design-refs/ (советская открытка + дорогой уют). */

@font-face { font-family: 'Cormorant'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/cormorant-500-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Cormorant'; font-weight: 500; font-style: normal; font-display: swap; src: url('/fonts/cormorant-500-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Cormorant'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/cormorant-600-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Cormorant'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/cormorant-600-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Cormorant'; font-weight: 500; font-style: italic; font-display: swap; src: url('/fonts/cormorant-500i-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Cormorant'; font-weight: 500; font-style: italic; font-display: swap; src: url('/fonts/cormorant-500i-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Manrope'; font-weight: 400 700; font-display: swap; src: url('/fonts/manrope-400-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Manrope'; font-weight: 400 700; font-display: swap; src: url('/fonts/manrope-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Marck'; font-weight: 400; font-display: swap; src: url('/fonts/marck-400-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Marck'; font-weight: 400; font-display: swap; src: url('/fonts/marck-400-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122; }

:root {
  /* Палитра «Цвета Нового года» */
  --wine: #7a1830;
  --wine-deep: #4c0f1e;
  --wine-ink: #3a0a16;
  --pine: #1f3b30;
  --pine-deep: #12251d;
  --night: #120a0d;
  --cream: #f7efe2;
  --paper: #fbf6ec;
  --champagne: #eadbc2;
  --gold: #b8904f;
  --gold-light: #e3c48a;
  --gold-deep: #8c6a33;
  --cocoa: #5b3f2c;
  --ink: #2b1b16;
  --ink-soft: #6a5649;
  --line: rgba(91, 63, 44, 0.18);
  --ok: #2f6b4f;
  --err: #a3243b;

  --serif: 'Cormorant', 'Times New Roman', serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --script: 'Marck', 'Segoe Script', cursive;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow-paper: 0 1px 0 rgba(255,255,255,.6) inset, 0 18px 40px -18px rgba(40, 10, 15, .55), 0 2px 6px rgba(40, 10, 15, .18);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums; /* у Cormorant цифра 1 иначе похожа на I */
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Ночной фон с тёплыми огнями ---------- */
.night {
  color: var(--cream);
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(227, 196, 138, .22), transparent 60%),
    radial-gradient(60% 40% at 85% 20%, rgba(122, 24, 48, .55), transparent 70%),
    radial-gradient(70% 50% at 10% 80%, rgba(31, 59, 48, .7), transparent 70%),
    linear-gradient(180deg, #1a0c11 0%, var(--night) 60%, #0d0709 100%);
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}
.bokeh { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bokeh i {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 150, .55), rgba(255, 214, 150, 0) 70%);
  filter: blur(1px);
  animation: twinkle 6s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: .35; transform: scale(1); } 50% { opacity: .9; transform: scale(1.15); } }

.snow { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.snow i {
  position: absolute; top: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  animation: fall linear infinite;
}
@keyframes fall { to { transform: translate3d(var(--drift, 20px), 110vh, 0); } }
@media (prefers-reduced-motion: reduce) {
  .snow, .bokeh i { animation: none; }
  .snow { display: none; }
}

/* ---------- Типографика ---------- */
.eyebrow { font-family: var(--script); font-size: 26px; line-height: 1; color: var(--gold-light); }
.h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(38px, 10vw, 64px); line-height: 1.02; letter-spacing: -.01em; margin: 0; }
.h1 em { font-style: italic; font-weight: 500; color: var(--gold-light); }
.h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 7vw, 36px); line-height: 1.1; margin: 0; }
.lead { font-size: 17px; line-height: 1.55; opacity: .88; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.ornament { display: flex; align-items: center; gap: 10px; color: var(--gold); }
.ornament::before, .ornament::after { content: ''; height: 1px; flex: 1; background: linear-gradient(90deg, transparent, currentColor, transparent); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px; border-radius: 999px; border: 0;
  font-weight: 700; font-size: 16px; letter-spacing: .01em; text-decoration: none;
  cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s, background .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn[aria-busy='true'] { opacity: .6; cursor: default; pointer-events: none; }
.btn--gold {
  color: var(--wine-ink);
  background: linear-gradient(180deg, #f0d6a0 0%, var(--gold-light) 45%, var(--gold) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 10px 24px -10px rgba(227, 196, 138, .8);
}
.btn--wine { color: var(--cream); background: linear-gradient(180deg, #8d1f3a, var(--wine)); box-shadow: 0 10px 24px -12px rgba(122, 24, 48, .9); }
.btn--ghost { color: inherit; background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.btn--quiet { color: var(--ink-soft); background: rgba(91, 63, 44, .08); }
.btn--block { width: 100%; }
.btn--sm { min-height: 44px; padding: 0 16px; font-size: 14px; }

/* ---------- Бумага ---------- */
.paper {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,.7), transparent 60%),
    linear-gradient(180deg, var(--paper), var(--cream));
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-paper);
}

/* ---------- Поля ---------- */
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field label, .field legend { font-weight: 700; font-size: 15px; }
.field .hint { font-size: 13px; color: var(--ink-soft); display: flex; justify-content: space-between; gap: 8px; }
.field .err { font-size: 13px; color: var(--err); min-height: 0; }
.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: rgba(255, 255, 255, .75);
  transition: border-color .2s, box-shadow .2s;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(184, 144, 79, .18); }
.input[aria-invalid='true'] { border-color: var(--err); }
.counter.is-over { color: var(--err); font-weight: 700; }

.choice { display: grid; gap: 10px; border: 0; padding: 0; margin: 0 0 18px; }
.choice label {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--line); background: rgba(255,255,255,.6); cursor: pointer; font-weight: 500;
}
.choice input { accent-color: var(--wine); width: 18px; height: 18px; }
.choice label:has(input:checked) { border-color: var(--wine); background: #fff; }
.choice label:has(input:disabled) { opacity: .5; cursor: default; }

/* ---------- Тосты ---------- */
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(92vw, 420px); }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--cream); box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: 15px; animation: toast-in .3s var(--ease); }
.toast--err { background: var(--err); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Подвал ---------- */
.footer { padding: 28px 20px 36px; font-size: 13px; text-align: center; opacity: .7; line-height: 2.2; }
.footer a { text-decoration: none; border-bottom: 1px solid currentColor; }

/* ---------- Сцена: почта зимней ночью (картинка вместо нарисованного фона) ---------- */
.scene {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: var(--night) url('/img/scene/post-office-mobile.webp') center 35% / cover no-repeat;
  transition: filter .5s var(--ease), transform .5s var(--ease);
}
@media (min-aspect-ratio: 4/5) { .scene { background-image: url('/img/scene/post-office-desktop.webp'); background-position: center 40%; } }
.scene::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(18,10,13,.62) 0%, rgba(18,10,13,.18) 32%, rgba(18,10,13,.25) 62%, rgba(18,10,13,.88) 100%);
}
/* Экраны с текстом и бумагой: фон уходит в расфокус, чтобы не спорить с содержимым */
.scene--dim { filter: blur(6px) brightness(.55); transform: scale(1.06); }
.scene ~ .bokeh { display: none; }
@media (prefers-reduced-motion: reduce) { .scene { transition: none; } }
