/* Data Science Tutor — search modal + stats cards
 * Included on every page via <link rel="stylesheet" href="/assets/site.css">.
 */

/* === Search button (floating top-right, fixed position) === */
.search-fab {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.1s ease, color 0.1s ease, transform 0.1s ease;
}
.search-fab:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.search-fab-icon { font-size: 0.95rem; line-height: 1; }
.search-fab-label { font-weight: 500; }
.search-fab-kbd {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-left: 0.2rem;
}
@media (max-width: 600px) {
  .search-fab-label, .search-fab-kbd { display: none; }
  .search-fab { padding: 0.5rem 0.6rem; }
}

/* === Search modal === */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.search-modal.open {
  display: flex;
}
.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}
.search-panel {
  position: relative;
  width: min(620px, 92vw);
  max-height: 70vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.search-icon { font-size: 1.1rem; }
.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  color: var(--ink);
  font-family: inherit;
  outline: none;
}
.search-input-wrap input::placeholder { color: var(--ink-faint); }
.search-esc {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.75rem;
  color: var(--ink-faint);
}
.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem;
}
.search-hint {
  padding: 1.5rem 1rem;
  color: var(--ink-faint);
  font-style: italic;
  text-align: center;
}
.search-hint.search-error {
  color: var(--red);
  background: var(--red-soft);
  border-radius: 6px;
  margin: 0.4rem;
  padding: 1rem;
  font-style: normal;
}
.search-hint.search-error small {
  display: block;
  margin-top: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.search-result {
  display: block;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: none;
  transition: background 0.05s ease;
}
.search-result:hover, .search-result.active {
  background: var(--accent-soft);
}
.search-result-title {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
.search-result-desc {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-bottom: 0.2rem;
}
.search-result-url {
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-family: 'SF Mono', Menlo, monospace;
}
.search-footer {
  display: flex;
  gap: 1.2rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--ink-faint);
  background: var(--bg);
}
.search-footer kbd {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.72rem;
  margin-right: 0.2rem;
}
.search-stamp {
  margin-left: auto;
  color: var(--ink-faint);
  font-style: italic;
  opacity: 0.8;
}

/* === Stats cards === */
[data-stats] {
  margin: 2rem 0;
  padding: 1.4rem 1.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
[data-stats] h2:first-child, [data-stats] > h3 {
  font-family: 'Georgia', serif;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--ink);
}
[data-stats] h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.4rem 0 0.6rem;
  color: var(--ink);
}
[data-stats] h2:first-child + .stats-grid, .stats-section:first-of-type {
  margin-top: 0.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}
.stats-grid-compact { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem;
  text-align: center;
}
.stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  font-family: 'Georgia', serif;
  line-height: 1.1;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.3rem;
}

.stats-section {
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}
.stats-section h3 {
  margin-top: 0;
  padding-top: 0;
  border: none;
}
.stats-list {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
}
.stats-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--border);
  font-size: 0.92rem;
}
.stats-list li:last-child { border-bottom: none; }
.stats-list a {
  border-bottom: none;
  color: var(--accent);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stats-list a:hover { border-bottom: 1px solid var(--accent); }
.stats-meta {
  font-size: 0.78rem;
  color: var(--ink-faint);
  white-space: nowrap;
}
.stats-empty {
  color: var(--ink-faint);
  font-style: italic;
  text-align: center;
  margin: 1rem 0;
}
.stats-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
}
.stats-clear {
  text-align: right;
  margin: 1rem 0 0;
}
.stats-clear button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-faint);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  margin-left: 0.4rem;
}
.stats-clear button:hover {
  color: var(--red);
  border-color: var(--red);
}

/* Sync badges — show whether stats are server-synced or local-only */
[data-stats] h2:first-child {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.sync-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  vertical-align: middle;
}
.sync-server {
  background: #e7f4e4;
  color: #2e7d32;
  border: 1px solid #b6d9b1;
}
.sync-local {
  background: #fff4e0;
  color: #b45c00;
  border: 1px solid #f0c890;
}

@media (max-width: 600px) {
  .search-footer { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
