/* Ночная тема мини-приложения.

   Приложение заменяет бота, поэтому экраны должны выдерживать длинный текст
   разбора и при этом не превращаться в простыню: отсюда стеклянные карточки,
   крупные заголовки и единственный акцентный цвет — золото.

   Фон один на всё приложение и прибит к окну: при прокрутке он не едет, и
   длинный разбор читается как лист, положенный на ночной стол. */

:root {
  --ink: #080d1f;
  --ink-soft: #101839;
  --gold: #e0b276;
  --gold-dim: rgba(224, 178, 118, 0.42);
  --text: #eeecf6;
  --muted: rgba(238, 236, 246, 0.6);
  --faint: rgba(238, 236, 246, 0.34);
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.085);
  --line: rgba(224, 178, 118, 0.2);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --bar: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Manrope", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

/* Фон отдельным слоем: так его можно притушить, не трогая прозрачность текста */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("assets/bg-night.webp") center / cover no-repeat;
  opacity: 0.85;
  z-index: -2;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(120% 70% at 50% 0%, transparent 35%, rgba(4, 7, 18, 0.85) 100%);
  z-index: -1;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--sat) + 10px) 16px calc(var(--bar) + var(--sab) + 18px);
}

/* --- шапка --- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 16px;
}

.topbar img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.topbar h1 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.2px;
}

.topbar p {
  margin: 0;
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --- экраны --- */

.screen {
  display: none;
  animation: rise 0.26s ease both;
}

.screen.on {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

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

.screen > h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 27px;
  margin: 2px 0 4px;
}

.screen > .lead {
  margin: 0 0 18px;
  color: var(--muted);
}

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

.card {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card h3 {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 6px;
}

.card p {
  margin: 0;
  color: var(--muted);
}

.card.tap {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.card.tap:active {
  transform: scale(0.985);
  background: var(--glass-strong);
}

.hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.hero img {
  display: block;
  width: 100%;
  height: 128px;
  object-fit: cover;
}

.hero .over {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 16px;
  background: linear-gradient(transparent, rgba(6, 10, 24, 0.9));
  font-family: var(--serif);
  font-size: 21px;
}

/* Карта крупно: на экране дня она главное, а не подпись под ней.
   Перевёрнутую показываем перевёрнутой — иначе слово в заголовке
   расходится с картинкой. */

.shot {
  /* Во всю ширину карта вытесняет текст за экран: разбор важнее картинки */
  max-width: 248px;
  margin: 0 auto 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.shot img {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 8;
  object-fit: cover;
}

.shot.upside img {
  transform: rotate(180deg);
}

/* --- строки данных --- */

.rows {
  display: grid;
  gap: 1px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: rgba(10, 15, 33, 0.72);
}

.row span:first-child {
  color: var(--muted);
}

.row b {
  font-weight: 600;
  text-align: right;
}

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

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: 600 15px/1 var(--sans);
  color: #1b1304;
  background: linear-gradient(180deg, #edc389, var(--gold));
  cursor: pointer;
}

.btn:active {
  transform: scale(0.99);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--gold);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  margin: 0 8px 8px 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
}

.chip.on {
  background: var(--gold);
  border-color: var(--gold);
  color: #1b1304;
}

/* --- служебные состояния --- */

.empty {
  text-align: center;
  padding: 10px 0 24px;
}

.empty img {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius);
  opacity: 0.9;
}

.empty p {
  color: var(--muted);
  margin: 14px 0 0;
}

.skeleton {
  height: 62px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: linear-gradient(100deg, var(--glass) 30%, var(--glass-strong) 50%, var(--glass) 70%);
  background-size: 220% 100%;
  animation: shine 1.4s linear infinite;
}

@keyframes shine {
  to {
    background-position: -120% 0;
  }
}

.note {
  color: var(--faint);
  font-size: 13px;
  margin: 10px 2px 0;
}

/* --- расклад --- */

.field {
  width: 100%;
  min-height: 96px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 13, 31, 0.6);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  resize: none;
}

.field:focus {
  outline: none;
  border-color: var(--gold);
}

.field.one-line {
  min-height: 52px;
  text-align: center;
  font-size: 22px;
  font-family: var(--serif);
  letter-spacing: 0.1em;
}

/* Данные рождения набирают, а не любуются ими: засечки тут мешают */
.field.plain {
  font-family: var(--sans);
  font-size: 17px;
  letter-spacing: 0;
}

label.note {
  display: block;
  margin: 2px 2px 6px;
}

.deal {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

/* Десять карт кельтского креста в три колонки читаются лучше,
   чем в ряд по две: ряд растягивает расклад на три экрана */
.deal.wide {
  grid-template-columns: repeat(3, 1fr);
}

.slot {
  text-align: center;
}

.slot img {
  width: 100%;
  aspect-ratio: 5 / 8;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  animation: lay 0.5s ease both;
}

.slot.rev img {
  transform: rotate(180deg);
}

.slot b {
  display: block;
  margin-top: 6px;
  font: 600 11px/1.3 var(--sans);
}

.slot span {
  display: block;
  font-size: 10px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

@keyframes lay {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
}

.reading {
  font-size: 15px;
  line-height: 1.62;
  /* Разбор собран для Telegram: абзацы в нём переводами строки, а не тегами.
     Без этого весь текст слипается в одну простыню. */
  white-space: pre-line;
}

.reading b,
.reading strong {
  color: var(--gold);
  font-weight: 600;
}

.reading i,
.reading em {
  color: var(--muted);
}

.waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.waiting::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid var(--gold-dim);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--gold);
  font: 500 14px/1 var(--sans);
  cursor: pointer;
}

.back-link svg {
  width: 16px;
  height: 16px;
}

/* --- нижняя панель --- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: space-around;
  padding: 6px 6px calc(var(--sab) + 6px);
  background: rgba(6, 10, 24, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  background: none;
  color: var(--faint);
  font: 500 10px/1.2 var(--sans);
  cursor: pointer;
}

.tab svg {
  width: 23px;
  height: 23px;
}

.tab.on {
  color: var(--gold);
}
