/* iPad (Safari и «На экран Домой») и Mac: крупные цели под палец, без двойных тапов и зависаний на hover, безопасные поля, широкие сетки.
   Подключается после style.css; ничего не меняет на мыши, кроме широких экранов. */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overscroll-behavior-y: none; -webkit-touch-callout: none; min-height: 100vh; min-height: 100dvh; }
:root { --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }

/* без задержки и увеличения по двойному тапу, без серой подсветки */
a, button, .btn, [data-act], [data-go], [data-x], [data-page], label, summary, select, input, textarea, tr[data-go], .car, .tile { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button, .btn, [data-act], [data-go] { -webkit-user-select: none; user-select: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }

/* поля не меньше 16 px: иначе Safari на iPad приближает страницу при фокусе */
input, select, textarea { font-size: max(16px, 1em); }

/* ПЛАНШЕТ И ТЕЛЕФОН: крупные элементы под палец (по типу указателя, не по ширине: мышь на Mac остаётся компактной) */
@media (pointer: coarse), (hover: none) {
  .btn, button, .tab, .filters button, .seg button, select, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), .input { min-height: 44px; }
  .btn-sm { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; }
  .nav a, .nav .nav-item, .tabbar a, .tabbar button, .fly a { min-height: 48px; }
  .tabbar { padding-bottom: calc(var(--safe-b) + 4px); }
  table.table td, table.table th { padding-top: 13px; padding-bottom: 13px; }
  tr[data-go], .car, .owner-link, .contact, .hist { min-height: 52px; }
  .modal { padding-bottom: calc(18px + var(--safe-b)); max-height: calc(100dvh - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .toasts { bottom: calc(76px + var(--safe-b)); }
  /* hover-подсказки и выезжающие меню не должны «залипать» на touch: показываем по клику (это делает приложение), а hover не нужен */
  .nav-group:hover > .fly, .nav-fly:hover { display: none; }
  .nav-group.open > .fly, .nav-fly.open { display: block; }
  ::-webkit-scrollbar { display: none; }
}

/* iPad в портрете и узкие окна Mac: таблицы листаются, а не ломают страницу */
@media (max-width: 1100px) {
  .view { padding-left: max(14px, var(--safe-l)); padding-right: max(14px, var(--safe-r)); }
  table.table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .toolbar { flex-wrap: wrap; }
  .modal { width: min(96vw, 720px); }
}

/* iPad в ландшафте и маленький Mac: двухколоночные карточки не схлопываются слишком рано */
@media (min-width: 1000px) and (max-width: 1400px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* большой Mac / внешний монитор: шире содержимое, больше колонок, плотные таблицы */
@media (min-width: 1500px) {
  .view { max-width: 1680px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (min-width: 1900px) { .view { max-width: 1960px; } }

/* режим «На экран Домой» (без панели Safari) */
@media (display-mode: standalone) {
  body { padding-top: var(--safe-t); }
  .topbar { padding-top: calc(var(--safe-t) * 0.2); }
}

/* уважаем «уменьшить движение» и не нагружаем iPad лишней анимацией */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* камера: предпросмотр снимка не вылезает за экран */
img, video, canvas { max-width: 100%; }
.vphotos img { object-fit: cover; }

/* статус ИИ-оформления фото */
.vphoto { position: relative; }
.vphoto-st { position: absolute; left: 6px; bottom: 6px; right: 6px; padding: 3px 8px; border-radius: 8px; background: rgba(0,0,0,.65); color: #ddd; font-size: 11px; line-height: 1.3; }

/* карточка машины: колонки не должны ломаться на iPad (1000-1400 px) */
@media (min-width: 1000px) and (max-width: 1400px) { .grid.cols-main { grid-template-columns: minmax(0, 1fr) 340px; } .cols-main > .grid { grid-template-columns: minmax(0, 1fr); } }
