/* Phones, iPhone first: notches and home indicators, no zoom-on-focus, and
   layouts that fit a thumb. Loaded last so it wins. */

html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; -webkit-touch-callout: none; }
button, a, .chip, .btn, .icon-btn, [role='button'], [role='tab'] { touch-action: manipulation; }
input, textarea, [contenteditable='true'], .pre, .post-text, .msg-bubble { -webkit-touch-callout: default; }

/* When Zurbax runs from the Home Screen (or the iOS app) the page reaches up
   under the status bar and down to the home indicator. */
.shell-wrap { padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.auth { padding-top: max(env(safe-area-inset-top), 0px); padding-bottom: env(safe-area-inset-bottom); }
.modal-back { padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
#layer-toasts { top: calc(18px + env(safe-area-inset-top)); }
.logo-orb { flex: none; aspect-ratio: 1; }

@media (pointer: coarse) {
  /* iOS zooms into any field with text under 16px. */
  .field, input:not([type='range']):not([type='color']):not([type='checkbox']):not([type='radio']), textarea, select { font-size: max(16px, 1rem) !important; }
  /* Long-press a message to react to it. */
  .msg.show-tools .msg-tools { display: flex !important; }
  .msg { -webkit-user-select: none; user-select: none; }
  .photo-cell:hover img, .gif-cell:hover, .poll-opt:hover { transform: none; }
}

@media (max-width: 640px) {
  /* The composer gives its whole width to what you're writing. */
  .composer > .avatar { display: none; }
  .composer.card { padding: 12px; }
  .tag-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -2px; padding: 2px; }
  .tag-row::-webkit-scrollbar { display: none; }
  .tag-pick { flex: none; }
  .composer-actions { flex-wrap: wrap !important; row-gap: 6px; }
  .composer-actions .composer-tools {
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    overflow: visible;
  }
  .composer-tools .tool { width: auto; height: 42px; }
  .composer-actions .pod-select { flex: 1 1 auto; max-width: none; }
  .composer-actions .post-btn { margin-left: auto; min-height: 42px; padding-left: 20px; padding-right: 20px; }
  .compose-modal .modal { width: 100%; }

  /* Pickers use the whole screen width. */
  .gif-scroll { height: 58dvh; }
  .gif-grid { columns: 2 120px; }
  .emoji-btn { height: 42px; }

  /* The join screen's floating stickers keep clear of the name. */
  .auth-floaters .floater:nth-child(5) { display: none; }

  .photo-grid { border-radius: 12px; }
  .lb-nav { display: none; }
}

/* Landscape phones: keep the tab bar off the rounded corners. */
@media (max-width: 920px) and (orientation: landscape) and (pointer: coarse) {
  .dock { left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); }
}

/* Installing on an iPhone */
.install-hero { display: flex; align-items: center; gap: 14px; }
.install-icon { border-radius: 22%; box-shadow: 0 8px 18px -6px rgba(0, 40, 100, 0.5); flex: none; }
.install-steps { margin: 4px 0; padding-left: 1.3em; display: grid; gap: 6px; }
.install-nudge {
  position: fixed;
  z-index: 40;
  left: 12px;
  right: 12px;
  bottom: calc(96px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-radius: 22px;
  animation: nudge-in 0.5s var(--spring);
}
.install-nudge img { border-radius: 22%; }
@keyframes nudge-in { from { transform: translateY(30px); opacity: 0; } }

/* Shown when the app is deployed without a database */
.storage-warning {
  position: fixed;
  z-index: 250;
  left: 50%;
  top: calc(32px + env(safe-area-inset-top));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  padding: 10px 40px 10px 14px;
  border-radius: 14px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: #4a2a00;
  background: #ffe28a;
  box-shadow: 0 8px 24px rgba(80, 50, 0, 0.35), inset 0 0 0 1px rgba(160, 100, 0, 0.35);
  text-shadow: none;
}
.storage-warning button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(120, 70, 0, 0.12); color: inherit; font: inherit; cursor: pointer; }

/* iPhone Home Screen apps: fill the screen, even where iOS makes the page
   a status bar short (lib/viewport.js measures --app-h and --app-gap; both
   are unset everywhere else), and never bounce the whole page. */
html { height: var(--app-h, 100%); overscroll-behavior: none; }
#wallpaper { bottom: auto; height: max(100%, var(--app-h, 0px)); }
@supports (height: 100lvh) {
  /* Under Safari's see-through bottom bar too. */
  #wallpaper { height: max(100lvh, var(--app-h, 0px)); }
}
.modal-back, .lightbox, .screensaver, .boot, .auth-floaters, .party-layer, .profile-effect { bottom: calc(0px - var(--app-gap, 0px)); }
.screensaver { height: auto; }
.view, .auth, .modal-body { overscroll-behavior-y: contain; }
@media (max-width: 820px) {
  .dock { bottom: calc(10px + env(safe-area-inset-bottom) - var(--app-gap, 0px)); }
  :root[data-skin='classic'] .dock, :root[data-skin='luna'] .dock { bottom: calc(0px - var(--app-gap, 0px)); }
  .fab { bottom: calc(96px + env(safe-area-inset-bottom) - var(--app-gap, 0px)); }
  .editor-drawer { bottom: calc(10px - var(--app-gap, 0px)); }
}
.install-nudge { bottom: calc(96px + env(safe-area-inset-bottom) - var(--app-gap, 0px)); }
