/* Mobile-first: base rules below target small phone screens (the primary
   way customers reach this app, usually right after scanning a QR code).
   Larger-screen enhancements live in the min-width media queries at the
   bottom rather than being the default. */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%; /* stop iOS auto-boosting font size */
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1a1a1a;
  background: #fafafa;
  overflow-x: hidden;
}

a {
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  padding-top: max(0.85rem, env(safe-area-inset-top));
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #1a1a1a;
  text-decoration: none;
  flex-shrink: 0;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.user-email {
  color: #666;
  font-size: 0.85rem;
  max-width: 38vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-form {
  display: inline;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

h1 {
  font-size: 1.4rem;
}

.error {
  color: #b00020;
}

.muted {
  color: #777;
  font-size: 0.85rem;
}

/* Forms: full-width and large tap targets by default (mobile). */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: 100%;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

input, button {
  font-size: 16px; /* 16px minimum avoids iOS Safari zooming in on focus */
  padding: 0.65rem 0.75rem;
  min-height: 44px; /* comfortable touch target */
}

input {
  border: 1px solid #ccc;
  border-radius: 6px;
}

button {
  cursor: pointer;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
}

.auth-form button {
  width: 100%;
  margin-top: 0.25rem;
}

.btn-secondary {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #ccc;
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  font-weight: 500;
}

/* Link-based buttons: same look as a <button>, usable on an <a>. */
.btn-primary, .btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  min-height: 44px;
  border-radius: 6px;
}

.btn-primary {
  background: #1a1a1a;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: #1a1a1a;
  border: 1px solid #1a1a1a;
}

.nav-link {
  color: #1a1a1a;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0;
}

.btn-nav {
  min-height: 36px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}

/* Device list (dashboard) and photo list (device detail): on mobile these
   render as single-column rows/stacks, which scans better one-handed than
   a cramped multi-column grid on a small screen. */
.device-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.device-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 0.5rem;
  overflow: hidden;
}

.device-card img, .no-photo {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 8px;
}

.device-card img {
  object-fit: cover;
  display: block;
}

.no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
  color: #999;
  font-size: 0.7rem;
  text-align: center;
  padding: 0.25rem;
}

.device-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.device-card-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.image-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  overflow: hidden;
}

.image-card a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.image-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
}

.device-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.btn-danger {
  color: #b00020;
  border-color: #e5b3ba;
}

/* --- Marketing landing page (logged-out visitors at "/") --- */
.hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.hero h1 {
  font-size: 1.7rem;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.hero-subtitle {
  color: #444;
  font-size: 1rem;
  max-width: 480px;
  margin: 0 auto 1.5rem;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 280px;
  margin: 0 auto;
}

/* Looping illustration: camera "flashes", a dot carries the photo across
   to the phone, and the phone's shelf visibly thins out — showing the
   value prop (notice what's running low) without reading anything. */
.hero-visual {
  max-width: 280px;
  margin: 1.5rem auto;
}

.pantry-anim {
  width: 100%;
  height: auto;
  display: block;
}

.flash {
  transform-origin: 31px 74px;
  animation: flash-pulse 4s ease-out infinite;
}

.packet {
  animation: packet-travel 4s ease-in-out infinite;
}

.shelf-a {
  animation: shelf-a-fade 4s ease-in-out infinite;
}

.shelf-b {
  animation: shelf-b-fade 4s ease-in-out infinite;
}

@keyframes flash-pulse {
  0%, 20% { opacity: 0; transform: scale(0.6); }
  30% { opacity: 1; transform: scale(1); }
  45%, 100% { opacity: 0; transform: scale(1.3); }
}

@keyframes packet-travel {
  0%, 28% { transform: translateX(0); opacity: 0; }
  32% { opacity: 1; }
  55% { transform: translateX(28px); opacity: 1; }
  60%, 100% { transform: translateX(28px); opacity: 0; }
}

@keyframes shelf-a-fade {
  0%, 58% { opacity: 1; }
  68%, 100% { opacity: 0; }
}

@keyframes shelf-b-fade {
  0%, 58% { opacity: 0; }
  68%, 100% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .flash, .packet, .shelf-a, .shelf-b {
    animation: none;
  }
  .shelf-b { opacity: 0; }
}

.value-pills {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0;
  margin: 1.5rem 0 0;
}

.value-pills li {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  color: #444;
}

/* Dashboard "coming soon" banner: sets expectations about what today's
   photo-only dashboard doesn't do yet, using the same icon language as
   the landing page animation. */
.coming-soon {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.coming-soon-badge {
  display: inline-block;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  margin-bottom: 0.5rem;
}

.coming-soon-lead {
  margin: 0 0 1rem;
  color: #444;
  font-size: 0.9rem;
}

.coming-soon-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.coming-soon-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.coming-soon-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

/* --- Larger screens: layer on a denser grid instead of the mobile list --- */
@media (min-width: 560px) {
  .site-header {
    padding: 1rem 1.5rem;
    padding-top: max(1rem, env(safe-area-inset-top));
  }

  main {
    padding: 1.5rem;
  }

  .auth-form {
    max-width: 320px;
  }

  .auth-form button {
    width: auto;
  }

  .device-grid, .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }

  .device-card {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }

  .device-card img, .no-photo {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border-radius: 0;
  }

  .device-card-info {
    padding: 0.5rem;
  }

  .image-card-footer {
    padding: 0.5rem;
  }

  .hero {
    padding: 3rem 0 3.5rem;
  }

  .hero h1 {
    font-size: 2.3rem;
  }

  .hero-subtitle {
    font-size: 1.1rem;
    max-width: 560px;
  }

  .hero-actions {
    flex-direction: row;
    justify-content: center;
    max-width: none;
  }

  .hero-visual {
    max-width: 340px;
  }

  .coming-soon {
    padding: 1.25rem 1.5rem;
  }

  .coming-soon-grid {
    flex-direction: row;
    justify-content: space-between;
    gap: 1rem;
  }
}
