/* ============================================
   space.com.tw — CSS Variables & Reset
   ============================================ */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --border-hover: #6366f1;
  --accent: #6366f1;
  --accent-light: #eef2ff;
  --accent-dark: #4f46e5;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --coming-soon-bg: #fef3c7;
  --coming-soon-text: #92400e;
  --coming-soon-border: #fcd34d;
  --active-badge-bg: #dcfce7;
  --active-badge-text: #166534;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --border-hover: #818cf8;
  --accent: #818cf8;
  --accent-light: #1e1b4b;
  --accent-dark: #a5b4fc;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -2px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -4px rgba(0,0,0,0.4);
  --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.6), 0 8px 10px -6px rgba(0,0,0,0.5);
  --coming-soon-bg: #451a03;
  --coming-soon-text: #fcd34d;
  --coming-soon-border: #92400e;
  --active-badge-bg: #052e16;
  --active-badge-text: #86efac;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ============================================
   Header
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
  transition: background var(--transition), border-color var(--transition);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
}

.logo-icon svg {
  width: 100%;
  height: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================
   Theme Toggle
   ============================================ */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--accent);
  background: var(--accent-light);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun  { display: block; }

[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }

/* ============================================
   Hero Section
   ============================================ */
.hero {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 64px 24px 56px;
  text-align: center;
  transition: background var(--transition), border-color var(--transition);
}

.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  transition: color var(--transition);
}

/* ============================================
   Search Box
   ============================================ */
.search-wrapper {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.search-input {
  width: 100%;
  padding: 14px 48px 14px 48px;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 15%, transparent);
  background: var(--bg-primary);
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.search-clear.visible {
  display: flex;
}

.search-clear:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.search-clear svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   Category Filter
   ============================================ */
.category-filter {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 0;
}

.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.category-btn {
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: 100px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.category-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.category-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

/* ============================================
   Main Content
   ============================================ */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  width: 100%;
}

.results-info {
  margin-bottom: 24px;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================
   Cards Grid
   ============================================ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* ============================================
   Service Card
   ============================================ */
.service-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}

.service-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  opacity: 0;
  transition: opacity var(--transition);
}

.service-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.service-card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}

.card-icon svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  transition: color var(--transition);
}

.card-description {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
  transition: color var(--transition);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-url {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
  transition: color var(--transition);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-active {
  background: var(--active-badge-bg);
  color: var(--active-badge-text);
}

.badge-coming-soon {
  background: var(--coming-soon-bg);
  color: var(--coming-soon-text);
  border: 1px solid var(--coming-soon-border);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active .badge-dot {
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin: 0 auto 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  padding: 32px 24px;
  text-align: center;
  transition: background var(--transition), border-color var(--transition);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

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

.footer-text a {
  color: var(--accent);
  font-weight: 600;
}

.footer-text a:hover {
  text-decoration: underline;
}

/* ============================================
   Responsive — Tablet
   ============================================ */
@media (max-width: 900px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   Responsive — Mobile
   ============================================ */
@media (max-width: 600px) {
  .header-inner {
    padding: 0 16px;
    height: 56px;
  }

  .logo span {
    display: none;
  }

  .hero {
    padding: 40px 16px 32px;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .category-filter {
    padding: 24px 16px 0;
  }

  main {
    padding: 24px 16px 48px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .service-card {
    padding: 20px;
  }

  .card-url {
    max-width: 55%;
  }
}
