/* ============================================================
   DatePlanet — Shared Styles (app.css)
   Mobile-first. Base styles target 320–360px phones.
   ============================================================ */

/* ──────────────────────────────────────────────
   1. CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ────────────────────────────────────────────── */
:root {
  /* Brand colours */
  --dp-primary: #8b5cf6;
  --dp-primary-dark: #7c3aed;
  --dp-primary-light: #a78bfa;
  --dp-accent: #ec4899;
  --dp-accent-dark: #db2777;

  /* Neutrals */
  --dp-bg: #ffffff;
  --dp-bg-alt: #faf7ff;
  --dp-surface: #ffffff;
  --dp-border: #e5e7eb;
  --dp-border-light: #f3f4f6;

  /* Text */
  --dp-text: #1f2937;
  --dp-text-muted: #6b7280;
  --dp-text-light: #9ca3af;
  --dp-text-inverse: #ffffff;

  /* Status */
  --dp-success: #10b981;
  --dp-success-bg: #d1fae5;
  --dp-error: #ef4444;
  --dp-error-bg: #fee2e2;
  --dp-warning: #f59e0b;
  --dp-warning-bg: #fef3c7;
  --dp-info: #3b82f6;
  --dp-info-bg: #dbeafe;

  /* Spacing */
  --dp-space-xs: 0.25rem;
  --dp-space-sm: 0.5rem;
  --dp-space-md: 1rem;
  --dp-space-lg: 1.5rem;
  --dp-space-xl: 2rem;
  --dp-space-2xl: 3rem;

  /* Radii */
  --dp-radius-sm: 0.375rem;
  --dp-radius-md: 0.75rem;
  --dp-radius-lg: 1rem;
  --dp-radius-xl: 1.5rem;
  --dp-radius-full: 9999px;

  /* Shadows */
  --dp-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --dp-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --dp-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --dp-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Typography */
  --dp-font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --dp-font-size-xs: 0.75rem;
  --dp-font-size-sm: 0.875rem;
  --dp-font-size-base: 1rem;
  --dp-font-size-lg: 1.125rem;
  --dp-font-size-xl: 1.25rem;
  --dp-font-size-2xl: 1.5rem;
  --dp-font-size-3xl: 1.875rem;

  /* Transitions */
  --dp-transition-fast: 150ms ease;
  --dp-transition-base: 250ms ease;
  --dp-transition-slow: 400ms ease;

  /* Layout */
  --dp-bottom-nav-height: 64px;
  --dp-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ──────────────────────────────────────────────
   2. RESET & BASE
   ────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--dp-font-sans);
  font-size: var(--dp-font-size-base);
  line-height: 1.5;
  color: var(--dp-text);
  background: var(--dp-bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px; /* Prevents iOS zoom */
}

a {
  color: var(--dp-primary);
  text-decoration: none;
  transition: color var(--dp-transition-fast);
}

a:hover, a:focus-visible {
  color: var(--dp-primary-dark);
}

:focus-visible {
  outline: 2px solid var(--dp-primary);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────
   3. TOAST NOTIFICATIONS
   ────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--dp-space-md) + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--dp-space-sm);
  width: calc(100% - 2rem);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--dp-space-sm);
  padding: var(--dp-space-md);
  border-radius: var(--dp-radius-md);
  background: var(--dp-surface);
  box-shadow: var(--dp-shadow-lg);
  border-left: 4px solid var(--dp-info);
  pointer-events: auto;
  animation: toast-enter 300ms ease-out;
  font-size: var(--dp-font-size-sm);
  color: var(--dp-text);
  min-height: 48px;
}

.toast--success {
  border-left-color: var(--dp-success);
  background: var(--dp-success-bg);
  color: #065f46;
}

.toast--error {
  border-left-color: var(--dp-error);
  background: var(--dp-error-bg);
  color: #991b1b;
}

.toast--info {
  border-left-color: var(--dp-info);
  background: var(--dp-info-bg);
  color: #1e40af;
}

.toast__message {
  flex: 1;
  line-height: 1.4;
}

.toast__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--dp-radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  opacity: 0.6;
  transition: opacity var(--dp-transition-fast), background var(--dp-transition-fast);
  font-size: 1rem;
}

.toast__close:hover,
.toast__close:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.toast--exit {
  animation: toast-exit 250ms ease-in forwards;
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ──────────────────────────────────────────────
   4. MODAL (CONFIRM / PROMPT)
   ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--dp-space-md);
  animation: overlay-enter 200ms ease-out;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay--exit {
  animation: overlay-exit 200ms ease-in forwards;
}

.modal {
  background: var(--dp-surface);
  border-radius: var(--dp-radius-lg);
  padding: var(--dp-space-xl);
  box-shadow: var(--dp-shadow-xl);
  width: 100%;
  max-width: 420px;
  animation: modal-enter 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal__message {
  margin: 0 0 var(--dp-space-lg);
  font-size: var(--dp-font-size-base);
  color: var(--dp-text);
  line-height: 1.5;
}

.modal__label {
  display: block;
  margin-bottom: var(--dp-space-sm);
  font-size: var(--dp-font-size-sm);
  font-weight: 600;
  color: var(--dp-text);
}

.modal__input {
  width: 100%;
  padding: var(--dp-space-md);
  border: 2px solid var(--dp-border);
  border-radius: var(--dp-radius-md);
  font-size: var(--dp-font-size-base);
  margin-bottom: var(--dp-space-lg);
  transition: border-color var(--dp-transition-fast);
  color: var(--dp-text);
  background: var(--dp-bg);
}

.modal__input:focus {
  outline: none;
  border-color: var(--dp-primary);
}

.modal__actions {
  display: flex;
  gap: var(--dp-space-sm);
  justify-content: flex-end;
}

.modal__btn {
  min-height: 44px;
  padding: var(--dp-space-sm) var(--dp-space-lg);
  border-radius: var(--dp-radius-md);
  font-size: var(--dp-font-size-base);
  font-weight: 600;
  transition: transform var(--dp-transition-fast), background var(--dp-transition-fast), box-shadow var(--dp-transition-fast);
  min-width: 90px;
}

.modal__btn:active {
  transform: scale(0.97);
}

.modal__btn--primary {
  background: var(--dp-primary);
  color: var(--dp-text-inverse);
}

.modal__btn--primary:hover,
.modal__btn--primary:focus-visible {
  background: var(--dp-primary-dark);
  box-shadow: var(--dp-shadow-md);
}

.modal__btn--secondary {
  background: var(--dp-border-light);
  color: var(--dp-text);
}

.modal__btn--secondary:hover,
.modal__btn--secondary:focus-visible {
  background: var(--dp-border);
}

@keyframes overlay-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes overlay-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ──────────────────────────────────────────────
   5. MATCH CELEBRATION MODAL
   ────────────────────────────────────────────── */
.match-modal {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.95), rgba(236, 72, 153, 0.95));
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--dp-space-lg);
  animation: match-overlay-enter 400ms ease-out;
}

.match-modal--exit {
  animation: match-overlay-exit 300ms ease-in forwards;
}

.match-modal__content {
  text-align: center;
  color: var(--dp-text-inverse);
  width: 100%;
  max-width: 400px;
  animation: match-content-enter 600ms cubic-bezier(0.34, 1.56, 0.64, 1) 100ms backwards;
}

.match-modal__heading {
  font-size: var(--dp-font-size-3xl);
  margin: 0 0 var(--dp-space-xl);
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  animation: match-heading-bounce 1s ease-in-out infinite alternate;
}

.match-modal__photos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: -20px;
  margin-bottom: var(--dp-space-xl);
  position: relative;
}

.match-modal__photo {
  width: 140px;
  height: 140px;
  border-radius: var(--dp-radius-full);
  object-fit: cover;
  border: 5px solid var(--dp-text-inverse);
  box-shadow: var(--dp-shadow-xl);
  background: var(--dp-border-light);
}

.match-modal__photo--me {
  transform: translateX(20px) rotate(-8deg);
  animation: match-photo-me 800ms cubic-bezier(0.34, 1.56, 0.64, 1) 200ms backwards;
}

.match-modal__photo--them {
  transform: translateX(-20px) rotate(8deg);
  animation: match-photo-them 800ms cubic-bezier(0.34, 1.56, 0.64, 1) 400ms backwards;
}

.match-modal__name {
  font-size: var(--dp-font-size-lg);
  margin: 0 0 var(--dp-space-xl);
  opacity: 0.95;
  line-height: 1.4;
}

.match-modal__actions {
  display: flex;
  flex-direction: column;
  gap: var(--dp-space-sm);
}

.match-modal__btn {
  min-height: 52px;
  padding: var(--dp-space-md) var(--dp-space-xl);
  border-radius: var(--dp-radius-full);
  font-size: var(--dp-font-size-base);
  font-weight: 700;
  transition: transform var(--dp-transition-fast), box-shadow var(--dp-transition-fast);
}

.match-modal__btn:active {
  transform: scale(0.97);
}

.match-modal__btn--primary {
  background: var(--dp-text-inverse);
  color: var(--dp-primary-dark);
  box-shadow: var(--dp-shadow-lg);
}

.match-modal__btn--primary:hover,
.match-modal__btn--primary:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--dp-shadow-xl);
}

.match-modal__btn--secondary {
  background: rgba(255, 255, 255, 0.2);
  color: var(--dp-text-inverse);
  border: 2px solid var(--dp-text-inverse);
}

.match-modal__btn--secondary:hover,
.match-modal__btn--secondary:focus-visible {
  background: rgba(255, 255, 255, 0.3);
}

@keyframes match-overlay-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes match-overlay-exit {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes match-content-enter {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes match-heading-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

@keyframes match-photo-me {
  from {
    opacity: 0;
    transform: translateX(-100px) rotate(-30deg);
  }
  to {
    opacity: 1;
    transform: translateX(20px) rotate(-8deg);
  }
}

@keyframes match-photo-them {
  from {
    opacity: 0;
    transform: translateX(100px) rotate(30deg);
  }
  to {
    opacity: 1;
    transform: translateX(-20px) rotate(8deg);
  }
}

/* ──────────────────────────────────────────────
   6. BOTTOM NAVIGATION (MOBILE)
   ────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dp-surface);
  border-top: 1px solid var(--dp-border);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  z-index: 100;
  padding-bottom: var(--dp-safe-bottom);
  min-height: calc(var(--dp-bottom-nav-height) + var(--dp-safe-bottom));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--dp-space-sm) var(--dp-space-xs);
  color: var(--dp-text-muted);
  font-size: var(--dp-font-size-xs);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dp-transition-fast), background var(--dp-transition-fast);
  min-height: 44px;
  position: relative;
}

.bottom-nav__item:hover,
.bottom-nav__item:focus-visible {
  color: var(--dp-primary);
  background: var(--dp-bg-alt);
}

.bottom-nav__item--active {
  color: var(--dp-primary);
}

.bottom-nav__item--active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--dp-primary);
  border-radius: 0 0 var(--dp-radius-full) var(--dp-radius-full);
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__icon svg {
  width: 100%;
  height: 100%;
}

.bottom-nav__label {
  font-size: 11px;
  line-height: 1;
}

/* Pages with bottom nav need padding to avoid overlap */
.has-bottom-nav {
  padding-bottom: calc(var(--dp-bottom-nav-height) + var(--dp-safe-bottom) + var(--dp-space-md));
}

/* ──────────────────────────────────────────────
   7. UTILITY CLASSES
   ────────────────────────────────────────────── */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--dp-space-md);
}

/* Loading spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--dp-border);
  border-top-color: var(--dp-primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  margin: var(--dp-space-xl) auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--dp-space-2xl) var(--dp-space-md);
  color: var(--dp-text-muted);
}

.empty-state__icon {
  font-size: 3rem;
  margin-bottom: var(--dp-space-md);
  opacity: 0.6;
}

.empty-state__title {
  font-size: var(--dp-font-size-lg);
  font-weight: 600;
  color: var(--dp-text);
  margin: 0 0 var(--dp-space-sm);
}

.empty-state__text {
  margin: 0 0 var(--dp-space-lg);
  line-height: 1.5;
}

/* ──────────────────────────────────────────────
   8. REDUCED MOTION
   ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ──────────────────────────────────────────────
   9. RESPONSIVE BREAKPOINTS
   ────────────────────────────────────────────── */

/* Tablet (768px+) */
@media (min-width: 768px) {
  .toast-container {
    top: var(--dp-space-lg);
    right: var(--dp-space-lg);
    left: auto;
    transform: none;
  }

  .match-modal__photos {
    gap: 0;
  }

  .match-modal__photo {
    width: 160px;
    height: 160px;
  }

  .match-modal__actions {
    flex-direction: row;
    justify-content: center;
  }

  .match-modal__btn {
    flex: 1;
    max-width: 180px;
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .bottom-nav {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    bottom: var(--dp-space-lg);
    border-radius: var(--dp-radius-xl);
    border: 1px solid var(--dp-border);
    box-shadow: var(--dp-shadow-xl);
  }
}