/* Phone and tablet fit for the public app (loaded after the app's own styles; see cloudflare/build.mjs).
   The app's layout is already responsive; this file fixes what only shows up on real touch devices. */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; }
img, video, canvas, svg { max-width: 100%; }
button, a, [role="button"], [role="tab"], label { -webkit-tap-highlight-color: transparent; }

/* Touch screens: no hover, so things that only appear on hover must always be visible. */
@media (hover: none) {
  .save-card { opacity: 1; }
}

/* iPhones zoom the whole page when an input under 16px gets focus. Keep every field at 16px on touch screens. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea { font-size: 16px !important; } /* !important: the app's own field rules are more specific */
}

/* Comfortable tap targets (the hit area grows; the look barely changes). */
@media (pointer: coarse) {
  .save-card { width: 40px; height: 40px; top: 4px; right: 4px; border-radius: 9px; }
  .back-link { min-height: 44px; margin-bottom: 8px; }
  .creator-name { min-height: 32px; }
  .text-btn { min-height: 36px; }
  .tabs button { min-height: 46px; }
  .side-nav a { min-height: 46px; }
  .ahp-mute { width: 40px; height: 40px; }
  .ahp-chip { min-height: 40px; }
}

/* The category chips and the creator tabs scroll sideways: no scrollbar, momentum scrolling. */
.tabs, .category-bar { scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.tabs::-webkit-scrollbar, .category-bar::-webkit-scrollbar { display: none; }

/* The floating "Report a Problem" button must not sit on top of the content. */
@media (max-width: 760px) {
  #report-trigger { padding: 8px 13px; font-size: 12px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); opacity: .92; }
  #report-toast { right: 10px; bottom: calc(60px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 20px); }
  .main, main { padding-bottom: 72px; }
  .hero-buttons { flex-wrap: wrap; }
  .hero-buttons > * { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 380px) {
  .hero-buttons > * { flex-basis: 100%; }
  .hero h2 { overflow-wrap: anywhere; }
}

/* Dialogs (sign-in, membership, ID check, report): fit the screen and scroll inside it. */
@media (max-width: 560px) {
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; border-radius: 16px; }
  .modal-body { padding: 28px 20px 22px; }
  #report-modal { padding: 18px; max-height: calc(100dvh - 16px); }
}

/* Landscape phones are short: shrink the report button, but never hide it (safety reports must stay reachable). */
@media (max-height: 480px) and (orientation: landscape) {
  #report-trigger { padding: 6px 11px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* The app hides the "Creator Studio" link under 1000px, which left phones with no way in. Keep it as an icon button
   (the words stay in the DOM, visually hidden, for screen readers). */
@media (max-width: 1000px) {
  .top-actions .studio-link {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid #3a3444; color: #d9c8f5; flex: none;
  }
  .top-actions .studio-link span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .top-actions { gap: 10px; }
}
@media (min-width: 501px) and (max-width: 1000px) {
  .top-actions .studio-link { width: auto; padding: 0 12px; gap: 6px; }
  .top-actions .studio-link::after { content: "Studio"; font-size: 13px; font-weight: 600; }
}

/* Phones: the logo used to be wider than its box and ran under the search icon. Give it the room it needs, and shrink it
   on the narrowest screens so the search icon, Studio button and Sign in all fit on one row. */
@media (max-width: 500px) {
  .brand-group { min-width: 0; flex: none; }
  .topbar { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 380px) { .brand { font-size: 19px; } }
@media (max-width: 340px) {
  .brand { font-size: 16px; letter-spacing: -.5px; }
  .brand-group { gap: 4px; }
  .top-actions { gap: 6px; }
  .top-actions .studio-link { width: 36px; height: 36px; }
}

/* Settings use the available width before the profile form gets squeezed by its aside. */
@media (max-width: 1000px) {
  .settings-page .settings-columns { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .settings-columns > form, .settings-columns > aside, .settings-page .panel { min-width: 0; }
  /* Keep reporting in normal flow on the long settings form so it cannot cover fields or Save. */
  body:has(.settings-page) #report-trigger { position: static; display: block; width: calc(100% - 24px); min-height: 44px; margin: 0 12px calc(16px + env(safe-area-inset-bottom, 0px)); padding: 11px 16px; opacity: 1; }
}

@media (max-width: 600px) {
  html { scroll-padding-top: calc(var(--top, 128px) + 16px); }
  .settings-page { padding: 20px 12px 24px; }
  .settings-page .subpage-heading { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 22px; }
  .settings-page .subpage-heading h1 { font-size: clamp(23px, 6.3vw, 28px); line-height: 1.25; letter-spacing: -.6px; }
  .settings-page .subpage-heading > .btn { align-self: flex-start; white-space: nowrap; font-size: 13px; min-height: 44px; padding: 10px 15px; }
  .settings-page .panel { padding: 20px 16px; margin-bottom: 18px; border-radius: 12px; }
  .settings-page .panel h2 { font-size: 17px; margin-bottom: 18px; }
  .settings-page .form-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .settings-page .form-stack { gap: 16px; }
  .settings-page input:not([type=checkbox]):not([type=radio]), .settings-page textarea { font-size: 16px; min-width: 0; }
  .settings-page textarea { min-height: 120px; }
  .settings-page .toggle-row { gap: 12px; min-height: 64px; }
  .settings-page .toggle-row strong { font-size: 14px; }
  .settings-page .toggle-row small { font-size: 13px; }
  .settings-page .switch { flex-shrink: 0; }
  .settings-columns > form > .btn { width: 100%; min-height: 46px; }
  .settings-page .settings-note { overflow-wrap: anywhere; }

  .topbar .menu-toggle, .topbar .user-button, .top-actions .studio-link { width: 44px; height: 44px; flex-shrink: 0; }
  .topbar .sign-in { min-height: 44px; }
  .topbar .search, .topbar .search:focus-within { inset: 77px 12px auto; width: auto; max-width: none; height: 44px; padding: 0 12px; border: 1px solid #303035; }
  .topbar .search:focus-within { border-color: var(--accent); }
  .topbar .search input { width: 100%; font-size: 16px; opacity: 1; }
  .modal .btn, #report-modal .btn { min-height: 44px; }
  .modal-close, #report-modal .report-close { display: grid; place-items: center; width: 44px; height: 44px; }
  #report-modal .report-close { top: 8px; right: 8px; }
  #report-modal h2 { margin-right: 44px; }

}
