/* AYK Universal Experience · Shared responsive foundations v1
   Viewport-driven, not handset-model-driven. Keep the existing editorial
   identity, card/image crop choices and page-specific breakpoints intact.
   Load after each screen's existing component styles. */

/* Prevent browser text inflation across Android, Samsung Internet and iOS. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { min-inline-size: 0; max-inline-size: 100%; }

/* Large original photos, videos, and rich embeds never force an entire page
   wider than the device. This does not alter their chosen object-fit ratio. */
:where(.page-shell, .founder-studio, .ayk-catalog-page, .store-front, main)
  :where(img, video, canvas, iframe) {
  max-inline-size: 100%;
}
:where(.page-shell, .founder-studio, .ayk-catalog-page, .store-front, main)
  :where(svg) { max-inline-size: 100%; }

/* A grid or flex child normally has min-width:auto, which can make Arabic
   titles, long cultivars and founder codes overflow on narrow screens. */
:where(.page-shell, .founder-studio, .ayk-catalog-page, .collection-browser,
       .ayk-private-journey, .store-product-card, .studio-edit-panel) {
  min-inline-size: 0;
}
:where(.page-shell, .founder-studio, .ayk-catalog-page)
  :where(.gridform, .cards, .plant-grid, .collection-grid,
         .collection-browser-controls, .collection-browser-heading,
         .studio-form-grid, .studio-heading, .studio-photo-row,
         .studio-product-main, .studio-product-list, .studio-actions,
         .ayk-catalog-layout, .ayk-catalog-samples, .ayk-catalog-stage,
         .showcase-filter, .showcase-grid) > * {
  min-inline-size: 0;
}
:where(.page-shell, .founder-studio, .ayk-catalog-page)
  :where(h1, h2, h3, .passport-identity, .studio-product-main,
         .collection-browser-heading, .ayk-catalog-sample strong) {
  overflow-wrap: anywhere;
}

/* Forms should shrink inside split-view/tablet and mobile grid columns.
   Preserve native small control sizes (checkboxes, radio, sliders). */
:where(.page-shell, .founder-studio, .ayk-catalog-page, .store-front, main)
  :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),
         textarea, select) {
  box-sizing: border-box;
  max-inline-size: 100%;
  min-inline-size: 0;
}
:where(.page-shell, .founder-studio, .ayk-catalog-page)
  :where(input[type="email"], input[type="url"], input[type="tel"],
         input[type="password"]) { direction: ltr; text-align: left; }

/* Native modal dialogs stay inside the *visible* viewport, including iOS
   browser toolbars, landscape keyboards, and Samsung split screen. */
:where(dialog, .create-dialog, .ayk-mother-photo-dialog) {
  box-sizing: border-box;
  max-inline-size: calc(100vw - 24px);
  max-block-size: calc(100vh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
}
@supports (height: 100dvh) {
  :where(dialog, .create-dialog, .ayk-mother-photo-dialog) {
    max-block-size: calc(100dvh - 24px);
  }
}
:where(dialog)::backdrop { overscroll-behavior: contain; }

/* A row of controls may scroll *within itself*, never enlarge its page. */
:where(.page-shell, .founder-studio)
  :where(.studio-tabs, .passport-section-nav, .ayk-market-tabs,
         .collection-browser-tabs) {
  max-inline-size: 100%;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

/* For small screens, avoid Safari's 16px input-zoom threshold and allow easy
   taps, without inflating price cards, compact icon controls or photos. */
@media (max-width: 760px) {
  :where(.page-shell, .founder-studio, .ayk-catalog-page, .store-front, main)
    :where(input[type="text"], input[type="email"], input[type="search"],
           input[type="number"], input[type="tel"], input[type="url"],
           input[type="password"], textarea, select) {
    font-size: 16px;
  }
  :where(.page-shell, .founder-studio, .ayk-catalog-page, .store-front)
    :where(button[type="submit"], .outline-button, .studio-tabs a) {
    min-block-size: 44px;
  }
  :where(.page-shell, .founder-studio, .ayk-catalog-page)
    :where(.studio-photo-row, .studio-heading, .collection-browser-heading) {
    max-inline-size: 100%;
  }
}

/* On notched and foldable handsets, the shared 5-slot dock stays inside the
   safe area. This intentionally does not change the number of navigation items. */
@media (max-width: 1100px) {
  body :where(.bottomnav.ayk-mobile-dock,
              .ayk-store-mobile-dock.ayk-unified-dock) {
    padding-inline-start: max(8px, env(safe-area-inset-left, 0px)) !important;
    padding-inline-end: max(8px, env(safe-area-inset-right, 0px)) !important;
  }
  :where(body > main.page-shell, body > main:has(.founder-studio),
         body > main:has(.ayk-catalog-page)) {
    padding-block-end: calc(92px + env(safe-area-inset-bottom, 0px));
  }
}

/* Short landscape viewports: keep access to form submit/close controls. */
@media (orientation: landscape) and (max-height: 500px) {
  :where(dialog, .create-dialog, .ayk-mother-photo-dialog) {
    max-block-size: calc(100vh - 12px);
  }
  @supports (height: 100dvh) {
    :where(dialog, .create-dialog, .ayk-mother-photo-dialog) {
      max-block-size: calc(100dvh - 12px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  :where(.page-shell, .founder-studio, .ayk-catalog-page)
    :where(*, *::before, *::after) { scroll-behavior: auto !important; }
}
