/* Cross-browser + device layer for the website. Loaded last.
   Targets: Chrome, Edge, Safari (macOS + iOS/iPadOS), Firefox, Samsung Internet / Android Chrome. */

/* stop iOS/Android from inflating text in landscape; keep tap flashes off */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; -moz-osx-font-smoothing: grayscale; }

/* iOS zooms the page when a focused field is under 16px: give fields 16px on touch screens */
@media (pointer: coarse) {
  input:is([type=text], [type=email], [type=tel], [type=number], [type=search], [type=url], [type=date], [type=time], :not([type])),
  textarea, select { font-size: 16px !important; }
}

/* mobile browser bars: 100vh is taller than the visible screen on iOS/Android; use the dynamic unit where supported */
@supports (height: 100dvh) {
  .a3, .atelier, .tryon, html.embed .a3 { min-height: 100dvh; }
  .a3-stage, .atelier-canvas { height: 100dvh; }
}

/* the native colour picker is a "button" on iOS that ignores opacity:0 unless the appearance is reset */
input[type=color] { -webkit-appearance: none; appearance: none; }

/* Firefox: range tracks + vertical zoom slider */
.a3-range input[type=range]::-moz-range-track, .a3-meas input[type=range]::-moz-range-track,
.a3-zoom input[type=range]::-moz-range-track { background: transparent; }
.a3-zoom input[type=range] { -webkit-writing-mode: vertical-lr; }

/* touch screens have no hover: show what desktop reveals on hover */
@media (hover: none) {
  #chrome.collapsed .navrow { max-height: 80px; opacity: 1; margin-top: 10px; }
  .btn:hover, .a3-chip:hover, .a3-dot:hover, .tool:hover, .opt:hover, .fr-gown:hover, .card:hover .card-img img, .house:hover img { transform: none; }
}

/* notched phones (viewport-fit=cover): keep floating panels off the notch and home bar */
@supports (padding: env(safe-area-inset-top)) {
  :root { --gut: max(20px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  #chrome { margin-top: env(safe-area-inset-top); }
  .a3-body { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}

/* grid tracks never grow past the screen because of a long word or image */
.a3-looks { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.a3-look span { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- tablets (iPad portrait, Android tablets) */
@media (max-width: 1000px) {
  .a3 { grid-template-columns: minmax(0, 1fr); }
  .a3-stage, .a3-panel { min-width: 0; }
  .a3-stage { min-height: 560px; }
}
@media (min-width: 721px) and (max-width: 1000px) {
  /* iPad portrait / Android tablets: rotate controls above the price bar, gown framed between the panels */
  .a3-views { inset-block-end: 160px; }
  .a3-canvas { inset-block: 120px 200px; }
  .a3-zoom { top: 40%; }
}

/* iPad landscape / small laptops: the rotate bar would slide under the logo bar, so it sits above the price card */
@media (min-width: 1001px) and (max-width: 1240px) {
  .a3-views { inset-block-start: auto; inset-block-end: 160px; inset-inline: var(--gut); justify-content: center; flex-wrap: wrap; }
  .a3-canvas { inset-block-end: 196px; }
}

/* ---------------------------------------------------------------- phones */
@media (max-width: 720px) {
  :root { --gut: 12px; }
  .a3-stage { height: 92vh; height: 92svh; min-height: 600px; }

  /* compact title + mode switch stacked under the logo bar */
  .a3-title { inset-block-start: 74px; padding: 8px 12px; }
  .a3-title .a3-label, .a3-title p { font-size: 9px; margin: 0; }
  .a3-title h1 { font-size: 22px; }
  .a3-mode, html.embed .a3-mode { inset-block-start: 142px; }
  html.embed .a3-title { inset-block-start: var(--gut); }

  /* the 3D canvas sits between the top panels and the price card, so nothing covers the gown */
  .a3-canvas { inset-block: 150px 214px; }
  .a3-sketch { padding: 0; }
  .a3-sketch .sk-stage, .sk-stage { inset: 180px 0 214px; }
  .a3-zoom { top: auto; inset-block-end: 222px; transform: none; padding: 6px 4px; }
  .a3-zoom input[type=range] { height: 80px; }

  /* rotate controls sit just above the price card instead of underneath it */
  .a3-views { inset-block-end: 158px; inset-inline: var(--gut); justify-content: center; }

  /* price card: one line of price, buttons in a tidy grid */
  .a3-bottom { padding: 10px; gap: 8px; }
  .a3-bottom > div:first-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; width: 100%; }
  .a3-bottom > div:first-child .a3-label { display: none; }
  .a3-bottom b#price, .a3-bottom #price { font-size: 19px; margin: 0; }
  .a3-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
  .a3-actions .btn { height: 38px; min-height: 0; padding: 0 8px; justify-content: center; font-size: 10px; }
  .a3-actions .btn.primary { grid-column: 1 / -1; }

  /* sketch: the floating parts tray scrolls along the bottom instead of covering the drawing */
  .sk-tray { top: auto; transform: none; inset-block-end: 214px; inset-inline: var(--gut); flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .sk-tray::-webkit-scrollbar { display: none; }
  .sk-piece { flex: none; width: 70px; }
}

/* very small phones (iPhone SE / mini) */
@media (max-width: 360px) {
  .a3-title h1 { font-size: 20px; }
  .a3-mode button { padding: 0 7px; }
}
