/*!
 * Like Button Component CSS
 * Clean, maintainable structure with consistent sizing across all contexts
 */

/* ================================
 * CSS Custom Properties (Variables)
 * ================================ */
:root {
  /* Base component sizing */
  --like-button-heart-size: 12px;
  --like-button-icon-container: 16px;
  --like-button-gap: 6px;
  --like-button-padding: 8px;
  --like-button-margin: -8px;
  
  /* Mobile sizing */
  --like-button-mobile-touch-target: 44px;
  --like-button-mobile-padding: 10px;
  --like-button-mobile-margin: -10px;
  
  /* Colors */
  --like-button-color-inactive: #9CA3AF;
  --like-button-color-active: #FF586D;
  --like-button-color-count: #6B7280;
  --like-button-hover-bg: rgba(255, 88, 109, 0.08);
  
  /* Typography */
  --like-button-font-size: 14px;
  --like-button-font-weight: 500;
}

/* ================================
 * Base Component Structure
 * ================================ */

/* Component container */
.like-button[data-component="like-button"] {
  display: inline-block;
  position: relative;
  margin: 0;
  padding: 0;
  line-height: 1;
  font-size: inherit;
}

/* Interactive trigger button */
.like-button__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--like-button-gap);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--like-button-padding);
  margin: var(--like-button-margin);
  border-radius: 8px;
  transition: background-color 0.2s ease, transform 0.1s ease;
  position: relative;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-align: left;
  min-width: auto;
  min-height: auto;
  touch-action: manipulation;
}

/* Icon container */
.like-button__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--like-button-icon-container);
  height: var(--like-button-icon-container);
  position: relative;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

/* Heart SVG icon */
.like-button__heart {
  width: var(--like-button-heart-size);
  height: var(--like-button-heart-size);
  color: var(--like-button-color-inactive);
  transition: color 0.2s ease, fill 0.2s ease;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Count display */
.like-button__count {
  font-size: var(--like-button-font-size);
  font-weight: var(--like-button-font-weight);
  color: var(--like-button-color-count);
  transition: color 0.2s ease;
  display: inline-block;
  margin: 0;
  padding: 0;
  line-height: 1;
  position: static;
  flex-shrink: 0;
}

/* ================================
 * Interactive States
 * ================================ */

.like-button__trigger:hover {
  background-color: var(--like-button-hover-bg);
}

.like-button__trigger:active {
  transform: scale(0.95);
}

.like-button__trigger:focus {
  outline: 2px solid var(--like-button-color-active);
  outline-offset: 2px;
}

.like-button__trigger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Active (liked) state */
.like-button__heart.is-active {
  color: var(--like-button-color-active);
  fill: currentColor;
}

.like-button__count.is-active {
  color: var(--like-button-color-active);
}

/* ================================
 * Loading State
 * ================================ */

.like-button--loading .like-button__trigger {
  pointer-events: none;
  opacity: 0.7;
}

.like-button--loading .like-button__heart {
  animation: heartSpin 1s linear infinite;
}

@keyframes heartSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ================================
 * Size Variants
 * ================================ */

.like-button--small {
  font-size: 12px;
}

.like-button--small .like-button__icon {
  width: 14px;
  height: 14px;
}

.like-button--small .like-button__heart {
  width: 10px;
  height: 10px;
}

.like-button--small .like-button__count {
  font-size: 12px;
}

.like-button--large {
  font-size: 16px;
}

.like-button--large .like-button__icon {
  width: 20px;
  height: 20px;
}

.like-button--large .like-button__heart {
  width: 16px;
  height: 16px;
}

.like-button--large .like-button__count {
  font-size: 16px;
}

/* ================================
 * Mobile Responsive Design
 * ================================ */

@media (max-width: 991px) {
  .like-button__trigger {
    min-width: var(--like-button-mobile-touch-target);
    min-height: var(--like-button-mobile-touch-target);
    padding: var(--like-button-mobile-padding);
    margin: var(--like-button-mobile-margin);
  }
}

@media (max-width: 480px) {
  .like-button__trigger {
    min-width: 40px;
    min-height: 40px;
    padding: var(--like-button-padding);
    margin: var(--like-button-margin);
  }
  
  .like-button__count {
    font-size: 13px;
  }
}

/* ================================
 * Context Integration
 * ================================ */

/* Ensure component doesn't inherit unwanted styles */
.like-button[data-component="like-button"] * {
  box-sizing: border-box;
}

/* Context containers that need flex alignment */
.home-review-liked,
.review-list-review-liked {
  display: flex;
  align-items: center;
}

/* ================================
 * Accessibility & User Preferences
 * ================================ */

/* High contrast mode support */
@media (prefers-contrast: high) {
  .like-button__heart {
    stroke-width: 3;
  }
  
  .like-button__trigger:focus {
    outline-width: 3px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .like-button__heart,
  .like-button__count,
  .like-button__trigger {
    transition: none;
    animation: none;
  }
  
  .like-button__heart.is-active {
    animation: none;
  }
}

/* ================================
 * Animation Effects
 * ================================ */

@keyframes heartPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Optional pulse animation on like (can be enabled via JS) */
.like-button__heart.pulse {
  animation: heartPulse 0.3s ease-out;
}