/* =====================================================
   MODERN TOUCHES: language switch, QR dialog, social icons, responsive layout
   (shared by index.html and get.html)
   ===================================================== */

/* ---------- Language switch with animated flags ---------- */
#lang-switch { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 300; }
.lang-cur, .lang-opt {
  display: flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font: inherit; color: #4a3b34;
  -webkit-tap-highlight-color: transparent;
}
.lang-cur {
  width: 52px; height: 40px; justify-content: center; padding: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .92); box-shadow: 0 4px 14px rgba(0, 0, 0, .2), 0 0 0 2px rgba(255, 255, 255, .9);
  transition: transform .2s cubic-bezier(.3, 1.8, .5, 1), box-shadow .2s;
}
.lang-cur:hover { transform: scale(1.1) rotate(-3deg); box-shadow: 0 8px 18px rgba(0, 0, 0, .25), 0 0 0 3px #ffb3c6; }
.lang-cur svg, .lang-opt .flag svg { display: block; width: 30px; height: 20px; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }
.lang-cur svg { animation: wave 3s ease-in-out infinite; transform-origin: 0 50%; }
@keyframes wave { 0%, 100% { transform: skewY(0) scaleX(1); } 25% { transform: skewY(-4deg) scaleX(.97); } 75% { transform: skewY(4deg) scaleX(.98); } }

.lang-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 170px; padding: 8px; display: grid; gap: 4px;
  background: rgba(255, 255, 255, .96); border-radius: 18px; box-shadow: 0 14px 34px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(-8px) scale(.9); transform-origin: top right; pointer-events: none;
  transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
#lang-switch.open .lang-menu { opacity: 1; transform: none; pointer-events: auto; }
.lang-opt { width: 100%; padding: 8px 12px; border-radius: 12px; background: transparent; font-weight: 600; font-size: 15px; transition: background .15s, transform .15s; }
#lang-switch.open .lang-opt { animation: flagIn .4s cubic-bezier(.3, 1.6, .5, 1) backwards; }
#lang-switch.open .lang-opt:nth-child(1) { animation-delay: .02s; } #lang-switch.open .lang-opt:nth-child(2) { animation-delay: .07s; }
#lang-switch.open .lang-opt:nth-child(3) { animation-delay: .12s; } #lang-switch.open .lang-opt:nth-child(4) { animation-delay: .17s; }
@keyframes flagIn { from { opacity: 0; transform: translateX(16px) scale(.8); } }
.lang-opt:hover { background: #fff0f4; transform: translateX(-3px); }
.lang-opt:hover .flag svg, .lang-opt.on .flag svg { animation: wave 1.2s ease-in-out infinite; transform-origin: 0 50%; }
.lang-opt.on { background: linear-gradient(135deg, #ffe3ea, #fff0d9); box-shadow: inset 0 0 0 2px #ff8fab; }

/* ---------- Social icons ---------- */
.social-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.soc {
  --c: #888; position: relative; width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%;
  color: #fff; background: var(--c); cursor: pointer; text-decoration: none; padding: 0; box-shadow: 0 5px 12px rgba(0, 0, 0, .2);
  transition: transform .22s cubic-bezier(.3, 1.8, .5, 1), box-shadow .22s, filter .2s;
  animation: socIn .5s cubic-bezier(.3, 1.6, .5, 1) calc(var(--i, 0) * 70ms) backwards; -webkit-tap-highlight-color: transparent;
}
.soc svg { width: 24px; height: 24px; transition: transform .25s cubic-bezier(.3, 1.8, .5, 1); }
.soc:hover, .soc:focus-visible { transform: translateY(-6px) scale(1.14); box-shadow: 0 12px 20px rgba(0, 0, 0, .28), 0 0 0 4px rgba(255, 255, 255, .8); filter: brightness(1.08); outline: none; }
.soc:hover svg { transform: rotate(-10deg) scale(1.12); }
.soc:active { transform: scale(.9); }
@keyframes socIn { from { opacity: 0; transform: translateY(18px) scale(.5); } }
.soc.copied::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  background: #2b2118; color: #fff; font-size: 12px; white-space: nowrap; padding: 5px 10px; border-radius: 999px;
}

/* ---------- QR download dialog ---------- */
#qr-btn { background: linear-gradient(135deg, #2dd4bf, #0ea5e9); }
#qr-dlg {
  width: min(92vw, 420px); max-height: 92vh; overflow: auto; padding: 26px 22px 22px; border: 0; border-radius: 28px; text-align: center;
  color: #4a3b34; box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
  background: radial-gradient(circle at 15% 0, rgba(255, 201, 168, .6), transparent 45%), radial-gradient(circle at 100% 20%, rgba(200, 182, 255, .5), transparent 45%), #fffaf6;
}
#qr-dlg[open] { animation: dlgIn .45s cubic-bezier(.2, 1.4, .4, 1); }
#qr-dlg::backdrop { background: rgba(60, 25, 40, .55); backdrop-filter: blur(3px); animation: fade .3s; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(30px) scale(.9); } }
@keyframes fade { from { opacity: 0; } }
.qr-x { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #ffe9ef; color: #c2415f; font-size: 16px; cursor: pointer; transition: transform .2s cubic-bezier(.3, 1.8, .5, 1); }
.qr-x:hover { transform: rotate(90deg) scale(1.1); }
#qr-dlg h3 { margin: 0 0 4px; font-size: 24px; background: linear-gradient(90deg, #ff6b81, #ff9a56, #a855f7); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.qr-sub { margin: 0 0 16px; font-size: 14px; opacity: .8; }

#qr-box { position: relative; width: min(240px, 62vw); aspect-ratio: 1; margin: 0 auto 14px; display: grid; place-items: center; }
#qr-box::before { content: ''; position: absolute; inset: -10px; border-radius: 26px; border: 3px solid #ff8fab; opacity: 0; animation: ring 2.4s ease-out infinite; }
#qr-box.ready::before { opacity: 1; }
@keyframes ring { 0% { transform: scale(.94); opacity: .9; } 100% { transform: scale(1.12); opacity: 0; } }
.qr-card { position: absolute; inset: 0; padding: 12px; background: #fff; border-radius: 20px; box-shadow: 0 12px 30px rgba(90, 50, 30, .25); overflow: hidden; animation: qrReveal .9s cubic-bezier(.2, 1.1, .3, 1) both; }
.qr-card canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
@keyframes qrReveal { from { clip-path: circle(0% at 50% 50%); transform: scale(.8) rotate(-8deg); } to { clip-path: circle(80% at 50% 50%); transform: none; } }
.qr-scan { position: absolute; left: 12px; right: 12px; height: 4px; border-radius: 4px; top: 12px; z-index: 2;
  background: linear-gradient(90deg, transparent, #ff6b81, transparent); box-shadow: 0 0 14px 4px rgba(255, 107, 129, .55); animation: scan 2.6s ease-in-out infinite; }
@keyframes scan { 0%, 100% { top: 12px; opacity: 0; } 10% { opacity: 1; } 50% { top: calc(100% - 16px); opacity: 1; } 90% { opacity: 0; } }
.qr-corner { position: absolute; width: 26px; height: 26px; border: 4px solid #ff6b81; z-index: 3; animation: corner 1.6s ease-in-out infinite; }
.qr-corner.tl { top: 4px; left: 4px; border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.qr-corner.tr { top: 4px; right: 4px; border-left: 0; border-bottom: 0; border-radius: 0 12px 0 0; }
.qr-corner.bl { bottom: 4px; left: 4px; border-right: 0; border-top: 0; border-radius: 0 0 0 12px; }
.qr-corner.br { bottom: 4px; right: 4px; border-left: 0; border-top: 0; border-radius: 0 0 12px 0; }
@keyframes corner { 50% { transform: scale(.82); opacity: .7; } }
.qr-spin { width: 46px; height: 46px; border: 5px solid #ffd1dc; border-top-color: #ff6b81; border-radius: 50%; animation: qrspin .8s linear infinite; }
@keyframes qrspin { to { transform: rotate(360deg); } }
#qr-msg { min-height: 20px; margin: 0 0 10px; font-size: 14px; font-weight: 600; }
#qr-msg.err { color: #c2415f; }
.qr-share-h { margin: 14px 0 10px; font-size: 14px; font-weight: 700; opacity: .85; }
.qr-note { margin: 14px 0 0; font-size: 12px; opacity: .6; }

/* ---------- RESPONSIVE LAYOUT: phone -> tablet -> desktop ---------- */
html { -webkit-text-size-adjust: 100%; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
img, video { max-width: 100%; }
button, select, input[type=number] { min-height: 40px; }

/* phones */
@media (max-width: 600px) {
  #welcome-screen { padding: 28px 18px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
  #welcome-screen p { font-size: 22px; }
  #video-wrap, #video-wrap video { max-width: 100%; }
  #ar-bar { flex-wrap: nowrap !important; justify-content: flex-start !important; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  #ar-bar::-webkit-scrollbar { display: none; }
  .ar-chip { flex: 0 0 auto; scroll-snap-align: center; }
  #booth-screen > button, #booth-screen #strip-btn { width: min(92vw, 360px); margin: 8px auto 0; display: block; }
  .result-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px !important; padding: 0 6px; }
  .result-actions button { width: 100%; padding-left: 10px !important; padding-right: 10px !important; }
  #print-settings { max-width: 94vw; }
  #gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important; }
  .edit-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .edit-layout { flex-direction: column; }
  .lang-menu { min-width: 150px; }
}
/* tablets */
@media (min-width: 601px) and (max-width: 1024px) {
  #welcome-screen { width: min(78vw, 600px); }
  #result-screen { max-width: 92vw; }
  #gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important; }
}
/* big screens / kiosks */
@media (min-width: 1280px) {
  #result-screen { max-width: 980px; }
  #final-strip { width: 300px; }
  #gallery { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)) !important; }
}
/* phone held sideways */
@media (max-height: 480px) and (orientation: landscape) {
  #welcome-screen { max-height: 94vh; overflow-y: auto; padding: 16px; }
  #welcome-screen h1 { font-size: 34px; margin-bottom: 8px; }
  #qr-dlg { max-height: 96vh; }
}

@media (prefers-reduced-motion: reduce) {
  .lang-cur svg, .lang-opt .flag svg, .soc, .qr-card, .qr-scan, .qr-corner, #qr-box::before, #qr-dlg[open], #lang-switch.open .lang-opt { animation: none !important; }
  .lang-menu, .soc, .soc svg { transition: none; }
}

/* ---------- Loading overlay (film strip + dots) ---------- */
#fx-loading {
  position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 20px;
  background: rgba(255, 233, 240, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; visibility: hidden; transition: opacity .3s, visibility .3s;
}
#fx-loading.on { opacity: 1; visibility: visible; }
.fxl-card {
  min-width: 240px; max-width: 86vw; padding: 26px 32px 22px; text-align: center; border-radius: 28px;
  background: rgba(255, 255, 255, .8); border: 1.5px solid rgba(255, 255, 255, .9);
  box-shadow: 0 20px 50px rgba(150, 60, 100, .28);
  transform: scale(.9) translateY(10px); transition: transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
#fx-loading.on .fxl-card { transform: none; }
.fxl-strip { display: flex; flex-direction: column; gap: 6px; width: 54px; margin: 0 auto 14px; padding: 8px 7px; background: #4a3b34; border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .25); animation: fxlSway 2.4s ease-in-out infinite; }
.fxl-strip i { display: block; height: 22px; border-radius: 3px; background: #ffd1dc; animation: fxlFrame 1.4s ease-in-out infinite; }
.fxl-strip i:nth-child(2) { animation-delay: .18s; background: #e3c8ff; }
.fxl-strip i:nth-child(3) { animation-delay: .36s; background: #cdf5ea; }
.fxl-strip i:nth-child(4) { animation-delay: .54s; background: #ffe3cf; }
@keyframes fxlFrame { 0%, 100% { opacity: .35; transform: scaleX(.88); } 40% { opacity: 1; transform: scaleX(1); filter: brightness(1.1); } }
@keyframes fxlSway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.fxl-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 10px; }
.fxl-dots b { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #ff8fab, #c084fc); animation: fxlBounce 1s ease-in-out infinite; }
.fxl-dots b:nth-child(2) { animation-delay: .15s; } .fxl-dots b:nth-child(3) { animation-delay: .3s; }
@keyframes fxlBounce { 0%, 80%, 100% { transform: translateY(0); opacity: .6; } 40% { transform: translateY(-9px); opacity: 1; } }
.fxl-msg { margin: 0; min-height: 22px; font-size: 16px; font-weight: 700; color: #5a3b4a; }
.fxl-msg.swap { animation: fxlMsg .45s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes fxlMsg { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  .fxl-strip, .fxl-strip i, .fxl-dots b, .fxl-msg.swap { animation: none !important; }
  #fx-loading, .fxl-card { transition: none; }
}