/* Keep WooCommerce clearfix pseudo-elements out of CSS grids. */
body.woocommerce-account main .woocommerce::before,
body.woocommerce-account main .woocommerce::after,
body.woocommerce-account main .addresses::before,
body.woocommerce-account main .addresses::after {
  content: none;
  display: none;
}

body.logged-in.woocommerce-account main .woocommerce {
  display: block;
}

body.logged-in.woocommerce-account main .page-entry__content > .woocommerce,
body.logged-in.woocommerce-account main .page-entry > .woocommerce {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 40px;
  width: 100%;
  min-width: 0;
}

body.woocommerce-account main .woocommerce > .woocommerce-MyAccount-navigation,
body.woocommerce-account main .woocommerce > .woocommerce-MyAccount-content {
  float: none;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

body.woocommerce-account main .woocommerce > .woocommerce-MyAccount-navigation {
  grid-column: 1;
}

body.woocommerce-account main .woocommerce > .woocommerce-MyAccount-content {
  grid-column: 2;
  padding-top: 24px;
  border-top: 8px solid var(--nictek-orange, #ff5a1f);
  overflow-wrap: anywhere;
}

body.woocommerce-account main .woocommerce > .woocommerce-notices-wrapper {
  grid-column: 1 / -1;
}

body.woocommerce-account main .woocommerce-notices-wrapper:empty {
  display: none;
}

body.woocommerce-account main .addresses {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  width: 100%;
}

body.woocommerce-account main .addresses > .woocommerce-Address {
  float: none;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 28px;
}

body.woocommerce-account main .woocommerce-Address-title h2,
body.woocommerce-account main .woocommerce-Address-title h3 {
  margin: 0 40px 20px 0;
  font-size: 23px;
  line-height: 1.4;
}

body.woocommerce-account main .woocommerce-Address address {
  min-height: 100px;
  margin: 0;
  overflow-wrap: anywhere;
}

body.woocommerce-account main .woocommerce-MyAccount-content > form {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

body.woocommerce-account main .woocommerce-MyAccount-content form .form-row {
  min-width: 0;
}

body.woocommerce-account main .woocommerce-MyAccount-content input.input-text,
body.woocommerce-account main .woocommerce-MyAccount-content select,
body.woocommerce-account main .woocommerce-MyAccount-content textarea,
body.woocommerce-account main .select2-container {
  max-width: 100%;
}

body.woocommerce-account main .woocommerce-info,
body.woocommerce-account main .woocommerce-message {
  display: flow-root;
  width: 100%;
  margin: 0 0 24px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

body.woocommerce-account main .woocommerce-info .button,
body.woocommerce-account main .woocommerce-message .button {
  margin: 0 0 8px 18px;
  text-align: center;
  white-space: normal;
}

body.woocommerce-account main table.my_account_orders {
  width: 100%;
  table-layout: auto;
}

body.woocommerce-account main form.lost_reset_password {
  width: min(100%, 760px);
  min-width: 0;
}

body.woocommerce-account main form.lost_reset_password .form-row-first {
  float: none;
  width: min(100%, 560px);
}

/* Four equal-height cart recommendations, preserving each image and link. */
body.woocommerce-cart .wp-block-woocommerce-empty-cart-block .wc-block-grid__products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 28px;
  margin: 24px 0 0;
  padding: 0;
}

body.woocommerce-cart .wp-block-woocommerce-empty-cart-block .wc-block-grid__product {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

body.woocommerce-cart .wc-block-grid__product-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
}

body.woocommerce-cart .wc-block-grid__product-image {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  place-items: center;
  margin: 0 0 16px;
}

body.woocommerce-cart .wc-block-grid__product-image img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

body.woocommerce-cart .wc-block-grid__product-title {
  min-height: 3.2em;
  margin: 0;
  line-height: 1.6;
}

body.woocommerce-cart .wc-block-grid__product-price {
  margin: 12px 0;
}

body.woocommerce-cart .wc-block-grid__product-add-to-cart {
  margin: auto 0 0;
  padding-top: 4px;
}

/* Align related-product prices and buttons even when names wrap. */
.single-product .related.products ul.products {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 28px;
  width: 100%;
  padding: 0;
}

.single-product .related.products ul.products::before,
.single-product .related.products ul.products::after {
  content: none;
  display: none;
}

.single-product .related.products ul.products li.product {
  display: flex;
  flex-direction: column;
  float: none;
  width: 100% !important;
  min-width: 0;
  margin: 0 !important;
}

.single-product .related.products li.product .woocommerce-LoopProduct-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.single-product .related.products li.product a img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
}

.single-product .related.products .woocommerce-loop-product__title {
  min-height: 3.2em;
  line-height: 1.6;
}

.single-product .related.products li.product .price {
  margin-top: auto;
  margin-bottom: 0;
}

.single-product .related.products li.product > .button {
  align-self: flex-start;
  margin-top: 18px;
}

@media (max-width: 1024px) {
  /* The sticky header's backdrop filter contains its fixed-position menu. */
  .site-header .site-navigation {
    top: var(--nictek-menu-top, 72px);
    right: 0;
    bottom: auto;
    width: min(410px, 100vw);
    height: var(--nictek-menu-height, calc(100dvh - 72px));
    max-height: var(--nictek-menu-height, calc(100dvh - 72px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 24px 36px;
    background: #fff;
    box-sizing: border-box;
    transform: translateY(-12px);
  }

  .site-header .site-navigation.is-open {
    transform: none;
  }

  .site-header .site-navigation > ul {
    width: 100%;
    min-width: 0;
  }

  .site-header .site-navigation .site-menu > li > a {
    white-space: normal;
  }
}

@media (max-width: 760px) {
  body.woocommerce-account .page-main,
  body.woocommerce-account .page-entry,
  body.woocommerce-account .page-entry__content {
    min-width: 0;
    max-width: 100%;
  }

  body.woocommerce-account .page-entry {
    width: calc(100% - 28px);
    padding: 36px 0 56px;
  }

  body.logged-in.woocommerce-account main .page-entry__content > .woocommerce,
  body.logged-in.woocommerce-account main .page-entry > .woocommerce {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  body.woocommerce-account main .woocommerce > .woocommerce-MyAccount-navigation,
  body.woocommerce-account main .woocommerce > .woocommerce-MyAccount-content {
    grid-column: 1 / -1;
  }

  body.woocommerce-account main .woocommerce-MyAccount-navigation ul {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    width: 100%;
  }

  body.woocommerce-account main .woocommerce-MyAccount-navigation a {
    padding: 10px 12px;
    white-space: normal;
    font-size: 14px;
    background: #f4f5f6;
    border-radius: 6px;
  }

  body.woocommerce-account main .woocommerce-MyAccount-navigation .is-active a {
    color: #fff;
    background: var(--nictek-orange, #ff5a1f);
  }

  body.woocommerce-account main .addresses {
    grid-template-columns: minmax(0, 1fr);
  }

  body.woocommerce-account main .woocommerce-MyAccount-content {
    padding-right: 0;
    padding-left: 0;
    box-shadow: none;
  }

  body.woocommerce-account main .woocommerce-MyAccount-content .form-row-first,
  body.woocommerce-account main .woocommerce-MyAccount-content .form-row-last {
    float: none;
    width: 100%;
  }

  body.woocommerce-account main .woocommerce-info .button,
  body.woocommerce-account main .woocommerce-message .button {
    float: none;
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 0 0 12px;
  }

  body.woocommerce-account main form.login,
  body.woocommerce-account main form.register {
    min-width: 0;
    padding: 28px 20px;
  }

  body.woocommerce-account main .u-columns,
  body.woocommerce-account main .u-column1,
  body.woocommerce-account main .u-column2 {
    min-width: 0;
    max-width: 100%;
  }

  .single-product .related.products ul.products,
  body.woocommerce-cart .wp-block-woocommerce-empty-cart-block .wc-block-grid__products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 16px;
  }

  .site-header .site-navigation {
    top: var(--nictek-menu-top, 64px);
    height: var(--nictek-menu-height, calc(100dvh - 64px));
    max-height: var(--nictek-menu-height, calc(100dvh - 64px));
  }

  .search-panel {
    inset: 0;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-y: auto;
    padding: 16px 0;
  }

  .search-panel .search-panel__dialog {
    width: calc(100% - 28px);
    min-width: 0;
    max-width: 560px;
    max-height: calc(100dvh - 64px);
    margin: 40px auto 0;
    padding: 20px;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .search-panel .site-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    width: 100%;
    min-width: 0;
  }

  .search-panel .site-search-form input[type="search"] {
    width: 100%;
    min-width: 0;
    padding: 12px 8px;
  }

  .search-panel .site-search-form button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .search-panel .search-panel__heading p {
    margin-right: 10px;
    font-size: 18px;
  }

  .search-panel .search-panel__close {
    flex: 0 0 38px;
  }
}

/* v1.1: let shared mobile grid/flex children shrink to the viewport. */
@media (max-width: 1024px) {
  body.theme-nictek-code-theme .site-header__inner {
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-width: 0;
    max-width: 100%;
  }

  body.theme-nictek-code-theme .site-brand,
  body.theme-nictek-code-theme .header-actions,
  body.theme-nictek-code-theme .site-main,
  body.theme-nictek-code-theme .page-entry,
  body.theme-nictek-code-theme .page-entry__content,
  body.theme-nictek-code-theme .nictek-shop-intro > *,
  body.theme-nictek-code-theme .nictek-product-card > *,
  body.theme-nictek-code-theme .contact-form-section > *,
  body.theme-nictek-code-theme .contact-form-row > *,
  body.theme-nictek-code-theme .site-footer__grid > * {
    min-width: 0;
  }

  body.theme-nictek-code-theme .site-main {
    max-width: 100%;
  }

  body.theme-nictek-code-theme .site-main form input:not([type="hidden"]),
  body.theme-nictek-code-theme .site-main form select,
  body.theme-nictek-code-theme .site-main form textarea {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.theme-nictek-code-theme .site-footer a,
  body.theme-nictek-code-theme .footer-contact p {
    overflow-wrap: anywhere;
  }

  /* WooCommerce block checkout: constrain the layout, not payment controls. */
  body.woocommerce-checkout .wp-block-woocommerce-checkout,
  body.woocommerce-checkout .wc-block-checkout,
  body.woocommerce-checkout .wc-block-components-sidebar-layout {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
    box-sizing: border-box;
  }

  body.woocommerce-checkout .wc-block-components-main,
  body.woocommerce-checkout .wc-block-components-sidebar,
  body.woocommerce-checkout .wc-block-checkout__main,
  body.woocommerce-checkout .wc-block-checkout__sidebar,
  body.woocommerce-checkout .wp-block-woocommerce-checkout-fields-block,
  body.woocommerce-checkout .wp-block-woocommerce-checkout-totals-block {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.woocommerce-checkout main fieldset,
  body.woocommerce-checkout .wc-block-components-address-form,
  body.woocommerce-checkout .wc-block-components-text-input,
  body.woocommerce-checkout .wc-block-components-combobox,
  body.woocommerce-checkout .wc-block-components-country-input,
  body.woocommerce-checkout .wc-block-components-state-input,
  body.woocommerce-checkout .wc-block-components-checkout-step__container,
  body.woocommerce-checkout .wc-block-components-checkout-step__content {
    min-width: 0;
    min-inline-size: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Also support stores using the classic WooCommerce checkout shortcode. */
  body.woocommerce-checkout form.checkout,
  body.woocommerce-checkout #customer_details,
  body.woocommerce-checkout #order_review,
  body.woocommerce-checkout #order_review_heading {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 767px) {
  body.theme-nictek-code-theme .site-footer__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.theme-nictek-code-theme .social-links {
    flex-wrap: wrap;
  }

  body.theme-nictek-code-theme .product-title-price-wrap,
  body.theme-nictek-code-theme .nictek-product-card__heading,
  body.theme-nictek-code-theme .nictek-product-card__actions {
    min-width: 0;
    flex-wrap: wrap;
  }

  body.theme-nictek-code-theme .product-title-price-wrap > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  body.woocommerce-checkout .page-entry {
    width: calc(100% - 28px);
    max-width: 100%;
    margin-right: auto;
    margin-left: auto;
  }

  body.woocommerce-checkout .wc-block-components-sidebar-layout {
    flex-direction: column;
  }

  body.woocommerce-checkout .wc-block-components-main,
  body.woocommerce-checkout .wc-block-components-sidebar {
    flex-basis: auto;
    width: 100%;
    padding-right: 0;
    padding-left: 0;
  }

  body.woocommerce-checkout form.checkout {
    display: block;
    width: 100%;
  }

  body.woocommerce-checkout form.checkout .col2-set,
  body.woocommerce-checkout form.checkout .col-1,
  body.woocommerce-checkout form.checkout .col-2,
  body.woocommerce-checkout form.checkout .form-row-first,
  body.woocommerce-checkout form.checkout .form-row-last {
    float: none;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.woocommerce-checkout .woocommerce-checkout-review-order-table {
    width: 100%;
    table-layout: fixed;
  }

  body.woocommerce-checkout .woocommerce-checkout-review-order-table th,
  body.woocommerce-checkout .woocommerce-checkout-review-order-table td,
  body.woocommerce-checkout .wc-block-components-product-name {
    overflow-wrap: anywhere;
  }
}
