/**
 * Youth Bible Studies - Mobile-Specific Features Styles
 * Styles for swipe gestures, voice input, floating button, and mobile optimizations
 */

/* ===== Swipe Feedback ===== */
.swipe-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 1rem 2rem;
  border-radius: 2rem;
  font-size: 1rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.swipe-feedback.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ===== Swipe Hint ===== */
.swipe-hint {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(
    135deg,
    var(--youth-primary, #3b82f6) 0%,
    var(--youth-secondary, #8b5cf6) 100%
  );
  color: white;
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 9998;
  max-width: 90%;
  animation: swipeHintBounce 2s ease-in-out infinite;
}

@keyframes swipeHintBounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-10px);
  }
}

.swipe-hint-content {
  text-align: center;
}

.swipe-hint-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
  animation: swipeHintWiggle 1s ease-in-out infinite;
}

@keyframes swipeHintWiggle {
  0%,
  100% {
    transform: rotate(-10deg);
  }
  50% {
    transform: rotate(10deg);
  }
}

.swipe-hint p {
  margin: 0 0 1rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.swipe-hint-dismiss {
  background: white;
  color: var(--youth-primary, #3b82f6);
  border: none;
  padding: 0.5rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.swipe-hint-dismiss:hover {
  transform: scale(1.05);
}

.swipe-hint-dismiss:active {
  transform: scale(0.95);
}

/* ===== Section Active State (Swipe Navigation) ===== */
.section-active {
  animation: sectionHighlight 1s ease;
}

@keyframes sectionHighlight {
  0%,
  100% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(59, 130, 246, 0.1);
  }
}

/* ===== Voice Input Wrapper ===== */
.voice-input-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.voice-input-wrapper textarea {
  width: 100%;
}

/* ===== Voice Input Button ===== */
.voice-input-btn {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: var(--youth-primary, #3b82f6);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s;
  z-index: 10;
}

.voice-input-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.voice-input-btn:active {
  transform: scale(0.95);
}

.voice-input-btn.listening {
  background: #ef4444;
  animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
  0%,
  100% {
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
  }
  50% {
    box-shadow: 0 2px 20px rgba(239, 68, 68, 0.6);
  }
}

/* ===== Floating Add Note Button ===== */
.floating-add-note {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  background: linear-gradient(
    135deg,
    var(--youth-primary, #3b82f6) 0%,
    var(--youth-secondary, #8b5cf6) 100%
  );
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 999;
  transition: all 0.3s;
}

.floating-add-note:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.floating-add-note:active {
  transform: scale(0.95);
}

/* Hide floating button on desktop */
@media (min-width: 1024px) {
  .floating-add-note {
    display: none;
  }
}

/* ===== Touch Target Enhancement ===== */
.touch-target-enhanced {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Increase tap area without changing visual size */
.touch-target-enhanced::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  min-height: 44px;
  width: 100%;
  height: 100%;
}

/* ===== Responsive Typography ===== */
/* Base font sizes are set via JavaScript on root element */
/* These rules ensure proper scaling */

@media (max-width: 374px) {
  /* Extra small phones */
  body {
    font-size: 0.875rem; /* 14px */
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  .study-title {
    font-size: 1.75rem !important;
  }

  .section-title {
    font-size: 1.25rem !important;
  }
}

@media (min-width: 375px) and (max-width: 767px) {
  /* Regular phones */
  body {
    font-size: 1rem; /* 16px */
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  h3 {
    font-size: 1.5rem;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  /* Tablets */
  body {
    font-size: 1.0625rem; /* 17px */
  }

  h1 {
    font-size: 2.25rem;
  }

  h2 {
    font-size: 2rem;
  }

  h3 {
    font-size: 1.75rem;
  }
}

@media (min-width: 1024px) {
  /* Desktop */
  body {
    font-size: 1.125rem; /* 18px */
  }

  h1 {
    font-size: 2.5rem;
  }

  h2 {
    font-size: 2.25rem;
  }

  h3 {
    font-size: 2rem;
  }
}

/* ===== Vertical Scrolling Optimization ===== */
body {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

html {
  scroll-behavior: smooth;
}

/* Prevent horizontal scroll on all containers */
.study-viewer,
.notes-manager,
.navigation-filter {
  overflow-x: hidden;
  max-width: 100%;
}

/* ===== Mobile Go Deeper Sections ===== */
@media (max-width: 767px) {
  .go-deeper-section {
    margin-bottom: 1rem;
  }

  .go-deeper-section.collapsed {
    background-color: var(--youth-bg-secondary, #f7fafc);
  }

  .go-deeper-toggle {
    padding: 1rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .go-deeper-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
  }

  .go-deeper-title {
    font-size: 1rem;
    flex: 1;
  }

  .go-deeper-chevron {
    font-size: 1rem;
    flex-shrink: 0;
  }

  .go-deeper-content {
    padding: 1rem;
    font-size: 0.9375rem;
    line-height: 1.7;
  }

  /* Smooth expand/collapse animation */
  .go-deeper-content {
    transition:
      max-height 0.3s ease,
      opacity 0.3s ease;
    overflow: hidden;
  }

  .go-deeper-section.collapsed .go-deeper-content {
    max-height: 0;
    opacity: 0;
  }

  .go-deeper-section.expanded .go-deeper-content {
    max-height: 5000px;
    opacity: 1;
  }
}

/* ===== Mobile Study Sections ===== */
@media (max-width: 767px) {
  .study-section {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .section-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .section-complete-btn {
    align-self: flex-end;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .section-content {
    gap: 1.5rem;
  }

  .teaching-text,
  .application-content,
  .prayer-content {
    font-size: 1rem;
    line-height: 1.7;
  }
}

/* ===== Mobile Notes Drawer ===== */
@media (max-width: 767px) {
  .notes-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--youth-bg-primary, #ffffff);
    border-top: 2px solid var(--youth-border-color, #e2e8f0);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: transform 0.3s ease;
  }

  .notes-drawer.notes-hidden {
    transform: translateY(calc(100% - 60px));
  }

  .notes-drawer.notes-hidden .notes-list,
  .notes-drawer.notes-hidden .note-form,
  .notes-drawer.notes-hidden .notes-export {
    display: none;
  }

  /* Ensure notes drawer is scrollable */
  .notes-drawer .notes-list {
    max-height: calc(70vh - 200px);
    overflow-y: auto;
  }
}

/* ===== Mobile Button Adjustments ===== */
@media (max-width: 767px) {
  .btn {
    min-height: 44px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    text-align: center;
  }

  .study-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .study-footer {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* ===== Mobile Form Elements ===== */
@media (max-width: 767px) {
  input[type="text"],
  input[type="email"],
  input[type="search"],
  textarea,
  select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }

  textarea {
    min-height: 120px;
  }

  /* Adjust textarea padding to accommodate voice button */
  .voice-input-wrapper textarea {
    padding-right: 3.5rem;
  }
}

/* ===== Mobile Navigation ===== */
@media (max-width: 767px) {
  .navigation-filter {
    padding: 0.75rem;
  }

  .filter-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    min-height: 44px;
    padding: 0.75rem 1rem;
    white-space: nowrap;
  }
}

/* ===== Accessibility - Focus Indicators ===== */
.voice-input-btn:focus,
.floating-add-note:focus,
.swipe-hint-dismiss:focus {
  outline: 3px solid var(--youth-primary, #3b82f6);
  outline-offset: 2px;
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
  .swipe-feedback,
  .section-active,
  .voice-input-btn,
  .floating-add-note,
  .go-deeper-content {
    animation: none;
    transition: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ===== Dark mode: driven by in-site toggle (.dark-mode), not device preference ===== */
.dark-mode .swipe-feedback {
  background: rgba(255, 255, 255, 0.9);
  color: #1a202c;
}

.dark-mode .swipe-hint {
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}

/* ===== Print Styles ===== */
@media print {
  .swipe-feedback,
  .swipe-hint,
  .voice-input-btn,
  .floating-add-note {
    display: none !important;
  }
}
