/* ============================================================
   Таємний Санта — дизайн-система
   Токени → база → компоненти. Використовують index.html і admin.html.
   Заголовки: Dela Gothic One. Усе інше: Inter.
   ============================================================ */

/* ---------- 1. Токени ---------- */
:root {
  color-scheme: light;

  /* Колір */
  --c-red: #A3201F;          /* основне поле */
  --c-red-deep: #6F1212;     /* тіні кнопок, тінь заголовка */
  --c-red-ink: #8E1A16;      /* червоний текст на світлому (AA) */
  --c-cream: #F6ECD8;        /* текст на червоному, кнопки */
  --c-paper: #FBF5E8;        /* фон модалки та адмінки */
  --c-white: #FFFFFF;
  --c-ink: #2A1512;          /* основний текст на світлому */
  --c-ink-2: #6B5049;        /* другорядний текст на світлому (AA на paper) */
  --c-line: #2A15121F;
  --c-green: #1E3A2B;
  --c-gold: #DDAA48;
  --c-on-red-2: #F6ECD8E0;   /* другорядний текст на червоному (AA) */

  --c-ok-bg: #DDEFE2;   --c-ok: #1D4A30;
  --c-warn-bg: #F7E7C2; --c-warn: #6E4A0C;
  --c-err-bg: #FBE3DF;  --c-err: #A3160F;
  --c-mute-bg: #EFE6D4; --c-mute: #5E4C38;

  /* Шрифти */
  --f-display: "Dela Gothic One", "Arial Black", system-ui, sans-serif;
  --f-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Шкала тексту */
  --t-xs: 13px;
  --t-sm: 15px;
  --t-md: 17px;
  --t-lg: 19px;
  --t-h3: clamp(20px, 2.2vw, 24px);
  --t-h2: clamp(24px, 3vw, 30px);
  --t-h1: clamp(40px, 7.2vw, 84px);

  /* Відступи (крок 4) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px; --s-9: 64px;

  /* Радіуси */
  --r-sm: 10px; --r-md: 14px; --r-lg: 22px; --r-pill: 999px;

  /* Тіні та рух */
  --sh-press: 0 4px 0 var(--c-red-deep);
  --sh-press-ink: 0 4px 0 var(--c-ink);
  --sh-pop: 0 30px 80px -24px #1a0000cc;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --focus: 0 0 0 3px var(--c-paper), 0 0 0 6px var(--c-gold);

  /* Розміри керування */
  --ctl-h: 56px;
}

/* ---------- 2. База ---------- */
*, *::before, *::after { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 var(--t-md)/1.55 var(--f-body); -webkit-font-smoothing: antialiased; overflow-x: clip; }
img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, .display { font-family: var(--f-display); font-weight: 400; line-height: 1.05; letter-spacing: -.005em; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 3. Компоненти ---------- */

/* Кнопка */
.btn {
  --btn-bg: var(--c-red); --btn-fg: var(--c-cream); --btn-sh: var(--c-red-deep);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-3);
  min-height: var(--ctl-h); padding: 0 var(--s-6);
  font: 700 var(--t-md)/1 var(--f-body); letter-spacing: .005em; text-decoration: none; white-space: nowrap;
  color: var(--btn-fg); background: var(--btn-bg); border: 2px solid transparent; border-radius: var(--r-pill);
  box-shadow: 0 4px 0 var(--btn-sh);
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), opacity .2s;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 var(--btn-sh); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--btn-sh); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }
.btn--cream { --btn-bg: var(--c-cream); --btn-fg: var(--c-red-ink); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--c-ink); --btn-sh: transparent; border-color: var(--c-ink); }
.btn--ghost:hover:not(:disabled) { box-shadow: 3px 3px 0 var(--c-ink); }
.btn--danger { --btn-bg: transparent; --btn-fg: var(--c-err); --btn-sh: transparent; border-color: var(--c-err); }
.btn--sm { min-height: 44px; padding: 0 var(--s-4); font-size: var(--t-sm); }
.btn--block { width: 100%; }
.link { background: none; border: 0; padding: var(--s-2) 0; min-height: 44px; font: 500 var(--t-sm) var(--f-body); color: var(--c-ink-2); text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--c-red-ink); }

/* Поле */
.field { display: grid; gap: var(--s-2); }
.field__label { font: 600 var(--t-sm)/1.2 var(--f-body); color: var(--c-ink); }
.field__label b { color: var(--c-red-ink); font-weight: 600; }
.field__input {
  width: 100%; min-height: var(--ctl-h); padding: 14px var(--s-4);
  font: 500 var(--t-md)/1.35 var(--f-body); color: var(--c-ink);
  background: var(--c-white); border: 2px solid var(--c-ink); border-radius: var(--r-md);
  transition: box-shadow .15s, border-color .15s;
}
textarea.field__input { min-height: 112px; resize: vertical; display: block; }
.field__input::placeholder { color: #2A151275; }
.field__input:focus { outline: none; border-color: var(--c-red); box-shadow: 4px 4px 0 var(--c-red); }
.field__input:focus-visible { box-shadow: 4px 4px 0 var(--c-red); }
.field__prefix { position: relative; }
.field__prefix > span { position: absolute; left: var(--s-4); top: 50%; transform: translateY(-50%); font: 600 var(--t-md) var(--f-body); color: var(--c-ink-2); pointer-events: none; }
.field__prefix > .field__input { padding-left: 38px; }
.field__hint { font-size: var(--t-xs); color: var(--c-ink-2); }
.field__error { font-size: var(--t-xs); color: var(--c-err); font-weight: 500; }
.field__error:empty { display: none; }
.field__input[aria-invalid="true"] { border-color: var(--c-err); background: #FFF6F4; }

/* Бейдж */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font: 600 var(--t-xs)/1.5 var(--f-body); white-space: nowrap; background: var(--c-mute-bg); color: var(--c-mute); }
.badge--ok { background: var(--c-ok-bg); color: var(--c-ok); }
.badge--warn { background: var(--c-warn-bg); color: var(--c-warn); }
.badge--err { background: var(--c-err-bg); color: var(--c-err); }

/* Повідомлення */
.note { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); font-size: var(--t-sm); background: var(--c-mute-bg); color: var(--c-ink); }
.note--ok { background: var(--c-ok-bg); color: var(--c-ok); }
.note--err { background: var(--c-err-bg); color: var(--c-err); }

/* Модальне вікно */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--s-4); }
.modal__scrim { position: absolute; inset: 0; background: #1E0605B8; backdrop-filter: blur(3px); animation: fade .25s var(--ease); }
.modal__panel {
  position: relative; width: min(100%, 560px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  background: var(--c-paper); color: var(--c-ink); border-radius: var(--r-lg); box-shadow: var(--sh-pop);
  padding: var(--s-7) clamp(20px, 5vw, 44px) var(--s-7); animation: rise .35s var(--ease);
}
.modal__close { position: absolute; top: var(--s-3); right: var(--s-3); width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--c-ink); }
.modal__close:hover { background: var(--c-mute-bg); }
.modal__close svg { width: 22px; height: 22px; }
@media (max-width: 600px) {
  .modal { padding: 0; place-items: end stretch; }
  .modal__panel { width: 100%; max-height: 94dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--s-6) var(--s-5) calc(var(--s-6) + env(safe-area-inset-bottom)); animation: sheet .35s var(--ease); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes sheet { from { transform: translateY(100%); } }
