/* BrickDeal — brand tokens.
   The price is the only loud element on the page. Everything else stays quiet. */

:root {
  --bg:        #17181C;
  --surface:   #1E2026;
  --surface-2: #262931;
  --line:      #2E313A;
  --accent:    #F5B41E;
  --text:      #F5F2EE;
  --muted:     #9A9A92;
  --alert:     #EE4B3C;

  --radius:    14px;
  --radius-sm: 9px;
  --wrap:      1180px;

  /* type scale */
  --t-xs:  0.75rem;
  --t-sm:  0.8125rem;
  --t-md:  0.9375rem;
  --t-lg:  1.0625rem;
  --t-xl:  1.375rem;
  --t-2xl: 1.75rem;
}

*, *::before, *::after { box-sizing: border-box; }

/* Several components below set an explicit `display`, which outranks the UA
   stylesheet's [hidden] rule. Without this, hiding them from JS silently fails. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Heebo, system-ui, "Segoe UI", Arial, sans-serif;
  font-size: var(--t-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 16px;
}

:where(a, button, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 8px;
  z-index: 100;
  background: var(--accent);
  color: #17181C;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.skip-link:focus { inset-inline-start: 12px; }

/* Shown only when the loaded feed contains placeholder links. */
.dev-banner {
  background: var(--alert);
  color: #fff;
  text-align: center;
  padding: 9px 16px;
  font-size: var(--t-sm);
  font-weight: 700;
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  padding-block: 14px;
  background: var(--bg);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand__logo { height: 40px; width: 40px; object-fit: contain; }

.brand__name {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.site-nav { display: flex; align-items: center; gap: 4px; }

/* Instagram is demoted to an icon so the Telegram button owns the header. */
.icon-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--muted);
}
.icon-link svg { width: 21px; height: 21px; }
.icon-link:hover { color: var(--text); background: var(--surface-2); }

@media (min-width: 420px) {
  .brand__logo { height: 46px; width: 46px; }
  .brand__name { font-size: 1.4rem; }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: var(--t-sm);
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-2);
  white-space: nowrap;
}

.btn--tg { background: var(--accent); color: #17181C; }
.btn--tg:hover { filter: brightness(1.08); }

.btn--solid { background: var(--surface-2); border: 1px solid var(--line); }
.btn--solid:hover { border-color: var(--muted); }

.btn--lg { padding: 12px 24px; font-size: var(--t-md); }

.btn__icon { width: 17px; height: 17px; flex: none; }

.btn--ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 100%;
  margin-top: 12px;
}
.btn--ghost:hover { color: var(--text); border-color: var(--muted); }

.btn--more {
  display: flex;
  margin: 28px auto 0;
  padding: 12px 28px;
  border: 1px solid var(--line);
  background: transparent;
}
.btn--more:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- hero ---------- */

/* Carries the promise from the Instagram ad: the price is the argument, so the
   featured deals appear immediately rather than behind a search. */
.hero { padding: 22px 0 4px; }

.hero__title {
  font-size: clamp(1.65rem, 8vw, 2.6rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
}

.hero__hl { color: var(--accent); }

.hero__sub {
  margin: 0;
  color: var(--muted);
  font-size: var(--t-md);
  max-width: 46ch;
}

.hero__count { color: var(--text); font-weight: 700; }

/* One full-width row per card on a phone — `auto-fit` here would pack three
   ~109px columns at 360px and push the price off-screen. */
.featured {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

@media (min-width: 560px) { .featured { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }

/* Re-roll the hero picks. Deliberately quiet: it sits directly under editorial
   content and must read as a small affordance, not a second call to action
   competing with the Telegram button. Muted text, hairline border, no fill. */
.featured__reroll {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
}
.featured__reroll:hover { color: var(--text); border-color: var(--muted); }
.featured__reroll__icon { display: inline-block; line-height: 1; }
.featured__reroll.is-spinning .featured__reroll__icon { animation: bd-spin 0.45s ease; }
@keyframes bd-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .featured__reroll.is-spinning .featured__reroll__icon { animation: none; }
}

/* A featured card is the normal card with the comparison made explicit. */
.fcard {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  transition: border-color .18s ease, transform .18s ease;
}
.fcard:hover { border-color: var(--accent); transform: translateY(-2px); }

@media (min-width: 560px) {
  .fcard { flex-direction: column; align-items: stretch; text-align: start; padding: 12px; }
}

.fcard__media {
  flex: none;
  width: 84px;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 6px;
}
@media (min-width: 560px) { .fcard__media { width: 100%; padding: 10%; } }

.fcard__media img { width: 100%; height: 100%; object-fit: contain; }

.fcard__body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }

.fcard__name {
  margin: 0;
  font-size: var(--t-sm);
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fcard__prices { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }

.fcard__now {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: var(--accent);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  font-size: clamp(1.5rem, 6.5vw, 1.9rem);
}
.fcard__now .card__currency { font-size: 0.5em; }

/* Only rendered when the feed carries a real originalPrice. Never synthesised. */
.fcard__was {
  color: var(--muted);
  font-size: var(--t-sm);
  text-decoration: line-through;
  text-decoration-color: var(--alert);
  unicode-bidi: isolate;
}

.fcard__save {
  background: var(--alert);
  color: #fff;
  font-size: var(--t-xs);
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- title ---------- */

.page-title {
  font-size: var(--t-lg);
  font-weight: 800;
  margin: 26px 0 10px;
  letter-spacing: -0.01em;
}

/* The count is proof the catalog is real — give it the brand colour. */
.page-title__count { color: var(--accent); }
/* nbsp, not a plain space — a trailing space in ::after content collapses away. */
.page-title__count:not(:empty)::after { content: "\00a0"; }

.page-sub { margin: 0 0 18px; color: var(--muted); font-size: var(--t-sm); }

/* ---------- search ---------- */

.controls { margin-bottom: 14px; }

.search { position: relative; }

.search__icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search__input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 44px;
  font-size: 1rem; /* 16px — stops iOS zooming on focus */
}
.search__input::placeholder { color: var(--muted); }
.search__input:focus { border-color: var(--accent); }
.search__input::-webkit-search-cancel-button { display: none; }

.search__clear {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.search__clear:hover { color: var(--text); }

/* ---------- theme chips ---------- */

.chips {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  /* bleed to the viewport edge so the row reads as scrollable on a phone */
  padding-inline: 16px;
  margin-inline: -16px;
  scroll-padding-inline: 16px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { border-color: var(--muted); }

.chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #17181C;
  font-weight: 700;
}

.chip__n { opacity: 0.6; font-size: 0.9em; }

/* ---------- toolbar: sort + filters ---------- */

/* One scrolling row: sort chips then the filter toggle, so they read as a
   single control group. At 360px it scrolls rather than wrapping or clipping. */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-inline: 16px;
  margin-inline: -16px;
}
.toolbar::-webkit-scrollbar { display: none; }

.segmented {
  display: flex;
  flex: none;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.segmented__btn {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.segmented__btn:hover { color: var(--text); }
.segmented__btn.is-on { background: var(--surface-2); color: var(--text); font-weight: 700; }

.more-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.more-filters:hover { color: var(--text); border-color: var(--muted); }
.more-filters[aria-expanded="true"] { color: var(--text); border-color: var(--muted); }

.more-filters__icon { width: 15px; height: 15px; flex: none; }

.more-filters__count {
  background: var(--accent);
  color: #17181C;
  font-size: var(--t-xs);
  font-weight: 800;
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding-inline: 5px;
}

.filters {
  margin-top: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filters__grid { display: grid; gap: 16px; grid-template-columns: 1fr; }

.field { border: 0; margin: 0; padding: 0; min-width: 0; }

.field__label {
  display: block;
  padding: 0;
  margin-bottom: 7px;
  font-size: var(--t-xs);
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field__row { display: flex; align-items: center; gap: 8px; }
.field__sep { color: var(--muted); }

.input {
  width: 100%;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

.input--num { -moz-appearance: textfield; appearance: textfield; }
.input--num::-webkit-outer-spin-button,
.input--num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* No min-height: an empty count line used to reserve a visible gap. */
.result-count {
  color: var(--muted);
  font-size: var(--t-sm);
  margin: 0 0 10px;
}
.result-count:empty { display: none; }

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 620px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .filters__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn--ghost { width: auto; }
}

@media (min-width: 940px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .page-title { font-size: var(--t-2xl); }
}

/* ---------- card ---------- */

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .18s ease, transform .18s ease;
}

a.card:hover { border-color: #3D414D; transform: translateY(-2px); }
a.card:active { transform: translateY(0); }

.card--stale { opacity: 0.72; }
.card--stale:hover { opacity: 1; }

/* Product image sits on the brand charcoal with generous padding, so the
   product silhouette reads rather than a cropped photo edge. */
.card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  padding: 10%;
}

.card__img { width: 100%; height: 100%; object-fit: contain; }
.card__img--failed { padding: 18%; opacity: 0.22; }

.card__body {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 7px;
}

/* the signature element — first thing under the image */
.card__price {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: var(--accent);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  /* The scale lives on the parent so the currency's `em` resolves against the
     amount's size, not the body's — otherwise ₪ renders at 8px. */
  font-size: clamp(1.6rem, 7.5vw, 2.1rem);
}

.card__amount { font-size: 1em; unicode-bidi: isolate; }
.card__currency { font-size: 0.5em; font-weight: 800; }

.card__name {
  margin: 0;
  font-size: var(--t-md);
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  /* two lines max, so every card in a row keeps the same rhythm */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
  color: var(--muted);
  font-size: var(--t-xs);
  margin: 0;
}

.card__meta-item { display: inline-flex; align-items: center; gap: 3px; }
.card__star { color: var(--accent); }

.card__checked { color: var(--muted); font-size: var(--t-xs); opacity: 0.75; margin-top: auto; }
.card__checked--stale { color: var(--alert); opacity: 1; }

.card--skeleton {
  aspect-ratio: 3 / 4.4;
  background: var(--surface);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.5; } }

/* CTA band woven into the grid, so scrolling the catalog still meets the channel */
.grid-cta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.grid-cta__text { margin: 0; font-weight: 700; }
.grid-cta__sub { margin: 2px 0 0; color: var(--muted); font-size: var(--t-sm); font-weight: 400; }

/* ---------- states ---------- */

.state { text-align: center; padding: 44px 16px; }

.state__title { color: var(--text); font-weight: 700; margin: 0 0 6px; }
.state__sub { color: var(--muted); font-size: var(--t-sm); margin: 0 0 18px; }

.state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

#empty .state__title { margin-bottom: 16px; }

/* ---------- notes ---------- */

/* Kept verbatim, but sized as a footnote — it should never be the loudest
   block on the page. */
.note {
  margin: 32px 0 8px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.note__title { margin: 0 0 10px; font-size: var(--t-md); font-weight: 800; }

.note__list {
  margin: 0;
  padding-inline-start: 18px;
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: 1.6;
  display: grid;
  gap: 7px;
}
.note__list strong { color: var(--text); font-weight: 700; }

/* ---------- CTA ---------- */

.cta {
  margin-top: 44px;
  padding-block: 26px;
  background: var(--surface);
  border-block: 1px solid var(--line);
}

.cta__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cta__title { margin: 0; font-size: var(--t-lg); font-weight: 800; }
.cta__sub { margin: 3px 0 0; color: var(--muted); font-size: var(--t-sm); }

/* ---------- footer ---------- */

.site-footer { padding-block: 26px 40px; color: var(--muted); font-size: var(--t-xs); }

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 0 0 14px;
  font-size: var(--t-sm);
  font-weight: 500;
}
.site-footer__links a:hover { color: var(--text); }

.site-footer__disclosure { margin: 0 0 10px; max-width: 62ch; line-height: 1.6; }
.site-footer__meta { margin: 16px 0 0; opacity: 0.7; }

/* ---------- deal page / archive (static, built by build.js) ---------- */

.deal {
  display: grid;
  gap: 22px;
  margin: 24px 0 8px;
  grid-template-columns: 1fr;
}

@media (min-width: 760px) { .deal { grid-template-columns: 1fr 1fr; gap: 34px; } }

.deal__media {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8%;
  aspect-ratio: 1 / 1;
}
.deal__media img { width: 100%; height: 100%; object-fit: contain; }

.deal__title { font-size: var(--t-xl); font-weight: 800; margin: 0 0 12px; line-height: 1.3; }

.deal__price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--accent);
  font-weight: 900;
  line-height: 1;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.deal__price .card__currency { font-size: 0.42em; }

.deal__specs {
  list-style: none;
  margin: 20px 0;
  padding: 0;
  display: grid;
  gap: 9px;
  font-size: var(--t-sm);
}

.deal__specs li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
  color: var(--muted);
}
.deal__specs strong { color: var(--text); font-weight: 700; }

.breadcrumb { font-size: var(--t-sm); color: var(--muted); margin: 18px 0 0; }
.breadcrumb a:hover { color: var(--text); }

.archive__list {
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  display: grid;
  gap: 2px;
}

.archive__list a {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.archive__list a:hover { color: var(--accent); }
.archive__price { color: var(--accent); font-weight: 800; flex: none; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  a.card:hover { transform: none; }
}
