/**
 * UX components: smart header, mobile navigation and responsive forms.
 */

/* Smart header: compact while scrolling, hidden down, revealed up. */
.rn-header {
  will-change: transform;
  transform: translate3d(0, 0, 0);
  transition:
    transform 260ms cubic-bezier(.2, .75, .2, 1),
    box-shadow var(--rn-base) var(--rn-ease),
    border-color var(--rn-base) var(--rn-ease),
    min-height var(--rn-base) var(--rn-ease);
}

.rn-header.is-hidden {
  pointer-events: none;
  transform: translate3d(0, calc(-100% - 12px), 0);
}

.rn-header.has-desktop-dropdown {
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
}

.rn-header.is-revealed {
  box-shadow: 0 14px 38px rgba(16, 25, 35, .12);
}

body.rn-menu-open .rn-header,
body.rn-modal-open .rn-header {
  pointer-events: auto;
  transform: none;
}

body.rn-modal-open {
  overflow: hidden;
}

.rn-mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: none;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(7, 19, 33, .54);
  border: 0;
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(3px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

/* Existing subscriber switch. */
.rn-customer-status {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 11px 12px;
  color: var(--rn-ink);
  background: rgba(55, 127, 190, .045);
  border: 1px solid rgba(55, 127, 190, .16);
  cursor: pointer;
  font-family: var(--rn-font-body);
  font-weight: 600;
}

.rn-customer-status input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.rn-customer-status-box {
  position: relative;
  width: 22px;
  height: 22px;
  background: #fff;
  border: 1px solid rgba(55, 127, 190, .42);
}

.rn-customer-status-box::after {
  position: absolute;
  left: 6px;
  top: 2px;
  width: 7px;
  height: 12px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  opacity: 0;
  transform: rotate(42deg) scale(.6);
  transition: opacity 150ms ease, transform 150ms ease;
  content: "";
}

.rn-customer-status input:checked + .rn-customer-status-box {
  background: var(--rn-blue);
  border-color: var(--rn-blue);
}

.rn-customer-status input:checked + .rn-customer-status-box::after {
  opacity: 1;
  transform: rotate(42deg) scale(1);
}

.rn-customer-status input:focus-visible + .rn-customer-status-box {
  outline: 3px solid rgba(55, 127, 190, .22);
  outline-offset: 2px;
}

.rn-subscriber-login[hidden] {
  display: none !important;
}

.rn-subscriber-login:not([hidden]) {
  animation: rnSubscriberFieldIn 180ms ease both;
}

@keyframes rnSubscriberFieldIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  body.rn-menu-open {
    overflow: hidden;
    touch-action: none;
  }

  body.rn-menu-open .rn-header {
    overflow: visible;
    will-change: auto;
    transform: none !important;
  }

  body.rn-menu-open .rn-mobile-panel {
    position: fixed;
    inset: 0 0 0 auto;
    min-height: 100dvh;
  }

  body.rn-menu-open .rn-mobile-backdrop {
    position: fixed;
    inset: 0;
  }

  .rn-header {
    z-index: 900;
  }

  .rn-header-shell {
    position: relative;
    z-index: 3;
  }

  .rn-mobile-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 2;
    display: flex !important;
    flex-direction: column;
    width: min(420px, 92vw);
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 92px 18px max(20px, env(safe-area-inset-bottom));
    background: #fff;
    border: 0;
    border-left: 1px solid rgba(55, 127, 190, .16);
    box-shadow: -24px 0 64px rgba(7, 19, 33, .18);
    opacity: 0;
    visibility: hidden;
    transform: translate3d(104%, 0, 0);
    transition: opacity 200ms ease, visibility 200ms ease, transform 280ms cubic-bezier(.2, .75, .2, 1);
  }

  body.admin-bar .rn-mobile-panel {
    top: 0;
    padding-top: 124px;
  }

  .rn-mobile-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0);
  }

  .rn-mobile-backdrop {
    display: block;
  }

  body.rn-menu-open .rn-mobile-backdrop {
    z-index: 1;
    opacity: 1;
    visibility: visible;
  }

  .rn-mobile-menu,
  .rn-mobile-menu ul {
    width: 100%;
  }

  .rn-mobile-menu > li > a {
    min-height: 52px;
    font-size: 16px;
  }

  .rn-mobile-menu .sub-menu {
    display: none;
    margin-left: 0;
    padding-left: 12px;
  }

  .rn-mobile-menu .menu-item-has-children {
    position: relative;
  }

  .rn-mobile-menu .menu-item-has-children > a {
    padding-right: 58px;
  }

  .rn-mobile-menu .menu-item-has-children.is-submenu-open > .sub-menu {
    display: grid;
  }

  .rn-mobile-submenu-toggle {
    position: absolute;
    top: 3px;
    right: 0;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--rn-blue-dark);
    background: rgba(55, 127, 190, .07);
    border: 1px solid rgba(55, 127, 190, .14);
  }

  .rn-mobile-submenu-toggle span {
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 180ms ease;
  }

  .rn-mobile-submenu-toggle[aria-expanded="true"] span {
    transform: translateY(2px) rotate(225deg);
  }

  .rn-mobile-menu .sub-menu a {
    min-height: 44px;
    font-size: 14px;
  }

  .rn-mobile-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: auto;
    padding-top: 20px;
  }

  .rn-mobile-actions > * {
    width: 100%;
    min-height: 48px;
  }
}

/* Forms stay inside the viewport and remain touch-friendly. */
.rn-modal-dialog {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.rn-callback-form,
.rn-business-request-form {
  gap: 14px;
}

.rn-form input,
.rn-form textarea,
.rn-form select {
  min-height: 48px;
}

.rn-form textarea {
  min-height: 112px;
}

@media (max-width: 680px) {
  .rn-modal {
    align-items: flex-end;
    padding: 0;
  }

  .rn-modal-dialog {
    width: 100%;
    max-width: none;
    max-height: min(92dvh, 860px);
    margin: 0;
    padding: 24px 16px max(18px, env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    clip-path: none;
    box-shadow: 0 -20px 60px rgba(7, 19, 33, .22);
  }

  .rn-modal-head {
    margin-bottom: 14px;
    padding-right: 42px;
  }

  .rn-modal-head h2 {
    font-size: clamp(26px, 8vw, 34px);
  }

  .rn-modal-head p {
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.5;
  }

  .rn-modal-close {
    position: sticky;
    z-index: 4;
    top: 0;
    float: right;
    margin-top: -8px;
    margin-right: -2px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(7, 19, 33, .10);
  }

  .rn-form,
  .rn-form-row,
  .rn-form-grid-2,
  .rn-business-request-form,
  .rn-business-request-form .rn-form-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .rn-form input,
  .rn-form textarea,
  .rn-form select {
    max-width: 100%;
    font-size: 16px;
  }

  .rn-form-submit,
  .rn-modal-dialog .rn-btn,
  .rn-modal-dialog .rn-btn-secondary {
    width: 100%;
    min-height: 50px;
  }

  .rn-settlement-picker-list {
    max-height: min(34dvh, 240px);
  }
}

@media (max-width: 520px) {
  .rn-mobile-panel {
    width: 100%;
    padding-inline: 14px;
    border-left: 0;
  }

  .rn-customer-status {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rn-header,
  .rn-mobile-panel,
  .rn-mobile-backdrop,
  .rn-subscriber-login:not([hidden]) {
    animation: none !important;
    transition: none !important;
  }
}
