/* =========================================================
   Components — nav, buttons, tiles, badges, footer
   ========================================================= */

/* ---------- Top navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-height);
  display: flex; align-items: center;
  background: var(--bg-nav);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--bg-nav-border);
  transition: background-color var(--dur-normal) var(--ease-standard),
              border-color var(--dur-normal) var(--ease-standard);
}
.nav__inner {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: flex; align-items: center; gap: var(--space-6);
  position: relative; /* anchor for the absolutely-centred nav title */
}

/* ---------- Nav centre title (mobile only) ----------
   Absolutely centred so it never pushes the brand or action buttons.
   Fades in via JS once the page heading scrolls behind the sticky bar. */
.nav__title {
  display: none; /* desktop: nav links already provide context */
}
@media (max-width: 820px) {
  .nav__title {
    display: block;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--type-sm);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
    white-space: nowrap;
    max-width: 44vw;           /* won't overlap logo or action buttons */
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-normal) var(--ease-standard);
  }
  .nav.title-visible .nav__title {
    opacity: 1;
  }
}
.nav__brand {
  display: inline-flex; align-items: center;
  color: var(--text-primary);
  /* The logo PNG has its native navy background — we wrap it in a navy badge so
     it reads as an intentional brand mark on both light and dark surfaces. */
  background: var(--brand-navy);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 4px 14px rgba(0,0,0,0.12);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.nav__brand:hover { transform: translateY(-1px); }
.nav__brand-logo {
  display: block;
  height: 34px;
  width: auto;
  box-sizing: content-box;
}

.nav__links {
  display: flex; align-items: center; gap: var(--space-1);
  margin-left: var(--space-6);
}
.nav__link {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--type-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.nav__link:hover {
  background: var(--bg-tinted);
  color: var(--text-primary);
}
.nav__link--active { color: var(--text-primary); background: var(--bg-tinted); }

.nav__spacer { flex: 1; }

.nav__actions { display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Mobile menu toggle (hamburger) ---------- */
.nav__menu-toggle {
  display: none; /* shown via media query below */
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--bg-tinted);
  color: var(--text-primary);
  transition: background-color var(--dur-fast) var(--ease-standard);
}
.nav__menu-toggle:hover { background: var(--bg-tinted-strong); }
.nav__menu-toggle svg { width: 20px; height: 20px; }
.nav__menu-toggle .icon-close { display: none; }
.nav.is-open .nav__menu-toggle .icon-open { display: none; }
.nav.is-open .nav__menu-toggle .icon-close { display: block; }

/* ---------- Mobile nav panel ---------- */
@media (max-width: 820px) {
  .nav__inner { gap: var(--space-3); }

  /* Compact the brand badge a touch on mobile */
  .nav__brand { padding: 6px 10px; border-radius: 10px; }
  .nav__brand-logo { height: 30px; }

  /* Move primary links into a slide-down panel */
  .nav__links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    inset-inline: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: var(--space-4) var(--gutter) var(--space-6);
    margin: 0;
    /* Solid surface so the hero behind doesn't bleed through */
    background: var(--bg-canvas);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    border-bottom: 1px solid var(--stroke-subtle);
    box-shadow: 0 16px 40px rgba(0,0,0,0.30);
  }
  .nav.is-open .nav__links { display: flex; }
  .nav__link {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: var(--type-base);
    text-align: left;
  }

  /* Show hamburger, hide "Shop the gear" CTA text on tight viewports */
  .nav__menu-toggle { display: inline-flex; }
  .nav__actions .btn--primary { display: none; }
}

@media (max-width: 380px) {
  .nav__inner { padding-inline: 16px; }
  .nav__brand-logo { height: 26px; }
}

.theme-toggle {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-pill);
  background: var(--bg-tinted);
  color: var(--text-primary);
  transition: background-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-spring);
}
.theme-toggle:hover { background: var(--bg-tinted-strong); transform: scale(1.05); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 14px 26px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--type-base);
  letter-spacing: var(--tracking-tight);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring),
              background-color var(--dur-normal) var(--ease-standard),
              color var(--dur-normal) var(--ease-standard),
              box-shadow var(--dur-normal) var(--ease-standard);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 6px 24px -6px rgba(245, 81, 57, 0.55);
}
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 10px 32px -6px rgba(245, 81, 57, 0.7); color: var(--text-on-accent); }

.btn--ghost {
  background: var(--bg-tinted);
  color: var(--text-primary);
}
.btn--ghost:hover { background: var(--bg-tinted-strong); color: var(--text-primary); }

.btn--text {
  padding: 8px 0;
  color: var(--text-primary);
  font-weight: 600;
}
.btn--text::after {
  content: "→";
  margin-left: 4px;
  transition: transform var(--dur-normal) var(--ease-spring);
}
.btn--text:hover { color: var(--accent); }
.btn--text:hover::after { transform: translateX(4px); }

.btn--sm { padding: 10px 18px; font-size: var(--type-sm); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-top: clamp(80px, 12vw, 160px);
  padding-bottom: clamp(60px, 9vw, 120px);
  text-align: center;
  isolation: isolate;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--hero-glow);
  z-index: -1;
  pointer-events: none;
}
.hero__eyebrow { margin-bottom: var(--space-5); }
.hero__title {
  max-width: 18ch;
  margin: 0 auto var(--space-6);
  background: linear-gradient(180deg, var(--text-primary) 0%, var(--text-secondary) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__subtitle {
  max-width: 36ch;
  margin: 0 auto var(--space-10);
}
.hero__actions {
  display: inline-flex; gap: var(--space-3); flex-wrap: wrap; justify-content: center;
}

/* ---------- Ecosystem badges (Apple Home / Matter / etc.) ---------- */
.ecosystem-strip {
  padding-block: var(--space-12);
  border-top: 1px solid var(--stroke-subtle);
  border-bottom: 1px solid var(--stroke-subtle);
}
.ecosystem-strip__label {
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--type-sm);
  font-weight: 500;
  margin-bottom: var(--space-6);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
/* Marquee wrapper — clips the scrolling track and fades the edges */
.ecosystem-strip__row {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
}
/* Scrolling track — 5 original items + 5 duplicates for a seamless loop */
.ecosystem-strip__track {
  display: flex;
  align-items: center;
  gap: clamp(40px, 6vw, 80px);
  width: max-content;
  animation: eco-marquee 30s linear infinite;
}
.ecosystem-strip__track:hover { animation-play-state: paused; }
@keyframes eco-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.ecosystem-strip__item {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--type-sm);
  opacity: 0.75;
  transition: opacity var(--dur-normal) var(--ease-standard);
}
.ecosystem-strip__item:hover { opacity: 1; }
/* Light mode: darker logos need higher opacity to stay readable */
:root[data-theme="light"] .ecosystem-strip__item,
:root:not([data-theme]) .ecosystem-strip__item {
  opacity: 0.95;
}
:root[data-theme="light"] .ecosystem-strip__item:hover,
:root:not([data-theme]) .ecosystem-strip__item:hover {
  opacity: 1;
}
.ecosystem-strip__item img {
  display: block;
  height: 30px;   /* Matter, Thread — bold heavy wordmarks */
  width: auto;
  max-width: 150px;
  object-fit: contain;
}
/* Alexa wordmark — match the house icon height so all three feel equally weighted.
   Selector includes parent to beat the specificity of .ecosystem-strip__item img (0,1,1). */
.ecosystem-strip__item .eco-logo--alexa {
  height: 72px;
  width: auto;
  max-width: none;
}
/* Square icon-only logos (Apple Home, Google Home).
   Using parent selector (0,2,0) beats (0,1,1). */
.ecosystem-strip__item .eco-logo--icon {
  height: 72px;
  width: auto;
  max-width: none;
}
/* Dark-fill SVGs (Thread, Matter): invert to white ONLY in dark mode.
   In light mode their dark fills are already readable on the light canvas. */
.eco-logo--light { filter: none; }
:root[data-theme="dark"] .eco-logo--light { filter: brightness(0) invert(1); }
/* Also handle OS-level dark preference when no explicit theme is stored yet */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .eco-logo--light { filter: brightness(0) invert(1); }
}
/* Mobile: smaller logos, marquee keeps running */
@media (max-width: 680px) {
  .ecosystem-strip__item img {
    height: 20px;
    max-width: 90px;
  }
  .ecosystem-strip__item .eco-logo--alexa {
    height: 44px;
    width: auto;
    max-width: none;
  }
  .ecosystem-strip__item .eco-logo--icon {
    height: 44px;
    width: auto;
    max-width: none;
  }
}

/* ---------- Section headings ---------- */
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: var(--space-6); flex-wrap: wrap;
  margin-bottom: var(--space-12);
}
.section-head__title { letter-spacing: var(--tracking-display); max-width: 22ch; }
.section-head__sub { color: var(--text-secondary); max-width: 44ch; margin-top: var(--space-3); }

/* ---------- Tile (Apple-Home style) ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-5);
}
.tile-grid--featured {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
}
/* Mobile: horizontal scroll shelf with snap */
@media (max-width: 680px) {
  .tile-grid--featured {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-padding-inline: var(--gutter);
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    padding-bottom: var(--space-3);
    scrollbar-width: none;
    gap: var(--space-4);
  }
  .tile-grid--featured::-webkit-scrollbar { display: none; }
  .tile-grid--featured .tile {
    flex: 0 0 78vw;
    max-width: 320px;
    scroll-snap-align: start;
  }
}

.tile {
  position: relative;
  display: flex; flex-direction: column;
  padding: var(--space-6);
  min-height: 280px;
  background: var(--tile-bg);
  border: 1px solid var(--stroke-subtle);
  border-radius: var(--radius-2xl);
  box-shadow: var(--tile-shadow);
  overflow: hidden;
  isolation: isolate;
  transition: transform var(--dur-normal) var(--ease-out-soft),
              box-shadow var(--dur-normal) var(--ease-out-soft),
              border-color var(--dur-normal) var(--ease-standard);
}
.tile::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--tile-glow);
  pointer-events: none;
  z-index: -1;
}
.tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--tile-shadow-hover);
  border-color: var(--stroke-strong);
}

.tile__media {
  /* position: relative so the absolutely-positioned img has a real
     containing block with a definite pixel height — avoids the Safari mobile
     bug where max-height:100% fails inside an implicit grid track. */
  position: relative;
  height: 200px;
  margin: -8px -8px var(--space-4);
  border-radius: var(--radius-xl);
  background: var(--media-bg);
  border: 1px solid var(--media-stroke);
  overflow: hidden;
}
.tile__media img {
  position: absolute;
  top: 20px; right: 20px; bottom: 20px; left: 20px;
  width: calc(100% - 40px);
  height: calc(100% - 40px);
  object-fit: contain;
  transition: transform var(--dur-slow) var(--ease-out-soft);
}
.tile:hover .tile__media img { transform: scale(1.06); }

.tile__cat {
  font-size: var(--type-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}
.tile__title {
  font-size: var(--type-lg);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
  margin-bottom: var(--space-2);
}
.tile__brand { color: var(--text-secondary); font-size: var(--type-sm); }
.tile__row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--space-4); }
.tile__price {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--type-lg);
  letter-spacing: var(--tracking-tight);
  font-feature-settings: "tnum";
}
.tile__cta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--type-sm); font-weight: 600;
  color: var(--accent);
}
.tile__cta::after { content: "→"; transition: transform var(--dur-normal) var(--ease-spring); }
.tile:hover .tile__cta::after { transform: translateX(3px); }

/* ---------- Category chip-tiles ---------- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}
.cat-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-5);
  min-height: 160px;
  border-radius: var(--radius-xl);
  background: var(--tile-bg);
  border: 1px solid var(--stroke-subtle);
  box-shadow: var(--tile-shadow);
  transition: transform var(--dur-normal) var(--ease-out-soft),
              box-shadow var(--dur-normal) var(--ease-out-soft),
              border-color var(--dur-normal) var(--ease-standard);
}
.cat-tile:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--tile-shadow-hover), 0 8px 32px -8px rgba(245,81,57,0.22);
  color: var(--text-primary);
}
.cat-tile__icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--accent-soft-bg);
  color: var(--accent);
  transition: transform var(--dur-normal) var(--ease-spring);
}
.cat-tile:hover .cat-tile__icon { transform: scale(1.12); }
.cat-tile__icon svg { width: 24px; height: 24px; }
.cat-tile__name {
  font-size: var(--type-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}
.cat-tile__count { font-size: var(--type-xs); color: var(--text-tertiary); margin-top: auto; }

/* ---------- Story / about block ---------- */
.story {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-12);
  align-items: center;
}
@media (min-width: 880px) {
  .story { grid-template-columns: 1.1fr 0.9fr; gap: var(--space-16); }
}
.story__visual {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-3xl);
  background: linear-gradient(160deg, var(--bg-elevated) 0%, var(--bg-canvas) 100%);
  border: 1px solid var(--stroke-subtle);
  position: relative;
  overflow: hidden;
}
.story__visual::after {
  content: "";
  position: absolute; inset: -20%;
  background: radial-gradient(40% 40% at 30% 30%, rgba(245,81,57,0.18), transparent 60%),
              radial-gradient(50% 50% at 70% 80%, rgba(81,129,158,0.20), transparent 60%);
  filter: blur(20px);
}

/* ---------- Scroll-reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s var(--ease-out-soft), transform 0.65s var(--ease-out-soft);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal--delay-1 { transition-delay: 0.08s; }
.reveal--delay-2 { transition-delay: 0.16s; }
.reveal--delay-3 { transition-delay: 0.24s; }
.reveal--delay-4 { transition-delay: 0.32s; }
.reveal--delay-5 { transition-delay: 0.40s; }
.reveal--delay-6 { transition-delay: 0.48s; }

/* ---------- Statement interstitial ---------- */
.statement {
  padding-block: clamp(80px, 12vw, 140px);
  background: var(--brand-navy);
  text-align: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.statement::before {
  content: "";
  position: absolute; inset: -50%;
  background:
    radial-gradient(50% 50% at 20% 50%, rgba(245,81,57,0.15), transparent 70%),
    radial-gradient(50% 50% at 80% 50%, rgba(81,129,158,0.12), transparent 70%);
  filter: blur(40px);
  z-index: -1;
  pointer-events: none;
}
.statement__inner {
  max-width: 820px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}
.statement__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: var(--tracking-display);
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.6) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: var(--space-6);
}
.statement__sub {
  font-size: var(--type-lg);
  color: rgba(255,255,255,0.50);
  max-width: 48ch;
  margin: 0 auto;
  line-height: 1.65;
}
.statement__stats {
  display: flex;
  justify-content: center;
  gap: clamp(var(--space-8), 6vw, var(--space-16));
  flex-wrap: wrap;
  margin-top: var(--space-12);
}
.statement__stat { text-align: center; }
.statement__stat-num {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 700;
  letter-spacing: var(--tracking-display);
  background: linear-gradient(180deg, #fff 0%, rgba(245,81,57,0.85) 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
  display: block;
  min-width: 3ch;
}
.statement__stat-label {
  font-size: var(--type-sm);
  color: rgba(255,255,255,0.45);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: var(--space-2);
  display: block;
}

/* ---------- Footer ---------- */
.footer {
  padding-block: var(--space-16) var(--space-12);
  border-top: 1px solid var(--stroke-subtle);
  color: var(--text-secondary);
  font-size: var(--type-sm);
}
.footer__grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: var(--space-10);
  margin-bottom: var(--space-12);
}
@media (max-width: 720px) {
  .footer__grid { grid-template-columns: 1fr 1fr; }
}
.footer__col h6 {
  font-size: var(--type-sm);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}
.footer__col ul { list-style: none; padding: 0; margin: 0; }
.footer__col li { margin-bottom: var(--space-2); }
.footer__bottom {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  justify-content: space-between; align-items: center;
  padding-top: var(--space-6);
  border-top: 1px solid var(--stroke-subtle);
  font-size: var(--type-xs);
  color: var(--text-tertiary);
}
.footer__disclosure { max-width: 64ch; }
