/* ============================================================================
   PTSB Online Banking — Responsive Layer  (v2)
   ----------------------------------------------------------------------------
   Loaded AFTER /online/css/style.css. Overrides the vendor's fixed-width
   desktop layout so the login flow renders correctly on every phone from a
   folded Galaxy Fold (~280px) through iPhone Pro Max, tablets, and desktop.

   Key vendor issues this layer fixes:
     • .centered { width: 1366px } — kills the whole page on mobile
     • .module-footer { margin: -107px 0 0 0; height: 107px } — sticky-bottom
       trick with negative margin that overlaps content on tall mobile stacks
     • #main { padding-bottom: 240px } — huge dead space on mobile
     • .module { overflow: hidden } — clips wrapped text on narrow widths
     • .module-header { height: 82px } — logo/welcome cramp at <500px
     • .module-notification-banner { height: 64px } — text overflows silently
     • .col6 { width: 50% } side-by-side help/fraud cards
   ============================================================================ */

/* ---------- 0. GLOBAL HARDENING — every viewport ---------- */

/* Kill the vendor's fixed min-width traps that would otherwise force
   horizontal overflow on any screen narrower than 980–1366px:
     .module-header { min-width: 980px }
     .centered      { width:     1366px }  ← we replace with a proper
                                              max-width, see below
     body.landing   { min-width: 980px }
*/
html,
body,
html body,
body #wrap,
#wrap,
#main,
body.landing,
.module-header,
.module-header > div,
.module-notification-banner,
.module-footer,
.row,
.module,
.module-login,
.module-need-help,
.module-protect-yourself {
  min-width: 0 !important;
}

/* The main centered container. Real PTSB caps content at ~1180px on desktop
   and centers it on the page background — NOT stretched edge-to-edge on wide
   monitors. Below 1200px, we let it flow full-width with a small gutter.
   These rules deliberately live OUTSIDE the media-query block below so they
   are the desktop default. */
.centered,
#main.centered,
#wrap .centered,
body.small .centered {
  width: 100% !important;
  max-width: 1180px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

/* Footer inner wrapper — same 1180px centered cap so the footer columns line
   up with the main content column above them. */
.module-footer > div {
  width: 100% !important;
  max-width: 1180px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

/* Header inner wrapper — same treatment so the logo + welcome text sit within
   the same 1180px column instead of pinning to the extreme viewport edges. */
.module-header > div {
  width: 100% !important;
  max-width: 1180px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

/* Notification banner content — cap so the banner background can still span
   full viewport width (that's the intended look) but the text/close-button
   stay within the 1180px reading column. */
.module-notification-banner > div {
  width: 100% !important;
  max-width: 1180px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 20px !important;
  padding-right: 20px !important;
  box-sizing: border-box !important;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip; /* modern browsers — better than hidden for scroll anchoring */
  width: 100%;
}

/* Prevent flex/grid children from resisting shrink with implicit min-width:auto */
* {
  min-width: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Long unbreakable strings (URLs, emails, tokens) must break rather than push
   horizontal scroll on narrow screens */
p, li, a, label, span, h1, h2, h3, h4, h5, h6 {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

img,
picture,
video,
svg {
  max-width: 100%;
  height: auto;
}

/* iOS Safari zooms whenever an input has font-size < 16px on focus. */
input.large,
input[type="tel"],
input[type="password"],
input[type="text"],
input[type="email"],
input[type="number"] {
  font-size: 16px;
}

/* Respect notches / rounded corners on iPhone Pro / Android edge screens. */
#wrap {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.module-footer {
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

/* ---------- 1. ≤ 1200px — laptops narrower than the 1180px content cap ---------- */
/* Below 1200px the 1180px column would touch both viewport edges, so we drop
   the max-width and let it flow the full width with a slightly reduced gutter. */
@media (max-width: 1200px) {
  .centered,
  #main.centered,
  #wrap .centered,
  body.small .centered,
  .module-footer > div,
  .module-header > div,
  .module-notification-banner > div {
    max-width: 100% !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* ---------- 2. ≤ 1024px — tablets and small laptops ---------- */
@media (max-width: 1024px) {
  #wrap {
    background-attachment: scroll; /* fixed bg jitters on mobile Safari */
  }
  #main {
    padding-bottom: 40px !important; /* was 240px, kills dead space */
  }
  .module-footer {
    margin: 24px 0 0 0 !important; /* undo negative-margin sticky trick */
    height: auto !important;
    padding: 16px 12px !important;
  }
  .module-footer.module-footer-larger {
    height: auto !important;
  }
  .module {
    overflow: visible !important; /* was hidden — clipped text on narrow */
  }
}

/* ---------- 3. ≤ 900px — header + footer start feeling cramped ---------- */
@media (max-width: 900px) {
  .module-header {
    height: auto !important;
  }
  .module-footer .col1,
  .module-footer .col3,
  .module-footer .col4 {
    width: 100% !important;
    float: none !important;
    margin: 0 0 12px 0 !important;
    padding: 0 !important;
  }
  .module-footer .footer-content {
    padding: 0;
  }
}

/* ---------- 4. ≤ 767px — main mobile pass (portrait phones + tablets) ---------- */
@media (max-width: 767px) {
  /* Notification banner — fixed 64px height crushes multi-line text */
  .module-notification-banner {
    height: auto !important;
    min-height: 0 !important;
    padding: 12px 44px 12px 14px !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
    position: relative !important;
  }
  .module-notification-banner p {
    padding: 0 !important;
    margin: 0 !important;
  }
  .module-notification-banner .btn-close {
    top: 12px !important;
    right: 12px !important;
    width: 22px !important;
    height: 22px !important;
  }

  /* Header — vertical stack, centered */
  .module-header {
    padding: 12px 14px !important;
    text-align: center !important;
    height: auto !important;
    position: relative !important;
  }
  .module-header > div {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    height: auto !important;
    width: 100% !important;
  }
  .module-header .logo,
  .module-header .logo-small {
    display: block !important;
    float: none !important;
    margin: 0 !important;
    line-height: 0;
  }
  .module-header .logo img {
    max-height: 34px !important;
    width: auto !important;
    display: inline-block;
  }
  .module-header .welcome {
    position: static !important;
    transform: none !important;
    font-size: 14px !important;
    line-height: 1.3 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #fff;
    text-align: center !important;
  }
  .module-header nav {
    float: none !important;
    width: 100% !important;
    height: auto !important;
  }

  /* Grid — every column collapses to full width */
  .col1, .col2, .col3, .col4, .col5,
  .col6, .col7, .col8, .col9, .col10, .col11, .col12 {
    width: 100% !important;
    float: none !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
  }
  .gutter-right-half,
  .gutter-left-half {
    padding: 0 !important;
    margin: 0 0 14px 0 !important;
  }
  .row {
    padding: 0 !important;
    margin: 0 0 14px 0 !important;
    border: 0 !important;
  }

  /* Login card */
  .module-login {
    margin: 14px 0 !important;
    background-color: #FFF6F2;
    border-radius: 8px;
  }
  .module-login .padding {
    padding: 18px 16px !important;
  }
  .module-login .lock {
    display: none !important; /* the 104px absolute-positioned lock icon */
  }
  .module-login h1 {
    font-size: 20px !important;
    line-height: 1.3 !important;
    text-align: left !important;
    margin: 0 0 18px 0 !important;
  }
  .module-login h1 span {
    font-size: 22px !important;
    display: inline !important;
  }

  /* Form rows — label above input */
  .module-login ul.step-1 {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
  }
  .module-login ul.step-1 li {
    display: block !important;
    margin: 0 0 16px 0 !important;
    padding: 0 !important;
    float: none !important;
    height: auto !important;
  }
  .module-login ul.step-1 li .col6,
  .module-login ul.step-1 li .col5 {
    display: block !important;
    text-align: left !important;
    padding: 0 !important;
    margin: 0 0 6px 0 !important;
    width: 100% !important;
    height: auto !important;
    float: none !important;
  }
  .module-login ul.step-1 li label {
    display: block !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    padding: 0 !important;
    margin: 0 0 4px 0 !important;
    height: auto !important;
  }
  .module-login ul.step-1 li label span {
    display: block !important;
    font-size: 12px !important;
    color: #6a6a6a !important;
    font-weight: 400 !important;
    margin-top: 2px !important;
  }
  .module-login .editor-field {
    width: 100% !important;
  }
  .module-login input.large {
    width: 100% !important;
    height: 48px !important;
    padding: 10px 12px !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    display: block !important;
  }

  /* Submit button — full-width tap target */
  .module-login footer.full-width,
  .module-login footer {
    margin-top: 8px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }
  .module-login .btn,
  .module-login .btn-submit {
    width: 100% !important;
    min-height: 48px !important;
    padding: 12px 16px !important;
    text-align: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    float: none !important;
    box-sizing: border-box !important;
  }
  .module-login .btn-submit span {
    float: none !important;
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Forgot-password link */
  #gbtnforgot {
    display: inline-block !important;
    padding: 8px 0 !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  /* Help & fraud info cards */
  .module-need-help,
  .module-protect-yourself {
    height: auto !important;
    min-height: 0 !important;
    margin: 0 0 14px 0 !important;
    border-radius: 8px;
  }
  .module-need-help .padding,
  .module-protect-yourself .padding {
    padding: 16px !important;
  }
  .heading-help,
  .heading-excl {
    font-size: 18px !important;
    line-height: 1.3 !important;
    margin: 0 0 10px 0 !important;
  }
  .arrows,
  .arrows-hovered {
    padding-left: 0 !important;
    list-style: none !important;
  }
  .arrows li,
  .arrows-hovered li {
    padding-left: 20px !important;
    background-position: 0 6px !important;
    line-height: 1.4 !important;
    margin-bottom: 6px !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Footer — unlatched from negative-margin sticky trick, everything stacks */
  .module-footer,
  .module-footer.module-footer-larger {
    position: static !important;
    margin: 20px 0 0 0 !important;
    padding: 18px 14px calc(24px + env(safe-area-inset-bottom)) 14px !important;
    height: auto !important;
    text-align: left !important;
  }
  .module-footer > div {
    max-width: 100% !important;
  }
  .module-footer .row {
    margin-bottom: 4px !important;
  }
  .module-footer .label {
    font-size: 14px !important;
    font-weight: 700 !important;
    margin-top: 10px !important;
  }
  .module-footer p,
  .module-footer a {
    font-size: 13px !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .icon-footer-logo {
    display: block !important;
    margin: 0 0 12px 0 !important;
  }

  /* Tap-friendly links across the board */
  .tel {
    display: inline-block !important;
    padding: 2px 0 !important;
  }
}

/* ---------- 5. ≤ 480px — small phones (iPhone SE, older Androids) ---------- */
@media (max-width: 480px) {
  .centered {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .module-notification-banner {
    font-size: 12px !important;
    padding: 10px 40px 10px 12px !important;
  }
  .module-notification-banner .btn-close {
    top: 10px !important;
    right: 10px !important;
  }
  .module-login .padding {
    padding: 14px 12px !important;
  }
  .module-login h1 {
    font-size: 18px !important;
  }
  .module-login h1 span {
    font-size: 20px !important;
  }
  .heading-help,
  .heading-excl {
    font-size: 16px !important;
  }
  .module-need-help .padding,
  .module-protect-yourself .padding {
    padding: 14px 12px !important;
  }
  .module-footer {
    padding: 16px 12px calc(20px + env(safe-area-inset-bottom)) 12px !important;
  }
}

/* ---------- 6. ≤ 360px — foldables + smallest ---------- */
@media (max-width: 360px) {
  .centered {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
  .module-header .logo img {
    max-height: 28px !important;
  }
  .module-header .welcome {
    font-size: 12px !important;
  }
  .module-login h1 {
    font-size: 17px !important;
  }
  .module-login h1 span {
    font-size: 18px !important;
  }
  .module-login input.large {
    height: 46px !important;
  }
  .module-login .btn-submit {
    font-size: 15px !important;
    min-height: 46px !important;
  }
  a[href^="tel:"],
  a[href^="https:"],
  a[href^="http:"] {
    word-break: break-word !important;
  }
}

/* ---------- 7. ≤ 280px — Galaxy Fold folded ---------- */
@media (max-width: 280px) {
  .centered {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
  .module-login .padding,
  .module-need-help .padding,
  .module-protect-yourself .padding {
    padding: 10px 8px !important;
  }
  .module-login h1 {
    font-size: 15px !important;
  }
  .module-login h1 span {
    font-size: 16px !important;
  }
  .module-login input.large {
    height: 42px !important;
    padding: 8px 10px !important;
  }
  .module-login .btn-submit {
    font-size: 14px !important;
    min-height: 42px !important;
  }
  p, li, label {
    font-size: 12px !important;
    line-height: 1.35 !important;
  }
}

/* ---------- 8. Landscape short phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .module-header {
    padding: 6px 12px !important;
  }
  .module-header .logo img {
    max-height: 26px !important;
  }
  .module-login {
    margin: 8px 0 !important;
  }
  .module-login .padding {
    padding: 12px 16px !important;
  }
  .module-login h1 {
    font-size: 17px !important;
    margin-bottom: 10px !important;
  }
  .module-login ul.step-1 li {
    margin-bottom: 10px !important;
  }
}

/* ---------- 9. Accessibility ---------- */
@media (prefers-contrast: more) {
  .module-login input.large {
    border: 2px solid #333 !important;
  }
  .module-login .btn-submit {
    outline: 2px solid #000;
    outline-offset: 2px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
