/* ================================================================
   Kaden Eid Al-Fitr Card — styles.css
   Brand:  60% #353737 | 30% #9B6F1F | 10% #DABC79
   ================================================================ */

:root {
  /* ── CSS controls read by app.js ── */
  --mobile-name-scale-tablet: 0.78;
  --mobile-name-scale-phone:  0.62;
  --name-min-font-size: 20;

  /* ── Name on card ── */
  --name-x:            50;
  --name-y:            83;
  --name-max-width:    72;
  --name-align:        center;
  --name-font-size:    68;
  --name-color:        #FFFFFF;
  --name-stroke-width: 0;
  --name-stroke-color: rgba(0,0,0,0.4);
  --name-shadow-color: rgba(0,0,0,0.55);
  --name-shadow-blur:  10;

  /* ── Brand ── */
  --c60:   #353737;
  --c30:   #9B6F1F;
  --c10:   #DABC79;
  --c10d:  #C9A855;   /* slightly darker gold */
  --c10bg: rgba(218,188,121,0.12);
  --c30bg: rgba(155,111,31,0.18);
}

/* ── Arabic font ── */
@font-face {
  font-family: "Jali Arabic Medium";
  src: url("./assets/JaliArabicMedium.ttf") format("truetype");
  font-display: swap;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  min-height: 100%;
  /* 60% base with Islamic 8-pointed star pattern */
  background-color: var(--c60);
  background-image:
    radial-gradient(ellipse 70% 50% at 50% 45%, rgba(155,111,31,0.1) 0%, transparent 70%),
    url("data:image/svg+xml,%3Csvg width='80' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolygon points='40%2C22 43%2C33 53%2C27 47%2C37 58%2C40 47%2C43 53%2C53 43%2C47 40%2C58 37%2C47 27%2C53 33%2C43 22%2C40 33%2C37 27%2C27 37%2C33' fill='%239B6F1F' fill-opacity='0.09'/%3E%3C/svg%3E");
  color: var(--c10);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  overflow-x: hidden;
}

/* ================================================================
   PARTICLE CANVAS (full screen, pointer-none)
   ================================================================ */
#particleCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  pointer-events: none;
}

/* ================================================================
   DECORATIONS LAYER
   ================================================================ */
.deco-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* ── Balloons ── */
.bwrap {
  position: absolute;
  bottom: -160px;
  animation: floatBalloon ease-in-out infinite;
}
.bw1 { left:  4%; animation-duration: 15s; animation-delay:  0s;  }
.bw2 { left: 14%; animation-duration: 19s; animation-delay:  4s;  }
.bw3 { left: 27%; animation-duration: 14s; animation-delay:  1.5s;}
.bw4 { left: 55%; animation-duration: 21s; animation-delay:  7s;  }
.bw5 { left: 70%; animation-duration: 16s; animation-delay:  2.5s;}
.bw6 { left: 86%; animation-duration: 18s; animation-delay:  9s;  }

@keyframes floatBalloon {
  0%   { transform: translateY(0) translateX(0);   opacity: 0; }
  6%   { opacity: 1; }
  50%  { transform: translateY(-55vh) translateX(14px); }
  94%  { opacity: 1; }
  100% { transform: translateY(-112vh) translateX(-6px); opacity: 0; }
}

.balloon {
  position: relative;
  width: 42px;
  height: 52px;
  border-radius: 50% 50% 50% 50% / 55% 55% 45% 45%;
  filter: blur(1px);
  opacity: 0.5;
  animation: sway ease-in-out 4.5s infinite alternate;
}
@keyframes sway {
  0%   { transform: rotate(-6deg); }
  100% { transform: rotate(6deg);  }
}

/* Knot (triangle) */
.knot {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left:  5px solid transparent;
  border-right: 5px solid transparent;
}
/* String */
.string {
  position: absolute;
  bottom: -42px;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px;
  height: 36px;
  background: rgba(218,188,121,0.2);
}

/* Brand-colored balloons */
.b-gold1   { background: #DABC79; }  .k1 { border-top: 7px solid #b09050; }
.b-bronze  { background: #9B6F1F; }  .k2 { border-top: 7px solid #6a4c14; }
.b-cream   { background: #E8D4A0; }  .k3 { border-top: 7px solid #bfaa75; }
.b-dark    { background: #4A3B1F; }  .k4 { border-top: 7px solid #2a2210; }
.b-gold2   { background: #C4A052; }  .k5 { border-top: 7px solid #9a7a35; }
.b-bronze2 { background: #7A5A16; }  .k6 { border-top: 7px solid #4a360c; }

/* Vary balloon sizes */
.bw1 .balloon, .bw5 .balloon { width: 48px; height: 60px; }
.bw3 .balloon                { width: 36px; height: 44px; }
.bw4 .balloon                { width: 54px; height: 66px; }

/* ── Crescent moons ── */
.cr {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  box-shadow: -7px 3px 0 5px rgba(218,188,121,0.4);
  animation: driftCrescent ease-in-out infinite alternate;
}
.cr1 { top: 12%; left:  6%; animation-duration:  9s; animation-delay: 0s; transform: rotate(-20deg); }
.cr2 { top: 28%; right: 5%; animation-duration: 12s; animation-delay: 3s; transform: rotate(15deg); width: 18px; height: 18px; box-shadow: -6px 2px 0 4px rgba(218,188,121,0.35); }
.cr3 { top: 65%; left:  9%; animation-duration: 10s; animation-delay: 6s; transform: rotate(-30deg); width: 16px; height: 16px; box-shadow: -5px 2px 0 3px rgba(218,188,121,0.3); }
@keyframes driftCrescent {
  0%   { transform: translateY(0)    rotate(-20deg); }
  100% { transform: translateY(-18px) rotate(-25deg); }
}

/* ── 4-pointed stars ── */
.star4 {
  position: absolute;
  background: var(--c10);
  clip-path: polygon(50% 0%, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0% 50%, 38% 38%);
  animation: twinkle ease-in-out infinite;
  opacity: 0.45;
}
.s1 { width: 10px; height: 10px; top: 20%; right: 10%; animation-duration: 3.5s; animation-delay: 0s; }
.s2 { width:  7px; height:  7px; top: 50%; left: 3%;   animation-duration: 4.2s; animation-delay: 1.5s; }
.s3 { width:  9px; height:  9px; top: 75%; right: 7%;  animation-duration: 3s;   animation-delay: 2.8s; }
@keyframes twinkle {
  0%, 100% { opacity: 0.45; transform: scale(1) rotate(0deg); }
  50%       { opacity: 0.9;  transform: scale(1.25) rotate(22.5deg); }
}

/* ================================================================
   PAGE (centered column, z above decorations)
   ================================================================ */
.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 28px;
}

/* ================================================================
   TOP BAR
   ================================================================ */
.topbar {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
}

.logo-wrap {
  flex: 1;
  max-width: 200px;
}
#kadenLogo {
  display: block;
  width: 100%;
  height: auto;
  /* 10% opacity reduction to feel integrated, not screaming */
  opacity: 0.92;
  animation: logoFadeIn 0.8s ease forwards;
}
@keyframes logoFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 0.92; transform: translateY(0); }
}

.lang-btn {
  background: rgba(155,111,31,0.18);
  border: 1px solid rgba(218,188,121,0.28);
  color: var(--c10);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .3px;
  transition: .22s ease;
  flex-shrink: 0;
}
.lang-btn:hover {
  background: var(--c30bg);
  border-color: var(--c10);
}

/* ================================================================
   CARD STAGE
   ================================================================ */
.card-stage {
  width: 100%;
  max-width: 500px;
  margin-top: 6px;
  animation: cardSlideUp 0.7s cubic-bezier(0.22,1,0.36,1) forwards;
  animation-delay: 0.15s;
  opacity: 0;
}
@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 3D tilt container */
.card-tilt {
  transform-style: preserve-3d;
  transition: transform 0.25s ease;
  will-change: transform;
}

/* Inner card wrapper */
.card-inner {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(218,188,121,0.25),
    0 1px 0 rgba(218,188,121,0.1),
    0 24px 64px rgba(0,0,0,0.65),
    0 6px 20px rgba(0,0,0,0.4);
  transition: box-shadow 0.3s ease;
}

/* Glow pulse when name first typed */
.card-inner.name-glow {
  animation: nameGlow 0.7s ease forwards;
}
@keyframes nameGlow {
  0%   { box-shadow: 0 0 0 1px rgba(218,188,121,0.25), 0 24px 64px rgba(0,0,0,0.65); }
  45%  { box-shadow: 0 0 0 3px rgba(218,188,121,0.6), 0 0 40px rgba(218,188,121,0.25), 0 24px 64px rgba(0,0,0,0.65); }
  100% { box-shadow: 0 0 0 1px rgba(218,188,121,0.25), 0 24px 64px rgba(0,0,0,0.65); }
}

#cardCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: #2a2216;
}

/* ── Shimmer sweep ── */
.card-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    108deg,
    transparent 30%,
    rgba(218,188,121,0.10) 48%,
    rgba(255,240,180,0.08) 52%,
    transparent 70%
  );
  background-size: 250% 100%;
  background-position: -100% 0;
  animation: shinePass 7s ease-in-out infinite;
  animation-delay: 2s;
  border-radius: 18px;
}
@keyframes shinePass {
  0%, 100% { background-position: -100% 0; opacity: 0; }
  10%       { opacity: 1; }
  45%       { background-position: 200% 0;  opacity: 1; }
  55%       { opacity: 0; }
}

/* ================================================================
   CONTROLS
   ================================================================ */
.controls {
  width: 100%;
  max-width: 500px;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  animation: fadeIn 0.6s ease forwards;
  animation-delay: 0.4s;
  opacity: 0;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Rounded white input */
.field-wrap {
  width: 100%;
  position: relative;
}
#nameInput {
  width: 100%;
  background: #ffffff;
  border: 2px solid rgba(155,111,31,0.2);
  border-radius: 14px;
  padding: 0 18px;
  height: 54px;
  color: #1E1A0E;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: .3px;
  caret-color: var(--c30);
  transition: border-color .25s ease, box-shadow .25s ease;
  /* Font set dynamically by JS per language */
  font-family: "Jali Arabic Medium", "Cairo", Arial, sans-serif;
}
#nameInput::placeholder {
  color: rgba(53,55,55,0.35);
  font-weight: 600;
  /* placeholder font matches input direction — JS sets it */
  font-family: inherit;
}
#nameInput:focus {
  outline: none;
  border-color: var(--c30);
  box-shadow: 0 0 0 4px rgba(155,111,31,0.14), 0 2px 12px rgba(0,0,0,0.1);
}

/* Gold bar not needed anymore — remove */
.field-bar { display: none; }

/* Download button */
.dl-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 52px;
  padding: 0 36px;
  background: linear-gradient(135deg, #DABC79 0%, #9B6F1F 100%);
  border: none;
  border-radius: 14px;
  color: #1E1A0E;        /* dark text on gold = premium contrast */
  font-family: inherit;
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: .2px;
  cursor: pointer;
  transition: transform .22s ease, box-shadow .22s ease, filter .22s ease;
  box-shadow: 0 6px 22px rgba(155,111,31,0.45), 0 2px 6px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}
/* Internal shimmer on button */
.dl-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.18) 50%, transparent 60%);
  background-size: 200% 100%;
  background-position: -100% 0;
  transition: background-position .5s ease;
}
.dl-btn:hover::after { background-position: 100% 0; }
.dl-btn:hover  { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(155,111,31,0.55); }
.dl-btn:active { transform: translateY(0);    box-shadow: 0 4px 12px rgba(155,111,31,0.35); }
.dl-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.dl-icon { flex-shrink: 0; }

/* Button "done" flash */
.dl-btn.dl-done {
  background: linear-gradient(135deg, #b0e8b0 0%, #4a9a4a 100%);
}

.hint {
  color: rgba(218,188,121,0.35);
  font-size: .84rem;
  text-align: center;
  line-height: 1.5;
}

/* ================================================================
   FOOTER
   ================================================================ */
.foot {
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(218,188,121,0.3);
  font-size: .82rem;
  letter-spacing: .3px;
}
.foot-diamond {
  font-size: .5rem;
  opacity: .5;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 540px) {
  .page     { padding: 0 12px 22px; }
  .topbar   { padding: 14px 0 12px; }
  .logo-wrap { max-width: 160px; }
  .card-stage, .controls { max-width: 100%; }
  .dl-btn   { padding: 0 24px; height: 48px; font-size: .95rem; }
  #nameInput { font-size: 1.15rem; }
  /* smaller balloons on mobile */
  .bw4 .balloon { width: 40px; height: 50px; }
}

@media (max-width: 380px) {
  #nameInput { font-size: 1.05rem; }
  .dl-btn    { padding: 0 18px; }
}

/* ── LTR layout override ── */
html[dir="ltr"] #nameInput { text-align: center; }
html[dir="ltr"] .logo-wrap { max-width: 200px; }
