/**
 * REUSABLE COMPONENTS
 * 
 * Common UI components used throughout the site: buttons, cards, tags,
 * badges, and other reusable elements.
 */

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  /* Minimum touch target size */
  min-height: 44px;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Primary button - Wisconsin red */
.btn-primary {
  background-color: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

/* Secondary button - outlined */
.btn-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-primary);
}

.btn-secondary:hover {
  border-color: var(--accent-soft);
  color: var(--accent-soft);
  text-decoration: none;
}

/* Ghost button - minimal */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
}

/* Small button */
.btn-sm {
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  min-height: 36px;
}

/* Large button */
.btn-lg {
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
  min-height: 52px;
}

/* ===== PROJECT CARDS ===== */

.project-grid {
  display: grid;
  gap: var(--space-xl);
  /* Mobile: 1 column */
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .project-grid {
    /* Tablet: 2 columns */
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .project-grid {
    /* Desktop: 3 columns */
    grid-template-columns: repeat(3, 1fr);
  }
}

.project-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-muted);
}

.project-card:focus-within {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.project-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background-color: var(--bg-tertiary);
  /* Placeholder background for missing images */
  background-image: linear-gradient(135deg, var(--bg-tertiary) 25%, transparent 25%),
                    linear-gradient(225deg, var(--bg-tertiary) 25%, transparent 25%),
                    linear-gradient(45deg, var(--bg-tertiary) 25%, transparent 25%),
                    linear-gradient(315deg, var(--bg-tertiary) 25%, var(--bg-secondary) 25%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 0, 10px -10px, 0 10px;
}

.project-card-content {
  padding: var(--space-lg);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.project-card-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.project-card-description {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  margin-bottom: var(--space-md);
  flex-grow: 1;
  /* Limit to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.project-card-date {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.project-card-category {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: auto;
}

/* ===== TAGS ===== */

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  background-color: var(--accent-muted);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tag-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* ===== BADGES ===== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
}

.badge-accent {
  background-color: var(--accent-muted);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* ===== SECTION HEADER ===== */

.section-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.section-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.section-subtitle {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ===== LOADING STATE ===== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-primary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ===== PAGE FADE-IN ANIMATIONS ===== */

/* Hide content initially to prevent FOUC (Flash of Unstyled Content) */
.fade-in-content {
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
}

/* Show content with fade-in effect */
.fade-in-content.loaded {
  opacity: 1;
}

/* Individual element staggered fade-in */
.fade-in-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.fade-in-item.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delays for sequential fade-in */
.fade-in-item:nth-child(1) { transition-delay: 0.1s; }
.fade-in-item:nth-child(2) { transition-delay: 0.2s; }
.fade-in-item:nth-child(3) { transition-delay: 0.3s; }
.fade-in-item:nth-child(4) { transition-delay: 0.4s; }
.fade-in-item:nth-child(5) { transition-delay: 0.5s; }
.fade-in-item:nth-child(6) { transition-delay: 0.6s; }

/* ===== EMPTY STATE ===== */

.empty-state {
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-lg);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--font-size-2xl);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.empty-state-description {
  font-size: var(--font-size-base);
  color: var(--text-muted);
}

/* ===== HERO SECTION ===== */

.hero {
  /* Removed top padding to match About page spacing */
  padding-bottom: var(--space-4xl);
  text-align: center;
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.hero-title {
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.hero-subtitle {
  font-size: var(--font-size-2xl);
  color: var(--accent-soft);
  margin-bottom: var(--space-lg);
}

.hero-description {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-2xl);
  max-width: var(--max-width-text);
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== PAGE HEADER (for category gallery pages) ===== */
/*
  Used on project gallery pages (homelab, ML, hardware, 3D).
  Provides proper spacing below fixed header and styles title/description.
*/

.page-header {
  padding: var(--space-3xl) var(--space-lg) var(--space-2xl);
  text-align: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
}

.page-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.page-description {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
}

@media (min-width: 768px) {
  .page-header {
    padding: var(--space-4xl) var(--space-xl) var(--space-3xl);
  }
  
  .page-title {
    font-size: var(--font-size-4xl);
  }
}

/* ===== PROFILE PHOTO ===== */

.profile-photo {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--border-primary);
  margin: 0 auto var(--space-xl);
}

@media (min-width: 768px) {
  .profile-photo {
    width: 200px;
    height: 200px;
  }
}

/* ===== LINK WITH ICON ===== */

.link-with-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--link-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.link-with-icon:hover {
  color: var(--accent-soft);
}

.link-with-icon svg {
  width: 16px;
  height: 16px;
}

/* ===== FOOTER ===== */

.site-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-primary);
  padding: var(--space-2xl) 0;
  margin-top: var(--space-4xl);
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  text-align: center;
}

.footer-social {
  display: flex;
  gap: var(--space-md);
}

.footer-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.footer-social-link:hover {
  color: var(--accent-soft);
}

.footer-social-link svg {
  width: 20px;
  height: 20px;
}

.footer-text {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
  }
}
