/**
 * Comic Widget Styles
 * Styled to match Sebastien Ringuette Portfolio aesthetic
 */

.comic-widget-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: #f5f3f0; /* Light beige background */
  padding: 30px;
  border-radius: 8px;
}

/* Loading State */
.comic-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #8b6f47; /* Brown text */
}

.comic-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e8e0d8; /* Light beige */
  border-top-color: #8b6f47; /* Brown */
  border-radius: 50%;
  animation: comic-spin 0.8s linear infinite;
  margin-bottom: 15px;
}

@keyframes comic-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.comic-error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #8b6f47;
  background: #f5f3f0;
  border-radius: 8px;
  border: 1px solid #d4c4b0;
}

/* Content */
.comic-content {
  display: flex;
  flex-direction: column;
}

/* Header */
.comic-header {
  margin-bottom: 25px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
}

.comic-header-text {
  flex: 1;
  min-width: 200px;
}

.comic-archive-title {
  margin-bottom: 8px;
}

.comic-archive-title h2 {
  margin: 0;
  /* Inherit from Elementor typography system and site styles */
  font-family: var(
    --e-global-typography-primary-font-family,
    var(
      --e-global-typography-text-font-family,
      -apple-system,
      BlinkMacSystemFont,
      "Segoe UI",
      Roboto,
      Oxygen,
      Ubuntu,
      Cantarell,
      sans-serif
    )
  );
  font-size: var(--e-global-typography-primary-font-size, 20px);
  font-weight: var(--e-global-typography-primary-font-weight, 600);
  line-height: var(--e-global-typography-primary-line-height, 1.3);
  color: var(--e-global-color-primary, #4a3e2e);
  letter-spacing: var(--e-global-typography-primary-letter-spacing, normal);
  text-transform: var(--e-global-typography-primary-text-transform, none);
}

.comic-copyright {
  margin-bottom: 0;
}

.comic-copyright p {
  margin: 0;
  font-size: 13px;
  color: #8b6f47; /* Brown */
  font-style: italic;
}

.comic-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 0;
  padding: 20px;
  background: #ebe6df; /* Slightly darker beige for content boxes */
  border-radius: 6px;
  border: 1px solid #d4c4b0;
  flex: 2;
  min-width: 300px;
}

.comic-control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 150px;
}

.comic-control-group label {
  font-size: 13px;
  font-weight: 600;
  color: #6b5d47; /* Darker brown for labels */
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comic-series-select,
.comic-strip-select,
input[type="search"].comic-search-input {
  padding: 10px 14px !important;
  border: 1px solid #d4c4b0 !important;
  border-radius: 4px !important;
  font-size: 14px !important;
  font-family: inherit !important;
  background: #fff !important;
  color: #4a3e2e !important; /* Brown text */
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.comic-series-select:focus,
.comic-strip-select:focus,
.comic-search-input:focus {
  outline: none;
  border-color: #8b6f47;
  box-shadow: 0 0 0 2px rgba(139, 111, 71, 0.1);
}

.comic-series-select:disabled,
.comic-strip-select:disabled {
  background: #f5f3f0;
  cursor: not-allowed;
  opacity: 0.6;
}

.comic-search-input {
  width: 100%;
}

/* Search Results */
.comic-search-results {
  width: 100%;
  margin-top: 0;
  margin-bottom: 20px;
}

.comic-search-no-results {
  padding: 40px 20px;
  text-align: center;
  color: #8b6f47;
  font-size: 16px;
  background: #ebe6df;
  border-radius: 6px;
  border: 1px solid #d4c4b0;
}

.comic-search-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
  background: #ebe6df;
  border-radius: 6px;
  border: 1px solid #d4c4b0;
}

.comic-search-result-item {
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #d4c4b0;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.comic-search-result-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: #8b6f47;
}

.comic-search-result-thumbnail {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f5f3f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comic-search-result-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.comic-search-result-no-thumb {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b6f47;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comic-search-result-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comic-search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: #4a3e2e;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.comic-search-result-date {
  font-size: 12px;
  color: #8b6f47;
  font-weight: 500;
}

.comic-search-result-series {
  font-size: 11px;
  color: #6b5d47;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-top: 2px;
}

/* Image Wrapper */
.comic-image-wrapper {
  position: relative;
  background: #ebe6df; /* Beige background */
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #d4c4b0;
  padding: 10px;
  touch-action: manipulation; /* Improve touch responsiveness */
}

.comic-image {
  width: 100%;
  line-height: 0;
  border-radius: 4px;
  overflow: hidden;
}

.comic-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.2s ease;
  touch-action: manipulation; /* Improve touch responsiveness */
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.comic-image img:hover {
  opacity: 0.9;
}

@media (hover: none) {
  .comic-image img:hover {
    opacity: 1; /* Don't change opacity on touch devices */
  }
}

/* Hover Text */
.comic-hover-text {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(245, 243, 240, 0.98); /* Beige with slight transparency */
  color: #4a3e2e; /* Brown text */
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 13px;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #d4c4b0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
}

.comic-image-wrapper:hover .comic-hover-text {
  opacity: 1;
  visibility: visible;
}

/* Hide hover text on touch devices */
@media (hover: none) and (pointer: coarse) {
  .comic-hover-text {
    display: none !important;
  }
}

/* Footer */
.comic-footer {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #d4c4b0;
}

/* Title */
.comic-title {
  font-size: 24px;
  font-weight: 700;
  color: #4a3e2e; /* Dark brown */
  letter-spacing: -0.5px;
  margin-bottom: 5px;
  text-align: center;
}

/* Content Text */
.comic-content-text {
  font-size: 16px;
  line-height: 1.6;
  color: #4a3e2e;
  margin: 15px 0;
  text-align: left;
}

.comic-content-text p {
  margin: 0 0 15px 0;
}

.comic-content-text p:last-child {
  margin-bottom: 0;
}

.comic-content-text a {
  color: #7fb3b8;
  text-decoration: underline;
}

.comic-content-text a:hover {
  color: #6a9ca0;
}

/* Navigation */
.comic-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.comic-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #7fb3b8; /* Light blue-green matching website buttons */
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 400;
  /* Inherit Elementor's button typography */
  font-family: var(
    --e-global-typography-text-font-family,
    var(
      --e-global-typography-primary-font-family,
      -apple-system,
      BlinkMacSystemFont,
      "Segoe UI",
      Roboto,
      Oxygen,
      Ubuntu,
      Cantarell,
      sans-serif
    )
  );
  font-style: var(--e-global-typography-text-font-style, normal);
  line-height: var(--e-global-typography-text-line-height, 1.5);
  cursor: pointer;
  transition: background-color 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
  text-transform: none;
  letter-spacing: normal;
}

.comic-nav-btn i {
  font-size: 12px;
}

.comic-nav-btn:hover {
  background: #6a9ca0; /* Darker blue-green on hover */
  transform: translateY(-1px);
}

.comic-nav-btn:active {
  transform: translateY(0);
}

.comic-nav-btn:disabled,
.comic-nav-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #a0c4c8; /* Lighter blue-green when disabled */
}

.comic-nav-btn:disabled:hover,
.comic-nav-btn.disabled:hover {
  background: #a0c4c8;
  transform: none;
}

/* Remove old nav-arrow styles as we're using Font Awesome now */

/* Copy Link Button */
.comic-copy-link {
  background: #7fb3b8; /* Same blue-green */
}

.comic-copy-link:hover {
  background: #6a9ca0;
}

/* Responsive */
@media (max-width: 768px) {
  .comic-widget-container {
    padding: 20px;
  }

  .comic-header {
    flex-direction: column;
  }

  .comic-header-text {
    min-width: 100%;
  }

  .comic-controls {
    flex-direction: column;
    padding: 15px;
    min-width: 100%;
  }

  .comic-control-group {
    min-width: 100%;
  }

  .comic-search-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 15px;
  }

  .comic-search-result-info {
    padding: 10px;
  }

  .comic-search-result-title {
    font-size: 13px;
  }

  .comic-footer {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .comic-title {
    font-size: 20px;
    text-align: center;
    margin-bottom: 10px;
  }

  .comic-content-text {
    font-size: 14px;
    line-height: 1.5;
    margin: 10px 0;
    text-align: left;
  }

  .comic-navigation {
    justify-content: center;
  }

  .comic-nav-btn {
    padding: 10px 16px;
    font-size: 13px;
  }

  .comic-hover-text {
    max-width: calc(100% - 40px);
    left: 20px;
    right: 20px;
    bottom: 20px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .comic-widget-container {
    padding: 15px;
  }

  .comic-nav-btn .nav-text {
    display: none;
  }

  .comic-nav-btn i {
    font-size: 14px;
  }

  .comic-copy-link .nav-text {
    display: inline;
  }

  .comic-search-results-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 12px;
  }

  .comic-search-result-info {
    padding: 8px;
  }

  .comic-search-result-title {
    font-size: 12px;
  }

  .comic-search-result-date {
    font-size: 11px;
  }

  .comic-search-result-series {
    font-size: 10px;
  }
}

/* Lightbox Styles */
.comic-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  padding: 20px;
  box-sizing: border-box;
  touch-action: manipulation; /* Improve touch responsiveness */
}

.comic-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.comic-lightbox-content {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  touch-action: pan-x pan-y pinch-zoom; /* Allow panning and zooming on mobile */
}

.comic-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: comic-lightbox-fade-in 0.3s ease;
  transition: transform 0.1s ease-out;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
  touch-action: pan-x pan-y pinch-zoom; /* Allow panning and zooming */
}

@keyframes comic-lightbox-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.comic-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 1000000;
  padding: 0;
  font-family: Arial, sans-serif;
}

.comic-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

.comic-lightbox-close:active {
  transform: scale(0.95);
}

/* Zoom Controls */
.comic-lightbox-zoom-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 1000000;
  background: rgba(0, 0, 0, 0.5);
  padding: 8px;
  border-radius: 8px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.comic-lightbox-zoom-btn {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
  font-family: Arial, sans-serif;
  font-weight: 300;
}

.comic-lightbox-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
}

.comic-lightbox-zoom-btn:active {
  transform: scale(0.95);
}

.comic-lightbox-zoom-reset {
  font-size: 20px;
}

/* Responsive Lightbox */
@media (max-width: 768px) {
  .comic-lightbox {
    padding: 10px;
  }

  .comic-lightbox-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 28px;
  }

  .comic-lightbox-image {
    border-radius: 2px;
  }

  .comic-lightbox-zoom-controls {
    bottom: 10px;
    padding: 6px;
    gap: 8px;
  }

  .comic-lightbox-zoom-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .comic-lightbox-zoom-reset {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .comic-lightbox {
    padding: 5px;
  }

  .comic-lightbox-close {
    top: 5px;
    right: 5px;
    width: 36px;
    height: 36px;
    font-size: 24px;
  }

  .comic-lightbox-zoom-controls {
    bottom: 5px;
    padding: 5px;
    gap: 6px;
  }

  .comic-lightbox-zoom-btn {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .comic-lightbox-zoom-reset {
    font-size: 16px;
  }
}
