/* Custom styles for GeminiCard app (extracted from inline) */

/* === 3D Flashcard flip (study modes: flip / srs / voiceFlip) ===
   BUGFIX: never apply rotateY on the outer .flipped alone — that mirrors
   the back face when it is simply display:block'd. Proper pattern:
   outer = perspective; inner = preserve-3d + rotate on flip;
   both faces = backface-visibility:hidden; back face pre-rotated 180°.
*/
.perspective-1000 { perspective: 1000px; }
.transform-style-3d { transform-style: preserve-3d; }
.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.rotate-y-180 { transform: rotateY(180deg); }

/* DO NOT use a bare `.flipped { transform: rotateY(180deg) }` —
   it mirrors text on show/hide flip cards. Scoped rules only: */

.flip-card {
  perspective: 1000px;
  position: relative;
  /* outer card must NOT rotate — only .flip-card-inner does */
  transform: none !important;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  min-height: 100%;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card .front,
.flip-card .back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  width: 100%;
}

.flip-card .front {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Back is pre-rotated so after parent rotateY(180) it reads upright */
.flip-card .back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  padding: inherit;
  box-sizing: border-box;
}

/* Fallback when markup has no .flip-card-inner (legacy): show/hide only, no 3D rotate */
.flip-card:not(:has(.flip-card-inner)) .back {
  display: none;
  position: static;
  transform: none;
  -webkit-transform: none;
}
.flip-card:not(:has(.flip-card-inner)).flipped .front {
  display: none;
}
.flip-card:not(:has(.flip-card-inner)).flipped .back {
  display: flex;
}

/* === Study Modal micro-interactions (commercial juice) === */
@keyframes vocab-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(6px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(2px); }
}

@keyframes vocab-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  70% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

@keyframes vocab-combo-bounce {
  0% { transform: scale(0.6) translateY(6px); opacity: 0; }
  50% { transform: scale(1.15) translateY(-2px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.animate-shake {
  animation: vocab-shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.animate-pop {
  animation: vocab-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.animate-combo-bounce {
  animation: vocab-combo-bounce 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.study-feedback-correct {
  box-shadow: 0 0 0 2px rgb(16 185 129);
}

.study-feedback-wrong {
  box-shadow: 0 0 0 2px rgb(239 68 68);
}

/* Zero-latency card stage transitions (0.2s) */
.study-area-stage {
  will-change: transform, opacity;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}

.study-area-stage.study-slide-out {
  transform: translateX(-28px);
  opacity: 0;
  pointer-events: none;
}

.study-area-stage.study-slide-in {
  animation: study-slide-in 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes study-slide-in {
  from {
    transform: translateX(28px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* HP hearts */
.study-hp-heart.is-lost {
  color: #d1d5db !important; /* gray-300 */
  transform: scale(0.9);
}

.study-hp-heart.is-cracked {
  color: #9ca3af !important;
}

/* Voice mic listening ring */
#voice-mic-icon.animate-pulse {
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
}

/* Rapid-fire timeout flash */
#study-area.study-flash-red {
  animation: study-flash-red 0.28s ease both;
  box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.85);
}

@keyframes study-flash-red {
  0% { background-color: rgba(239, 68, 68, 0.25); }
  100% { background-color: transparent; }
}

#rapid-time-bar {
  transition: none;
  transform-origin: left center;
}

/* SRS due badge blink */
@keyframes due-badge-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.due-badge-pulse {
  animation: due-badge-blink 1.1s ease-in-out infinite;
}

.session-summary-pop {
  animation: vocab-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Additional modern polish for GeminiCard dashboard */

/* Deck cards - premium elevated feel with smooth motion */
.deck-card {
  transition: transform 0.25s cubic-bezier(0.23, 1, 0.32, 1), 
              box-shadow 0.25s cubic-bezier(0.23, 1, 0.32, 1),
              border-color 0.2s ease;
  will-change: transform;
}

.deck-card:hover {
  transform: translateY(-4px) scale(1.005);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  border-color: rgb(199 210 254 / 0.6); /* indigo tint on hover */
}

.deck-card .action-btn {
  transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.deck-card .action-btn:hover {
  transform: translateY(-1px) scale(1.02);
}

.deck-card .action-btn:active {
  transform: scale(0.985);
}

/* Premium button styles */
.btn-primary {
  transition: all 0.2s cubic-bezier(0.23, 1.0, 0.32, 1);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgb(79 70 229 / 0.3), 0 4px 6px -4px rgb(79 70 229 / 0.3);
}

.btn-primary:active {
  transform: translateY(0) scale(0.985);
}

.btn-secondary {
  transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.btn-secondary:hover {
  background-color: #f3f4f6;
  transform: translateY(-1px);
}

.dark .btn-secondary:hover {
  background-color: #1f2937;
}

/* Smooth entrance animation for cards */
.deck-card {
  opacity: 0;
  transform: translateY(12px);
}

.deck-card.is-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s cubic-bezier(0.23, 1.0, 0.32, 1), 
              transform 0.5s cubic-bezier(0.23, 1.0, 0.32, 1);
}

/* Modern empty state */
.empty-state {
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.empty-state:hover {
  border-color: #a5b4fc;
}

/* Refined form input for create deck */
.create-input {
  transition: all 0.2s ease;
}

.create-input:focus {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  border-color: #6366f1;
}

/* Feature action pills - modern and prominent */
.feature-pill {
  transition: all 0.25s cubic-bezier(0.23, 1.0, 0.32, 1);
  position: relative;
  overflow: hidden;
}

.feature-pill:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.feature-pill:active {
  transform: scale(0.985);
}

/* Loading states, etc. can be added here */
.spinner {
  border: 2px solid #e5e7eb;
  border-top-color: #4f46e5;
  animation: spin 0.8s linear infinite;
}

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

/* === HIGH-END VISUAL DESIGN (redesign-existing-projects + high-end-visual-design) === */

/* Double-Bezel containers */
.double-bezel {
  border-radius: 22px;
  padding: 1px;
  background: linear-gradient(145deg, rgba(99,102,241,.15), rgba(255,255,255,.04));
}
.dark .double-bezel {
  background: linear-gradient(145deg, rgba(99,102,241,.28), rgba(255,255,255,.03));
}
.double-bezel > .inner {
  border-radius: 21px;
}

/* Premium elevation */
.premium-card {
  transition: transform .28s cubic-bezier(.23,1,.32,1), box-shadow .28s cubic-bezier(.23,1,.32,1);
  box-shadow: 0 1px 2px rgb(0 0 0 / .03), 0 10px 15px -3px rgb(0 0 0 / .05);
}
.premium-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / .06), 0 8px 10px -6px rgb(0 0 0 / .05);
}

/* High-end buttons */
.btn-premium {
  transition: all .2s cubic-bezier(.23,1,.32,1);
}
.btn-premium:hover { transform: translateY(-1px); }
.btn-premium:active { transform: scale(.985); }

/* === EXTENDED HIGH-END SYSTEM (gpt-taste + redesign) === */

/* Double-Bezel containers */
.double-bezel {
  border-radius: 22px;
  padding: 1px;
  background: linear-gradient(145deg, rgba(99,102,241,.15), rgba(255,255,255,.04));
}
.dark .double-bezel {
  background: linear-gradient(145deg, rgba(99,102,241,.28), rgba(255,255,255,.03));
}
.double-bezel > .inner {
  border-radius: 21px;
}

/* Premium elevation with better shadows */
.premium-card {
  transition: transform .28s cubic-bezier(.23,1,.32,1), 
              box-shadow .28s cubic-bezier(.23,1,.32,1);
  box-shadow: 0 1px 2px rgb(0 0 0 / .03), 
              0 10px 15px -3px rgb(0 0 0 / .05);
}
.premium-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / .06), 
              0 8px 10px -6px rgb(0 0 0 / .05);
}

/* Generous spacing */
.section { padding-top: 3rem; padding-bottom: 3rem; }
@media (min-width: 768px) { .section { padding-top: 4.5rem; padding-bottom: 4.5rem; } }

/* Refined focus */
:focus-visible { outline: 2px solid #6366f1; outline-offset: 3px; }

/* Premium grain texture */
.grain::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: url('data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27100%27 height=%27100%27%3E%3Cfilter id=%27n%27%3E%3CfeTurbulence type=%27fractalNoise%27 baseFrequency=%270.85%27/%3E%3C/filter%3E%3Crect width=%27100%27 height=%27100%27 filter=%27url(%23n)%27 opacity=%270.03%27/%3E%3C/svg%27');
  mix-blend-mode: multiply; border-radius: inherit;
}

/* Subtle section header polish */
.section-title {
  letter-spacing: -0.025em;
}
