/* --- Filter You Theme Foundation --- */
:root {
    --bg-ultra-light: #f8faff; 
    --bg-subtle-accent: #eef4ff; 
    --text-dark-pop: #3a3560; 
    --text-medium-pop: #6b6399;
    --clr-hot-pink: #ff33a8; 
    --clr-electric-blue: #00aaff; 
    --clr-sunny-yellow: #f9d423;
    --clr-vibrant-purple: #a855f7; 
    --clr-candy-orange: #ff8c42;
    --font-heading: 'Fredoka One', cursive; 
    --font-body: 'Poppins', sans-serif; 
    --shadow-funky: 3px 3px 0px var(--text-dark-pop); 
    --shadow-funky-hover: 5px 5px 0px var(--clr-electric-blue);
}

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; font-family: var(--font-body);
}

body {
  background-color: #000;
  color: var(--text-dark-pop);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  display: flex; justify-content: center; align-items: center;
}

#main-app-container {
    width: 100%; height: 100%;
    position: relative;
    background-color: #000;
}

#canvas-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 30px;
  border: 4px solid var(--text-dark-pop);
  box-shadow: var(--shadow-funky);
  overflow: hidden;
}

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

.poweredbysnap-logo {
  position: absolute; bottom: 25px; left: 25px; z-index: 10;
}
.poweredbysnap-logo > img {
  width: 110px; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.2)); display: block;
}

#video-preview-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(58, 53, 96, 0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 2000; display: flex; justify-content: center;
  align-items: center; padding: 20px; box-sizing: border-box;
}
#video-preview-popup {
  position: relative; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  width: 100%; max-width: 450px; max-height: 90vh;
  background: var(--bg-ultra-light);
  border: 3px solid var(--text-dark-pop); border-radius: 20px;
  padding: 20px; padding-top: 50px;
  box-shadow: var(--shadow-funky); box-sizing: border-box;
}
#preview-video {
  max-width: 100%; max-height: calc(90vh - 150px);
  object-fit: contain; border-radius: 12px;
  border: 2px solid var(--bg-subtle-accent);
}
#close-preview-button {
  position: absolute; top: 10px; right: 10px;
  width: 35px; height: 35px; background: var(--bg-subtle-accent);
  color: var(--text-dark-pop); border: 2px solid var(--text-dark-pop);
  border-radius: 50%; font-family: sans-serif; font-size: 22px;
  font-weight: bold; line-height: 31px; text-align: center;
  cursor: pointer; z-index: 2005; transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#close-preview-button:active {
    transform: rotate(90deg) scale(1.0);
}
#popup-actions {
  width: 100%; display: flex;
  flex-direction: row;
  justify-content: center; 
  gap: 15px; 
  margin-top: 25px;
}
.cta-button { 
  background: linear-gradient(45deg, var(--clr-hot-pink), var(--clr-candy-orange));
  color: #fff !important; padding: 1rem 0;
  width: 120px;
  text-align: center;
  text-decoration: none; font-size: 1.1em; font-family: var(--font-heading);
  border-radius: 12px; transition: all 0.2s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  display: inline-block; box-shadow: var(--shadow-funky);
  border: 2px solid var(--text-dark-pop);
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2); cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cta-button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 2px 2px 0px var(--text-dark-pop);
    filter: brightness(0.95);
}

#controls {
  position: absolute; bottom: 5%; width: 100%;
  display: flex; justify-content: center; align-items: center;
  z-index: 999;
}
#capture-button {
  height: 95px; width: 95px; background-color: transparent;
  border: none; border-radius: 50%; z-index: 1000;
  transition: all 0.2s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  cursor: pointer;
  box-shadow: var(--shadow-funky); position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#capture-button::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 100%; height: 100%;
  background-color: var(--bg-ultra-light);
  border: 6px solid var(--clr-hot-pink); border-radius: 50%;
  box-sizing: border-box; transition: all 0.2s ease;
}
#capture-button::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 65px; height: 65px;
  background-color: var(--clr-hot-pink); border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
#capture-button:active {
    transform: translateY(2px) scale(0.95);
    box-shadow: 2px 2px 0px var(--text-dark-pop);
}
#capture-button.recording::before { animation: pulse-border 1.5s infinite; }
#capture-button.recording::after { border-radius: 25%; background-color: #DB0007; }

@keyframes pulse-border {
  0% { border-color: var(--clr-hot-pink); }
  50% { border-color: var(--clr-electric-blue); }
  100% { border-color: var(--clr-hot-pink); }
}

#loading-global {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(58, 53, 96, 0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  z-index: 4000; display: flex; justify-content: center; align-items: center;
}
.spinner {
  width: 60px; height: 60px; border: 7px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--clr-sunny-yellow); border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 500px) {
  #capture-button { height: 85px; width: 85px; }
  #capture-button::after { width: 55px; height: 55px; }
  #video-preview-popup { padding: 15px; padding-top: 45px; }
  .cta-button { width: 100px; padding: 0.8rem 0; font-size: 1em; }
  #popup-actions { flex-direction: row; }
}

/* --- THEMED START SCREEN STYLES (Mobile-First) --- */
#start-screen {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 5000;
  display: flex; justify-content: center; align-items: center;
  background-color: var(--bg-ultra-light);
  padding: 10px;
  box-sizing: border-box;
}

#start-screen-content {
  background: var(--bg-subtle-accent);
  width: 100%;
  height: 100%;
  border: 4px solid var(--text-dark-pop);
  box-sizing: border-box;
  border-radius: 30px;
  padding: 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#start-screen-interactive #start-button {
  padding: 1.2rem 0;
  width: 200px;
  font-size: 1.5em;
}

#start-screen-interactive #start-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#start-screen-logo {
    max-width: 80%;
    width: 250px;
    height: auto;
    margin-bottom: 50px;
}

#permission-status {
  margin-top: 20px;
  color: var(--clr-hot-pink);
  font-weight: 600;
  min-height: 2em;
  line-height: 1.4;
}

#start-screen-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-medium-pop);
  font-size: 1.2em;
}

#start-screen-loader .spinner {
    margin-bottom: 20px;
}

/* --- DESKTOP OVERRIDES --- */
@media (min-width: 768px) {
  #start-screen-content {
    width: auto;
    height: auto;
    max-width: 500px;
    box-shadow: var(--shadow-funky);
  }
}

/* --- HOVER-SPECIFIC STYLES (for mouse users) --- */
@media (hover: hover) {
  #close-preview-button:hover {
    background-color: var(--clr-sunny-yellow);
    transform: rotate(90deg) scale(1.1);
    box-shadow: var(--shadow-funky);
  }

  .cta-button:hover { 
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-funky-hover);
    filter: brightness(1.1);
  }

  #capture-button:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-funky-hover);
  }
}

/* NEW: Photo Preview Styles */
#photo-preview-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-color: rgba(58, 53, 96, 0.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 2000; display: flex; justify-content: center;
  align-items: center; padding: 20px; box-sizing: border-box;
}
#photo-preview-popup {
  position: relative; display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  width: 100%; max-width: 450px; max-height: 90vh;
  background: var(--bg-ultra-light);
  border: 3px solid var(--text-dark-pop); border-radius: 20px;
  padding: 20px; padding-top: 50px;
  box-shadow: var(--shadow-funky); box-sizing: border-box;
}
#preview-image {
  max-width: 100%; max-height: calc(90vh - 150px);
  object-fit: contain; border-radius: 12px;
  border: 2px solid var(--bg-subtle-accent);
  aspect-ratio: 9 / 16;
}
#close-photo-preview-button {
  position: absolute; top: 10px; right: 10px;
  width: 35px; height: 35px; background: var(--bg-subtle-accent);
  color: var(--text-dark-pop); border: 2px solid var(--text-dark-pop);
  border-radius: 50%; font-family: sans-serif; font-size: 22px;
  font-weight: bold; line-height: 31px; text-align: center;
  cursor: pointer; z-index: 2005; transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#close-photo-preview-button:active {
    transform: rotate(90deg) scale(1.0);
}
#photo-popup-actions {
  width: 100%; display: flex;
  flex-direction: row;
  justify-content: center; 
  gap: 15px; 
  margin-top: 25px;
}
@media (hover: hover) {
  #close-photo-preview-button:hover {
    background-color: var(--clr-sunny-yellow);
    transform: rotate(90deg) scale(1.1);
    box-shadow: var(--shadow-funky);
  }
}
