/*
 * Custom styles for Hop Into Hangul
 *
 * Base utilities are provided by Tailwind CSS.
 * This file contains only project-specific custom styles.
 */

/* Form enhancements - custom focus states */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #53653a;
  box-shadow: 0 0 0 3px rgba(83, 101, 58, 0.18);
}

@media (prefers-color-scheme: dark) {
  input[type="text"]:focus,
  input[type="email"]:focus,
  input[type="password"]:focus,
  input[type="time"]:focus,
  select:focus,
  textarea:focus {
    border-color: #c6d690;
    box-shadow: 0 0 0 3px rgba(198, 214, 144, 0.22);
  }
}

/* Flash message animation */
@keyframes slide-down {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.animate-slide-down {
  animation: slide-down 0.3s ease-out;
}

/* Toast notification slide in/out animations */
@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.animate-slide-in {
  animation: slide-in 0.3s ease-out;
}

.animate-slide-out {
  animation: slide-out 0.3s ease-out;
}

/* Word View Stamp Icon Animation */
.word-view-stamp-container {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.word-view-stamp {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Initial state - gray outline only */
.stamp-outline {
  stroke: #dce0d1;
  opacity: 0.4;
  transition: opacity 200ms ease;
}

@media (prefers-color-scheme: dark) {
  .stamp-outline {
    stroke: #47533d;
    opacity: 0.3;
  }
}

/* Fill circle - starts invisible */
.stamp-fill {
  fill: #53653a; /* Olive progress mark */
  transform-origin: center;
  transform: scale(0);
  opacity: 0;
}

@media (prefers-color-scheme: dark) {
  .stamp-fill {
    fill: #c6d690; /* Pear progress mark in dark mode */
  }
}

/* Checkmark icon - starts invisible */
.stamp-icon {
  stroke: white;
  transform-origin: center;
  transform: scale(0) rotate(-10deg);
  opacity: 0;
}

/* Animated state (triggered by JS) */
.word-view-stamp-animated .stamp-outline {
  opacity: 0;
}

.word-view-stamp-animated .stamp-fill {
  animation: stamp-fill-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.word-view-stamp-animated .stamp-icon {
  animation: stamp-icon-in 300ms cubic-bezier(0.34, 1.56, 0.64, 1) 250ms forwards;
}

/* Stamp fill animation - ink spreading effect */
@keyframes stamp-fill-in {
  0% {
    transform: scale(0) rotate(-5deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.15) rotate(2deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* Icon appears after stamp */
@keyframes stamp-icon-in {
  0% {
    transform: scale(0) rotate(-10deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .word-view-stamp-animated .stamp-fill,
  .word-view-stamp-animated .stamp-icon {
    animation: none;
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }

  .stamp-fill {
    transform: scale(1);
    opacity: 1;
  }

  .stamp-icon {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* Mobile size adjustment */
@media (max-width: 640px) {
  .word-view-stamp-container {
    width: 40px;
    height: 40px;
  }
}

/* ===========================================
   Flashcard 3D Flip & Swipe Styles
   =========================================== */

/* 3D perspective container */
.perspective-1000 {
  perspective: 1000px;
}

/* Preserve 3D transformations */
.preserve-3d {
  transform-style: preserve-3d;
}

/* Hide backface of flipped elements */
.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Back of card rotated 180deg */
.rotate-y-180 {
  transform: rotateY(180deg);
}

/* Flipped state for card */
.flashcard.flipped {
  transform: rotateY(180deg);
}

/* Swipe feedback - green glow when swiping right (Know) */
.swiping-right {
  box-shadow: 0 0 30px rgba(120, 139, 80, 0.4);
}

/* Swipe feedback - red glow when swiping left (Still Learning) */
.swiping-left {
  box-shadow: 0 0 30px rgba(181, 108, 54, 0.35);
}

/* Smooth cursor for dragging */
.flashcard {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  transform-origin: center center;
}

/* Swipe exit animations */
@keyframes swipe-out-right {
  to {
    transform: translateX(500px) rotate(25deg);
    opacity: 0;
  }
}

@keyframes swipe-out-left {
  to {
    transform: translateX(-500px) rotate(-25deg);
    opacity: 0;
  }
}

.card-exit-right {
  animation: swipe-out-right 0.3s ease-out forwards;
}

.card-exit-left {
  animation: swipe-out-left 0.3s ease-out forwards;
}

/* Entrance animation for new cards */
@keyframes card-enter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.flashcard-entering {
  animation: card-enter 0.2s ease-out;
}

.flashcard:active {
  cursor: grabbing;
}

/* Ensure card doesn't trigger text selection on swipe */
.flashcard * {
  pointer-events: none;
}

/* But allow buttons to be clicked */
button[data-action*="swipe"] {
  pointer-events: auto;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .flashcard {
    transition: none !important;
  }

  .flashcard.flipped {
    transform: none;
  }

  .flashcard .backface-hidden:first-child {
    display: block;
  }

  .flashcard .backface-hidden:last-child {
    display: none;
  }

  .flashcard.flipped .backface-hidden:first-child {
    display: none;
  }

  .flashcard.flipped .backface-hidden:last-child {
    display: block;
    transform: none;
  }
}

/* ===========================================
   Pull to Refresh (PWA)
   =========================================== */

/* Disable browser's default pull-to-refresh in PWA */
@media (display-mode: standalone) {
  html, body {
    overscroll-behavior-y: contain;
  }
}

/* Pull to refresh spinner */
.pull-spinner {
  border-width: 3px;
  transition: transform 0.2s ease;
}

/* Spinning animation when refreshing */
@keyframes pull-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

[data-pull-to-refresh-target="indicator"].refreshing .pull-spinner {
  animation: pull-spin 0.8s linear infinite;
}

/* Ready state - full rotation indicator */
[data-pull-to-refresh-target="indicator"].ready .pull-spinner {
  border-color: #53653a;
  border-top-color: transparent;
}

@media (prefers-color-scheme: dark) {
  [data-pull-to-refresh-target="indicator"].ready .pull-spinner {
    border-color: #c6d690;
    border-top-color: transparent;
  }
}

/* ===========================================
   Navigation Create Buttons - Touch Support
   =========================================== */

/* On touch devices, show + buttons at reduced opacity since hover isn't available */
@media (hover: none) and (pointer: coarse) {
  .nav-create-btn {
    opacity: 0.5 !important;
  }

  .nav-create-btn:active {
    opacity: 1 !important;
    transform: translateY(-50%) scale(0.95);
  }
}

/* One identity across the native companion website and the legacy account UI. */
.hop-web {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}
.hop-brand-lockup { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 750; letter-spacing: -.6px; text-decoration: none; }
.hop-rabbit { width: 32px; height: 32px; flex-shrink: 0; }
.hop-web h1 { font-family: Georgia, serif; font-weight: 400; letter-spacing: -1.2px; }
.hop-web h2 { letter-spacing: -.4px; }
.hop-auth { margin-top: 38px; margin-bottom: 60px; background: #fffef8; border: 1px solid #dce0d1; border-radius: 26px; box-shadow: 0 14px 55px #303b2908; }
.hop-auth h1 { font-size: 46px; margin-bottom: 12px; }
.hop-auth input:not([type="checkbox"]), .hop-auth select { min-height: 48px; border-radius: 12px; }
.hop-web a, .hop-web button, .hop-web input, .hop-web select { accent-color: #53653a; }
.hop-web :focus-visible { outline: 3px solid #788b50; outline-offset: 3px; }
.hop-web .hop-nav, .hop-web .hop-footer { border-color: #dce0d1; }
@media (prefers-color-scheme: dark) {
  .hop-auth { background: #222b1f; border-color: #47533d; box-shadow: none; }
  .hop-web :focus-visible { outline-color: #c6d690; }
  .hop-web .hop-footer { color: #b7c0aa; }
}
@media (max-width: 520px) {
  .hop-auth { width: calc(100% - 32px); margin-top: 16px; }
  .hop-brand-lockup { font-size: 16px; gap: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .hop-web *, .hop-web *::before, .hop-web *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.hop-web [data-menu-target="trigger"] { --hop-mark-eye: #303b29; }
