/* Font Showcase Block - Fixed CSS with Proper Glyph Grid Scoping */

:root {
  --ffv-primary: #3469a8;
  --ffv-secondary: #f3f4f6;
  --ffv-font: #333;
  --ffv-preview-padding: 8px;
  --ffv-export-checker-size: 16px;
}

/* SCOPED: Reset and Base - ONLY affects our plugin */
.font-showcase-block {
  font-family: Arial, sans-serif;
  margin: 0;
  position: relative;
  max-width: 800px;
  margin: 20px auto;
  padding: 20px;
  background: var(--ffv-secondary);
  border-radius: 8px;
  box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1);
  color: var(--ffv-font);
}

/* SCOPED: Loading Bar */
.font-showcase-loading-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 60px;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: opacity 0.5s, height 0.5s, margin 0.5s;
}

.font-showcase-loading-bar.fade {
  opacity: 0;
  height: 0;
  margin: 0;
  overflow: hidden;
}

.font-showcase-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #ccc;
  border-top: 3px solid #666;
  border-radius: 50%;
  animation: font-showcase-spin 1s linear infinite;
}

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

/* SCOPED: Header Section */
.font-showcase-header {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.font-showcase-header-title {
  background: var(--ffv-primary);
  color: #fff;
  padding: 15px 20px;
  font-size: 1.2rem;
  margin: 0;
  text-align: center;
  font-weight: 600;
}

/* SCOPED: Image Gallery */
.font-showcase-header-gallery {
  position: relative;
  background: #fff;
  padding: 1px;
  display: flex;
  gap: 1px;
  overflow: hidden;
  min-height: 200px;
}

.font-showcase-gallery-1 {
  justify-content: center;
}

.font-showcase-gallery-1 .font-showcase-header-image {
  width: 100%;
  max-width: 600px;
  height: 200px;
}

.font-showcase-gallery-2,
.font-showcase-gallery-3,
.font-showcase-gallery-4 {
  justify-content: stretch;
  align-items: stretch;
}

.font-showcase-gallery-2 .font-showcase-header-image,
.font-showcase-gallery-3 .font-showcase-header-image,
.font-showcase-gallery-4 .font-showcase-header-image {
  flex: 1;
  height: 200px;
  border: none;
  border-radius: 0;
  overflow: hidden;
  margin: 0;
}

.font-showcase-header-image {
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  background: #f8f9fa;
  border: 1px solid #ddd;
}

.font-showcase-header-image:hover {
  transform: scale(1.02);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  border-color: var(--ffv-primary);
}

.font-showcase-header-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  transition: transform 0.3s ease;
  background: #f8f9fa;
}

.font-showcase-header-image:hover img {
  transform: scale(1.05);
}

/* SCOPED: Lightbox */
.font-showcase-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.font-showcase-lightbox.show {
  display: flex;
}

.font-showcase-lightbox-content {
  position: relative;
  max-width: 80vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.font-showcase-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.font-showcase-lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  font-weight: bold;
  color: #333;
  transition: all 0.3s ease;
  z-index: 10001;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.font-showcase-lightbox-nav:hover {
  background: white;
  transform: translateY(-50%) scale(1.1);
}

.font-showcase-lightbox-prev {
  left: 20px;
}

.font-showcase-lightbox-next {
  right: 20px;
}

.font-showcase-lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  font-weight: bold;
  color: #333;
  z-index: 10001;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.font-showcase-lightbox-close:hover {
  background: white;
  transform: scale(1.1);
}

.font-showcase-lightbox-dots {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10001;
}

.font-showcase-lightbox-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.font-showcase-lightbox-dot.active {
  background: white;
  transform: scale(1.2);
}

.font-showcase-lightbox-dot:hover:not(.active) {
  background: rgba(255, 255, 255, 0.8);
}

.font-showcase-lightbox-counter {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10001;
}

/* SCOPED: Title Bar */
.font-showcase-title-bar {
  text-align: center;
  margin-bottom: 15px;
}

.font-showcase-title-bar h2 {
  margin: 0;
  color: var(--ffv-primary);
  font-size: 1.8rem;
  font-weight: bold;
}

.font-showcase-title-bar span {
  font-size: 1rem;
  color: #666;
}

/* SCOPED: Controls */
.font-showcase-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  background: #ccc;
  border-radius: 20px;
  padding: 1rem 1.5rem;
  margin-bottom: 20px;
}

.font-showcase-input-row {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.font-showcase-input-row label {
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}

.font-showcase-input-row input {
  border: 1px solid #aaa;
  border-radius: 6px;
  padding: 6px;
  font-size: 0.9rem;
}

.font-showcase-input-row input[type="text"] {
  width: 180px;
  background: #eee;
}

.font-showcase-input-row input[type="color"] {
  width: 60px;
  height: 40px;
  cursor: pointer;
}

.font-showcase-input-row input[type="range"] {
  width: 120px;
}

.font-showcase-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  border: none;
  transition: background 0.3s;
}

.font-showcase-icon-btn:hover {
  background: rgba(0, 0, 0, 0.3);
}

.font-showcase-icon-btn[title="Reset"]::before {
  content: "↻";
  font-size: 20px;
  font-weight: bold;
}

.font-showcase-icon-btn[title="Share"]::before {
  content: "🔗";
  font-size: 16px;
}

/* SCOPED: Font Blocks */
.font-showcase-fonts {
  background: transparent;
}

.font-showcase-font-item {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  padding: 15px;
  position: relative;
}

.font-showcase-font-info {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 6px;
  margin-bottom: 15px;
}

.font-showcase-font-info strong {
  font-weight: 600;
}

.font-showcase-info-btn {
  margin-left: auto;
  color: var(--ffv-primary) !important;
  font-size: 1.7rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.font-showcase-info-btn:hover {
  color: #244f7d;
}

/* SCOPED: Font Preview */
.font-showcase-font-preview {
  position: relative;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: var(--ffv-preview-padding);
  min-height: 60px;
  font-size: 48px;
  font-weight: 600;
  margin: 15px 0;
}

.font-showcase-font-preview::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 100%;
  background: linear-gradient(to right, rgba(240, 240, 240, 0), rgba(240, 240, 240, 1));
  pointer-events: none;
}

/* SCOPED: Font Pills */
.font-showcase-font-metadata {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}

.font-showcase-metadata-pill {
  background: #ddd;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #333;
}

/* SCOPED: Font Actions */
.font-showcase-font-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.font-showcase-generate-btn,
.font-showcase-buy-btn,
.font-showcase-download-btn {
  border: none;
  border-radius: 4px;
  color: #fff;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.3s;
}

.font-showcase-generate-btn {
  background: #0056b3;
}

.font-showcase-buy-btn {
  background: #f39c12;
}

.font-showcase-download-btn {
  background: #545b62;
}

.font-showcase-generate-btn:hover,
.font-showcase-buy-btn:hover,
.font-showcase-download-btn:hover {
  opacity: 0.9;
}

/* SCOPED: Note Section */
.font-showcase-note {
  background: #fff8c4;
  border-left: 4px solid #f1c40f;
  padding: 12px 16px;
  margin-top: 20px;
  border-radius: 4px;
  color: #333;
  font-size: 0.95rem;
}

/* SCOPED: Modal Base Styles */
.font-showcase-share-modal,
.font-showcase-info-modal,
.font-showcase-export-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.font-showcase-share-modal.show,
.font-showcase-info-modal.show,
.font-showcase-export-modal.show {
  display: flex;
}

.font-showcase-share-content,
.font-showcase-info-content,
.font-showcase-export-content {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.font-showcase-share-close,
.font-showcase-info-close,
.font-showcase-export-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  color: #888;
  cursor: pointer;
}

.font-showcase-share-close:hover,
.font-showcase-info-close:hover,
.font-showcase-export-close:hover {
  color: #000;
}

/* SCOPED: Share Modal Icons */
.font-showcase-share-icons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
}

.font-showcase-share-icon-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: white;
}

.font-showcase-share-icon-btn[data-site="pinterest"] {
  background: #bd081c;
}

.font-showcase-share-icon-btn[data-site="x"] {
  background: #000000;
}

.font-showcase-share-icon-btn[data-site="facebook"] {
  background: #1877f2;
}

.font-showcase-share-icon-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.font-showcase-share-icon-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.font-showcase-share-link-container {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.font-showcase-share-link-container input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.font-showcase-share-copy {
  padding: 10px 20px;
  background: var(--ffv-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.font-showcase-share-copy:hover {
  opacity: 0.9;
}

/* SCOPED: Modal Tabs */
.font-showcase-modal-tabs {
  display: flex;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
}

.font-showcase-modal-tab {
  flex: 1;
  padding: 12px 16px;
  background: #f5f5f5;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  transition: all 0.3s ease;
}

.font-showcase-modal-tab.active {
  background: white;
  color: var(--ffv-primary);
  border-bottom: 2px solid var(--ffv-primary);
}

.font-showcase-modal-tab:hover:not(.active) {
  background: #e9e9e9;
  color: #333;
}

.font-showcase-modal-body {
  display: none;
  min-height: 300px;
}

.font-showcase-modal-body.active {
  display: block;
}

/* SCOPED: FIXED - Glyphs Grid ONLY for Glyphs Tab */
.font-showcase-modal-body.font-showcase-glyphs-grid {
  display: grid !important;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  justify-content: center;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
  width: 100%;
  min-width: 400px;
  background: white;
  border: 1px solid #eee;
  border-radius: 4px;
}

.font-showcase-modal-body.font-showcase-glyphs-grid .font-showcase-char-cell {
  aspect-ratio: 1;
  min-height: 60px;
  min-width: 60px;
  border: 1px solid #ccc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  font-weight: normal;
  transition: all 0.2s ease;
  background: white;
  position: relative;
}

.font-showcase-modal-body.font-showcase-glyphs-grid .font-showcase-char-cell:hover {
  background-color: #f0f0f0;
  border-color: var(--ffv-primary);
  transform: scale(1.05);
  z-index: 1;
}

/* SCOPED: Active Block Highlighting */
.font-showcase-font-item.font-showcase-active-block {
  box-shadow: 0 0 0 2px var(--ffv-primary);
  transition: box-shadow 0.3s ease;
}

/* SCOPED: Export Preview Backgrounds */
.font-showcase-export-preview {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin: 15px 0;
}

.font-showcase-export-preview.checker {
  background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f0f0f0 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.font-showcase-export-preview.solid {
  background: white;
}

.font-showcase-export-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* SCOPED: Tooltip Styles for Tippy.js */
.tippy-box[data-theme~="light-border"] {
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid rgba(0, 8, 16, 0.15);
  color: #333;
  box-shadow: 0 4px 14px -2px rgba(0, 8, 16, 0.08);
}

.tippy-box[data-theme~="light-border"] > .tippy-backdrop {
  background-color: #fff;
}

.tippy-box[data-theme~="light-border"] > .tippy-arrow:before,
.tippy-box[data-theme~="light-border"] > .tippy-svg-arrow > svg:first-child:not(:last-child) {
  border-color: rgba(0, 8, 16, 0.15);
}

.tippy-box[data-theme~="light-border"] > .tippy-arrow:after,
.tippy-box[data-theme~="light-border"] > .tippy-svg-arrow > svg:last-child {
  border-color: #fff;
}

/* SCOPED: Responsive Design */
@media (max-width: 768px) {
  .font-showcase-controls {
    flex-direction: column;
  }

  .font-showcase-input-row input[type="text"] {
    width: 140px;
  }

  .font-showcase-share-content,
  .font-showcase-info-content,
  .font-showcase-export-content {
    width: 95%;
  }

  .font-showcase-font-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .font-showcase-lightbox {
    padding: 40px 20px;
  }

  .font-showcase-lightbox-nav {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .font-showcase-lightbox-prev {
    left: -60px;
  }

  .font-showcase-lightbox-next {
    right: -60px;
  }

  .font-showcase-lightbox-close {
    width: 35px;
    height: 35px;
    font-size: 20px;
    top: -15px;
    right: -15px;
  }

  .font-showcase-gallery-2 .font-showcase-header-image,
  .font-showcase-gallery-3 .font-showcase-header-image,
  .font-showcase-gallery-4 .font-showcase-header-image {
    width: 150px;
    height: 150px;
    margin-right: 4px;
  }

  /* Glyphs grid responsive - 4 columns on mobile */
  .font-showcase-modal-body.font-showcase-glyphs-grid {
    grid-template-columns: repeat(4, 1fr);
    min-width: 320px;
    gap: 6px;
  }

  .font-showcase-modal-body.font-showcase-glyphs-grid .font-showcase-char-cell {
    min-height: 50px;
    min-width: 50px;
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .font-showcase-block {
    margin: 10px;
    padding: 15px;
  }

  .font-showcase-header-title {
    padding: 12px 15px;
    font-size: 1.1rem;
  }

  .font-showcase-gallery-2 .font-showcase-header-image,
  .font-showcase-gallery-3 .font-showcase-header-image,
  .font-showcase-gallery-4 .font-showcase-header-image {
    width: 120px;
    height: 120px;
  }

  /* Extra small screens - maintain 4 columns but smaller cells */
  .font-showcase-modal-body.font-showcase-glyphs-grid {
    grid-template-columns: repeat(4, 1fr);
    min-width: 280px;
    gap: 4px;
  }

  .font-showcase-modal-body.font-showcase-glyphs-grid .font-showcase-char-cell {
    min-height: 45px;
    min-width: 45px;
    font-size: 18px;
  }
}

/* Tablet and larger screens - enhance glyph grid */
@media (min-width: 769px) and (max-width: 1024px) {
  .font-showcase-modal-body.font-showcase-glyphs-grid {
    grid-template-columns: repeat(6, 1fr);
    min-width: 480px;
  }
}

@media (min-width: 1025px) {
  .font-showcase-modal-body.font-showcase-glyphs-grid {
    grid-template-columns: repeat(8, 1fr);
    min-width: 640px;
  }

  .font-showcase-modal-body.font-showcase-glyphs-grid .font-showcase-char-cell {
    min-height: 70px;
    min-width: 70px;
    font-size: 26px;
  }
}

/* SCOPED: Notification Styles */
.font-showcase-notifications {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10002;
  max-width: 300px;
}

.font-showcase-notification {
  background: #4caf50;
  color: white;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideInRight 0.3s ease;
}

.font-showcase-notification.error {
  background: #f44336;
}

.font-showcase-notification-close {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  margin-left: 10px;
  padding: 0;
  line-height: 1;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
