:root {
  --bg: #faf7f2;
  --ink: #2b2320;
  --accent: #c96a45;
  --accent-dark: #a4502f;
  --card-bg: #ffffff;
  --border: #e7ddd2;
}

* { box-sizing: border-box; }

/* Garantit que l'attribut [hidden] gagne toujours, même sur des éléments
   dont une règle plus loin dans ce fichier fixe déjà un display explicite. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.site-header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.site-header h1 { margin: 0 0 .3rem; font-size: 2.2rem; }
.site-header p { margin: 0; opacity: .7; }

.tabs {
  display: flex;
  justify-content: center;
  gap: .5rem;
  padding: 0 1rem 2rem;
  flex-wrap: wrap;
}

.tab-btn {
  padding: .7rem 1.4rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s, color .15s;
}

.tab-btn:hover { background: #f2e8dc; }

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

main { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem 3rem; }

.product-section {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.product-section.active { display: grid; }

.product-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
}

.product-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  padding: .5rem;
  background: radial-gradient(ellipse at 50% 40%, #ffffff 0%, #f0ede8 70%, #e5ded2 100%);
}

.product-card .info { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.product-card h3 { margin: 0; font-size: 1.05rem; }
.product-card .price { color: var(--accent-dark); font-weight: 600; }

.product-card button.view-360 {
  margin-top: auto;
  padding: .6rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: .95rem;
}

.product-card button.view-360:hover { background: var(--accent-dark); }

.custom-card {
  border-style: dashed;
  border-color: #cbb89a;
}

.custom-card-visual {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  font-size: 1.4rem;
  text-align: center;
  color: var(--accent-dark);
  background: #f2ede4;
}

.custom-upload {
  padding: 2rem 1.5rem;
  border: 2px dashed #cbb89a;
  border-radius: 12px;
  text-align: center;
  margin-bottom: 1rem;
}

.custom-upload-label {
  display: inline-block;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: .8rem;
}

.custom-upload-hint {
  margin: .8rem 0 0;
  font-size: .82rem;
  opacity: .65;
}

.custom-upload-intro {
  margin: 0 0 .6rem;
  font-size: .95rem;
  font-weight: 600;
}

.custom-upload-or {
  margin: .8rem 0;
  font-size: .8rem;
  opacity: .55;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.bg-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .6rem;
  margin-bottom: .5rem;
}

.bg-choice {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #f2ede4;
  cursor: pointer;
  width: 5.5rem;
  height: 5.5rem;
}

.bg-choice img { display: block; width: 100%; height: 100%; object-fit: cover; }

.bg-choice.active { border-color: var(--accent); }

.customize-price {
  margin: .8rem 0 0;
  font-size: .95rem;
  font-weight: 700;
  color: var(--accent-dark);
  text-align: center;
}

.empty-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  opacity: .6;
}

.category-notice {
  grid-column: 1 / -1;
  background: #fdf3e3;
  border: 1px solid #ecd3a0;
  border-radius: 10px;
  padding: .9rem 1.1rem;
  margin-bottom: .5rem;
  font-size: .88rem;
  line-height: 1.5;
}

.category-notice p { margin: 0; }
.category-notice p + p { margin-top: .4rem; }
.category-notice .notice-en { opacity: .8; font-style: italic; }

.phone-model-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .8rem 1rem;
  margin: .8rem 0;
  background: #fdf3e3;
  font-size: .92rem;
}

.phone-model-block input[type="text"] {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  margin: .4rem 0 .6rem;
}

.phone-model-block .custom-upload-hint { margin: 0; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20,15,10,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 2rem 0;
}

.modal.hidden { display: none; }

.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  width: min(92vw, 560px);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  position: relative;
}

.modal-close {
  position: absolute;
  top: .6rem;
  right: .8rem;
  border: none;
  background: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--ink);
  opacity: .6;
}

.modal-close:hover { opacity: 1; }

#viewer-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 40%, #ffffff 0%, #f0ede8 55%, #ddd6cb 100%);
}

/* Ombre portée simulée sous le produit, pour un rendu "studio" */
#viewer-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 10%;
  width: 55%;
  height: 8%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0,0,0,.28) 0%, rgba(0,0,0,0) 72%);
  pointer-events: none;
}

#viewer-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center 50%;
  padding: 8%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  cursor: zoom-in;
  transition: transform .15s ease;
}

#viewer-frame.zoomed {
  cursor: zoom-out;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.85);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.gallery-arrow:hover { background: #ffffff; }
.gallery-prev { left: .6rem; }
.gallery-next { right: .6rem; }

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: .4rem;
  margin-top: .9rem;
}

.gallery-dots .dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--border);
}

.gallery-dots .dot.active { background: var(--accent); }

.customize-panel {
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.customize-toggle-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  cursor: pointer;
}

.customize-toggle-row input { width: 1.1rem; height: 1.1rem; }

#customize-surcharge-note {
  font-weight: 400;
  font-size: .85rem;
  color: var(--accent-dark);
}

.customize-lock-row {
  font-weight: 400;
  font-size: .85rem;
  opacity: .85;
  margin-bottom: .9rem;
}

#customize-fields { margin-top: 1rem; }

.customize-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.customize-preview {
  order: -1;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card-bg);
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--border);
}

.customize-controls { min-width: 0; }

@media (min-width: 680px) {
  .modal-content:has(#customize-fields:not([hidden])) {
    width: min(96vw, 1040px);
  }

  .customize-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .customize-preview {
    order: 1;
    flex: 0 0 460px;
    padding-bottom: 0;
    padding-left: 1rem;
    border-bottom: none;
    border-left: 1px solid var(--border);
  }

  .customize-controls { flex: 1 1 auto; max-width: 460px; }
}

#customize-text {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: .9rem;
}

.customize-label {
  margin: 0 0 .4rem;
  font-size: .85rem;
  font-weight: 600;
  opacity: .7;
}

.tag-choices, .logo-choices, .font-choices {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}

.tag-choice, .logo-choice {
  border: 2px solid transparent;
  border-radius: 8px;
  padding: .3rem;
  background: #f2ede4;
  cursor: pointer;
}

.tag-choice img, .logo-choice img { display: block; width: 4.5rem; height: auto; }

.tag-choice.active, .logo-choice.active { border-color: var(--accent); }

.tag-choice-none, .logo-choice-none {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 3rem;
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink);
}

.font-choice {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .9rem;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 1.05rem;
}

.font-choice.active {
  border-color: var(--accent);
  background: #fbeee6;
}

.customize-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .8rem;
}

.customize-row label {
  font-size: .9rem;
  font-weight: 600;
  opacity: .8;
}

.customize-row input[type="range"] { flex: 1; max-width: 60%; }

.customize-row input[type="color"] {
  width: 2.4rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.customize-canvas {
  width: 100%;
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 40%, #ffffff 0%, #f0ede8 55%, #ddd6cb 100%);
}

.btn-download {
  display: block;
  width: 100%;
  margin-top: .8rem;
  padding: .7rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-download:hover { background: var(--accent-dark); }

.gallery-download {
  display: inline-block;
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 600;
}

.gallery-download:hover { text-decoration: underline; }

.btn-add-cart {
  background: var(--ink);
  margin-top: .6rem;
}

.btn-add-cart:hover { background: #453a34; }

.btn-download:disabled {
  background: #c9c2b8;
  cursor: not-allowed;
}

.btn-download:disabled:hover { background: #c9c2b8; }

.cart-hint-inline {
  margin: .5rem 0 0;
  padding: .6rem .7rem;
  background: #fff3cd;
  border: 1px solid #f0d178;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  color: #6b4e00;
  text-align: left;
}

.btn-secondary {
  padding: .7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--ink);
  font-size: .95rem;
  cursor: pointer;
}

.cart-toggle {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .8rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

.cart-toggle:hover { background: var(--accent-dark); }

.cart-panel {
  position: fixed;
  right: 1.2rem;
  bottom: 5rem;
  z-index: 60;
  width: min(90vw, 360px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
  padding: 1.2rem;
  display: none;
}

.cart-panel.open { display: block; }

.cart-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .8rem;
}

.cart-panel-header h3 { margin: 0; font-size: 1.1rem; }

.cart-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.cart-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .6rem;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cart-item-info strong { font-size: .95rem; }

.cart-item-details {
  font-size: .78rem;
  opacity: .7;
  margin-top: .15rem;
}

.cart-item-price {
  font-size: .85rem;
  color: var(--accent-dark);
  font-weight: 600;
  margin-top: .2rem;
}

.cart-remove {
  border: none;
  background: none;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink);
  opacity: .5;
  cursor: pointer;
}

.cart-remove:hover { opacity: 1; }

.cart-empty {
  text-align: center;
  padding: 1rem 0;
  opacity: .6;
  font-size: .9rem;
}

.cart-actions {
  display: flex;
  gap: .6rem;
}

.cart-actions .btn-download { margin-top: 0; }

.cart-hint {
  margin: .9rem 0 0;
  padding: .7rem .8rem;
  background: #fff3cd;
  border: 1px solid #f0d178;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: #6b4e00;
  text-align: left;
}

.save-toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(90vw, 420px);
  padding: .8rem 1.1rem;
  background: #2b2320;
  color: #fff3cd;
  border-radius: 10px;
  font-size: .88rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.save-toast.visible { opacity: 1; }

.site-footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  font-size: .85rem;
  opacity: .6;
}

.site-footer code {
  background: #eee3d5;
  padding: .1rem .4rem;
  border-radius: 4px;
}
