/* style.css */
html {
  overflow: hidden;
  width: 100%;
  height: 100%;
}

body {
  font-family:
    "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    Meiryo, sans-serif;
  background-color: #f0f4f8;
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;

  height: 100dvh;
  margin: 0;
  padding: 20px 10px;
  box-sizing: border-box;
  overflow: hidden;
  width: 100%;
  position: relative;
  touch-action: none;
}

h1 {
  color: #2c3e50;
  margin-bottom: 20px;
  text-align: center;
  font-size: 1.8rem;
}

.category-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-btn {
  padding: 8px 16px;
  border: 2px solid #3498db;
  background-color: transparent;
  color: #3498db;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
  font-size: 14px;
}
.filter-btn.active,
.filter-btn:hover {
  background-color: #3498db;
  color: white;
}

.action-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  font-size: 14px;
}

.shuffle-btn {
  background-color: #3498db;
  color: white;
}
.reset-btn {
  background-color: #ecf0f1;
  color: #7f8c8d;
  border: 1px solid #bdc3c7;
}

.toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 5px;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #bdc3c7;
  transition: 0.3s;
  border-radius: 26px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
input:checked + .toggle-slider {
  background-color: #3498db;
}
input:checked + .toggle-slider:before {
  transform: translateX(22px);
}
.toggle-label {
  font-size: 14px;
  font-weight: bold;
  color: #7f8c8d;
  cursor: pointer;
  user-select: none;
}

.card-container {
  width: 100%;
  max-width: 400px;
  height: 300px;
  perspective: 1000px;
  margin-bottom: 20px;
  cursor: pointer;
  position: relative;
  touch-action: pan-x pan-y;
}

.carousel-track {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}
.carousel-track.sliding {
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.card {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  transition:
    transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1),
    opacity 0.4s ease;
  transform-style: preserve-3d;
  box-shadow: 0 8px 16px rgba(52, 152, 219, 0.1);
  border-radius: 15px;
  user-select: none;
  -webkit-user-select: none;
  z-index: 2;
}

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

.card.is-flipped .card-front {
  pointer-events: none !important;
}
.card.is-flipped .card-back {
  pointer-events: auto !important;
  z-index: 50;
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 50px 15px 15px 15px;
  box-sizing: border-box;
  border-radius: 15px;
  background-color: white;
  text-align: center;
  border: 1px solid #e1e8ed;
  overflow-y: hidden;
}

.card-front {
  z-index: 2;
  transform: rotateY(0deg);
  pointer-events: auto;
}
.card-back {
  transform: rotateY(180deg);
  background-color: #f8fafc;
  pointer-events: none;
}

.word-en {
  margin: auto 0;
  font-size: 28px;
  font-weight: bold;
  color: #2c3e50;
  width: 100%;
}
.word-ja {
  margin-top: auto;
  margin-bottom: 5px;
  font-size: 22px;
  font-weight: bold;
  color: #2980b9;
  width: 100%;
}
.word-example {
  margin-bottom: 10px;
  font-size: 14px;
  color: #7f8c8d;
  line-height: 1.4;
  padding: 0 5px;
}

.tag {
  position: absolute;
  top: 15px;
  left: 15px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  font-weight: bold;
  z-index: 100;
}
.tag.daily {
  background-color: #ebf5fb;
  color: #3498db;
}
.tag.it {
  background-color: #2c3e50;
  color: white;
}

.speak-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: #bdc3c7;
  cursor: pointer;
  padding: 8px;
  z-index: 100;
  pointer-events: inherit;
}

.mic-container {
  margin-top: 0;
  margin-bottom: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transform: translateZ(20px);
  z-index: 1000;
  pointer-events: inherit;
}

.mic-btn {
  background-color: #ecf0f1;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #7f8c8d;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  pointer-events: inherit;
}
.mic-btn.recording {
  background-color: #e74c3c;
  color: white;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
  }
}

.mic-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  color: #95a5a6;
  background-color: #ecf0f1;
  min-height: 32px;
}
.mic-result.success {
  background-color: #27ae60;
  color: white;
}
.mic-result.error {
  background-color: #e74c3c;
  color: white;
}
.mic-result.warning {
  background-color: #f39c12;
  color: white;
}
.mic-result.recording-status {
  background-color: #34495e;
  color: white;
}

.memorize-btn {
  width: 100%;
  max-width: 400px;
  padding: 12px 0;
  background-color: #3498db;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  margin-bottom: 20px;
  cursor: pointer;
}

.controls {
  display: flex;
  width: 100%;
  max-width: 400px;
  justify-content: center;
  align-items: center;
}

.nav-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid #3498db;
  background: white;
  color: #3498db;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 80px;
}
.nav-btn:hover {
  background-color: #f0f8ff;
  border-color: #2980b9;
}

.counter {
  font-size: 15px;
  font-weight: bold;
  color: #7f8c8d;
  width: 100px;
  text-align: center;
}

.card-dummy {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  border-radius: 15px;
  background-color: white;
  border: 1px solid #e1e8ed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 50px 15px 15px 15px;
  box-sizing: border-box;
  text-align: center;
  opacity: 0.4;
  transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  z-index: 1;
  pointer-events: none;
}

.card-dummy.prev {
  left: calc(-100% - 15px);
}
.card-dummy.next {
  left: calc(100% + 15px);
}
.card-dummy.active {
  opacity: 1;
}

.no-transition {
  transition: none !important;
}

@media (max-width: 480px) {
  .card-container {
    width: 82%;
    height: 280px;
    margin-left: auto;
    margin-right: auto;
    overflow: visible;
  }
  .word-en {
    font-size: 24px;
  }
  .word-ja {
    font-size: 20px;
  }

  .action-buttons {
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    max-width: 400px;
  }
  .btn {
    padding: 6px 10px;
    font-size: 13px;
  }
  .btn .material-symbols-outlined {
    font-size: 18px;
  }
  .toggle-container {
    gap: 4px;
    margin-left: 0;
  }
  .toggle-label {
    font-size: 12px;
    white-space: nowrap;
  }
  .toggle-switch {
    width: 40px;
    height: 22px;
  }
  .toggle-slider:before {
    height: 16px;
    width: 16px;
    bottom: 3px;
    left: 3px;
  }
  input:checked + .toggle-slider:before {
    transform: translateX(18px);
  }
}

@media (min-width: 481px) {
  .card-container {
    width: 100%;
    overflow: hidden;
  }
}
