/* TrickerAI web — shared tokens and components (original app styling). */

:root {
  --bg: #faf7f4;
  --surface: #ffffff;
  --surface-muted: #f3eee8;
  --charcoal: #1a1c22;
  --charcoal-soft: #2e313a;
  --text: #1a1c22;
  --text-2: #8c8480;
  --text-3: #b6afa9;
  --text-on-dark: #fdfbfa;
  --accent: #7b5cfa;
  --accent-dark: #6242d9;
  --accent-soft: #e4ddfb;
  --accent-tint: #f3f0fd;
  --sparkle: #ff6f5e;
  --border: #efe7e1;
  --border-strong: #e3d9d1;
  --danger: #e5484d;
  --success: #3eae6b;
  --scrim: rgba(20, 16, 14, 0.38);

  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 16px;
  --s-lg: 20px;
  --s-xl: 24px;
  --s-xxl: 32px;
  --s-xxxl: 40px;

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-squircle: 16px;
  --r-pill: 999px;

  --sh-soft: 0 4px 14px rgba(26, 28, 34, 0.04);
  --sh-card: 0 6px 18px rgba(26, 28, 34, 0.06);
  --sh-button: 0 6px 14px rgba(26, 28, 34, 0.1);
  --sh-accent: 0 8px 16px rgba(98, 66, 217, 0.28);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

img {
  display: block;
  -webkit-user-drag: none;
}

input,
textarea {
  font: inherit;
  color: inherit;
}

ion-icon {
  display: block;
  flex-shrink: 0;
}

/* ---------- Stage ----------
   Phones: the app fills the screen edge to edge.
   Larger screens: the same app as a full-height centered column on the same
   background — no phone frame, no rounded corners, no device chrome. */

#stage {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

#device {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

#screens,
#overlays {
  position: absolute;
  inset: 0;
}

#overlays {
  pointer-events: none;
  z-index: 50;
}

#overlays > * {
  pointer-events: auto;
}

/* ---------- Screens + transitions ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.screen .scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.screen .scroll::-webkit-scrollbar,
.hscroll::-webkit-scrollbar {
  display: none;
}

/* Installed (home-screen) app: an opaque strip behind the iOS status bar so
   scrolling content never shows through it, like a native navigation bar. */
.screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--safe-top);
  background: var(--bg);
  z-index: 20;
  pointer-events: none;
}

.safe-top {
  padding-top: calc(var(--safe-top) + 8px);
}

.safe-bottom {
  padding-bottom: calc(var(--safe-bottom) + 8px);
}

.hscroll {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.anim-push-in {
  animation: pushIn 0.34s var(--ease-out) both;
  z-index: 2;
}
.anim-push-out {
  animation: pushOut 0.3s var(--ease-out) both;
  z-index: 2;
}
.anim-modal-in {
  animation: modalIn 0.38s var(--ease-out) both;
  z-index: 2;
}
.anim-modal-out {
  animation: modalOut 0.3s var(--ease-out) both;
  z-index: 2;
}
.anim-fade-in {
  animation: fadeIn 0.28s ease both;
}

@keyframes pushIn {
  from {
    transform: translateX(100%);
  }
  to {
    transform: none;
  }
}
@keyframes pushOut {
  from {
    transform: none;
  }
  to {
    transform: translateX(100%);
  }
}
@keyframes modalIn {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}
@keyframes modalOut {
  from {
    transform: none;
  }
  to {
    transform: translateY(100%);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Typography ---------- */

.t-display {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.6px;
}
.t-h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.t-h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.t-h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.t-body {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
}
.t-body-medium {
  font-size: 15px;
  font-weight: 600;
}
.t-caption {
  font-size: 13px;
  font-weight: 500;
}
.t-small {
  font-size: 11px;
  font-weight: 600;
}
.muted {
  color: var(--text-2);
}
.faint {
  color: var(--text-3);
}
.center {
  text-align: center;
}

/* ---------- Pressable ---------- */

.pressable {
  transition: transform 0.35s var(--spring), opacity 0.2s ease;
  touch-action: manipulation;
}
.pressable.is-pressed {
  transition: transform 0.12s ease-out;
  transform: scale(var(--press-scale, 0.95));
}

/* ---------- Buttons ---------- */

.btn {
  height: 56px;
  width: 100%;
  border-radius: var(--r-pill);
  padding: 0 var(--s-xl);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.btn ion-icon {
  font-size: 18px;
}
.btn-dark {
  background: var(--charcoal);
  color: var(--text-on-dark);
  box-shadow: var(--sh-button);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--sh-accent);
}
.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--charcoal);
}
.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
}
.btn[disabled],
.btn.is-loading {
  opacity: 0.45;
  pointer-events: none;
}
.btn .spinner {
  border-color: currentColor;
  border-right-color: transparent;
}

.icon-btn {
  width: var(--size, 44px);
  height: var(--size, 44px);
  border-radius: var(--r-squircle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--icon, 20px);
  color: var(--text);
}
.icon-btn.round {
  border-radius: 50%;
}
.icon-btn-surface {
  background: var(--surface);
  box-shadow: var(--sh-soft);
}
.icon-btn-transparent {
  background: rgba(255, 255, 255, 0.9);
}
.icon-btn-dark {
  background: var(--charcoal);
  color: var(--text-on-dark);
}
.icon-btn-accent {
  background: var(--accent);
  color: #fff;
}
.icon-btn-tinted {
  background: var(--accent-tint);
  color: var(--accent-dark);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--text);
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- App header ---------- */

.app-header {
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-lg);
  margin-bottom: var(--s-lg);
  flex-shrink: 0;
}
.app-header .side {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  min-width: 44px;
  display: flex;
}
.app-header .side.right {
  justify-content: flex-end;
}
/* Truly centered regardless of what's on either side. */
.app-header .wordmark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}
.app-header .wordmark img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.app-header .wordmark span {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.pro-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: #fff;
  padding: 6px 8px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 700;
  margin-left: -8px;
  white-space: nowrap;
}
.pro-pill ion-icon {
  font-size: 12px;
}

/* ---------- Bottom bar ---------- */
/* Full-width tab bar pinned to the bottom: Home | raised camera "Create" | Profile.
   Solid white surface with rounded top corners and a soft shoulder around the
   raised center button. */

.bottom-bar {
  --bar-h: 64px;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -6px 22px rgba(26, 28, 34, 0.07);
}
.bottom-bar .bar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  height: var(--bar-h);
}
.bottom-bar .tab {
  position: relative;
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  -webkit-tap-highlight-color: transparent;
}
.bottom-bar .tab-icon {
  width: 52px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-pill);
  font-size: 22px;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.bottom-bar .tab-label {
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.1px;
  white-space: nowrap;
}
.bottom-bar .tab.active {
  color: var(--accent);
}
.bottom-bar .tab.active .tab-icon {
  background: var(--accent-tint);
}

/* Center "Create": a raised accent circle overlapping the bar's top edge,
   its label on the same baseline as the other tabs. */
.bottom-bar .tab-create {
  justify-content: flex-end;
  padding-bottom: 9px;
  color: var(--text-2);
}
.bottom-bar .tab-create.active {
  color: var(--accent);
}
.bottom-bar .tab-create::before {
  /* Shoulder: a white disc behind the button, clipped to the part above the bar. */
  content: '';
  position: absolute;
  left: 50%;
  top: -30px;
  width: 80px;
  height: 80px;
  margin-left: -40px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 -6px 22px rgba(26, 28, 34, 0.07);
  clip-path: inset(-30px -30px 50px -30px);
  pointer-events: none;
}
.bottom-bar .tab-create .tab-icon {
  position: absolute;
  left: 50%;
  top: -22px;
  width: 60px;
  height: 60px;
  margin-left: -30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  box-shadow: var(--sh-accent);
}
.bottom-bar .tab-create.active .tab-icon {
  background: var(--accent);
}
/* Hit area covers the raised circle too. */
.bottom-bar .tab-create::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -24px;
  bottom: 0;
  width: 72px;
  margin-left: -36px;
}

/* Invisible 44px+ hit area around the visually smaller pro pill. */
.pro-pill {
  position: relative;
}
.pro-pill::after {
  content: '';
  position: absolute;
  inset: -8px -4px;
}

/* Space so content can scroll clear of the bar (and the raised button). */
.bottom-bar-spacer {
  height: calc(var(--safe-bottom) + 96px);
  flex-shrink: 0;
}

/* ---------- Template card ---------- */

.tpl-card {
  position: relative;
  flex: 1;
  min-width: 0;
  height: var(--h, 168px);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: var(--s-sm);
  background: var(--surface-muted);
  box-shadow: var(--sh-card);
  --press-scale: 0.96;
  animation: fadeIn 0.32s ease both;
  text-align: left;
}
.tpl-card > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.label-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  background: var(--scrim);
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.label-pill ion-icon {
  font-size: 12px;
  margin-right: 5px;
}
.label-pill span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Chips ---------- */

.chip {
  flex-shrink: 0;
  padding: 9px var(--s-md);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  white-space: nowrap;
}
.chip.active {
  background: var(--accent-tint);
  color: var(--accent-dark);
  font-weight: 700;
}

/* ---------- Before/after scanner ---------- */

.scanner {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--surface-muted);
}
.scanner img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner .after {
  clip-path: inset(0 0 100% 0);
  animation: scanReveal 4s infinite;
}
.scanner .line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  margin-top: -1px;
  background: var(--accent);
  box-shadow: 0 0 10px 2px rgba(123, 92, 250, 0.9);
  animation: scanLine 4s infinite;
}
.scanner.paused .after,
.scanner.paused .line {
  animation-play-state: paused;
}
@keyframes scanReveal {
  0%,
  20% {
    clip-path: inset(0 0 100% 0);
    animation-timing-function: ease-in-out;
  }
  50%,
  70% {
    clip-path: inset(0 0 0 0);
    animation-timing-function: ease-in-out;
  }
  100% {
    clip-path: inset(0 0 100% 0);
  }
}
@keyframes scanLine {
  0%,
  20% {
    top: 0%;
    opacity: 0;
    animation-timing-function: ease-in-out;
  }
  21% {
    opacity: 1;
  }
  49% {
    opacity: 1;
  }
  50%,
  70% {
    top: 100%;
    opacity: 0;
    animation-timing-function: ease-in-out;
  }
  71% {
    opacity: 1;
  }
  99% {
    opacity: 1;
  }
  100% {
    top: 0%;
    opacity: 0;
  }
}

/* ---------- Toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 100px);
  transform: translateX(-50%);
  max-width: calc(100% - 48px);
  background: var(--charcoal);
  color: var(--text-on-dark);
  padding: 12px 18px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--sh-button);
  animation: toastIn 0.3s var(--ease-out) both;
  pointer-events: none;
  text-align: center;
}
.toast.out {
  animation: toastOut 0.25s ease both;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* ---------- Alert (iOS-style) ---------- */

.alert-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 14, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease both;
}
.alert-box {
  width: 100%;
  max-width: 290px;
  background: rgba(250, 247, 244, 0.97);
  border-radius: 16px;
  overflow: hidden;
  text-align: center;
  animation: alertIn 0.25s var(--spring) both;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.alert-box .alert-body {
  padding: 20px 18px 16px;
}
.alert-box h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}
.alert-box p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}
.alert-box .alert-actions {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-strong);
}
.alert-box .alert-actions.row {
  flex-direction: row;
}
.alert-box .alert-actions button {
  flex: 1;
  padding: 13px 8px;
  font-size: 17px;
  color: var(--accent-dark);
}
.alert-box .alert-actions button + button {
  border-top: 1px solid var(--border-strong);
}
.alert-box .alert-actions.row button + button {
  border-top: 0;
  border-left: 1px solid var(--border-strong);
}
.alert-box .alert-actions button.bold {
  font-weight: 700;
}
.alert-box .alert-actions button.destructive {
  color: var(--danger);
}
.alert-box .alert-actions button.cancel {
  font-weight: 600;
}
@keyframes alertIn {
  from {
    opacity: 0;
    transform: scale(1.12);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Misc ---------- */

.hidden {
  display: none !important;
}

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