/* HyphySpace Native Mobile v1.0.2 — mobile enhancements plus desktop detail return.
   We respect the CSS safe-area insets supplied by each device: no fixed notch sizes. */
.hsp-app-dock { display: none; }
@media (max-width: 800px) {
  html.hsp-native-app {
    --hsp-safe-top: env(safe-area-inset-top, 0px);
    --hsp-safe-bottom: env(safe-area-inset-bottom, 0px);
    --hsp-safe-left: env(safe-area-inset-left, 0px);
    --hsp-safe-right: env(safe-area-inset-right, 0px);
    --hsp-dock-base: 58px;
    -webkit-text-size-adjust: 100%;
  }
  /* Existing theme already adds this padding on some iOS versions. Assigning,
     rather than adding to, padding-top prevents doubled Dynamic Island spacing. */
  html.hsp-native-app .hyphy-topbar {
    padding-top: var(--hsp-safe-top);
    background: var(--hs-bg, #0a0a0b);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  html.hsp-native-app .hyphy-topbar__inner {
    width: 100%;
    min-height: 52px;
    min-width: 0;
    padding-left: max(12px, var(--hsp-safe-left));
    padding-right: max(12px, var(--hsp-safe-right));
  }
  html.hsp-native-app .hyphy-topbar__left,
  html.hsp-native-app .hyphy-topbar__right { min-width: 0; }
  /* In the installed app the six primary tabs move into the thumb-friendly
     bottom dock. Search, account, and log out stay accessible in the header. */
  html.hsp-native-app.hsp-has-dock .hyphy-topbar .hyphy-nav__link:not(.hyphy-nav__me):not(.hyphy-nav__logout) {
    display: none !important;
  }
  html.hsp-native-app.hsp-has-dock .hyphy-topbar__right { gap: 2px; }
  html.hsp-native-app .hyphy-main {
    padding-left: var(--hsp-safe-left);
    padding-right: var(--hsp-safe-right);
  }
  html.hsp-native-app.hsp-has-dock .hyphy-main {
    padding-bottom: calc(92px + var(--hsp-safe-bottom));
  }
  html.hsp-native-app.hsp-has-dock .hyphy-ig-wrap {
    padding-bottom: calc(70px + var(--hsp-safe-bottom));
  }
  html.hsp-native-app.hsp-has-dock .hsp-app-dock {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: start;
    gap: 0;
    position: fixed;
    z-index: 95;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--hsp-dock-base) + var(--hsp-safe-bottom));
    padding: 4px max(8px, var(--hsp-safe-right)) calc(4px + var(--hsp-safe-bottom)) max(8px, var(--hsp-safe-left));
    border-top: 1px solid var(--hs-line, #26262c);
    background: var(--hs-bg, #0a0a0b);
    box-sizing: border-box;
  }
  html.hsp-native-app .hsp-app-dock__item {
    display: flex;
    min-width: 0;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 0;
    background: transparent;
    color: var(--hs-text-2, #bbb);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
  }
  html.hsp-native-app .hsp-app-dock__item[aria-current="page"],
  html.hsp-native-app .hsp-app-dock__item.is-compose {
    color: var(--hs-text, #fff);
  }
  html.hsp-native-app .hsp-app-dock__item[aria-current="page"]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: calc(50% - 9px);
    width: 18px;
    height: 2px;
    background: var(--hs-gold-2, #ff8c1a);
    border-radius: 2px;
  }
  html.hsp-native-app .hsp-app-dock__item.is-compose svg { color: var(--hs-gold, #ffb347); }
  html.hsp-native-app .hsp-app-dock__item svg { width: 23px; height: 23px; fill: currentColor; flex: 0 0 23px; }
  html.hsp-native-app .hsp-app-dock__item:focus-visible { outline: 2px solid var(--hs-gold, #ffb347); outline-offset: -2px; }
  html.hsp-native-app .hsp-app-dock__badge {
    position: absolute;
    top: 2px;
    left: calc(50% + 6px);
    min-width: 16px;
    padding: 0 3px;
    border-radius: 9px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    font-weight: 800;
    color: #100b05;
    background: var(--hs-gold, #ffb347);
  }
  /* Inputs use 16px to prevent Safari's automatic zoom while typing. */
  html.hsp-native-app input:not([type="checkbox"]):not([type="radio"]),
  html.hsp-native-app textarea,
  html.hsp-native-app select { font-size: max(16px, 1em); }
  html.hsp-native-app a,
  html.hsp-native-app button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  /* Fullscreen overlays must never tuck close buttons behind the Island or
     save/send buttons under the bottom swipe handle. */
  html.hsp-native-app .hyphy-mobile-search {
    height: 100dvh;
    max-height: 100dvh;
    padding-top: var(--hsp-safe-top);
    padding-bottom: var(--hsp-safe-bottom);
    box-sizing: border-box;
  }
  html.hsp-native-app .hyphy-mobile-search__results {
    padding-bottom: max(12px, var(--hsp-safe-bottom));
  }
  html.hsp-native-app .hyphy-composer-modal,
  html.hsp-native-app .hyphy-report-modal,
  html.hsp-native-app .hyphy-confirm-modal,
  html.hsp-native-app .hyphy-requests-modal,
  html.hsp-native-app .hyphy-qr-modal,
  html.hsp-native-app .hyphy-edit-modal,
  html.hsp-native-app .hyphy-userlist-modal,
  html.hsp-native-app .hyphy-notifs-modal,
  html.hsp-native-app .hyphy-giphy-modal,
  html.hsp-native-app .hyphy-crop-modal,
  html.hsp-native-app .hyphy-settings-modal {
    padding-top: var(--hsp-safe-top);
    padding-bottom: var(--hsp-safe-bottom);
    padding-left: var(--hsp-safe-left);
    padding-right: var(--hsp-safe-right);
    box-sizing: border-box;
  }
  html.hsp-native-app .hyphy-composer-modal__panel,
  html.hsp-native-app .hyphy-edit-modal__panel,
  html.hsp-native-app .hyphy-userlist-modal__panel,
  html.hsp-native-app .hyphy-notifs-modal__panel,
  html.hsp-native-app .hyphy-giphy-modal__panel,
  html.hsp-native-app .hyphy-crop-modal__panel,
  html.hsp-native-app .hyphy-settings-modal__panel,
  html.hsp-native-app .hyphy-report-modal .hyphy-userlist-modal__panel,
  html.hsp-native-app .hyphy-confirm-modal .hyphy-userlist-modal__panel,
  html.hsp-native-app .hyphy-requests-modal .hyphy-userlist-modal__panel {
    max-height: calc(100dvh - var(--hsp-safe-top) - var(--hsp-safe-bottom) - 8px);
    max-width: 100%;
  }
  /* Video page uses --hyphy-topbar-h measured by the theme itself, which
     already includes the safe top inset. Leave the top edge untouched. */
  html.hsp-native-app.hsp-has-dock .hyphy-videos {
    bottom: calc(var(--hsp-dock-base) + var(--hsp-safe-bottom));
  }
  html.hsp-native-app .hyphy-videos {
    padding-left: var(--hsp-safe-left);
    padding-right: var(--hsp-safe-right);
  }
  html.hsp-native-app.hsp-has-dock .hyphy-toast,
  html.hsp-native-app.hsp-has-dock .hyphy-first-save-popup {
    bottom: calc(18px + var(--hsp-dock-base) + var(--hsp-safe-bottom));
  }
  html.hsp-native-app .hsp-native-offline {
    display: block;
    position: fixed;
    left: max(12px, var(--hsp-safe-left));
    right: max(12px, var(--hsp-safe-right));
    bottom: calc(12px + var(--hsp-safe-bottom) + var(--hsp-dock-base));
    border: 1px solid var(--hs-line, #333);
    background: var(--hs-bg-2, #131316);
    color: var(--hs-text, #fff);
    padding: 10px 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    box-shadow: 0 6px 14px rgba(0,0,0,.2);
    z-index: 160;
  }
  html.hsp-native-app:not(.hsp-has-dock) .hsp-native-offline { bottom: calc(12px + var(--hsp-safe-bottom)); }
  html.hsp-native-app.hsp-keyboard-open .hsp-app-dock { display: none !important; }
}
@media (max-width: 360px) {
  html.hsp-native-app .hyphy-topbar__inner { gap: 4px; padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
  html.hsp-native-app .hsp-app-dock__item svg { width: 21px; height: 21px; flex-basis: 21px; }
}
@media (orientation: landscape) and (max-height: 440px) and (max-width: 800px) {
  html.hsp-native-app { --hsp-dock-base: 46px; }
  html.hsp-native-app .hyphy-topbar__inner { min-height: 42px; }
  html.hsp-native-app .hsp-app-dock__item { min-height: 36px; }
  html.hsp-native-app .hyphy-main { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  html.hsp-native-app *, html.hsp-native-app *::before, html.hsp-native-app *::after { scroll-behavior: auto !important; }
}

/* v1.0.2 — dedicated post and media Back control on desktop AND the installed mobile app. */
.hsp-native-detailbar {
  position: sticky;
  top: var(--hyphy-topbar-h, 56px);
  z-index: 44;
  display: flex;
  align-items: center;
  padding: 4px max(10px, env(safe-area-inset-left, 0px)) 8px;
  margin-bottom: 10px;
  min-height: 48px;
  background: var(--hs-bg, #0a0a0b);
  border-bottom: 1px solid var(--hs-line, #26262c);
  box-sizing: border-box;
}
.hsp-native-detailbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 78px;
  min-height: 42px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--hs-text, #fff);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hsp-native-detailbar__back svg {
  width: 22px; height: 22px; flex: 0 0 22px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.hsp-native-detailbar__back:focus-visible {
  outline: 2px solid var(--hs-gold, #ffb347);
}

/* Pull down to refresh remains exclusive to the installed phone app. */
@media (max-width: 800px) {
  html.hsp-native-app .hsp-pull-refresh {
    --hsp-pull-distance: 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: fixed;
    top: calc(var(--hyphy-topbar-h, 56px) + 7px);
    left: 50%;
    z-index: 90;
    width: max-content;
    max-width: calc(100vw - var(--hsp-safe-left) - var(--hsp-safe-right) - 20px);
    min-height: 42px;
    box-sizing: border-box;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--hs-line, #333);
    background: var(--hs-bg-2, #171719);
    color: var(--hs-text, #fff);
    box-shadow: 0 7px 20px rgba(0,0,0,.22);
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(-50%, calc(-100% - 16px + var(--hsp-pull-distance)), 0);
    transition: opacity .12s ease, transform .15s ease;
  }
  html.hsp-native-app .hsp-pull-refresh.is-dragging,
  html.hsp-native-app .hsp-pull-refresh.is-loading,
  html.hsp-native-app .hsp-pull-refresh.is-offline { opacity: 1; }
  html.hsp-native-app .hsp-pull-refresh.is-dragging { transition: opacity .10s ease; }
  html.hsp-native-app .hsp-pull-refresh__icon,
  html.hsp-native-app .hsp-pull-refresh__icon svg { display: block; width: 19px; height: 19px; }
  html.hsp-native-app .hsp-pull-refresh__icon svg {
    fill: none;
    stroke: var(--hs-gold, #ffb347);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
  }
  html.hsp-native-app .hsp-pull-refresh.is-ready .hsp-pull-refresh__icon {
    transform: rotate(80deg);
  }
  html.hsp-native-app .hsp-pull-refresh.is-loading .hsp-pull-refresh__icon {
    animation: hsp-native-pull-spin .75s linear infinite;
  }
}
@keyframes hsp-native-pull-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  html.hsp-native-app .hsp-pull-refresh { transition: none; }
  html.hsp-native-app .hsp-pull-refresh.is-loading .hsp-pull-refresh__icon { animation: none; }
}
