/* components.css — reusable components: pills, icon buttons, cards, modal, scroll FAB.
 * Owns: visual styling of self-contained UI building blocks.
 * Depends on: tokens.css.
 */

/* ----- Pill (used in quicklinks, profile-groups, sort/view toolbars) ----- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  min-height: 36px;
  cursor: pointer;
}
.pill:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}
.pill.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.pill.active:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ----- Icon button (header actions, card share row) ----- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  position: relative;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--bg-elev); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[hidden] { display: none; }
.icon-btn .copied-flash {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--text);
  color: var(--bg);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.icon-btn.flash .copied-flash { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ----- Card ----- */
article.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
article.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
article.card.featured {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg-card) 60%);
}

.card-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.card-emoji {
  font-size: 26px;
  line-height: 1;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-title-block {
  flex: 1;
  min-width: 0;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.card-title h3 {
  font-size: 15.5px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.005em;
  overflow-wrap: anywhere;
}
.featured-star {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.type-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-elev);
  padding: 3px 8px;
  border-radius: 999px;
  margin-top: 4px;
  letter-spacing: 0.01em;
}

.card-desc {
  font-size: 13.5px;
  color: var(--text);
  margin: 0;
  flex: 1;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.action-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 36px;
  transition: border-color 0.15s, background 0.15s;
}
.action-link:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  background: var(--bg-card);
}
.action-link.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.action-link.primary:hover {
  filter: brightness(0.95);
  background: var(--accent);
}
.action-link svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-share {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.card-share .icon-btn { width: 38px; height: 38px; }
.card-share .icon-btn svg { width: 16px; height: 16px; }
.card-share-label {
  font-size: 11px;
  color: var(--text-muted);
  align-self: center;
  margin-right: auto;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* ----- Profile group (inside profiles section) ----- */
.profile-group { margin-bottom: 14px; }
.profile-group:last-child { margin-bottom: 0; }
.profile-group-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 8px;
}
.profile-group .pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ----- QR modal ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.modal-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}
.modal-card .qr-wrap {
  background: #ffffff;
  padding: 10px;
  border-radius: 8px;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-card .qr-wrap img {
  width: 100%;
  height: 100%;
  display: block;
}
.modal-card .qr-url {
  font-size: 11.5px;
  color: var(--text-muted);
  word-break: break-all;
  text-align: center;
  max-width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.modal-card .modal-close {
  align-self: stretch;
  padding: 10px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.modal-card .modal-close:hover { border-color: var(--border-strong); }

/* ----- Scroll-to-bottom FAB ----- */
.scroll-bottom-btn {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  right: max(20px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.15s, background 0.15s;
}
.scroll-bottom-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-bottom-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev);
}
.scroll-bottom-btn:active { transform: scale(0.94); }
.scroll-bottom-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (min-width: 700px) {
  .scroll-bottom-btn {
    bottom: max(24px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
    width: 52px;
    height: 52px;
  }
  .scroll-bottom-btn svg { width: 24px; height: 24px; }
}

/* ----- Scroll-to-top FAB (mirror of scroll-bottom, top-right) ----- */
.scroll-top-btn {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.15s, background 0.15s;
}
.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.scroll-top-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev);
}
.scroll-top-btn:active { transform: scale(0.94); }
.scroll-top-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (min-width: 700px) {
  .scroll-top-btn {
    top: max(24px, env(safe-area-inset-top));
    right: max(24px, env(safe-area-inset-right));
    width: 52px;
    height: 52px;
  }
  .scroll-top-btn svg { width: 24px; height: 24px; }
}
