/* ============================================================
   COMPOSER PAGE — Carosello Centrale
   Padroni a Casa Nostra
   ============================================================ */

/* === PAGE BASE === */
.composer-page {
  min-height: 100vh;
  background: var(--off-white);
  padding-top: 64px;
  padding-bottom: 100px; /* space for sticky action bar */
}

/* === PAGE WRAPPER === */
.composer-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

/* === HERO TITLE === */
.composer-hero {
  text-align: center;
  padding-top: 0.5rem;
}
.composer-hero h1 {
  font-family: Impact, 'Arial Narrow', Arial, sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--blue);
  line-height: 1;
  margin-bottom: 0.4rem;
}
.composer-hero p {
  font-size: 0.95rem;
  color: #666;
  font-weight: 500;
}
.composer-hero strong {
  color: var(--red);
}

/* === STEP TRACK === */
.step-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.step-item span {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #bbb;
  transition: color 0.3s;
}
.step-item.active span,
.step-item.done span { color: var(--blue); }

.step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2.5px solid var(--light-gray);
  background: var(--white);
  color: #bbb;
  font-size: 0.8rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  transition: all 0.3s ease;
}
.step-item.active .step-circle {
  border-color: var(--blue);
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(40,21,110,0.35);
}
.step-item.done .step-circle {
  border-color: var(--green);
  background: var(--green);
  color: var(--white);
}
.step-item.done .step-circle::before {
  content: '✓';
  font-size: 0.85rem;
}
.step-item.done .step-circle { font-size: 0; }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--light-gray);
  min-width: 40px;
  max-width: 80px;
  margin-bottom: 24px;
  transition: background 0.3s;
}
.step-line.done { background: var(--green); }

/* === STEP SECTIONS === */
.composer-step {
  background: var(--white);
  border: 1px solid var(--light-gray);
  border-radius: 20px;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.step-hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
  height: 0;
  overflow: hidden;
  padding: 0;
  border: none;
  gap: 0;
}
.step-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  height: auto;
  overflow: visible;
  padding: 1.75rem 1.5rem;
  border: 1px solid var(--light-gray);
  gap: 1.25rem;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue);
}
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 0.7rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* === FORMAT TOGGLE === */
.format-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.format-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-radius: 14px;
  border: 2.5px solid var(--light-gray);
  background: var(--white);
  transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.format-btn:hover {
  border-color: var(--blue);
  background: rgba(40,21,110,0.03);
}
.format-btn.active {
  border-color: var(--blue);
  background: rgba(40,21,110,0.06);
  box-shadow: 0 4px 16px rgba(40,21,110,0.12);
}
.format-icon {
  border-radius: 5px;
  background: var(--light-gray);
  flex-shrink: 0;
  transition: background 0.25s;
}
.format-icon.r45  { width: 28px; height: 35px; }
.format-icon.r916 { width: 20px; height: 35px; }
.format-btn.active .format-icon { background: var(--blue); }

.format-info { display: flex; flex-direction: column; gap: 0.15rem; }
.format-info strong {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--dark);
  letter-spacing: 0.02em;
}
.format-info span {
  font-size: 0.72rem;
  color: #888;
  font-weight: 500;
}
.format-btn.active .format-info strong { color: var(--blue); }

/* === CAROUSEL === */
.carousel-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
}

.carousel-arrow {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--light-gray);
  background: var(--white);
  color: var(--dark);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s, transform 0.15s, color 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.carousel-arrow svg { width: 20px; height: 20px; }
.carousel-arrow:hover:not(:disabled) {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
  transform: scale(1.08);
}
.carousel-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}
.carousel-arrow.bounce {
  animation: arrowBounce 0.35s ease;
}
@keyframes arrowBounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(0.85); }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Canvas container inside carousel */
.carousel-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  max-width: calc(100% - 120px);
  position: relative;
}

/* === CANVAS === */
#composerCanvas {
  border-radius: 14px;
  box-shadow: 0 10px 48px rgba(0,0,0,0.2);
  touch-action: none;
  cursor: grab;
  max-width: 100%;
  max-height: 60vh;
  display: block;
  transition: box-shadow 0.3s;
}
#composerCanvas:active { cursor: grabbing; }
#composerCanvas.fade-in {
  animation: canvasFadeIn 0.35s ease;
}
@keyframes canvasFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* Placeholder */
.canvas-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: #bbb;
  text-align: center;
  padding: 3rem 1rem;
  width: 100%;
}
.canvas-placeholder .ph-icon { font-size: 3.5rem; }
.canvas-placeholder p { font-size: 0.85rem; font-weight: 500; max-width: 220px; }

/* === CAROUSEL DOTS === */
.carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.carousel-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--light-gray);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s, width 0.25s;
}
.carousel-dot.active {
  background: var(--blue);
  transform: scale(1.3);
  width: 22px;
  border-radius: 4px;
}
.carousel-dot:hover:not(.active) {
  background: #aaa;
}

/* === CONFIRM BUTTON === */
.btn-confirm {
  align-self: center;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 50px;
  padding: 0.875rem 2.5rem;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(218,37,28,0.35);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.btn-confirm:hover {
  background: #b41e16;
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(218,37,28,0.45);
}
.btn-confirm:active { transform: translateY(0); }

/* === PHOTO UPLOAD === */
.upload-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.upload-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 0.75rem;
  border-radius: 14px;
  border: 2px solid var(--light-gray);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  font-family: inherit;
}
.upload-action-btn:hover {
  border-color: var(--blue);
  background: rgba(40,21,110,0.04);
  transform: translateY(-2px);
}
.upload-action-btn .icon { font-size: 1.75rem; }
.upload-action-btn span:last-child {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: 0.05em;
}

/* === ZOOM SLIDER === */
.zoom-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--off-white);
  border-radius: 12px;
}
.zoom-label {
  font-size: 1rem;
  font-weight: 700;
  color: #999;
  user-select: none;
  line-height: 1;
  flex-shrink: 0;
}
.zoom-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--blue);
  min-width: 3ch;
  text-align: right;
  flex-shrink: 0;
}
#zoomSlider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: var(--light-gray);
  outline: none;
  cursor: pointer;
}
#zoomSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(40,21,110,0.4);
}

.canvas-hint {
  font-size: 0.8rem;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  text-align: center;
  justify-content: center;
}

/* === ACTION BAR (sticky bottom) === */
.composer-actions {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--light-gray);
  z-index: 200;
}

.composer-actions .btn {
  min-width: 130px;
  font-size: 0.88rem;
  padding: 0.75rem 1.5rem;
}

.btn-download {
  background: var(--green);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(0,149,62,0.35);
}
.btn-download:hover:not(:disabled) {
  background: #007a33;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,149,62,0.45);
}

.btn-share {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 4px 16px rgba(40,21,110,0.3);
}
.btn-share:hover:not(:disabled) {
  background: #1e0e56;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(40,21,110,0.42);
}

.btn-reset {
  background: transparent;
  color: #888;
  border: 1.5px solid var(--light-gray);
}
.btn-reset:hover {
  border-color: #aaa;
  color: var(--dark);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  background: var(--dark);
  color: var(--white);
  padding: 0.875rem 1.75rem;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 9999;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* === RESPONSIVE === */
@media (max-width: 520px) {
  .composer-wrapper { padding: 1.25rem 0.75rem; gap: 1.75rem; }
  .carousel-arrow { width: 40px; height: 40px; }
  .carousel-arrow svg { width: 18px; height: 18px; }
  .carousel-canvas-wrap { max-width: calc(100% - 100px); }
  .composer-actions { gap: 0.5rem; padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom)); }
  .composer-actions .btn { flex: 1; min-width: 0; font-size: 0.8rem; padding: 0.7rem 0.5rem; }
  .format-btn { padding: 0.875rem 0.75rem; gap: 0.75rem; }
}

@media (max-width: 380px) {
  .carousel-arrow { width: 34px; height: 34px; }
  .carousel-canvas-wrap { max-width: calc(100% - 84px); }
}
