/* ============================================================================
   ThinkPing v1.1 — Component Library
   Reference: Beat 03 (UI Component Library)
   ============================================================================ */

/* ----------------------------------------------------------------------------
   BUTTONS
   ---------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  min-height: var(--tap-min);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-standard);
  user-select: none;
  text-align: center;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Primary button (coral) */
.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-pressed);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  background: var(--accent-pressed);
}

/* Secondary button (outline ink) */
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--text-primary);
  color: var(--text-inverse);
}

/* Ghost button (text only) */
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  padding: var(--space-2) var(--space-4);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-raised);
}

/* Danger button */
.btn-danger {
  background: transparent;
  color: var(--state-error);
  border-color: var(--state-error);
}

.btn-danger:hover:not(:disabled) {
  background: var(--state-error);
  color: var(--text-inverse);
}

/* Size variants */
.btn-sm {
  min-height: 36px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}

.btn-lg {
  min-height: 56px;
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-lg);
}

.btn-block {
  width: 100%;
}

/* ----------------------------------------------------------------------------
   TAP BUTTON (the coral circle)
   ---------------------------------------------------------------------------- */

.tap-button {
  position: relative;
  width: var(--tap-button-size);
  height: var(--tap-button-size);
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-coral);
  transition: transform var(--duration-fast) var(--ease-standard),
              box-shadow var(--duration-fast) var(--ease-standard);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.tap-button:hover {
  transform: scale(1.03);
  box-shadow: 0 16px 50px -10px rgba(198, 93, 72, 0.55);
}

.tap-button.pressing {
  transform: scale(0.96);
}

.tap-button.tap-success {
  animation: tap-success-pulse var(--duration-slow) var(--ease-tender);
}

.tap-button-inner {
  position: absolute;
  inset: 12px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle at 30% 30%, 
    rgba(245, 223, 216, 0.15) 0%, 
    transparent 50%);
  pointer-events: none;
}

/* Ripple effect — single expanding ring */
.tap-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  border: 2px solid rgba(140, 50, 40, 0.55);
  background: transparent;
  transform: translate(-50%, -50%) scale(1);
  animation: ripple-expand 1s cubic-bezier(0, 0, 0.2, 1) forwards;
  pointer-events: none;
}

.tap-button {
  overflow: visible !important;
}


/* ----------------------------------------------------------------------------
   INPUT FIELDS
   ---------------------------------------------------------------------------- */

.input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  min-height: var(--tap-min);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-standard),
              background var(--duration-fast) var(--ease-standard);
}

.input:focus {
  border-color: var(--border-focus);
  background: var(--surface-page);
  outline: 2px solid var(--border-focus);
  outline-offset: -1px;
}

.input::placeholder {
  color: var(--text-placeholder);
  font-style: italic;
}

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

.input.input-error {
  border-color: var(--state-error);
}

.input.input-mono {
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.input-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-muted);
}

.input-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

.input-error-msg {
  font-size: var(--text-sm);
  color: var(--state-error);
}

/* Textarea */
.textarea {
  resize: vertical;
  min-height: 80px;
}

.textarea-count {
  display: flex;
  justify-content: flex-end;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.textarea-count.warning {
  color: var(--accent-primary);
}

/* ----------------------------------------------------------------------------
   CHIPS & BADGES
   ---------------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  background: var(--surface-raised);
  color: var(--text-secondary);
}

.chip-private {
  background: var(--surface-raised);
  color: var(--text-muted);
}

.chip-open {
  background: var(--accent-bg);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.chip-pending {
  background: var(--accent-bg);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  animation: pulse-subtle 1.6s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   AVATAR
   ---------------------------------------------------------------------------- */

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  color: var(--text-accent);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-lg);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-sm { width: 28px; height: 28px; font-size: var(--text-sm); }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-xl); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--text-3xl); }

/* Avatar variants (8 deterministic patterns) */
.avatar-v1 { background: linear-gradient(135deg, var(--primitive-cream-300), var(--primitive-coral-100)); }
.avatar-v2 { background: linear-gradient(135deg, var(--primitive-cream-400), var(--primitive-coral-200)); }
.avatar-v3 { background: linear-gradient(135deg, var(--primitive-cream-300), var(--primitive-sage-200)); }
.avatar-v4 { background: linear-gradient(135deg, var(--primitive-sage-200), var(--primitive-cream-400)); }
.avatar-v5 { background: linear-gradient(135deg, var(--primitive-cream-200), var(--primitive-cream-500)); }
.avatar-v6 { background: linear-gradient(135deg, var(--primitive-coral-100), var(--primitive-sage-200)); }
.avatar-v7 { background: linear-gradient(135deg, var(--primitive-cream-500), var(--primitive-ink-100)); }
.avatar-v8 { background: linear-gradient(135deg, var(--primitive-cream-400), var(--primitive-ink-200)); }

/* ----------------------------------------------------------------------------
   CARDS
   ---------------------------------------------------------------------------- */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--duration-fast) var(--ease-standard);
}

.card:hover {
  border-color: var(--primitive-cream-500);
}

/* ----------------------------------------------------------------------------
   LOG ENTRY
   ---------------------------------------------------------------------------- */

.log-entry {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px dotted var(--border-default);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry-time {
  flex-shrink: 0;
  width: 56px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

.log-entry-body {
  flex: 1;
  min-width: 0;
}

.log-entry-text {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-normal);
}

.log-entry-text .mention {
  font-family: var(--font-mono);
  font-size: 0.95em;
  color: var(--text-accent);
  font-weight: 600;
}

.log-entry-note {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-snug);
}

.log-entry-tags {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------------------
   CIRCLE SELECTOR
   ---------------------------------------------------------------------------- */

.circles-scroll {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding: var(--space-4) var(--space-4);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.circles-scroll::-webkit-scrollbar {
  display: none;
}

.circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  min-width: 72px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background var(--duration-fast) var(--ease-standard);
  scroll-snap-align: start;
}

.circle-item:hover {
  background: var(--surface-raised);
}

.circle-item.active {
  background: var(--surface-raised);
}

.circle-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  font-size: var(--text-xl);
  color: var(--text-accent);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.circle-item.active .circle-icon {
  background: var(--accent-bg);
  border: 2px solid var(--accent-primary);
  transform: scale(1.05);
}

.circle-item.add .circle-icon {
  border: 2px dashed var(--border-default);
  background: transparent;
  color: var(--text-muted);
}

.circle-name {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.circle-item.active .circle-name {
  color: var(--text-primary);
  font-weight: 600;
}

/* ----------------------------------------------------------------------------
   MODAL
   ---------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 21, 16, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: modal-fade-in var(--duration-fast) var(--ease-out);
}

.modal {
  background: var(--surface-page);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-slide-up var(--duration-base) var(--ease-tender);
}

.modal-header {
  margin-bottom: var(--space-5);
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.modal-subtitle {
  font-family: var(--font-body);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.modal-footer {
  margin-top: var(--space-6);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ----------------------------------------------------------------------------
   TOAST
   ---------------------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-3) var(--space-5);
  background: var(--surface-inverse);
  color: var(--text-inverse);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  z-index: var(--z-toast);
  max-width: 90vw;
  animation: toast-slide-up var(--duration-base) var(--ease-tender);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.toast-success {
  background: var(--primitive-sage-400);
}

.toast-error {
  background: var(--state-error);
}

.toast-info {
  background: var(--primitive-ink-400);
}

.toast.toast-leaving {
  animation: toast-slide-down var(--duration-fast) var(--ease-in) forwards;
}

/* ----------------------------------------------------------------------------
   OFFLINE BANNER
   ---------------------------------------------------------------------------- */

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--primitive-ink-400);
  color: var(--text-inverse);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-align: center;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.offline-banner.hidden {
  display: none;
}

.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  animation: pulse-subtle 1.6s ease-in-out infinite;
}

/* ----------------------------------------------------------------------------
   ERROR STATE
   ---------------------------------------------------------------------------- */

.error-state {
  text-align: center;
  padding: var(--space-16) var(--space-4);
}

.error-icon {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.error-state h3 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.error-state p {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}

/* ----------------------------------------------------------------------------
   LOADING
   ---------------------------------------------------------------------------- */

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  animation: loading-dot 1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

/* ----------------------------------------------------------------------------
   CONSENT TOAST (10-min timer)
   ---------------------------------------------------------------------------- */

.consent-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-page);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  max-width: 420px;
  width: calc(100% - var(--space-8));
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toast);
  animation: toast-slide-up var(--duration-base) var(--ease-tender);
}

.consent-toast-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.consent-toast-body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.consent-toast-timer {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.consent-toast-actions {
  display: flex;
  gap: var(--space-3);
}

.consent-toast-actions .btn {
  flex: 1;
}
