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

:root {
  /* Premium warm palette */
  --bg: #f5ede0;
  --bg-soft: #faf5eb;
  --bg-deep: #0e1f1a;
  --ink: #1a1612;
  --ink-soft: #5c544a;
  --ink-faint: #8a8174;
  --emerald: #1f4a3a;
  --emerald-deep: #0d2e22;
  --gold: #b8924a;
  --gold-light: #d4ae6d;
  --gold-soft: #e8d4a8;
  --line: rgba(26, 22, 18, 0.08);

  /* Typography */
  --font-display: 'Aref Ruqaa', 'Amiri', serif;
  --font-kufi: 'Reem Kufi', 'Cairo', sans-serif;
  --font-body: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --font-naskh: 'Amiri', serif;
}

/* English-mode font swap — use elegant Latin fonts */
body.lang-en {
  --font-display: 'Playfair Display', 'Aref Ruqaa', serif;
  --font-kufi: 'Inter', 'Reem Kufi', sans-serif;
  --font-body: 'Inter', 'Tajawal', system-ui, sans-serif;
}

body.lang-en .hero-name,
body.lang-en .feature-title,
body.lang-en .section-title,
body.lang-en .contact-title,
body.lang-en .footer-name,
body.lang-en .timeline-title,
body.lang-en .project-title {
  letter-spacing: -0.02em;

  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 10px;

  --shadow-sm: 0 2px 12px rgba(26, 22, 18, 0.04);
  --shadow: 0 8px 32px rgba(26, 22, 18, 0.08);
  --shadow-lg: 0 20px 60px rgba(26, 22, 18, 0.15);
}

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
}

/* ================================
   BACKGROUND PATTERN
   ================================ */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23b8924a' stroke-width='0.3' opacity='0.3'%3E%3Cpath d='M40 10L48 26L65 28L52 41L55 58L40 50L25 58L28 41L15 28L32 26Z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px;
}

/* ================================
   ABOUT PAGE
   ================================ */
.page-about {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 40px;
}

.about-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  padding: 40px 0 24px;
}

.about-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 28px 32px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar {
  position: relative;
  width: 96px;
  height: 96px;
  margin-bottom: 4px;
}

.avatar-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 45deg, var(--gold-light), var(--gold), var(--gold-soft), var(--gold-light));
  opacity: 0.6;
}

.avatar-inner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-deep) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold-soft);
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  border: 3px solid var(--bg-soft);
}

.avatar-initial {
  line-height: 1;
  padding-bottom: 8px;
}

.about-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.6rem);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.about-handle {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: 500;
  direction: ltr;
  letter-spacing: 0.02em;
}

.about-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--gold);
  margin: 4px 0;
  width: 100%;
  max-width: 200px;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to var(--dir, left), transparent, var(--gold) 50%, transparent);
  opacity: 0.4;
}

.about-bio {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.8;
  font-weight: 500;
  max-width: 320px;
}

.bio-soft {
  color: var(--ink-soft);
  font-weight: 400;
  font-size: 0.95rem;
}

.about-links {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.social-link {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  text-decoration: none;
  transition: all 0.2s ease;
  background: var(--bg);
}

.social-link:hover {
  background: var(--emerald);
  color: var(--gold-soft);
  border-color: var(--emerald);
  transform: translateY(-2px);
}

/* Primary CTA */
.primary-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: var(--emerald);
  color: var(--bg-soft);
  text-decoration: none;
  border-radius: var(--radius);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 24px rgba(31, 74, 58, 0.25);
  -webkit-tap-highlight-color: transparent;
  min-height: 64px;
}

.primary-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(31, 74, 58, 0.35);
}

.primary-cta:active {
  transform: translateY(0);
}

.cta-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: start;
}

.cta-label {
  font-family: var(--font-kufi);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--bg-soft);
}

.cta-sub {
  font-size: 0.78rem;
  color: var(--gold-soft);
  font-weight: 400;
}

.cta-arrow {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--emerald-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.primary-cta:hover .cta-arrow {
  transform: translateX(-4px);
}

/* RTL: arrow points right naturally, fix for LTR direction */
[dir="rtl"] .cta-arrow svg {
  transform: scaleX(1);
}

.about-footer {
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.8rem;
  padding: 8px 0;
  font-family: var(--font-body);
}

/* ================================
   EID PAGE
   ================================ */
.page-eid {
  background: var(--bg);
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.eid-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 237, 224, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  border-radius: 50%;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.back-link:active {
  background: var(--line);
}

.eid-title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.eid-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

.eid-subtitle {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-weight: 400;
}

.eid-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 140px;
  position: relative;
  z-index: 1;
}

.eid-section {
  padding: 24px 0;
}

.section-head {
  margin-bottom: 16px;
}

.section-label {
  font-family: var(--font-kufi);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--gold);
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  margin-top: 4px;
}

/* Card thumbnails */
.card-grid {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding: 6px 4px 18px;
  scrollbar-width: none;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.card-grid::-webkit-scrollbar {
  display: none;
}

.card-thumb {
  flex-shrink: 0;
  width: 130px;
  aspect-ratio: 4/5;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
  border: 2px solid transparent;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  background: none;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-sm);
}

.card-thumb:active {
  transform: scale(0.96);
}

.card-thumb.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 146, 74, 0.2), var(--shadow);
}

.card-thumb .card-bg,
.card-thumb .card-overlay,
.card-thumb .card-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-thumb .card-content {
  display: none;
}

.thumb-label {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  padding: 8px 6px 6px;
  font-family: var(--font-kufi);
  font-size: 0.7rem;
  font-weight: 500;
  text-align: center;
  color: white;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  z-index: 5;
}

/* Font picker */
.font-options {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
  scrollbar-width: none;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.font-options::-webkit-scrollbar {
  display: none;
}

.font-chip {
  flex-shrink: 0;
  padding: 12px 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 30px;
  cursor: pointer;
  font-size: 1.05rem;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

.font-chip:active {
  transform: scale(0.96);
}

.font-chip.active {
  background: var(--emerald);
  color: var(--gold-soft);
  border-color: var(--emerald);
}

/* Greeting picker */
.greeting-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.greeting-chip {
  padding: 14px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.2s ease;
  min-height: 52px;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.greeting-chip.active {
  background: var(--emerald);
  color: var(--gold-soft);
  border-color: var(--emerald);
}

.greeting-chip:active {
  transform: scale(0.97);
}

/* Image upload section */
.upload-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-label {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: var(--bg-soft);
  border: 2px dashed rgba(184, 146, 74, 0.4);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 76px;
  -webkit-tap-highlight-color: transparent;
}

.upload-label:hover {
  background: white;
  border-color: var(--gold);
  border-style: solid;
}

.upload-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(184, 146, 74, 0.12);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.upload-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.upload-text {
  font-family: var(--font-kufi);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-weight: 400;
}

.upload-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 30px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: center;
  -webkit-tap-highlight-color: transparent;
}

.upload-clear:hover {
  background: #fff5f0;
  color: #c04040;
  border-color: #c04040;
}

/* Custom greeting */
.custom-greeting-wrap {
  margin-top: 14px;
}

.custom-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--ink-faint);
}

.custom-divider .divider-line {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.custom-divider .divider-text {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* Name input */
.input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.name-input {
  width: 100%;
  padding: 16px 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.05rem;
  outline: none;
  transition: all 0.2s ease;
  min-height: 56px;
}

.name-input::placeholder {
  color: var(--ink-faint);
}

.name-input:focus {
  border-color: var(--gold);
  background: white;
  box-shadow: 0 0 0 3px rgba(184, 146, 74, 0.15);
}

/* Preview */
.preview-area {
  display: flex;
  justify-content: center;
  padding: 8px 0 16px;
}

.card-preview-wrapper {
  width: min(88vw, 360px);
}

#card-preview {
  width: 100%;
  aspect-ratio: 4/5;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
}

#card-preview .card-bg,
#card-preview .card-overlay,
#card-preview .card-decor {
  position: absolute;
  inset: 0;
}

#card-preview .card-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  z-index: 3;
  text-align: center;
  gap: 12px;
}

.card-greeting {
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1.3;
  direction: rtl;
}

.card-name {
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-weight: 500;
  margin-top: 16px;
  opacity: 0.9;
  direction: rtl;
}

.card-wishes {
  font-size: clamp(0.75rem, 2.4vw, 0.9rem);
  font-weight: 400;
  opacity: 0.75;
  margin-top: 6px;
  line-height: 1.6;
  direction: rtl;
  max-width: 85%;
}

/* Actions bar */
.actions-bar {
  position: fixed;
  bottom: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  z-index: 50;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  background: rgba(245, 237, 224, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.btn-download {
  flex: 1;
  max-width: 280px;
  min-height: 56px;
  padding: 16px 24px;
  background: var(--emerald);
  color: var(--gold-soft);
  font-family: var(--font-kufi);
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 20px rgba(31, 74, 58, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(31, 74, 58, 0.4);
}

.btn-download:active {
  transform: translateY(0);
}

.btn-download:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.share-buttons {
  display: flex;
  gap: 8px;
}

.share-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.share-btn:active {
  transform: scale(0.92);
}

.share-btn.whatsapp:hover {
  background: #25D366;
  color: white;
  border-color: #25D366;
}

.share-btn.twitter:hover {
  background: #000;
  color: white;
  border-color: #000;
}

.share-btn.instagram:hover {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: white;
  border-color: transparent;
}

.share-btn.native:hover {
  background: var(--gold);
  color: var(--emerald-deep);
  border-color: var(--gold);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ================================
   TABLET+ LAYOUT
   ================================ */
@media (min-width: 768px) {
  .eid-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    padding-top: 24px;
    padding-bottom: 60px;
  }

  .eid-controls {
    order: 2;
  }

  .eid-preview-section {
    order: 1;
    position: sticky;
    top: 90px;
    align-self: start;
  }

  .card-grid,
  .font-options {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .actions-bar {
    position: static;
    padding: 0;
    background: none;
    backdrop-filter: none;
    border: none;
    flex-direction: column;
    margin-top: 16px;
  }

  .btn-download {
    width: 100%;
    max-width: none;
  }

  .share-buttons {
    margin-top: 8px;
  }
}

@media (min-width: 1024px) {
  .eid-main {
    max-width: 960px;
    gap: 56px;
  }
}
