/* ==========================================================================
   Checkout Responsive Styles
   Only active below 768px and 480px breakpoints.
   Desktop layout is completely unaffected.
   ========================================================================== */

/* ---------- Primary Breakpoint: 768px ---------- */
@media screen and (max-width: 768px) {

  /* --- Global overrides --- */
  body#inner-page {
    min-width: 0 !important;
  }

  .container {
    width: 100% !important;
    box-sizing: border-box;
    padding: 0 15px;
  }

  /* --- Header: logo left, nav right, same line --- */
  #page-header {
    min-width: 0 !important;
    height: auto !important;
    margin: 0 !important;
    padding: 10px 12px;
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }

  /* Remove clearfix pseudo-elements so they don't become flex items */
  #page-header::before,
  #page-header::after {
    display: none !important;
  }

  #page-header .checkout-logo {
    margin: 0 !important;
    max-width: 130px;
    height: auto;
    position: static;
  }

  #page-header ul {
    display: inline !important;
    margin: 0;
    position: static;
  }

  #page-header li {
    margin: 0 0 0 8px;
    font-size: 12px;
  }

  /* --- Progress Bar: clean text row, no CSS arrows --- */
  #checkout_progress {
    border-bottom: 2px solid #eee;
  }

  #checkout_progress .container {
    padding: 0;
    overflow: hidden;
  }

  #checkout_progress ul {
    display: flex !important;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .arrow_box,
  .arrow_box_last {
    float: none !important;
    width: auto !important;
    height: auto !important;
    flex: 1;
    padding: 12px 4px 10px !important;
    font-size: 12px;
    text-align: center;
    background: transparent !important;
    color: #b0b8c0;
  }

  /* <a> tags wrapping <li> on non-summary pages must also flex */
  #checkout_progress ul > a {
    flex: 1;
    text-decoration: none;
  }

  /* Hide CSS arrow pseudo-elements entirely on mobile */
  .arrow_box:after,
  .arrow_box:before {
    display: none !important;
  }

  /* Active step gets a bottom highlight */
  .arrow_box_selected {
    color: #00abff !important;
    font-weight: bold;
    border-bottom: 3px solid #00abff;
    padding-bottom: 8px !important;
  }

  /* Selectable (completed) steps */
  .arrow_box_selectable {
    color: #5b6f82 !important;
  }

  .arrow_box_first {
    padding-left: 4px !important;
  }

  /* Hide "Completion" step on mobile */
  .arrow_box_last {
    display: none !important;
  }

  /* --- Shared: float/width reset for stacking --- */
  .co-main-col,
  .co-summary-title,
  .co-summary-cta,
  .co-print-design,
  .co-delivery-opts,
  .co-color-table {
    float: none !important;
    width: 100% !important;
  }

  /* Hide Order Overview sidebar on mobile */
  .co-sidebar {
    display: none !important;
  }

  /* Hide top "Proceed with Checkout" on summary (keep bottom one) */
  .co-summary-title + .co-summary-cta {
    display: none !important;
  }

  .co-summary-cta {
    text-align: center;
    margin-top: 5px;
  }

  /* Hide quantities disclaimer on mobile */
  .co-qty-note {
    display: none;
  }

  .co-print-design {
    border-right: none !important;
    border-bottom: 1px solid #eee;
    padding-bottom: 20px;
    margin-bottom: 20px;
  }

  .co-delivery-opts {
    padding-left: 0 !important;
  }

  .co-color-table {
    margin-bottom: 15px;
  }

  /* --- Content padding: tighter on mobile --- */
  .essay.cf {
    padding: 20px 15px !important;
  }

  /* --- Page headings: scale down for mobile --- */
  h1.article,
  .essay h1.article {
    font-size: 22px !important;
    margin-bottom: 4px;
  }

  .biggrey {
    font-size: 16px;
    margin: 18px 0 8px;
  }

  /* --- Images --- */
  .co-print-design div[style*="float"] {
    float: none !important;
    display: inline-block;
    vertical-align: top;
    width: 48%;
    margin: 0 2px 8px 0 !important;
  }

  .co-print-design img {
    max-width: 100%;
    height: auto;
  }

  /* --- Order Summary Table --- */
  .order_summary_table {
    width: 100% !important;
  }

  .order_summary_table td {
    padding: 8px 4px;
    font-size: 14px;
    line-height: 1.5;
  }

  /* Quantity inputs: bigger touch targets */
  .qty_box {
    width: auto;
    min-width: 52px;
    float: left;
    padding: 4px 6px 4px 0;
    font-size: 13px;
    text-align: center;
  }

  .qty_form {
    width: 38px;
    padding: 6px 4px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    -webkit-appearance: none;
  }

  /* --- Form Tables (shipping, payment) --- */
  .checkout_table {
    width: 100%;
    border-spacing: 0;
  }

  .checkout_table td {
    display: block;
    width: 100% !important;
    padding: 3px 0 6px;
  }

  /* Keep First Name / Last Name side by side */
  .co-name-row {
    display: flex !important;
    gap: 10px;
  }

  .co-name-row td {
    display: block !important;
    flex: 1;
    width: auto !important;
  }

  /* Keep radio button + label on same line */
  .checkout_table td[width="20"] {
    display: inline-block !important;
    width: 24px !important;
    vertical-align: top;
    padding-top: 2px;
  }

  .checkout_table td[width="20"] + td {
    display: inline-block !important;
    width: calc(100% - 32px) !important;
    vertical-align: top;
  }

  .checkout_table .plain_form,
  .checkout_table input[type="text"],
  .checkout_table select {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
  }

  /* All form inputs: consistent sizing */
  .plain_form {
    font-size: 16px !important;
    padding: 8px !important;
    border-radius: 4px;
  }

  select.plain_form {
    padding: 7px 8px !important;
    height: auto;
  }

  /* Keep City / State / Zip in a compact row */
  .co-city-state-zip {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0 10px;
  }

  .co-city-state-zip td {
    display: block !important;
    padding: 4px 0 8px;
  }

  /* City takes full width */
  .co-city-state-zip td:first-child {
    width: 100% !important;
    flex: 0 0 100%;
  }

  /* State and Zip side by side */
  .co-city-state-zip td:nth-child(2) {
    flex: 1;
    width: auto !important;
  }

  .co-city-state-zip td:nth-child(3) {
    flex: 0 0 35%;
    width: auto !important;
  }

  /* Hide empty 4th td */
  .co-city-state-zip td:nth-child(4) {
    display: none !important;
  }

  #stateinfo,
  #validateaddress_output {
    width: 100% !important;
  }

  #instructions {
    width: 100% !important;
    box-sizing: border-box;
  }

  /* --- Section headings: subtle divider for visual hierarchy --- */
  .essay h2.biggrey {
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
    margin-top: 22px;
  }

  /* First section heading after h1 doesn't need top margin */
  h1.article + .biggrey,
  h1.article + .co-summary-cta + br + .biggrey {
    margin-top: 10px;
  }

  /* --- Buttons --- */
  .checkout_button {
    width: 100%;
    box-sizing: border-box;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 14px 17px !important;
    font-size: 17px !important;
  }

  /* --- Delivery options table --- */
  .co-delivery-opts table {
    width: 100%;
  }

  .co-delivery-opts td {
    font-size: 14px;
    line-height: 1.5;
    padding: 4px 2px;
  }

  /* Guaranteed dates: smaller on mobile */
  .co-delivery-opts td[align="right"] {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
  }

  /* Voucher code section */
  .co-delivery-opts #inputcoupon {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #eee;
  }

  /* --- Total price: more prominent --- */
  .co-total-row {
    border-top: 2px solid #e0e0e0;
    margin-top: 8px;
  }

  .co-total-row td {
    padding-top: 12px !important;
    vertical-align: middle;
  }

  .co-total-row .biggrey {
    border-bottom: none;
    margin: 0 !important;
    padding-bottom: 0;
  }

  .co-total-row h2.biggrey {
    font-size: 24px !important;
    font-weight: bold !important;
  }

  /* Override inline float on card number wrapper in legacy payment form */
  .co-main-col .checkout_table div[style*="float"] {
    float: none !important;
    width: 100%;
  }

  #payment-element {
    max-width: 100% !important;
  }

  /* Payment page: terms checkbox */
  #agreementcheckbox {
    width: 18px;
    height: 18px;
    vertical-align: middle;
  }

  /* Hide "Please allow up to a minute" text until order is submitted */
  #orderbutton > span {
    display: none;
  }

  /* --- Instructions page: ink color delete links more visible --- */
  .co-color-table a[style*="color:#ddd"] {
    color: #c0392b !important;
    font-size: 12px;
    text-decoration: underline;
  }

  /* Instructions page: ink color swatch cells */
  .co-color-table td {
    padding: 4px 4px;
    vertical-align: middle;
  }

  /* --- Completion Page --- */

  /* Table layouts -> stacked blocks */
  .co-timeline,
  .co-order-detail,
  .co-referral,
  .co-quick-links {
    display: block !important;
  }

  .co-timeline > div {
    display: block !important;
  }

  .co-timeline-step,
  .co-quick-link {
    width: 100% !important;
    border-bottom: 1px solid #eee;
  }

  .co-timeline-step:last-child,
  .co-quick-link:last-child {
    border-bottom: none;
  }

  .co-quick-link {
    display: block !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom-color: #e0e0e0;
    padding: 12px 0 !important;
  }

  .co-order-images {
    display: block !important;
    width: 100% !important;
    padding-right: 0 !important;
    text-align: center;
    margin-bottom: 15px;
  }

  .co-order-images img {
    max-width: 45%;
    height: auto;
  }

  .co-order-info {
    display: block !important;
    width: 100% !important;
  }

  .co-order-info table {
    width: 100%;
  }

  .co-referral > div {
    display: block !important;
    width: 100% !important;
    text-align: center;
    padding: 10px 0 !important;
  }

  #referral-link {
    width: 100% !important;
    box-sizing: border-box;
    max-width: 100%;
  }

  /* Override inline display:inline-block on referral input wrapper */
  .co-referral div[style*="inline-block"] {
    display: block !important;
    width: 100%;
  }

  .co-order-detail + div {
    word-wrap: break-word;
  }

  /* Completion page: tighten confirmation banner padding */
  .essay .co-timeline-step div[style*="width:36px"] {
    display: inline-block;
    vertical-align: middle;
    margin: 0 10px 0 0 !important;
  }

  /* Completion page: inline timeline steps */
  .co-timeline-step {
    text-align: left !important;
    display: flex !important;
    align-items: center;
    gap: 12px;
  }

  .co-timeline-step > div:first-child {
    flex-shrink: 0;
  }

  /* --- Footer --- */
  .essay + div,
  body#inner-page > .container + div {
    padding: 10px 15px;
    font-size: 12px;
  }
}


/* ---------- Secondary Breakpoint: 480px ---------- */
@media screen and (max-width: 480px) {

  .container {
    padding: 0 10px;
  }

  .essay.cf {
    padding: 15px 10px !important;
  }

  /* Slightly smaller step text */
  .arrow_box,
  .arrow_box_last {
    font-size: 11px;
    padding: 10px 2px 8px !important;
  }

  /* Tighter page headings */
  h1.article,
  .essay h1.article {
    font-size: 20px !important;
  }

  .biggrey {
    font-size: 15px;
  }

  /* Quantity boxes: wrap properly */
  .qty_box {
    min-width: 48px;
    font-size: 12px;
  }

  .qty_form {
    width: 34px;
    padding: 5px 3px;
    font-size: 13px;
  }

  #page-header .checkout-logo {
    max-width: 110px;
  }

  #page-header li {
    font-size: 11px;
  }

  .co-order-images img {
    max-width: 42%;
  }

  #referral-link {
    font-size: 12px;
    padding-right: 70px !important;
  }

  /* Completion page: smaller banner */
  .essay div[style*="width:64px"][style*="border-radius:50%"] {
    width: 52px !important;
    height: 52px !important;
    line-height: 52px !important;
  }

  .essay div[style*="width:64px"] span {
    font-size: 26px !important;
  }
}
