/* ====================================
   Pan sin vino - Recipe Player Styles
   Mobile-first, cookbook-themed design
   ==================================== */

/* Font Faces */
@font-face {
  font-family: 'Bangers';
  src: url('fonts/Bangers/Bangers-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Comic Neue';
  src: url('fonts/Comic_Neue/ComicNeue-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Comic Neue';
  src: url('fonts/Comic_Neue/ComicNeue-Bold.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

/* ====================================
   CSS Variables - Cookbook Color Palette
   ==================================== */
:root {
  --color-primary: #D4A574;
  --color-secondary: #C8964E;
  --color-text-dark: #3B2314;
  --color-text-brown: #5C4033;
  --color-cream: #F5E6D3;
  --color-cream-light: #E8D4B8;
  --color-bg-wood: #C89664;

  --font-header: 'Bangers', cursive;
  --font-body: 'Comic Neue', cursive, sans-serif;

  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  --button-size: 60px;
  --arrow-size: 48px;
}

/* ====================================
   Reset & Base Styles
   ==================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg-wood);
  background-image: url('images/background.webp');
  background-size: cover;
  background-attachment: fixed;
  color: var(--color-text-dark);
  overflow-x: hidden;
  min-height: 100vh;
  touch-action: pan-y pinch-zoom;
}

/* ====================================
   Recipe Container
   ==================================== */
.recipe-container {
  max-width: 100vw;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-sm);
}

/* ====================================
   Header
   ==================================== */
.recipe-header {
  position: relative;
  text-align: center;
  padding: var(--spacing-md) var(--spacing-sm);
  background: rgba(245, 230, 211, 0.95);
  border-radius: 16px;
  margin-bottom: var(--spacing-md);
  box-shadow: 0 4px 12px rgba(59, 35, 20, 0.15);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  position: relative;
}

.recipe-title {
  font-family: var(--font-header);
  font-size: 2.5rem;
  color: var(--color-text-dark);
  letter-spacing: 1px;
  text-transform: uppercase;
  line-height: 1.2;
  flex: 1;
  text-align: center;
}

/* Progress Indicator */
.progress-indicator {
  margin-top: var(--spacing-md);
}

.progress-text {
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--color-text-brown);
  display: block;
  margin-bottom: var(--spacing-xs);
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--color-cream);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(59, 35, 20, 0.2);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  border-radius: 20px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(200, 150, 78, 0.4);
}

/* ====================================
   Carousel
   ==================================== */
.carousel-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  margin: var(--spacing-md) 0;
  min-height: 300px;
}

/* Edge shadows for swipe affordance */
.carousel-wrapper::before,
.carousel-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
  z-index: 10;
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

.carousel-wrapper::before {
  left: 0;
  background: linear-gradient(to right, rgba(59, 35, 20, 0.2), transparent);
}

.carousel-wrapper::after {
  right: 0;
  background: linear-gradient(to left, rgba(59, 35, 20, 0.2), transparent);
}

.carousel {
  display: flex;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  will-change: transform; /* Performance optimization for smooth dragging */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.step-card {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
  text-align: center;
}

.step-number {
  display: none;
}

.step-content {
  background: rgba(245, 230, 211, 0.95);
  padding: var(--spacing-lg);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(59, 35, 20, 0.2);
  max-width: 500px;
  width: 100%;
  /* Prevent text selection during swipe */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Subtle swipe hint animation on intro step (first load only) */
@keyframes swipeHint {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

.step-title {
  font-family: var(--font-header);
  font-size: 1.75rem;
  color: var(--color-text-dark);
  margin-bottom: var(--spacing-md);
  letter-spacing: 0.5px;
}

.step-description {
  font-family: var(--font-body);
  font-size: 1.125rem;
  color: var(--color-text-brown);
  line-height: 1.6;
}

/* Intro step styling (step 0) */
.intro-step .step-content {
  background: linear-gradient(135deg, rgba(255, 236, 179, 0.95) 0%, rgba(255, 224, 130, 0.95) 100%);
  border: 2px solid rgba(255, 193, 7, 0.5);
  animation: swipeHint 2s ease-in-out 1s 2; /* Subtle hint: swipe me! */
}

.intro-step .step-title {
  font-size: 2rem;
  color: var(--color-primary);
}

.intro-step .step-description {
  font-size: 1.25rem;
  color: var(--color-text-dark);
  font-weight: 500;
}

/* Step ingredients list (preserves newlines) */
.step-ingredients {
  display: block;
  white-space: pre-line;
  margin-bottom: 0.75rem;
  line-height: 1.8;
}

/* Step action/instruction (different styling) */
.step-action {
  display: block;
  color: var(--color-text-dark);
  font-style: italic;
  font-weight: 500;
}

/* Sub-recipe display (fixed above carousel) */
.sub-recipe-display {
  text-align: center;
  padding: var(--spacing-md) var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  background: rgba(59, 35, 20, 0.9);
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(59, 35, 20, 0.3);
  border: 3px solid var(--color-primary);
}

.sub-recipe-current {
  font-family: var(--font-header);
  font-size: 1.75rem;
  color: var(--color-cream);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  margin: 0;
}

/* Hide old sub-recipe headers in carousel */
.sub-recipe-header {
  display: none;
}

/* ====================================
   Controls
   ==================================== */
.controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg) var(--spacing-sm);
  background: rgba(245, 230, 211, 0.95);
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(59, 35, 20, 0.2);
  margin-bottom: var(--spacing-md);
}

/* Navigation Buttons */
.nav-button {
  width: var(--arrow-size);
  height: var(--arrow-size);
  background: var(--color-cream);
  border: 3px solid var(--color-text-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(59, 35, 20, 0.15);
}

.nav-button:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(59, 35, 20, 0.2);
}

.nav-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-button img {
  width: 32px;
  height: 32px;
}

/* Audio Button */
.audio-button {
  width: var(--button-size);
  height: var(--button-size);
  background: var(--color-primary);
  border: 4px solid var(--color-text-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 35, 20, 0.25);
}

.audio-button:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(59, 35, 20, 0.3);
}

.audio-button img {
  width: 40px;
  height: 40px;
}

.audio-button.playing {
  background: var(--color-secondary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(59, 35, 20, 0.25);
  }
  50% {
    box-shadow: 0 4px 20px rgba(200, 150, 78, 0.5);
  }
}

/* ====================================
   Footer
   ==================================== */
.recipe-footer {
  text-align: center;
  padding: var(--spacing-md);
}

.back-link {
  font-family: var(--font-body);
  font-size: 1.125rem;
  font-weight: bold;
  color: var(--color-text-dark);
  text-decoration: none;
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-cream);
  border-radius: 12px;
  border: 2px solid var(--color-text-dark);
  transition: all 0.2s ease;
}

.back-link:hover,
.back-link:active {
  background: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(59, 35, 20, 0.2);
}

/* ====================================
   Touch & Mobile Optimizations
   ==================================== */
@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets on mobile */
  .nav-button {
    width: 56px;
    height: 56px;
  }

  .audio-button {
    width: 72px;
    height: 72px;
  }

  .audio-button img {
    width: 48px;
    height: 48px;
  }
}

/* ====================================
   Responsive Design
   ==================================== */
@media (max-width: 480px) {
  .recipe-title {
    font-size: 1.75rem;
  }

  .header-content {
    gap: var(--spacing-xs);
  }

  .ingredients-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .ingredients-toggle svg {
    width: 18px;
    height: 18px;
  }

  .step-number {
    font-size: 3rem;
  }

  .step-title {
    font-size: 1.5rem;
  }

  .step-description {
    font-size: 1rem;
  }

  .controls {
    padding: var(--spacing-md) var(--spacing-xs);
  }
}

@media (min-width: 768px) {
  .recipe-container {
    max-width: 768px;
    margin: 0 auto;
    padding: var(--spacing-lg);
  }

  .step-content {
    max-width: 600px;
  }
}

/* ====================================
   Accessibility
   ==================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
button:focus-visible {
  outline: 3px solid var(--color-secondary);
  outline-offset: 4px;
}

/* ====================================
   Ingredients Toggle Button
   ==================================== */
.ingredients-toggle {
  background: rgba(212, 165, 116, 0.3);
  border: 2px solid var(--color-text-dark);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 4px rgba(59, 35, 20, 0.15);
  position: relative;
  flex-shrink: 0;
}

.ingredients-toggle:hover {
  background: rgba(212, 165, 116, 0.5);
  transform: scale(1.05);
  box-shadow: 0 3px 8px rgba(59, 35, 20, 0.25);
}

.ingredients-toggle:active {
  transform: scale(0.98);
  box-shadow: 0 1px 3px rgba(59, 35, 20, 0.2);
}

.ingredients-toggle svg {
  color: var(--color-text-dark);
  width: 20px;
  height: 20px;
}

.ingredients-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #E74C3C;
  color: white;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  padding: 2px 4px;
  font-size: 10px;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ingredients-badge.show {
  display: flex;
}

/* ====================================
   Ingredients Sidebar
   ==================================== */
.ingredients-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
}

.ingredients-sidebar.open {
  pointer-events: auto;
}

.ingredients-sidebar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(59, 35, 20, 0);
  transition: background 0.3s ease;
}

.ingredients-sidebar.open .ingredients-sidebar-overlay {
  background: rgba(59, 35, 20, 0.7);
}

.ingredients-sidebar-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 85%;
  max-width: 400px;
  height: 100%;
  background: var(--color-cream);
  background-image: url('images/background.webp');
  background-size: cover;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  display: flex;
  flex-direction: column;
  border-left: 4px solid var(--color-text-dark);
}

.ingredients-sidebar.open .ingredients-sidebar-content {
  transform: translateX(0);
}

.ingredients-sidebar-header {
  padding: var(--spacing-lg) var(--spacing-md);
  background: rgba(245, 230, 211, 0.95);
  border-bottom: 3px solid var(--color-text-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ingredients-sidebar-title {
  font-family: var(--font-header);
  font-size: 1.75rem;
  color: var(--color-text-dark);
  margin: 0;
  letter-spacing: 1px;
}

.ingredients-sidebar-close {
  background: var(--color-primary);
  border: 3px solid var(--color-text-dark);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ingredients-sidebar-close:hover {
  background: var(--color-secondary);
  transform: rotate(90deg);
}

.ingredients-sidebar-close svg {
  color: var(--color-text-dark);
  width: 20px;
  height: 20px;
}

.ingredients-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  -webkit-overflow-scrolling: touch;
}

.ingredient-item {
  background: rgba(245, 230, 211, 0.9);
  border: 3px solid var(--color-text-dark);
  border-radius: 12px;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ingredient-item:hover {
  transform: translateX(-4px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.ingredient-item.checked {
  background: rgba(200, 150, 78, 0.3);
  opacity: 0.6;
}

.ingredient-checkbox {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 3px solid var(--color-text-dark);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.ingredient-checkbox::after {
  content: '';
  position: absolute;
  display: none;
  left: 8px;
  top: 3px;
  width: 6px;
  height: 12px;
  border: solid var(--color-text-dark);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.ingredient-item.checked .ingredient-checkbox {
  background: var(--color-secondary);
}

.ingredient-item.checked .ingredient-checkbox::after {
  display: block;
}

.ingredient-text {
  flex: 1;
  font-size: 1rem;
  color: var(--color-text-dark);
  line-height: 1.4;
  font-weight: 500;
}

.ingredient-item.checked .ingredient-text {
  text-decoration: line-through;
  color: var(--color-text-brown);
}

/* ====================================
   Responsive Adjustments
   ==================================== */
@media (min-width: 768px) {
  .ingredients-sidebar-content {
    width: 400px;
  }

  .header-content {
    gap: var(--spacing-md);
  }

  .ingredients-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .ingredients-toggle svg {
    width: 22px;
    height: 22px;
  }
}

/* ====================================
   Print Styles
   ==================================== */
@media print {
  body {
    background: white;
  }

  .controls,
  .recipe-footer,
  .ingredients-toggle,
  .ingredients-sidebar {
    display: none;
  }
}
