/* ==========================================================================
   Component Gallery — main stylesheet
   Presets: 8px base font-size scale, Inter font, light/dark themes.
   The gallery page styles live here. Submitted component previews are
   rendered inside isolated iframes so they never clash with these rules.
   ========================================================================== */

:root {
  --bg: #f7f8fc;
  --bg-alt: #ffffff;
  --card-bg: #ffffff;
  --text: #1f2430;
  --text-muted: #5c6474;
  --border: #e3e6ef;
  --primary: #6d5dfc;
  --primary-strong: #5a46f6;
  --primary-soft: rgba(109, 93, 252, 0.12);
  --accent: #22c1c3;
  --shadow: 0 10px 30px rgba(31, 36, 48, 0.08);
  --shadow-sm: 0 4px 14px rgba(31, 36, 48, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --header-gradient: linear-gradient(135deg, #6d5dfc 0%, #22c1c3 100%);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-alt: #181b24;
  --card-bg: #1b1f2a;
  --text: #eceef4;
  --text-muted: #9aa3b5;
  --border: #2a2f3d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

.container {
  width: min(1180px, 92%);
  margin: 0 auto;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.85em;
}

/* ===== Header / Nav ===== */
.site-header {
  background: var(--header-gradient);
  color: #fff;
  border-radius: 0 0 32px 32px;
  padding-bottom: 3.5rem;
  position: relative;
  overflow: hidden;
}

.site-header::before,
.site-header::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.site-header::before {
  width: 320px;
  height: 320px;
  top: -140px;
  right: -90px;
}

.site-header::after {
  width: 220px;
  height: 220px;
  bottom: -120px;
  left: -70px;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  position: relative;
  z-index: 1;
}

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}

.brand span {
  color: #ffe66d;
}

.brand:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 500;
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: #fff;
  text-decoration: none;
}

.theme-toggle {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  position: relative;
  z-index: 1;
  margin-top: 2rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.hero p {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.92);
  max-width: 640px;
  margin: 0 auto;
}

.hero .hero-sub {
  margin-top: 0.25rem;
  font-size: 0.98rem;
  color: rgba(255, 255, 255, 0.78);
}

.hero-actions {
  display: flex;
  gap: 0.9rem;
  justify-content: center;
  margin-top: 1.8rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  border: 2px solid transparent;
}

.btn:hover {
  transform: translateY(-2px);
  text-decoration: none;
}

.btn-primary {
  background: #fff;
  color: var(--primary-strong);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.btn-primary:hover {
  background: #f2f0ff;
}

.btn-outline {
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
}

.stats {
  display: flex;
  gap: 2.2rem;
  justify-content: center;
  margin-top: 2.4rem;
  flex-wrap: wrap;
}

.stats span {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}

.stats strong {
  font-size: 1.4rem;
  display: block;
  color: #fff;
  font-weight: 800;
}

/* ===== Filters ===== */
.filters {
  margin-top: -2.6rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.4rem;
  position: relative;
  z-index: 2;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.chip {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== Gallery ===== */
.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 3rem 0 1.5rem;
}

.section-title span {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  vertical-align: middle;
  margin-left: 0.4rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.6rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.preview {
  position: relative;
  height: 260px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.card-info {
  padding: 1rem 1.15rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.card-author {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.4rem;
}

.card-author a {
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.gallery-status {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 0;
  font-size: 0.95rem;
}

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

.empty-state p {
  margin-bottom: 0.4rem;
}

/* ===== Contribute ===== */
.contribute {
  margin-top: 3rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}

.step {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--header-gradient);
  color: #fff;
  font-weight: 800;
  margin-bottom: 0.7rem;
}

.step h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.step p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.contribute-cta {
  text-align: center;
  margin-top: 2rem;
}

.contribute-cta .btn-primary {
  background: var(--primary);
  color: #fff;
}

.contribute-cta .btn-primary:hover {
  background: var(--primary-strong);
}

/* ===== Footer ===== */
.site-footer {
  margin-top: 4rem;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
}

.site-footer p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-note {
  margin-top: 0.3rem;
  font-size: 0.82rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .stats {
    gap: 1.4rem;
  }
}