/**
 * SwiftPress Components CSS
 * Buttons, Forms, Cards, Widgets, Post Cards
 *
 * Performance: Component styles are loaded after critical CSS.
 * All interactive states use CSS transitions, never JS.
 */

/* ─── Buttons ────────────────────────────────────────────────────── */
.sp-btn,
.wp-block-button__link,
button[type="submit"],
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform 75ms ease;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
}

.sp-btn:active { transform: scale(0.98); }

/* Primary */
.sp-btn,
.sp-btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.sp-btn:hover,
.sp-btn--primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Secondary / Ghost */
.sp-btn--secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.sp-btn--secondary:hover {
  background: var(--color-primary-light);
}

/* Ghost */
.sp-btn--ghost {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.sp-btn--ghost:hover {
  background: var(--color-bg-alt);
}

/* Sizes */
.sp-btn--sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }
.sp-btn--lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); }

/* ─── Forms ──────────────────────────────────────────────────────── */
.sp-form-group {
  margin-bottom: var(--space-5);
}

.sp-form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.sp-form-control,
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.sp-form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(26 110 245 / 0.15);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* Search Form */
.sp-search-form {
  display: flex;
  gap: var(--space-2);
}

.sp-search-form input[type="search"] {
  flex: 1;
}

/* Comment Form */
.comment-form p { margin-bottom: var(--space-4); }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
}

/* ─── Post Card ──────────────────────────────────────────────────── */
.sp-post-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.sp-post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sp-post-card__thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

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

.sp-post-card:hover .sp-post-card__thumb img {
  transform: scale(1.03);
}

.sp-post-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  gap: var(--space-3);
}

.sp-post-card__category {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  text-decoration: none;
}

.sp-post-card__title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  line-height: var(--leading-snug);
  margin: 0;
}

.sp-post-card__title a {
  color: var(--color-text);
  text-decoration: none;
}

.sp-post-card__title a:hover { color: var(--color-primary); }

.sp-post-card__excerpt {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  /* Truncate long excerpts */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sp-post-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: var(--border-width) solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ─── Sidebar Widgets ────────────────────────────────────────────── */
.sp-sidebar .widget {
  padding: var(--space-6);
  background: var(--color-bg-alt);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}

.sp-sidebar .widget-title {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-width) solid var(--color-border);
}

.sp-sidebar .widget ul {
  list-style: none;
  padding: 0;
}

.sp-sidebar .widget ul li {
  padding: var(--space-2) 0;
  border-bottom: var(--border-width) solid var(--color-border);
  font-size: var(--text-sm);
}

.sp-sidebar .widget ul li:last-child { border-bottom: none; }

/* ─── Breadcrumbs ────────────────────────────────────────────────── */
.sp-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.sp-breadcrumbs a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.sp-breadcrumbs a:hover { color: var(--color-primary); }

.sp-breadcrumbs-sep::before {
  content: '/';
}

/* ─── Category / Tag Labels ──────────────────────────────────────── */
.sp-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.7em;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.sp-badge:hover {
  background: var(--color-primary);
  color: #fff;
}
