/* Buttons, fields, dialogs, menus, tabs and other shared pieces. */

.card { border-radius: 1rem; border: 1px solid var(--line); background: var(--surface); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */

/* Medium by default (the same as .btn-md), so a button without a size class still looks
   like a button. .btn-sm and .btn-lg override it. */
.btn {
  display: inline-flex;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
  font-size: 0.9375rem;
  border-radius: 9999px;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn[aria-busy='true'] > .btn-icon { display: none; }

.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover:not(:disabled) { background: color-mix(in oklab, var(--ink) 85%, transparent); }
.btn-primary:active:not(:disabled) { background: color-mix(in oklab, var(--ink) 75%, transparent); }

.btn-secondary { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-secondary:active:not(:disabled) { background: var(--surface-3); }

.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn-ghost:active:not(:disabled) { background: var(--surface-3); }

.btn-quiet { background: var(--surface-2); color: var(--ink); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); }

.btn-danger { background: var(--danger-fill); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.9; }

.btn-sm { height: 2rem; padding: 0 0.75rem; font-size: 0.875rem; }
.btn-md { height: 2.5rem; padding: 0 1rem; font-size: 0.9375rem; }
.btn-lg { height: 3rem; padding: 0 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.mt { margin-top: 0.25rem; }

.icon-btn {
  display: inline-flex;
  height: 2.5rem;
  width: 2.5rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  color: var(--ink-2);
  transition: color 0.15s, background-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn:disabled { opacity: 0.5; }
.icon-btn.is-active { background: var(--surface-2); color: var(--ink); }
.icon-btn-sm { height: 2rem; width: 2rem; }

.chip {
  border-radius: 9999px;
  background: var(--surface-2);
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-2);
}

/* ─── Avatar ─────────────────────────────────────────────────────────────── */

.avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.025em;
  user-select: none;
  /* Low chroma on purpose: avatars must never read as data colors. */
  background: oklch(var(--avatar-bg-l) 0.03 var(--avatar-hue));
  color: oklch(var(--avatar-fg-l) var(--avatar-fg-c) var(--avatar-hue));
}
.avatar-sm { height: 2rem; width: 2rem; font-size: 0.75rem; }
.avatar-md { height: 2.5rem; width: 2.5rem; font-size: 0.875rem; }
.avatar-lg { height: 4rem; width: 4rem; font-size: 1.25rem; }
.avatar-xl { height: 5rem; width: 5rem; font-size: 1.5rem; }
.avatar-2xl { height: 7rem; width: 7rem; font-size: 2.25rem; }
/* A profile picture: filling its circle, with a hairline so a white one keeps its edge. */
img.avatar {
  object-fit: cover;
  background-color: var(--surface-2);
  outline: 1px solid color-mix(in oklab, var(--ink) 8%, transparent);
  outline-offset: -1px;
}

/* ─── Pro badge (site/icons.rs `pro_badge`, shared/icons.js `proBadge`) ──── */

/* After a Pro account's name, before its flags: the logo's curve on a warm tile, as tall as
   the name's letters (14–16 px), sitting on the text's middle. */
.pro-badge {
  flex: none;
  display: inline-block;
  width: clamp(14px, 1em, 16px);
  height: clamp(14px, 1em, 16px);
  margin-left: 0.3em;
  vertical-align: -0.15em;
  align-self: center;
}
.pro-badge-tile { fill: var(--pro); }
.pro-badge-curve { stroke: var(--pro-ink); }
/* A profile's heading: the badge a size up. */
.profile-name .pro-badge { width: 20px; height: 20px; vertical-align: -0.1em; }
/* Leading a menu item or a button ("Pro"), where icons sit: no gap of its own. */
.menu-item .pro-badge, .btn .pro-badge { margin: 0; }

/* ─── Profile card on hover (components/hovercard.js) ───────────────────── */

.hovercard {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 55;
  width: 18rem;
  max-width: calc(100vw - 1rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.18), 0 2px 6px rgb(0 0 0 / 0.08);
  opacity: 0;
  transition: opacity 0.12s;
}
.hovercard.is-in { opacity: 1; }
.hovercard[hidden] { display: none; }
.hovercard-cover { height: 4.5rem; background: var(--surface-2); }
.hovercard-cover img { width: 100%; height: 100%; object-fit: cover; }
.hovercard-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem; margin-top: -2rem; padding: 0 1rem; }
.hovercard-face { display: inline-flex; border-radius: 9999px; }
.hovercard-face .avatar { box-shadow: 0 0 0 3px var(--surface); }
.hovercard-follow { margin-bottom: 0.125rem; }
.hovercard-name { display: block; padding: 0.5rem 1rem 0; font-size: 1rem; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; unicode-bidi: isolate; }
.hovercard-name:hover { text-decoration: underline; }
.hovercard-flags { margin-left: 0.375rem; font-weight: 400; }
.hovercard-handle { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0 1rem; font-size: 0.875rem; color: var(--muted); }
.hovercard-bio {
  display: -webkit-box;
  overflow: hidden;
  padding: 0.5rem 1rem 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink-2);
  white-space: pre-line;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.hovercard-counts { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; padding: 0.625rem 1rem 0.875rem; font-size: 0.875rem; color: var(--muted); }
.hovercard-counts a:hover { color: var(--ink); text-decoration: underline; }
.hovercard-counts strong { font-weight: 600; color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .hovercard { transition: none; } }

/* ─── Cropper (components/cropper.js) ────────────────────────────────────── */

.cropper { width: min(26rem, calc(100vw - 1.5rem)); }
.cropper-cover { width: min(44rem, calc(100vw - 1.5rem)); }
.cropper-hint { margin-top: 0.25rem; font-size: 0.875rem; color: var(--muted); }
.cropper-stage {
  position: relative;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #0d0d0c;
  touch-action: none;
  user-select: none;
  cursor: grab;
}
.cropper-stage.is-dragging { cursor: grabbing; }
.cropper-stage:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
/* Square, and never taller than the window leaves room for (a phone held sideways). */
.cropper-avatar .cropper-stage { aspect-ratio: 1; width: min(100%, max(12rem, 100dvh - 15rem)); margin-inline: auto; }
.cropper-cover .cropper-stage { aspect-ratio: 3 / 1.25; }
.cropper-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
}
/* The part that's kept, clear; the rest dimmed around it. */
.cropper-frame {
  position: absolute;
  inset: var(--pad);
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.6);
  outline: 2px solid rgb(255 255 255 / 0.9);
  pointer-events: none;
}
.cropper-avatar .cropper-frame { border-radius: 9999px; }
.cropper-cover .cropper-frame { border-radius: 0.25rem; }
.cropper-zoom { display: flex; align-items: center; gap: 0.5rem; }
.cropper-slider { flex: 1; min-width: 0; accent-color: var(--ink); }
.cropper-note { font-size: 0.8125rem; color: var(--muted); }
.cropper-note:empty { display: none; }

/* ─── Fields ─────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.field-head label { font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.field-optional { margin-left: 0.375rem; font-weight: 400; color: var(--muted); }
.field-status { flex-shrink: 0; font-size: 0.75rem; white-space: nowrap; color: var(--muted); }
.field-status:empty { display: none; }
.field-message { font-size: 0.875rem; color: var(--muted); }
.field-error, .field-error-text { font-size: 0.875rem; color: var(--danger); }

.control {
  width: 100%;
  border-radius: 0.75rem;
  background: var(--surface);
  padding: 0 0.875rem;
  font-size: 0.9375rem;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  outline: none;
  transition: box-shadow 0.15s;
}
input.control, select.control { height: 2.75rem; }
.control:focus, .control:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); outline: none; }
.control:disabled { cursor: not-allowed; background: var(--surface-2); color: var(--muted); }
.control[aria-invalid='true'], .control.is-invalid { box-shadow: inset 0 0 0 1px var(--danger); }
.control[aria-invalid='true']:focus { box-shadow: inset 0 0 0 2px var(--focus); }
.control-area { min-height: 6rem; max-height: 60vh; overflow-y: auto; padding: 0.625rem 0.875rem; line-height: 1.625; }
.control-wrap { position: relative; }
.control-trailing { padding-right: 3rem; }
.control-trailing-slot { position: absolute; top: 0; bottom: 0; right: 0.25rem; display: flex; align-items: center; }
.control-select { appearance: none; -webkit-appearance: none; padding-right: 2.5rem; }
.control-chevron { pointer-events: none; position: absolute; top: 50%; right: 0.875rem; height: 1rem; width: 1rem; transform: translateY(-50%); color: var(--muted); }

.char-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.char-count.is-near { color: var(--ink-2); }
.char-count.is-over { color: var(--danger); font-weight: 500; }

.form { display: flex; flex-direction: column; gap: 1rem; }
.form-actions { margin-top: 0.25rem; display: flex; gap: 0.75rem; }
.form-error {
  border-radius: 0.75rem;
  background: color-mix(in oklab, var(--danger) 10%, transparent);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--danger);
}

.field-group { display: flex; flex-direction: column; gap: 0.375rem; border: 0; min-width: 0; }
.field-group > legend { margin-bottom: 0.375rem; padding: 0; font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.field-note { font-size: 0.875rem; color: var(--muted); }
.grid-birth { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0.75rem; }
.grid-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.status-ok { display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 500; color: var(--ink-2); }
.status-bad { font-weight: 500; color: var(--danger); }

/* Radio "cards" (report reasons, gender). */
.choices { display: flex; flex-direction: column; gap: 0.375rem; border: 0; min-width: 0; }
.choices > legend { margin-bottom: 0.375rem; padding: 0; font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.choice {
  display: flex;
  cursor: pointer;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: 0.75rem;
  padding: 0.625rem 0.75rem;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color 0.15s, box-shadow 0.15s;
}
.choice:hover { background: var(--surface-2); }
.choice.is-selected { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ink-2); }
.choice:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.radio-input { margin-top: 0.25rem; accent-color: var(--ink); }
.choice-title { display: block; font-size: 0.875rem; font-weight: 500; color: var(--ink); }
.choice-hint { display: block; font-size: 0.75rem; color: var(--muted); }
.choice-compact {
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.choice-compact .radio-input { margin-top: 0; }
.choice-compact.is-selected { font-weight: 500; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-2); }

/* ─── States ─────────────────────────────────────────────────────────────── */

.empty { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 3rem 1.5rem; text-align: center; }
.empty-icon { display: flex; height: 3rem; width: 3rem; align-items: center; justify-content: center; border-radius: 9999px; background: var(--surface-2); color: var(--ink-2); }
.empty-text { max-width: 24rem; }
.empty-text :is(h1, h2, h3) { font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; color: var(--ink); }
.empty-body { margin-top: 0.375rem; font-size: 0.9375rem; line-height: 1.625; color: var(--muted); }
.empty-action { margin-top: 0.25rem; }

.error-compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.75rem;
  background: var(--surface-2);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.progress { height: 0.375rem; overflow: hidden; border-radius: 9999px; background: var(--surface-3); }
.progress-bar { height: 100%; border-radius: 9999px; background: var(--ink-2); transition: width 0.5s; }

.note-box {
  display: flex;
  gap: 0.75rem;
  border-radius: 0.75rem;
  background: var(--surface-2);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--ink-2);
}
.note-box > .icon { margin-top: 0.125rem; }
.note-box-block { margin-top: 1.5rem; border-radius: 1rem; padding: 1rem; }

.notice { border-radius: 1rem; border: 1px dashed var(--line-strong); background: var(--surface); padding: 1.5rem 1.25rem; }
.notice-row { display: flex; align-items: flex-start; gap: 0.75rem; }
.notice-row > .icon { margin-top: 0.125rem; color: var(--ink-2); }
.notice-title { font-weight: 500; color: var(--ink); }
.notice-body { margin-top: 0.25rem; font-size: 0.875rem; color: var(--muted); }
.notice-lock { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); }
.notice-lock > .icon { color: var(--ink-2); }
.notice-progress { margin-top: 0.75rem; }
.notice-progress + .notice-body { margin-top: 0.75rem; }
.notice-center { padding: 2rem 1.25rem; text-align: center; }
.notice-serif { font-family: var(--font-serif); font-size: 1.125rem; line-height: 1.75rem; font-weight: 600; color: var(--ink); }
.notice-center .notice-body { margin: 0.375rem auto 0; max-width: 28rem; }
.notice-center .button-row { margin-top: 1.25rem; justify-content: center; }

/* ─── Dialog ─────────────────────────────────────────────────────────────── */

.dialog {
  margin: auto;
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  border-radius: 1rem;
  background: var(--surface);
  padding: 0;
  color: var(--ink);
  box-shadow: var(--shadow-2xl), 0 0 0 1px var(--line);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.45); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dialog[open] { animation: bt-pop 420ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.dialog-inner { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-head h2 { font-family: var(--font-serif); font-size: 1.25rem; line-height: 1.75rem; font-weight: 600; }
.dialog-desc { margin-top: 0.25rem; font-size: 0.875rem; color: var(--muted); }
.dialog-close { margin: -0.25rem -0.5rem 0 0; }
.dialog-body { display: flex; flex-direction: column; gap: 1rem; }
.dialog-body:empty, .dialog-footer:empty { display: none; }
.dialog-footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; padding-top: 0.25rem; }

/* ─── Menu ───────────────────────────────────────────────────────────────── */

.menu { position: relative; }
.menu-button {
  display: inline-flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s;
}
.menu-button:hover { background: var(--surface-2); color: var(--ink); }
.menu-popup {
  animation: bt-fade-up 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  position: absolute;
  top: 2.25rem;
  z-index: 30;
  min-width: 11rem;
  border-radius: 0.75rem;
  background: var(--surface);
  padding: 0.25rem;
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--line);
}
.menu-popup.is-right { right: 0; }
.menu-popup.is-left { left: 0; }
.menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.625rem;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  color: var(--ink);
}
.menu-item:hover, .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.menu-item.is-danger { color: var(--danger); }

/* ─── Tabs and segmented controls ────────────────────────────────────────── */

.tabs { display: flex; }
.tabs-underline { gap: 0.25rem; border-bottom: 1px solid var(--line); }
.tabs-pill { gap: 0.25rem; border-radius: 9999px; background: var(--surface-2); padding: 0.25rem; }
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--muted);
  transition: color 0.15s;
}
.tab:disabled { opacity: 0.4; }
.tabs-underline .tab { margin-bottom: -1px; border-bottom: 2px solid transparent; padding: 0.625rem 0.75rem; }
.tabs-underline .tab:hover { color: var(--ink); }
.tabs-underline .tab.is-selected { border-color: var(--ink); color: var(--ink); }
.tabs-pill .tab { flex: 1; justify-content: center; border-radius: 9999px; padding: 0.375rem 0.75rem; }
.tabs-pill .tab.is-selected { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.tab-dot { height: 0.375rem; width: 0.375rem; border-radius: 9999px; background: var(--ink-2); }

.segmented { display: inline-flex; gap: 0.25rem; border-radius: 9999px; background: var(--surface-2); padding: 0.25rem; }
.segmented-sm { padding: 0.125rem; }
.segment {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border-radius: 9999px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s;
}
.segment-sm { padding: 0.25rem 0.75rem; }
.segment:hover { color: var(--ink); }
.segment.is-selected { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

@media (min-width: 640px) {
  .dialog-inner { padding: 1.5rem; }
}
