/* HSK Flashcards — custom styles on top of Tailwind */

html, body { height: 100%; }
body {
  overscroll-behavior-y: none;
  /* `manipulation` disables the browser's double-tap-to-zoom while keeping
     pan and pinch-scroll-on-element behaviour. Combined with the JS handlers
     in index.html this gives a locked, native-feeling zoom level. */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* iOS Safari auto-zooms when focusing an input whose font-size is < 16px.
   Force the minimum so the page never zooms in on tap-into-input either. */
input, textarea, select { font-size: 16px; }

/* Material Symbols default */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 24px;
  line-height: 1;
  user-select: none;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* Bottom nav items */
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  color: #727687;
  transition: color 150ms ease, transform 150ms ease;
  text-decoration: none;
}
.nav-item:hover { color: #0066ff; }
.nav-item.active { color: #0066ff; }
.nav-item.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}
.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Flashcard 3D flip */
.card-3d-perspective { perspective: 1200px; }
.card-3d {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.4, 0.0, 0.2, 1);
  will-change: transform;
}
.card-3d.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 1.75rem;
  background: #ffffff;
  box-shadow: 0 20px 40px -12px rgba(0, 80, 203, 0.12);
  border: 1px solid #f2f3ff;
  display: flex;
  flex-direction: column;
}
.card-face.back { transform: rotateY(180deg); }

/* Swipe-out animations */
.swipe-out-left {
  transform: translateX(-150%) rotate(-15deg) !important;
  opacity: 0;
  transition: transform 350ms ease-in, opacity 350ms ease-in;
}
.swipe-out-right {
  transform: translateX(150%) rotate(15deg) !important;
  opacity: 0;
  transition: transform 350ms ease-in, opacity 350ms ease-in;
}

/* Decorative motif behind level cards */
.chinese-motif {
  user-select: none;
  pointer-events: none;
  opacity: 0.07;
  font-family: 'Noto Sans SC', sans-serif;
}

/* Subtle ring pulse for audio button */
@keyframes ring-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}
.ring-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid currentColor;
  animation: ring-pulse 1.2s ease-out infinite;
}

/* Progress ring */
.progress-ring { transform: rotate(-90deg); }
.progress-ring__track { stroke: #e6e7f4; }
.progress-ring__fill {
  stroke: #0066ff;
  transition: stroke-dashoffset 600ms ease;
  stroke-linecap: round;
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, #ecedfa 0%, #f5f5fb 50%, #ecedfa 100%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: 0.75rem;
}
@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Scrollbar hidden */
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* Settings rows */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid #ecedfa;
}
.setting-row:last-child { border-bottom: none; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  /* Inside a flex .setting-row a long description can squeeze the toggle —
     pin a min-width and stop shrinking so the pill always renders fully. */
  flex-shrink: 0;
  min-width: 44px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #c2c6d8;
  border-radius: 999px;
  transition: background 200ms ease;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 999px;
  transition: transform 200ms ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}
.toggle input:checked + .slider { background: #0066ff; }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* Pill chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Hide bottom nav on focused full-screen experiences (e.g., card session) */
body.no-nav #bottom-nav { display: none; }
body.no-nav main#view { padding-bottom: 0; }

/* Subtle entrance animation for views */
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
#view > * { animation: view-in 250ms ease-out; }

/* Big Chinese display tweaks */
.hanzi-xl {
  font-family: 'Noto Sans SC', 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Auth page */
.auth-shell {
  position: relative;
  isolation: isolate;
}
.auth-shell::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 22rem;
  background: none;
  pointer-events: none;
}
.auth-orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.95;
  filter: blur(6px);
  animation: float-orb 9s ease-in-out infinite;
}
.auth-orb--one {
  top: 2rem;
  right: -3rem;
  width: 12rem;
  height: 12rem;
  background: radial-gradient(circle, rgba(250, 198, 56, 0.52), rgba(250, 198, 56, 0));
}
.auth-orb--two {
  top: 15rem;
  left: -2.25rem;
  width: 9rem;
  height: 9rem;
  background: radial-gradient(circle, rgba(0, 102, 255, 0.35), rgba(0, 102, 255, 0));
  animation-delay: -3s;
}
.auth-hero {
  background:
    linear-gradient(140deg, #0057db 0%, #0a3d9e 58%, #191b24 100%);
}
.auth-stat-pill {
  display: flex;
  min-height: 4.5rem;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.12);
  padding: 0.75rem;
  backdrop-filter: blur(14px);
}
.auth-stat-pill strong {
  font-size: 1.05rem;
  line-height: 1.1;
}
.auth-stat-pill small {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.76;
  text-transform: uppercase;
}
.auth-surface {
  position: relative;
}

/* Premium lock states */
.locked-level-card .level-card-content {
  filter: blur(1.8px);
  transform: scale(0.985);
  opacity: 0.82;
}
.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem;
}
.lock-surface {
  position: relative;
  display: flex;
  min-height: calc(100% - 0.25rem);
  width: 100%;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}
.lock-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.56), rgba(236, 237, 250, 0.2));
}
.lock-surface__halo {
  position: absolute;
  left: 50%;
  bottom: -30%;
  width: 8rem;
  height: 8rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: radial-gradient(circle, rgba(0, 102, 255, 0.14), rgba(0, 102, 255, 0));
}
.lock-badge {
  display: flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0066ff;
  box-shadow: 0 10px 22px rgba(0, 102, 255, 0.16);
}

/* HSK 7–9 "Mastery Tier" banner — visually distinct from HSK 1–6 cards.
   Soft cream-to-champagne gradient (very light, not a solid thick colour),
   big 九 motif, diagonal "Coming Soon" ribbon. Click is captured by JS and
   shows a toast — the link target is dummy. */
.hsk79-card {
  cursor: pointer;
  isolation: isolate;
}
.hsk79-bg {
  position: absolute;
  inset: 0;
  /* Very pale, mostly-white wash with the faintest hint of warm gold so it
     still reads as a special "tier" without being bold or heavy. */
  background: linear-gradient(135deg, #ffffff 0%, #fffbf2 45%, #fdf3da 80%, #f7e4b4 100%);
}
.hsk79-glow {
  position: absolute;
  inset: 0;
  /* Soft warm orbs in the corners to add depth without saturation. */
  background:
    radial-gradient(circle at 105% 110%, rgba(252, 211, 77, 0.30), transparent 55%),
    radial-gradient(circle at 0% 0%, rgba(167, 139, 250, 0.10), transparent 55%);
  pointer-events: none;
}
.hsk79-motif {
  position: absolute;
  right: -2.5rem;
  bottom: -3.5rem;
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
  font-size: 14rem;
  line-height: 1;
  color: rgba(180, 132, 33, 0.14);
  transform: rotate(6deg);
  pointer-events: none;
  user-select: none;
}
.hsk79-ribbon {
  position: absolute;
  top: 18px;
  right: -42px;
  width: 160px;
  text-align: center;
  padding: 5px 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #5b3a07;
  background: linear-gradient(to right, #fef3c7, #fbbf24 55%, #f59e0b);
  transform: rotate(35deg);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.25);
  z-index: 20;
}
.hsk79-card::after {
  /* Soft warm-toned inner border for a polished finish. */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(245, 158, 11, 0.22);
  z-index: 11;
}
.hsk79-card:hover .hsk79-glow {
  opacity: 1.15;
}
/* Smaller screens: shrink motif so it doesn't overflow */
@media (max-width: 380px) {
  .hsk79-motif { font-size: 11rem; right: -1.75rem; bottom: -3rem; }
  .hsk79-ribbon { right: -48px; font-size: 9px; }
}

/* Premium page */
.premium-hero-card {
  background: linear-gradient(145deg, #0057db 0%, #0a3d9e 50%, #171b2a 100%);
}
.premium-hero-orb {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.92;
  filter: blur(8px);
}
.premium-hero-orb--one {
  top: -2rem;
  right: -3rem;
  width: 11rem;
  height: 11rem;
  background: radial-gradient(circle, rgba(250, 198, 56, 0.55), rgba(250, 198, 56, 0));
}
.premium-hero-orb--two {
  bottom: -2.5rem;
  left: -2rem;
  width: 9rem;
  height: 9rem;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
}
.premium-glass-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 1.75rem;
  background: rgba(255, 255, 255, 0.84);
  padding: 1.25rem;
  box-shadow: 0 18px 40px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.premium-glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.35), rgba(236, 237, 250, 0.1));
  pointer-events: none;
}
.premium-glass-card > * {
  position: relative;
  z-index: 1;
}
.premium-stat-card {
  display: flex;
  min-height: 4.25rem;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1.2rem;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255, 255, 255, 0.88);
  padding: 0.8rem;
}
.premium-stat-card strong {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
  color: #191b24;
}
.premium-stat-card small {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #727687;
  text-transform: uppercase;
}
.premium-step {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}
.premium-step__index {
  display: inline-flex;
  width: 1.9rem;
  height: 1.9rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 102, 255, 0.12);
  color: #0066ff;
  font-size: 0.78rem;
  font-weight: 700;
}
.premium-card-stage {
  position: relative;
  width: 9.5rem;
  height: 11.25rem;
}
.premium-card-stack {
  position: absolute;
  inset: 0;
}
.premium-card-stack--back {
}
.premium-card-stack--front {
}
.premium-mini-card {
  --tx: 0px;
  --ty: 0px;
  --rot: 0deg;
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.5rem;
  border-radius: 1.8rem;
  padding: 1.1rem;
  transform: translate3d(var(--tx), var(--ty), 0) rotate(var(--rot));
  box-shadow: 0 22px 45px rgba(9, 16, 40, 0.2);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: premium-sway 5.8s ease-in-out infinite;
}
.premium-card-stack--back .premium-mini-card {
  --tx: -0.7rem;
  --ty: 0.7rem;
  --rot: -8deg;
  animation-delay: -2.2s;
}
.premium-card-stack--front .premium-mini-card {
  --tx: 0.65rem;
  --ty: -0.2rem;
  --rot: 6deg;
}
.premium-mini-card--glass {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08)),
    linear-gradient(145deg, rgba(0, 102, 255, 0.24), rgba(9, 61, 158, 0.34));
}
.premium-mini-card--violet {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08)),
    linear-gradient(145deg, rgba(155, 37, 171, 0.42), rgba(55, 68, 213, 0.28));
}
.premium-mini-card__eyebrow {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
.premium-mini-card strong {
  font-size: 1.45rem;
  line-height: 1.1;
  font-weight: 800;
  color: #ffffff;
}
.premium-mini-card small {
  display: block;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
}
.premium-benefit-card {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.9rem;
  align-items: flex-start;
  border-radius: 1.35rem;
  border: 1px solid rgba(226, 232, 240, 0.92);
  background: rgba(255, 255, 255, 0.88);
  padding: 0.95rem;
}
.premium-benefit-icon {
  display: flex;
  width: 3rem;
  height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(0, 102, 255, 0.12), rgba(0, 102, 255, 0.06));
  color: #0066ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

@keyframes float-orb {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(0, -12px, 0) scale(1.04); }
}
@keyframes premium-sway {
  0%, 100% { transform: translate3d(var(--tx), var(--ty), 0) rotate(var(--rot)); }
  25% { transform: translate3d(calc(var(--tx) - 6px), calc(var(--ty) - 5px), 0) rotate(calc(var(--rot) - 3deg)); }
  50% { transform: translate3d(calc(var(--tx) + 3px), calc(var(--ty) - 10px), 0) rotate(calc(var(--rot) + 2.5deg)); }
  75% { transform: translate3d(calc(var(--tx) + 7px), calc(var(--ty) - 4px), 0) rotate(calc(var(--rot) + 4deg)); }
}
