/* ==========================================
   Page baseline
   ========================================== */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: #fdfbf4;
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
  color: #333;
}

/* ==========================================
   Browser-frame mockup wrapper
   ========================================== */
.browser-frame {
  max-width: 1000px;
  margin: 30px auto;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(85, 187, 68, 0.15), 0 2px 8px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  border: 1px solid #eee;
}

@media (max-width: 1040px) {
  .browser-frame {
    margin: 0;
    border-radius: 0;
    border: none;
  }
}

/* Mac-style top bar with traffic-light dots + URL bar */
.top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: #f4f1ea;
  border-bottom: 1px solid #ece6d6;
}
.dots {
  display: flex;
  gap: 7px;
  flex-shrink: 0;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #d0c8b4;
}
.dot:nth-child(1) { background: #ff5f57; }
.dot:nth-child(2) { background: #febc2e; }
.dot:nth-child(3) { background: #28c840; }
.url-bar {
  flex: 1;
  height: 24px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e4dfd1;
}

/* ==========================================
   Header (logo left, icons right)
   ========================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 30px;
  border-bottom: 1px solid #f0eee0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

#logo-container {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.logo-clover {
  width: 100%;
  height: 100%;
  display: block;
}

#logo-images-container {
  width: 44px;
  height: 44px;
}
.logo-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.logo-image.active {
  opacity: 1;
}

.logo-text {
  font-family: 'Mountains of Christmas', cursive;
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 0.5px;
  line-height: 1;
}
.o-green { color: #55bb44; }
.o-yellow { color: #eebb22; }

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.envelope {
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.envelope:hover {
  transform: scale(1.12);
}
.envelope svg {
  width: 100%;
  height: 100%;
  display: block;
}
.profile-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #aadd66;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}
.profile-button:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(85, 187, 68, 0.3);
}
.profile-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================
   Main content + clover SVG sizing
   ========================================== */
.main-content {
  padding: 20px;
}
.clover-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px 20px 60px;
}
.clover-svg {
  width: 100%;
  max-width: 360px;
  height: auto;
  display: block;
}

/* Leaf hover: brighten + soft shadow.
   IMPORTANT: do NOT set CSS transform-origin on .leaf-group —
   it overrides the rotation center baked into the SVG
   transform="rotate(120, 200, 270)" attribute and shoves the
   left/right leaves out of the viewBox. */
.leaf-group {
  cursor: pointer;
  transition: filter 0.2s ease;
}
.leaf-group:hover {
  filter: brightness(1.08) drop-shadow(0 2px 4px rgba(85, 187, 68, 0.3));
}

/* ==========================================
   Modal base (covers email, contact, drawing, gallery, gesture)
   ========================================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(40, 50, 30, 0.55);
  z-index: 1000;
  overflow-y: auto;
  padding: 30px 20px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: #ffffff;
  margin: 0 auto;
  padding: 36px 32px 28px;
  border-radius: 16px;
  max-width: 480px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
  animation: modal-pop 0.18s ease-out;
}
@keyframes modal-pop {
  from { transform: translateY(12px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

.close-modal,
.close-contact,
.close-drawing,
.close-gallery,
.close-gesture {
  position: absolute;
  top: 10px;
  right: 16px;
  font-size: 32px;
  line-height: 1;
  color: #aaa;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, transform 0.15s ease;
}
.close-modal:hover,
.close-contact:hover,
.close-drawing:hover,
.close-gallery:hover,
.close-gesture:hover {
  color: #55bb44;
  transform: scale(1.15);
}

.contact-title {
  font-family: 'Mountains of Christmas', cursive;
  font-size: 42px;
  color: #55bb44;
  text-align: center;
  margin-top: 20px;
  margin-bottom: 30px;
  font-weight: bold;
}

/* Modal title styling */
.modal-title {
  font-family: 'Mountains of Christmas', cursive;
  font-size: 36px;
  color: #55bb44;
  text-align: center;
  margin-bottom: 20px;
  font-weight: bold;
}

/* Drawing modal styles */
.drawing-modal-content {
  max-width: 900px;
  min-height: 600px;
}

.canvas-container {
  position: relative;
  width: 100%;
  height: 400px;
  border: 3px solid #aadd66;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  margin-bottom: 20px;
}

#drawing-canvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: block;
}

.drawing-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background: #f0ffe0;
  border-radius: 8px;
}

.color-picker-group,
.brush-size-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.color-picker-group label,
.brush-size-group label {
  font-size: 16px;
  color: #333;
  font-weight: bold;
}

#brush-color {
  width: 50px;
  height: 40px;
  border: 2px solid #aadd66;
  border-radius: 6px;
  cursor: pointer;
}

#brush-size {
  width: 150px;
  cursor: pointer;
}

#brush-size-value {
  font-size: 16px;
  font-weight: bold;
  color: #55bb44;
  min-width: 30px;
}

.drawing-buttons {
  display: flex;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: 'Patrick Hand', cursive, sans-serif;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background-color: #55bb44;
  color: white;
}

.btn-primary:hover {
  background-color: #33aa33;
  transform: scale(1.05);
}

.btn-secondary {
  background-color: #eebb22;
  color: white;
}

.btn-secondary:hover {
  background-color: #ddaa11;
  transform: scale(1.05);
}

.btn-secondary:disabled {
  background-color: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* Gallery modal styles */
.gallery-modal-content {
  max-width: 1000px;
  min-height: 600px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
  max-height: 500px;
  overflow-y: auto;
}

.gallery-item {
  position: relative;
  border: 3px solid #aadd66;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.gallery-item:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.gallery-item img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.gallery-item-info {
  padding: 10px;
  background: #f0ffe0;
  text-align: center;
}

.gallery-item-date {
  font-size: 14px;
  color: #666;
}

.gallery-item-actions {
  display: flex;
  gap: 5px;
  justify-content: center;
  padding: 10px;
}

.gallery-item-actions button {
  padding: 5px 10px;
  font-size: 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Patrick Hand', cursive, sans-serif;
}

.delete-btn {
  background-color: #ff4444;
  color: white;
}

.delete-btn:hover {
  background-color: #cc3333;
}

.download-btn {
  background-color: #55bb44;
  color: white;
}

.download-btn:hover {
  background-color: #33aa33;
}

.no-artworks {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 20px;
}

/* Gesture modal styles */
.gesture-modal-content {
  max-width: 1000px;
  min-height: 700px;
}

.gesture-instructions {
  text-align: center;
  padding: 15px;
  background: #f0ffe0;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 18px;
  color: #333;
}

.video-container {
  position: relative;
  width: 100%;
  height: 450px;
  border: 3px solid #aadd66;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin-bottom: 20px;
}

#gesture-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.7;
  /* Mirror the front camera so movements feel natural
     (right hand on screen = your actual right hand).
     The overlay canvas already mirrors landmarks via ctx.scale(-1,1),
     so they stay aligned with the mirrored video. */
  transform: scaleX(-1);
}

#gesture-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.clover-growth-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 350px;
  pointer-events: none;
}

#growth-clover {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.gesture-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.gesture-controls button {
  padding: 12px 30px;
  font-size: 18px;
}

.growth-indicator {
  font-size: 20px;
  font-weight: bold;
  color: #55bb44;
  padding: 10px 20px;
  background: #f0ffe0;
  border-radius: 8px;
  border: 2px solid #aadd66;
}

#growth-level {
  font-size: 24px;
  color: #33aa33;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .drawing-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .drawing-buttons {
    justify-content: center;
  }
  
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .video-container {
    height: 350px;
  }
  
  .clover-growth-display {
    width: 250px;
    height: 300px;
  }
}

/* ==========================================
   Dewdrop / ladybug hover reveal
   The SVG has opacity="0" by default; make them visible
   when hovering the parent leaf-group so they can be clicked.
   ========================================== */
.dewdrop, .ladybug, .star-icon {
  pointer-events: all;
  cursor: pointer;
  transition: opacity 0.3s ease-in-out;
}
.leaf-group[data-leaf="top"]:hover .dewdrop,
.dewdrop:hover,
.leaf-group[data-leaf="right"]:hover .ladybug,
.ladybug:hover,
.leaf-group[data-leaf="left"]:hover .star-icon,
.star-icon:hover {
  opacity: 1;
}
/* Gentle twinkle so the star feels alive once revealed */
.star-icon {
  animation: star-twinkle 2.4s ease-in-out infinite;
}
@keyframes star-twinkle {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 210, 90, 0.5)); }
  50%      { filter: drop-shadow(0 0 10px rgba(255, 210, 90, 0.95)); }
}

/* ==========================================
   Drawing tool palette (iPad-style buttons)
   ========================================== */
.tool-palette {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: #f4f9eb;
  border: 1px solid #d9ecbf;
  border-radius: 10px;
  margin-bottom: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.tool-btn {
  width: 52px;
  height: 52px;
  border: 2px solid #cfe6a8;
  background: #ffffff;
  border-radius: 10px;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
              border-color 0.15s ease, background 0.15s ease;
}
.tool-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(85, 187, 68, 0.2);
  border-color: #aadd66;
}
.tool-btn.active {
  background: #eaf6d8;
  border-color: #33aa33;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(85, 187, 68, 0.35), inset 0 0 0 2px rgba(85,187,68,0.15);
}

/* ==========================================
   Toast notifications
   ========================================== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translate(-50%, 20px);
  padding: 12px 28px;
  border-radius: 10px;
  font-family: 'Patrick Hand', cursive, sans-serif;
  font-size: 17px;
  font-weight: bold;
  color: #ffffff;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast-show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-info,
.toast-success {
  background: #55bb44;
}
.toast-error {
  background: #ff4444;
}

/* ==========================================
   Gallery loading / error states
   ========================================== */
.gallery-loading,
.gallery-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 50px 20px;
  font-size: 18px;
  font-family: 'Patrick Hand', cursive, sans-serif;
}
.gallery-loading { color: #55bb44; }
.gallery-error { color: #ff4444; }

/* ==========================================
   Gesture controls: button row layout
   ========================================== */
.gesture-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ==========================================
   Growth clover: smooth stem draw + leaf scale
   ========================================== */
.growth-stem {
  /* dasharray/offset set inline by JS; transition gives a soft growth feel */
  transition: stroke-dashoffset 0.18s ease-out;
}
.growth-leaf {
  transition: transform 0.18s ease-out;
}

