/* ==========================================================================
   VISUAL POLISH OVERRIDES (Global)
   Added to enhance typography, spacing, and micro-interactions
   ========================================================================== */

/* 1. Typography & Spacing */
h1 {
  letter-spacing: -0.05em !important;
  line-height: 0.95 !important;
}

h2 {
  letter-spacing: -0.04em !important;
  line-height: 1.05 !important;
}

h3 {
  letter-spacing: -0.02em !important;
}

.section {
  padding: clamp(60px, 8vw, 100px) 0 !important;
}

.section.tight {
  padding: clamp(48px, 6vw, 80px) 0 !important;
}

p, .lead {
  line-height: 1.65 !important;
}

/* 2. Premium Micro-interactions */
/* Buttons */
.btn-primary, .btn-secondary, .nav-links a.nav-survey-link, .survey-link-card .btn {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), 
              box-shadow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), 
              background-color 0.3s ease !important;
}

.btn-primary:hover, .nav-links a.nav-survey-link:hover, .survey-link-card .btn:hover {
  transform: translateY(-3px) scale(1.02) !important;
  box-shadow: 0 16px 32px rgba(11, 51, 42, 0.3), 0 4px 8px rgba(11, 51, 42, 0.15) !important;
}

.btn-secondary:hover {
  transform: translateY(-3px) scale(1.02) !important;
  box-shadow: 0 12px 28px rgba(16, 37, 31, 0.15), 0 4px 8px rgba(16, 37, 31, 0.08) !important;
}

/* Navigation Links */
.nav-links a:not(.nav-survey-link) {
  position: relative;
  transition: color 0.25s ease !important;
  text-decoration: none !important;
}

.nav-links a:not(.nav-survey-link)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 60%;
  height: 2px;
  background-color: var(--forest);
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.nav-links a:not(.nav-survey-link):hover::after, 
.nav-links a.active:not(.nav-survey-link)::after {
  transform: translateX(-50%) scaleX(1);
}

/* Section Cards (Science Steps, etc) */
.science-step, .home-contact-card {
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), 
              box-shadow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), 
              border-color 0.3s ease !important;
  box-shadow: 0 4px 14px rgba(16, 37, 31, 0.03), inset 0 1px 2px rgba(255, 255, 255, 0.6) !important;
}

.science-step:hover, .home-contact-card:hover {
  transform: translateY(-6px) scale(1.01) !important;
  box-shadow: 0 22px 44px rgba(16, 37, 31, 0.1), inset 0 1px 2px rgba(255, 255, 255, 1) !important;
  border-color: rgba(185, 145, 53, 0.35) !important;
}

/* 3. Utility Classes */
.dog-detail-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-ref-wrapper,
.card-share-wrapper {
  position: relative;
  display: inline-block;
}

/* 4. Accessibility (a11y) & Keyboard Navigation */
:focus-visible {
  outline: 3px solid rgba(185, 145, 53, 0.6) !important;
  outline-offset: 3px !important;
  border-radius: 4px;
}

.btn:focus-visible, .nav-links a:focus-visible {
  border-radius: 999px;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--forest);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* 5. Premium UI Refinements */

/* Mobile Gallery Snapping & Scrollbars */
@media (max-width: 760px) {
  body[data-page="aging"] .dog-gallery {
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
  }
  body[data-page="aging"] .dog-gallery::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
  }
  body[data-page="aging"] .dog-gallery > * {
    scroll-snap-align: start;
  }
}

/* Hide scrollbar for horizontal carousel */
#deckGrid {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#deckGrid::-webkit-scrollbar {
  display: none;
}

/* Citation Hierarchy */
.card-ref-tooltip {
  font-size: 0.8rem !important;
  color: rgba(250, 247, 242, 0.8) !important; /* Muted cream for dark background */
  line-height: 1.4 !important;
  max-height: 250px !important;
  overflow-y: auto !important;
}

/* Status Contrast */
body[data-page="aging"] .gallery-status {
  color: #4a3618 !important; /* Darker bronze for contrast */
}

/* Tactile Active States */
.btn-primary:active, .btn-secondary:active, .nav-links a.nav-survey-link:active, .survey-link-card .btn:active, .share-scale:active, .clear-dogs:active {
  transform: scale(0.98) translateY(0) !important;
  box-shadow: 0 4px 8px rgba(11, 51, 42, 0.15) !important;
  transition: transform 0.1s ease, box-shadow 0.1s ease !important;
}

/* Card Entrance Animations */
@keyframes premiumFadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.dog-detail-card {
  animation: premiumFadeInUp 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

/* Header Anchoring */
.deck-head {
  border-bottom: 1px solid rgba(16, 37, 31, 0.08);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

/* Floating Tooltip Dog Names in Gallery (Global Styles) */
body[data-page="aging"] .dog-gallery {
  padding-top: 50px !important; /* Provide space for the top row tooltips */
}

body[data-page="aging"] .dog-tile {
  position: relative !important;
  overflow: visible !important;
}

body[data-page="aging"] .dog-tile .dog-hover-name {
  position: absolute !important;
  bottom: 100% !important; /* Positioned above the dog tile */
  left: 50% !important;
  transform: translateX(-50%) translateY(0) !important;
  
  /* Tooltip Styling */
  background: var(--forest) !important;
  color: var(--cream) !important;
  font-family: 'Outfit', 'Inter', sans-serif !important;
  font-size: 0.60rem !important; /* Extremely small text */
  font-weight: 500 !important;
  letter-spacing: 0.05em !important; /* Keep it legible at this micro size */
  line-height: 1.25 !important;
  padding: 6px 12px !important;
  border-radius: 8px !important;
  white-space: normal !important;
  width: max-content !important;
  max-width: 120px !important;
  text-align: center !important;
  pointer-events: none !important; /* Ensure it doesn't block clicks */
  box-shadow: 0 12px 24px rgba(16, 37, 31, 0.18) !important;
  z-index: 100 !important;
  margin-bottom: 6px !important;
}

/* Triangle pointer pointing down to the dog */
body[data-page="aging"] .dog-tile .dog-hover-name::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: var(--forest) transparent transparent transparent;
}

/* Desktop Hover Logic */
@media (hover: hover) and (pointer: fine) and (min-width: 761px) {
  body[data-page="aging"] .dog-tile .dog-hover-name {
    opacity: 0 !important;
    transform: translateX(-50%) translateY(8px) !important;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.25, 1, 0.5, 1) !important;
  }
  
  body[data-page="aging"] .dog-tile:hover .dog-hover-name,
  body[data-page="aging"] .dog-tile:focus-visible .dog-hover-name {
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
  }
}

/* Mobile Always-Visible Logic */
@media (max-width: 760px), (hover: none) {
  body[data-page="aging"] .dog-tile .dog-hover-name {
    opacity: 1 !important;
  }
}

/* Inline Search and Filter Controls */
body[data-page="aging"] .dog-gallery-controls {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
  scrollbar-width: none !important; /* Firefox */
  -webkit-overflow-scrolling: touch;
  width: 100% !important;
  flex-shrink: 0 !important; /* Prevent controls from being squashed vertically */
}

body[data-page="aging"] .dog-gallery-controls::-webkit-scrollbar {
  display: none !important; /* Chrome/Safari */
  width: 0 !important;
  height: 0 !important;
}

body[data-page="aging"] .dog-gallery-controls input#dogSearch {
  flex: 0 0 140px !important; /* Fixed base width */
  min-width: 140px !important;
}

body[data-page="aging"] .dog-gallery-controls .search-suggestions {
  margin-top: 0 !important;
  flex: 0 0 auto !important;
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 6px !important;
}

body[data-page="aging"] .dog-gallery-controls .search-suggestions .suggestion-chip {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}

/* ========================================================================
   QA AUDIT RESPONSIVE FIXES
   ======================================================================== */

/* 1. Overflow & Cut-offs: The "Clear all" Button Risk */
body[data-page="aging"] .clear-dogs {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
}

/* 2. Mobile Hover Conflicts: Cancel sticky hovers on touch devices */
@media (hover: none) and (pointer: coarse) {
  body[data-page="aging"] .dog-detail-card:hover {
    transform: none !important;
    border-color: rgba(16, 37, 31, 0.08) !important;
    box-shadow: 0 8px 24px rgba(16, 37, 31, 0.08) !important;
  }
  
  body[data-page="aging"] .clear-dogs:not(:disabled):hover {
    background: transparent !important;
    border-color: rgba(16, 37, 31, .15) !important;
    color: var(--forest) !important;
  }
  
  body[data-page="aging"] .btn-share-pack:hover {
    background: var(--forest) !important;
    transform: none !important;
    box-shadow: 0 6px 16px rgba(16, 37, 31, 0.2) !important;
  }
}

/* 3. Flexbox Collisions: The Deck Header Actions */
body[data-page="aging"] .deck-head-actions {
  flex-wrap: wrap !important;
}

/* 4. Z-Index Contexts: Carousel Tooltip Clipping */
body[data-page="aging"] .deck-grid.is-carousel {
  overflow-y: visible !important;
}

/* 5. Scrollbar Polish: Hide custom scrollbar on mobile */
@media (hover: none) and (pointer: coarse) {
  body[data-page="aging"] .deck-grid.is-carousel::-webkit-scrollbar {
    display: none !important;
  }
}

/* 6. Flexbox Squashing: Prevent gallery headers from shrinking */
body[data-page="aging"] .gallery-status {
  flex-shrink: 0 !important;
}
