/* ==========================================================================
   Components: buttons, badges, cards, sheets, popovers, toasts, the
   universal pieces every surface composes from.
   ========================================================================== */

/* ----- Button ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-2);
  background: var(--surface-1);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--fs-200);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-3); color: var(--text-1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-primary {
  background: var(--text-1);
  color: var(--surface-0);
  border-color: var(--text-1);
}
.btn-primary:hover { background: var(--text-2); border-color: var(--text-2); color: var(--surface-0); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }

.btn-danger {
  color: var(--danger);
  border-color: var(--border-2);
}
.btn-danger:hover { background: var(--danger); color: var(--surface-0); border-color: var(--danger); }

.btn-sm { padding: 6px 10px; font-size: var(--fs-100); }
.btn-lg { padding: 10px 18px; font-size: var(--fs-300); }

/* Pressable accent button (CTA on home, on map) */
.btn-accent {
  background: var(--accent-faint);
  color: var(--accent);
  border-color: transparent;
}
.btn-accent:hover { background: var(--accent); color: var(--surface-0); border-color: var(--accent); }

/* ----- Pill / badge ----- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  color: var(--text-2);
  font-size: var(--fs-100);
  font-family: var(--font-mono);
  letter-spacing: .02em;
  font-weight: 500;
  white-space: nowrap;
}
.pill-fleshed {
  background: var(--accent-faint);
  color: var(--accent-strong);
  border-color: var(--accent-faint);
}
.pill-stub {
  color: var(--text-3);
}
.pill-mod {
  font-family: var(--font-mono);
  background: transparent;
  border-color: var(--border-2);
}
.pill-mod::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--module-hue, var(--text-4));
}

/* ----- Card ----- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.card.is-hoverable:hover { border-color: var(--border-3); background: var(--surface-2); }
.card.is-link { display: block; text-decoration: none; color: inherit; }
.card.compact { padding: 14px 16px; }

.card-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-bottom: 6px;
}
.card-title {
  font-size: var(--fs-400);
  font-weight: 650;
  color: var(--text-1);
  letter-spacing: -.012em;
  margin: 0 0 6px;
}
.card-description {
  color: var(--text-3);
  font-size: var(--fs-200);
  line-height: 1.55;
  margin: 0;
}

/* ----- Sheet (slide-in from the right) ----- */
.sheet {
  position: fixed;
  inset: 0 0 0 auto;
  width: 480px;
  max-width: 92vw;
  background: var(--surface-1);
  border-left: 1px solid var(--border-2);
  z-index: 70;
  transform: translateX(100%);
  transition: transform var(--dur-mid) var(--ease-out);
  overflow-y: auto;
  padding: 0;
  box-shadow: var(--shadow-3);
}
.sheet[data-open="true"] { transform: translateX(0); }
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 0;
  background: var(--surface-1);
  z-index: 1;
}
.sheet-body {
  padding: 18px;
}

/* ----- Popover (small floating panel) ----- */
.popover {
  position: absolute;
  background: var(--surface-2);
  border: 1px solid var(--border-3);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-3);
  z-index: 80;
  padding: 6px;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
}

/* ----- Command Palette ----- */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 10, .6);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 100;
  backdrop-filter: blur(6px);
}
.cmd-overlay[data-open="true"] { display: flex; }

.cmd-palette {
  width: min(720px, 92vw);
  background: var(--surface-1);
  border: 1px solid var(--border-3);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
}
.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-1);
}
.cmd-input-row .ico {
  color: var(--text-3);
  width: 18px; height: 18px;
}
.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-1);
  font-size: var(--fs-400);
  font-family: var(--font-sans);
}
.cmd-input::placeholder { color: var(--text-4); }
.cmd-results {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}
.cmd-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-2);
  font-size: var(--fs-200);
}
.cmd-result:hover, .cmd-result.is-active {
  background: var(--surface-2);
  color: var(--text-1);
}
.cmd-result .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-result .meta {
  font-family: var(--font-mono);
  font-size: var(--fs-100);
  color: var(--text-4);
}
.cmd-result mark {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}
.cmd-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-200);
}
.cmd-foot {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border-1);
  font-size: var(--fs-100);
  color: var(--text-4);
  font-family: var(--font-mono);
}
.cmd-foot .kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border-2);
  border-radius: 3px;
  margin: 0 2px;
}

/* ----- Toasts ----- */
#toasts {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-3);
  border-left: 2px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--fs-200);
  color: var(--text-1);
  max-width: 320px;
  pointer-events: auto;
  animation: toast-in var(--dur-mid) var(--ease-out);
  box-shadow: var(--shadow-2);
}
.toast-tier { border-left-color: var(--accent-strong); font-weight: 600; }
.toast-achievement { border-left-color: var(--success); }
.toast.is-leaving { animation: toast-out var(--dur-mid) var(--ease-out); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(8px); }
}

/* ----- Progress bar ----- */
.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width var(--dur-mid) var(--ease-out);
}

/* ----- Form controls ----- */
input[type="text"], input[type="search"], input[type="email"], textarea, select {
  background: var(--surface-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: var(--fs-200);
  width: 100%;
  transition: border-color var(--dur-fast);
}
input[type="text"]:focus, input[type="search"]:focus, textarea:focus, select:focus {
  border-color: var(--border-3);
}
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-200);
  color: var(--text-2);
}
label.field > .label-text {
  font-weight: 500;
  color: var(--text-2);
  font-size: var(--fs-200);
}

/* ----- Choice list (radios styled as cards) ----- */
.choice-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.choice-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--surface-1);
  transition: border-color var(--dur-fast), background var(--dur-fast);
  font-size: var(--fs-200);
}
.choice-list label:hover { background: var(--surface-2); border-color: var(--border-3); }
.choice-list input { margin-top: 3px; flex: 0 0 auto; }
.choice-list label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-faint);
}

/* ----- Hover ring helper ----- */
.ring-on-hover { transition: box-shadow var(--dur-fast); }
.ring-on-hover:hover { box-shadow: 0 0 0 1px var(--accent); }

/* ----- Divider ----- */
.div { height: 1px; background: var(--border-1); margin: 16px 0; }
.div-vert { width: 1px; align-self: stretch; background: var(--border-1); }

/* ----- Section headers ----- */
.section-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  font-family: var(--font-mono);
}
.section-title {
  font-size: var(--fs-500);
  font-weight: 600;
  color: var(--text-1);
  margin: 4px 0 8px;
  letter-spacing: -.012em;
}

/* ----- Empty states ----- */
.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-lg);
}
.empty h3 { color: var(--text-2); margin-bottom: 6px; }

/* ----- Hero strip used on module pages ----- */
.hero-strip {
  display: flex;
  align-items: stretch;
  gap: 24px;
  padding: 28px 0;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 24px;
}
.hero-stripe {
  width: 4px;
  border-radius: 2px;
  background: var(--module-hue, var(--accent));
  flex: 0 0 auto;
}
.hero-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.hero-num {
  font-family: var(--font-mono);
  font-size: var(--fs-200);
  letter-spacing: .04em;
  color: var(--text-3);
  text-transform: uppercase;
}
.hero-title {
  font-size: var(--fs-700);
  letter-spacing: -.018em;
  margin: 0;
  text-wrap: balance;
}
.hero-tagline {
  color: var(--text-3);
  font-size: var(--fs-300);
  max-width: 60ch;
  margin: 0;
}
