/* =====================================================
   14 August Pakistan Independence Day Poster Maker
   Design System — Premium CSS
   ===================================================== */

/* ---- Google Fonts fallback ---- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Noto+Nastaliq+Urdu:wght@400;600;700&family=Amiri:wght@400;700&display=swap');


/* ---- CSS Variables ---- */
:root {
  --pk-green:      #01411C;
  --pk-green-mid:  #025a26;
  --pk-green-lite: #037a35;
  --pk-green-glow: #0d9e4a;
  --pk-gold:       #D4AF37;
  --pk-gold-lite:  #FFD700;
  --pk-white:      #FAFAFA;
  --pk-cream:      #FFF8E8;
  --bg-dark:       #050f08;
  --bg-card:       rgba(255,255,255,0.05);
  --border-subtle: rgba(255,255,255,0.12);
  --shadow-glow:   0 0 40px rgba(1,65,28,0.6);
  --radius-lg:     16px;
  --radius-xl:     24px;
  --radius-pill:   999px;
  --font-en:       'Outfit', sans-serif;
  --font-ur:       'Noto Nastaliq Urdu', 'Amiri', serif;
  --transition:    all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-en);
  background: var(--bg-dark);
  color: var(--pk-white);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* =====================================================
   HERO HEADER
   ===================================================== */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(135deg, #020c05 0%, #01411C 40%, #025a26 70%, #010a03 100%);
  padding: 2rem 1rem 8rem;
}

/* Animated star field */
.hero-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.hero-stars .star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--dur, 3s) var(--delay, 0s) infinite ease-in-out;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.5); }
}

/* Flag stripes accents */
.flag-stripe-green,
.flag-stripe-white {
  position: absolute;
  bottom: 0;
  height: 6px;
  width: 100%;
}
.flag-stripe-green { background: var(--pk-green-lite); bottom: 6px; }
.flag-stripe-white { background: rgba(255,255,255,0.9); }

/* Crescent decoration */
.crescent-wrap {
  position: absolute;
  top: -60px;
  right: -40px;
  width: 360px;
  height: 360px;
  opacity: 0.08;
  animation: float 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
.crescent {
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 60px solid white;
  position: absolute;
  top: 40px;
  left: 20px;
  clip-path: inset(0 0 0 80px);
}
.star-symbol {
  position: absolute;
  top: 60px;
  right: 20px;
  font-size: 120px;
  color: white;
  line-height: 1;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-20px) rotate(5deg); }
}

/* Hero Content */
.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
}

.badge-pill {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-pill);
  padding: 0.4rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 1.5rem;
  animation: fadeInDown 0.8s ease both;
}

.hero-title {
  font-family: var(--font-en);
  font-size: clamp(2.8rem, 8vw, 6rem);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 1rem;
  animation: fadeInDown 0.9s 0.1s ease both;
}

.title-en {
  display: block;
  background: linear-gradient(135deg, #fff 30%, var(--pk-gold-lite) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-divider {
  display: block;
  font-size: 1.5rem;
  color: var(--pk-gold);
  margin: 0.3rem 0;
}

.title-ur {
  display: block;
  font-family: var(--font-ur);
  font-size: clamp(2rem, 6vw, 4rem);
  background: linear-gradient(135deg, var(--pk-gold-lite) 0%, #fff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  direction: rtl;
}

.hero-sub {
  font-size: clamp(0.9rem, 2.5vw, 1.15rem);
  color: rgba(255,255,255,0.75);
  max-width: 600px;
  margin: 0 auto 2rem;
  line-height: 1.8;
  animation: fadeInDown 1s 0.2s ease both;
}

.hero-cta {
  display: inline-block;
  background: linear-gradient(135deg, var(--pk-gold) 0%, #b8860b 100%);
  color: #000;
  font-family: var(--font-ur);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1rem 2.5rem;
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 32px rgba(212,175,55,0.4);
  transition: var(--transition);
  animation: fadeInDown 1.1s 0.3s ease both;
  direction: rtl;
}

.hero-cta:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 16px 48px rgba(212,175,55,0.6);
}

/* =====================================================
   MAIN SECTIONS
   ===================================================== */
main { position: relative; }

.section-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pk-gold);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.step-label span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--pk-gold);
  color: #000;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* =====================================================
   TEMPLATE GRID
   ===================================================== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 600px) {
  .templates-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .templates-grid { grid-template-columns: repeat(5, 1fr); }
}

.template-card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 3px solid transparent;
  transition: var(--transition);
  aspect-ratio: 1;
  background: var(--pk-green);
}

.template-card:hover {
  border-color: var(--pk-gold);
  transform: scale(1.04);
  box-shadow: 0 12px 40px rgba(212,175,55,0.35);
}

.template-card.active {
  border-color: var(--pk-gold-lite);
  box-shadow: 0 0 0 3px rgba(255,215,0,0.3), 0 12px 40px rgba(212,175,55,0.4);
}

.template-thumb {
  width: 100%;
  height: 100%;
  position: relative;
}

.template-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Fallback gradient backgrounds */
.fallback-t1 { background: linear-gradient(135deg, #01411C, #037a35); }
.fallback-t2 { background: linear-gradient(180deg, #2d1b69, #01411C); }
.fallback-t3 { background: linear-gradient(135deg, #fff8e8, #f0e6d3); }
.fallback-t4 { background: linear-gradient(135deg, #0a2010, #01411C, #D4AF37 200%); }

.template-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  padding: 1.5rem 0.5rem 0.5rem;
  text-align: center;
}

.template-name {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  letter-spacing: 0.05em;
}

.template-name-ur {
  display: block;
  font-family: var(--font-ur);
  font-size: 0.75rem;
  color: var(--pk-gold-lite);
  direction: rtl;
}

.check-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: var(--pk-gold-lite);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  color: #000;
  opacity: 0;
  transform: scale(0.5);
  transition: var(--transition);
}

.template-card.active .check-badge {
  opacity: 1;
  transform: scale(1);
}

/* =====================================================
   NAME INPUT
   ===================================================== */
.name-input-wrap {
  position: relative;
  max-width: 600px;
}

.lang-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
}

.lang-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  transition: var(--transition);
  flex-shrink: 0;
}

.lang-dot.urdu { background: var(--pk-green-glow); box-shadow: 0 0 8px var(--pk-green-glow); }
.lang-dot.english { background: var(--pk-gold-lite); box-shadow: 0 0 8px var(--pk-gold-lite); }

.name-input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  color: white;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-family: var(--font-en);
  padding: 1rem 1.5rem;
  outline: none;
  transition: var(--transition);
  text-align: left;
  direction: ltr;
}

.name-input:focus {
  border-color: var(--pk-gold);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 4px rgba(212,175,55,0.15);
}

.name-input.urdu-mode {
  font-family: var(--font-ur);
  text-align: right;
  direction: rtl;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.char-count {
  position: absolute;
  bottom: -1.5rem;
  right: 0;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* =====================================================
   CANVAS PREVIEW
   ===================================================== */
.canvas-container {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 80px rgba(0,0,0,0.6), 0 0 0 2px rgba(212,175,55,0.3);
  aspect-ratio: 1;
  background: var(--pk-green);
}

#posterCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  gap: 0.75rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  transition: opacity 0.3s;
  pointer-events: none;
}

.canvas-loader.hidden { opacity: 0; }

.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: var(--pk-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =====================================================
   SHARE BUTTONS
   ===================================================== */
.share-section { text-align: center; }

.share-buttons-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.btn-download,
.btn-whatsapp,
.btn-facebook {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-en);
  transition: var(--transition);
  min-width: 200px;
  justify-content: center;
}

.btn-download svg,
.btn-whatsapp svg,
.btn-facebook svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-download span,
.btn-whatsapp span,
.btn-facebook span { text-align: left; line-height: 1.3; }

.btn-download span small,
.btn-whatsapp span small,
.btn-facebook span small {
  display: block;
  font-family: var(--font-ur);
  font-size: 0.75rem;
  opacity: 0.8;
  font-weight: 400;
  direction: rtl;
}

.btn-download {
  background: linear-gradient(135deg, var(--pk-gold) 0%, #b8860b 100%);
  color: #000;
  box-shadow: 0 8px 24px rgba(212,175,55,0.35);
}
.btn-download:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(212,175,55,0.55);
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: white;
  box-shadow: 0 8px 24px rgba(37,211,102,0.3);
}
.btn-whatsapp:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(37,211,102,0.5);
}

.btn-facebook {
  background: linear-gradient(135deg, #1877F2 0%, #0d5dbf 100%);
  color: white;
  box-shadow: 0 8px 24px rgba(24,119,242,0.3);
}
.btn-facebook:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(24,119,242,0.5);
}

.share-note {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  border: 1px solid rgba(255,255,255,0.08);
  line-height: 1.8;
  max-width: 600px;
  margin: 0 auto;
  text-align: left;
}

.share-note strong { color: rgba(255,255,255,0.8); }

/* =====================================================
   FOOTER
   ===================================================== */
.site-footer {
  background: linear-gradient(180deg, transparent 0%, rgba(1,65,28,0.3) 100%);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 3rem 1.5rem;
  text-align: center;
}

.footer-flag {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  animation: float 4s ease-in-out infinite;
}

.footer-tagline {
  font-family: var(--font-ur);
  font-size: 1.1rem;
  color: var(--pk-gold-lite);
  margin-bottom: 0.25rem;
}

.footer-link {
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

.footer-link a {
  color: var(--pk-gold);
  font-weight: 600;
  border-bottom: 1px solid rgba(212,175,55,0.3);
  padding-bottom: 2px;
  transition: var(--transition);
}
.footer-link a:hover { border-color: var(--pk-gold); }

.footer-share-prompt {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  margin-top: 1rem;
  line-height: 1.8;
}

/* =====================================================
   TOAST NOTIFICATION
   ===================================================== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1a2e;
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.12);
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show { transform: translateX(-50%) translateY(0); }

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

/* Section reveal on scroll */
.section-wrap {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-wrap.visible {
  opacity: 1;
  transform: translateY(0);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 480px) {
  .share-buttons-wrap { flex-direction: column; align-items: stretch; }
  .btn-download, .btn-whatsapp, .btn-facebook { min-width: unset; width: 100%; }
  .hero { padding-bottom: 5rem; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--pk-green); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--pk-green-glow); }

/* =====================================================
   OPTIONAL BADGE
   ===================================================== */
.optional-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(212,175,55,0.18);
  color: var(--pk-gold);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.6rem;
  margin-left: 0.5rem;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* =====================================================
   PHOTO UPLOAD SECTION
   ===================================================== */
.photo-upload-area {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 600px;
}

/* Dropzone */
.photo-dropzone {
  border: 2px dashed rgba(212,175,55,0.4);
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  position: relative;
}

.photo-dropzone:hover,
.photo-dropzone:focus {
  border-color: var(--pk-gold);
  background: rgba(212,175,55,0.07);
  outline: none;
}

.photo-dropzone.drag-over {
  border-color: var(--pk-gold-lite);
  background: rgba(212,175,55,0.12);
  transform: scale(1.01);
}

.photo-dropzone.has-photo {
  border-style: solid;
  border-color: rgba(212,175,55,0.3);
  pointer-events: none;
  cursor: default;
}

/* Hidden file input */
#photoInput {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 0;
}

.photo-dropzone-content {
  position: relative;
  z-index: 1;
  padding: 2rem 1.5rem;
  text-align: center;
  pointer-events: none;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  animation: float 3s ease-in-out infinite;
}

.upload-main {
  font-family: var(--font-ur);
  font-size: 1.1rem;
  color: rgba(255,255,255,0.85);
  direction: rtl;
  margin-bottom: 0.25rem;
}

.upload-sub {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  margin-bottom: 0.5rem;
}

.upload-hint {
  font-size: 0.75rem;
  color: var(--pk-gold);
  font-weight: 600;
}

/* Photo controls (shown after upload) */
.photo-controls {
  display: none;
  align-items: center;
  gap: 1.25rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  flex-wrap: wrap;
}

.photo-thumb-wrap {
  position: relative;
  flex-shrink: 0;
}

.photo-thumb-wrap img {
  width: 90px;
  height: 90px;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
  border: 3px solid var(--pk-gold);
  display: block;
}

.remove-photo-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #c0392b;
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.remove-photo-btn:hover {
  background: #e74c3c;
  transform: scale(1.1);
}

.photo-sliders {
  flex: 1;
  min-width: 200px;
}

.slider-label {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  font-weight: 500;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.slider-icon { font-size: 0.8rem; color: rgba(255,255,255,0.5); }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pk-gold);
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.3);
  transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--pk-gold-lite);
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--pk-gold);
  cursor: pointer;
  border: 2px solid rgba(0,0,0,0.3);
}

/* =====================================================
   DRAG INSTRUCTION BANNER
   ===================================================== */
.drag-instruction {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
  background: rgba(212,175,55,0.1);
  border: 1px solid rgba(212,175,55,0.25);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.6;
}

.drag-icon {
  font-size: 1.4rem;
  color: var(--pk-gold);
  animation: float 2s ease-in-out infinite;
  display: block;
  margin-bottom: 0.2rem;
}

/* Canvas grab cursor */
#posterCanvas {
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none; /* needed for touch drag */
}

