/* 梗圖產生器 v2 - 直接從製圖器開始 */

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

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #10427E;
}

/* Allow scroll for meme generator */
html.meme-active,
html.meme-active body {
  overflow: auto;
  height: auto;
  min-height: 100%;
}

#root {
  width: 100%;
  min-height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background: #10427E;
}

/* ══════════════════════════════════════════════════════════════════════════
   MEME GENERATOR SECTION
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Meme Generator Container ── */
.meme-generator {
  display: none;
  position: relative;
  width: 100%;
  min-height: 100%;
  background: #10427E;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 100px;
}

.meme-generator.show {
  display: block;
}

/* ── Meme Page ── */
.meme-page {
  width: 100%;
  position: relative;
  padding-bottom: 20px;
}

/* ── Hero Content ── */
.meme-hero-content {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  overflow: visible;
}

.meme-hero-bg {
  width: 100%;
}

.meme-hero-bg > img {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Form Overlay ── */
.meme-form-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: visible;
}

.meme-form-overlay > * {
  pointer-events: auto;
  touch-action: pan-y;
}

/* ── Capture Area (for screenshot) ── */
.meme-capture-area {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

/* ── Nickname Input ── */
.meme-nickname-input {
  position: absolute;
  top: 58%;
  left: 5%;
  right: 5%;
}

.meme-input-field {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  font-size: 16px;
  color: #333;
  outline: none;
}

.meme-input-field::placeholder {
  color: #aaa;
}

/* ── Photo Section ── */
.meme-photo-section {
  position: absolute;
  top: 70%;
  left: 5%;
  right: 18%;
}

.meme-avatar-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(to right, black 85%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  padding-right: 10px;
}

.meme-avatar-row::-webkit-scrollbar {
  display: none;
}

.meme-avatar-option {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s;
  background: #ccc;
  flex-shrink: 0;
}

.meme-avatar-option:hover,
.meme-avatar-option.selected {
  border-color: #5B9BD5;
}

.meme-avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Upload Button ── */
.meme-upload-btn {
  position: absolute;
  top: 70%;
  right: 5%;
  height: 28px;
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
  transform: translateY(7px);
}

.meme-upload-btn img {
  height: 100%;
  width: auto;
  display: block;
}

.meme-upload-btn:hover {
  opacity: 0.8;
}

/* ── Slogan Section ── */
.meme-slogan-section {
  position: absolute;
  top: 81%;
  left: 5%;
  right: 5%;
  overflow: visible;
}

/* ── Custom Select ── */
.meme-custom-select {
  position: relative;
  width: 100%;
  overflow: visible;
}

.meme-custom-select-trigger {
  width: 100%;
  padding: 12px 36px 12px 14px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  font-size: 16px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meme-custom-select-trigger::after {
  content: '▼';
  font-size: 10px;
  color: #666;
  margin-left: 8px;
}

.meme-custom-select.open .meme-custom-select-trigger::after {
  content: '▲';
}

.meme-custom-select-trigger.placeholder {
  color: #aaa;
}

.meme-custom-select-options {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
  display: none;
}

.meme-custom-select.open .meme-custom-select-options {
  display: block;
}

.meme-custom-select-option {
  padding: 12px 14px;
  cursor: pointer;
  font-size: 16px;
  color: #333;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meme-custom-select-option:last-child {
  border-bottom: none;
}

.meme-custom-select-option:hover {
  background: #f5f5f5;
}

.meme-custom-select-option.selected {
  color: #FF85A2;
}

/* ── User Photo Display ── */
.meme-user-photo {
  position: absolute;
  top: 16.5%;
  left: 12%;
  width: 63%;
  aspect-ratio: 1 / 1;
  pointer-events: auto;
  z-index: 1;
  overflow: hidden;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
}

.meme-user-photo:active {
  cursor: grabbing;
}

.meme-user-photo-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}

.meme-user-photo img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* ── Zoom Control ── */
.meme-zoom-control {
  position: absolute;
  top: 50%;
  left: 43.5%;
  transform: translateX(-50%);
  width: 55%;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 4;
}

.meme-zoom-label {
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
}

.meme-zoom-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  touch-action: none;
}

.meme-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FF85A2;
  cursor: pointer;
  border: 2px solid #fff;
}

.meme-zoom-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FF85A2;
  cursor: pointer;
  border: 2px solid #fff;
}

/* ── Template Preview ── */
.meme-template-preview {
  position: absolute;
  top: 10.5%;
  left: 12%;
  width: 63%;
  height: auto;
  pointer-events: none;
  z-index: 10;
}

.meme-template-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

/* ── Name Display ── */
.meme-user-name-display {
  position: absolute;
  top: 11.7%;
  left: 1.5%;
  width: 63%;
  text-align: center;
  pointer-events: none;
  z-index: 15;
}

.meme-user-name-display span {
  color: #41413f;
  font-family: "Noto Sans TC", "PingFang TC", -apple-system, sans-serif;
  font-weight: 700;
  font-size: 16px;
}

/* ── Slogan Display ── */
.meme-user-slogan-display {
  position: absolute;
  top: 15.62%;
  left: 13%;
  width: 63%;
  text-align: center;
  pointer-events: none;
  z-index: 15;
}

.meme-user-slogan-display span {
  color: #005aee;
  font-family: "Noto Sans TC", "PingFang TC", -apple-system, sans-serif;
  font-weight: 700;
  font-size: 14px;
}

/* ── Custom Slogan Input ── */
.meme-custom-slogan-input {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  font-size: 16px;
  color: #333;
  outline: none;
  margin-top: 8px;
}

.meme-custom-slogan-input::placeholder {
  color: #aaa;
}

/* ── Type Selector ── */
.meme-type-selector {
  position: absolute;
  top: 21%;
  right: 9.5%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meme-type-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.meme-type-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.meme-type-btn:hover {
  transform: scale(1.1);
}

/* ── Change Button ── */
.meme-change-btn {
  position: absolute;
  top: 38%;
  right: 9%;
  width: 38px;
  height: auto;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

.meme-change-btn.animated {
  animation: memeChangePulse 1.2s ease-in-out infinite;
}

.meme-change-btn img {
  width: 100%;
  height: auto;
  display: block;
}

@media (hover: hover) {
  .meme-change-btn:hover {
    animation-play-state: paused;
    transform: scale(1.1);
  }
}

@keyframes memeChangePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ── Generate Button ── */
.meme-generate-btn {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  padding: 8px 20px 12px;
  margin: 0;
  background: #ffffff;
  border: none;
  cursor: pointer;
  z-index: 250;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.meme-generator.show ~ .meme-generate-btn,
.meme-generate-btn.show {
  display: block;
}

.meme-generate-btn img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* ── Validation Toast ── */
.meme-validation-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.meme-validation-toast.show {
  opacity: 1;
}

/* ── Result Lottie Overlay ── */
.meme-result-overlay {
  position: fixed;
  inset: 0;
  background: #10427E;
  z-index: 400;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.meme-result-overlay.show {
  display: flex;
}

.meme-result-container {
  position: relative;
  width: 100%;
  max-width: 430px;
}

.meme-result-bg {
  width: 100%;
  display: block;
  pointer-events: none;  /* 防止長按存到背景圖 */
}

.meme-result-image {
  position: absolute;
  top: calc(14.5% - 2.5px);
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  border-radius: 2px;
}

.meme-share-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: -100px;
  padding: 0 20px;
  padding-left: 175px;
  position: relative;
  z-index: 10;
}

.meme-share-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.meme-share-btn img {
  height: 48px;
  width: auto;
  pointer-events: none;  /* 防止長按存到按鈕圖片 */
}

#iosShareBtn {
  position: absolute;
  bottom: 45px;
  left: 50%;
  transform: translateX(-50%);
}

#iosShareBtn img {
  height: 95px;
}

/* Android share button - adjust to match iOS visual size */
#iosShareBtn.android {
  bottom: 45px;
}

#iosShareBtn.android img {
  height: 85px;
}

#copyLinkBtn img,
#shareIgBtn img {
  height: 34px;
}

/* iOS version */
#copyLinkBtn {
  margin-right: 15px;
  transform: translate(-5px, -45px);
}

#shareIgBtn {
  margin-left: 5px;
  transform: translate(-28px, -45px);
}

/* Android/Web version */
#copyLinkBtn.android {
  transform: translate(-5px, -32px);
}

#shareIgBtn.android {
  transform: translate(-30px, -32px);
}
