/* ==========================================================================
   Site Discovery Engine — main styles
   ========================================================================== */

:root {
  --bg-page: #0c0e10;
  --bg-page-subtle: radial-gradient(ellipse 100% 80% at 50% -20%, rgba(26, 35, 50, 0.35), transparent 50%), #0c0e10;
  --bg-card: #161a1e;
  --bg-elevated: #1c2025;
  --border: #2a2e33;
  --text: #eef0f2;
  --text-muted: #9aa0a6;
  --accent: #5aa3ff;
  --accent-hover: #7ab5ff;
  --success: #34a853;
  --danger: #ea4335;
  --radius: 10px;
  --radius-sm: 8px;
  --space: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-page-subtle);
  background-attachment: fixed;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.page-main {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* ==========================================================================
   Cards (sections)
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(90, 163, 255, 0.15);
}

.card__title {
  margin: 0 0 var(--space);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.card__subtitle {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card__lead {
  margin: 0 0 var(--space-lg);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(90, 163, 255, 0.25);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(90, 163, 255, 0.3);
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.btn--secondary:hover:not(:disabled) {
  background: rgba(90, 163, 255, 0.08);
  border-color: rgba(90, 163, 255, 0.3);
  color: var(--accent);
}

.btn--link {
  background: none;
  color: var(--accent);
  padding-left: 0;
  padding-right: 0;
}

.btn--link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Hero (ML resources)
   ========================================================================== */

.hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  max-width: 42rem;
  box-shadow: var(--shadow-card);
}

.hero__title {
  margin: 0 0 var(--space);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.hero__title a {
  color: var(--text);
  text-decoration: none;
}

.hero__title a:hover {
  color: var(--accent);
}

.hero ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.hero ul li {
  margin-bottom: 0.25rem;
}

.hero a {
  color: var(--accent);
}

.hero a:hover {
  text-decoration: underline;
}

.hero__footer {
  margin: var(--space) 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.hero__footer a {
  font-weight: 500;
}

/* ==========================================================================
   Search
   ========================================================================== */

.search-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: var(--space-lg);
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 1rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(90, 163, 255, 0.2);
}

/* ==========================================================================
   Quick links grid
   ========================================================================== */

.quick-links {
  margin-bottom: 0;
}

.quick-links-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-link {
  padding: 0.5rem 0.875rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.quick-link:hover {
  background: rgba(90, 163, 255, 0.08);
  border-color: rgba(90, 163, 255, 0.25);
  color: var(--accent);
}

/* ==========================================================================
   Discovery section
   ========================================================================== */

.discovery-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--space);
}

.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin: var(--space) 0;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.stats {
  display: flex;
  justify-content: flex-start;
  gap: var(--space-xl);
  padding: var(--space);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  margin-top: var(--space);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   Content area: loading, error, articles
   ========================================================================== */

.loading {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.error {
  padding: var(--space);
  color: var(--danger);
  font-size: 0.9375rem;
  border-radius: var(--radius-sm);
  background: rgba(234, 67, 53, 0.1);
}

.trending-topics {
  margin-bottom: var(--space-xl);
}

.topics-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.topic-item {
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.topic-item:hover {
  background: var(--border);
}

.articles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space);
  margin-bottom: var(--space-xl);
}

.article {
  padding: var(--space-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.article:hover {
  border-color: rgba(90, 163, 255, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.article h3 {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.article a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9375rem;
}

.article a:hover {
  text-decoration: underline;
}

.source {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* Status indicators */
.status-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.status-online {
  background: var(--success);
}

.status-offline {
  background: var(--danger);
}

.status-checking {
  background: #f9ab00;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================================================
   About section
   ========================================================================== */

.about-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
}

.about-section .card__title {
  margin-bottom: 0.5rem;
}

.about-section p {
  margin: 0 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.about-section a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.about-section a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Utilities
   ========================================================================== */

.u-hidden {
  display: none !important;
}

.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Legacy class compatibility (JS / dynamic content) */
.discovery-button {
  /* Same as .btn.btn--secondary; class kept for JS querySelectorAll */
}
