/* =========================================================
   Лучик - лёгкий, нежный, мягкий.
   Тёплая слоновая кость, песок и приглушённый шалфей; арки с фотографиями,
   волны между секциями, тонкая антиква Cormorant и разреженные подписи Montserrat.
   Подпись - рукописная Marck Script. Только светлая тема: так задумано.
   Каждый экран помещается в окно целиком, прокрутки нет: блоки с фотографиями
   подстраиваются по высоте, размеры шрифтов зависят от высоты экрана.
   ========================================================= */
:root {
  --bg: #f6f0ea;
  --sand: #ece2d7;
  --panel: #fbf8f4;
  --beige: #e8dbcd;
  --beige-2: #ddccbc;
  --text: #4b423c;
  --muted: #8d8178;
  --accent: #a6826a;
  --rose: #bf8577;
  --line: rgba(75, 66, 60, 0.16);
  --pad: 20px;
  --serif: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --sans: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --script: "Marck Script", "Segoe Script", cursive;
  --ease: cubic-bezier(0.22, 0.7, 0.2, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.65 var(--sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.35; cursor: default; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.ic { flex: none; display: block; }

/* Экран - колонка во всю высоту окна. */
.wrap {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 480px; margin: 0 auto;
  padding: env(safe-area-inset-top) var(--pad) 0;
  overflow: hidden;
}
.loading { margin: auto; color: var(--muted); font: italic 20px var(--serif); }
.muted { color: var(--muted); }

/* ---------- Типографика ---------- */
.eyebrow { margin: 0; font: 500 10px/1.5 var(--sans); letter-spacing: 0.26em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 6px 0 0; font: 400 clamp(28px, 5vh, 38px)/1.08 var(--serif); letter-spacing: -0.005em; }
h2 { margin: 4px 0 0; font: 400 clamp(22px, 3.6vh, 30px)/1.15 var(--serif); }
h1 em, h2 em { font-style: italic; }
.lead { margin: 0; font: italic 400 clamp(18px, 2.6vh, 21px)/1.35 var(--serif); color: var(--muted); }

/* ---------- Шапка ---------- */
.top { flex: none; display: flex; align-items: center; justify-content: space-between; height: 52px; margin: 0 -8px; }
.brand { display: flex; align-items: center; gap: 9px; padding-left: 8px; font: 500 15px/1 var(--serif); letter-spacing: 0.34em; text-transform: uppercase; }
.brand .ic { color: var(--accent); }
.top-act { display: flex; }
.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text);
}
.icon-btn:active { background: var(--sand); }
.jar-btn b {
  position: absolute; top: 5px; right: 3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--rose); color: #fff;
  font: 600 10px/17px var(--sans);
}
.jar-btn.bump { animation: bump 0.7s var(--ease); }
@keyframes bump { 35% { transform: scale(1.15) rotate(-5deg); } 70% { transform: scale(0.97) rotate(2deg); } }

/* ---------- Приветствие ---------- */
.greet { flex: none; text-align: center; padding: clamp(2px, 1vh, 10px) 0 clamp(8px, 1.8vh, 16px); }
.greet.small h1 { font-size: clamp(24px, 4vh, 32px); }

/* ---------- Арки ---------- */
.arch {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: 999px 999px 3px 3px;
  background: var(--beige);
}
.arch img { width: 100%; height: 100%; object-fit: cover; }
/* «Лучик»: мягкая полоса света медленно проходит по фотографии. */
.beam {
  position: absolute; inset: -40% -80%;
  background: linear-gradient(112deg, transparent 42%, rgba(255, 249, 238, 0.42) 50%, transparent 58%);
  animation: beam 9s ease-in-out infinite;
  pointer-events: none;
}
@keyframes beam { 0%, 25% { transform: translateX(-38%); } 75%, 100% { transform: translateX(38%); } }
/* Гибкая арка: занимает всю оставшуюся высоту, ширина - по пропорции 4:5.
   Тонкий контур вокруг - кольцом тени, оно повторяет форму арки. */
.wish-arch, .one-arch { position: relative; flex: 1 1 0; min-height: 64px; }
/* Высота - вся свободная, но не шире 72%: тогда арка прижимается к низу, к панели с текстом. */
.wish-arch .arch, .one-arch .arch {
  position: absolute; bottom: 0; left: 50%;
  height: calc(100% - 10px);
  transform: translateX(-50%);
  max-width: 72%;
  box-shadow: 0 0 0 8px var(--bg), 0 0 0 9px var(--line);
}
.sand .one-arch .arch { box-shadow: 0 0 0 8px var(--sand), 0 0 0 9px var(--line); }

/* ---------- Полосы и волны ---------- */
.wave { flex: none; display: block; width: calc(100% + 2 * var(--pad)); height: 26px; margin: 0 calc(-1 * var(--pad)) -1px; }
.wave.to-sand path { fill: var(--sand); }
.band { margin: 0 calc(-1 * var(--pad)); padding: 4px var(--pad) calc(14px + env(safe-area-inset-bottom)); text-align: center; }
.band.sand { background: var(--sand); }
.band.fill { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.band.bottom { flex: none; }

/* ---------- Выбор настроения: сетка 3 × 2 ---------- */
.moods {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.6vh, 16px) 16px;
  width: 100%;
  /* Чтобы две строки карточек влезли по высоте, сетка сужается на низких экранах. */
  max-width: calc(120vh - 400px); max-width: calc(120dvh - 400px);
  margin-top: clamp(10px, 2.2vh, 22px);
}
.mood {
  display: flex; flex-direction: column; align-items: center;
  min-width: 0; padding: 0 0 2px;
  border: 0; background: none;
  transition: opacity 0.6s var(--ease), transform 0.2s ease;
  animation: rise 0.8s calc(var(--i) * 70ms) both var(--ease);
}
.mood:active { transform: scale(0.97); }
.mood .arch { width: 100%; box-shadow: 0 0 0 4px var(--sand), 0 0 0 5px var(--line); transition: box-shadow 0.4s ease; }
.mood .beam { display: none; }
.mood b { margin-top: clamp(6px, 1.2vh, 11px); font: 500 clamp(17px, 2.5vh, 20px)/1.1 var(--serif); }
.mood small { margin-top: 2px; font: 400 9.5px/1.3 var(--sans); letter-spacing: 0.03em; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* Раскрытие: выбранная арка наполняется светом, остальные тают. */
.is-opening .mood:not(.picked) { opacity: 0.25; }
.is-opening .mood { pointer-events: none; }
.is-opening .mood.picked .arch { box-shadow: 0 0 0 4px var(--sand), 0 0 0 5px var(--accent), 0 0 34px rgba(255, 240, 214, 0.95); }
.is-opening .mood.picked .beam { display: block; animation: beam-open 1.3s var(--ease) forwards; }
.is-opening .mood.picked img { animation: bloom 1.5s var(--ease) forwards; }
@keyframes bloom { to { transform: scale(1.08); filter: brightness(1.15) saturate(0.85); } }
@keyframes beam-open { from { transform: translateX(-40%); } to { transform: translateX(40%); } }

/* Один лучик без вопроса: особая дата или askMood: false, а также пустая копилка. */
.one { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; width: 100%; padding-bottom: calc(18px + env(safe-area-inset-bottom)); text-align: center; }
.band .one { padding-bottom: 0; }
.one-arch { width: 100%; margin-bottom: clamp(14px, 2.6vh, 24px); }
.one .btn { margin-top: clamp(12px, 2.4vh, 22px); }
.one .muted { margin: 6px 0 0; max-width: 280px; font-size: 12.5px; }

/* ---------- Открытый лучик ---------- */
.wish { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.wish-panel {
  flex: none; position: relative; z-index: 1;
  margin-top: -34px; padding: clamp(16px, 2.6vh, 26px) 20px clamp(10px, 1.6vh, 16px);
  background: var(--panel);
  border: 1px solid var(--line);
  text-align: center;
}
.wish-text { margin: clamp(6px, 1.2vh, 12px) 0 0; font: 500 clamp(21px, 3.1vh, 26px)/1.34 var(--serif); text-wrap: pretty; }
.wish-text.mid { font-size: clamp(20px, 2.8vh, 24px); }
.wish-text.long { font-size: clamp(18.5px, 2.5vh, 22px); line-height: 1.3; }
.sign { margin: clamp(2px, 0.8vh, 8px) 0 0; text-align: right; font: 400 clamp(22px, 3.2vh, 27px)/1 var(--script); color: var(--accent); }

.wish.reveal .wish-arch { animation: rise 1s both var(--ease); }
.wish.reveal .wish-panel { animation: rise 1s 0.15s both var(--ease); }
.wish.reveal .wish-text { animation: fade 1.3s 0.45s both; }
.wish.reveal .sign { animation: fade 1s 0.9s both; }
.reveal-late { animation: fade 0.9s 1s both; }
.wish.leaving { animation: leave 0.42s ease forwards; }
.wish.from-right { animation: slide-r 0.45s var(--ease); }
.wish.from-left { animation: slide-l 0.45s var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes leave { to { opacity: 0; transform: translateX(-26px); } }
@keyframes slide-r { from { opacity: 0; transform: translateX(26px); } }
@keyframes slide-l { from { opacity: 0; transform: translateX(-26px); } }
.wish.glow .wish-panel { animation: glow 1.6s ease; }
@keyframes glow { 30% { box-shadow: 0 0 0 4px rgba(191, 133, 119, 0.14), 0 0 44px rgba(255, 238, 214, 0.95); } }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 46px; padding: 0 24px;
  border: 0; border-radius: 2px;
  background: var(--beige); color: var(--text);
  font: 500 10.5px/1 var(--sans); letter-spacing: 0.22em; text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease;
}
.btn:active { background: var(--beige-2); }
.btn.soft { background: var(--panel); border: 1px solid var(--line); }
.btn.soft:active { background: var(--beige); }
.rate-btns { display: flex; gap: 10px; }
.rate-btns .btn { flex: 1; }
.pager .btn { flex: 0 0 52px; padding: 0; }
.pager .btn.wide { flex: 1; }
.btn.like.on { background: var(--beige); border-color: transparent; }
.btn.like.on .ic { color: var(--rose); animation: heart-pop 0.5s ease; }
@keyframes heart-pop { 40% { transform: scale(1.35); } }

/* Вспышка тонких лучиков от «Нравится». */
.burst { position: fixed; width: 0; height: 0; pointer-events: none; z-index: 40; }
.burst i {
  position: absolute; left: -1px; top: -7px;
  width: 2px; height: 14px; border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  animation: ray-out 0.9s var(--ease) forwards;
}
.burst i:nth-child(3n) { background: var(--rose); }
@keyframes ray-out {
  from { opacity: 0; transform: rotate(var(--a)) translateY(-10px) scaleY(0.4); }
  25% { opacity: 0.9; }
  to { opacity: 0; transform: rotate(var(--a)) translateY(calc(-1 * var(--d))) scaleY(1); }
}

/* ---------- Нижняя полоса ---------- */
.next { display: flex; align-items: center; justify-content: center; gap: 8px; margin: clamp(8px, 1.4vh, 12px) 0 0; font: italic 18px/1.3 var(--serif); color: var(--text); }
.next .ic { color: var(--accent); }
.inline-ic { display: inline-block; vertical-align: -3px; color: var(--accent); }
.link {
  margin-top: 4px;
  border: 0; border-bottom: 1px solid var(--line); background: none;
  padding: 4px 0 3px;
  font: 500 9.5px/1.4 var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted);
}

/* ---------- Шторка ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(75, 60, 50, 0.28); animation: fade 0.3s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 480px; max-height: 94vh; max-height: 94dvh; margin: 0 auto; overflow-y: auto;
  padding: clamp(18px, 3vh, 30px) 26px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--bg);
  text-align: center;
  animation: sheet-up 0.5s var(--ease);
}
.sheet-arch { width: 78px; margin: 6px auto 0; }
.sheet-arch .arch { box-shadow: 0 0 0 6px var(--bg), 0 0 0 7px var(--line); }
.sheet h2 { margin: clamp(10px, 2vh, 18px) 0 clamp(8px, 1.4vh, 14px); }
.sheet .eyebrow + h2 { margin-top: 8px; }
.sheet p:not(.eyebrow) { margin: 0 0 clamp(6px, 1.2vh, 10px); font-size: 13.5px; line-height: 1.65; }
.sheet p.sign { margin: 4px 0 14px; text-align: center; font-size: 26px; }
.sheet .btn { width: 100%; margin-top: 6px; }
@keyframes sheet-up { from { transform: translateY(100%); } }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  width: max-content; max-width: calc(100% - 32px);
  padding: 13px 18px; border-radius: 3px;
  background: #5c5048; color: #f6f0ea;
  font: 400 12.5px/1.5 var(--sans); text-align: center;
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.toast button {
  margin-left: 10px; padding: 5px 10px;
  border: 0; border-radius: 2px;
  background: var(--beige); color: var(--text);
  font: 500 9.5px/1.2 var(--sans); letter-spacing: 0.2em; text-transform: uppercase;
}

/* ---------- Первый экран: имена ---------- */
.intro {
  width: 100%; max-width: 340px; margin: auto;
  padding: 16px 0 calc(20px + env(safe-area-inset-bottom));
  text-align: center;
}
.intro-mark { display: block; width: 76px; height: 92px; margin: 0 auto 20px; }
.intro h1 { margin: 6px 0 8px; }
.intro .lead { margin: 0 0 22px; }
.intro form { display: grid; gap: 14px; text-align: left; }
.intro label { display: grid; gap: 6px; font: 500 10px/1.4 var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.intro input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 2px;
  background: var(--panel); color: var(--text);
  font: 400 16px/1 var(--sans); letter-spacing: normal; text-transform: none;
}
.intro input:focus { outline: none; border-color: var(--accent); }
.intro .btn { width: 100%; margin-top: 6px; }
.intro-msg { min-height: 1.5em; margin: 14px 0 0; font: italic 17px/1.4 var(--serif); color: var(--rose); }
.sheet-link { display: block; margin: 14px auto 0; }

/* ---------- Узкие и низкие экраны ---------- */
@media (max-width: 360px) {
  :root { --pad: 16px; }
  .moods { column-gap: 13px; }
  .wish-panel { padding-left: 14px; padding-right: 14px; }
  .btn { padding: 0 12px; letter-spacing: 0.16em; }
}
@media (max-height: 640px) {
  .mood small { display: none; }
  .greet.small h1 { display: none; }
  .sheet-arch { display: none; }
}
/* Высокие экраны: арки настроений чуть вытягиваются, чтобы занять место. */
@media (min-height: 780px) {
  .mood .arch { aspect-ratio: 4 / 5.4; }
}

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