/**
 * XSClean - Main Stylesheet (non-critical)
 * Loaded after above-the-fold render
 */

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .site-header,
  .sidebar,
  .site-footer,
  .back-to-top,
  .kqxs-actions,
  .collapsible-trigger,
  .btn { display: none !important; }

  .content-area { grid-template-columns: 1fr !important; }

  .kqxs-wrapper {
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }

  a[href]::after { content: " (" attr(href) ")"; }
  a[href^="#"]::after { content: ""; }
}

/* ========================================
   FORMS
   ======================================== */
.comment-form label {
  display: block;
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

.comment-form-cookies-consent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.comment-form-cookies-consent input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.comment-form-cookies-consent label {
  font-weight: 400;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
}

/* ========================================
   TAGS PAGE
   ======================================== */
.tag-cloud-link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm) !important;
  color: var(--color-text-secondary);
  text-decoration: none;
  margin: var(--space-1);
  transition: all var(--transition-fast);
}

.tag-cloud-link:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ========================================
   GALLERY
   ======================================== */
.gallery {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.gallery-columns-2 { grid-template-columns: repeat(2, 1fr); }
.gallery-columns-3 { grid-template-columns: repeat(3, 1fr); }
.gallery-columns-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 480px) {
  .gallery-columns-3,
  .gallery-columns-4 { grid-template-columns: repeat(2, 1fr); }
}

.gallery-item {
  overflow: hidden;
  border-radius: var(--radius-md);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.gallery-item:hover img {
  transform: scale(1.05);
}

/* ========================================
   EMBEDS
   ======================================== */
.wp-block-embed,
.embed-responsive {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6);
}

/* ========================================
   TABLE RESPONSIVE WRAPPER
   ======================================== */
.entry-content table {
  min-width: 400px;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========================================
   STICKY SIDEBAR
   ======================================== */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    max-height: calc(100vh - var(--header-height) - var(--space-8));
    overflow-y: auto;
    scrollbar-width: thin;
  }

  .sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .sidebar::-webkit-scrollbar-track {
    background: var(--color-bg);
  }

  .sidebar::-webkit-scrollbar-thumb {
    background: var(--color-border-strong);
    border-radius: var(--radius-full);
  }
}

/* ========================================
   SMOOTH TRANSITIONS FOR COLLAPSIBLE
   ======================================== */
.collapsible-content {
  overflow: hidden;
  transition: max-height var(--transition-base);
}

.collapsible.is-open .collapsible-content {
  display: block;
}

/* ========================================
   TOAST NOTIFICATION
   ======================================== */
.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  background: var(--color-text);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  transition: transform var(--transition-base);
  white-space: nowrap;
  pointer-events: none;
}

.toast.is-visible {
  transform: translateX(-50%) translateY(0);
}

/* ========================================
   LOADING OVERLAY
   ======================================== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

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

/* ========================================
   CUSTOMIZER PREVIEW
   ======================================== */
.customize-preview-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ========================================
   ACCESSIBILITY FOCUS STYLES
   ======================================== */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  border-radius: var(--radius-sm);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border-width: 2px;
    border-color: var(--color-text);
  }

  .btn {
    border-width: 2px;
  }

  .badge {
    border: 1px solid currentColor;
  }
}

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

/* ========================================
   DARK MODE EXTRAS
   ======================================== */
@media (prefers-color-scheme: dark) {
  .kqxs-wrapper {
    border-color: var(--color-border);
  }

  .kqxs-table th {
    background: var(--color-surface-2);
    color: var(--color-text-secondary);
  }

  .giai-db td {
    background: rgba(227, 160, 8, 0.15) !important;
  }

  .comment {
    background: var(--color-surface);
    border-color: var(--color-border);
  }

  input, textarea, select {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-color: var(--color-border);
  }

  .header-search-input {
    background: var(--color-surface-2);
    color: var(--color-text);
  }
}
