/* Reusable components: buttons, icons, avatars, cards, reviews, embed preview. */

/* ---------- Icons ---------- */

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-muted);
}

.icon-button:hover {
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.button--small {
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.button--primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.button--primary:hover {
  background: var(--color-accent-hover);
  color: var(--color-accent-contrast);
}

.button--secondary {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}

.button--secondary:hover {
  background: var(--color-surface-raised);
  color: var(--color-text);
}

/* ---------- Status pill ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-subtle);
}

.pill--positive .pill__dot {
  background: var(--brand-teal);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* ---------- Avatars ---------- */

.avatar {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: var(--avatar-size, 40px);
  height: var(--avatar-size, 40px);
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 700;
  font-size: calc(var(--avatar-size, 40px) * 0.4);
  line-height: 1;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--sm { --avatar-size: 30px; }
.avatar--lg { --avatar-size: 48px; }

/* ---------- Section heading ---------- */

.section {
  padding-block: var(--space-8) 0;
}

.section__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.section__header h2 {
  margin: 0;
  font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem);
}

.section__header p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.section__link {
  font-weight: 500;
}

/* ---------- Cards ---------- */

.card {
  height: 100%;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.card-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

.card-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

/* Bot card: the whole card is clickable via the title link's pseudo-element. */
.bot-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.bot-card:hover {
  border-color: var(--color-accent);
}

.bot-card:focus-within {
  border-color: var(--color-accent);
}

.bot-card__top {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bot-card__name {
  margin: 0;
}

.bot-card__link {
  color: var(--color-text);
  text-decoration: none;
}

.bot-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.bot-card__link:focus-visible {
  outline: none;
}

.bot-card:has(.bot-card__link:focus-visible) {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.bot-card__description {
  flex: 1;
  margin: 0;
  color: var(--color-text-muted);
}

.bot-card__past {
  margin: 0;
  color: var(--color-text-subtle);
  font-size: var(--text-xs);
  font-weight: 600;
}

.bot-card__owner {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-link);
}

/* ---------- Reviews ---------- */

.review {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
}

.review__rating {
  display: flex;
  gap: 2px;
  color: var(--color-star);
}

.review__rating-text {
  margin-right: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.review__rating .icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: none;
}

.review__rating .icon--empty {
  color: var(--color-border-strong);
}

.review__quote {
  flex: 1;
  margin: 0;
  line-height: 1.6;
}

.review__quote p {
  margin: 0;
}

.review__author {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

/* ---------- Discord-style embed preview ---------- */

.embed-preview {
  margin: 0;
}

.discord-message {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-embed-canvas);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--color-embed-text);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.discord-message__body {
  flex: 1;
  min-width: 0;
}

.discord-message__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.discord-message__name {
  font-weight: 600;
  color: var(--color-embed-name);
}

.discord-message__badge {
  padding: 1px 5px;
  border-radius: 4px;
  background: #5865f2; /* Discord's own APP badge colour, same in both themes */
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.discord-message__time {
  font-size: var(--text-xs);
  color: var(--color-embed-muted);
}

.embed {
  max-width: 440px;
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: var(--color-embed-card);
  border-left: 4px solid var(--embed-colour, var(--brand-teal));
  border-radius: 4px;
}

.embed__author {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-embed-name);
}

.embed__title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-embed-name);
  letter-spacing: 0;
}

.embed__description {
  margin: 0 0 var(--space-3);
}

.embed__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-3);
}

.embed__field {
  grid-column: 1 / -1;
}

.embed__field--inline {
  grid-column: auto;
}

.embed__field dt {
  font-weight: 600;
  color: var(--color-embed-name);
  margin-bottom: 2px;
}

.embed__field dd {
  margin: 0;
}

.embed__footer {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-embed-muted);
}

.discord-message__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.discord-button {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-embed-name);
  font-size: var(--text-xs);
  font-weight: 600;
}

.discord-button--primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.embed-preview__caption {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  text-align: center;
}

.notice {
  padding: var(--space-5);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  text-align: center;
}

.button--danger {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger-text);
}

.button--danger:hover {
  border-color: var(--color-danger-text);
  color: var(--color-danger-text);
}

.button--danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
