/* =========================================================
   ChrysoKit, Enhancements (additive only)
   Styles for: theme toggle, favorite stars, view toggle,
   category filter chips, stats bar, back-to-top,
   recent tools section, social icons, skip link.
   Does not override any existing rules.
   ========================================================= */

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  background: var(--primary);
  color: var(--white);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow-md);
}
.skip-link:focus {
  left: 16px;
  color: var(--white);
}

/* ---------- Header icon buttons ---------- */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background var(--t), border-color var(--t), color var(--t);
}
.icon-btn:hover {
  background: var(--secondary-bg);
  border-color: var(--border-warm);
  color: var(--primary-darker);
}
.icon-btn svg { width: 18px; height: 18px; }

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

/* ---------- Favorite star ---------- */
.tool-card .fav-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-subtle);
  border-radius: 50%;
  z-index: 2;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.tool-card .fav-btn:hover {
  background: var(--secondary-bg);
  color: var(--warning);
  transform: scale(1.1);
}
.tool-card .fav-btn svg { width: 18px; height: 18px; }
.tool-card .fav-btn.is-fav {
  color: var(--warning);
}
.tool-card .fav-btn.is-fav svg {
  fill: var(--warning);
  stroke: var(--warning);
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  justify-content: center;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--page-bg);
  border: 1px solid var(--border-warm);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--t), color var(--t), border-color var(--t);
  cursor: pointer;
  white-space: nowrap;
}
.filter-chip:hover {
  border-color: var(--primary);
  color: var(--text);
}
.filter-chip.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}
.filter-chip svg { width: 14px; height: 14px; }

html[data-theme="dark"] .filter-chip.active { color: var(--page-bg); }

/* ---------- Stats bar ---------- */
.stats-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 0 4px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.stats-bar .count {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- View toggle ---------- */
.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--page-bg);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius);
  padding: 3px;
}
.view-toggle .view-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background var(--t), color var(--t);
}
.view-toggle .view-btn:hover { color: var(--text); }
.view-toggle .view-btn.active {
  background: var(--white);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.view-toggle .view-btn svg { width: 16px; height: 16px; }

/* ---------- List view for tool grid ---------- */
.tool-grid.view-list {
  grid-template-columns: 1fr;
  gap: 10px;
}
.tool-grid.view-list .tool-card {
  flex-direction: row;
  align-items: center;
  padding: 16px 20px;
  gap: 18px;
}
.tool-grid.view-list .tool-card .icon-wrap {
  flex: 0 0 44px;
}
.tool-grid.view-list .tool-card h3 {
  margin: 0;
}
.tool-grid.view-list .tool-card p {
  flex: 1;
  margin: 0;
}
.tool-grid.view-list .tool-card .btn {
  align-self: center;
  flex-shrink: 0;
}
.tool-grid.view-list .tool-card .fav-btn {
  position: static;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .tool-grid.view-list .tool-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .tool-grid.view-list .tool-card .fav-btn {
    position: absolute;
    top: 14px;
    right: 14px;
  }
}

/* ---------- Recent tools section ---------- */
.recent-section {
  padding: 20px 0 40px;
}
.recent-section .section-header { margin-bottom: 22px; text-align: left; }
.recent-section .section-header h2 {
  font-size: 1.35rem;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.recent-section .section-header h2 svg {
  width: 20px; height: 20px;
  color: var(--primary-darker);
}
.recent-section .clear-recent {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: auto;
}
.recent-section .recent-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: var(--white);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--t), transform var(--t), background var(--t);
  z-index: 60;
}
.back-to-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover { background: var(--primary-dark); }
.back-to-top svg { width: 20px; height: 20px; }
html[data-theme="dark"] .back-to-top { color: var(--page-bg); }

/* ---------- Social icons ---------- */
.social-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.social-links a {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: background var(--t), color var(--t);
}
.social-links a:hover {
  color: var(--primary-darker);
  background: rgba(212, 163, 115, 0.1);
}
.social-links a svg { width: 18px; height: 18px; }

/* ---------- Favorites-only active state ---------- */
.favorites-toggle.active {
  background: var(--warning);
  color: var(--white);
  border-color: var(--warning);
}
html[data-theme="dark"] .favorites-toggle.active { color: var(--page-bg); }

/* ---------- Under construction banner ---------- */
.coming-soon {
  text-align: center;
  padding: 48px 28px;
  background: var(--secondary-bg);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-lg);
  margin: 28px auto;
  max-width: 640px;
}
.coming-soon .cs-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: var(--white);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-darker);
  box-shadow: var(--shadow-sm);
}
.coming-soon .cs-icon svg { width: 26px; height: 26px; }
.coming-soon h2 { margin-bottom: 10px; }
.coming-soon p { color: var(--text-muted); margin-bottom: 18px; }

/* ---------- Mobile header adjustments ---------- */
@media (max-width: 768px) {
  .header-actions {
    margin-left: auto;
    margin-right: 8px;
  }
  .filter-bar {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }
  .filter-chips { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .view-toggle { align-self: flex-end; }
}


/* =========================================================
   AdSense - professional ad zone (placeholder when empty,
   transparent wrapper when filled)
   ========================================================= */
.ad-zone {
  margin: 36px auto;
  width: 100%;
  text-align: center;
}
.ad-zone__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-subtle);
  margin: 0 0 8px;
  font-weight: 500;
}
.ad-zone__inner {
  position: relative;
  overflow: hidden;
  background: var(--white);
  border: 1px dashed var(--border-warm);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0 auto;
}
.ad-zone__inner::before {
  content: 'Ad space';
  color: var(--text-subtle);
  font-size: 0.78rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  position: absolute;
  z-index: 0;
  pointer-events: none;
}
/* Hide placeholder once AdSense actually fills */
.ad-zone__inner:has(.adsbygoogle[data-ad-status="filled"])::before,
.ad-zone__inner:has(iframe)::before {
  content: '';
  display: none;
}
.ad-zone--leaderboard .ad-zone__inner { max-width: 728px; min-height: 90px; }
.ad-zone--rectangle  .ad-zone__inner { max-width: 336px; min-height: 280px; }
.ad-zone--responsive .ad-zone__inner { max-width: 100%; min-height: 100px; }
.adsbygoogle {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: inherit;
}

/* Inline kbd styling */
kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--border-warm);
  border-radius: 4px;
  background: var(--page-bg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  vertical-align: baseline;
}
