/**
 * Button Component Styles
 * Accessible, consistent button patterns
 */

/* ═══════════════════════════════════════════════════════════
   BASE BUTTON
   ══════════════════════════════════════════════════════════ */

.btn,
button {
  /* Reset */
  border: none;
  background: none;
  cursor: pointer;
  
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
  
  /* Spacing */
  padding: var(--space-2) var(--space-4);
  min-height: var(--button-height-md);
  min-width: var(--touch-target-min);  /* WCAG AA */
  
  /* Typography */
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  line-height: 1.2;
  text-decoration: none;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
  
  /* Visual */
  border-radius: var(--radius-md);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), outline 0.15s ease;
  
  /* Accessibility */
  max-width: 100%;
  user-select: none;
}

/* The display:inline-flex above outranks the UA's [hidden]{display:none},
   so JS toggling the hidden attribute (e.g. the directory's Load more
   button in its waitlist state) left buttons visible. Restore the contract. */
.btn[hidden],
button[hidden] {
  display: none;
}

/* Ripple effect on click */
.btn::before,
button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn:active::before,
button:active::before {
  width: 300px;
  height: 300px;
  transition: width 0s, height 0s;
  animation: rippleOut 0.6s ease-out;
}

@keyframes rippleOut {
  0% {
    box-shadow: 0 0 0 0 currentColor;
  }
  100% {
    box-shadow: 0 0 0 20px rgba(255, 255, 255, 0);
  }
}

.btn:focus-visible,
button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  animation: focusPulse 0.4s ease-out;
}

@keyframes focusPulse {
  0% {
    outline-width: 0;
    outline-offset: 8px;
  }
  100% {
    outline-width: 2px;
    outline-offset: 2px;
  }
}

.btn:disabled,
button:disabled {
  opacity: 0.65;                            /* GAP-003: increased from 0.5 for WCAG AA visibility */
  cursor: not-allowed;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.55);        /* GAP-003: explicit color for disabled text (4.5:1 on dark bg) */
}


/* ═══════════════════════════════════════════════════════════
   BUTTON VARIANTS
   ══════════════════════════════════════════════════════════ */

/* Primary - Main actions */
.btn-primary {
  background: var(--interactive-primary);
  color: #ffffff;  /* White text for AA contrast on gold primary buttons (4.5:1 minimum) */
}

.btn-primary:hover:not(:disabled) {
  background: var(--interactive-primary-hover);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.3),
    0 0 16px color-mix(in srgb, var(--interactive-primary) 40%, transparent);
  animation: hoverGlow 0.4s ease-out;
}

@keyframes hoverGlow {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--interactive-primary) 60%, transparent);
  }
  100% {
    box-shadow: 0 0 0 8px color-mix(in srgb, var(--interactive-primary) 0%, transparent);
  }
}

.btn-primary:active {
  background: var(--interactive-primary-active);
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Secondary - Alternative actions */
.btn-secondary {
  background: var(--interactive-secondary);
  color: var(--text-primary);
  border: var(--border-width-thin) solid var(--border-subtle);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-emphasis);
  background: var(--interactive-secondary-hover);
  color: var(--interactive-primary);
  transform: translateY(-2px) scale(1.01);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  animation: shimmer 0.6s ease-in-out;
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.btn-secondary:active {
  background: var(--interactive-secondary-active);
  transform: translateY(0) scale(0.99);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Danger - Destructive actions */
.btn-danger {
  background: transparent;
  color: var(--status-error);
  border: var(--border-width-thin) solid var(--status-error);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-danger:hover:not(:disabled) {
  background: var(--status-error);
  color: var(--color-white, #fff);
  transform: translateY(-2px);
  box-shadow: 
    0 4px 12px rgba(224, 80, 80, 0.24),
    0 0 20px rgba(224, 80, 80, 0.3);
  animation: pulseError 0.5s ease-in-out;
}

@keyframes pulseError {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(224, 80, 80, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(224, 80, 80, 0);
  }
}

.btn-danger:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(224, 80, 80, 0.24);
}

/* Ghost - Subtle actions */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Link - Minimal actions */
.btn-link {
  background: transparent;
  color: var(--text-link);
  min-width: auto;
  padding-left: 0;
  padding-right: 0;
}

.btn-link:hover:not(:disabled) {
  color: var(--text-link-hover);
  text-decoration: underline;
}

/* Rose Theme - Feminine elegance for key CTAs */
.btn-rose {
  background: var(--color-error-500);
  color: var(--color-white, #fff);
  border: transparent;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-rose:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-error-500) 90%, black);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 8px 20px rgba(201, 168, 76, 0.2),
    0 0 24px color-mix(in srgb, var(--color-error-500) 40%, transparent);
  animation: roseGlow 0.5s ease-out;
}

@keyframes roseGlow {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--color-error-500) 60%, transparent);
  }
  100% {
    box-shadow: 0 0 0 12px color-mix(in srgb, var(--color-error-500) 0%, transparent);
  }
}

.btn-rose:active {
  background: color-mix(in srgb, var(--color-error-500) 80%, black);
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.2);
}

.btn-rose-primary {
  background: linear-gradient(135deg, var(--color-error-500) 0%, var(--color-purple-composition) 100%);
  color: var(--color-white, #fff);
  border: transparent;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  background-size: 200% 200%;
}

.btn-rose-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-error-500) 90%, black) 0%, color-mix(in srgb, var(--color-purple-composition) 90%, black) 100%);
  background-position: 100% 100%;
  transform: translateY(-3px) scale(1.03);
  box-shadow: 
    0 12px 28px rgba(0, 0, 0, 0.28),
    0 0 32px color-mix(in srgb, var(--color-error-500) 35%, transparent),
    0 0 64px color-mix(in srgb, var(--color-purple-composition) 25%, transparent);
  animation: gradientShift 0.6s ease-out;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 100% 100%;
  }
}

.btn-rose-primary:active {
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-error-500) 80%, black) 0%, color-mix(in srgb, var(--color-purple-composition) 80%, black) 100%);
  transform: translateY(-1px) scale(0.98);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}


/* ═══════════════════════════════════════════════════════════
   BUTTON SIZES
   ══════════════════════════════════════════════════════════ */

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  min-height: var(--button-height-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-lg);
  min-height: var(--button-height-lg);
}

.btn-xs {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  min-height: 2rem;
  min-width: 2rem;
}


/* ═══════════════════════════════════════════════════════════
   BUTTON LAYOUTS
   ══════════════════════════════════════════════════════════ */

/* Full width button */
.btn-block {
  width: 100%;
  justify-content: center;
}

/* Icon-only button */
.btn-icon {
  padding: var(--space-2);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  background: var(--interactive-secondary);
  color: var(--text-primary);
  border: var(--border-width-thin) solid var(--border-subtle);
  transition: all 0.2s ease;
}

.btn-icon:hover:not(:disabled) {
  background: var(--interactive-secondary-hover);
  border-color: var(--border-emphasis);
  color: var(--interactive-primary);
  transform: scale(1.08);
}

.btn-icon:active:not(:disabled) {
  transform: scale(0.96);
  background: var(--interactive-secondary-active);
}

.btn-icon:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.btn-icon.btn-sm {
  min-width: 2rem;
  min-height: 2rem;
}

/* ACC-P2-8: Enforce WCAG 2.5.5 44px touch targets on touch screens */
@media (pointer: coarse) {
  .btn-sm {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
  }
  .btn-icon.btn-sm {
    min-width: var(--touch-target-min);
    min-height: var(--touch-target-min);
  }
  .btn-xs {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
  }
}


/* ═══════════════════════════════════════════════════════════
   BUTTON GROUPS
   ══════════════════════════════════════════════════════════ */

.btn-group {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.btn-group .btn:not(:last-child) {
  margin-right: 0;
}


/* ═══════════════════════════════════════════════════════════
   BUTTON LOADING STATE
   ══════════════════════════════════════════════════════════ */

.btn:has(.spinner) {
  position: relative;
}

.btn .spinner {
  display: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin var(--duration-slow) linear infinite;
}

/* Hide text when loading */
.btn-loading .btn-text {
  visibility: hidden;
}

.btn-loading .spinner {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* ═══════════════════════════════════════════════════════════
   BUTTON SUCCESS STATE
   ══════════════════════════════════════════════════════════ */

.btn-success {
  background: var(--accent2, #4fc8a0);
  color: var(--color-white, #fff);
  animation: successPulse 0.6s ease-out;
}

.btn-success::after {
  content: '✓';
  position: absolute;
  font-weight: bold;
  font-size: 1.2em;
  animation: successCheckmark 0.4s ease-out;
}

@keyframes successPulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 200, 160, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(79, 200, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 200, 160, 0); }
}

@keyframes successCheckmark {
  0% { transform: scale(0) rotate(-45deg); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════
   DENSITY SELECTOR (UX Review Phase 1.1)
   ══════════════════════════════════════════════════════════ */

.density-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.density-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius-md, 8px);
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
  min-height: auto;
}

.density-btn:hover {
  border-color: var(--gold-dim, #a08839);
  background: var(--bg2);
}

.density-btn--active,
.density-btn[aria-pressed="true"] {
  border-color: var(--gold, #c9a84c);
  background: rgba(201, 168, 76, 0.08);
}

.density-btn-icon {
  font-size: 1.5rem;
  color: var(--gold, #c9a84c);
}

.density-btn-label {
  font-weight: 600;
  font-size: var(--text-base, 1rem);
  color: var(--text);
}

.density-btn-desc {
  font-size: var(--text-sm, 0.85rem);
  color: var(--text-dim);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════════
   PROFILE SECTION NAV (UX Review Phase 2.5)
   ══════════════════════════════════════════════════════════ */

.profile-section-nav {
  position: sticky;
  top: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  margin-bottom: var(--space-4);
  z-index: 10;
}

.profile-section-nav .section-nav-pill {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm, 0.85rem);
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  min-height: auto;
  min-width: auto;
}

.profile-section-nav .section-nav-pill:hover,
.profile-section-nav .section-nav-pill.active {
  background: rgba(201, 168, 76, 0.12);
  border-color: var(--gold, #c9a84c);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   GUIDED READING VIEW (UX Review Phase 2.1)
   ══════════════════════════════════════════════════════════ */

.guided-reading {
  position: relative;
}

.guided-reading .reading-card {
  display: none;
  padding: var(--space-6) var(--space-4);
  min-height: 300px;
}

.guided-reading .reading-card.reading-card--active {
  display: block;
  animation: fadeInCard 0.3s ease;
}

@keyframes fadeInCard {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.reading-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
}

.reading-nav-dots {
  display: flex;
  gap: var(--space-2);
}

.reading-nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  padding: 0;
  min-height: auto;
  min-width: auto;
  cursor: pointer;
  transition: background 0.2s;
}

.reading-nav-dot.active {
  background: var(--gold, #c9a84c);
}

/* ═══════════════════════════════════════════════════════════
   MILESTONE STRIP (UX Review Phase 1.4)
   ══════════════════════════════════════════════════════════ */

.milestone-strip {
  display: flex;
  align-items: center;
  gap: 0;
  padding: var(--space-4);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.milestone-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 90px;
  text-align: center;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  background: none;
  padding: var(--space-2);
  min-height: auto;
}

.milestone-step .ms-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: var(--bg3);
  border: 2px solid var(--border);
  color: var(--text-dim);
  transition: all 0.2s;
}

.milestone-step.completed .ms-icon {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--gold, #c9a84c);
  color: var(--gold, #c9a84c);
}

.milestone-step .ms-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.3;
  max-width: 80px;
}

.milestone-connector {
  width: 24px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

.milestone-step.completed + .milestone-connector {
  background: var(--gold-dim, #a08839);
}

/* ═══════════════════════════════════════════════════════════
   PRACTITIONER SUB-TABS (UX Review Phase 2.2)
   ══════════════════════════════════════════════════════════ */

.prac-sub-tabs {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-4);
}

.prac-sub-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm, 0.85rem);
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  min-height: auto;
  border-radius: 0;
}

.prac-sub-tab:hover {
  color: var(--text);
}

.prac-sub-tab.active {
  color: var(--gold, #c9a84c);
  border-bottom-color: var(--gold, #c9a84c);
}
