/* Shared phone-card hover language.
   The /phones browse cards are the source of truth: slight raise, shadow,
   image zoom, and emerald title color. Supports both patterns used in the app:
   the animated surface can be the same element as .group, or a child of it. */
.phone-card-surface-motion {
  --phone-card-rest-shadow: none;
  --phone-card-hover-shadow:
    0 4px 6px -1px rgb(0 0 0 / 0.1),
    0 2px 4px -2px rgb(0 0 0 / 0.1);
  box-shadow: var(--phone-card-rest-shadow);
  transition:
    transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1),
    background-color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.phone-card-surface-motion-emerald {
  --phone-card-rest-shadow:
    0 0 0 1.5px color-mix(in srgb, var(--color-secondary) 25%, transparent),
    0 12px 32px color-mix(in srgb, var(--color-secondary) 14%, transparent);
  --phone-card-hover-shadow: var(--phone-card-rest-shadow);
}

/* Dark phone-card surfaces need the same quiet edge as dialogs and the
   resting header. Keep it when the standard hover lift adds its soft shadow. */
@media (prefers-color-scheme: dark) {
  :root[data-style="classic"][data-theme-preference="system"] .phone-card-surface-motion:not(.phone-card-surface-motion-emerald) {
    --phone-card-dark-boundary:
      inset 0 0 0 1px color-mix(in srgb, var(--color-on-surface) 6%, transparent);
    --phone-card-rest-shadow: var(--phone-card-dark-boundary);
    --phone-card-hover-shadow:
      var(--phone-card-dark-boundary),
      0 4px 6px -1px rgb(0 0 0 / 0.1),
      0 2px 4px -2px rgb(0 0 0 / 0.1);
  }
}

:root[data-style="classic"][data-theme="dark"] .phone-card-surface-motion:not(.phone-card-surface-motion-emerald) {
  --phone-card-dark-boundary:
    inset 0 0 0 1px color-mix(in srgb, var(--color-on-surface) 6%, transparent);
  --phone-card-rest-shadow: var(--phone-card-dark-boundary);
  --phone-card-hover-shadow:
    var(--phone-card-dark-boundary),
    0 4px 6px -1px rgb(0 0 0 / 0.1),
    0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.group.phone-card-surface-motion:hover,
.group.phone-card-surface-motion:focus-visible,
.group:hover .phone-card-surface-motion,
.group:focus-visible .phone-card-surface-motion,
.phone-card-surface-motion:has(> a:focus-visible) {
  box-shadow: var(--phone-card-hover-shadow);
  transform: translateY(-0.125rem);
}

.phone-card-image-motion {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Standard cards keep their product image crisp. In dark mode, a compact,
   low-saturation echo preserves a hint of product colour without letting an
   opaque studio background tint the entire plate. */
.phone-card-image-plate {
  isolation: isolate;
  overflow: hidden;
  position: relative;
}

/* A compact landscape plate keeps browse cards focused on the decision copy.
   Keep the white frame landscape too: source assets are often portrait, but
   the frame should be a deliberate surface around the contained product.
   Editor variants keep their own composition. */
.phone-card-surface-motion .phone-card-image-plate:not(.home-editors-pick-image-cell) {
  aspect-ratio: 4 / 3;
}

.phone-card-surface-motion .phone-card-image-plate:not(.home-editors-pick-image-cell) > .photo-frame {
  aspect-ratio: 1;
  box-sizing: border-box;
  height: auto;
  width: 60%;
}

/* Every standard phone-card grid uses the same useful middle density. Each
   section keeps its own tablet and desktop column count above this range. */
@media (min-width: 480px) and (max-width: 767.98px) {
  .phone-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

[data-phone-card-ambient]::before {
  background-image: var(--phone-card-ambient-image);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 72%;
  content: '';
  display: none;
  filter: blur(26px) saturate(0.38) brightness(0.76);
  inset: -10%;
  opacity: 0.18;
  pointer-events: none;
  position: absolute;
  transform: scale(1.04);
  z-index: 0;
}

.phone-card-image-plate > .photo-frame {
  position: relative;
  z-index: 1;
}

@media (prefers-color-scheme: dark) {
  :root[data-style="classic"][data-theme-preference="system"] [data-phone-card-ambient]::before {
    display: block;
  }
}

:root[data-style="classic"][data-theme="dark"] [data-phone-card-ambient]::before {
  display: block;
}

.group:hover .phone-card-image-motion,
.group:focus-visible .phone-card-image-motion {
  transform: scale(1.05);
}

.phone-card-title-motion {
  transition: color 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.group:hover .phone-card-title-motion,
.group:focus-visible .phone-card-title-motion {
  color: var(--color-secondary);
}

.group:hover .phone-card-title-motion-on-primary,
.group:focus-visible .phone-card-title-motion-on-primary {
  color: var(--color-tertiary);
}

/* ── City construction ──────────────────────────────────────────────────
   Root-scoped under :root[data-style="city"] so Classic stays untouched.
   The `.phone-card-*` hooks come from [PhoneCard]; the print surface and hard
   shadow tokens come from city.css, coordinated with the existing motion. */
:root[data-style="city"] .phone-card-surface {
  --phone-card-rest-shadow: var(--fp-hard-shadow);
  --phone-card-hover-shadow: var(--fp-hard-shadow-hover);
  background: var(--color-surface-container-lowest);
}

:root[data-style="city"] .phone-card-image-plate {
  border-bottom: var(--fp-outline-width) solid var(--fp-ink);
}

:root[data-style="city"] .phone-card-body {
  background: var(--color-surface-container-lowest);
}

:root[data-style="city"] .phone-card-eyebrow {
  align-self: flex-start;
  background: var(--color-tertiary);
  border: 1px solid var(--fp-ink);
  color: var(--color-on-tertiary);
  padding: 2px 6px;
}

:root[data-style="city"] .phone-card-specs {
  border-top: 1px solid color-mix(in srgb, var(--fp-ink) 28%, transparent);
}

:root[data-style="city"] .phone-card-relationship {
  color: var(--color-secondary);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

:root[data-style="city"] .group.phone-card-surface-motion:hover,
:root[data-style="city"] .group.phone-card-surface-motion:focus-visible,
:root[data-style="city"] .group:hover .phone-card-surface-motion,
:root[data-style="city"] .group:focus-visible .phone-card-surface-motion,
.phone-card-surface-motion:has(> a:focus-visible) {
  transform: translate(-1px, -2px);
}

@media (prefers-reduced-motion: reduce) {
  .phone-card-surface-motion,
  .phone-card-image-motion,
  .phone-card-title-motion {
    transition: none;
  }

  .group.phone-card-surface-motion:hover,
  .group.phone-card-surface-motion:focus-visible,
  .group:hover .phone-card-surface-motion,
  .group:focus-visible .phone-card-surface-motion,
  .group:hover .phone-card-image-motion,
  .group:focus-visible .phone-card-image-motion,
  :root[data-style="city"] .group.phone-card-surface-motion:hover,
  :root[data-style="city"] .group.phone-card-surface-motion:focus-visible,
  :root[data-style="city"] .group:hover .phone-card-surface-motion,
  :root[data-style="city"] .group:focus-visible .phone-card-surface-motion,
.phone-card-surface-motion:has(> a:focus-visible) {
    transform: none;
  }
}
