/* T333 Mini App — строгий минимализм (D-053): цвет, контраст и вес шрифта вместо пиктограмм.
   Шрифт — Inter (OFL, self-hosted, webapp/fonts). Сетка 8 px, скругления 12–16 px. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-cyrillic-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
       url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── палитра: нейтральная основа + один акцент + смысловые цвета (AA на своём фоне) ── */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1d1d1f);
  --surface: var(--tg-theme-secondary-bg-color, #f5f5f7); /* подложка панелей — как в самом Telegram */
  --text-2: #5f5f64;      /* 6.3:1 на белом; hint_color темы не берём — у части тем ниже AA */
  --line: #e3e3e8;
  --skeleton: #ececf0;
  --accent: var(--tg-theme-button-color, #0a66d8);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --good: #1a7f37;        /* 5.1:1 */
  --warn: #8a5a00;        /* 5.6:1 */
  --bad: #b42318;         /* 6.2:1 */
  --good-soft: rgba(26, 127, 55, .10);
  --warn-soft: rgba(138, 90, 0, .10);
  --bad-soft: rgba(180, 35, 24, .09);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px;
  --r1: 12px; --r2: 16px;
  --t: 200ms cubic-bezier(.2, .8, .2, 1); /* ease-out */
  --fs-display: 28px; --fs-body: 15px; --fs-small: 13px;
}
:root[data-theme="dark"] {
  --bg: var(--tg-theme-bg-color, #000000);
  --text: var(--tg-theme-text-color, #f5f5f7);
  --surface: var(--tg-theme-secondary-bg-color, #1c1c1e);
  --text-2: #a1a1a6;      /* 7.9:1 на чёрном */
  --line: #2c2c2e;
  --skeleton: #232326;
  --accent: var(--tg-theme-button-color, #3d8bfd);
  --good: #4ac26b;
  --warn: #d6a338;
  --bad: #f2685f;
  --good-soft: rgba(74, 194, 107, .14);
  --warn-soft: rgba(214, 163, 56, .14);
  --bad-soft: rgba(242, 104, 95, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* T391: без «резины» и pull-to-refresh у краёв страницы — в WebView Telegram они тянут за собой
   весь экран; прокрутка внутри ленты остаётся обычной. Высота — стабильная высота окна от SDK. */
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body {
  min-height: var(--tg-viewport-stable-height, 100vh);
  font-family: "Inter", system-ui, sans-serif; /* системный — только пока Inter грузится */
  font-size: var(--fs-body);
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
/* нажатие без задержки двойного тапа и без выделения текста на долгом тапе */
button, .row, .chip, .switch { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.num, .odds, .profit, .money { font-feature-settings: "tnum", "cv11"; font-variant-numeric: tabular-nums; }

/* safe-area: вырезы и «домой»-полоса (env) + отступы Telegram в полноэкранном режиме (Bot API 8.0) */
main {
  max-width: 640px; margin: 0 auto;
  overflow-x: hidden; overflow-x: clip; /* сдвиг экрана при въезде не даёт горизонтальной прокрутки */
  padding-top: calc(var(--s2) + var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
  padding-right: calc(var(--s2) + max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px)));
  padding-bottom: calc(var(--s5) + max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px)));
  padding-left: calc(var(--s2) + max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px)));
}

/* ── экраны: смена без рывков — только transform/opacity (композитор), направление по data-dir ── */
.screen { display: none; }
.screen.is-active { display: block; animation: enter-fwd 240ms cubic-bezier(.2, .8, .2, 1) both; }
main[data-dir="back"] .screen.is-active { animation-name: enter-back; }
@keyframes enter-fwd { from { opacity: 0; transform: translate3d(24px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes enter-back { from { opacity: 0; transform: translate3d(-24px, 0, 0); } to { opacity: 1; transform: none; } }

/* ── типографика: 3 размера ── */
.display { font-size: var(--fs-display); font-weight: 600; letter-spacing: -0.022em; line-height: 1.15; margin: 0; }
.sub { font-size: var(--fs-small); color: var(--text-2); margin: 2px 0 0; }
.label { font-size: var(--fs-small); color: var(--text-2); font-weight: 500; }
h2 { font-size: var(--fs-body); font-weight: 600; margin: var(--s3) 0 var(--s1); letter-spacing: -0.01em; }

.bar { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s2); margin: var(--s1) 0 var(--s2); }

/* ── кнопки: одна главная (заливка), остальные — контур/текст ── */
.btn, .btn-text, .btn-line, .chip, .seg button {
  border: 0; background: none; cursor: pointer; border-radius: var(--r1);
  transition: background-color var(--t), color var(--t), opacity var(--t), transform var(--t);
}
.btn { background: var(--accent); color: var(--accent-text); font-weight: 600; padding: 12px var(--s2); min-height: 44px; }
.btn-text { color: var(--accent); font-weight: 500; padding: var(--s1) 0; min-height: 44px; }
.btn-line { border: 1px solid var(--line); padding: 10px var(--s2); min-height: 44px; font-weight: 500; }
.btn:active, .btn-line:active, .chip:active, .seg button:active, .row:active { transform: scale(.98); }
.btn-line[data-tone="good"] { color: var(--good); }
.btn-line[data-tone="bad"] { color: var(--bad); }
.btn-line[data-tone="warn"] { color: var(--warn); }
.btn-line.is-on[data-tone="good"] { background: var(--good-soft); border-color: transparent; font-weight: 600; }
.btn-line.is-on[data-tone="bad"] { background: var(--bad-soft); border-color: transparent; font-weight: 600; }
.btn-line.is-on[data-tone="warn"] { background: var(--warn-soft); border-color: transparent; font-weight: 600; }

.seg { position: relative; display: flex; gap: 2px; background: var(--surface); padding: 2px; border-radius: var(--r1); margin-bottom: var(--s2); isolation: isolate; }
.seg button { position: relative; z-index: 1; flex: 1 1 0; min-width: 0; padding: 8px var(--s1); border-radius: 10px; color: var(--text-2); font-weight: 500; min-height: 36px; }
.seg button.is-on { background: var(--bg); color: var(--text); font-weight: 600; }
/* бегунок (T391): один слой под кнопками едет transform'ом; ширина = доля одной кнопки (--n кнопок, зазор 2px) */
.seg-thumb {
  position: absolute; z-index: 0; top: 2px; bottom: 2px; left: 2px;
  width: calc((100% - 4px - (var(--n, 2) - 1) * 2px) / var(--n, 2));
  transform: translate3d(calc(var(--i, 0) * (100% + 2px)), 0, 0);
  background: var(--bg); border-radius: 10px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  transition: transform 260ms cubic-bezier(.2, .8, .2, 1);
  opacity: 0;
}
.seg.has-thumb .seg-thumb { opacity: 1; }
.seg.has-thumb button.is-on { background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: var(--s1); }
.chip { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: var(--fs-small); font-weight: 500; min-height: 36px; }
.chip.is-on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.chip.is-off { color: var(--text-2); text-decoration: line-through; }

/* ── лента: тонкие разделители вместо рамок и теней ── */
.list { list-style: none; margin: 0; padding: 0; }
.row { padding: var(--s2) 0; border-top: 1px solid var(--line); cursor: pointer; transition: opacity var(--t), transform var(--t);
       /* длинная лента: строки за экраном не раскладываются и не рисуются */
       content-visibility: auto; contain-intrinsic-size: auto 120px; }
.row:first-child { border-top: 0; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.event { font-weight: 600; letter-spacing: -0.01em; }
.profit { font-weight: 600; color: var(--good); white-space: nowrap; }
.profit.is-neg { color: var(--bad); }
.meta { font-size: var(--fs-small); color: var(--text-2); margin-top: 2px; }
.legs-line { font-size: var(--fs-small); margin-top: 6px; }
.legs-line .odds { font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s1); }
.tag { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--surface); color: var(--text-2); }
.tag[data-tone="accent"] { background: var(--accent-soft); color: var(--accent); }
.tag[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.tag[data-tone="bad"] { background: var(--bad-soft); color: var(--bad); }
.tag[data-tone="good"] { background: var(--good-soft); color: var(--good); }

.note { font-size: var(--fs-small); color: var(--warn); background: var(--warn-soft); padding: 10px 12px; border-radius: var(--r1); margin: 0 0 var(--s2); }
.empty { padding: var(--s5) 0; text-align: left; }
.empty-title { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 var(--s1); }

/* ── скелетон ── */
.skel { display: block; height: 72px; border-radius: var(--r1); background: var(--skeleton); margin: var(--s1) 0 var(--s2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
/* T391: скелетоны повторяют форму содержимого — при подмене на данные высота почти не прыгает */
.skel-row { list-style: none; padding: var(--s2) 0; border-top: 1px solid var(--line); }
.skel-row:first-child { border-top: 0; }
.skel-line { height: 12px; border-radius: 6px; margin: 0 0 10px; }
.skel-line:last-child { margin-bottom: 0; }
.skel-title { height: 30px; width: 80%; border-radius: 8px; margin: 0 0 var(--s2); }
.skel-big { height: 40px; width: 40%; border-radius: 8px; margin: 0 0 var(--s1); }
.skel-block { height: 96px; margin: var(--s2) 0 0; }
.skel-block.tall { height: 220px; }
.skel-card { padding-top: var(--s1); }
/* невидимый образец для прогрева шрифтов (app.js::warmFonts): вне экрана, не влияет на раскладку страницы */
.font-warm { position: absolute; left: -10000px; top: 0; visibility: hidden; contain: layout paint; white-space: nowrap; pointer-events: none; }
.w45 { width: 45%; } .w70 { width: 70%; } .w85 { width: 85%; }

/* ── карточка ── */
.card-head { margin: var(--s1) 0 var(--s3); }
.big-profit { font-size: 40px; font-weight: 600; letter-spacing: -0.03em; color: var(--good); line-height: 1.1; margin: var(--s2) 0 2px; }
.big-profit.is-neg { color: var(--bad); }
.leg { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s2); padding: 12px 0; border-top: 1px solid var(--line); }
.leg:first-of-type { border-top: 0; }
.leg-bk { font-weight: 600; }
.leg-bk a { color: var(--accent); text-decoration: none; }
.leg-label { grid-column: 1; }
.leg .odds { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 20px; font-weight: 600; }
.leg .meta { grid-column: 1 / -1; }
.leg .meta.is-warn { color: var(--warn); }
.checks { margin: 0; padding: 0; list-style: none; }
.checks li { font-size: var(--fs-small); padding: 6px 0; border-top: 1px solid var(--line); color: var(--text-2); }
.checks li:first-child { border-top: 0; }
.checks li[data-tone="good"] { color: var(--good); }
.checks li[data-tone="warn"] { color: var(--warn); }
.checks li[data-tone="bad"] { color: var(--bad); }

.panel { background: var(--surface); border-radius: var(--r2); padding: var(--s2); margin-top: var(--s2); }
.field { display: flex; align-items: center; gap: var(--s1); background: var(--bg); border-radius: var(--r1); padding: 0 var(--s2); margin: var(--s1) 0 var(--s2); }
.field input { flex: 1; border: 0; outline: 0; background: none; font-size: 22px; font-weight: 600; padding: 12px 0; min-width: 0; font-feature-settings: "tnum"; }
.field .unit { color: var(--text-2); font-weight: 500; }
#calc-out { min-height: 132px; transition: opacity var(--t); }  /* место под таблицу заранее — без скачка */
#calc-out.is-stale { opacity: .5; }
.calc-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.calc-table td { padding: 8px 0; border-top: 1px solid var(--line); }
.calc-table tr:first-child td { border-top: 0; }
.calc-table td.r { text-align: right; }
.calc-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: var(--s1); padding-top: var(--s1); border-top: 1px solid var(--line); font-weight: 600; }
.calc-total .money.is-good { color: var(--good); }
.calc-total .money.is-bad { color: var(--bad); }
.calc-warn { color: var(--bad); font-size: var(--fs-small); margin: var(--s1) 0 0; }
.hint { font-size: var(--fs-small); color: var(--text-2); margin: var(--s2) 0 0; }

.verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s1); }
.reasons { margin-top: var(--s1); }

.filter-block { padding: var(--s2) 0; border-top: 1px solid var(--line); }
.filter-block:first-child { border-top: 0; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.switch { position: relative; width: 51px; height: 31px; border-radius: 999px; background: var(--line); border: 0; cursor: pointer; flex: none; transition: background-color var(--t); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform var(--t); }
.switch[aria-checked="true"] { background: var(--good); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .4; cursor: default; }

.toast { position: fixed; left: 50%; bottom: calc(var(--s3) + max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px))); transform: translate(-50%, 8px); opacity: 0; background: var(--text); color: var(--bg); padding: 10px var(--s2); border-radius: var(--r1); font-size: var(--fs-small); font-weight: 500; transition: opacity var(--t), transform var(--t); pointer-events: none; max-width: calc(100% - 32px); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .screen.is-active, main[data-dir="back"] .screen.is-active { animation: none; }
  .skel { animation: none; opacity: .8; }
}
