/**
 * Spontydex Theme - Centralized CSS
 * 
 * This file contains all theme variables and base styles for Spontydex web pages.
 * Matches the mobile app's dark theme with teal accents EXACTLY.
 * 
 * Import this file in all HTML pages:
 * <link rel="stylesheet" href="/styles/theme.css">
 */

/* ===== Brand fonts (self-hosted, SIL OFL 1.1 — licenses in /fonts) =====
   Same families as the app: Sora for display/headings, Inter for text. */
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/sora-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/sora-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/sora-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-latin-700-normal.woff2') format('woff2'); }

/* ===== CSS Variables - EXACT MATCH TO MOBILE APP ===== */
:root {
  /* Primary Colors - from paperTheme.ts */
  --color-primary: #2DD4BF;
  --color-primary-container: #0D9488;
  --color-primary-dark: #14B8A6;
  
  /* Secondary/Accent Colors */
  --color-secondary: #4ADE80;
  --color-tertiary: #818cf8;
  --color-error: #ef4444;
  --color-warning: #FBBF24;
  
  /* Text Colors - from uiColors */
  --color-text-primary: #F7F9FA;
  --color-text-secondary: #9ca3af;
  --color-text-muted: #6b7280;
  --color-text-on-dark: #000000;
  --color-text-on-light: #ffffff;
  
  /* Background Colors - from uiColors */
  --color-bg-dark: #000000;
  --color-bg-card: #121212;
  --color-bg-subtle: #1f2937;
  --color-bg-surface-variant: #1f2937;
  --color-bg-overlay: rgba(0, 0, 0, 0.5);
  --color-bg-elevated: rgba(255, 255, 255, 0.03);
  
  /* Border Colors */
  --color-border-default: #374151;
  --color-border-subtle: #1f2937;
  --color-border-accent: rgba(45, 212, 191, 0.3);
  
  /* Status Colors - from statusColors */
  --color-status-host: #4ADE80;
  --color-status-approved: #2DD4BF;
  --color-status-pending: #9CA3AF;
  --color-status-rejected: #ef4444;
  
  /* Gradients - EXACT MATCH to gradients.background from paperTheme.ts */
  /* Original: ['#000000', '#080808', '#081010', '#051916', '#062320'] */
  --gradient-background: linear-gradient(180deg, 
    #000000 0%, 
    #080808 30%, 
    #081010 50%, 
    #051916 80%, 
    #062320 100%
  );
  
  /* Login gradient */
  --gradient-login: linear-gradient(180deg, 
    #000000 0%, 
    #080808 30%, 
    #081010 50%, 
    #062320 80%, 
    #073530 100%
  );
  
  --gradient-header: linear-gradient(135deg, #0D9488 0%, #2DD4BF 100%);
  --gradient-card: linear-gradient(180deg, rgba(45, 212, 191, 0.05) 0%, rgba(0, 0, 0, 0) 100%);
  
  /* Spacing - matches app spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  
  /* Border Radius - matches theme.roundness = 12 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-display: 'Sora', var(--font-family);
  --font-mono: 'SF Mono', Monaco, 'Courier New', monospace;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
}

/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Black at top for overscroll bounce */
  background-color: #000000;
}

body {
  font-family: var(--font-family);
  /* Gradient as background-image so background-color (#062320) shows behind it.
     Top overscroll reveals html black; bottom overscroll reveals body #062320. */
  background-color: #062320;
  background-image: var(--gradient-background);
  background-attachment: scroll;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  min-height: 100vh;
  color: var(--color-text-primary);
  line-height: 1.6;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--color-text-primary);
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

/* The nav logo is a <picture> (WebP with PNG fallback); let the <img> inside
   lay out as if the wrapper were not there. */
.nav-brand picture { display: contents; }

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

p {
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-md);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

/* ===== App-style Container ===== */
.app-container {
  max-width: 500px;
  margin: 0 auto;
  padding: var(--spacing-md);
  min-height: 100vh;
}

/* ===== Card Component - matches app surface ===== */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.card-content {
  padding: var(--spacing-lg);
}

/* ===== Host Item - matches app hostItem style ===== */
.host-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  cursor: default;
}

.host-avatar-container {
  position: relative;
  width: 36px;
  height: 36px;
}

.host-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-primary);
}

.host-crown-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--color-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  z-index: 1;
}

.host-text-container {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-xs);
  flex: 1;
  min-width: 0;
}

.host-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.creator-text {
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

/* ===== Divider ===== */
.divider {
  height: 1px;
  background: var(--color-border-subtle);
  margin: var(--spacing-md) 0;
}

/* ===== Button Component - matches app buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  width: 100%;
}

.btn:hover {
  text-decoration: none;
}

@media (hover: hover) {
  .btn:hover { transform: translateY(-2px); }
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-on-dark);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  color: var(--color-text-on-dark);
}

/* App entry point shared by meetup previews and invite fallback pages. */
.meetup-app-btn {
  display: flex;
  width: fit-content;
  margin: 0 auto var(--spacing-lg);
  padding: 14px 32px;
  border-radius: var(--radius-full);
  font-size: 16px;
  font-weight: 700;
}

/* Ghost pill — transparent fill, teal hairline + glow, full pill radius.
   Matches the app's ghost CTA (used for the "Open Spontydex App" actions). */
.btn-ghost {
  background: transparent;
  color: var(--color-text-primary);
  border: 1px solid rgba(45, 212, 191, 0.45);
  border-radius: var(--radius-full);
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.15);
}

.btn-ghost:hover {
  background: rgba(45, 212, 191, 0.12);
  box-shadow: 0 0 26px rgba(45, 212, 191, 0.28);
}

/* ===== Chip Component - matches app Chip ===== */
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  background: rgba(45, 212, 191, 0.1);
  color: var(--color-primary);
  margin-right: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.categories {
  display: flex;
  flex-wrap: wrap;
}

/* ===== Attendees Avatars - matches app avatarGroup ===== */
.attendees-section {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-sm);
}

.avatar-group {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: var(--spacing-sm);
  margin: calc(-1 * var(--spacing-sm));
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.avatar-group:hover {
  background: rgba(255, 255, 255, 0.05);
}

.attendee-avatar-container {
  position: relative;
  margin-left: -12px;
}

.attendee-avatar-container:first-child {
  margin-left: 0;
}

.attendee-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--color-bg-card);
  object-fit: cover;
  background: var(--color-bg-subtle);
}

.attendee-avatar.host {
  border-color: var(--color-primary);
}

/* A face without an https photo: the person's initial in the photo's box. */
.attendee-avatar.is-letter,
.attendee-list-avatar.is-letter {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
  font-weight: 700;
}

.attendee-avatar.is-letter { font-size: 16px; }
.attendee-list-avatar.is-letter { font-size: 18px; }

.attendee-crown-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: var(--color-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  z-index: 1;
}

.more-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-on-dark);
  border: 3px solid var(--color-bg-card);
  margin-left: -12px;
}

/* ===== Code ===== */
.code {
  background: var(--color-bg-card);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-primary);
  word-break: break-all;
  border: 1px solid var(--color-border-subtle);
}

/* ===== Modal Styles ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing-lg);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border-subtle);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border-subtle);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--color-bg-subtle);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 20px;
}

.modal-close:hover {
  background: var(--color-border-default);
}

.modal-body {
  padding: var(--spacing-md);
  overflow-y: auto;
  flex: 1;
}

/* ===== Attendee List Item ===== */
.attendee-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  transition: background 0.2s ease;
}

.attendee-item:hover {
  background: var(--color-bg-subtle);
}

.attendee-list-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: var(--spacing-md);
  border: 2px solid transparent;
}

.attendee-list-avatar.host-border {
  border-color: var(--color-primary);
}

.attendee-info {
  flex: 1;
}

.attendee-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.attendee-username {
  font-size: 14px;
  color: var(--color-text-muted);
}

.status-badge {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.host-status {
  background: var(--color-secondary);
  color: var(--color-text-on-dark);
}

.approved-status {
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
}

.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--color-text-muted);
}

/* ===== Full Text ===== */
.full-text {
  color: var(--color-error) !important;
  font-weight: 600;
}

/* ===== Page Header for Legal Pages ===== */
.page-header {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
  border-bottom: 1px solid var(--color-border-accent);
  margin-bottom: var(--spacing-lg);
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--spacing-sm);
}

.page-subtitle {
  color: var(--color-text-secondary);
  font-size: 14px;
}

.last-updated {
  color: var(--color-text-muted);
  font-size: 12px;
  margin-top: var(--spacing-sm);
}

/* ===== Section Headers for Legal Pages ===== */
.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-primary);
  margin: var(--spacing-xl) 0 var(--spacing-md);
}

.section-subtitle {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: var(--spacing-lg) 0 var(--spacing-md);
}

/* ===== List Styles ===== */
ul, ol {
  margin-left: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
}

li {
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-sm);
}

/* ===== Alert/Box Components ===== */
.alert {
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  margin: var(--spacing-md) 0;
}

.alert-info {
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid var(--color-border-accent);
}

.alert-title {
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--spacing-sm);
}

/* ===== Footer ===== */
.page-footer {
  text-align: center;
  margin-top: var(--spacing-2xl);
  padding: var(--spacing-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-muted);
  font-size: 14px;
}

.page-footer a {
  color: var(--color-text-secondary);
  margin: 0 var(--spacing-sm);
}

.page-footer a:hover {
  color: var(--color-primary);
}

/* ===== Contact Box ===== */
.contact-box {
  background: rgba(45, 212, 191, 0.1);
  border: 1px solid var(--color-border-accent);
  border-radius: var(--radius-md);
  padding: var(--spacing-lg);
  margin-top: var(--spacing-xl);
}

.contact-box h3 {
  color: var(--color-primary);
  margin-top: 0;
  margin-bottom: var(--spacing-md);
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .app-container {
    padding: var(--spacing-sm);
  }
  
  h1, .page-title { font-size: 24px; }
  h2, .section-title { font-size: 18px; }
  
  .modal-content {
    max-height: 90vh;
    margin: var(--spacing-sm);
  }
  
  .attendee-avatar {
    width: 36px;
    height: 36px;
  }
  
  .more-avatar {
    width: 36px;
    height: 36px;
    font-size: 11px;
  }
}

/* ===== Page-to-page transitions =====
   Same-origin navigations cross-fade instead of flashing white (Chrome/Android 126+, Safari 18.2+;
   others navigate as before). The card wall drifts in step with the clock (cardwall.js), so between
   pages that share it the fade has nothing to show. Discover's tab bar is named so it holds still
   while the list under it fades, also when the old page was scrolled. */
@view-transition { navigation: auto; }
.share.discover .tabs { view-transition-name: discover-tabs; }
