/* Custom Tailwind extensions & Baicizhan app animations */

:root {
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-light: #ccfbf1;
  --accent: #f59e0b;
  --bg-main: #f8fafc;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #0f172a;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Dynamic Viewport Container for iPhone & Mobile Browsers */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

@media (min-width: 640px) {
  .app-container {
    height: 92dvh;
    max-height: 880px;
    border-radius: 28px;
  }
}

/* iOS Safe Area Padding for Bottom Navigation */
nav {
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

/* Card flip animation */
.perspective-1000 {
  perspective: 1000px;
}
.transform-style-3d {
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.rotate-y-180 {
  transform: rotateY(180deg);
}

/* Smooth pulse & feedback animations */
@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.animate-correct {
  animation: correctPop 0.3s ease-in-out;
  border-color: #10b981 !important;
  background-color: #ecfdf5 !important;
  color: #047857 !important;
}

.animate-wrong {
  border-color: #ef4444 !important;
  background-color: #fef2f2 !important;
  color: #b91c1c !important;
}

/* Calendar heatmap styling */
.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}

.calendar-day.checked {
  background-color: #0d9488;
  color: white;
  box-shadow: 0 2px 4px rgba(13, 148, 136, 0.3);
}

.calendar-day.today {
  border: 2px solid #f59e0b;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Navigation consumes its own space; pages no longer reserve a second footer. */
.app-container > header { flex: 0 0 auto; padding: 7px 12px; }
.app-container > main { padding-bottom: 0; min-height: 0; }
.app-container > nav { position: static; flex: 0 0 auto; padding-top: 5px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.app-container > main > section { padding: 10px 12px; }
#tab-study:not(.hidden) { display: flex; height: 100%; padding: 8px 10px; overflow-y: auto; }
#tab-study > div:first-child { margin-bottom: 6px; }
#tab-study > div:nth-child(2) { flex: 0 0 auto; justify-content: flex-start; overflow: visible; gap: 6px; }
#tab-study > div:nth-child(2) > div:first-child { min-height: 0; padding: 10px; justify-content: flex-start; }
#study-card-stage-badge { max-width: 52%; line-height: 1.3; }
#study-word { font-size: clamp(19px, 5.8vw, 26px); line-height: 1.15; overflow-wrap: anywhere; }
#study-phonetic { line-height: 1.3; font-size: 11px; overflow-wrap: anywhere; }
#study-context-box { padding: 7px 9px; }
#study-sentence { font-size: 12px; line-height: 1.4; }
#study-sentence-cn { line-height: 1.4; }
#voice-status { margin-top: 4px; line-height: 1.3; }
#quiz-options-container { margin-top: 0; }
#choices { display: grid; grid-template-columns: minmax(0,1fr); gap: 5px; }
#choices.hidden { display: none; }
#choices > * { margin-top: 0; }
#choices > [data-answer] { display: block; width: 100%; height: 100%; min-height: 48px; padding: 9px 8px; font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; cursor: pointer; touch-action: manipulation; position: relative; }
#choices > [data-answer] > * { pointer-events: none; }
#choices > [data-answer] b { margin-right: 5px; }
#unknown { grid-column: 1 / -1; padding: 5px; }
#study-mnemonic-box { padding: 6px 8px; margin-top: 6px; line-height: 1.4; }
#answer-feedback > div { padding: 7px 9px; margin-top: 5px; line-height: 1.4; }
#tab-home > * + *, #tab-settings > * + *, #tab-words > * + * { margin-top: 9px; }
#calendar-grid { gap: 3px; }
.calendar-day { aspect-ratio: auto; min-height: 21px; font-size: 10px; border-radius: 5px; }
#tab-home .calendar-heading { margin-bottom: 6px; }
@media (min-width: 640px) {
 .app-container { height: 100dvh; max-height: none; border-radius: 0; }
}
@media (max-height: 650px) {
 .app-container > header { padding: 4px 10px; }
 #tab-study { padding: 5px 8px; }
 #tab-study > div:nth-child(2) > div:first-child { padding: 7px; }
 #tab-study .text-center.my-2 { margin-top: 5px; margin-bottom: 5px; }
 #study-context-box { padding: 5px 7px; }
 #choices > [data-answer] { min-height: 44px; padding: 7px; }
 #tab-home > * + * { margin-top: 6px; }
}
