/* ==========================================================================
 * Shared styles for Wapuufy custom blocks.
 * Spacing uses theme.json preset variables for consistency.
 * ========================================================================== */

/* --- Credits Grid Block --- */
.wapuu-credits-grid {
  display: grid;
  gap: var(--wp--preset--spacing--md);
  grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
  .wapuu-credits-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .wapuu-credits-grid { grid-template-columns: repeat(3, 1fr); }
}

.wapuu-credit-card {
  display: flex;
  flex-direction: column;
  padding: var(--wp--preset--spacing--lg);
  border: 1px solid var(--wapuu-border, var(--wp--preset--color--border));
  border-radius: 0.75rem;
  background: var(--wapuu-card, var(--wp--preset--color--card));
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.wapuu-credit-card:hover {
  border-color: var(--wp--preset--color--primary);
  transform: translateY(-2px);
}

/* Creator highlight card */
.wapuu-credit-card--creator {
  flex-direction: row;
  align-items: center;
  gap: var(--wp--preset--spacing--lg);
  padding: var(--wp--preset--spacing--xl);
  margin-bottom: var(--wp--preset--spacing--2xl);
  border-color: color-mix(in srgb, var(--wp--preset--color--primary) 40%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--wp--preset--color--primary) 8%, transparent), var(--wapuu-card, var(--wp--preset--color--card)));
}

.wapuu-credit-card--creator:hover {
  border-color: var(--wp--preset--color--primary);
  background: linear-gradient(135deg, color-mix(in srgb, var(--wp--preset--color--primary) 12%, transparent), var(--wapuu-card, var(--wp--preset--color--card)));
}

.wapuu-credit-card--creator__avatar {
  flex-shrink: 0;
}

.wapuu-credit-card--creator__avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--wp--preset--color--primary) 40%, transparent);
  object-fit: cover;
  background: var(--wapuu-muted, var(--wp--preset--color--muted));
}

.wapuu-credit-card--creator__content {
  display: flex;
  flex-direction: column;
}

@media (max-width: 639px) {
  .wapuu-credit-card--creator {
    flex-direction: column;
    text-align: center;
  }
}

.wapuu-credit-card__name {
  font-weight: 600;
  font-size: 1rem;
}

.wapuu-credit-card__role {
  display: inline-block;
  margin-top: var(--wp--preset--spacing--xs);
  padding: 0.125rem var(--wp--preset--spacing--sm);
  border-radius: 9999px;
  background: color-mix(in srgb, var(--wp--preset--color--primary) 10%, transparent);
  color: var(--wp--preset--color--primary);
  font-size: 0.75rem;
  font-weight: 500;
}

.wapuu-credit-card__desc {
  margin-top: var(--wp--preset--spacing--sm);
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
}

/* --- Site Logo Block --- */
.wapuufy-site-logo {
  display: inline-flex;
  align-items: center;
}

.wapuufy-logo-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.wapuufy-logo-wrap {
  display: inline-flex;
  align-items: center;
}

.wapuufy-logo {
  display: inline-block;
  object-fit: contain;
}

.dark .wapuufy-logo--light { display: none; }
.dark .wapuufy-logo--dark { display: inline-block; }
.light .wapuufy-logo--dark { display: none; }
.light .wapuufy-logo--light { display: inline-block; }

/* --- Feature Showcase Block --- */
.wapuu-feature-grid {
  display: grid;
  gap: var(--wp--preset--spacing--lg);
  grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
  .wapuu-feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .wapuu-feature-grid { grid-template-columns: repeat(3, 1fr); }
}

.wapuu-feature-card {
  padding: var(--wp--preset--spacing--lg);
  border: 1px solid var(--wapuu-border, var(--wp--preset--color--border));
  border-radius: 0.75rem;
  background: var(--wapuu-card, var(--wp--preset--color--card));
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.wapuu-feature-card:hover {
  border-color: color-mix(in srgb, var(--wp--preset--color--primary) 50%, transparent);
  transform: translateY(-2px);
}

.wapuu-feature-card__icon {
  display: inline-flex;
  padding: var(--wp--preset--spacing--sm);
  margin-bottom: var(--wp--preset--spacing--md);
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--wp--preset--color--primary) 10%, transparent);
  color: var(--wp--preset--color--primary);
}

.wapuu-feature-card__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.wapuu-feature-card__title {
  font-size: 1.125rem;
  font-weight: 600;
}

.wapuu-feature-card__desc {
  margin-top: var(--wp--preset--spacing--sm);
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
}

/* --- Gallery Grid Block --- */
.wapuu-gallery-grid {
  display: grid;
  gap: var(--wp--preset--spacing--md);
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 640px) {
  .wapuu-gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .wapuu-gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

.wapuu-gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 0.75rem;
  border: 1px solid var(--wapuu-border, var(--wp--preset--color--border));
}

.wapuu-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

/* --- Event List Block --- */
.wapuu-event-list {
  display: grid;
  gap: var(--wp--preset--spacing--md);
  grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
  .wapuu-event-list { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .wapuu-event-list { grid-template-columns: repeat(3, 1fr); }
}

.wapuu-event-card {
  --event-color: #21759B;
  position: relative;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--wapuu-border, var(--wp--preset--color--border));
  border-radius: 0.75rem;
  background: var(--wapuu-card, var(--wp--preset--color--card));
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.wapuu-event-card:hover {
  transform: translateY(-3px);
  border-color: var(--event-color);
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--event-color) 25%, transparent);
}

.wapuu-event-card__accent {
  width: 4px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--event-color), color-mix(in srgb, var(--event-color) 40%, transparent));
  transition: width 0.2s ease;
}

.wapuu-event-card:hover .wapuu-event-card__accent {
  width: 6px;
}

.wapuu-event-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--xs);
  padding: var(--wp--preset--spacing--lg);
  flex: 1;
}

.wapuu-event-card__name {
  font-weight: 600;
  font-size: 1rem;
}

.wapuu-event-card__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--wp--preset--spacing--xs);
  font-size: 0.8125rem;
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
}

.wapuu-event-card__meta svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* --- App Download Block --- */
.wapuu-app-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wp--preset--spacing--md);
}

.wapuu-app-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: 1px solid var(--wapuu-border, var(--wp--preset--color--border));
  border-radius: 0.75rem;
  background: var(--wapuu-card, var(--wp--preset--color--card));
  color: var(--wapuu-foreground, var(--wp--preset--color--foreground));
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wapuu-app-badge:hover {
  background: var(--wapuu-secondary, var(--wp--preset--color--secondary));
}

.wapuu-app-badge svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

/* --- Crowdsource CTA Block --- */
.wapuu-crowdsource-grid {
  display: grid;
  gap: var(--wp--preset--spacing--lg);
  grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
  .wapuu-crowdsource-grid { grid-template-columns: repeat(2, 1fr); }
}

.wapuu-crowdsource-card {
  display: flex;
  flex-direction: column;
  padding: var(--wp--preset--spacing--lg);
  border: 1px solid var(--wapuu-border, var(--wp--preset--color--border));
  border-radius: 0.75rem;
  background: var(--wapuu-card, var(--wp--preset--color--card));
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.wapuu-crowdsource-card--primary {
  border-color: color-mix(in srgb, var(--wp--preset--color--primary) 50%, transparent);
  background: color-mix(in srgb, var(--wp--preset--color--primary) 5%, transparent);
}

.wapuu-crowdsource-card:hover {
  border-color: var(--wp--preset--color--primary);
  transform: translateY(-2px);
}

.wapuu-crowdsource-card__icon svg {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: var(--wp--preset--spacing--md);
  color: var(--wp--preset--color--primary);
}

.wapuu-crowdsource-card__title {
  font-weight: 600;
  font-size: 1.125rem;
}

.wapuu-crowdsource-card__desc {
  margin-top: var(--wp--preset--spacing--sm);
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
}

.wapuu-crowdsource-card__action {
  display: inline-flex;
  align-items: center;
  gap: var(--wp--preset--spacing--xs);
  margin-top: var(--wp--preset--spacing--md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--wp--preset--color--primary);
  text-decoration: none;
  transition: gap 0.2s ease;
}

.wapuu-crowdsource-card:hover .wapuu-crowdsource-card__action {
  gap: var(--wp--preset--spacing--sm);
}

/* ==========================================================================
 * Scroll-triggered animations.
 * Elements start hidden; .wapuu-visible is added by scroll-animate.js.
 * Respects prefers-reduced-motion.
 * ========================================================================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(1.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Initial hidden state for animated elements */
.wapuu-animate {
  opacity: 0;
}

/* Animate when visible */
.wapuu-animate.wapuu-visible {
  animation: fadeInUp 0.5s ease forwards;
}

/* Staggered delays for grid children */
.wapuu-animate-stagger.wapuu-visible > :nth-child(1) { animation: fadeInUp 0.4s ease 0.0s forwards; opacity: 0; }
.wapuu-animate-stagger.wapuu-visible > :nth-child(2) { animation: fadeInUp 0.4s ease 0.07s forwards; opacity: 0; }
.wapuu-animate-stagger.wapuu-visible > :nth-child(3) { animation: fadeInUp 0.4s ease 0.14s forwards; opacity: 0; }
.wapuu-animate-stagger.wapuu-visible > :nth-child(4) { animation: fadeInUp 0.4s ease 0.21s forwards; opacity: 0; }
.wapuu-animate-stagger.wapuu-visible > :nth-child(5) { animation: fadeInUp 0.4s ease 0.28s forwards; opacity: 0; }
.wapuu-animate-stagger.wapuu-visible > :nth-child(6) { animation: fadeInUp 0.4s ease 0.35s forwards; opacity: 0; }
.wapuu-animate-stagger.wapuu-visible > :nth-child(n+7) { animation: fadeInUp 0.4s ease 0.42s forwards; opacity: 0; }

/* Gallery uses scale-in */
.wapuu-gallery-grid.wapuu-animate-stagger.wapuu-visible > * {
  animation-name: scaleIn;
}

/* Nav link underline slide */
.wp-block-navigation a {
  position: relative;
  text-decoration: none;
}

.wp-block-navigation a::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--wp--preset--color--primary);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.25s ease;
}

.wp-block-navigation a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* --- Footer --- */
.wapuu-footer a {
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
  text-decoration: none;
  transition: color 0.2s ease;
}

.wapuu-footer a:hover {
  color: var(--wp--preset--color--foreground);
}

.wapuu-footer__nav a {
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
}

.wapuu-footer__nav a:hover {
  color: var(--wp--preset--color--primary-light, var(--wp--preset--color--primary));
}

.wapuu-footer__credit a,
.wapuu-footer__legal a {
  color: var(--wapuu-muted-foreground, var(--wp--preset--color--muted-foreground));
}

.wapuu-footer__credit a:hover,
.wapuu-footer__legal a:hover {
  color: var(--wp--preset--color--foreground);
}

/* Site title link in footer inherits foreground */
.wapuu-footer .wp-block-site-title a {
  color: var(--wp--preset--color--foreground);
  text-decoration: none;
}

.wapuu-footer .wp-block-site-title a:hover {
  color: var(--wp--preset--color--primary-light, var(--wp--preset--color--primary));
}

/* Separator in footer */
.wapuu-footer .wp-block-separator {
  opacity: 0.5;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wapuu-animate,
  .wapuu-animate-stagger > * {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }

  .wapuu-credit-card,
  .wapuu-feature-card,
  .wapuu-event-card,
  .wapuu-crowdsource-card,
  .wapuu-app-badge-official,
  .wapuu-gallery-item img {
    transition: none !important;
  }
}
