/* ── iPhone Design Tokens (scoped to .page--iphone) ── */
.page--iphone {
  color-scheme: dark;

  /* Color */
  --iphone-text-primary: #ffffff;
  --iphone-text-secondary: #a1a1a6;
  --iphone-text-tertiary: #6e6e73;
  --iphone-surface-base: #000000;
  --iphone-surface-elevated: #1d1d1f;
  --iphone-surface-card: #161617;
  --iphone-surface-muted: #0071e3;
  --iphone-surface-strong: #d2d2d7;
  --iphone-border: #333336;
  --iphone-border-hover: #515154;
  --iphone-focus: #2997ff;

  /* Typography */
  --iphone-font-family: "SF Pro Text", "SF Pro Icons", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --iphone-font-display: "SF Pro Display", "SF Pro Icons", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --iphone-font-size-xs: 12px;
  --iphone-font-size-sm: 14px;
  --iphone-font-size-md: 17px;
  --iphone-font-size-lg: 20px;
  --iphone-font-size-xl: 24px;
  --iphone-font-size-2xl: 28px;
  --iphone-font-size-3xl: 56px;
  --iphone-font-size-4xl: 80px;
  --iphone-font-weight-base: 400;
  --iphone-font-weight-semibold: 600;
  --iphone-line-height-base: 1.4706;
  --iphone-line-height-tight: 1.066;

  /* Spacing */
  --iphone-space-1: 3px;
  --iphone-space-2: 8px;
  --iphone-space-3: 9px;
  --iphone-space-4: 10px;
  --iphone-space-5: 11px;
  --iphone-space-6: 13.6px;
  --iphone-space-7: 14px;
  --iphone-space-8: 15px;

  /* Radius */
  --iphone-radius-xs: 20px;
  --iphone-radius-sm: 28px;
  --iphone-radius-md: 36px;
  --iphone-radius-lg: 50px;
  --iphone-radius-xl: 980px;

  /* Motion */
  --iphone-duration-instant: 100ms;
  --iphone-duration-fast: 320ms;
  --iphone-duration-normal: 400ms;
  --iphone-duration-slow: 500ms;
  --iphone-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --iphone-ease-out: cubic-bezier(0.25, 1, 0.5, 1);

  background: var(--iphone-surface-base);
  color: var(--iphone-text-primary);
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-md);
  font-weight: var(--iphone-font-weight-base);
  line-height: var(--iphone-line-height-base);
}

/* ── Focus-visible: WCAG 2.2 AA ── */
.page--iphone :focus-visible {
  outline: 2px solid var(--iphone-focus);
  outline-offset: 2px;
}

/* ── Override nav/footer for dark theme ── */
.page--iphone .site-header {
  background: var(--iphone-surface-base);
  border-bottom: 1px solid var(--iphone-border);
}

.page--iphone .site-footer {
  background: var(--iphone-surface-elevated);
  color: var(--iphone-text-secondary);
  border-top: 1px solid var(--iphone-border);
}

.page--iphone .nav__link,
.page--iphone .nav__brand {
  color: var(--iphone-text-primary);
}

.page--iphone .nav__logo {
  filter: invert(1);
}

.page--iphone .nav__icon-button {
  color: var(--iphone-text-primary);
}

/* ── Catalog Hero ── */
.page--iphone .catalog-hero {
  padding: 120px var(--iphone-space-8) 60px;
  background: var(--iphone-surface-base);
  text-align: center;
}

.page--iphone .catalog-hero .eyebrow {
  color: var(--iphone-surface-muted);
  font-size: var(--iphone-font-size-lg);
  font-weight: var(--iphone-font-weight-semibold);
  margin: 0 0 var(--iphone-space-2);
}

.page--iphone .catalog-hero__title {
  margin: 0;
  font-family: var(--iphone-font-display);
  font-size: clamp(var(--iphone-font-size-3xl), 12vw, var(--iphone-font-size-4xl));
  font-weight: var(--iphone-font-weight-semibold);
  line-height: var(--iphone-line-height-tight);
  color: var(--iphone-text-primary);
  letter-spacing: -0.015em;
}

.page--iphone .catalog-hero__lead {
  max-width: 42rem;
  margin: var(--iphone-space-8) auto 0;
  color: var(--iphone-text-secondary);
  font-size: var(--iphone-font-size-lg);
  font-weight: var(--iphone-font-weight-base);
  line-height: var(--iphone-line-height-base);
}

/* ── Gradient accent behind hero ── */
.page--iphone .catalog-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.page--iphone .catalog-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(0, 113, 227, 0.12), transparent 70%),
    radial-gradient(ellipse 60% 70% at 50% 100%, rgba(41, 151, 255, 0.06), transparent 70%);
  pointer-events: none;
}

/* ── Toolbar ── */
.page--iphone .catalog-section {
  padding-top: var(--iphone-space-8);
}

.page--iphone .product-toolbar {
  display: grid;
  gap: var(--iphone-space-7);
  margin-block: var(--iphone-space-7) 24px;
}

.page--iphone .product-search {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--iphone-border);
  border-radius: var(--iphone-radius-xs);
  background: var(--iphone-surface-elevated);
  color: var(--iphone-text-primary);
  padding: 0 16px;
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-md);
  font-weight: var(--iphone-font-weight-base);
  transition: border-color var(--iphone-duration-fast) var(--iphone-ease-standard), box-shadow var(--iphone-duration-fast) var(--iphone-ease-standard);
}

.page--iphone .product-search::placeholder {
  color: var(--iphone-text-tertiary);
}

.page--iphone .product-search:hover {
  border-color: var(--iphone-border-hover);
}

.page--iphone .product-search:focus-visible {
  border-color: var(--iphone-focus);
  box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.22);
}

.page--iphone .product-search:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Filter chips ── */
.page--iphone .filter-chip {
  min-height: 36px;
  border: 1px solid var(--iphone-border);
  border-radius: var(--iphone-radius-xl);
  background: var(--iphone-surface-elevated);
  color: var(--iphone-text-primary);
  padding: 0 var(--iphone-space-7);
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-sm);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--iphone-duration-fast) var(--iphone-ease-standard), border-color var(--iphone-duration-fast) var(--iphone-ease-standard), color var(--iphone-duration-fast) var(--iphone-ease-standard), transform var(--iphone-duration-fast) var(--iphone-ease-standard);
}

.page--iphone .filter-chip:hover {
  background: var(--iphone-border);
  border-color: var(--iphone-border-hover);
}

.page--iphone .filter-chip:active {
  transform: scale(0.97);
}

.page--iphone .filter-chip.is-active {
  border-color: var(--iphone-surface-muted);
  background: var(--iphone-surface-muted);
  color: #ffffff;
}

.page--iphone .filter-chip.is-active:hover {
  background: #0077ed;
  border-color: #0077ed;
}

/* ── Product grid ── */
.page--iphone .product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--iphone-space-7);
}

/* ── Product card ── */
.page--iphone .product-card {
  position: relative;
  overflow: hidden;
  min-height: 100%;
  border: 1px solid var(--iphone-border);
  border-radius: var(--iphone-radius-xs);
  background: var(--iphone-surface-card);
  transition: transform var(--iphone-duration-fast) var(--iphone-ease-out), box-shadow var(--iphone-duration-fast) var(--iphone-ease-standard), border-color var(--iphone-duration-fast) var(--iphone-ease-standard);
  contain: layout paint;
}

.page--iphone .product-card:hover {
  transform: translateY(-4px);
  border-color: var(--iphone-border-hover);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.48),
    0 0 0 1px var(--iphone-border-hover);
}

.page--iphone .product-card__link {
  display: grid;
  min-height: 100%;
  grid-template-rows: auto 1fr;
  color: inherit;
}

.page--iphone .product-card__media {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.04), transparent 58%),
    var(--iphone-surface-card);
  place-items: center;
  overflow: hidden;
  border-radius: calc(var(--iphone-radius-xs) - 1px) calc(var(--iphone-radius-xs) - 1px) 0 0;
}

.page--iphone .product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: clamp(0.45rem, 2vw, 1rem);
  transition: transform var(--iphone-duration-slow) var(--iphone-ease-out), filter var(--iphone-duration-fast) var(--iphone-ease-standard);
}

.page--iphone .product-card:hover .product-card__media img {
  transform: scale(1.04);
  filter: brightness(1.06);
}

/* Badge */
.page--iphone .product-card__badge {
  position: absolute;
  top: var(--iphone-space-7);
  left: var(--iphone-space-7);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: var(--iphone-radius-xl);
  background: var(--iphone-surface-muted);
  color: #ffffff;
  padding: 0 var(--iphone-space-2);
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-xs);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}

/* Condition pill */
.page--iphone .product-card__condition {
  position: absolute;
  top: var(--iphone-space-7);
  right: var(--iphone-space-7);
  z-index: 2;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--iphone-radius-xl);
  background: rgba(29, 29, 31, 0.72);
  color: var(--iphone-text-primary);
  padding: 0 var(--iphone-space-2);
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-xs);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: 1;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Card body */
.page--iphone .product-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--iphone-space-1);
  padding: var(--iphone-space-7) var(--iphone-space-8);
}

.page--iphone .product-card__brand {
  color: var(--iphone-text-secondary);
  font-size: var(--iphone-font-size-xs);
  font-weight: var(--iphone-font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.page--iphone .product-card__title {
  margin: 0;
  font-family: var(--iphone-font-display);
  font-size: var(--iphone-font-size-xl);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: var(--iphone-line-height-tight);
  color: var(--iphone-text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.page--iphone .product-card__description {
  margin: 0;
  color: var(--iphone-text-secondary);
  font-size: var(--iphone-font-size-sm);
  font-weight: var(--iphone-font-weight-base);
  line-height: var(--iphone-line-height-base);
}

/* Facts */
.page--iphone .product-card__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--iphone-space-1);
  min-height: 24px;
}

.page--iphone .product-card__facts span {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border: 1px solid var(--iphone-border);
  border-radius: var(--iphone-radius-xl);
  background: transparent;
  color: var(--iphone-text-secondary);
  padding: 0 var(--iphone-space-2);
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-xs);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: 1;
}

/* Footer */
.page--iphone .product-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--iphone-space-7);
  margin-top: var(--iphone-space-2);
}

/* Price */
.page--iphone .price {
  display: inline-flex;
  flex-direction: column;
  gap: var(--iphone-space-1);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: 1.15;
}

.page--iphone .price__current {
  font-size: var(--iphone-font-size-xl);
  color: var(--iphone-text-primary);
}

.page--iphone .price__old {
  color: var(--iphone-text-tertiary);
  font-size: var(--iphone-font-size-xs);
  font-weight: var(--iphone-font-weight-base);
  text-decoration: line-through;
}

/* Stock pill */
.page--iphone .stock-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: var(--iphone-space-1);
  border-radius: var(--iphone-radius-xl);
  background: rgba(255, 255, 255, 0.08);
  color: var(--iphone-text-secondary);
  padding: 0 10px;
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-xs);
  font-weight: var(--iphone-font-weight-semibold);
  line-height: 1;
}

.page--iphone .stock-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #30d158;
  flex-shrink: 0;
}

.page--iphone .stock-pill[data-stock="false"]::before {
  background: #ff9f0a;
}

/* ── Skeleton ── */
.page--iphone .product-card-skeleton {
  overflow: hidden;
  min-height: 25rem;
  border: 1px solid var(--iphone-border);
  border-radius: var(--iphone-radius-xs);
  background:
    linear-gradient(var(--iphone-surface-elevated), var(--iphone-surface-elevated)) 0 0 / 100% 58% no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.06)) var(--iphone-space-7) 65% / 40% 12px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04)) var(--iphone-space-7) 72% / 70% 16px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04)) var(--iphone-space-7) 82% / 52% 14px no-repeat,
    var(--iphone-surface-card);
  position: relative;
}

.page--iphone .product-card-skeleton::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  content: "";
  transform: translateX(-100%);
  animation: iphone-skeleton 1.2s infinite;
}

@keyframes iphone-skeleton {
  to {
    transform: translateX(100%);
  }
}

/* ── Empty state ── */
.page--iphone .empty-state {
  border: 1px dashed var(--iphone-border);
  border-radius: var(--iphone-radius-xs);
  padding: 48px var(--iphone-space-7);
  color: var(--iphone-text-secondary);
  font-family: var(--iphone-font-family);
  font-size: var(--iphone-font-size-md);
  text-align: center;
  background: transparent;
}

.page--iphone .empty-state--searchlight {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 35%, rgba(0, 113, 227, 0.12), transparent 12rem),
    var(--iphone-surface-card);
}

.page--iphone .empty-state--searchlight::before {
  position: absolute;
  inset: -35% auto auto 50%;
  z-index: -1;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(41, 151, 255, 0.16), transparent 64%);
  content: "";
  transform: translateX(-50%);
}

/* ── Responsive ── */
@media (min-width: 640px) {
  .page--iphone .product-toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .page--iphone .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 834px) {
  .page--iphone .catalog-hero {
    padding: 160px var(--iphone-space-8) 80px;
  }

  .page--iphone .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .page--iphone .section {
    padding-block: 80px;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .page--iphone .product-card,
  .page--iphone .product-card__media img,
  .page--iphone .filter-chip {
    transition: none;
  }

  .page--iphone .product-card:hover {
    transform: none;
  }

  .page--iphone .product-card:hover .product-card__media img {
    transform: none;
  }

  .page--iphone .product-card-skeleton::after {
    animation: none;
  }
}
