@import url("https://fonts.googleapis.com/css2?family=Abril+Fatface&family=Barlow+Condensed:wght@500;600;700&family=Bebas+Neue&family=Caveat:wght@500;600;700&family=Cinzel:wght@500;600;700&family=Cormorant+Garamond:wght@500;600;700&family=Dancing+Script:wght@500;600;700&family=Great+Vibes&family=Lobster&family=Montserrat:wght@500;600;700&family=Oswald:wght@500;600;700&family=Pacifico&family=Permanent+Marker&family=Playfair+Display:wght@500;600;700&family=Raleway:wght@500;600;700&display=swap");


:root {
  --ink: #202421;
  --muted: #71766f;
  --paper: #f4f1ea;
  --panel: #fffdf8;
  --line: #ddd7ca;
  --accent: #173f38;
  --shadow: 0 18px 45px rgba(24, 35, 31, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

.topbar {
  height: 76px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 241, 234, .92);
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: white;
  display: grid; place-items: center;
  font-family: Georgia, "Times New Roman", serif; font-size: 22px;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }

.ghost {
  border: 1px solid var(--line); background: transparent;
  border-radius: 999px; padding: 10px 16px; cursor: pointer;
}

.app {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
}

.viewer-panel {
  position: relative;
  min-height: 650px;
  overflow: hidden;
  background: transparent;
}

#viewer { position: absolute; inset: 0; }
#viewer canvas { display: block; width: 100%; height: 100%; }

.viewer-help {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  color: #5e645f; background: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.8);
  padding: 8px 13px; border-radius: 999px;
  backdrop-filter: blur(8px); font-size: 13px;
}

.badge {
  position: absolute; top: 22px; left: 22px;
  padding: 7px 10px; border-radius: 6px;
  background: rgba(23,63,56,.9); color: white;
  font-size: 11px; letter-spacing: .12em; font-weight: 700;
}

.controls {
  background: var(--panel);
  padding: 38px 34px;
  border-left: 1px solid var(--line);
  overflow-y: auto;
}

.eyebrow {
  margin: 0 0 8px; color: var(--accent);
  letter-spacing: .14em; font-size: 12px; font-weight: 700;
}
h1 {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 35px; line-height: 1.06;
}
.intro > p:last-child { color: var(--muted); line-height: 1.55; }

.control-group { margin-top: 25px; }
.label-row { display: flex; justify-content: space-between; margin-bottom: 9px; }
label { font-weight: 600; }
output { color: var(--accent); font-weight: 700; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
select {
  width: 100%; margin-top: 9px; padding: 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: white;
}


.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 25px; padding: 14px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.toggle-row small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--accent); }

.summary {
  display: flex; justify-content: space-between; align-items: end;
  margin-top: 28px; padding: 18px;
  border-radius: 12px; background: #eeebe2;
}
.summary span, .summary strong { display: block; }
.summary span { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.price { text-align: right; }
.price strong { font-size: 25px; color: var(--accent); }

.primary {
  width: 100%; margin-top: 15px; border: 0; border-radius: 10px;
  padding: 15px; background: var(--accent); color: white;
  font-weight: 700; cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }
.request-message { color: var(--accent); line-height: 1.45; font-size: 13px; }

.field-help {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.texture-upload input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: #fff;
}

.texture-actions {
  margin-top: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mini-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.mini-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.small-button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  padding: 8px 11px;
  cursor: pointer;
}

.small-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.texture-preview-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #f4f1ea;
  aspect-ratio: 16 / 9;
}

.texture-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.relief-control { margin-top: 14px; }
.compact-toggle {
  margin-top: 14px;
  padding: 10px 0;
}



.order-preview {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin: 22px 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: #eeebe2;
}

.order-preview span {
  color: var(--muted);
}

.order-form > label {
  display: block;
  margin: 15px 0 7px;
}

.order-form input[type="email"],
.order-form input[type="number"] {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}

.order-form input:focus {
  outline: 2px solid rgba(23,63,56,.22);
  border-color: var(--accent);
}

.privacy-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.order-status {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.order-status.success { color: #17633c; }
.order-status.error { color: #a12d2d; }

.honeypot {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

.primary:disabled {
  opacity: .58;
  cursor: wait;
}


/* Smalto */
#glaze {
  cursor: pointer;
}

/* Modulo ordine sempre visibile */
.order-inline {
  margin-top: 28px;
  padding: 21px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f5f1e8;
}

.order-inline h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
}

.order-intro {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.order-inline form > label {
  display: block;
  margin: 15px 0 7px;
}

.order-inline input[type="email"],
.order-inline input[type="number"] {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
}

.order-inline input:focus {
  outline: 2px solid rgba(23,63,56,.22);
  border-color: var(--accent);
}

.order-preview {
  margin-top: 0;
}

/* Evidenzia brevemente l'anteprima quando cambia un parametro */
.viewer-panel.viewer-updated {
  animation: viewerPulse .28s ease-out;
}

@keyframes viewerPulse {
  0% { filter: brightness(1); }
  45% { filter: brightness(1.035); }
  100% { filter: brightness(1); }
}

/* Barra e anteprima sempre raggiungibili */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
}

@media (max-width: 900px) {
  .topbar {
    height: 64px;
    padding: 0 14px;
  }

  .brand small {
    display: none;
  }

  .ghost {
    padding: 8px 11px;
    font-size: 12px;
  }

  .app {
    display: block;
    min-height: auto;
  }

  .viewer-panel {
    position: sticky;
    top: 64px;
    z-index: 12;
    width: 100%;
    height: 40vh;
    min-height: 270px;
    max-height: 390px;
    box-shadow: 0 12px 28px rgba(24,35,31,.15);
  }

  .controls {
    position: relative;
    z-index: 2;
    padding: 28px 20px 48px;
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow: visible;
  }

  .viewer-help {
    bottom: 12px;
    max-width: calc(100% - 28px);
    white-space: nowrap;
    font-size: 11px;
  }

  .badge {
    top: 12px;
    left: 12px;
  }

  h1 {
    font-size: 31px;
  }
}

@media (max-width: 500px) {
  .viewer-panel {
    height: 36vh;
    min-height: 240px;
  }

  .summary {
    padding: 14px;
  }

  .price strong {
    font-size: 21px;
  }
}


/* Campi ordine coordinati con la configurazione */
.order-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 12px;
  margin-top: 14px;
}

.order-field {
  display: block;
  margin: 0 !important;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eeebe2;
}

.order-field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.order-field input[type="email"],
.order-field input[type="number"] {
  width: 100%;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}

.order-field input::placeholder {
  color: #8a8d87;
  font-weight: 400;
}

.order-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23,63,56,.11);
}

.quantity-field input {
  text-align: center;
}

@media (max-width: 430px) {
  .order-fields {
    grid-template-columns: minmax(0, 1fr) 94px;
    gap: 9px;
  }

  .order-field {
    padding: 11px 12px;
  }
}


/* Sezione rilievo più evidente */
.relief-section {
  margin-top: 28px;
  padding: 18px;
  border: 2px solid var(--accent);
  border-radius: 16px;
  background: rgba(23, 63, 56, .035);
}

.relief-section-title {
  margin-bottom: 8px;
}

.relief-section-title span {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

.relief-section-title strong {
  display: block;
  margin-top: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1.1;
}

.relief-section .control-group {
  margin-top: 16px;
}

/* Viewer pulito: nessun fondale, nessuna ombra */
.viewer-panel {
  background: transparent !important;
}

#viewer,
#viewer canvas {
  background: transparent !important;
}


.editor-section {
  margin-top: 30px;
}

.section-heading {
  margin-bottom: 17px;
}

.section-heading span {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .15em;
}

.section-heading strong {
  display: block;
  margin-top: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1.12;
}

.section-divider {
  position: relative;
  height: 34px;
  margin: 12px 0;
}

.section-divider::before,
.section-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 21px);
  height: 1px;
  background: var(--line);
}

.section-divider::before { left: 0; }
.section-divider::after { right: 0; }

.section-divider span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent);
  background: var(--panel);
  transform: translate(-50%, -50%) rotate(45deg);
}

.relief-section {
  margin-top: 10px !important;
  padding: 24px !important;
  box-shadow: 0 12px 30px rgba(23,63,56,.08);
}

.viewer-panel {
  background: #f2eee5 !important;
}

@media (max-width: 900px) {
  .relief-section {
    padding: 20px !important;
  }
}


.price strong small {
  font-size: .48em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--accent);
}


.quality-note {
  margin: 9px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(23, 63, 56, .07);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}


.text-section {
  margin-top: 10px;
}

.text-input {
  width: 100%;
  margin-top: 9px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.text-input:focus {
  outline: 2px solid rgba(23,63,56,.18);
  border-color: var(--accent);
}

.text-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.text-controls-grid .control-group {
  margin-top: 18px;
}

@media (max-width: 520px) {
  .text-controls-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}


.service-section {
  margin-top: 10px;
}

.service-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.service-card {
  position: relative;
  display: block;
  min-height: 122px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f4f1ea;
  cursor: pointer;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.service-card:hover {
  transform: translateY(-1px);
}

.service-card.active {
  border: 2px solid var(--accent);
  padding: 15px;
  background: rgba(23,63,56,.055);
  box-shadow: 0 8px 20px rgba(23,63,56,.08);
}

.service-card input {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.service-card-title {
  display: block;
  padding-right: 25px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.15;
}

.service-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.4;
}

.text-section[hidden],
.relief-section[hidden] {
  display: none !important;
}

.text-negative-toggle {
  margin-top: 22px;
}

@media (max-width: 520px) {
  .service-choice {
    grid-template-columns: 1fr;
  }

  .service-card {
    min-height: auto;
  }
}

.customization-tabs{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.customization-tab{border:1px solid var(--line);border-radius:14px;padding:16px;background:#f2eee5;text-align:left;cursor:pointer}
.customization-tab.active{border:2px solid var(--accent);padding:15px;background:rgba(23,63,56,.055);box-shadow:0 8px 22px rgba(23,63,56,.09)}
.customization-tab span,.customization-tab small{display:block}
.customization-tab span{font-family:Georgia,"Times New Roman",serif;font-size:18px;font-weight:700}
.customization-tab small{margin-top:7px;color:var(--muted);line-height:1.35}
.customization-panel{margin-top:16px;padding:18px;border:1px solid var(--line);border-radius:14px;background:#fbfaf6}
.customization-panel[hidden]{display:none!important}
.frame-section{margin-top:10px}
@media(max-width:520px){.customization-tabs{grid-template-columns:1fr}}

.apply-text-button{margin-top:10px}
.text-apply-status{min-height:18px;margin:8px 0 0;color:var(--muted);font-size:12px;line-height:1.35}
.text-apply-status.success{color:var(--accent);font-weight:700}


.text-apply-status.error {
  color: #a12d2d;
  font-weight: 700;
}


/* La scritta usa lo stesso smalto, ma una luce radente ne evidenzia i bordi. */



.font-picker {
  position: relative;
  margin-top: 9px;
}

.font-picker-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.font-picker-arrow {
  font-family: Arial, sans-serif;
  font-size: 18px;
  line-height: 1;
  transition: transform .16s ease;
}

.font-picker.open .font-picker-arrow {
  transform: rotate(180deg);
}

.font-picker-menu {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 7px);
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 16px 40px rgba(20, 28, 25, .18);
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.font-option {
  width: 100%;
  display: block;
  padding: 12px 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 17px;
  cursor: pointer;
}

.font-option:hover,
.font-option.active {
  background: #eeebe2;
}

.font-montserrat {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
}

.font-playfair {
  font-family: "Playfair Display", serif;
  font-weight: 700;
}

.font-cinzel {
  font-family: "Cinzel", serif;
  font-weight: 600;
  letter-spacing: .03em;
}

.font-cormorant {
  font-family: "Cormorant Garamond", serif;
  font-weight: 700;
  font-size: 20px;
}

.font-pacifico {
  font-family: "Pacifico", cursive;
  font-weight: 400;
  font-size: 19px;
}

.font-bebas {
  font-family: "Bebas Neue", sans-serif;
  font-weight: 400;
  letter-spacing: .06em;
  font-size: 20px;
}

.font-oswald {
  font-family: "Oswald", sans-serif;
  font-weight: 600;
}

.font-raleway {
  font-family: "Raleway", sans-serif;
  font-weight: 700;
  letter-spacing: .03em;
}

.font-abril {
  font-family: "Abril Fatface", serif;
  font-weight: 400;
  font-size: 19px;
}

.font-lobster {
  font-family: "Lobster", cursive;
  font-weight: 400;
  font-size: 20px;
}

.font-dancing {
  font-family: "Dancing Script", cursive;
  font-weight: 700;
  font-size: 21px;
}

.font-greatvibes {
  font-family: "Great Vibes", cursive;
  font-weight: 400;
  font-size: 23px;
}

.font-caveat {
  font-family: "Caveat", cursive;
  font-weight: 700;
  font-size: 22px;
}

.font-marker {
  font-family: "Permanent Marker", cursive;
  font-weight: 400;
  font-size: 18px;
}

.font-barlow {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .04em;
}


.text-area {
  min-height: 92px;
  resize: vertical;
  line-height: 1.35;
  font-family: inherit;
}



.home-store-button {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1000;
  width: 94px;
  height: 94px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 50%;
  background: #173f38;
  color: #ffffff;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 12px 28px rgba(16, 35, 31, .28);
  border: 2px solid rgba(255,255,255,.72);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  -webkit-tap-highlight-color: transparent;
}

.home-store-button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 34px rgba(16, 35, 31, .34);
  background: #1d4e45;
}

.home-store-button:active {
  transform: scale(.97);
}

.home-store-arrow {
  font-size: 22px;
  line-height: 1;
  font-family: Arial, sans-serif;
  font-weight: 700;
}

.home-store-label {
  max-width: 76px;
  font-size: 12px;
  line-height: 1.15;
  font-weight: 700;
}

@media (max-width: 700px) {
  .home-store-button {
    right: 14px;
    bottom: 14px;
    width: 82px;
    height: 82px;
  }

  .home-store-arrow {
    font-size: 20px;
  }

  .home-store-label {
    max-width: 68px;
    font-size: 11px;
  }
}


.project-load-status {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(23, 63, 56, .92);
  color: white;
  font-size: 13px;
  line-height: 1.35;
  backdrop-filter: blur(8px);
}

.project-load-status.error {
  background: rgba(145, 39, 39, .94);
}

.project-link-result {
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(23, 63, 56, .22);
  border-radius: 10px;
  background: rgba(23, 63, 56, .055);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.project-link-result strong,
.project-link-result a {
  display: block;
}

.project-link-result a {
  margin-top: 5px;
  color: var(--accent);
  font-weight: 700;
}


/* v31 — il viewer desktop occupa solo l'altezza visibile dello schermo.
   La colonna dei controlli scorre autonomamente e non allunga più il canvas. */
@media (min-width: 901px) {
  .app {
    height: calc(100vh - 76px);
    min-height: 0;
    overflow: hidden;
  }

  .viewer-panel {
    height: 100%;
    min-height: 0;
    align-self: stretch;
  }

  .controls {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* Mantiene integralmente il comportamento già corretto su telefoni e tablet. */
@media (max-width: 900px) {
  .app {
    height: auto;
    overflow: visible;
  }
}
