/* ==========================================================================
   MOLDURA CAM - Premium CSS Stylesheet
   ========================================================================== */

/* Design Tokens & Variables */
:root {
  --font-primary: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;
  
  /* Color Palette - Capoeira Golden Amber & Dark Warm Accent Theme */
  --clr-bg: #0c0a08;
  --clr-surface: #181410;
  --clr-primary: #f59e0b;
  --clr-primary-glow: rgba(245, 158, 11, 0.4);
  --clr-secondary: #dc2626;
  --clr-secondary-glow: rgba(220, 38, 38, 0.4);
  
  --clr-text-main: #fef3c7;
  --clr-text-muted: #d97706;
  
  /* Glassmorphism */
  --glass-bg: rgba(24, 20, 16, 0.7);
  --glass-border: rgba(245, 158, 11, 0.2);
  --glass-blur: blur(16px);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-primary);
  background: #0a0806 url('assets/bg.jpg') center/cover no-repeat fixed;
  color: var(--clr-text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: url('assets/fundo.png') center/100% 100% no-repeat;
  pointer-events: none;
  z-index: 0;
  opacity: 0.9;
}

html {
  height: -webkit-fill-available;
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: -webkit-fill-available;
  position: relative;
  background: linear-gradient(180deg, rgba(12, 10, 8, 0.75) 0%, rgba(12, 10, 8, 0.88) 100%), url('assets/bg.jpg') center/cover no-repeat;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.app-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('assets/fundo.png') center/100% 100% no-repeat;
  pointer-events: none;
  z-index: 2;
  opacity: 0.85;
}

/* Screen Transitions */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  z-index: 1;
  background-color: var(--clr-bg);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
  z-index: 10;
}

/* Icons */
.icon {
  width: 20px;
  height: 20px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-inline {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: text-bottom;
  margin-right: 6px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   SCREEN 1: LANDING & PERMISSION
   ========================================================================== */
#screen-permission {
  justify-content: center;
  align-items: center;
  padding: 2rem 1.5rem;
  background: radial-gradient(circle at top, rgba(245, 158, 11, 0.25) 0%, transparent 65%), linear-gradient(180deg, rgba(12, 10, 8, 0.65) 0%, rgba(12, 10, 8, 0.85) 100%);
}

.landing-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 380px;
  position: relative;
  z-index: 5;
}

.logo-wrapper {
  width: 120px;
  height: 120px;
  margin-bottom: 1.25rem;
  position: relative;
}

.app-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.5), 0 0 15px rgba(220, 38, 38, 0.3);
  border: 3px solid #f59e0b;
}

.app-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.3rem;
  line-height: 1.1;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 10%, #fbbf24 60%, #dc2626 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.app-subtitle {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #fde68a;
  margin-bottom: 1.2rem;
  padding: 0 1rem;
}

/* Capoeira Action Banner */
.capoeira-banner-wrapper {
  width: 100%;
  max-width: 320px;
  height: 110px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.2rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.capoeira-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Preview Grid (Landing page cards - 9:16 ratio) */
.frames-preview-grid {
  display: flex;
  gap: 12px;
  margin-bottom: 2rem;
  width: 100%;
  justify-content: center;
}

.preview-card {
  width: 90px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  padding: 8px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: rotate(var(--angle));
  box-shadow: var(--glass-shadow);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.preview-card:hover {
  transform: scale(1.08) rotate(0deg);
  border-color: var(--clr-primary);
}

.preview-card.active {
  transform: scale(1.1) rotate(0deg);
  border-color: var(--clr-primary);
  box-shadow: 0 0 20px var(--clr-primary-glow);
}

.preview-card.active span {
  color: var(--clr-text-main);
  font-weight: 700;
}

.preview-img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 6px;
  background-color: rgba(255, 255, 255, 0.03);
}

.preview-card span {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--clr-text-muted);
}

/* Privacy Note */
.privacy-note {
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  margin-top: 1.5rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 300px;
}

/* Animations */
.animate-pulse {
  animation: pulse 3s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}


/* ==========================================================================
   SCREEN 2: CAMERA VIEW (INSTAGRAM STORIES 9:16 FULLSCREEN)
   ========================================================================== */

#screen-camera {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
}

/* Header overlay */
.app-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 30;
  pointer-events: auto;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-small {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.header-logo span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Main Camera Preview Area (Fullscreen 9:16) */
.camera-viewport-wrapper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  margin: 0;
  padding: 0;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #000;
  overflow: hidden;
}

/* Video configuration */
#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* default to mirror (front camera) */
  transition: transform var(--transition-normal);
  background-color: #000;
}

#webcam.environment-mode {
  transform: scaleX(1); /* no mirror for back camera */
}

/* Moldura Frame Overlay (9:16 Fullscreen overlay) */
#frame-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 5;
}

/* Grid/Guide overlay */
.camera-guide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.guide-text {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.55);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.75rem;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 500;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: pulse-guide 2.5s infinite ease-in-out;
}

@keyframes pulse-guide {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.9; }
}

/* Camera loading placeholder */
.camera-loader {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--clr-surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 6;
  opacity: 1;
  transition: opacity var(--transition-normal) ease-out;
}

.camera-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(138, 43, 226, 0.2);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-bottom: 12px;
}

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

.camera-loader p {
  font-size: 0.85rem;
  color: var(--clr-text-muted);
}

/* Floating Bottom Controls Container (Instagram Stories style) */
.camera-overlay-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 65%, transparent 100%);
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  pointer-events: auto;
}

/* Active frame label section */
.section-title-container {
  text-align: center;
  margin-bottom: 0.5rem;
}

.active-frame-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 14px;
  border-radius: 20px;
  backdrop-filter: blur(8px);
}

/* Carousel (horizontal list of floating frames) */
.carousel-container {
  width: 100%;
  padding: 0.25rem 0;
  margin-bottom: 0.5rem;
}

.frames-carousel {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px 1.5rem;
  scrollbar-width: none; /* Firefox */
}

.frames-carousel::-webkit-scrollbar {
  display: none; /* Safari / Chrome */
}

.carousel-item {
  flex: 0 0 72px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.carousel-item:active {
  transform: scale(0.95);
}

.carousel-img-wrapper {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 3px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.carousel-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.02);
}

.carousel-label {
  font-size: 0.65rem;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
  transition: color var(--transition-fast);
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

/* Active carousel item styling */
.carousel-item.active .carousel-img-wrapper {
  border-color: var(--clr-primary);
  box-shadow: 0 0 16px var(--clr-primary-glow);
  transform: scale(1.1);
}

.carousel-item.active .carousel-label {
  color: #fff;
  font-weight: 700;
}

/* Upload new frame item styling */
.carousel-item.upload-btn-item .carousel-img-wrapper {
  border: 2px dashed rgba(255, 255, 255, 0.5);
  background: rgba(138, 43, 226, 0.25);
  display: flex;
  justify-content: center;
  align-items: center;
}

.carousel-item.upload-btn-item:hover .carousel-img-wrapper {
  border-color: var(--clr-primary);
  background: rgba(138, 43, 226, 0.4);
}

.carousel-item.upload-btn-item svg {
  width: 24px;
  height: 24px;
  stroke: #fff;
}

/* Control Bar (Shutter & actions) */
.bottom-controls {
  width: 100%;
  padding: 0.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.control-placeholder {
  width: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* The Capture Shutter Button */
.shutter-button {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background-color: transparent;
  border: 4px solid #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  outline: none;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.3);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.shutter-button:hover {
  transform: scale(1.06);
  border-color: var(--clr-secondary);
}

.shutter-button:active {
  transform: scale(0.92);
}

.shutter-inner {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(45deg, var(--clr-primary), var(--clr-secondary));
  transition: transform var(--transition-fast);
}

.shutter-button:active .shutter-inner {
  transform: scale(0.85);
}


/* ==========================================================================
   SCREEN 3: PREVIEW & SHARE (INSTAGRAM STORIES 9:16 PREVIEW)
   ========================================================================== */
#screen-preview {
  background-color: rgba(9, 9, 11, 0.96);
  backdrop-filter: blur(20px);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.preview-modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 1.25rem;
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-header {
  text-align: center;
  margin-bottom: 1rem;
}

.preview-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.preview-header p {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
}

/* 9:16 Stories Cropped output container */
.captured-image-container {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 9 / 16;
  max-height: 48vh;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-color: #000;
}

#captured-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sharing buttons layout */
.share-actions-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-btn-main {
  width: 100%;
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.share-instructions {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--clr-text-muted);
  text-align: center;
  margin: 4px 0;
}

.share-instructions em {
  font-style: normal;
  color: #fff;
  font-weight: 600;
}

/* Button UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--clr-primary) 0%, var(--clr-secondary) 100%);
  color: #fff;
}

.btn-glow {
  box-shadow: 0 4px 15px var(--clr-primary-glow);
}

.btn-glow:hover {
  box-shadow: 0 6px 20px rgba(255, 0, 127, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--glass-blur);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.share-btn-whatsapp {
  background-color: #25d366;
  color: #fff;
  border: none;
}

.share-btn-whatsapp:hover {
  background-color: #20ba5a;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.btn-outline {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.4);
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(20, 20, 25, 0.4);
  border: 1px solid var(--glass-border);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon:active {
  transform: scale(0.9);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-pwa-install {
  color: #fff;
  border-color: var(--clr-primary);
  background: rgba(138, 43, 226, 0.2);
}


/* ==========================================================================
   TOASTS & MODALS
   ========================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(18, 18, 22, 0.9);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  z-index: 100;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Help Modal overlay styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #18181f;
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 2rem;
  width: 85%;
  max-width: 360px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-content h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-content ol {
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-content ol li::marker {
  color: var(--clr-primary);
  font-weight: bold;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* Support for very small devices */
@media (max-height: 667px) {
  #screen-permission {
    padding: 1rem;
  }
  .app-title {
    font-size: 2rem;
  }
  .frames-preview-grid {
    margin-bottom: 1.5rem;
  }
  .logo-wrapper {
    width: 90px;
    height: 90px;
  }
  .bottom-controls {
    padding-bottom: 1.5rem;
  }
}
