/* AJR Pre-Loved Finds: styles.css
   The look borrows from a real thrift shop: price stickers on the goods, hang tags for the filters,
   a red SOLD stamp. Everything else stays plain so the stickers and stamps are what you notice.
   Fonts are loaded from index.html (not @import), so they don't block rendering in a chain. */

:root {
  --shelf: #e8ebe6;          /* page background: a pale shelf grey-green */
  --paper: #fbfbf8;          /* pop-up and tag surfaces */
  --ink: #15202b;            /* text, borders, buttons */
  --muted: #55606b;          /* secondary text (5.3:1 on the shelf colour) */
  --line: #c9cfc6;           /* thin dividers */
  --photo-bg: #d5dad2;       /* behind photos while they load */
  --sticker: #ffd23f;        /* price stickers and the main button */
  --sticker-hover: #ffc400;
  --stamp: #c8102e;          /* SOLD stamp */
  --hold: #1d4ed8;           /* reserved items and keyboard focus */

  --font: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(1rem, 5vw, 3rem);
  --radius: 6px;
}

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

* { margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  background: var(--shelf);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1rem;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--shelf);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body:has(dialog[open]) { overflow: hidden; } /* the page behind the pop-up stays put */

main { flex: 1; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

img { max-width: 100%; }

a { color: inherit; }

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

.wrap {
  width: min(100% - 2 * var(--gutter), 72rem);
  margin-inline: auto;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  transform: translateY(-160%);
  transition: transform 180ms ease;
}

.skip-link:focus { transform: translateY(0); }

.noscript {
  padding: 1rem 0;
  font-weight: 600;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.15rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: 600 0.9375rem/1.2 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease;
}

.btn--primary { background: var(--sticker); }
.btn--primary:hover { background: var(--sticker-hover); }
.btn--ghost:hover { background: rgba(21, 32, 43, 0.08); }

/* ==========================================================================
   Header and intro
   ========================================================================== */
.site-header { border-bottom: 2px solid var(--ink); }

.site-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}

.brand img { display: block; border-radius: 8px; }

.brand-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

/* Keeps "Pre-Loved Finds" together, so on a narrow phone the name wraps as "AJR" over "Pre-Loved Finds" */
.nobreak { white-space: nowrap; }

.site-header .btn { white-space: nowrap; }

.intro { padding: clamp(2.5rem, 8vw, 5.5rem) 0 clamp(1.5rem, 4vw, 2.5rem); }

.intro h1 {
  max-width: 14ch;
  font-size: clamp(2.75rem, 9vw, 6rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

.intro-lead {
  max-width: 46ch;
  margin-top: 1.25rem;
  font-size: clamp(1.0625rem, 2vw, 1.25rem);
  line-height: 1.55;
}

.intro-count {
  margin-top: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

/* ==========================================================================
   Toolbar: search, sort, sold toggle, category tags
   ========================================================================== */
.shop { padding-bottom: clamp(2rem, 6vw, 4rem); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.field--search { flex: 1 1 16rem; }

.field--sort {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.field--sort label { font-weight: 600; white-space: nowrap; }

.toolbar input[type="search"],
.toolbar select {
  min-height: 2.75rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* 16px stops iPhones zooming in on focus */
}

.toolbar input[type="search"] { width: 100%; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

/* A hang tag: the punched hole is the same colour as the shelf behind it */
.chip {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem 0.5rem 1.85rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: 600 0.9375rem/1.2 var(--font);
  cursor: pointer;
  transition: background-color 160ms ease;
}

.chip::before {
  content: "";
  position: absolute;
  left: 0.65rem;
  top: 50%;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: -0.275rem;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--shelf);
}

.chip:hover { background: #f1f1e8; }
.chip[aria-pressed="true"] { background: var(--sticker); }

.chip-count {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.chip[aria-pressed="true"] .chip-count { color: var(--ink); }

.notice {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--ink);
  background: var(--paper);
  font-size: 0.9375rem;
}

.result-status {
  margin: 1.5rem 0 1rem;
  color: var(--muted);
  font-weight: 600;
}

/* ==========================================================================
   Item cards
   ========================================================================== */
.grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 0.875rem;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
    gap: 2.25rem 1.25rem;
  }
}

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

.card-media {
  position: relative;
  display: block;
  aspect-ratio: 4 / 5;
  background: var(--photo-bg);
  border-radius: 4px;
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

/* The price sticker, stuck on slightly crooked */
.sticker {
  position: absolute;
  left: -0.35rem;
  bottom: 0.85rem;
  z-index: 1;
  padding: 0.3rem 0.65rem;
  border-radius: 2px;
  background: var(--sticker);
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 800;
  line-height: 1.1;
  transform: rotate(-3deg);
  box-shadow: 0 1px 2px rgba(21, 32, 43, 0.35);
}

.card:nth-child(3n + 2) .sticker { transform: rotate(2deg); }
.card:nth-child(3n) .sticker { transform: rotate(-1.5deg); }

.card-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin-top: 0.7rem;
  font-weight: 600;
  line-height: 1.3;
}

.card-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.card-link:hover .card-title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Rubber stamps */
.stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  padding: 0.1rem 0.7rem;
  border: 3px solid var(--stamp);
  border-radius: 4px;
  background: rgba(251, 251, 248, 0.82);
  color: var(--stamp);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  transform: translate(-50%, -50%) rotate(-12deg);
}

.stamp--reserved {
  border-color: var(--hold);
  color: var(--hold);
  font-size: 1.125rem;
  transform: translate(-50%, -50%) rotate(-6deg);
}

.is-sold .card-media img {
  filter: grayscale(1);
  opacity: 0.8;
}

.is-sold .sticker {
  background: #d9dcd6;
  color: var(--muted);
}

.is-reserved .card-media img { opacity: 0.9; }

.empty,
.load-error {
  display: grid;
  justify-items: start;
  gap: 1rem;
  max-width: 34rem;
  padding: 1.5rem 0;
}

.empty p,
.load-error p { font-size: 1.125rem; }

/* ---- Sold section ---- */
.sold {
  padding: clamp(2rem, 6vw, 3.5rem) 0;
  border-top: 2px solid var(--ink);
}

.sold h2,
.how h2 {
  margin-bottom: 1.5rem;
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.count {
  color: var(--muted);
  font-weight: 600;
}

/* ---- How it works ---- */
.how {
  padding: clamp(2rem, 6vw, 3.5rem) 0 clamp(3rem, 8vw, 5rem);
  border-top: 2px solid var(--ink);
}

.steps {
  list-style: none;
  display: grid;
  gap: 1.5rem;
  counter-reset: step;
}

@media (min-width: 720px) {
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2rem; }
}

.steps li { counter-increment: step; }

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  background: var(--sticker);
  font-weight: 800;
}

.steps h3 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.steps p {
  max-width: 32ch;
  margin-top: 0.25rem;
}

/* ---- Footer ---- */
.site-footer {
  padding: 1.5rem 0;
  background: var(--ink);
  color: #e8ebe6;
  font-size: 0.9375rem;
}

.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.site-footer a { color: var(--sticker); }
.site-footer :focus-visible { outline-color: var(--sticker); }

/* ==========================================================================
   Item pop-up
   ========================================================================== */
dialog {
  width: min(100% - 1rem, 58rem);
  max-width: none;
  max-height: calc(100vh - 1rem);
  max-height: calc(100dvh - 1rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop { background: rgba(21, 32, 43, 0.65); }

@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: pop-in 180ms ease-out; }
  dialog[open]::backdrop { animation: fade-in 180ms ease-out; }
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dialog-panel {
  position: relative;
  display: grid;
  gap: 1.25rem;
  padding: 1rem;
}

@media (min-width: 720px) {
  .dialog-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 2rem;
    padding: 1.5rem;
  }
}

.dialog-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.dialog-close:hover { background: var(--sticker); }

.dialog-close svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.gallery-main {
  aspect-ratio: 4 / 5;
  background: var(--photo-bg);
  border-radius: 6px;
  overflow: hidden;
}

.gallery-main img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbs {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.thumbs button {
  display: block;
  width: 3.5rem;
  height: 4.375rem;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 4px;
  background: var(--photo-bg);
  cursor: pointer;
}

.thumbs button[aria-current="true"] { border-color: var(--ink); }

.thumbs img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dialog-info h2 {
  padding-right: 3.25rem; /* keeps the title clear of the close button on phones */
  font-size: clamp(1.625rem, 4vw, 2.125rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.dialog-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}

.sticker--static {
  position: static;
  display: inline-block;
  padding: 0.4rem 0.85rem;
  font-size: 1.5rem;
  transform: rotate(-2deg);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
}

.badge--available { background: #d7e8d4; color: #1f4d2a; }
.badge--reserved { background: var(--hold); color: #fff; }
.badge--sold { background: var(--ink); color: #fff; }

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.35rem 1.25rem;
  margin-top: 1.25rem;
  padding: 1rem 0;
  border-block: 1px solid var(--line);
  font-size: 0.9375rem;
}

.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { overflow-wrap: anywhere; }

.dialog-desc {
  margin-top: 1rem;
  max-width: 56ch;
}

.dialog-desc p + p { margin-top: 0.75rem; }

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.dialog-note {
  font-weight: 600;
}

.dialog-hint {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.dialog-hint:empty { margin: 0; }

.sticker--sold {
  background: #d9dcd6;
  color: var(--muted);
}

/* On phones the buttons stay pinned to the bottom of the pop-up, so Inquire is always one tap away */
@media (max-width: 719px) {
  .dialog-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 1.25rem -1rem -1rem;
    padding: 0.75rem 1rem;
    background: var(--paper);
    border-top: 1px solid var(--line);
  }
}

/* Hover lift for cards, only for mouse users who haven't asked for less motion */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card-media img { transition: transform 200ms ease; }
  .card-link:hover .card-media img { transform: translateY(-3px); }
  .card-link:hover .sticker { transform: rotate(0deg) scale(1.04); }
}

/* ---- Small screens ---- */
@media (max-width: 400px) {
  .btn-extra { display: none; } /* the header button reads "Message" on the narrowest phones */
}

@media (max-width: 480px) {
  .field--sort { flex: 1 1 100%; }
  .field--sort select { flex: 1; }
  .brand-name { font-size: 1.125rem; }
  .stamp { font-size: 1.25rem; }
  .stamp--reserved { font-size: 1rem; }
}

/* Narrowest phones: the later (max-width: 480px) rule would otherwise win, so this sits last */
@media (max-width: 400px) {
  .brand-name { font-size: 1rem; }
}
