/* ═══════════════════════════════════════════════════════════════
   BASE STYLES - Reset, Typography, Utilities
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   RESET
   ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  background: var(--color-bg);  /* Fallback for when living-background is loading */
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-normal);
  color: var(--color-text);
  background: transparent;  /* Allow living-background canvas to show through */
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

img, video, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* ─────────────────────────────────────────────────────────────────
   TYPOGRAPHY
   ───────────────────────────────────────────────────────────────── */
.text-hero {
  font-size: var(--text-hero);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tighter);
}

.text-display {
  font-size: var(--text-5xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

.text-heading-1 {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
}

.text-heading-2 {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
}

.text-heading-3 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
}

.text-body {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.text-body-lg {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
}

.text-small {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.text-caption {
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-wide);
}

.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }

/* ─────────────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────────────── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height);
  padding: 0 var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-lg);
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-lg {
  height: var(--btn-height-lg);
  padding: 0 var(--space-8);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
}

.btn-xl {
  height: var(--btn-height-xl);
  padding: 0 var(--space-10);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--color-void);
  box-shadow:
    var(--shadow-2),
    0 4px 16px rgba(var(--color-primary-rgb), 0.25);
}

.btn-primary:hover {
  box-shadow:
    var(--shadow-3),
    0 8px 24px rgba(var(--color-primary-rgb), 0.35);
}

.btn-secondary {
  background: var(--color-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border-light);
}

.btn-secondary:hover {
  background: var(--color-overlay);
  border-color: var(--color-border-light);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text);
}

.btn-icon {
  width: var(--btn-height);
  padding: 0;
}

.btn-icon.btn-lg {
  width: var(--btn-height-lg);
}

/* ─────────────────────────────────────────────────────────────────
   CARDS
   ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--component-padding);
  box-shadow: var(--glass-inner-glow);
  transition:
    transform var(--duration-normal) var(--ease-spring),
    box-shadow var(--duration-normal) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.card:hover {
  transform: translateY(-2px);
  background: var(--glass-bg-strong);
  box-shadow: var(--glass-inner-glow), var(--shadow-3);
}

.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow:
    var(--glass-inner-glow),
    var(--shadow-3);
}

/* Glass fallback */
@supports not (backdrop-filter: blur(1px)) {
  .card-glass {
    background: rgba(22, 22, 25, 0.95);
  }
}

/* ─────────────────────────────────────────────────────────────────
   INPUTS
   ───────────────────────────────────────────────────────────────── */
.input {
  width: 100%;
  height: var(--input-height);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  color: var(--color-text);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.input::placeholder {
  color: var(--color-text-muted);
}

.input:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
}

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

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(var(--color-error-rgb), 0.15);
}

textarea.input {
  height: auto;
  min-height: 120px;
  padding: var(--space-4);
  resize: vertical;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fafafa' fill-opacity='0.5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* ─────────────────────────────────────────────────────────────────
   FORM GROUPS
   ───────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-secondary);
}

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

.form-error {
  font-size: var(--text-sm);
  color: var(--color-error);
}

/* ─────────────────────────────────────────────────────────────────
   UTILITIES
   ───────────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Layout */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* Gaps */
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Sizing */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; min-height: 100dvh; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Interactive base */
.interactive {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--duration-fast) var(--ease-spring);
}

.interactive:active {
  transform: scale(0.97);
}

/* Hide scrollbar but keep functionality */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Scroll snap */
.snap-x {
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.snap-center {
  scroll-snap-align: center;
}

.snap-start {
  scroll-snap-align: start;
}

/* Dividers */
.divider {
  height: 1px;
  background: var(--color-border);
  width: 100%;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--color-border);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  background: var(--color-primary-muted);
  color: var(--color-primary);
}

.badge-success {
  background: rgba(var(--color-success-rgb), 0.12);
  color: var(--color-success);
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
}

/* Avatar */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-ring {
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-primary);
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 0%,
    var(--color-elevated) 50%,
    var(--color-surface) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   FOOTER - Fine Print
   ============================================ */
.site-footer {
  padding: var(--space-8) var(--space-4);
  padding-bottom: calc(var(--space-8) + 80px); /* Clear the floating pill menu */
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: var(--space-8);
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
}

.footer-business {
  font-size: 0.75rem;
  color: var(--color-text-tertiary, #6B7280);
  margin-bottom: var(--space-2);
}

.footer-credit {
  font-size: 0.7rem;
  color: var(--color-text-tertiary, #6B7280);
  opacity: 0.7;
}

.footer-credit a {
  color: var(--color-primary, #2563EB);
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer-credit a:hover {
  opacity: 0.8;
  text-decoration: underline;
}
