:root {
  --walnut: #241712;
  --walnut-deep: #170f0b;
  --parchment: #efe1be;
  --parchment-dim: #ddc99a;
  --ink: #2b1b14;
  --amethyst: #6e4a8e;
  --amethyst-deep: #4a3060;
  --copper: #b4622b;
  --copper-bright: #d97f3f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at top, #3a2418 0%, var(--walnut) 45%, var(--walnut-deep) 100%);
  color: var(--parchment);
  font-family: "Arvo", Georgia, serif;
}

.frame {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 32px 20px 48px;
  display: flex;
  flex-direction: column;
}

.header {
  text-align: center;
  margin-bottom: 28px;
}

.eyebrow {
  font-style: italic;
  color: var(--parchment-dim);
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.title {
  font-family: "Rye", "Arvo", serif;
  font-weight: 400;
  font-size: clamp(2rem, 8vw, 2.8rem);
  margin: 0;
  color: var(--copper-bright);
  text-shadow: 2px 2px 0 var(--walnut-deep);
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--parchment-dim);
  max-width: 40ch;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.test-banner {
  margin: 14px auto 0;
  max-width: 40ch;
  color: var(--copper-bright);
  background: rgba(180, 98, 43, 0.15);
  border: 1px solid var(--copper);
  padding: 8px 14px;
  font-size: 0.85rem;
  font-style: italic;
}

.stage {
  flex: 1;
  display: flex;
  justify-content: center;
}

.panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hidden { display: none; }

/* --- Viewfinder --- */

.viewfinder {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 3px solid var(--copper);
  box-shadow: 0 0 0 6px var(--walnut-deep), 0 12px 30px rgba(0,0,0,0.5);
  overflow: hidden;
}

.viewfinder video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* efeito espelho, mais natural pra quem está na frente */
}

.viewfinder-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid var(--amethyst);
  opacity: 0.85;
}
.viewfinder-corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.viewfinder-corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.viewfinder-corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.viewfinder-corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

.countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Rye", serif;
  font-size: 5rem;
  color: var(--parchment);
  text-shadow: 0 0 20px rgba(0,0,0,0.8);
  pointer-events: none;
}

.hint {
  margin: 0;
  color: var(--parchment-dim);
  font-size: 0.9rem;
  text-align: center;
}

.mode-toggle {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.mode-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 2px solid var(--parchment-dim);
  color: var(--parchment);
  font-family: "Arvo", serif;
  font-weight: 700;
  cursor: pointer;
}

.mode-btn.selected {
  border-color: var(--copper);
  background: rgba(180, 98, 43, 0.25);
  color: var(--copper-bright);
}

.register-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}

.landing-samples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 480px;
}

.landing-samples img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  background: var(--walnut-deep); /* aparece enquanto a imagem carrega, ou se faltar o arquivo */
}

.landing-pitch {
  max-width: 42ch;
  line-height: 1.6;
}

.landing-offer {
  background: var(--parchment);
  color: var(--ink);
  padding: 16px 20px;
  text-align: center;
  max-width: 380px;
}

.landing-offer p {
  margin: 4px 0;
}

.landing-offer strong {
  color: var(--copper);
  font-size: 1.3rem;
}

.landing-offer .hint {
  color: var(--ink);
  opacity: 0.75;
  font-size: 0.85rem;
}

.text-input {
  padding: 14px 16px;
  border: 2px solid var(--parchment-dim);
  background: var(--walnut-deep);
  color: var(--parchment);
  font-family: "Arvo", serif;
  font-size: 1rem;
}

.text-input::placeholder {
  color: var(--parchment-dim);
  opacity: 0.7;
}

.text-input:focus {
  outline: none;
  border-color: var(--copper);
}

/* --- Temas --- */

.themes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 480px;
}

.theme-option {
  flex: 1 1 auto;
  min-width: 140px;
  padding: 10px 14px;
  border: 2px solid var(--parchment-dim);
  background: transparent;
  color: var(--parchment);
  font-family: "Arvo", serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.theme-option.selected {
  border-color: var(--amethyst);
  background: rgba(110, 74, 142, 0.25);
}

.caption-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.caption-options .theme-option {
  text-align: left;
  width: 100%;
}

/* --- Botões --- */

.btn {
  font-family: "Arvo", serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 28px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--copper);
  color: var(--walnut-deep);
  box-shadow: 0 4px 0 #7a3f18;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--parchment);
  border: 2px solid var(--parchment-dim);
}
.btn-ghost:hover { border-color: var(--parchment); }

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- Foto (preview / resultado) --- */

.photo-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 14px;
  background: var(--parchment);
  box-shadow: 0 14px 34px rgba(0,0,0,0.55);
  transform: rotate(-1deg);
}

.photo-frame img {
  width: 100%;
  display: block;
  filter: sepia(0.15);
}

.result-frame { transform: rotate(1deg); }

.stamp {
  margin: 10px 0 0;
  text-align: center;
  color: var(--ink);
  font-style: italic;
  font-size: 0.95rem;
}

/* --- Loading (rolo de filme) --- */

.reel {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 6px solid var(--parchment-dim);
  border-top-color: var(--amethyst);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--parchment-dim);
  font-style: italic;
}

.error-text {
  color: var(--copper-bright);
  text-align: center;
  max-width: 40ch;
}

.footer {
  text-align: center;
  margin-top: 32px;
  color: var(--parchment-dim);
  font-size: 0.8rem;
  opacity: 0.7;
}

/* --- Galeria --- */

.panel-title {
  font-family: "Rye", serif;
  font-weight: 400;
  color: var(--copper-bright);
  font-size: 1.4rem;
  margin: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
  width: 100%;
}

.gallery-item {
  position: relative;
  cursor: pointer;
  border: 3px solid transparent;
  background: var(--parchment);
  padding: 6px;
}

.gallery-item.selected {
  border-color: var(--amethyst);
}

.gallery-item img {
  width: 100%;
  display: block;
  filter: sepia(0.15);
  cursor: zoom-in;
}

.gallery-item .check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--walnut-deep);
  border: 2px solid var(--parchment-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: transparent;
}

.gallery-item.selected .check {
  background: var(--amethyst);
  border-color: var(--amethyst);
  color: var(--parchment);
}

.gallery-item .price-tag {
  text-align: center;
  color: var(--ink);
  font-size: 0.8rem;
  margin-top: 6px;
}

/* --- Lightbox (foto em tamanho cheio) --- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.lightbox.hidden {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  box-shadow: 0 14px 40px rgba(0,0,0,0.6);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: transparent;
  border: none;
  color: var(--parchment);
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
}

.total-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 4px;
  border-top: 2px solid var(--parchment-dim);
  border-bottom: 2px solid var(--parchment-dim);
  font-size: 1.1rem;
}

.payment-note {
  max-width: 40ch;
  text-align: center;
  font-style: italic;
}

.qr-frame {
  background: var(--parchment);
  padding: 14px;
  width: 220px;
}

.qr-frame img {
  width: 100%;
  display: block;
}

.delivery-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 420px;
}

.delivery-thumbs img {
  width: 100%;
  display: block;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  width: 100%;
}

.preview-grid img {
  width: 100%;
  display: block;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}

/* --- Impressão --- */

#print-area {
  display: none;
}

@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }
  .print-page {
    page-break-after: always;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
  }
  .print-page img {
    max-width: 100%;
    max-height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reel { animation: none; border-top-color: var(--amethyst); }
}
