/* ============================================
   QR Code Generator — Styles
   ============================================ */

/* --- Tokens --- */
:root {
  --bg: #0a0a0f;
  --surface: #14141f;
  --surface-2: #1e1e2e;
  --accent: #00e5a0;
  --accent-hover: #00ffb2;
  --accent-dim: rgba(0, 229, 160, 0.12);
  --accent-glow: rgba(0, 229, 160, 0.06);
  --text: #e8e8f0;
  --text-dim: #8888a0;
  --border: #2a2a3e;
  --border-focus: var(--accent);
  --radius: 16px;
  --radius-sm: 12px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', 'Fira Code', monospace;
}


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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
}

input {
  font: inherit;
  -webkit-appearance: none;
}


/* --- Base --- */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient glow */
body::before {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 30% 20%, var(--accent-glow) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}


/* --- Layout --- */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px 48px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}


/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: 40px;
  padding-top: 20px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards;
}

.header h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.1s forwards;
}

.header p {
  color: var(--text-dim);
  font-size: 15px;
  margin-top: 8px;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.2s forwards;
}


/* --- Input --- */
.input-section {
  opacity: 0;
  animation: fadeUp 0.6s ease 0.3s forwards;
}

.input-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: block;
}

.input-row {
  display: flex;
  gap: 8px;
}

.url-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 16px; /* >=16px prevents iOS zoom */
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.url-input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

.url-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.generate-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  width: 56px;
  min-width: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition);
}

.generate-btn svg {
  width: 22px;
  height: 22px;
  stroke: var(--bg);
}

.generate-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

.generate-btn:active {
  transform: scale(0.95);
}


/* --- QR Section --- */
.qr-section {
  margin-top: 32px;
  opacity: 0;
  animation: fadeUp 0.6s ease 0.4s forwards;
}

.qr-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: border-color 0.4s ease;
}

.qr-card.has-qr {
  border-color: var(--accent);
}

/* Placeholder */
.qr-placeholder {
  width: 220px;
  height: 220px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 2px dashed var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 14px;
}

.qr-placeholder svg {
  width: 40px;
  height: 40px;
  opacity: 0.3;
}

/* QR Result */
.qr-result {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

.qr-result.visible {
  display: flex;
}

.qr-frame {
  padding: 16px;
  background: #ffffff;
  border-radius: var(--radius-sm);
  width: 252px;
  height: 252px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* QRCode.js creates both canvas + img; only show canvas */
.qr-frame canvas {
  display: block !important;
  border-radius: 4px;
}

.qr-frame img {
  display: none !important;
}

.url-display {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  word-break: break-all;
  text-align: center;
  max-width: 280px;
  line-height: 1.6;
}


/* --- Size Selector --- */
.size-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.size-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  transition: all var(--transition);
}

.size-chip:hover {
  border-color: var(--text-dim);
}

.size-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}


/* --- Action Buttons --- */
.actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.action-btn {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--transition), opacity var(--transition);
}

.action-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.action-btn:hover {
  transform: translateY(-1px);
}

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

.btn-download {
  background: var(--accent);
  color: var(--bg);
}

.btn-download:hover {
  background: var(--accent-hover);
}

.btn-copy {
  background: var(--surface-2);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-copy:hover {
  border-color: var(--text-dim);
}


/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 14px;
  font-weight: 500;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
  transition:
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.4s;
}

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


/* --- Footer --- */
.footer {
  text-align: center;
  margin-top: auto;
  padding-top: 40px;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.5;
}


/* --- Animations --- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* --- Responsive --- */
@media (max-width: 400px) {
  .app {
    padding: 16px 16px 32px;
  }

  .header h1 {
    font-size: 26px;
  }

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

  .qr-frame {
    width: 232px;
    height: 232px;
  }

  .actions {
    flex-direction: column;
  }
}

/* Safe area for notch devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .app {
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
  }

  .toast {
    bottom: calc(32px + env(safe-area-inset-bottom));
  }
}
