/* ========================================
   Attachment Style Test - Chat Simulator
   Primary: #D946EF (fuchsia)
   Dark mode first, Glassmorphism 2.0
   ======================================== */

/* --- CSS Variables (Dark mode default) --- */
:root {
  --primary: #D946EF;
  --primary-rgb: 217, 70, 239;
  --primary-glow: rgba(217, 70, 239, 0.3);
  --primary-dim: rgba(217, 70, 239, 0.15);
  --bg: #0f0f1a;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-option: rgba(255, 255, 255, 0.06);
  --bg-option-hover: rgba(217, 70, 239, 0.15);
  --text: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --border: rgba(255, 255, 255, 0.1);
  --border-active: rgba(217, 70, 239, 0.5);
  --shadow: rgba(0, 0, 0, 0.3);
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-blur: 20px;
  --meter-bg: rgba(255, 255, 255, 0.1);
  --phone-bg: #1a1a2e;
  --phone-header-bg: rgba(26, 26, 46, 0.95);
  --bubble-incoming: rgba(255, 255, 255, 0.08);
  --bubble-outgoing: linear-gradient(135deg, #D946EF, #a855f7);
  --reply-bg: rgba(255, 255, 255, 0.06);
  --reply-hover: rgba(217, 70, 239, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Light mode --- */
[data-theme="light"] {
  --bg: #faf5ff;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.85);
  --bg-option: rgba(217, 70, 239, 0.06);
  --bg-option-hover: rgba(217, 70, 239, 0.12);
  --text: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #8888a0;
  --border: rgba(0, 0, 0, 0.08);
  --border-active: rgba(217, 70, 239, 0.4);
  --shadow: rgba(0, 0, 0, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 255, 255, 0.8);
  --meter-bg: rgba(217, 70, 239, 0.1);
  --phone-bg: #f8f0ff;
  --phone-header-bg: rgba(248, 240, 255, 0.95);
  --bubble-incoming: rgba(0, 0, 0, 0.05);
  --reply-bg: rgba(217, 70, 239, 0.06);
  --reply-hover: rgba(217, 70, 239, 0.15);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', 'Noto Sans JP', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* --- Skip Link (a11y) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  z-index: 10001;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 16px;
}

/* --- App Loader --- */
.app-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.app-loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  text-align: center;
}

.loader-emoji {
  font-size: 64px;
  animation: pulse 1.5s ease-in-out infinite;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  margin: 20px auto 0;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* --- Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(15, 15, 26, 0.7);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .app-header {
  background: rgba(250, 245, 255, 0.7);
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-option);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 20px;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--bg-option-hover);
  border-color: var(--border-active);
}

[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

.lang-select {
  height: 44px;
  padding: 0 12px;
  background: var(--bg-option);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
  min-width: 100px;
}

.lang-select:hover,
.lang-select:focus {
  border-color: var(--border-active);
  outline: none;
}

/* --- Container --- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

/* --- Screen States --- */
.screen {
  display: none;
  animation: fadeIn 0.5s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Glass Card --- */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: 0 8px 32px var(--shadow);
  transition: all var(--transition);
}

/* --- Start Screen --- */
.start-card {
  text-align: center;
  padding: 48px 24px;
}

.app-emoji {
  font-size: 72px;
  margin-bottom: 16px;
  animation: floatEmoji 3s ease-in-out infinite;
}

@keyframes floatEmoji {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.badge {
  display: inline-block;
  background: var(--primary-dim);
  color: var(--primary);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.start-card h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 8px;
  line-height: 1.5;
}

.description {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.info-chips {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg-option);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
}

.disclaimer {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 28px;
  font-style: italic;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 44px;
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px var(--primary-glow);
}

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

.btn-share {
  background: var(--bg-option);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 14px;
  padding: 10px 20px;
}

.btn-share:hover {
  background: var(--bg-option-hover);
  border-color: var(--border-active);
}

.btn-twitter {
  background: rgba(29, 155, 240, 0.15);
  color: #1d9bf0;
  border-color: rgba(29, 155, 240, 0.3);
}

.btn-twitter:hover {
  background: rgba(29, 155, 240, 0.25);
}

/* ======================================
   PHONE / CHAT SIMULATOR
   ====================================== */

.phone-frame {
  background: var(--phone-bg);
  border-radius: 32px;
  border: 2px solid var(--border);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  max-height: 700px;
  min-height: 500px;
  position: relative;
}

[data-theme="light"] .phone-frame {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.phone-notch {
  width: 120px;
  height: 28px;
  background: var(--bg);
  border-radius: 0 0 16px 16px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

[data-theme="light"] .phone-notch {
  background: #1a1a2e;
}

.phone-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  margin-top: -20px;
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.status-signal, .status-battery {
  width: 16px;
  height: 11px;
}

.phone-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--phone-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.phone-contact {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.phone-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.phone-contact-info {
  display: flex;
  flex-direction: column;
}

.phone-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.phone-online {
  font-size: 11px;
  color: #34d399;
  font-weight: 500;
}

.phone-counter {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-option);
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* --- Chat Area --- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
  width: 4px;
}

.chat-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* --- Chat Context (scenario label) --- */
.chat-context {
  text-align: center;
  padding: 8px 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.chat-context span {
  background: var(--bg-option);
  padding: 3px 12px;
  border-radius: 10px;
}

/* --- Chat Bubbles --- */
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  animation: bubbleIn 0.3s ease;
  word-wrap: break-word;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble-incoming {
  align-self: flex-start;
  background: var(--bubble-incoming);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.bubble-outgoing {
  align-self: flex-end;
  background: var(--bubble-outgoing);
  border-bottom-right-radius: 4px;
  color: #fff;
}

/* --- Typing Indicator --- */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
  background: var(--bubble-incoming);
  border: 1px solid var(--border);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  animation: bubbleIn 0.3s ease;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Reply Area --- */
.reply-area {
  padding: 12px 16px 16px;
  background: var(--phone-header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.reply-hint {
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.reply-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reply-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--reply-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.reply-btn:hover {
  background: var(--reply-hover);
  border-color: var(--border-active);
  transform: translateX(4px);
}

.reply-btn:active {
  transform: translateX(2px);
}

.reply-btn.selected {
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  border-color: var(--primary);
  transform: translateX(0);
}

.reply-btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.reply-options.hidden {
  display: none;
}

/* --- Sent message animation --- */
.bubble-sending {
  animation: sendMessage 0.4s ease forwards;
}

@keyframes sendMessage {
  0% { opacity: 0.7; transform: translateY(20px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ======================================
   RESULT SCREEN
   ====================================== */

.result-card {
  text-align: center;
}

.result-reveal {
  margin-bottom: 28px;
}

.result-emoji {
  font-size: 80px;
  margin-bottom: 12px;
  animation: resultBounce 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

@keyframes resultBounce {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.result-type {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: typeReveal 0.6s ease 0.3s both;
}

@keyframes typeReveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-label {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  animation: typeReveal 0.6s ease 0.5s both;
}

/* --- Attachment Meter --- */
.attachment-meter {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-option);
  border-radius: var(--radius-sm);
  animation: fadeInUp 0.5s ease 0.5s both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.attachment-meter h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.meter-container {
  position: relative;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  margin-bottom: 6px;
}

.meter-labels-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 0;
}

.meter-bar {
  width: 100%;
  height: 12px;
  background: var(--meter-bg);
  border-radius: 6px;
  position: relative;
  overflow: visible;
}

.meter-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  background: var(--primary);
  border: 3px solid var(--text);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px var(--primary-glow);
  transition: left 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Result Details --- */
.result-details {
  text-align: left;
  margin-top: 24px;
}

.result-section {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg-option);
  border-radius: var(--radius-sm);
  animation: fadeInUp 0.5s ease both;
}

.result-section:nth-child(1) { animation-delay: 0.6s; }
.result-section:nth-child(2) { animation-delay: 0.7s; }
.result-section:nth-child(3) { animation-delay: 0.8s; }
.result-section:nth-child(4) { animation-delay: 0.9s; }
.result-section:nth-child(5) { animation-delay: 1.0s; }

.result-section h3 {
  font-size: 14px;
  color: var(--primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.traits-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.traits-list li {
  background: var(--primary-dim);
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(var(--primary-rgb), 0.2);
}

#result-partner,
#result-advice {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.secondary-type p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* --- Result Actions --- */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 28px;
}

/* --- Cross-promo --- */
#cross-promo-container {
  margin-top: 32px;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

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

/* --- Responsive --- */
@media (max-width: 480px) {
  .container {
    padding: 16px 8px 60px;
  }

  .glass-card {
    padding: 24px 16px;
  }

  .start-card {
    padding: 36px 16px;
  }

  .start-card h1 {
    font-size: 24px;
  }

  .app-emoji {
    font-size: 56px;
  }

  .phone-frame {
    border-radius: 24px;
    height: calc(100vh - 120px);
    max-height: 640px;
  }

  .phone-notch {
    width: 100px;
    height: 24px;
  }

  .chat-bubble {
    max-width: 85%;
    font-size: 13px;
  }

  .reply-btn {
    font-size: 12px;
    padding: 8px 12px;
  }

  .result-emoji {
    font-size: 64px;
  }

  .result-actions {
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .loader-emoji,
  .app-emoji,
  .typing-dot {
    animation: none;
  }

  .meter-indicator,
  .progress-fill {
    transition-duration: 0.01ms !important;
  }
}
