/* GiveKH — App-like, Khmer-first, mobile-first */
@import url('https://fonts.googleapis.com/css2?family=Kantumruy+Pro:wght@400;500;600;700&family=DM+Sans:opsz,wght@9..40,400;9..40,600;9..40,700&display=swap');

:root {
  --primary: #c1121f;
  --primary-dark: #9e0e19;
  --primary-light: #e63946;
  --primary-glow: rgba(193, 18, 31, 0.08);
  --bg: #f7f5f2;
  --bg-warm: #f0ece6;
  --bg-hero: linear-gradient(165deg, #faf8f5 0%, #f5ede4 50%, #f0e8dd 100%);
  --text: #1c1917;
  --text-secondary: #78716c;
  --text-muted: #a8a29e;
  --card-bg: #ffffff;
  --border: #e7e5e4;
  --border-light: #f5f5f4;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --gold: #d97706;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --font-display: 'Kantumruy Pro', 'DM Sans', sans-serif;
  --font-body: 'DM Sans', 'Kantumruy Pro', sans-serif;
  --font-khmer: 'Kantumruy Pro', sans-serif;
  --shadow-card: 0 1px 3px rgba(28, 25, 23, 0.04), 0 4px 12px rgba(28, 25, 23, 0.03);
  --shadow-elevated: 0 4px 16px rgba(28, 25, 23, 0.08), 0 12px 40px rgba(28, 25, 23, 0.04);
  --shadow-glow: 0 4px 24px rgba(193, 18, 31, 0.15);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: var(--safe-bottom);
  overscroll-behavior-y: contain;
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

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

/* ===== Khmer language mode ===== */
body.lang-km {
  font-family: var(--font-khmer);
  line-height: 1.75;
}

body.lang-km h1, body.lang-km h2, body.lang-km h3 {
  font-family: var(--font-khmer);
  font-weight: 700;
  line-height: 1.4;
}

body.lang-km .btn {
  font-family: var(--font-khmer);
}

body.lang-km p {
  line-height: 1.85;
}

/* ===== Language Toggle ===== */
.lang-toggle {
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--card-bg);
  font-family: var(--font-khmer);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-toggle:active {
  transform: scale(0.95);
  background: var(--bg-warm);
}

/* ===== Nav ===== */
nav {
  max-width: 600px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: rgba(247, 245, 242, 0.88);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  z-index: 100;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--bg-hero);
  padding-bottom: 2rem;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--bg));
}

.hero-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 3rem 1.5rem 3rem;
  text-align: center;
  animation: fadeUp 0.6s ease-out;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  letter-spacing: -0.3px;
}

body.lang-km .hero h1 {
  font-size: 2.2rem;
  line-height: 1.35;
}

.highlight {
  color: var(--primary);
  position: relative;
}

.highlight::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: -2px;
  right: -2px;
  height: 6px;
  background: var(--primary-glow);
  border-radius: 3px;
  z-index: -1;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-weight: 400;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

body.lang-km .subtitle {
  font-size: 1rem;
  line-height: 1.8;
}

.cta-group {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-direction: column;
  max-width: 320px;
  margin: 0 auto;
  animation: fadeUp 0.6s ease-out 0.1s both;
}

/* ===== Buttons ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.75rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 52px;
  user-select: none;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:active {
  background: var(--bg-warm);
}

/* ===== Steps ===== */
.steps {
  max-width: 600px;
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

.steps h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  padding-left: 0.25rem;
}

.step-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.25rem 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
}

.step-number {
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.step-text {
  flex: 1;
}

.step h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.step p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.55;
}

/* ===== Features ===== */
.features {
  max-width: 100%;
  background: var(--bg-warm);
  padding: 3rem 0;
}

.features h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1.25rem;
}

.feature-grid {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.feature {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

.feature h3 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.feature p {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 2rem 1.25rem;
  padding-bottom: calc(2rem + var(--safe-bottom));
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.innolabs-footer {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.innolabs-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.innolabs-logo:hover {
  opacity: 1;
}

.innolabs-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}

/* ===== Cause Page ===== */
.cause-page {
  max-width: 500px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
  animation: fadeUp 0.5s ease-out;
}

.cause-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
}

.cause-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

body.lang-km .cause-header h1 {
  line-height: 1.4;
}

.cause-description {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.cause-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.cause-badge {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 100px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-primary);
  font-weight: 600;
}

.cause-location {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.cause-organizer {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* ===== Progress ===== */
.progress-section {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
  animation: scaleIn 0.4s ease-out 0.1s both;
}

.progress-amounts {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.progress-amounts span:first-child {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--success);
}

.progress-amounts span:last-child {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-bar {
  height: 8px;
  background: var(--bg-warm);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #22c55e);
  border-radius: 4px;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  min-width: 4px;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  background-size: 200% 100%;
  animation: shimmer 2.5s infinite;
}

.progress-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== QR Section ===== */
.qr-section {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
  animation: scaleIn 0.4s ease-out 0.2s both;
}

.qr-section h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.amount-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  justify-content: center;
}

.amount-presets button {
  padding: 0.7rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--card-bg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  transition: all 0.1s ease;
  min-height: 48px;
  flex: 1 1 auto;
  min-width: 56px;
  max-width: 80px;
}

.amount-presets button:active {
  transform: scale(0.95);
}

.amount-presets button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.amount-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.amount-input-group input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-body);
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  min-height: 52px;
}

.amount-input-group input:focus {
  border-color: var(--primary);
  background: var(--card-bg);
}

.message-input.message-input {
  font-size: 0.9rem;
  font-weight: 400;
  text-align: left;
  padding: 0.65rem 0.85rem;
}

.amount-input-group .btn {
  width: 100%;
  padding: 0.85rem 1.25rem;
}

#qr-canvas {
  margin: 1.25rem auto;
  display: block;
  max-width: 240px;
  border-radius: var(--radius-xs);
  animation: bounceIn 0.5s ease-out;
  box-shadow: 0 2px 12px rgba(28, 25, 23, 0.06);
}

.qr-instruction {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.6;
}

/* ===== Check Payment ===== */
#check-section {
  margin: 1rem 0 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.3s ease;
}

#check-section .btn {
  width: 100%;
}

#check-status {
  font-size: 0.9rem;
  font-weight: 600;
}

/* ===== Donations List ===== */
.donations-section {
  margin-bottom: 1.5rem;
  animation: fadeUp 0.4s ease-out 0.3s both;
}

.donations-section h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.donation-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border-light);
  gap: 0.75rem;
}

.donation-item:last-child {
  border-bottom: none;
}

.donation-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
}

.donation-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  flex-shrink: 0;
}

.donation-amount {
  font-weight: 700;
  color: var(--success);
  font-size: 1.05rem;
}

.donation-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.donation-date {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.donation-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.no-donations {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
  font-size: 0.9rem;
}

/* ===== Share Bar ===== */
.share-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  animation: fadeUp 0.4s ease-out 0.25s both;
}

.share-bar button {
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--card-bg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  transition: all 0.1s ease;
  min-height: 48px;
}

.share-bar button:active {
  transform: scale(0.96);
  background: var(--bg-warm);
}

/* ===== Causes Listing ===== */
.causes-section {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.causes-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-left: 0.25rem;
}

.causes-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cause-card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.15rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
}

.cause-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-elevated);
}

.cause-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

body.lang-km .cause-card h3 {
  line-height: 1.5;
}

.cause-card-desc {
  color: var(--text-secondary);
  font-size: 0.825rem;
  margin-bottom: 0.85rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cause-card-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.cause-card-raised {
  font-weight: 700;
  color: var(--success);
}

.cause-card-count {
  color: var(--text-muted);
}

.cause-card .progress-bar {
  margin-bottom: 0;
  height: 6px;
}

.no-causes {
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem 0;
  font-size: 0.9rem;
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 4rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  animation: pulse 1.2s infinite;
}

.error-page {
  text-align: center;
  padding: 4rem 1.25rem;
  animation: fadeUp 0.4s ease-out;
}

.error-page h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.error-page p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* ===== Responsive — tablet+ ===== */
@media (min-width: 601px) {
  nav {
    max-width: 700px;
    padding: 1rem 2rem;
  }

  .hero-content {
    max-width: 700px;
    padding: 5rem 2rem 4rem;
  }

  .hero h1 {
    font-size: 3rem;
  }

  body.lang-km .hero h1 {
    font-size: 2.6rem;
  }

  .subtitle {
    font-size: 1.15rem;
  }

  .cta-group {
    flex-direction: row;
    max-width: none;
  }

  .steps, .causes-section {
    max-width: 700px;
    padding: 4rem 2rem;
  }

  .steps h2, .causes-section h2 {
    font-size: 1.75rem;
    text-align: center;
    padding-left: 0;
  }

  .step-grid {
    flex-direction: row;
    gap: 1rem;
  }

  .step {
    flex-direction: column;
    text-align: center;
    padding: 1.75rem 1.5rem;
  }

  .step-number {
    margin: 0 auto 1rem;
  }

  .features h2 {
    max-width: 700px;
    font-size: 1.75rem;
    text-align: center;
  }

  .feature-grid {
    max-width: 700px;
  }

  .causes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .cause-page {
    padding: 2rem 2rem 4rem;
  }

  .cause-header h1 {
    font-size: 2rem;
  }
}

/* ===== Large screens ===== */
@media (min-width: 1024px) {
  .hero-content {
    padding: 6rem 2rem 5rem;
  }

  .hero h1 {
    font-size: 3.5rem;
  }

  .feature:hover {
    box-shadow: var(--shadow-elevated);
    transform: translateY(-2px);
  }

  .cause-card:hover {
    box-shadow: var(--shadow-elevated);
    transform: translateY(-2px);
  }

  .btn:hover {
    transform: translateY(-1px);
  }

  .btn-primary:hover {
    background: var(--primary-light);
  }

  .step:hover {
    box-shadow: var(--shadow-elevated);
    transform: translateY(-2px);
  }
}

/* ===== Small phones ===== */
@media (max-width: 360px) {
  .share-bar {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 2rem;
  }

  body.lang-km .hero h1 {
    font-size: 1.85rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }
}
