/* Приглашение-письмо: общий вид для страницы получателя и предпросмотра.
   Цвета и шрифты приходят из темы (themes.css). */

.iv { position: relative; container-type: inline-size; color: var(--ink); font-family: var(--font-text); }

/* ---------- конверт ---------- */

.env { display: grid; justify-items: center; gap: 18px; padding: 12px 0 8px; text-align: center; }
.env[hidden] { display: none; }
.env__to {
  font-family: var(--font-hand); font-weight: 700; font-size: clamp(2.2rem, 1.6rem + 3cqi, 3rem);
  line-height: 1; color: var(--env-ink, var(--ink)); transform: rotate(-3deg);
}
.env__body {
  position: relative; width: min(100%, 340px); aspect-ratio: 3 / 2; padding: 0; border: 0; background: none;
  cursor: pointer; perspective: 900px; -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, .18));
  animation: env-wait 2.8s ease-in-out infinite;
}
.env__body:focus-visible { outline-offset: 8px; border-radius: 18px; }
.env__body > * { position: absolute; left: 0; width: 100%; }
.env__back { top: 0; height: 100%; fill: var(--env-fill, var(--stamp)); }
.env__letter {
  top: 8%; left: 8%; width: 84%; height: 80%; border-radius: 12px; background: var(--bg);
  display: grid; align-content: start; gap: 9px; padding: 18% 12% 0;
  transition: transform .55s cubic-bezier(.16, 1, .3, 1) .35s;
}
.env__letter span { height: 7px; border-radius: 4px; background: var(--line); }
.env__letter span:nth-child(2) { width: 80%; }
.env__letter span:nth-child(3) { width: 55%; }
.env__pocket { bottom: 0; height: 100%; fill: color-mix(in oklab, var(--env-fill, var(--stamp)) 82%, #fff); }
.env__flap {
  top: 0; height: 60%; fill: color-mix(in oklab, var(--env-fill, var(--stamp)) 84%, #000);
  transform-origin: 50% 0; transition: transform .45s cubic-bezier(.4, 0, .2, 1) .12s; z-index: 2;
}
.env__seal {
  top: 46%; left: 50%; width: 22%; aspect-ratio: 1; translate: -50% -50%; z-index: 3;
  transition: transform .25s ease, opacity .25s ease;
}
.env__seal svg { width: 100%; height: 100%; }
.env__seal circle { fill: var(--seal, var(--stamp)); stroke: color-mix(in oklab, var(--seal, var(--stamp)) 70%, #000); stroke-width: 3; }
.env__seal path { fill: var(--seal-ink, rgba(255, 255, 255, .85)); }
.env__hint { font-weight: 700; font-size: 1rem; color: var(--env-muted, var(--muted)); }

.env.is-open .env__body { animation: none; }
.env.is-open .env__seal { transform: scale(1.3); opacity: 0; }
.env.is-open .env__flap { transform: rotateX(180deg); z-index: 0; }
.env.is-open .env__letter { transform: translateY(-46%); }
.env.is-leaving { transition: opacity .3s ease, transform .3s ease; opacity: 0; transform: translateY(24px) scale(.96); }

@keyframes env-wait { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(-1deg); } }

/* ---------- карточка ---------- */

.iv__ticket {
  width: 100%; max-width: 440px; margin: 0 auto;
  padding-bottom: var(--stub-h);
  border-radius: var(--iv-radius);
  box-shadow: var(--card-shadow);
}
.iv__ticket[hidden] { display: none; }
.iv:not([data-theme="ticket"]) .iv__ticket { -webkit-mask: none; mask: none; margin-top: 46px; }

.iv__body { padding: 28px 24px 26px; }

.iv__screen { display: grid; gap: 16px; text-align: center; }
.iv__screen[hidden] { display: none; }
.iv__screen.is-in > * { animation: iv-in .5s var(--ease) both; }
.iv__screen.is-in > :nth-child(2) { animation-delay: .05s; }
.iv__screen.is-in > :nth-child(3) { animation-delay: .1s; }
.iv__screen.is-in > :nth-child(n+4) { animation-delay: .15s; }
@keyframes iv-in { from { opacity: 0; transform: translateY(14px); } }

.iv__to { font-family: var(--font-hand); font-weight: 700; font-size: 1.9rem; line-height: 1; margin-bottom: -6px; color: var(--accent); }
.iv__to[hidden], .iv__from[hidden] { display: none; }
.iv__from { font-family: var(--font-hand); font-weight: 700; font-size: 1.8rem; line-height: 1; color: var(--accent); justify-self: end; margin-top: -6px; transform: rotate(-3deg); }

.iv__pic { display: grid; place-items: center; }
.iv__pic[hidden] { display: none; }
.iv__pic img { width: min(56%, 200px); aspect-ratio: 1; object-fit: contain; }
.iv__pic.is-cat .cat { width: min(64%, 210px); }
.iv__pic.is-photo img { width: min(78%, 280px); aspect-ratio: 1; object-fit: cover; }
.iv__pic.is-heart img {
  -webkit-mask: url("/assets/img/heart-mask.svg") center / contain no-repeat;
          mask: url("/assets/img/heart-mask.svg") center / contain no-repeat;
}
.iv__pic.is-heart { filter: drop-shadow(0 10px 18px color-mix(in oklab, var(--stamp) 35%, transparent)); }
.iv__pic.is-round img { border-radius: 24px; aspect-ratio: 4 / 5; border: 4px solid var(--bg); box-shadow: 0 12px 26px -12px rgba(0, 0, 0, .35); }

/* котик выглядывает из-за верхнего края карточки на шагах выбора */
.iv__peek {
  position: absolute; z-index: -1; top: -64px; right: 28px; width: 104px;
  transition: transform .45s cubic-bezier(.16, 1, .3, 1), opacity .3s;
  transform: translateY(40px); opacity: 0;
}
.iv[data-screen="date"] .iv__peek, .iv[data-screen="food"] .iv__peek { transform: none; opacity: 1; }
.iv__ticket { position: relative; isolation: isolate; background: var(--bg); }
.iv[data-theme="ticket"] .iv__peek { display: none; }

.iv__title {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.6rem, 1rem + 3cqi, 2.1rem);
  line-height: var(--iv-title-leading); letter-spacing: var(--iv-title-tracking); text-transform: var(--iv-title-case);
  overflow-wrap: anywhere;
}
.iv[data-theme="ticket"] .iv__title { font-size: clamp(1.9rem, 1.2rem + 3.2cqi, 2.6rem); }
.iv__text { font-size: 1.0625rem; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.iv__title[hidden], .iv__text[hidden] { display: none; }

/* ---------- кнопки ---------- */

.iv .btn, .iv-portal .btn {
  border-radius: var(--iv-btn-radius);
  font-family: var(--font-display); text-transform: var(--iv-title-case);
  letter-spacing: 0; font-weight: 700; font-size: 1.05rem;
}
.iv:not([data-theme="ticket"]) .btn:not(.btn--ghost) {
  border-color: var(--accent); background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 10px 22px -10px color-mix(in oklab, var(--accent) 80%, #000);
}
.iv:not([data-theme="ticket"]) .btn--ghost, .iv-portal:not([data-theme="ticket"]) .btn--ghost { border-color: var(--line); background: var(--bg); color: var(--ink); }

.iv__answers { display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; min-height: 72px; }
.iv__yes { min-width: 136px; transform: scale(var(--grow, 1)); transition: transform .3s var(--ease), width .3s var(--ease); }
.iv__yes:hover { transform: scale(var(--grow, 1)) translateY(-2px); }
.iv__yes.is-only { width: 100%; max-width: 280px; }
.iv__no { min-width: 112px; }
.iv__no[hidden] { display: none; }
.iv__no-ghost { display: inline-block; height: 52px; }
/* слой для бегущей «Нет»: тема та же, но без container-type и transform у предков */
.iv-portal { position: absolute; inset: 0; pointer-events: none; z-index: 50; }
.iv-portal--fixed { position: fixed; z-index: 90; }
.iv-portal .iv__no { pointer-events: auto; }
.iv__no.is-running {
  position: absolute; z-index: 50; margin: 0;
  transform: scale(var(--shrink, 1));
  transition: left .32s var(--ease), top .32s var(--ease), transform .32s var(--ease), opacity .28s;
}
.iv__no.is-gone { opacity: 0; transform: scale(.2) rotate(-20deg); }
.iv__no-gone { font-size: .95rem; font-weight: 600; color: var(--muted); }
.iv__no-gone[hidden] { display: none; }

/* ---------- календарь ---------- */

.cal { text-align: center; }
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal__month { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; text-transform: var(--iv-title-case); }
.cal__nav {
  width: 40px; height: 40px; border: 2px solid var(--line); border-radius: 12px; background: var(--bg);
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.cal__nav:disabled { opacity: .3; cursor: default; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal__wd { font-size: var(--step-small); color: var(--muted); padding: 4px 0; }
.cal__day {
  aspect-ratio: 1; min-height: 36px; border: 0; border-radius: 12px; background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 1rem; cursor: pointer; transition: background-color .15s, color .15s, transform .15s;
}
.cal__day:hover:not(:disabled) { background: var(--tint-5); }
.cal__day:disabled { background: none; color: color-mix(in oklab, var(--ink) 25%, transparent); cursor: default; }
.cal__day.is-today { box-shadow: inset 0 0 0 2px var(--tint-4); }
.cal__day[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); transform: scale(1.06); }

/* ---------- время и блюда ---------- */

.times { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  min-height: 42px; padding: 0 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink);
  font-weight: 700; font-size: 1rem; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--surface); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.times__other { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; }
.times__other[hidden] { display: none; }
.times__other input { min-height: 44px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }

.dishes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dish {
  display: grid; justify-items: center; align-content: center; gap: 4px;
  min-height: 104px; padding: 12px 8px; border: 2px solid var(--line); border-radius: 20px;
  background: var(--bg); color: var(--ink); cursor: pointer; transition: background-color .15s, color .15s, transform .15s, border-color .15s;
}
.dish:hover { background: var(--surface); }
.dish__emoji { font-size: 2.2rem; line-height: 1; }
.dish__label { font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.dish[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); transform: translateY(-2px); }

.iv__comment { display: grid; gap: 6px; text-align: left; font-weight: 700; }
.iv__comment small { font-weight: 400; color: var(--muted); font-size: var(--step-small); }
.iv__comment textarea {
  width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink);
  resize: vertical; font-size: 1rem;
}
.iv__comment textarea:focus { border-color: var(--accent); outline: none; }
.iv__comment-slot:empty { display: none; }

.iv__error { color: var(--stamp); font-weight: 700; }

/* ---------- план (корешок) ---------- */

.iv:not([data-theme="ticket"]) .ticket__stub {
  background-image: radial-gradient(circle, var(--line) 1.6px, transparent 2px);
  background-size: 12px 6px; background-position: 0 0; background-repeat: repeat-x;
}
.iv:not([data-theme="ticket"]) .ticket__stub::before {
  content: ""; position: absolute; top: -9px; left: 50%; width: 18px; height: 18px; translate: -50% 0;
  background: var(--stamp);
  -webkit-mask: url("/assets/img/heart-mask.svg") center / contain no-repeat;
          mask: url("/assets/img/heart-mask.svg") center / contain no-repeat;
}
.iv:not([data-theme="ticket"]) .ticket__label { font-family: var(--font-text); font-weight: 700; letter-spacing: .02em; text-transform: none; font-size: .8125rem; }
.iv:not([data-theme="ticket"]) .ticket__value { font-family: var(--font-display); font-weight: 600; font-size: 1rem; text-transform: none; border-bottom-color: var(--line); }

.plan { display: grid; gap: 12px; justify-items: center; margin-top: 4px; }
.plan[hidden] { display: none; }
.plan__count {
  padding: 8px 16px; border-radius: 999px; background: var(--surface);
  font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums;
}
.plan__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.iv--preview .plan__actions { pointer-events: none; }

/* ---------- штамп ---------- */

.iv[data-screen="final"] .stamp { right: 10px; top: 10px; }
.iv:not([data-theme="ticket"]) .stamp {
  width: 96px; height: 96px; font-family: var(--font-display); font-size: 1.9rem;
  border-width: 4px; box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 6px var(--stamp);
}
.iv--no-food .ticket__stub { grid-template-columns: 1.3fr 1fr; }

@container (max-width: 360px) {
  .iv__body { padding: 24px 16px 22px; }
  .ticket__stub { padding: 0 14px; }
  .ticket__value { font-size: 1rem; }
  .dish { min-height: 92px; }
  .iv__peek { width: 88px; top: -54px; }
}

@media (prefers-reduced-motion: reduce) {
  .env__body { animation: none; }
}
