/* BrickEscape public homepage. All styling lives here (strict CSP: no inline styles). */

:root {
  --ink: #232323;
  --paper: #F4F4F1;
  --white: #FFFFFF;
  --line: #DADBD5;
  --green: #48785A;
  --green-mid: #2F5A40;
  --green-dark: #1F3E2C;
  --orange: #F99A00;
  --muted: #4A4F4B;
  --muted-2: #45494A;
  --dash: #B9BDB6;
  --font-sans: Archivo, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

body { margin: 0; background: var(--paper); }

a { color: var(--green-mid); }
a:hover { color: var(--green-dark); }

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

[hidden] { display: none !important; }

.page {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  min-height: 100%;
}

/* ---------- Top bar ---------- */
.topbar { background: var(--green-dark); color: #D6E4DA; font-size: 13px; }
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 8px 24px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
}

/* ---------- Header ---------- */
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 20px;
}
.logo-link { display: block; flex: none; }
.logo { width: 64px; height: 64px; display: block; }
.site-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 26px;
  margin-left: auto; font-weight: 600; font-size: 15px;
}
.nav-link {
  color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: center; min-height: 44px;
}
.nav-link:hover { color: var(--green-mid); text-decoration: underline; }
.lbl-short { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center;
  border-radius: 10px; font-weight: 700; text-decoration: none;
}
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-mid); color: var(--white); }
.btn-sm { min-height: 44px; padding: 0 18px; }
.btn-lg { min-height: 52px; padding: 0 26px; }
.btn-outline { border: 1.5px solid var(--ink); color: var(--ink); padding: 0 22px; }
.btn-outline:hover { background: var(--ink); color: var(--white); }

/* ---------- Hero ---------- */
.hero {
  max-width: 1240px; margin: 0 auto; padding: 56px 24px 48px;
  display: flex; flex-wrap: wrap; gap: 28px; align-items: stretch;
}
.hero-text {
  flex: 7 1 520px; min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
}
.hero h1 {
  margin: 0 0 20px; font-stretch: 85%; font-weight: 800; font-size: 76px;
  line-height: 0.95; letter-spacing: -0.025em;
}
.hero-lede {
  margin: 0 0 28px; max-width: 560px; font-size: 19px; line-height: 1.55; color: var(--muted-2);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-side {
  flex: 5 1 360px; min-width: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.hero-brick-panel {
  flex: 1 1 auto; min-height: 260px; background: var(--orange); border-radius: 18px;
  display: flex; align-items: center; justify-content: center; padding: 40px 24px 28px;
}
.hero-brick { display: flex; flex-direction: column; align-items: center; }
.hero-studs { display: flex; gap: 14px; margin-bottom: -2px; }
.hero-stud { width: 40px; height: 16px; background: var(--green-mid); border-radius: 4px 4px 0 0; }
.hero-body { width: 236px; height: 104px; background: var(--green-mid); border-radius: 6px; }
.stats { display: flex; gap: 12px; }
.stat { flex: 1 1 0; background: var(--white); border-radius: 18px; padding: 18px 20px; }
.stat-num { font-stretch: 85%; font-weight: 800; font-size: 36px; line-height: 1; }
.stat-label { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ---------- From the shelves ---------- */
.shelves { background: var(--white); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.shelves-inner { max-width: 1240px; margin: 0 auto; padding: 48px 24px 40px; }
.shelves-head {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 20px;
}
.h2-big { margin: 0; font-stretch: 85%; font-weight: 800; font-size: 44px; letter-spacing: -0.02em; }
.see-all { font-weight: 700; display: inline-block; line-height: 44px; min-height: 44px; }

.search-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.search-label { font-weight: 700; font-size: 15px; }
.search-input {
  flex: 1 1 320px; min-width: 0; height: 52px; padding: 0 16px;
  border: 2px solid var(--ink); border-radius: 12px;
  font: inherit; font-size: 17px; background: var(--white); color: var(--ink);
}
.search-input:focus-visible { outline: 3px solid var(--orange); outline-offset: 1px; }
.btn-clear {
  height: 52px; padding: 0 18px; border: 1.5px solid var(--ink); border-radius: 12px;
  background: var(--white); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn-clear:hover { background: var(--paper); }
.caption { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.caption:empty { display: none; }
.cond-select-wrap { display: none; }
.cond-select {
  height: 40px; padding: 0 30px 0 12px; border: 1.5px solid var(--ink); border-radius: 999px;
  background: var(--white); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.more-row { display: flex; justify-content: center; }
.btn-more {
  min-height: 48px; margin-top: 8px; padding: 0 22px; border: 1.5px solid var(--ink); border-radius: 12px;
  background: var(--white); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
}
.btn-more:hover { background: var(--paper); }
.btn-more[hidden] { display: none; }

.filters {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-bottom: 20px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--ink);
  background: var(--white); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.chip:hover { background: var(--paper); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--white); }

.seg { display: flex; gap: 0; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; }
.seg-btn {
  min-height: 41px; padding: 0 16px; border: 0; background: var(--white); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.seg-btn:hover { background: var(--paper); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.seg-btn:focus-visible { outline-offset: -4px; }

/* Results: a scrolling row (strip) or, while searching, a responsive grid. */
.row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.row > .card { flex: 0 0 210px; }
.grid {
  display: grid; gap: 14px; padding-bottom: 10px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* ---------- Cards ---------- */
.card {
  display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; color: var(--ink); text-decoration: none; background: var(--white);
  min-width: 0;
}
a.card:hover { border-color: var(--ink); color: var(--ink); }
a.card:hover .card-cta { text-decoration: underline; }
a.card:focus-visible { outline-offset: 3px; }
.card-media {
  position: relative; height: 170px; background: var(--paper);
  display: flex; align-items: center; justify-content: center;
}
.card-img {
  max-width: 80%; max-height: 130px; width: auto; height: auto; display: block; object-fit: contain;
}
.card-placeholder {
  width: 96px; height: 96px; border: 2px dashed var(--dash); border-radius: 10px; background: var(--white);
}
.tag {
  position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
}
.tag-new { background: var(--green); color: var(--white); }
.tag-used { background: var(--orange); color: var(--ink); }
.card-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 14px 16px; flex: 1 1 auto; }
.card-meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.card-name { font-weight: 700; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.card-colour { font-size: 14px; color: var(--muted); }
.card-qty { font-size: 14px; color: var(--muted); }
.card-foot {
  margin-top: auto; padding-top: 10px;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 8px;
}
.card-price { font-family: var(--font-mono); font-weight: 600; }
.sale-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 5px;
  background: var(--orange); color: var(--ink);
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; vertical-align: 1px;
}
.card-cta { font-size: 14px; font-weight: 700; color: var(--green-mid); flex-basis: 100%; }

/* Skeleton cards while loading */
.card-skeleton { pointer-events: none; }
.card-skeleton .card-media { background: #E9EAE5; }
.sk-line { display: block; height: 12px; border-radius: 6px; background: #E9EAE5; margin-top: 6px; width: 90%; }
.sk-short { width: 45%; margin-top: 0; }
.sk-mid { width: 65%; }
@media (prefers-reduced-motion: no-preference) {
  .card-skeleton .card-media, .sk-line { animation: sk-pulse 1.4s ease-in-out infinite; }
}
@keyframes sk-pulse { 50% { opacity: 0.55; } }

/* No results and failure boxes */
.empty {
  flex: 1 1 auto; padding: 32px; border: 1.5px dashed var(--dash); border-radius: 14px; background: var(--paper);
}
.grid > .empty { grid-column: 1 / -1; }
.empty-title { margin: 0 0 6px; font-weight: 700; font-size: 18px; }
.empty-text { margin: 0 0 16px; color: var(--muted); }
.empty-text-last { margin-bottom: 0; }
.btn-ask {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 20px; border-radius: 10px;
  background: var(--orange); color: var(--ink); font-weight: 700; text-decoration: none;
}
.btn-ask:hover { background: #E08A00; color: var(--ink); }

/* ---------- Grading ---------- */
.grading {
  max-width: 1240px; margin: 0 auto; padding: 48px 24px 64px;
  display: flex; flex-wrap: wrap; gap: 12px;
}
.grading-intro { flex: 3 1 280px; min-width: 0; padding: 8px 8px 8px 0; }
.h2-mid { margin: 0 0 10px; font-stretch: 85%; font-weight: 800; font-size: 32px; }
.grading-lede { margin: 0; line-height: 1.6; color: var(--muted-2); }
.grade-card { flex: 4 1 300px; min-width: 0; background: var(--white); border-radius: 18px; padding: 24px; }
.grade-new { border-top: 6px solid var(--green); }
.grade-used { border-top: 6px solid var(--orange); }
.grade-label { font-family: var(--font-mono); font-weight: 600; margin-bottom: 10px; }
.grade-label-new { color: var(--green-mid); }
.grade-label-used { color: #8A5300; }
.grade-p { margin: 0 0 12px; line-height: 1.6; }
.grade-p-last { margin: 0; }

/* ---------- Footer / info ---------- */
.info { background: var(--green-dark); color: var(--white); }
.info-grid {
  max-width: 1240px; margin: 0 auto; padding: 28px 24px 18px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 28px; font-size: 14px;
}
.info-label { font-family: var(--font-mono); font-size: 12px; color: var(--orange); margin-bottom: 4px; }
.info-p { margin: 0; line-height: 1.5; color: #E2ECE5; }
.info-link { color: var(--white); }
.info-link:hover { color: #D6E4DA; }
.info :focus-visible { outline-color: var(--orange); }
.legal {
  max-width: 1240px; margin: 0 auto; padding: 12px 24px 20px; border-top: 1px solid #3E6150;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; font-size: 12px; color: #B9CFC1;
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .topbar-inner, .header-inner, .hero, .shelves-inner, .grading, .info-grid, .legal {
    padding-left: 16px; padding-right: 16px;
  }
  .hero { padding-top: 36px; padding-bottom: 36px; }
  .hero h1 { font-size: 48px; }
  .hero-lede { font-size: 17px; }
  .hero-brick-panel { min-height: 200px; }
  .hero-body { width: 200px; height: 88px; }
  .hero-stud { width: 34px; }
  .hero-studs { gap: 12px; }
  .stat-num { font-size: 30px; }
  .h2-big { font-size: 36px; }
  /* Header on one line: smaller logo, short labels, no shop button ("Shop now" sits right below). */
  .header-inner { flex-wrap: nowrap; gap: 12px; padding-top: 6px; padding-bottom: 6px; }
  .logo { width: 48px; height: 48px; }
  .site-nav { flex-wrap: nowrap; gap: 0 16px; margin-left: auto; font-size: 14px; }
  .nav-shop { display: none; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid .card-media { height: 130px; }
  .grid .card-img { max-height: 100px; }
  .grid .card-body { padding: 12px 10px 14px; }
  .grid .card-name { font-size: 15px; }
  .row > .card { flex-basis: 190px; }
  .empty { padding: 24px 20px; }

  /* Phones: stock first. The hero shrinks and the brick tile goes, so the search sits near the top. */
  .topbar-inner { padding-top: 6px; padding-bottom: 6px; }
  .hero { padding-top: 20px; padding-bottom: 20px; gap: 0; }
  .hero h1 { font-size: 36px; margin-bottom: 10px; }
  .hero-lede { font-size: 16px; margin-bottom: 16px; }
  .hero-side { display: none; }
  .hero-actions { display: none; }      /* the stock search right below is the way in; "See all →" and every card open the store */
  .hero-lede { margin-bottom: 0; }

  .shelves-inner { padding-top: 20px; padding-bottom: 28px; }
  .shelves-head { margin-bottom: 6px; align-items: center; flex-wrap: nowrap; }
  .h2-big { font-size: 28px; }
  .see-all { font-size: 14px; }
  .search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  /* The search and filters stay at the top while scrolling through lots. */
  #stock-controls {
    position: sticky; top: 0; z-index: 5; background: var(--white);
    margin: 0 -16px; padding: 8px 16px 2px; border-bottom: 1px solid var(--line);
  }
  .search-row { margin-bottom: 8px; flex-wrap: nowrap; }
  .search-input { flex: 1 1 auto; }
  .search-input { height: 46px; font-size: 16px; }
  .btn-clear { height: 46px; padding: 0 14px; }
  .caption { margin: 0 0 8px; font-size: 13px; }

  /* Filters on two short lines: the type chips, then the New / Used switch underneath. */
  .filters { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
  .chips { flex-wrap: nowrap; gap: 6px; }
  .chip { flex: none; min-height: 40px; padding: 0 14px; font-size: 14px; }
  .seg-btn { min-height: 37px; padding: 0 14px; font-size: 14px; }

  #results { margin-top: 12px; }

  /* Simpler cards: picture, name, colour, price and quantity. The whole card opens the lot. */
  .grid .card-meta, .grid .card-cta { display: none; }
  .grid .card-media { height: 140px; }
  .grid .card-img { max-height: 112px; }
  .grid .card-name {
    font-size: 14px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .grid .card-colour { font-size: 13px; }
  .grid .card-body { gap: 2px; padding: 10px 10px 12px; }
  .grid .card-foot { padding-top: 6px; align-items: baseline; }
  .grid .card-price { font-size: 15px; font-weight: 700; }
  .grid .card-qty { font-size: 12px; }
}
