/* ============================================================
   DESIGN TOKENS
   Change values here to re-theme the whole site.
   ============================================================ */
:root {
  --bg: #eaf4fb;
  --panel: #d9ecf8;
  --ink: #10293b;
  --ink-soft: #4c6b80;
  --line: #c2dcec;
  --accent: #1b9fe0;
  --accent-ink: #ffffff;
  --navy: #0c2c42;
  --navy-ink: #e7f2fa;
  --danger: #c0392b;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Work Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 3px;
  --radius-md: 6px;

  --max-width: 1180px;
}


/* ============================================================
   RESET & BASE
   ============================================================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.5em;
  color: var(--ink);
}

h1 { font-size: 2.75rem; }
h2 { font-size: 1.9rem; }
h3 { font-size: 1.3rem; }

p { margin: 0 0 1em; max-width: 62ch; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 3px rgba(16, 41, 59, 0.08);
}

.site-header__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.25rem;
  padding: 1.1rem 0;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-shrink: 0;
}

.domain-badge {
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.45rem;
}

/* Large search bar, Amazon-style: category dropdown + text field + button
   fused into one bar. */
.site-search {
  flex: 1;
  display: flex;
  align-items: stretch;
  max-width: 760px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
}

.site-search__category {
  border: none;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding: 0 1.6rem 0 0.75rem;
  max-width: 9.5rem;
}

.site-search__input {
  flex: 1;
  border: none;
  border-radius: 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
}
.site-search__input:focus { outline: none; }

.site-search__button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 0 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.site-search__button:hover { background: #1584b9; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.cart-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.cart-badge[hidden] { display: none; }

/* Category row beneath the search bar */
.site-header__categories {
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.site-header__categories-inner {
  display: flex;
  align-items: center;
  gap: 2.2rem;
  padding: 0.65rem 0;
  font-size: 0.87rem;
  overflow-x: auto;
}

.site-header__categories-inner a {
  color: var(--ink-soft);
  white-space: nowrap;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

.site-header__categories-inner a:hover,
.site-header__categories-inner a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}

@media (min-width: 901px) {
  .site-header__categories-inner { justify-content: center; }
}


/* ============================================================
   BUTTONS & FORM ELEMENTS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn:hover { background: #000; border-color: #000; }

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn--accent:hover { background: #1584b9; border-color: #1584b9; }

.btn--outline {
  background: transparent;
  color: var(--ink);
}
.btn--outline:hover { background: var(--ink); color: var(--bg); }

.btn--full { width: 100%; }

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn[disabled]:hover { background: var(--ink); border-color: var(--ink); }

input[type="text"],
input[type="search"],
input[type="number"],
input[type="tel"],
select,
textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Quantity stepper */
.qty-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.qty-stepper button {
  background: var(--panel);
  border: none;
  width: 2.1rem;
  font-size: 1.1rem;
  color: var(--ink);
}
.qty-stepper button:hover { background: var(--line); }
.qty-stepper input {
  width: 3rem;
  border: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: center;
  border-radius: 0;
  -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ============================================================
   HERO BANNER
   ============================================================ */
.hero-banner {
  padding-top: 2rem;
}
.hero-banner img {
  width: 100%;
  height: 420px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

/* ============================================================
   PRODUCT GRID & CARDS
   ============================================================ */
.section {
  padding: 2.5rem 0;
  border-top: 1px solid var(--line);
}

/* Two half-width sections sitting side by side in one row. Each keeps its
   own heading and grid, but only takes half the container's width. */
.section-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}
.section-row .section--in-row {
  min-width: 0; /* lets the grid inside shrink instead of overflowing */
}
/* Half-width sections only have room for 2 cards across, not 4. */
.section--in-row .product-grid {
  grid-template-columns: repeat(2, 1fr);
}

.section--zigbee {
  position: relative;
  z-index: 0;
}
.section--zigbee::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -2.5rem;
  right: -2.5rem;
  background: #fbeceb;
  border: 2px solid #f0c2bd;
  border-radius: 16px;
  z-index: -1;
}
.section--zigbee h2 { color: #96281b; }
.section--zigbee .section__header a { color: #96281b; }

.section__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.75rem 1.5rem;
}

.product-card { display: flex; flex-direction: column; }

.product-card__image {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  margin-bottom: 0.9rem;
  background: var(--panel);
}
.product-card__image img { width: 100%; height: 100%; object-fit: cover; }

.deal-corner {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-top: 42px solid var(--danger);
  border-right: 42px solid transparent;
}
.deal-corner svg {
  position: absolute;
  top: -34px;
  left: 8px;
  width: 12px;
  height: 12px;
  color: #fff;
}

.product-card__category {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.25rem;
}

.product-card__name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  line-height: 1.3;
  min-height: 2.6rem;
  margin-bottom: 0.3rem;
}

.product-card .protocol-tag { margin-bottom: 0.5rem; }

.product-card__tagline {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.product-card__footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.price { font-weight: 600; font-family: var(--font-display); font-size: 1.05rem; }

.price-block {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.price--deal { color: var(--danger); }
.price-original {
  text-decoration: line-through;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 500;
}

.btn--small { padding: 0.5rem 0.9rem; font-size: 0.85rem; }

.out-of-stock-tag {
  font-size: 0.78rem;
  color: var(--danger);
  font-weight: 600;
}

/* ============================================================
   SHOP PAGE (filters + grid)
   ============================================================ */
.shop-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  padding: 2.5rem 0 4rem;
  align-items: start;
}

.filters h2 { font-size: 1rem; margin-bottom: 0.9rem; }

.filter-group { margin-bottom: 2rem; }

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.92rem;
  padding: 0.3rem 0;
  color: var(--ink-soft);
}

.filter-option input { accent-color: var(--ink); }

.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.search-bar input { flex: 1; }

.shop-results-meta {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  text-align: center;
  color: var(--ink-soft);
}

/* ============================================================
   PRODUCT DETAIL PAGE
   ============================================================ */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 1.25rem 0 0;
}
.breadcrumb a:hover { text-decoration: underline; }

.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3.5rem;
  padding: 2rem 0 4rem;
  align-items: start;
}

.product-gallery {
  display: flex;
  gap: 0.75rem;
}

.product-gallery__thumbs {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-shrink: 0;
}

.product-gallery__thumb {
  width: 4.2rem;
  height: 4.2rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}
.product-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-gallery__thumb:hover { border-color: var(--ink-soft); }
.product-gallery__thumb.is-active { border-color: var(--accent); border-width: 2px; }

.product-detail__image {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 1 / 1;
}
.product-detail__image img { width: 100%; height: 100%; object-fit: cover; }

.product-detail__category {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.product-detail__title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.product-detail__title-row h1 { margin-bottom: 0; }

.protocol-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.protocol-tag--wifi {
  background: rgba(27, 159, 224, 0.12);
  color: #0f7bb3;
  border-color: rgba(27, 159, 224, 0.35);
}
.protocol-tag--zigbee {
  background: #fdecd2;
  color: #93540c;
  border-color: #f0c98a;
}
.protocol-tag--esphome {
  background: #ece3fb;
  color: #6231b0;
  border-color: #d4c1f2;
}
.protocol-tag--combo {
  background: var(--ink);
  color: #fff;
}

.zigbee-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: #fff4e5;
  border: 1px solid #e0a94a;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: 0.88rem;
  line-height: 1.45;
}
.zigbee-warning svg { flex-shrink: 0; margin-top: 0.1rem; color: #d97706; }

.product-detail__price {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0.75rem 0 1.25rem;
}

.deal-pill {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: 3px;
  margin-top: 0.75rem;
}

.product-detail__price-row {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0.75rem 0 0.15rem;
}
.product-detail__discount-percent {
  color: var(--danger);
  font-size: 1.3rem;
  font-weight: 700;
}
.product-detail__price--deal {
  margin: 0;
  color: var(--danger);
}
.product-detail__list-price {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 0 0 1.25rem;
}
.product-detail__list-price .price-original { font-size: inherit; }

.product-detail__add-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.spec-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 2rem;
  font-size: 0.92rem;
}
.spec-table tr { border-top: 1px solid var(--line); }
.spec-table tr:last-child { border-bottom: 1px solid var(--line); }
.spec-table th, .spec-table td { text-align: left; padding: 0.6rem 0; }
.spec-table th { color: var(--ink-soft); font-weight: 500; width: 40%; }

/* ============================================================
   CART PAGE
   ============================================================ */
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 3rem;
  padding: 2.5rem 0 4rem;
  align-items: start;
}

.cart-table {
  width: 100%;
  border-collapse: collapse;
}
.cart-table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}
.cart-table td {
  padding: 1.2rem 0.5rem 1.2rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.cart-table td:first-child { padding-left: 0; }

.cart-line-product {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.cart-line-product img {
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.cart-line-product__name { font-weight: 600; margin-bottom: 0.2rem; }
.cart-line-product__remove {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
}
.cart-line-product__remove:hover { text-decoration: underline; }

.order-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  position: sticky;
  top: 6.5rem;
}
.order-summary h2 { font-size: 1.2rem; }
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  padding: 0.55rem 0;
}
.summary-row--total {
  border-top: 1px solid var(--line);
  margin-top: 0.5rem;
  padding-top: 1rem;
  font-weight: 600;
  font-size: 1.1rem;
}

/* ============================================================
   CHECKOUT PAGE
   ============================================================ */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 3rem;
  padding: 2.5rem 0 4rem;
  align-items: start;
}

.checkout-steps {
  display: flex;
  gap: 1.5rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.checkout-steps .is-current { color: var(--ink); font-weight: 600; }

.order-text {
  width: 100%;
  min-height: 220px;
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background: #fff;
}

.checkout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 1rem;
}

.copy-confirm {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-top: 0.6rem;
  min-height: 1.3em;
}

.checkout-note {
  border: 1px solid var(--line);
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: var(--panel);
  border-radius: var(--radius-sm);
  margin-top: 1.75rem;
}

.customer-fields {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}
.customer-fields h2 { font-size: 1.1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--navy);
  color: var(--navy-ink);
  margin-top: 3rem;
}

.footer-back-to-top {
  display: block;
  text-align: center;
  background: #123449;
  color: var(--navy-ink);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.75rem 0;
}
.footer-back-to-top:hover { background: #17415a; }

.footer-columns {
  padding: 1.75rem 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
.footer-columns h2 {
  color: var(--navy-ink);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
  opacity: 0.7;
}
.footer-columns a,
.footer-columns p,
.footer-columns li {
  color: var(--navy-ink);
  opacity: 0.85;
  font-size: 0.82rem;
}
.footer-columns p { margin: 0; }
.footer-columns ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .section--zigbee::before { left: -1rem; right: -1rem; }
  .hero-banner img { height: 300px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .section-row { grid-template-columns: 1fr; gap: 0; }
  .shop-layout, .cart-layout, .checkout-layout { grid-template-columns: 1fr; }
  .product-detail { grid-template-columns: 1fr; gap: 2rem; }
  .footer-columns { grid-template-columns: 1fr 1fr; }
  .site-header__row { flex-wrap: wrap; row-gap: 0.75rem; }
  .site-search { order: 3; flex: 1 1 100%; max-width: none; }
}

@media (max-width: 640px) {
  .section--zigbee::before { left: 0; right: 0; }
  .product-gallery { flex-direction: column-reverse; }
  .product-gallery__thumbs { flex-direction: row; overflow-x: auto; }
  .product-gallery__thumb { width: 3.6rem; height: 3.6rem; flex-shrink: 0; }
  .site-search__category { display: none; }
  .cart-link span:not(.cart-badge) { display: none; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 2.1rem; }
  .hero-banner img { height: 200px; }
  .cart-table thead { display: none; }
  .cart-table, .cart-table tbody, .cart-table tr, .cart-table td { display: block; width: 100%; }
  .cart-table tr { padding: 1rem 0; }
  .field-row { grid-template-columns: 1fr; }
  .footer-columns { grid-template-columns: 1fr; }
}
