/* ── css/device.css ──────────────────────────────────────────────────
   One small layer every page loads LAST. It does not restyle anything: it
   makes sure each page behaves on real devices — notches and home bars,
   iOS input zoom, very small and very large screens, short landscape
   phones, touch vs mouse, reduced motion, print.

   Plain defaults use :where() (zero specificity) so a page's own CSS always
   wins; the few rules that must beat page CSS say why.
────────────────────────────────────────────────────────────────── */

/* Text never gets inflated by the browser; long words and URLs wrap instead of pushing the page wide. */
:where(html) { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
:where(body) { overflow-wrap: break-word; min-height: 100vh; min-height: 100dvh; }
:where(img, video, iframe, canvas) { max-width: 100%; }
:where(pre) { overflow-x: auto; max-width: 100%; }
:where(table) { max-width: 100%; }

/* viewport-fit=cover lets pages use the whole screen; keep content out from under a landscape notch. */
:where(body) {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* A visible keyboard focus ring wherever a page didn't define one. */
:where(:focus-visible) { outline: 2px solid currentColor; outline-offset: 2px; }

/* ── Touch screens ─────────────────────────────────────────────────── */
@media (hover: none), (pointer: coarse) {
  :where(a, button, [role="button"], label, summary) { -webkit-tap-highlight-color: rgba(17, 17, 17, .08); touch-action: manipulation; }
}

/* iOS Safari zooms the whole page when a field under 16px gets focus. This has to beat the
   pages' own font sizes, so it is !important and limited to touch devices. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="image"]),
  select,
  textarea { font-size: max(16px, 1em) !important; }
}

/* ── Finger-sized targets ───────────────────────────────────────────
   Selectors the responsive audit found under ~32px on a phone. Padding (not a
   bigger visual) so the look stays; negative margins hand the space back. */
@media (pointer: coarse) {
  .kx-logo { min-height: 44px; }
  .kx-ai { min-width: 40px; min-height: 40px; }
  .kx-foot-col a { padding: 11px 0; }
  .kx-footer-bottom a, .kx-footer-news a { display: inline-block; padding: 8px 0; }
  .kc-title { display: inline-block; padding: 4px 0; }
  .hm-dot { position: relative; }
  .hm-dot::after { content: ''; position: absolute; inset: -14px -6px; }
  .ksp-tab, .chip, .hbtn, .kx-tab { min-height: 40px; }
  .pe-bar-row, .st-bar-row { min-height: 40px; }
  .pd-store, .pd-rating, .st-rate, .st-report, .featured-link, #shareProductBtn, #reportProductBtn, .pe-rc-report { display: inline-flex; align-items: center; min-height: 40px; }
  .forgot-pass, .cnt, .mobile-logo { display: inline-block; padding: 10px 0; }
}

/* ── Bottom edge: everything fixed to it clears the home indicator ──── */
@media (max-width: 900px) {
  :where(.kx-toasts) { bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
}
:where(#kova-chat-btn, #kc-teaser, #kova-chat-widget, .kx-top, .toast, #toast, #sellerToast) { margin-bottom: env(safe-area-inset-bottom, 0px); }
:where(.savebar, #cookieBanner, .ai-savebar) { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

/* ── Short landscape phones ────────────────────────────────────────── */
@media (max-height: 480px) and (orientation: landscape) {
  :where(html) { scroll-padding-top: 8px; }
  /* sticky headers eat half the screen at this height; let them scroll away */
  :where(.kx-header, .kb-header, .co-head) { position: static !important; }
}

/* ── Large screens: keep line lengths and cards readable ───────────── */
@media (min-width: 1900px) {
  :where(html) { font-size: 106.25%; }   /* rem-based text grows 6% */
}
@media (min-width: 2400px) {
  :where(html) { font-size: 112.5%; }
}

/* ── Reduced motion ────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Print ─────────────────────────────────────────────────────────── */
@media print {
  #kova-chat-btn, #kc-teaser, #kova-chat-widget, .kx-toasts, .cookie-banner, #cookieBanner, .kx-tabbar, .co-bar, .ai-savebar, .toast, #toast { display: none !important; }
  body { background: #fff !important; padding: 0 !important; }
  a { color: inherit; text-decoration: none; }
}
