/* CG Agency mini app — палитра и типографика сайта cgagency.ge.
   Тема Telegram намеренно не наследуется: витрина недвижимости продаёт
   настроением, а подстройка под тёмную схему клиента ломает подачу фото
   и делает приложение неотличимым от любого другого бота. */

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

:root {
  --bg:        #f1ebe1;   /* фон — слоновая кость */
  --surface:   #fcf8f1;   /* карточки */
  --raised:    #e6dccb;   /* приподнятые плашки */
  --wine:      #5c1f24;   /* акцентная заливка */
  --wine-ink:  #6b2129;   /* акцентный текст, 9.4:1 на фоне */
  --wine-hi:   #7a2a31;   /* наведение */
  --gold:      rgba(154,124,70,.28);  /* волосяные линии */
  --ink:       #241f1d;   /* основной текст */
  --muted:     #5a4a44;   /* вторичный, 7.1:1 */
  --head:      #1a1513;   /* заголовки */
  --on-wine:   #f6f1e7;   /* текст на бордовом, 11.1:1 */
  --serif:     'DM Serif Display', Georgia, serif;
  --sans:      'Inter', -apple-system, system-ui, sans-serif;
  --ease:      cubic-bezier(.16,1,.3,1);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(2rem + var(--safe-bottom));
  overscroll-behavior-y: none;
}

/* ── Шапка ── */
.top {
  position: sticky; top: 0; z-index: 40;
  padding: calc(.7rem + var(--safe-top)) 1rem .6rem;
  background: rgba(252,248,241,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.mark { width: 26px; height: 26px; color: var(--wine-ink); flex: 0 0 26px; }
.wordmark { font-family: var(--serif); font-size: 1.15rem; letter-spacing: .1em; color: var(--head); }

.tabs { display: flex; gap: .3rem; background: var(--raised); padding: .25rem; border-radius: 2px; }
.tab {
  flex: 1; border: 0; background: none; cursor: pointer;
  font: 500 .74rem/1 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: .65rem .4rem; border-radius: 1px;
  transition: background .25s, color .25s;
}
.tab.active { background: var(--wine); color: var(--on-wine); }

/* ── Фильтры ── */
.filters { padding: .8rem 1rem .2rem; }
.deal-switch { display: flex; gap: .4rem; margin-bottom: .7rem; }
.deal {
  flex: 1; cursor: pointer; padding: .55rem;
  font: 500 .72rem/1 var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--wine-ink); background: none;
  border: 1px solid var(--gold); transition: background .25s, color .25s;
}
.deal.active { background: var(--wine); color: var(--on-wine); border-color: var(--wine); }

.city-row {
  display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.city-row::-webkit-scrollbar { display: none; }
.city {
  flex: 0 0 auto; cursor: pointer; white-space: nowrap;
  padding: .45rem .8rem; font-size: .78rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--gold);
  transition: color .25s, border-color .25s, background .25s;
}
.city.active { background: var(--wine); color: var(--on-wine); border-color: var(--wine); }
.city .n { opacity: .55; font-size: .7rem; margin-left: .3rem; }

.more-filters {
  width: 100%; cursor: pointer; background: none; border: 0;
  border-top: 1px solid var(--gold); margin-top: .2rem; padding: .7rem 0 .5rem;
  font: 500 .7rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  color: var(--wine-ink); display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.badge {
  background: var(--wine); color: var(--on-wine);
  font-size: .62rem; padding: .1rem .4rem; border-radius: 999px;
}

.summary-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .8rem; padding: .6rem 1rem .2rem;
}
.summary { font-size: .76rem; color: var(--muted); }
.summary b { color: var(--wine-ink); font-weight: 600; }
.sort select {
  font: 400 .74rem var(--sans); color: var(--wine-ink);
  background: none; border: 0; border-bottom: 1px solid var(--gold);
  padding: .15rem 0; cursor: pointer;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Лента ── */
.feed { display: flex; flex-direction: column; gap: .9rem; padding: .7rem 1rem 0; }

.card {
  background: var(--surface); border: 1px solid var(--gold);
  cursor: pointer; overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s;
}
.card:active { transform: scale(.985); }
.card-media { position: relative; aspect-ratio: 4 / 3; background: var(--raised); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-price {
  position: absolute; right: .6rem; top: .6rem;
  background: var(--wine); color: var(--on-wine);
  font-family: var(--serif); font-size: 1.05rem; padding: .3rem .7rem;
}
.card-tag {
  position: absolute; left: .6rem; top: .6rem;
  background: rgba(36,31,29,.72); color: var(--on-wine);
  font-size: .58rem; letter-spacing: .14em; text-transform: uppercase;
  padding: .3rem .55rem;
}
.card-body { padding: .8rem .9rem 1rem; }
.card-title { font-family: var(--serif); font-size: 1.12rem; color: var(--head); line-height: 1.25; }
.card-sub { font-size: .74rem; color: var(--muted); margin-top: .25rem; }
.card-facts { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .7rem; }
.fact {
  font-size: .68rem; color: var(--muted);
  border: 1px solid var(--gold); padding: .22rem .5rem;
}
.card-src { margin-top: .6rem; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); opacity: .8; }

.empty { padding: 3rem 1rem; text-align: center; color: var(--muted); font-size: .85rem; }
.empty b { display: block; font-family: var(--serif); font-size: 1.2rem; color: var(--head); margin-bottom: .4rem; }

.loader { padding: 1.4rem; text-align: center; color: var(--muted); font-size: .8rem; }
.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: .4rem;
  border: 1.5px solid var(--gold); border-top-color: var(--wine);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.load-more {
  display: block; margin: 1.2rem auto 0; cursor: pointer;
  background: none; border: 1px solid var(--gold); color: var(--wine-ink);
  font: 500 .7rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
  padding: .9rem 2rem;
}

/* ── Шторки ── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(36,31,29,.5); backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-top: 1px solid var(--gold);
  padding: .5rem 1.1rem calc(1.4rem + var(--safe-bottom));
  animation: rise .32s var(--ease);
}
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 38px; height: 3px; background: var(--gold); border-radius: 2px; margin: .35rem auto 1rem; }
.sheet-title { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; color: var(--head); margin-bottom: 1.2rem; }

.field { display: block; margin-bottom: 1.3rem; }
.field-label {
  display: block; font-size: .62rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--wine-ink); margin-bottom: .55rem;
}
.range-pair { display: flex; gap: .6rem; }
.range-pair input, .sheet input[type="number"] {
  width: 100%; font: 400 .95rem var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--gold); padding: .7rem .8rem;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--wine-ink); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips.scroll { max-height: 8.5rem; overflow-y: auto; }
.chip {
  cursor: pointer; padding: .45rem .75rem; font-size: .76rem;
  color: var(--muted); background: var(--surface); border: 1px solid var(--gold);
}
.chip.active { background: var(--wine); color: var(--on-wine); border-color: var(--wine); }

.switch-row { display: flex; align-items: center; gap: .6rem; font-size: .85rem; margin-bottom: 1.5rem; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--wine); }

.sheet-actions { display: flex; gap: .6rem; }
.btn-wine, .btn-ghost {
  flex: 1; cursor: pointer; padding: .95rem;
  font: 500 .72rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
}
.btn-wine { background: var(--wine); color: var(--on-wine); border: 1px solid var(--wine); }
.btn-wine:active { background: var(--wine-hi); }
.btn-ghost { background: none; color: var(--wine-ink); border: 1px solid var(--gold); }

/* ── Карточка объекта ── */
.detail-media { margin: -.5rem -1.1rem 1rem; aspect-ratio: 4 / 3; background: var(--raised); }
.detail-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-price { font-family: var(--serif); font-size: 2rem; color: var(--wine-ink); line-height: 1; }
.detail-title { font-family: var(--serif); font-size: 1.35rem; color: var(--head); margin: .5rem 0 .2rem; line-height: 1.25; }
.detail-sub { font-size: .8rem; color: var(--muted); margin-bottom: 1.1rem; }
.detail-specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--gold); border: 1px solid var(--gold); margin-bottom: 1.2rem;
}
.spec { background: var(--surface); padding: .8rem .9rem; }
.spec-k { font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.spec-v { font-family: var(--serif); font-size: 1.1rem; color: var(--head); margin-top: .2rem; }
.detail-note {
  font-size: .72rem; line-height: 1.65; color: var(--muted);
  border-top: 1px solid var(--gold); padding-top: .9rem; margin-top: 1.1rem;
}
.detail-actions { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.2rem; }
.detail-actions a, .detail-actions button {
  display: block; width: 100%; text-align: center; text-decoration: none; cursor: pointer;
  padding: .95rem; font: 500 .72rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
}
.act-primary { background: var(--wine); color: var(--on-wine); border: 1px solid var(--wine); }
.act-second { background: none; color: var(--wine-ink); border: 1px solid var(--gold); }

@media (min-width: 620px) {
  .feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .sheet { left: 50%; transform: translateX(-50%); max-width: 560px; }
}
