/*
  Toddler Music Box - Stylesheet
  Bubbly, colorful, toddler-friendly, and responsive.
*/

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Quicksand:wght@500;700&display=swap');

:root {
  --font-kids: 'Fredoka', cursive;
  --font-text: 'Quicksand', sans-serif;
  
  /* Vibrant, kid-friendly palette */
  --bg-color: #FFFAEC;
  --panel-bg: #FFFFFF;
  --border-color: #3D3D3D;
  --text-color: #3D3D3D;
  
  /* Card colors with matching dark shadows for 3D effect */
  --color-1: #FFE066; --color-1-shadow: #F5C200;
  --color-2: #63E6BE; --color-2-shadow: #20C997;
  --color-3: #72C3FC; --color-3-shadow: #339AF0;
  --color-4: #FF93B4; --color-4-shadow: #F06595;
  --color-5: #D0BFFF; --color-5-shadow: #B197FC;
  --color-6: #FFC078; --color-6-shadow: #FFA94D;
  
  --shadow-color: rgba(61, 61, 61, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input, select, textarea, [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}


body {
  font-family: var(--font-text);
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Fullscreen app container */
#app {
  width: 100%;
  height: 100%;
  max-width: 600px; /* Tablet portrait simulation on desktop */
  background-color: var(--bg-color);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
  border-left: 2px solid rgba(0,0,0,0.02);
  border-right: 2px solid rgba(0,0,0,0.02);
}

/* Header style with settings button */
header {
  height: 60px;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: transparent;
  z-index: 10;
}

h1 {
  font-family: var(--font-kids);
  font-size: 1.5rem;
  color: #FF6B8B;
  text-shadow: 1px 1px 0px #FFFFFF, 2px 2px 0px rgba(0,0,0,0.1);
  letter-spacing: 0.5px;
}

/* Settings Gear button with holding indication */
.settings-btn {
  background: white;
  border: 3px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--border-color);
  transition: transform 0.1s, box-shadow 0.1s;
  position: relative;
  overflow: hidden;
}

.settings-btn svg {
  width: 22px;
  height: 22px;
  fill: var(--text-color);
  transition: transform 3s linear;
}

.settings-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border-color);
}

/* Bouncy scale rotation during hold */
.settings-btn.holding svg {
  transform: rotate(360deg);
}

/* Progress overlay for holding */
.hold-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background-color: rgba(255, 107, 139, 0.3);
  transition: height 0.1s linear;
  pointer-events: none;
}

/* Grid of 6 cards */
.grid-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 16px;
  padding: 16px;
  padding-bottom: 8px;
}

/* Individual toddler card */
.music-card {
  border: 4px solid var(--border-color);
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}

.music-card .card-icon {
  filter: drop-shadow(2px 4px 0px rgba(0,0,0,0.1));
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.music-card .card-title {
  margin-top: 8px;
  font-family: var(--font-kids);
  color: var(--text-color);
  text-align: center;
  padding: 0 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

/* Grid responsive scaling based on column count */
.grid-cols-2 .music-card .card-icon { font-size: clamp(3rem, 12vw, 4.5rem); }
.grid-cols-2 .music-card .card-title { font-size: 0.95rem; }

.grid-cols-3 .music-card .card-icon { font-size: clamp(2.4rem, 8vw, 3.8rem); }
.grid-cols-3 .music-card .card-title { font-size: 0.85rem; }

.grid-cols-4 .music-card .card-icon { font-size: clamp(1.9rem, 6vw, 3.0rem); }
.grid-cols-4 .music-card .card-title { font-size: 0.75rem; }

.grid-cols-5 .music-card .card-icon { font-size: clamp(1.5rem, 4.5vw, 2.2rem); }
.grid-cols-5 .music-card .card-title { font-size: 0.65rem; }

/* Distinct card backgrounds & 3D shadows */
.card-0 { background-color: var(--color-1); box-shadow: 0 8px 0 var(--color-1-shadow), 0 8px 0 var(--border-color), 0 12px 10px rgba(0,0,0,0.15); }
.card-1 { background-color: var(--color-2); box-shadow: 0 8px 0 var(--color-2-shadow), 0 8px 0 var(--border-color), 0 12px 10px rgba(0,0,0,0.15); }
.card-2 { background-color: var(--color-3); box-shadow: 0 8px 0 var(--color-3-shadow), 0 8px 0 var(--border-color), 0 12px 10px rgba(0,0,0,0.15); }
.card-3 { background-color: var(--color-4); box-shadow: 0 8px 0 var(--color-4-shadow), 0 8px 0 var(--border-color), 0 12px 10px rgba(0,0,0,0.15); }
.card-4 { background-color: var(--color-5); box-shadow: 0 8px 0 var(--color-5-shadow), 0 8px 0 var(--border-color), 0 12px 10px rgba(0,0,0,0.15); }
.card-5 { background-color: var(--color-6); box-shadow: 0 8px 0 var(--color-6-shadow), 0 8px 0 var(--border-color), 0 12px 10px rgba(0,0,0,0.15); }

/* Card active tap states */
.music-card:active {
  transform: translateY(6px);
}
.music-card.card-0:active { box-shadow: 0 2px 0 var(--color-1-shadow), 0 2px 0 var(--border-color), 0 4px 4px rgba(0,0,0,0.1); }
.music-card.card-1:active { box-shadow: 0 2px 0 var(--color-2-shadow), 0 2px 0 var(--border-color), 0 4px 4px rgba(0,0,0,0.1); }
.music-card.card-2:active { box-shadow: 0 2px 0 var(--color-3-shadow), 0 2px 0 var(--border-color), 0 4px 4px rgba(0,0,0,0.1); }
.music-card.card-3:active { box-shadow: 0 2px 0 var(--color-4-shadow), 0 2px 0 var(--border-color), 0 4px 4px rgba(0,0,0,0.1); }
.music-card.card-4:active { box-shadow: 0 2px 0 var(--color-5-shadow), 0 2px 0 var(--border-color), 0 4px 4px rgba(0,0,0,0.1); }
.music-card.card-5:active { box-shadow: 0 2px 0 var(--color-6-shadow), 0 2px 0 var(--border-color), 0 4px 4px rgba(0,0,0,0.1); }

/* Spin / pop icon animations when card is playing */
.music-card.playing .card-icon {
  animation: playPulse 1.2s infinite ease-in-out alternate;
}

@keyframes playPulse {
  0% { transform: scale(1) rotate(-3deg); }
  100% { transform: scale(1.15) rotate(3deg); }
}

@keyframes musicBar1 {
  0% { height: 4px; }
  100% { height: 20px; }
}

@keyframes musicBar2 {
  0% { height: 8px; }
  100% { height: 16px; }
}

@keyframes musicBar3 {
  0% { height: 12px; }
  100% { height: 20px; }
}


/* Now Playing Panel at the bottom */
.now-playing-panel {
  background-color: var(--panel-bg);
  border-top: 4px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
  position: relative;
  z-index: 5;
}

.now-playing-panel.hidden {
  height: 0;
  padding: 0;
  overflow: hidden;
  border-top-width: 0;
}

.panel-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.panel-title {
  font-family: var(--font-kids);
  font-size: 0.9rem;
  color: #72C3FC;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-title::before {
  content: "🎵";
  animation: noteFloat 1s infinite alternate;
}

@keyframes noteFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}

.stop-btn {
  background: #FF6B8B;
  border: 2px solid var(--border-color);
  color: white;
  font-family: var(--font-kids);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border-color);
}

.stop-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border-color);
}

/* Active player container wrapper */
.player-container {
  width: 100%;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  background: #f8f9fa;
}

.player-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Confetti particle canvas container */
#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* Parent Modal Styling */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-content {
  background: white;
  border: 4px solid var(--border-color);
  border-radius: 28px;
  width: 90%;
  max-width: 450px;
  max-height: 85%;
  display: flex;
  flex-direction: column;
  padding: 24px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.25);
  transform: scale(0.85);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed #DDD;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.modal-title {
  font-family: var(--font-kids);
  font-size: 1.3rem;
  color: var(--text-color);
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: #999;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 10px;
}

/* Parent Lock Modal specifics */
.lock-challenge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.lock-question {
  font-family: var(--font-kids);
  font-size: 1.2rem;
  color: var(--text-color);
}

.lock-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin-top: 10px;
}

.lock-option-btn {
  background: white;
  border: 3px solid var(--border-color);
  padding: 14px;
  border-radius: 16px;
  font-family: var(--font-kids);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--border-color);
  transition: all 0.1s;
}

.lock-option-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border-color);
}

.lock-option-btn.color-yellow { background-color: #FFF3BF; }
.lock-option-btn.color-blue { background-color: #D0EBFF; }
.lock-option-btn.color-red { background-color: #FFD8A8; }
.lock-option-btn.color-green { background-color: #D3F9D8; }

/* Settings form styling */
.settings-section-title {
  font-family: var(--font-kids);
  font-size: 1.05rem;
  margin-top: 16px;
  margin-bottom: 8px;
  color: #72C3FC;
  border-bottom: 2px solid #E9ECEF;
  padding-bottom: 4px;
}

.helper-card {
  background: #E8F7FF;
  border: 2px solid #A2DCFF;
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.helper-card p {
  margin-bottom: 8px;
}

.helper-card p:last-child {
  margin-bottom: 0;
}

.helper-btn {
  display: inline-block;
  background: #339AF0;
  color: white;
  text-decoration: none;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 8px;
  margin-top: 4px;
  border: 2px solid var(--border-color);
  box-shadow: 0 2px 0 var(--border-color);
}

.helper-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--border-color);
}

.settings-row {
  margin-bottom: 16px;
  border: 2px solid #E9ECEF;
  border-radius: 16px;
  padding: 12px;
  background-color: #FCFDFE;
}

.settings-row-header {
  font-weight: bold;
  font-family: var(--font-kids);
  font-size: 0.9rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-index-badge {
  background-color: #3D3D3D;
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.form-group {
  margin-bottom: 8px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 3px;
  color: #666;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid #CED4DA;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: #3D3D3D;
}

.form-row-grid {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 8px;
}

.select-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233D3D3D' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  padding-right: 24px;
}

.action-buttons {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 12px;
  border-radius: 16px;
  font-family: var(--font-kids);
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  border: 3px solid var(--border-color);
  box-shadow: 0 4px 0 var(--border-color);
  transition: all 0.1s;
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border-color);
}

.btn-primary {
  background-color: #51CF66;
  color: white;
}

.btn-secondary {
  background-color: #E9ECEF;
  color: var(--text-color);
}

/* Sound indicator helper in settings test player */
.test-player-wrapper {
  margin-top: 10px;
  border: 2px dashed #B5FFFC;
  border-radius: 12px;
  padding: 8px;
  background-color: #F8FFFF;
}

/* Safe Area Support for newer phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .now-playing-panel {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* Responsive adjustments for iPad / larger tablets */
@media (min-width: 768px) {
  #app {
    max-width: 900px;
  }
}
