/* ---------------------------------------------------------------------------
   "Your own design" (inc/photoprint-product.php, madformat_is_custom_design_product)

   The photoprint page with the shopper's own picture in the gallery column and
   an upload block in the form. Scoped by `body.mf-pdp-custom`, so no other
   product page changes. Colours, radii and type are the theme's tokens.
   ------------------------------------------------------------------------ */

/* Where the gallery sits: the photoprint page places `.woocommerce-product-gallery`;
   this column is not one (WooCommerce's gallery script would start on it). */
@media (min-width: 721px) {
  body.mf-pdp-custom.single-product div.product .mf-cd-gallery {
    grid-column: 1;
    grid-row: 1;
  }
}

@media (max-width: 720px) {
  body.mf-pdp-custom.single-product div.product > .mf-cd-gallery {
    order: 1;
  }

  body.mf-pdp-custom.single-product div.product > .mf-pdp-details {
    order: 4;
  }
}

.mf-cd-gallery {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}

/* ---- the column of tiles ---- */

.mf-cd-thumbs {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 3px;
}

.mf-cd-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  aspect-ratio: 1;
  padding: 0.25rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-inner);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.mf-cd-thumb--add {
  border: 1px dashed var(--border-control);
  background: transparent;
  font-size: var(--type-caption);
  line-height: 1.15;
  text-align: center;
}

.mf-cd-thumb--add:hover {
  background: var(--paper);
}

.mf-cd-thumb__plus {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--paper);
  font-size: 1.3rem;
  line-height: 1;
}

.mf-cd-thumb--view.is-active {
  border: 2px solid var(--ink);
}

.mf-cd-thumb__art {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  background: var(--paper-bright);
  position: relative;
  overflow: hidden;
}

/* The tile of the wall view: a wall with the picture in the middle of it. */
.mf-cd-thumb__art--wall::before,
.mf-cd-thumb__art--flat::before {
  content: '';
  position: absolute;
  background: var(--mf-cd-thumb, var(--paper)) center / cover no-repeat;
  box-shadow: 0 2px 5px rgba(18, 20, 22, 0.25);
}

.mf-cd-thumb__art--wall::before {
  inset: 18% 28%;
}

.mf-cd-thumb__art--flat::before {
  inset: 6%;
  box-shadow: none;
}

/* ---- the frame: a wall, and the print on it ---- */

.mf-cd-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 7 / 8;
  min-width: 0;
  border-radius: calc(var(--radius-card) * 1.25);
  background: linear-gradient(180deg, #ece9e3 0%, var(--paper) 100%);
  overflow: hidden;
}

.mf-cd-art {
  --mf-cd-edge: #cfc8bb;
  position: relative;
  height: 74%;
  aspect-ratio: var(--mf-cd-ar, 2 / 3);
  background: var(--paper-bright);
  overflow: hidden;
  touch-action: pan-y;
  transition: box-shadow 0.25s var(--ease);
}

.mf-cd-art:not(.is-empty) {
  cursor: grab;
}

.mf-cd-art.is-dragging {
  cursor: grabbing;
}

.mf-cd-art__img {
  position: absolute;
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;
}

.mf-cd-art__img[hidden] {
  display: none;
}

.mf-cd-art__gloss {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

/* No picture yet: a neutral print with a plain call to add one. */
.mf-cd-art.is-empty {
  background: var(--paper-bright);
  outline: 1px dashed var(--border-control);
  outline-offset: -1px;
}

.mf-cd-art__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1rem;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--type-meta);
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
}

.mf-cd-art:not(.is-empty) .mf-cd-art__empty {
  display: none;
}

/* The materials. Drawn, not photographed: a flat print with a margin, a canvas
   with a thick edge and a weave, a sheet of glass with a shine. */
.mf-cd-art.is-poster {
  box-shadow: 0 1px 2px rgba(18, 20, 22, 0.25), 0 14px 28px -10px rgba(18, 20, 22, 0.35);
}

.mf-cd-art.is-canva {
  box-shadow:
    1px 1px 0 var(--mf-cd-edge),
    2px 2px 0 var(--mf-cd-edge),
    3px 3px 0 var(--mf-cd-edge),
    4px 4px 0 var(--mf-cd-edge),
    5px 5px 0 #b9b2a5,
    6px 6px 0 #b9b2a5,
    22px 28px 34px -12px rgba(18, 20, 22, 0.45);
}

.mf-cd-art.is-canva .mf-cd-art__gloss {
  display: block;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.05) 0 1px, transparent 1px 3px);
}

.mf-cd-art.is-painting {
  outline: 3px solid rgba(255, 255, 255, 0.85);
  outline-offset: -3px;
  box-shadow: 0 2px 6px rgba(18, 20, 22, 0.3), 0 26px 40px -12px rgba(18, 20, 22, 0.5);
}

.mf-cd-art.is-painting .mf-cd-art__gloss {
  display: block;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.08) 28%, rgba(255, 255, 255, 0) 45%, rgba(255, 255, 255, 0.14) 70%, rgba(255, 255, 255, 0) 100%);
}

.mf-cd-art.is-empty .mf-cd-art__gloss {
  display: none;
}

/* The second view: the print area as it will be printed, no wall. */
.mf-cd-frame[data-view='1'] {
  background: var(--paper);
}

.mf-cd-frame[data-view='1'] .mf-cd-art {
  height: 94%;
  box-shadow: none;
  outline: 0;
}

.mf-cd-frame[data-view='1'] .mf-cd-art.is-empty {
  outline: 1px dashed var(--border-control);
}

.mf-cd-frame[data-view='1'] .mf-cd-art__gloss {
  display: none;
}

.mf-cd-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-top: -1.25rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  cursor: pointer;
}

.mf-cd-nav--prev {
  left: 0.6rem;
}

.mf-cd-nav--next {
  right: 0.6rem;
}

.mf-cd-counter {
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  background: rgba(20, 21, 24, 0.72);
  color: var(--on-dark);
  font-size: var(--type-caption);
  font-variant-numeric: tabular-nums;
}

/* ---- the upload block ---- */

.mf-cd-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--type-control);
  font-weight: 700;
  line-height: 1.25;
}

.mf-cd-title span {
  font-weight: 400;
  color: var(--text-muted);
}

.mf-cd-upload {
  margin: 0.9rem 0 0;
  padding: 0.9rem;
  border: 1px dashed var(--border-control);
  border-radius: var(--radius-card);
}

.mf-cd-upload__row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.65rem;
}

.mf-cd-drop {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4.5rem;
  padding: 0.6rem 0.8rem;
  border: 1px dashed var(--border-control);
  border-radius: var(--radius-inner);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.mf-cd-drop svg {
  flex: none;
}

.mf-cd-drop:hover,
.mf-cd-drop.is-over {
  border-color: var(--ink);
  background: var(--paper);
}

.mf-cd-drop__text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  font-size: var(--type-meta);
  line-height: 1.3;
}

.mf-cd-drop__text strong {
  font-weight: 500;
  color: var(--ink);
}

.mf-cd-drop__text span {
  color: var(--text-muted);
  font-size: var(--type-caption);
}

.mf-cd-upload__side {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 0;
}

.mf-cd-choose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--ink);
  color: var(--on-dark);
  font: inherit;
  font-size: var(--type-control);
  font-weight: 600;
  cursor: pointer;
}

.mf-cd-choose:hover {
  background: var(--graphite);
}

.mf-cd-hint,
.mf-cd-status {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--type-caption);
  line-height: 1.4;
}

.mf-cd-status {
  margin-top: 0.6rem;
  overflow-wrap: anywhere;
}

.mf-cd-status.is-error,
.mf-cd-status.is-warn {
  color: var(--signal);
}

.mf-cd-status.is-ok {
  color: var(--ink);
}

/* Low resolution is information, not an error: a warm, calm note. */
.mf-cd-status.is-low {
  color: var(--ink);
  padding-left: 0.6rem;
  border-left: 2px solid var(--oak);
}

body.mf-pdp-custom .mf-cd-tips {
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.8rem;
  background: var(--paper);
  border-radius: var(--radius-control, 4px);
  font-size: var(--type-caption);
  line-height: 1.4;
  color: var(--text-muted);
}

body.mf-pdp-custom .mf-cd-tips__title {
  margin: 0 0 0.3rem;
  font-size: var(--type-caption);
  font-weight: 600;
  color: var(--ink);
}

body.mf-pdp-custom .mf-cd-tips ul {
  margin: 0;
  padding-left: 1.1rem;
  list-style: disc;
}

body.mf-pdp-custom .mf-cd-tips li {
  margin: 0.1rem 0;
  overflow-wrap: anywhere;
}

body.mf-pdp-custom .mf-cd-tips__note {
  margin: 0.4rem 0 0;
  color: var(--ink);
}

body.mf-pdp-custom .mf-cd-reqs__list {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
  line-height: 1.5;
}

.mf-cd-upload.is-nudged {
  animation: mf-cd-nudge 0.5s var(--ease);
  border-color: var(--signal);
}

@keyframes mf-cd-nudge {
  20% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  80% { transform: translateX(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .mf-cd-upload.is-nudged {
    animation: none;
  }
}

/* ---- the crop controls ---- */

.mf-cd-adjust {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  margin: 0.6rem 0 0;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-card);
  background: var(--paper);
}

.mf-cd-adjust__thumb {
  flex: none;
  width: 4.25rem;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-inner);
  background: var(--paper-bright) center / cover no-repeat;
  box-shadow: 0 0 0 1px var(--rule);
}

.mf-cd-adjust__body {
  flex: 1 1 auto;
  min-width: 0;
}

.mf-cd-adjust__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.25rem;
  margin-top: 0.4rem;
}

.mf-cd-adjust__group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.mf-cd-adjust__group--scale {
  flex: 1 1 9rem;
}

.mf-cd-adjust__group label,
.mf-cd-adjust__label {
  color: var(--text-muted);
  font-size: var(--type-caption);
}

.mf-cd-adjust__row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.mf-cd-adjust__row input[type='range'] {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--ink);
}

.mf-cd-tool {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-inner);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.mf-cd-tool:hover:not(:disabled),
.mf-cd-tool:focus:not(:disabled) {
  color: var(--ink);
  background: var(--paper-bright);
  border-color: var(--ink);
}

.mf-cd-tool:disabled,
.mf-cd-adjust input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* The buy button before an image is added: still there, plainly not ready. */
body.mf-pdp-custom .summary .single_add_to_cart_button.mf-cd-blocked {
  opacity: 0.45;
  cursor: not-allowed;
}

.mf-cd-gallery :is(button, [role='button']):focus-visible,
.mf-cd-upload :is(button, [role='button']):focus-visible,
.mf-cd-adjust :is(button, input):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---- how it works ---- */

.mf-cd-how__list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.mf-cd-how__step {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding-left: 1.25rem;
  border-left: 1px solid var(--rule);
  font-size: var(--type-meta);
  line-height: 1.45;
  color: var(--text-muted);
}

.mf-cd-how__step:first-child {
  padding-left: 0;
  border-left: 0;
}

.mf-cd-how__step strong {
  color: var(--ink);
  font-size: var(--type-control);
}

.mf-cd-how__num {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 900px) {
  .mf-cd-how__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mf-cd-how__step:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }
}

@media (max-width: 480px) {
  .mf-cd-how__list {
    grid-template-columns: minmax(0, 1fr);
  }

  .mf-cd-how__step {
    padding-left: 0;
    border-left: 0;
  }
}

/* ---- a phone: the preview on top, the tiles in a row under it ---- */

@media (max-width: 720px) {
  .mf-cd-gallery {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.7rem;
  }

  .mf-cd-frame {
    order: 1;
  }

  .mf-cd-thumbs {
    order: 2;
    flex-direction: row;
    overflow-x: auto;
    padding: 3px;
    scrollbar-width: thin;
  }

  .mf-cd-thumb {
    flex: 0 0 4.25rem;
    width: 4.25rem;
  }

  .mf-cd-upload__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .mf-cd-adjust {
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .mf-cd-adjust__thumb {
    width: 3.25rem;
  }
}
