/*
 * Responsive public pages.
 *
 * The public layout (app/views/layouts/public.html.erb) renders with
 * width=device-width, so phones get a real narrow viewport instead of the
 * 1050px desktop page scaled down. Every rule here is scoped to
 * body.public-responsive so the logged-in app layouts, which still use the fixed
 * 1050px viewport, are untouched.
 *
 * Desktop must look exactly as before: fixed widths become max-widths of the
 * same size, and layout changes live inside the narrow-width media queries.
 * mobile.css (max-width: 768px) also starts applying to public pages on
 * phones; where its app-oriented rules hurt a public page, they are overridden
 * here rather than edited, since the logged-in mobile pages rely on them.
 */

/* ------------------------------------------------------------------------
   Containers. Nothing here applies at desktop widths, so wide windows render
   exactly as before (page-specific .inner widths such as .privacy-policy keep
   winning there). Once the window is narrower than the fixed 1000/1140px
   containers, they fill the window instead of overflowing it.
   ------------------------------------------------------------------------ */

@media screen and (max-width: 1140px) {
  /* main.css: #home #header .inner { width: 1140px } (body#home on public). */
  #home.public-responsive #header .inner {
    width: auto;
  }
}

@media screen and (max-width: 1030px) {
  /* main.css: .inner { width: 1000px; padding: 0 15px } and
     .hero-copy { width: 1000px; padding-left: 15px }, both content-box. */
  .public-responsive .inner,
  .public-responsive .hero-copy {
    width: auto;
  }

  /* The home hero copy is absolutely positioned at left: 0 of the hero, so
     once the hero is the window's width it needs its own gutter. */
  .public-responsive .home-hero-copy-inner {
    padding-inline: 20px;
  }
}

/* ------------------------------------------------------------------------
   Phones and small tablets: shared header and footer.
   ------------------------------------------------------------------------ */

@media screen and (max-width: 768px) {
  /* Header: logo and links share one row; the row may wrap on very narrow
     screens, so the header grows instead of spilling over the page. */
  .public-responsive #header {
    height: auto;
  }

  /* display stays at low specificity: main.css hides whichever of the two
     header inners (.dot-family-header or the plain one) the product doesn't
     use, and those rules must keep winning. This only undoes the Phase 11
     `.site-header__inner { display: block }` mobile rule. */
  .public-responsive .site-header__inner {
    display: flex;
  }

  #home.public-responsive #header .site-header__inner {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    /* 75px like desktop: hero sections (.top-page-hero, .mayflower-hero) pull
       themselves up 76px to sit under the header. */
    box-sizing: border-box;
    min-height: 75px;
    padding: 8px 16px;
  }

  /* The logo is a fixed 190x50 sprite; zoom scales the sprite and its box. */
  .public-responsive #header .site-header__brand {
    flex: 0 0 auto;
    zoom: 0.66;
  }

  .public-responsive #header .site-header__nav {
    flex-wrap: nowrap;
    gap: 12px;
    height: auto; /* main.css: .inner .site-nav { height: 75px } */
    margin-inline-start: auto;
    line-height: normal;
  }

  .public-responsive #header .site-header__nav a {
    margin: 0;
    font-size: 14px;
    white-space: nowrap;
  }

  .public-responsive #header .site-header__nav a.button {
    padding: 0 12px;
    line-height: 32px;
  }

  /* Footer: mobile.css right-aligns it and sets 20px/36px type for the app's
     single-column mobile footer. On public pages use two left-aligned
     columns of ordinary-sized links. */
  .public-responsive #footerWrap .footerContent {
    box-sizing: border-box;
    width: auto;
    padding: 0 16px;
    text-align: left;
  }

  .public-responsive #footerWrap .site-footer__columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
    padding-top: 32px;
  }

  .public-responsive #footerWrap .site-footer__columns .footerColumn {
    width: auto;
    margin: 0 0 28px;
  }

  .public-responsive #footerWrap .footerColumn.blogposts {
    grid-column: 1 / -1;
  }

  .public-responsive #footerWrap .footerColumn h3 {
    margin-bottom: 8px;
  }

  .public-responsive #footerWrap .footerColumn div,
  .public-responsive #footerWrap .footerColumn a {
    font-size: 15px;
    line-height: 1.9;
  }

  .public-responsive #footerWrap .footerBottom .footerContent {
    text-align: center;
  }

  .public-responsive #footerWrap .footerBottom .footerContent,
  .public-responsive #footerWrap .footerBottom .footerContent * {
    font-size: 12px;
    line-height: 1.8;
  }
}

@media screen and (max-width: 360px) {
  /* Smallest phones: let the links take their own row under the logo. */
  .public-responsive #header .site-header__nav {
    flex: 1 0 100%;
    justify-content: flex-start;
  }

  .public-responsive #footerWrap .site-footer__columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------------------------
   Phones and small tablets: page content.
   ------------------------------------------------------------------------ */

@media screen and (max-width: 768px) {
  /* Page titles that sit directly in the layout (coming_soon, FAQ). */
  .public-responsive .main_title {
    padding: 16px 16px 0;
    font-size: 28px;
    line-height: 1.2;
  }

  .public-responsive .public-copy-inner .main_title {
    padding-inline: 0;
  }

  /* FAQ question headings wrap on phones; give the lines room. */
  .public-responsive .bigletter {
    font-size: 21px;
    line-height: 1.25;
  }

  /* Terms: the desktop 20% right gutter and 13px copy are too cramped. */
  .public-responsive .terms-of-service {
    padding-right: 15px;
  }

  .public-responsive .terms-of-service p {
    font-size: 15px;
    line-height: 1.6;
  }

  /* Home hero: on desktop the copy is pinned to the bottom of a fixed-height
     photo. On phones the copy flows normally and the photo stretches behind
     it. main.css forces `.home-hero.hero-image { height: 300px !important }`
     at this width, so overriding it needs !important too (documented
     exception per HTML_CSS_MODERNIZATION_TODO.md). */
  .public-responsive .home-hero-copy {
    position: relative;
    box-sizing: border-box;
    min-height: 0;
    padding: 104px 20px 44px;
  }

  .public-responsive .home-hero-copy-inner {
    position: static;
    padding: 0;
  }

  .public-responsive .home-hero.hero-image {
    position: absolute;
    inset: 0;
    height: auto !important;
    min-height: 0 !important;
  }

  .public-responsive .home-hero-copy-inner h1 {
    margin-bottom: 16px;
    font-size: clamp(48px, 15vw, 72px);
    line-height: 0.9;
  }

  .public-responsive .home-hero-copy-inner p span {
    display: inline;
    font-size: 17px;
    line-height: 1.5;
  }

  /* Home testimonials: desktop uses 125-215px side padding to stagger the
     quotes; on phones that leaves no room for the text. */
  .public-responsive .testimonial-wrapper.short,
  .public-responsive .testimonial-wrapper.medium,
  .public-responsive .testimonial-wrapper.long {
    padding: 0 16px;
  }

  .public-responsive .testimonial-wrapper .testimonial .quote {
    font-size: 18px;
    line-height: 1.55;
  }

  .public-responsive .testimonial-wrapper .attribution {
    margin-left: 20px;
    font-size: 17px;
  }

  .public-responsive .section-header {
    margin: 40px auto 28px;
    padding: 0 16px;
    font-size: 30px;
    line-height: 1.2;
  }

  /* Home "Why choose" columns: one per row; the round photos keep their
     250px size but must not exceed the column. */
  .public-responsive .three-col-wrapper .column {
    box-sizing: border-box;
    width: auto;
    margin: 0;
    padding: 0 16px;
  }

  .public-responsive .three-col-wrapper .column .thumb-wrapper {
    max-width: 100%;
    margin-inline: auto;
  }

  /* Call-to-action blurbs under the home sections are a fixed 430px. */
  .public-responsive .iti p {
    width: auto;
    max-width: 430px;
    padding: 0 16px;
  }

  /* Home "Wondering how it works?": main.css forces this band (copy, photo
     and its inner wrapper) to 300px with !important, which clips the copy on
     phones. Same documented !important exception as the home hero. */
  .public-responsive .demo-hero-section .signup-hero-copy-2 {
    box-sizing: border-box;
    height: auto !important;
    min-height: 0 !important;
    padding: 48px 16px;
  }

  .public-responsive .demo-hero-section .hero-image.signup-hero-image-2 {
    bottom: 0;
    height: auto !important;
    min-height: 0 !important;
  }

  .public-responsive .demo-hero-section .hero-inner.hero-inner-3 {
    height: 100% !important;
    min-height: 0 !important;
  }

  .public-responsive .signup-hero-copy-2 h1.section-header.demo-hub-blurb {
    margin: 0 0 28px;
  }

  .public-responsive .signup-hero-copy-2 a.big.button {
    margin-bottom: 0;
  }

  /* Outline call-to-action buttons (.big.button) are 60px-padded, 26-32px
     uppercase on one 72-80px line; let long labels wrap inside the screen. */
  .public-responsive a.big.button {
    box-sizing: border-box;
    max-width: 100%;
    padding: 14px 24px;
    font-size: 22px;
    line-height: 1.3;
  }

  /* Mayflower landing pages: the 800x350 headline is a sprite cut from an
     800x800 image, so scale the box and the sprite together (zoom keeps the
     background-position offsets in step). The banner copy is a fixed 1000px. */
  .public-responsive .mayflower-hero-header {
    zoom: 0.9;
  }

  .public-responsive .mayflower-hero-info p {
    width: auto;
    padding: 0 16px;
    font-size: 18px;
  }

  .public-responsive .mayflower-import-terms {
    box-sizing: border-box;
    width: auto;
    height: auto;
    margin: 15px 16px;
  }

  /* Hero pages with a centered heading over a photo (login, check_email):
     drop the 700px desktop minimum so the photo ends with the content. */
  .public-responsive .signup-hero-copy {
    min-height: 0;
    padding-bottom: 40px;
  }

  .public-responsive .signup-hero-copy h1 {
    margin: 28px 16px 24px;
    font-size: 28px;
    line-height: 1.2;
  }

  /* Login card (user_sessions/new): a fixed 600px panel on desktop. */
  .public-responsive .login-wrapper {
    box-sizing: border-box;
    width: auto;
    margin: 0 16px 24px;
    padding: 22px 18px 24px;
    border-radius: 12px;
  }

  .public-responsive .login-wrapper .password-instructions {
    font-size: 15px;
    line-height: 1.5;
  }

  .public-responsive .login-wrapper .translucent-form label {
    margin-left: 2px;
  }

  .public-responsive .login-wrapper .translucent-form input[type=text],
  .public-responsive .login-wrapper .translucent-form input[type=password] {
    box-sizing: border-box;
    width: 100%;
    margin-right: 0;
  }

  /* Password row: the Show Password toggle sits beside the field instead of
     being absolutely positioned over a 85%-wide input. */
  .public-responsive .login-wrapper .translucent-form .form-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 8px;
    margin-bottom: 15px;
  }

  .public-responsive .login-wrapper .translucent-form .form-line label {
    flex: 0 0 100%;
  }

  .public-responsive .login-wrapper .translucent-form input#password {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
  }

  .public-responsive .login-wrapper .translucent-form a.show-password {
    position: static;
    flex: 0 0 auto;
    align-self: stretch;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    width: auto;
    padding: 0 12px;
    font-size: 13px;
    white-space: nowrap;
  }

  .public-responsive .login-wrapper .translucent-form a.show-password br {
    display: none;
  }

  .public-responsive .login-wrapper .reset-pass-link {
    margin: 0 0 6px;
    font-size: 15px;
  }

  .public-responsive .login-wrapper .translucent-form input[type=submit].big-button {
    display: block;
    float: none;
    width: 100%;
    margin: 16px 0 0;
  }

  .public-responsive .no-account-link {
    margin: 0 16px;
    padding: 8px 0;
  }

  /* coming_soon: a 60px message in a fixed 380px box clips on phones. */
  .public-responsive .coming-soon-message {
    height: auto;
    margin: 32px 0 48px;
    padding: 0 16px;
    font-size: 28px;
    line-height: 1.3;
  }
}

/* Smallest widths, after the 768px rules so these win. */
@media screen and (max-width: 480px) {
  .public-responsive .mayflower-hero-header {
    zoom: 0.45;
  }
}

@media screen and (max-width: 360px) {
  .public-responsive .mayflower-hero-header {
    zoom: 0.38;
  }
}

/* ------------------------------------------------------------------------
   Signup wizard (signups/new) on phones.

   Desktop choreography: three plan cards in a fixed 1000px row; choosing one
   slides it right (translateX 637px) while the others fly off 5000px, and the
   form box (parked at left: -5000px) slides in beside it. Its three steps sit
   on a 2500px strip that slides 605px per step. None of that fits a phone.

   On phones the same state classes from signups_controller.js drive a stacked
   flow instead, the way .subscription-checkout already lays out this markup:
   - no plan chosen: the three cards stacked;
   - plan chosen (.signup-box.plan-selected): the other cards (.exit-*) are
     removed, the chosen card collapses to its name, price and Change Plan,
     and the form box sits below it in normal flow;
   - steps: only the current step's heading and panel are shown, selected by
     .step-1-complete / .step-2-complete on the .pricing container.
   ------------------------------------------------------------------------ */

@media screen and (max-width: 768px) {
  .public-responsive .signup-flow-container h2 {
    padding: 0 16px;
    font-size: 19px;
    line-height: 1.4;
  }

  /* Cards: stacked, full width, without the desktop stagger. */
  .public-responsive .signup-flow-container .pricing.three-col {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: auto;
    left: 0;
    margin-top: 28px;
    padding: 0; /* .inner / .hero-copy already give the 15px gutters */
  }

  .public-responsive .signup-flow-container .pricing.three-col > .column {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    top: 0;
    left: 0;
    transform: none;
    transition: none;
  }

  .public-responsive .signup-flow-container .pricing > .column.exit-left,
  .public-responsive .signup-flow-container .pricing > .column.exit-right,
  .public-responsive .signup-flow-container .pricing > .column[hidden] {
    display: none;
  }

  /* The chosen card becomes a compact summary above the form. Its feature
     list and the testimonial/credibility panels (which slide in from
     off-screen on desktop) are dropped. */
  .public-responsive .signup-flow-container .pricing > .column:is(.selected-right, .selected-left) {
    padding: 12px 0 16px;
    scroll-margin-top: 12px;
  }

  .public-responsive .signup-flow-container .pricing > .column:is(.selected-right, .selected-left) > p,
  .public-responsive .signup-flow-container .pricing > .column:is(.selected-right, .selected-left) .column-content-wrap {
    display: none;
  }

  .public-responsive .signup-flow-container .pricing > .column:is(.selected-right, .selected-left) h3 {
    margin-top: 6px;
  }

  /* Form box: hidden until a plan is chosen, then in flow below the card. */
  .public-responsive .signup-flow-container .signup-box:not(.plan-selected) {
    display: none;
  }

  .public-responsive .signup-flow-container .pricing.three-col .signup-box {
    position: static;
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0 0 24px;
    padding: 22px 16px 24px;
    transform: none;
    transition: none;
    scroll-margin-top: 12px;
  }

  /* Steps: one at a time instead of a sliding 2500px strip. The selector has
     to outrank main.css's per-step slides, the most specific of which is
     .step-1-complete.step-2-complete.step-3-complete .signup-box .signup-steps-wrapper. */
  .public-responsive .signup-flow-container .pricing.three-col .signup-box :is(.signup-steps-header, .signup-steps-wrapper) {
    width: auto;
    transform: none;
    transition: none;
  }

  .public-responsive .signup-flow-container .signup-header,
  .public-responsive .signup-flow-container .signup-form-wrapper {
    display: none;
    float: none;
    width: auto;
    min-height: 0;
    margin: 0;
  }

  .public-responsive .signup-flow-container .pricing:not(.step-1-complete) :is(.signup-header-1, .signup-step-1),
  .public-responsive .signup-flow-container .pricing.step-1-complete:not(.step-2-complete) :is(.signup-header-2, .signup-step-2),
  .public-responsive .signup-flow-container .pricing.step-1-complete.step-2-complete :is(.signup-header-3, .signup-step-3) {
    display: block;
  }

  .public-responsive .signup-flow-container .signup-header h3 {
    font-size: 21px;
    line-height: 1.3;
  }

  /* Step indicator: 70px circles with 127px connectors need 465px. */
  .public-responsive .signup-flow-container .signup-steps-glyphs {
    grid-template-columns: 56px minmax(12px, 1fr) 56px minmax(12px, 1fr) 56px;
    width: auto;
    max-width: 320px;
    margin: 12px auto 4px;
  }

  .public-responsive .signup-flow-container .steps-spacer {
    width: auto;
    margin: 75px 6px 0;
  }

  .public-responsive .signup-flow-container .signup-step-glyph {
    width: 56px;
    zoom: 0.8;
  }

  /* Step 1: the Hub name field and the Step 2 button share a flex row on
     desktop; stack them. */
  .public-responsive .signup-flow-container #hub_name_form {
    display: block;
  }

  /* Fields: single column, full width. */
  .public-responsive .signup-flow-container .translucent-form .hub-name,
  .public-responsive .signup-flow-container .translucent-form .form-element {
    width: auto;
    margin-right: 0;
  }

  .public-responsive .signup-flow-container .translucent-form input {
    box-sizing: border-box;
    width: 100%;
  }

  .public-responsive .signup-flow-container .signup-form-wrapper > p {
    font-size: 15px;
    line-height: 1.5;
  }

  /* Back / forward buttons share the row; the charge note goes below. */
  .public-responsive .signup-flow-container .subscribe-button-wrapper .wizard-action {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 12px;
  }

  .public-responsive .signup-flow-container .subscribe-button-wrapper .wizard-charge-message {
    flex: 0 0 100%;
    margin: 6px 0 0;
    text-align: center;
  }

  .public-responsive .signup-flow-container .bonus-pitch-blurb {
    padding: 0 16px;
  }
}
