/* main.css - Layout, components, glassmorphism, responsive.
 * All colors come from the CSS variables defined in themes.css.
 */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 17.6px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--t-base) ease, color var(--t-base) ease;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

a {
  color: var(--neon-cyan);
  text-decoration: none;
  transition: color var(--t-fast) ease;
}
a:hover { color: var(--neon-magenta); }
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input { font-family: inherit; font-size: inherit; color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ----- Decorative background (blurred blobs) ----- */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.bg-decor .blob {
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.9;
}
.blob-1 { background: var(--blob-1); top: -120px; left: -100px; }
.blob-2 { background: var(--blob-2); top: 30%; right: -160px; }
.blob-3 { background: var(--blob-3); bottom: -180px; left: 30%; }

/* ----- Header ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--gap-md) var(--gap-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-md);
}
.brand-title {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}
.brand-subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-sm);
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-xs);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  transition: background var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) ease;
}
.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-1px);
}
.theme-toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.theme-toggle-label { font-size: 0.85rem; color: var(--text-secondary); }
.theme-toggle-icon { font-size: 1rem; }

/* ----- Tabs nav ----- */
.tabs-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}
/* The header is sticky, place the tabs just below */
.site-header { z-index: 30; }
.tabs-nav { top: 64px; }
@media (max-width: 480px) { .tabs-nav { top: 56px; } }

.tabs-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--gap-lg);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-inner::-webkit-scrollbar { display: none; }

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--t-fast) ease, border-color var(--t-fast) ease, background var(--t-fast) ease;
}
.tab-button:hover { color: var(--text-primary); background: var(--bg-card-hover); }
.tab-button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tab-button.is-active {
  color: var(--text-primary);
  border-bottom-color: transparent;
  background: linear-gradient(to top, rgba(34,211,238,0.15), transparent 70%);
  position: relative;
}
.tab-button.is-active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--gradient-accent);
}
.tab-emoji { font-size: 1rem; }

/* ----- Main layout (single column) ----- */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
  min-width: 0;
}

.tab-panel { display: flex; flex-direction: column; gap: var(--gap-lg); }
.tab-panel[hidden] { display: none; }

/* ----- Glassmorphism helper ----- */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat));
  -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ----- Bio ----- */
.bio {
  padding: var(--gap-lg);
  display: flex;
  gap: var(--gap-md);
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}
.bio::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-accent);
  opacity: 0.06;
  pointer-events: none;
}
.bio-avatar {
  font-size: 2.4rem;
  width: 64px; height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.bio-body { display: flex; flex-direction: column; gap: 6px; position: relative; }
.bio-tagline {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.bio-text { margin: 0; color: var(--text-secondary); white-space: pre-line; }
.bio-links { margin: 4px 0 0; font-size: 0.85rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px; }
.bio-sep { color: var(--text-muted); }

/* ----- Search ----- */
.search-section {
  padding: var(--gap-md) var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}
.search-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--border-accent);
  box-shadow: var(--focus-ring);
}
.counter {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ----- Filter chips ----- */
.filters-section {
  padding: var(--gap-md) var(--gap-lg);
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}
.filter-title {
  margin: 0 0 var(--gap-xs);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.filter-block[hidden] { display: none; }

.chip-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-button {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) ease;
}
/* The background (including the gradient when active) is carried by a
   pseudo-element with the same border-radius. This removes the artefacts
   (blue or pink edges) that appear with a mask + border on the main element. */
.chip-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--bg-chip);
  z-index: -1;
  transition: background var(--t-fast) ease;
}
.chip-button:hover { color: var(--text-primary); border-color: var(--border-accent); transform: translateY(-1px); }
.chip-button:hover::before { background: var(--bg-card-hover); }
.chip-button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chip-button.is-active {
  color: var(--text-inverse);
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(168, 139, 250, 0.35);
}
.chip-button.is-active::before { background: var(--gradient-accent); }
.chip-button-count {
  font-size: 0.72rem;
  background: rgba(0,0,0,0.18);
  color: inherit;
  padding: 1px 7px;
  border-radius: 999px;
}

/* ----- Section title ----- */
.section-title {
  margin: 0 0 var(--gap-md);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* ----- Cards grid ----- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--gap-md);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  padding: var(--gap-md);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat));
  -webkit-backdrop-filter: blur(var(--backdrop-blur)) saturate(var(--backdrop-sat));
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
  transition: transform var(--t-base) ease, border-color var(--t-base) ease, box-shadow var(--t-base) ease, background var(--t-base) ease;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--gradient-accent);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--t-base) ease;
  pointer-events: none;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card-hover);
  outline: none;
}
.card:hover::before, .card:focus-visible::before { opacity: 1; }

.card-head { display: flex; align-items: center; gap: var(--gap-sm); }
.card-emoji {
  font-size: 1.8rem;
  line-height: 1;
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-chip);
  flex-shrink: 0;
}
.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  word-break: break-word;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.card-pin {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 1.1rem;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}
.card.is-featured {
  border-color: rgba(34, 211, 238, 0.35);
}
.card-host {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.card-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}
.chip {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-chip);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.chip.is-archive {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  border-style: dashed;
}
/* Circular yellow "Archived" badge displayed next to the subcategory.
   The badge reuses the exact same box model as `.chip` (inline-block,
   same padding, same font-size, default line-height) so it sits on the
   exact same baseline as the category and subcategory chips in
   `.card-badges`. We only change the colors and force the shape into a
   circle via `min-width` + full radius. The yellow ring is rendered
   through the border + a soft outer shadow. */
.card-archive-badge {
  display: inline-block;
  box-sizing: border-box;
  min-width: 22px;
  height: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--archive-badge-bg);
  color: var(--archive-badge-fg);
  border: 1px solid var(--archive-badge-border);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.15);
}
/* ----- Language switcher ----- */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
}
.lang-button {
  /* Same trick as .chip-button: the gradient background of the active
     state is carried by a ::before pseudo-element with the same border-
     radius. Drawing the gradient directly on the main element leaks the
     raw background color between the gradient and the rounded corners,
     which is visible as a faint blue/pink edge against the switcher. */
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  transition: color var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-fast) ease;
}
.lang-button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  z-index: -1;
  transition: background var(--t-fast) ease;
}
.lang-button:hover {
  color: var(--text-primary);
  border-color: var(--border-subtle);
  transform: translateY(-1px);
}
.lang-button:hover::before { background: var(--bg-card-hover); }
.lang-button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.lang-button.is-active {
  color: var(--text-inverse);
  border-color: transparent;
  font-weight: 700;
}
.lang-button.is-active::before { background: var(--gradient-accent); }
.chip.is-category {
  background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(168,139,250,0.18));
  border-color: rgba(34, 211, 238, 0.35);
  color: var(--text-primary);
  font-weight: 500;
}
.chip.is-subcategory {
  background: rgba(236, 72, 153, 0.12);
  border-color: rgba(236, 72, 153, 0.35);
  color: var(--text-primary);
  font-weight: 500;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--gap-sm);
}

.card.is-archived {
  opacity: 0.55;
  filter: grayscale(0.4);
}
.card.is-archived:hover { opacity: 0.85; filter: grayscale(0.1); }
/* Keep the yellow archive badge vivid even when its card is greyed out. */
.card.is-archived .card-archive-badge { filter: none; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .card.is-archived,
  .card.is-archived:hover { transition: none; }
}

/* ----- Empty state ----- */
.empty-state {
  padding: var(--gap-xl) var(--gap-md);
  text-align: center;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
}
.empty-state[hidden] { display: none; }
.empty-state p { margin: 0 0 var(--gap-md); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--gradient-accent);
  color: var(--text-inverse);
  box-shadow: 0 8px 22px rgba(168, 139, 250, 0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(232, 121, 249, 0.45); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--focus-ring), 0 8px 22px rgba(168, 139, 250, 0.35); }

/* ----- Markdown content ----- */
.markdown {
  padding: var(--gap-lg);
  line-height: 1.7;
  color: var(--text-primary);
}
.markdown h1, .markdown h2, .markdown h3, .markdown h4 {
  margin-top: 1.4em;
  margin-bottom: 0.5em;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.markdown h1 { font-size: 1.8rem; margin-top: 0; background: var(--gradient-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.markdown h2 { font-size: 1.3rem; padding-bottom: 6px; border-bottom: 1px solid var(--border-subtle); }
.markdown h3 { font-size: 1.1rem; }
.markdown p { margin: 0.8em 0; color: var(--text-secondary); }
.markdown a { color: var(--neon-cyan); }
.markdown a:hover { color: var(--neon-magenta); }
.markdown ul, .markdown ol { padding-left: 1.4em; color: var(--text-secondary); }
.markdown li { margin: 0.3em 0; }
.markdown blockquote {
  margin: 1em 0;
  padding: 8px 16px;
  border-left: 3px solid var(--neon-purple);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
}
.markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 6px;
  background: var(--bg-chip);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}
.markdown pre {
  margin: 1em 0;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
}
.markdown pre code {
  background: transparent;
  border: none;
  padding: 0;
}
.markdown input[type="checkbox"] {
  accent-color: var(--neon-cyan);
  margin-right: 6px;
}
.markdown hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 1.5em 0;
}

/* ----- Footer ----- */
.site-footer {
  margin-top: var(--gap-lg);
  padding-top: var(--gap-lg);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* ----- Responsive ----- */
@media (max-width: 600px) {
  .header-inner { padding: var(--gap-md); }
  .theme-toggle-label { display: none; }
  .main { padding: var(--gap-md); gap: var(--gap-md); }
  .bio { flex-direction: column; }
  .cards-grid { grid-template-columns: 1fr; }
}

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
  .bg-decor .blob { filter: blur(40px); }
}
