/**
 * Pond Hair & Cosmetic — premium app shell, motion, lightbox.
 */

:root {
  --pond-ink: #1c1a18;
  --pond-surface: #e8e4de;
  --pond-surface-2: #f2efe9;
  --pond-card: #ffffff;
  --pond-accent: #62348e;
  --pond-accent-soft: rgba(98, 52, 142, 0.14);
  --pond-ring: rgba(81, 42, 119, 0.45);
  /* 8px grid */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.25rem;
  --s-6: 1.5rem;
}

html {
  overscroll-behavior-y: none;
}

@media (prefers-reduced-motion: no-preference) {
  .app-native .app-page {
    animation: pond-page-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
}
@keyframes pond-page-in {
  from {
    opacity: 0.94;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .app-native .app-page {
    animation: none;
  }
}

/* App-like: no text selection by default; forms stay selectable */
.app-body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  color: var(--pond-ink);
  /* Marketplace-style canvas (Amazon-like neutral gray) */
  background: #eaeded;
  min-height: 100%;
}

.app-body,
.app-body * {
  -webkit-user-select: none;
  user-select: none;
}

.app-body input,
.app-body textarea,
.app-body select,
.app-body [contenteditable='true'],
.app-body .allow-select {
  -webkit-user-select: text;
  user-select: text;
}

.app-surface {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

.page-shell {
  animation: pageIn 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-shell {
    animation: none;
  }
  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
  }
}

[data-animate] {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-animate].is-inview {
  opacity: 1;
  transform: translateY(0);
}

/* Micro-interaction: subtle press on interactive surfaces */
@media (hover: hover) and (pointer: fine) {
  a:active:not(.no-press),
  button:active:not(:disabled):not(.no-press),
  [role='button']:active:not(.no-press) {
    transition: transform 0.12s ease;
  }
}

button,
a,
[role='button'] {
  -webkit-tap-highlight-color: var(--pond-accent-soft);
}

:focus-visible {
  outline: 2px solid var(--pond-ring);
  outline-offset: 2px;
}

/* Premium panels: white on tinted canvas */
.app-panel {
  background: var(--pond-card);
  border: 1px solid rgba(15, 15, 20, 0.1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.75) inset, 0 6px 20px -8px rgba(26, 22, 40, 0.12);
}

/* Phone shell — tighter canvas, safe areas */
.app-shell {
  padding-left: max(0.625rem, env(safe-area-inset-left));
  padding-right: max(0.625rem, env(safe-area-inset-right));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
}

@media (max-width: 767px) {
  .app-shell {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }
}

body.lightbox-open {
  touch-action: none;
  overscroll-behavior: none;
}

/* Fullscreen image lightbox — no pinch-zoom on image; swipe only */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: rgba(23, 21, 20, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: lightboxIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@keyframes lightboxIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lightbox__top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 0.25rem
    max(0.75rem, env(safe-area-inset-left));
}

.lightbox__counter {
  margin-right: auto;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.78);
}

.lightbox__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.15s ease;
}
.lightbox__close:hover {
  background: rgba(255, 255, 255, 0.18);
}
.lightbox__close:active {
  transform: scale(0.96);
}

.lightbox__icon {
  width: 1.35rem;
  height: 1.35rem;
}

.lightbox__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem max(0.75rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-bottom))
    max(0.75rem, env(safe-area-inset-right));
  min-height: 0;
  touch-action: none;
}

.lightbox__img {
  max-width: 100%;
  max-height: min(88vh, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.875rem;
  box-shadow: 0 24px 64px -12px rgba(0, 0, 0, 0.5);
  touch-action: none;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  transition:
    background 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.15s ease;
}
.lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.22);
}
.lightbox__nav:active {
  transform: translateY(-50%) scale(0.96);
}
.lightbox__nav--prev {
  left: max(0.5rem, env(safe-area-inset-left));
}
.lightbox__nav--next {
  right: max(0.5rem, env(safe-area-inset-right));
}

@media (max-width: 767px) {
  .lightbox__nav {
    width: 2.5rem;
    height: 2.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox {
    animation: none;
  }
}

#pwa-install-banner {
  transform: translateY(120%);
  transition: transform 0.38s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
  border-radius: 1rem;
  border: 1px solid rgba(232, 224, 217, 0.95);
  background: rgba(255, 255, 255, 0.97);
  padding: 1rem;
  box-shadow: 0 -8px 40px -12px rgba(42, 38, 36, 0.18);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
#pwa-install-banner.is-visible {
  transform: translateY(0);
}
#pwa-install-banner .pwa-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
#pwa-install-banner .pwa-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--pond-ink);
}
#pwa-install-banner .pwa-sub {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #57534e;
}
#pwa-install-banner .pwa-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
#pwa-install-banner button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 0.75rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 600;
}
#pwa-install-banner .pwa-btn-primary {
  background: linear-gradient(180deg, #febd69 0%, #f3a847 100%);
  color: #0f1111;
}
#pwa-install-banner .pwa-btn-ghost {
  background: transparent;
  color: #78716c;
}
#pwa-install-banner .pwa-icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: #ede6f2;
  color: #5a3f68;
  font-size: 0.7rem;
  font-weight: 800;
}

.pond-btn-primary {
  background: linear-gradient(180deg, #ffd814 0%, #f7ca00 100%);
  color: #0f1111;
  box-shadow: 0 2px 5px rgba(213, 217, 217, 0.9);
  border: 1px solid #fcd200;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}
.pond-btn-primary:active {
  transform: scale(0.98);
  filter: brightness(0.97);
}

.app-card {
  box-shadow: 0 1px 0 rgba(15, 15, 20, 0.05), 0 4px 16px -6px rgba(26, 22, 40, 0.1);
}

/* Shimmer skeleton (listings / loading states) */
@keyframes pond-shimmer {
  100% {
    transform: translateX(100%);
  }
}
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #e8e4de;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: pond-shimmer 1.1s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton::after {
    animation: none;
  }
}

/* Toast (JS-inserted) */
#pond-toast-root {
  position: fixed;
  left: 50%;
  bottom: max(5.5rem, calc(5rem + env(safe-area-inset-bottom)));
  z-index: 120;
  transform: translateX(-50%);
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}
.pond-toast {
  pointer-events: auto;
  border-radius: 0.875rem;
  padding: 0.65rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: 0 12px 40px -8px rgba(15, 15, 25, 0.25);
  animation: pondToastIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.pond-toast--ok {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.pond-toast--err {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
@keyframes pondToastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* SPA client navigation */
#spa-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 9998;
  pointer-events: none;
  background: linear-gradient(90deg, #febd69, #f08804);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
#spa-progress.is-active {
  transform: scaleX(1);
}
#main.spa-main-loading {
  opacity: 0.92;
  transition: opacity 0.12s ease;
}
body.spa-navigating {
  cursor: progress;
}
@media (prefers-reduced-motion: reduce) {
  #spa-progress {
    transition: none;
  }
  #main.spa-main-loading {
    opacity: 1;
  }
}

/* Bottom nav — active tab (SPA sync uses .pond-nav-tab--active) */
#pond-bottom-nav .pond-nav-tab {
  color: #475569;
  font-weight: 500;
  transition: color 0.15s ease, transform 0.12s ease;
}
#pond-bottom-nav .pond-nav-tab:active {
  transform: scale(0.97);
}
#pond-bottom-nav .pond-nav-tab--active {
  color: #0f1111;
  font-weight: 700;
}
#pond-bottom-nav .pond-nav-tab--active svg {
  color: #0f1111;
}

/* Full-page boot overlay until window load */
html.app-booting body {
  overflow: hidden;
}
.app-boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.97);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition:
    opacity 0.38s ease,
    visibility 0.38s ease;
}
.app-boot-overlay--hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.app-boot-overlay__box {
  text-align: center;
}
.app-boot-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 0.65rem;
  border: 3px solid #e2e8f0;
  border-top-color: #f08804;
  border-radius: 50%;
  animation: app-boot-spin 0.7s linear infinite;
}
.app-boot-overlay__brand {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #0f172a;
}
@keyframes app-boot-spin {
  to {
    transform: rotate(360deg);
  }
}
html.app-spa-fetching::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9996;
  background: rgba(15, 23, 42, 0.07);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .app-boot-spinner {
    animation: none;
    opacity: 0.85;
  }
}

/* ---------------------------------------------------------------------------
   Cart — checkout strip sits above bottom nav (same offset as .app-shell pb)
   --------------------------------------------------------------------------- */
.cart-checkout-strip {
  bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 49;
}
@media (min-width: 768px) {
  .cart-checkout-strip {
    display: none;
  }
}

/**
 * Extra scroll space below line items for the fixed checkout strip (~3.5–4rem).
 * .app-shell already reserves the bottom nav band; this adds clearance for the bar above it.
 */
@media (max-width: 767px) {
  .cart-page--items {
    padding-bottom: max(4rem, calc(3.5rem + env(safe-area-inset-bottom, 0px)));
  }
}

/* Amazon-style quantity stepper (− / qty / +) */
.cart-qty-stepper {
  display: inline-flex;
  align-items: stretch;
  height: 2rem;
  border-radius: 0.125rem;
  border: 1px solid #d5d9d9;
  background: #f0f2f2;
  box-shadow: inset 0 1px 2px rgba(15, 17, 17, 0.08);
}
.cart-qty-stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-width: 2rem;
  border: none;
  background: #f0f2f2;
  color: #0f1111;
  cursor: pointer;
  transition: background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.cart-qty-stepper__btn:hover:not(:disabled) {
  background: #e3e6e6;
}
.cart-qty-stepper__btn:active:not(:disabled) {
  background: #d5d9d9;
}
.cart-qty-stepper__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.cart-qty-stepper__btn svg {
  flex-shrink: 0;
}
.cart-qty-stepper__value {
  display: flex;
  min-width: 2.25rem;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #d5d9d9;
  border-right: 1px solid #d5d9d9;
  background: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0f1111;
}
.cart-line-card {
  border-radius: 0.125rem;
  border: 1px solid #d5d9d9;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 17, 17, 0.06);
}

/* Checkout — keep summary strip readable vs sticky header */
.checkout-flow {
  position: relative;
  z-index: 0;
}
.checkout-toolbar {
  position: relative;
  z-index: 1;
}
