/*
 * Sukha checkout extras: gift wrapping, personal message and the zine upsell.
 * Markup: includes/class-sce-frontend.php. Behaviour: assets/sce.js.
 * Type, colours and lines follow the cart drawer and the checkout of the theme.
 * No fixed heights on anything that holds text: blocks grow with their content.
 */

.sce {
  --sce-ink: var(--sk-ink, #222);
  --sce-soft: var(--sk-ink-soft, rgba(34, 34, 34, .7));
  --sce-line: #e6e6e6;
  --sce-field: #fafafa;
  --sce-field-line: #ddd;
  --sce-brown: #473028;
  --sce-red: #c52020;
  --sce-ease: var(--sk-ease, cubic-bezier(.22, .61, .36, 1));
  position: relative;
  color: var(--sce-ink);
  font-family: Roboto, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  text-align: left;
}

.sce[hidden],
.sce [hidden] {
  display: none !important;
}

.sce p {
  margin: 0;
}

.sce__nowrap {
  white-space: nowrap;
}

.sce__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Gift wrapping: checkbox with the price in the label ───────────────── */

/* With a photo: photo | checkbox, like the zine row; the message gets the full width below. */
.sce__wrap.has-image {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 16px;
  align-items: start;
}

.sce__wrap.has-image .sce__wrap-body {
  display: contents;
}

.sce__wrap.has-image .sce__message {
  grid-column: 1 / -1;
}

.sce__wrap.has-image .sce__message-inner {
  padding-left: 0;
}

.sce__check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.sce .sce__checkbox {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  padding: 0;
  background: var(--sce-field) center / 12px 12px no-repeat;
  border: 1px solid rgba(34, 34, 34, .42);
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 160ms var(--sce-ease), border-color 160ms var(--sce-ease);
}

.sce .sce__checkbox:hover {
  border-color: var(--sce-ink);
}

.sce .sce__checkbox:checked {
  background-color: var(--sce-brown);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6.3l2.5 2.5 5.1-5.6' fill='none' stroke='%23fff' stroke-width='1.4'/%3E%3C/svg%3E");
  border-color: var(--sce-brown);
}

.sce .sce__checkbox:focus-visible {
  outline: 1px solid var(--sce-ink);
  outline-offset: 2px;
}

.sce .sce__check-label {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  cursor: pointer;
}

/* ── Personal message: opens under the checkbox, aligned with its label ── */

.sce__message {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
}

.sce__message.is-open {
  grid-template-rows: 1fr;
  visibility: visible;
}

.sce--ready .sce__message {
  transition: grid-template-rows 320ms var(--sce-ease), visibility 0s linear 320ms;
}

.sce--ready .sce__message.is-open {
  transition: grid-template-rows 320ms var(--sce-ease), visibility 0s;
}

.sce__message-inner {
  min-height: 0;
  overflow: hidden;
  padding-left: 30px;
}

.sce .sce__field-label {
  display: block;
  margin: 0 0 6px;
  padding-top: 16px;
  color: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

.sce .sce__textarea {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 78px;
  margin: 0;
  padding: 8px 12px;
  background-color: var(--sce-field);
  border: 1px solid var(--sce-field-line);
  border-radius: 3px;
  color: var(--sce-ink);
  font: inherit;
  line-height: 20px;
  resize: vertical;
  transition: border-color 160ms var(--sce-ease);
}

.sce .sce__textarea:focus {
  border-color: var(--sce-soft);
  outline: 0;
}

.sce__meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-top: 6px;
  color: var(--sce-soft);
  font-size: 13px;
  line-height: 18px;
}

.sce__hint {
  flex: 1 1 auto;
  min-width: 0;
}

.sce__count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Zine: one quiet row, built like a cart line ───────────────────────── */

.sce__zine {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.sce__wrap:not([hidden]) + .sce__zine {
  margin-top: 24px;
}

/* Product photo in its own proportions (Sophie's are landscape duo pictures). */
.sce .sce__image {
  flex: 0 0 auto;
  width: 88px;
  max-width: none;
  height: auto;
  background-color: var(--sk-frame, #ddd4c6);
}

.sce__zine-body {
  flex: 1 1 auto;
  min-width: 0;
}

.sce__zine-text {
  padding-top: 6px;
  color: var(--sce-soft);
}

.sce .sce__button {
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  margin: 12px 0 0;
  padding: 7px 20px;
  background-color: transparent;
  border: 1px solid var(--sce-brown);
  border-radius: 1px;
  color: var(--sce-brown);
  font: inherit;
  font-size: 13px;
  line-height: 20px;
  letter-spacing: .02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 200ms var(--sce-ease), color 200ms var(--sce-ease), opacity 200ms var(--sce-ease);
}

.sce .sce__button:hover,
.sce .sce__button:focus-visible {
  background-color: var(--sce-brown);
  color: #fff;
}

.sce .sce__button:focus-visible {
  outline: 1px solid var(--sce-ink);
  outline-offset: 2px;
}

.sce .sce__button[aria-disabled="true"] {
  opacity: .45;
  cursor: default;
}

.sce__error {
  padding-top: 12px;
  color: var(--sce-red);
  font-size: 13px;
  line-height: 18px;
}

.sce__error:empty {
  display: none;
}

/* ── In the cart drawer ────────────────────────────────────────────────── */

.sce--drawer {
  flex: 0 0 auto;
  margin: 0 24px;
  padding: 24px 0;
  border-top: 1px solid var(--sce-line);
}

.sce--drawer .sce__zine-title {
  font-size: 15px;
  font-weight: 300;
  line-height: 18px;
}

/*
 * While the extras are shown, products and extras scroll together and the
 * subtotal with the checkout button stays in view at the bottom of the drawer.
 * sce.js sets the class; without it the drawer is exactly as the theme made it.
 */
.sce-drawer-on .w-commerce-commercecartformwrapper {
  min-height: 0;
}

.sce-drawer-on .w-commerce-commercecartform {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Focus moving into the list must not end up behind the pinned footer. */
  scroll-padding-bottom: var(--sce-foot, 161px);
}

.sce-drawer-on .w-commerce-commercecartlist {
  flex: 0 0 auto;
  overflow: visible;
}

.sce-drawer-on .w-commerce-commercecartfooter {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-top: auto;
  background-color: var(--sce-surface, #f4f1ec);
}

/* ── On the checkout, inside the order summary ─────────────────────────── */

/* The theme's item list ends on a -20px margin; give the line the same air as between two items. */
.sce--checkout {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--sce-line);
  color: #333;
}

/* Same step as the theme's own fields: 16px on small screens, so iOS does not zoom. */
@media screen and (max-width: 767px) {
  .sce .sce__textarea {
    font-size: 16px;
    line-height: 22px;
    min-height: 84px;
  }

  .sce--drawer .sce__zine-title {
    font-size: 16px;
    line-height: 1.2;
  }
}

@media (pointer: coarse) {
  .sce .sce__textarea {
    font-size: 16px;
    line-height: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sce *,
  .sce--ready .sce__message,
  .sce--ready .sce__message.is-open {
    transition: none !important;
  }
}
