/* ================================================================
   Girl Harmony — Components
   Reusable UI atoms. Lots of soft rounding, warm shadows, motion.
   ================================================================ */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 14px 24px;
  font-size: var(--size-body);
  transition: transform var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out),
              background var(--d-fast) var(--ease-out),
              opacity var(--d-fast);
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--gh-plum-500);
  color: #fff;
  box-shadow: var(--shadow-plum);
}
.btn-primary:hover:not(:disabled) {
  background: var(--gh-plum-700);
  box-shadow: 0 12px 36px rgba(107, 76, 154, 0.42);
}

/* Cocoa "espresso" button — for the rare moment when a deeper, less brand-accent button is needed */
.btn-cocoa {
  background: var(--gh-cocoa-700);
  color: var(--gh-cream-50);
  box-shadow: var(--shadow-md);
}
.btn-cocoa:hover:not(:disabled) {
  background: var(--gh-cocoa-900);
  box-shadow: var(--shadow-lg);
}

/* btn-rose — kept as alias to btn-primary for backward-compat. Plum is the brand. */
.btn-rose {
  background: var(--gh-plum-500);
  color: #fff;
  box-shadow: var(--shadow-plum);
}
.btn-rose:hover:not(:disabled) { background: var(--gh-plum-700); }

.btn-secondary {
  background: var(--gh-cream-100);
  color: var(--gh-cocoa-700);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--gh-cream-200); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  padding: 10px 16px;
}
.btn-ghost:hover:not(:disabled) { background: var(--gh-cream-100); }

.btn-block { width: 100%; }
.btn-lg { padding: 16px 28px; font-size: 16px; }
.btn-sm { padding: 10px 16px; font-size: 13px; }
.btn-icon { padding: 12px; aspect-ratio: 1; }

/* ---------- Card ---------- */
.card {
  background: var(--bg-elevated);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-tinted {
  background: var(--bg-tint);
  border-color: transparent;
}
.card-clickable {
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease-out),
              box-shadow var(--d-fast) var(--ease-out),
              border-color var(--d-fast);
}
.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(60, 36, 23, 0.10);
}
.card-clickable:active { transform: scale(0.985); }
.card-clickable.is-selected {
  border-color: var(--gh-plum-500);
  background: var(--gh-plum-50);
  box-shadow: 0 4px 16px rgba(107, 76, 154, 0.12);
}

/* ---------- Pill / Chip / Tag ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--gh-cream-100);
  color: var(--text);
  letter-spacing: 0.01em;
}
.pill-rose      { background: var(--gh-rose-100);       color: var(--gh-menstrual); }
.pill-menstrual { background: var(--gh-menstrual-soft); color: var(--gh-menstrual); }
.pill-follicular{ background: var(--gh-follicular-soft);color: #B05A3F; }
.pill-ovulation { background: var(--gh-ovulation-soft); color: #8C6A28; }
.pill-luteal    { background: var(--gh-luteal-soft);    color: var(--gh-luteal); }
.pill-gold      { background: var(--gh-gold-100);       color: #8C6A28; }
.pill-sage      { background: var(--gh-sage-100);       color: #4F7351; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all var(--d-fast) var(--ease-out);
  user-select: none;
}
.chip:hover { background: var(--gh-cream-100); }
.chip:active { transform: scale(0.96); }
.chip.is-selected {
  background: var(--gh-plum-500);
  color: #fff;
  border-color: var(--gh-plum-500);
  box-shadow: 0 4px 12px rgba(107, 76, 154, 0.24);
}
.chip.chip-danger {
  color: var(--gh-error, #C24A5C);
  border-color: var(--gh-error-soft, #F5D8DD);
  background: transparent;
  padding: 8px 10px;
}
.chip.chip-danger:hover {
  background: var(--gh-error-soft, #F5D8DD);
}

/* ---------- Input ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.input,
.textarea,
.select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  transition: border-color var(--d-fast) var(--ease-out), box-shadow var(--d-fast);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--gh-plum-500);
  box-shadow: 0 0 0 4px rgba(107, 76, 154, 0.18);
}
.textarea { min-height: 100px; resize: vertical; font-family: inherit; }

/* ---------- Toggle ---------- */
.switch {
  position: relative;
  width: 48px;
  height: 28px;
  background: var(--gh-cream-200);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--d-fast) var(--ease-out);
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform var(--d-fast) var(--ease-out);
}
.switch.is-on { background: var(--gh-plum-500); }
.switch.is-on::after { transform: translateX(20px); }

/* ---------- Twemoji — render emojis at the same baseline as text ---------- */
img.twemoji,
img.emoji {
  height: 1em;
  width: 1em;
  display: inline-block;
  margin: 0 0.05em 0 0.1em;
  vertical-align: -0.18em;
}

/* ---------- Avatar ---------- */
.avatar {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gh-plum-100), var(--gh-pink-100));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--gh-plum-500);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar-lg { width: 88px; height: 88px; font-size: 38px; }
.avatar.is-editable {
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease-out);
}
.avatar.is-editable:active { transform: scale(0.96); }
.avatar-edit-badge {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 28px; height: 28px;
  background: var(--gh-plum-500);
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  border: 3px solid var(--bg);
  box-shadow: 0 2px 8px rgba(107, 76, 154, 0.32);
  transition: transform var(--d-fast) var(--ease-out);
}
.avatar.is-editable:hover .avatar-edit-badge { transform: scale(1.08); }
.avatar-lg .avatar-edit-badge { width: 36px; height: 36px; bottom: 2px; right: 2px; }
.avatar-lg .avatar-edit-badge svg { width: 16px; height: 16px; }

/* ---------- Progress ---------- */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gh-cream-200);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gh-plum-500), var(--gh-plum-300));
  border-radius: var(--r-pill);
  transition: width var(--d-base) var(--ease-out);
}

/* ---------- Divider ---------- */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--s-4) 0;
}

/* ---------- List row ---------- */
.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 14px 0;
  cursor: pointer;
  transition: background var(--d-fast);
  border-radius: var(--r-md);
}
.row:hover { background: var(--gh-cream-100); }
.row + .row { border-top: 1px solid var(--border); }
.row-icon {
  width: 36px; height: 36px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gh-cream-100);
  font-size: 18px;
  flex-shrink: 0;
}
.row-content { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; }
.row-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.row-trail { color: var(--text-muted); }

/* ---------- Sheet (modal) ---------- */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 26, 18, 0.42);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--d-base) var(--ease-out);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-elevated);
  border-top-left-radius: var(--r-2xl);
  border-top-right-radius: var(--r-2xl);
  z-index: 51;
  transform: translateY(100%);
  transition: transform var(--d-slow) var(--ease-out);
  padding: var(--s-3) var(--s-5) calc(var(--safe-bottom) + var(--s-5));
  max-height: 88%;
  overflow-y: auto;
  box-shadow: 0 -16px 60px rgba(0,0,0,0.18);
}
.sheet.is-open { transform: translateY(0); }
.sheet-handle {
  width: 40px; height: 5px;
  background: var(--gh-cream-300);
  border-radius: var(--r-pill);
  margin: 8px auto var(--s-4);
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  left: 16px; right: 16px;
  background: var(--gh-cocoa-900);
  color: var(--gh-cream-50);
  padding: 14px 16px;
  border-radius: var(--r-lg);
  z-index: 90;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transform: translateY(-120%);
  opacity: 0;
  transition: transform var(--d-base) var(--ease-out), opacity var(--d-base);
  font-size: 14px;
  font-weight: 500;
}
.toast.is-shown { transform: translateY(0); opacity: 1; }

/* ---------- Loaders ---------- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gh-cream-200);
  border-top-color: var(--gh-plum-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.shimmer {
  background: linear-gradient(90deg, var(--gh-cream-100) 0%, var(--gh-cream-200) 50%, var(--gh-cream-100) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Phase swatch ---------- */
.phase-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.phase-dot.menstrual  { background: var(--gh-menstrual); }
.phase-dot.follicular { background: var(--gh-follicular); }
.phase-dot.ovulation  { background: var(--gh-ovulation); }
.phase-dot.luteal     { background: var(--gh-luteal); }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: var(--s-10) var(--s-6);
  color: var(--text-muted);
}
.empty-emoji { font-size: 56px; line-height: 1; margin-bottom: var(--s-3); }

/* ---------- Skeleton screen ---------- */
.skeleton {
  background: var(--gh-cream-100);
  border-radius: var(--r-md);
  animation: shimmer 1.4s linear infinite;
}
