/* Общие стили карточки: приложение (index.html) и виджет (embed.html).
   Вёрстка mobile-first: базовые правила — под телефон,
   медиазапрос min-width:480px возвращает десктопную плитку 320px. */

:root {
  --card-width: 100%;
  --card-max: 360px;
  --text-size: 17px;
  --passport-size: 12px;
  --gutter: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: Ubuntu, sans-serif;
  background: #f0f0f0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding:
    calc(var(--gutter) + env(safe-area-inset-top, 0px))
    calc(var(--gutter) + env(safe-area-inset-right, 0px))
    calc(var(--gutter) + env(safe-area-inset-bottom, 0px))
    calc(var(--gutter) + env(safe-area-inset-left, 0px));
  color: rgb(34, 34, 34);
  -webkit-tap-highlight-color: transparent;
}

/* ── Card ── */
#app {
  width: var(--card-width);
  max-width: var(--card-max);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.13);
  overflow: hidden;
  opacity: 0;
  animation: fadeInUp 0.5s ease-out forwards;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card header ── */
.card-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #e8e8e8;
}

.card-header img {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.card-header h1 {
  font-size: 14px;
  font-weight: 700;
  color: rgb(34, 34, 34);
  line-height: 1.2;
}

/* ── Chastushka text ── */
#content-wrapper {
  padding: 18px 14px 14px;
  position: relative;
}

#chastushka-text {
  font-size: var(--text-size);
  font-weight: 400;
  line-height: 1.6;
  color: rgb(34, 34, 34);
  white-space: pre-line;
  overflow-wrap: break-word;
  text-align: center;
  position: relative;
}

/* ── Divider ── */
.card-divider {
  border: none;
  border-top: 1px solid #e8e8e8;
  margin: 14px 0 10px;
}

/* ── Button ── */
#next-btn {
  display: block;
  width: var(--card-width);
  max-width: var(--card-max);
  min-height: 44px;
  margin: 14px auto 0;
  padding: 11px 20px;
  font-family: Ubuntu, sans-serif;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: #2b7cb8;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s ease;
  opacity: 0;
  animation: fadeInUp 0.5s ease-out 0.15s forwards;
}

#next-btn:hover  { background: #1f6399; }
#next-btn:active { background: #185280; }

/* ── Transition ── */
.content-transition {
  animation: contentFade 0.35s ease-out;
}

@keyframes contentFade {
  0%   { opacity: 1; }
  40%  { opacity: 0; }
  100% { opacity: 1; }
}

/* Узкие телефоны: отступы и кегль поменьше */
@media (max-width: 359px) {
  :root {
    --gutter: 12px;
    --text-size: 16px;
  }
}

/* Планшет и десктоп: прежняя плитка 320px, кнопка по контенту */
@media (min-width: 480px) {
  :root {
    --card-max: 320px;
    --text-size: 15px;
    --passport-size: 11px;
    --gutter: 32px;
  }

  #content-wrapper { padding: 16px 12px 12px; }
  #chastushka-text { padding: 0 8px; }

  #next-btn {
    width: auto;
    min-height: 0;
    padding: 7px 20px;
    font-size: 13px;
  }
}

/* Телефон лёжа: карточка не должна упираться в края */
@media (max-height: 480px) and (orientation: landscape) {
  body { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  #app, #next-btn, .content-transition {
    animation: none;
    opacity: 1;
  }
}
