/* ============================================================
   STAMPIO APP
   ============================================================ */

.stampio-content {
  position: relative;
  height: 100%;
  overflow: hidden;
  font-family: 'Montserrat', sans-serif;
}

#stampio-container {
  width: 100%;
  height: 100%;
  background: #f8f5ed;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Views ---- */
.stampio-view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.stampio-view.active {
  display: flex;
}

/* ---- Header ---- */
.stampio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(248,245,237,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 5;
}
.stampio-header-title {
  font-size: 17px;
  font-weight: 700;
  color: #757575;
  letter-spacing: .08em;
}
.stampio-btn {
  width: 40px;
  height: 40px;
  background: #fefaf5;
  border: none;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  color: #757575;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s;
  flex-shrink: 0;
}
.stampio-btn:active { transform: scale(.9); }
.stampio-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stampio-btn-spacer { width: 40px; flex-shrink: 0; }

/* ---- HOME VIEW ---- */
.stampio-home-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 100px;
}
.stampio-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}
.stampio-empty-icon {
  width: 100px;
  height: 100px;
  background: #fefaf5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.04);
  margin-bottom: 20px;
}
.stampio-empty-icon svg { width: 40px; height: 40px; stroke: #757575; fill: none; stroke-width: 1.5; }
.stampio-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: #a0a09c;
  margin-bottom: 6px;
}
.stampio-empty-sub {
  font-size: 13px;
  color: #a0a09c;
  max-width: 200px;
}

/* Date group */
.stampio-date-group {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stampio-date-label {
  font-size: 13px;
  font-weight: 700;
  color: #a0a09c;
  padding: 0 6px 8px;
}
.stampio-date-count {
  font-size: 11px;
  font-weight: 600;
  color: #b8b8b5;
  display: block;
  padding: 0 6px;
  margin-top: -4px;
  margin-bottom: 4px;
}
.stampio-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 8px 6px;
  -webkit-mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
  mask-image: linear-gradient(to right, transparent, black 20px, black calc(100% - 20px), transparent);
}
.stampio-row::-webkit-scrollbar { display: none; }

/* Stamp thumbnail */
.stampio-thumb {
  flex-shrink: 0;
  width: 90px;
  cursor: pointer;
  transition: transform .2s;
}
.stampio-thumb:hover { transform: scale(1.05); }
.stampio-thumb:nth-child(odd) { transform: rotate(-2deg); }
.stampio-thumb:nth-child(even) { transform: rotate(2deg); }
.stampio-thumb:nth-child(odd):hover { transform: rotate(-2deg) scale(1.05); }
.stampio-thumb:nth-child(even):hover { transform: rotate(2deg) scale(1.05); }

/* FAB */
.stampio-fab {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  background: #fefaf5;
  border: none;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  color: #757575;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 6;
  transition: transform .15s;
}
.stampio-fab:active { transform: scale(.9); }
.stampio-fab svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---- CAMERA VIEW ---- */
.stampio-camera-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 20px;
}
.stampio-source-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 260px;
}
.stampio-source-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  background: #fefaf5;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #757575;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s;
}
.stampio-source-btn:active { transform: scale(.96); }
.stampio-source-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Stamp outline placeholder */
.stampio-placeholder {
  width: 160px;
  aspect-ratio: 3/4;
  border: 2px dashed #757575;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stampio-placeholder svg { width: 40px; height: 40px; stroke: #757575; fill: none; stroke-width: 1.5; }

/* Live camera — video fills entire view, machine frame floats on top */
.stampio-view[data-view="camera-live"] {
  position: relative;
}
.stampio-view[data-view="camera-live"] .stampio-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: rgba(248,245,237,.6);
}
.stampio-camera-body.stampio-camera-live-body {
  position: absolute;
  inset: 0;
  padding: 0;
  gap: 0;
}
.stampio-live-machine {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.stampio-live-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}
.stampio-live-video.mirror { transform: scaleX(-1); }
.stampio-live-frame {
  position: absolute;
  top: calc(50% - 16px);
  left: 50%;
  /*
   * The PNG is landscape. After rotate(90deg):
   *   CSS width  → visual height   |   CSS height → visual width
   * Use width to control visual height (how tall the machine looks),
   * and constrain so it doesn't overflow the window edges.
   */
  width: 165%;
  height: auto;
  transform: translate(-50%, -50%) rotate(90deg);
  filter: drop-shadow(0 6px 24px rgba(0,0,0,.35));
  z-index: 2;
  pointer-events: none;
}
.stampio-camera-controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 5;
}
.stampio-cam-btn {
  width: 48px;
  height: 48px;
  background: rgba(254,250,245,.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  color: #757575;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s;
}
.stampio-cam-btn:active { transform: scale(.9); }
.stampio-cam-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---- SAVE VIEW ---- */
.stampio-save-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 20px;
}
.stampio-save-preview {
  width: 120px;
}
.stampio-save-input-wrap {
  text-align: center;
}
.stampio-save-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid #757575;
  font-size: 18px;
  font-weight: 700;
  color: #757575;
  text-align: center;
  padding: 6px 12px;
  width: 180px;
  outline: none;
  font-family: inherit;
}
.stampio-save-input::placeholder { color: #b8b8b5; }
.stampio-save-hint {
  margin-top: 8px;
  font-size: 13px;
  color: #a0a09c;
}
.stampio-save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  background: #fefaf5;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #757575;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s;
  width: 100%;
  max-width: 260px;
}
.stampio-save-btn:disabled { opacity: .4; cursor: not-allowed; }
.stampio-save-btn:not(:disabled):active { transform: scale(.96); }
.stampio-save-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---- ALBUM VIEW ---- */
.stampio-album-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.stampio-album-body::-webkit-scrollbar { display: none; }
.stampio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
}
.stampio-grid-item {
  cursor: pointer;
  transition: transform .2s;
}
.stampio-grid-item:hover { transform: scale(1.05); }

/* ---- DETAILS VIEW ---- */
.stampio-details-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 24px;
}
.stampio-details-stamp {
  width: 200px;
}
.stampio-details-info {
  text-align: center;
}
.stampio-details-name {
  font-size: 18px;
  font-weight: 700;
  color: #4a4a48;
}
.stampio-details-date {
  font-size: 14px;
  color: #a0a09c;
  font-style: italic;
  margin-top: 4px;
}
.stampio-details-actions {
  display: flex;
  gap: 12px;
}
.stampio-del-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: #fff0f0;
  border: none;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #e74c3c;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s;
}
.stampio-del-btn:active { transform: scale(.95); }
.stampio-del-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.stampio-dl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: #fefaf5;
  border: none;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  color: #757575;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s;
}
.stampio-dl-btn:active { transform: scale(.95); }
.stampio-dl-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---- Confirm modal ---- */
.stampio-modal-bg {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  align-items: center;
  justify-content: center;
}
.stampio-modal-bg.active { display: flex; }
.stampio-modal {
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  width: 260px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
.stampio-modal-icon {
  width: 52px;
  height: 52px;
  background: #fff0f0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.stampio-modal-icon svg { width: 24px; height: 24px; stroke: #e74c3c; fill: none; stroke-width: 2; }
.stampio-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #4a4a48;
  margin-bottom: 6px;
}
.stampio-modal-sub {
  font-size: 12px;
  color: #a0a09c;
  margin-bottom: 18px;
}
.stampio-modal-confirm {
  width: 100%;
  padding: 12px;
  background: #e74c3c;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 8px;
}
.stampio-modal-cancel {
  width: 100%;
  padding: 12px;
  background: #fefaf5;
  border: none;
  border-radius: 14px;
  color: #757575;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ---- Stamp Cutter Animations ---- */

/* Phase 1: Machine slams down */
.stampio-live-frame.stampio-slam {
  animation: stampio-slam-down .25s cubic-bezier(.4, 0, 1, .4) forwards;
}
@keyframes stampio-slam-down {
  0%   { transform: translate(-50%, -50%) rotate(90deg) scale(1); }
  100% { transform: translate(-50%, -50%) rotate(90deg) scale(1.08); }
}

/* Phase 3: Machine releases / bounces back */
.stampio-live-frame.stampio-release {
  animation: stampio-bounce-up .4s cubic-bezier(.2, .8, .3, 1.4) forwards;
}
@keyframes stampio-bounce-up {
  0%   { transform: translate(-50%, -50%) rotate(90deg) scale(1.08); }
  60%  { transform: translate(-50%, -50%) rotate(90deg) scale(0.96); }
  100% { transform: translate(-50%, -50%) rotate(90deg) scale(1); }
}

/* Frozen frame (replaces live video during animation) */
.stampio-freeze {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* Phase 4: Cut-out stamp ejects from machine */
.stampio-cutout {
  position: absolute;
  width: 30%;
  left: 35%;
  top: 50%;
  z-index: 15;
  opacity: 0;
  transform: translateY(-50%) scale(.5);
  filter: drop-shadow(0 6px 20px rgba(0,0,0,.4));
  transition: none;
}
.stampio-cutout.stampio-cutout-eject {
  animation: stampio-eject .8s cubic-bezier(.2, .8, .3, 1.2) forwards;
}
@keyframes stampio-eject {
  0%   { opacity: 0; transform: translateY(-50%) scale(.5); }
  30%  { opacity: 1; transform: translateY(-55%) scale(.85); }
  60%  { opacity: 1; transform: translateY(-65%) scale(1.05); }
  100% { opacity: 1; transform: translateY(-60%) scale(1); }
}

/* Spinner */
.stampio-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248,245,237,.7);
  z-index: 10;
}
.stampio-spinner::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 2px solid rgba(117,117,117,.15);
  border-top-color: #757575;
  border-radius: 50%;
  animation: stampio-spin .6s linear infinite;
}
@keyframes stampio-spin {
  to { transform: rotate(360deg); }
}
