/* app.css - оформление приложения «Домики» по _docs/design-system.md (источник - макет МАКЕТЫ/2_oblik.html).
   Правила: без функции смешивания цветов; высота экрана 100vh, следом 100dvh; цвета - переменными. */

@font-face {
  font-family: 'Onest'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('../fonts/onest-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Onest'; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url('../fonts/onest-latin.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;
}
@font-face {
  font-family: 'Playfair Display'; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url('../fonts/playfair-display-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Playfair Display'; font-style: normal; font-weight: 400 900; font-display: swap;
  src: url('../fonts/playfair-display-latin.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;
}

/* ---------- цвета: светлая схема по умолчанию, тёмная - класс dark на body ---------- */
:root {
  --err: #B3261E;
  --bad-bg: #FBE3E1; --bad-tx: #5C1410; --pre-tx: #7A5A00; --ok-tx: #14502F;
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --text: #14171C;
  --text2: #454B58;
  --edge: #4B5160;
  --btn: #14171C;
  --btn-text: #FFFFFF;
  --btn-press: #2C3139;
  --acc-top: #BD5800; --acc-bot: #A24B00; --acc-press: #8F4300; --acc-text: #FFFFFF;
  --acc-shadow: 0 2px 6px rgba(120, 60, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  --upd-top: #FFC83D; --upd-bot: #F7B52C; --upd-text: #2B1700; --upd-btn: #3A2100; --upd-btn-press: #1F1100; --upd-btn-text: #FFFFFF;
  --upd-line: rgba(120, 70, 0, 0.35); --upd-x-press: rgba(43, 23, 0, 0.14);
  --line: #DAD5C9;
  --cell: #F7F5F0;
  --cell-wk: #EFECE3;
  --cell-hover: #ECE8DD;
  --today-bg: #E3EAF6;
  --press: #ECE8DD;
  --press2: #F2EFE7;
  --wk-text: #8B3A3A;
  --ctl: rgba(255, 255, 255, 0.92);
  --sub-bg: rgba(247, 245, 240, 0.86);
  --pre-gap: rgba(255, 255, 255, 0.95); --pre-chip: rgba(255, 255, 255, 0.9);
  --scroll-thumb: rgba(20, 23, 28, 0.22);
  --g-back: drop-shadow(0 2px 3px rgba(60, 45, 15, 0.22));
  --g-front: none;
  --head-serif: 'Playfair Display', Georgia, "Times New Roman", serif;
  /* шапка (решение владельца 02.10: вариант «40 %») */
  --safe-top: env(safe-area-inset-top, 0px);
  --hero-h: 62px; --hw-fs: 27px; --hw-lh: 30px; --hw-top: 10px; --hw-left: 12px; --hw-ls: 0.06em; --hw-fw: 700;
  --sub-fs: 11px; --sub-lh: 14px; --sub-top: 41px;
  --gl-w: 160px; --gl-h: 52px; --gl-l: 14px; --gl-t: 9px; --gear-top: 12px; --gear-ic: 20px; --gear-box: 32px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}
body.dark {
  --err: #FF8A80;
  --bad-bg: #3A1E1D; --bad-tx: #FFD9D5; --pre-tx: #E6C264; --ok-tx: #7FD6A0;
  --bg: #121418; --surface: #1C1F26; --text: #F2F3F5; --text2: #A9AFBC; --edge: #ECEDF1; --btn: #ECEDF1; --btn-text: #121418; --btn-press: #C9CBD2;
  --acc-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  --line: #343946; --cell: #232730; --cell-wk: #1A1D24; --cell-hover: #2D323D; --today-bg: #263045;
  --press: #2A2F3A; --press2: #242933; --wk-text: #E59A9A; --ctl: rgba(28, 31, 38, 0.92); --sub-bg: rgba(18, 20, 24, 0.7); --pre-gap: rgba(28, 31, 38, 0.95); --pre-chip: rgba(28, 31, 38, 0.92);
  --scroll-thumb: rgba(255, 255, 255, 0.24); --g-back: brightness(1.45) saturate(1.15); --g-front: brightness(1.45) saturate(1.15);
}

/* ---------- основа ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); color-scheme: light;
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body.dark { color-scheme: dark; }
button {
  font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0;
  cursor: pointer; -webkit-appearance: none; appearance: none; text-align: inherit;
}
button:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }

/* ---------- каркас экрана: колонка до 1040 px по центру (ПК) ---------- */
.app {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 1040px; margin: 0 auto;
  min-height: 100vh; min-height: 100dvh; background: var(--bg);
}

/* ---------- шапка ---------- */
.hero { position: relative; flex: none; height: calc(var(--hero-h) + var(--safe-top)); overflow: hidden; }
.garland { position: absolute; z-index: 1; left: var(--gl-l); top: calc(var(--gl-t) + var(--safe-top)); width: var(--gl-w); height: var(--gl-h); max-width: none; pointer-events: none; filter: var(--g-back); }
/* передняя копия: только концы венка (по краям), остальное прозрачно - рисунок «проходит сквозь буквы» */
.garland.front { display: none; z-index: 3; filter: var(--g-front); }
@supports ((-webkit-mask-image: linear-gradient(#000, #000)) or (mask-image: linear-gradient(#000, #000))) {
  .garland.front {
    display: block;
    -webkit-mask-image: linear-gradient(to right, #000 0%, #000 14%, transparent 26%, transparent 74%, #000 86%, #000 100%);
    mask-image: linear-gradient(to right, #000 0%, #000 14%, transparent 26%, transparent 74%, #000 86%, #000 100%);
  }
}
.hero h1 {
  position: absolute; z-index: 2; left: var(--hw-left); top: calc(var(--hw-top) + var(--safe-top)); margin: 0; font-family: var(--head-serif); font-weight: var(--hw-fw);
  font-size: var(--hw-fs); line-height: var(--hw-lh); letter-spacing: var(--hw-ls); color: var(--text);
}
.hero h1 span { display: inline-block; }
.sub { position: absolute; z-index: 4; left: calc(var(--hw-left) - 2px); top: calc(var(--sub-top) + var(--safe-top)); display: flex; align-items: center; font-size: var(--sub-fs); line-height: var(--sub-lh); color: var(--text2); }
.sub span { padding: 0 5px; border-radius: 6px; background: var(--sub-bg); }
.tools { position: absolute; z-index: 4; right: 2px; top: calc(var(--gear-top) + var(--safe-top)); display: flex; align-items: center; }
/* шестерёнка: на вид маленькая, зона касания остаётся 44 x 44 */
.gear { position: relative; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.gear::before { content: ''; position: absolute; left: 50%; top: 50%; width: var(--gear-box); height: var(--gear-box); margin: calc(var(--gear-box) / -2) 0 0 calc(var(--gear-box) / -2); border-radius: 9px; background: var(--ctl); border: 1px solid var(--line); }
.gear svg { position: relative; width: var(--gear-ic); height: var(--gear-ic); }
.gear:active::before { background: var(--press); }
body.dark .sub { color: var(--text); text-shadow: 0 0 5px #000, 0 1px 2px #000; }
body.dark .hero h1 { text-shadow: 0 0 6px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.7); }

/* появление шапки при открытии - 3 секунды (решение владельца 02.10): сначала по одной всплывают буквы, затем венок наплывает на слово,
   под конец проявляется дата. Анимируется только шапка (transform и opacity); экран, шестерёнка, кнопки и полоска обновления доступны сразу */
.anim .hero h1 span { opacity: 0; transform: translateY(12px); animation: rise 900ms var(--ease-out) forwards; }
.anim .hero .sub { opacity: 0; animation: fadein 900ms ease-out 1900ms forwards; }
.anim .garland { opacity: 0; transform: translateX(-16px); animation: drift 1800ms var(--ease-out) 1200ms forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes drift { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- первый экран (домиков ещё нет) ---------- */
.empty { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 28px 48px; text-align: center; }
.empty .em-ic { width: 208px; height: 208px; border-radius: 50%; background: var(--cell-wk); display: flex; align-items: center; justify-content: center; }
.empty .em-ic img { display: block; width: 168px; height: 168px; object-fit: contain; }
.empty .em-t { margin: 22px 0 0; max-width: 300px; font-size: 19px; line-height: 27px; font-weight: 600; }

/* ---------- наведение мышью (только мышь) ---------- */
@media (hover: hover) and (pointer: fine) {
  .gear:hover::before { background: var(--press); }
}

@media (prefers-reduced-motion: reduce) {
  .anim .hero h1 span, .anim .hero .sub, .anim .garland { animation: none; opacity: 1; transform: none; }
}

/* ---------- экран настроек: выезжает справа, внутри колонки до 1040 px; полоса прокрутки не лежит на содержимом ---------- */
.hscreen {
  position: fixed; top: 0; bottom: 0; left: 0; right: 0; z-index: 15; width: 100%; max-width: 1040px; margin: 0 auto;
  background: var(--bg); overflow-y: auto; visibility: hidden; transform: translateX(100%);
  transition: transform 240ms var(--ease-drawer), visibility 0s linear 240ms;
}
.hscreen.open { visibility: visible; transform: translateX(0); transition-delay: 0s; }
.hs-in { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(20px + var(--kb, 0px)); }   /* --kb - высота экранной клавиатуры над нижним краем страницы (ui.js) */
.hs-back { display: inline-flex; align-items: center; height: 44px; padding: 0 12px 0 4px; margin-left: -4px; font-size: 16px; font-weight: 700; border-radius: 10px; }
.hs-back:active { background: var(--press); }
.set-title { margin: 4px 0 6px; font-family: var(--head-serif); font-weight: 800; font-size: 30px; line-height: 36px; }
.set-sec { margin-top: 20px; }
.set-h { margin: 0 0 8px 4px; font-size: 13px; line-height: 18px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.4px; }
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.seg { display: flex; padding: 4px; border-radius: 14px; background: var(--cell-wk); }
.seg button { flex: 1; height: 52px; border-radius: 11px; font-size: 17px; font-weight: 700; text-align: center; color: var(--text2); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20, 23, 28, 0.18); }
.set-ver { margin: 22px 0 6px; text-align: center; font-size: 14px; line-height: 20px; color: var(--text2); }

/* тонкие неброские полосы прокрутки с отступом 2 px от края (раздел 14 design-system) */
@supports not selector(::-webkit-scrollbar) { .hscreen { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; } }
.hscreen::-webkit-scrollbar { width: 8px; height: 8px; }
.hscreen::-webkit-scrollbar-thumb { background: var(--scroll-thumb); background-clip: padding-box; border: 0 solid transparent; }
.hscreen::-webkit-scrollbar-thumb:vertical { border-right-width: 2px; border-radius: 3px 5px 5px 3px; }
.hscreen::-webkit-scrollbar-thumb:horizontal { border-bottom-width: 2px; border-radius: 3px 3px 5px 5px; }
.hscreen::-webkit-scrollbar-track, .hscreen::-webkit-scrollbar-corner { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .hscreen, .hscreen.open { transition: none; }
}

/* ---------- полоска «Доступна новая версия»: под шапкой, сдвигает содержимое вниз, не лежит поверх (design-system 14а) ---------- */
.upd { position: relative; z-index: 6; flex: none; display: flex; align-items: center; height: 40px; padding: 0 2px 0 14px; color: var(--upd-text);
  background: linear-gradient(to bottom, var(--upd-top), var(--upd-bot)); border-bottom: 1px solid var(--upd-line); animation: updin 320ms var(--ease-out) both; }
.upd .t { flex: 1; min-width: 0; font-size: 14px; line-height: 18px; font-weight: 600; }
.upd .ub { position: relative; flex: none; height: 30px; padding: 0 14px; border-radius: 9px; background: var(--upd-btn); color: var(--upd-btn-text); font-size: 14px; font-weight: 700; }
.upd .ub::after { content: ''; position: absolute; top: -7px; bottom: -7px; left: -4px; right: -4px; }
.upd .ub:active { background: var(--upd-btn-press); }
.upd .ux { flex: none; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: -2px 0; border-radius: 10px; }
.upd .ux:active { background: var(--upd-x-press); }
@keyframes updin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .upd { animation: none; }
}

/* ---------- установка на экран: кнопка (второстепенная) и подсказка для iPhone (design-system 7а) ---------- */
.inst { display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border: 1px solid var(--edge); border-radius: 12px; background: var(--surface); font-size: 17px; font-weight: 700; text-align: center; }
.inst svg { flex: none; margin-right: 8px; }
.inst:active { background: var(--press2); }
.ios-hint { margin: 0; font-size: 15px; line-height: 21px; color: var(--text2); text-align: center; }
.empty #inst-slot { width: 100%; max-width: 320px; }
.empty .inst { margin-top: 20px; }
.empty .ios-hint { margin: 20px auto 0; max-width: 300px; }
.inst-box { padding: 12px; }
.inst-box p { margin: 6px 2px 0; font-size: 13px; line-height: 17px; color: var(--text2); text-align: center; }
.inst-box p.ios-hint { margin: 0; font-size: 15px; line-height: 21px; }
@media (hover: hover) and (pointer: fine) {
  .inst:hover { background: var(--press2); }
}

/* ---------- цвета домиков: --c основной (одинаковы в обеих схемах) ---------- */
.h1 { --c: 156, 95, 16; }
.h2 { --c: 42, 99, 154; }
.h3 { --c: 160, 64, 104; }
.h4 { --c: 43, 111, 75; }
.h5 { --c: 31, 111, 120; }
.h6 { --c: 91, 74, 143; }
.h7 { --c: 164, 69, 44; }
.h8 { --c: 107, 112, 32; }
.h9 { --c: 170, 34, 50; }
.h10 { --c: 84, 98, 114; }
.h11 { --c: 122, 86, 58; }
.h12 { --c: 62, 80, 160; }

/* ---------- область под шапкой ---------- */
.main-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.empty .em-s { margin: 10px 0 0; max-width: 300px; font-size: 14px; line-height: 20px; color: var(--text2); }
.empty .main { width: 100%; max-width: 320px; margin: 24px 0 0; }
.nostore { flex: none; padding: 10px 14px; background: #FFD54A; color: #1F1A00; font-size: 14px; line-height: 19px; font-weight: 600; }
.hint { flex: none; margin: 8px 14px 0; padding: 10px 12px; border-radius: 12px; background: var(--today-bg); color: var(--text); font-size: 14px; line-height: 19px; font-weight: 600; }
.app.has-board { height: 100vh; height: 100dvh; }
