/* Pick n' Puller — mobile-first, dark. */

:root {
  --bg: #0e1116;
  --surface: #161b23;
  --surface-2: #1d232d;
  --line: #2a323e;
  --text: #e8edf5;
  --muted: #93a1b5;
  --accent: #ffb02e;      /* Pick-n-Pull yellow */
  --accent-ink: #1b1200;
  --new: #35d07f;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

/* `display: flex` on .sheet would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body.locked { overflow: hidden; }

/* ------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-t) + 10px) 14px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-row { display: flex; align-items: center; justify-content: space-between; }

.topbar h1 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.2px;
}
.topbar h1::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateY(-1px);
}

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

.statusline {
  display: flex; justify-content: space-between; gap: 10px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.statusline b { color: var(--text); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { margin-top: 0; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}
.chip span { color: var(--muted); font-size: 14px; line-height: 1; }

/* -------------------------------------------------------------- results */

main { padding: 10px 12px calc(28px + var(--safe-b)); }

.results { display: flex; flex-direction: column; gap: 9px; }

.card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 11px;
  padding: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
}
.card:active { background: var(--surface-2); }

.thumb {
  width: 92px; height: 70px;
  border-radius: 9px;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
}
.thumb.placeholder {
  display: grid; place-items: center;
  color: var(--line);
  font-size: 24px;
}

.card-main { min-width: 0; }

.card-title {
  font-size: 15.5px;
  font-weight: 640;
  letter-spacing: -0.15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-foot {
  margin-top: 5px;
  display: flex; align-items: center; gap: 7px;
  font-size: 12px;
}

.badge {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .2px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge.fresh { background: var(--new); color: #04200f; border-color: transparent; }
.badge.row { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.divider {
  margin: 14px 2px 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}
.divider:first-child { margin-top: 2px; }

.btn-more {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.empty { text-align: center; padding: 56px 20px; }
.empty-title { font-size: 17px; font-weight: 650; margin: 0 0 4px; }
.empty-sub { color: var(--muted); margin: 0 0 16px; font-size: 13.5px; }

/* --------------------------------------------------------------- sheets */

.backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  animation: rise .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translateY(100%); } }

@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto;
    width: 560px;
    transform: translateX(-50%);
    animation: none;
  }
}

.sheet-grip {
  width: 38px; height: 4px;
  margin: 9px auto 2px;
  border-radius: 2px;
  background: var(--line);
  flex: none;
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.sheet-head h2 { margin: 0; font-size: 17px; }

.sheet-body {
  padding: 14px 16px calc(22px + var(--safe-b));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.field { display: block; margin-bottom: 14px; }
.field-row { display: flex; gap: 10px; align-items: flex-end; }
.field-row .field { flex: 1; margin-bottom: 0; }
.field-row.tight { align-items: center; }
.dash { color: var(--muted); font-size: 13px; }

.label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--muted);
}
.out { color: var(--accent); text-transform: none; letter-spacing: 0; }

input[type=text], input[type=search], input[type=number], select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;            /* 16px stops iOS from zooming on focus */
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393a1b5' stroke-width='2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 17px;
  padding-right: 34px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

input[type=range] {
  width: 100%;
  height: 28px;
  background: transparent;
  appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px; background: var(--surface-2);
}
input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 22px; height: 22px;
  margin-top: -8.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
}
input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--surface-2); }
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border: 3px solid var(--surface);
  border-radius: 50%; background: var(--accent);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.check input {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.check input::after {
  content: "";
  width: 11px;
  height: 6px;
  border: 2.5px solid var(--accent-ink);
  border-top: 0;
  border-right: 0;
  border-radius: 1px;
  transform: rotate(-45deg) translate(1px, -1px) scale(0);
  transition: transform .12s ease;
}
.check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.check input:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.yardlist {
  display: flex; flex-wrap: wrap; gap: 5px;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.yardlist span {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.yardlist span.out-of-range { opacity: .35; text-decoration: line-through; }

.advanced { margin: 4px 0 14px; }
.advanced summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 0;
}
.advanced[open] summary { margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }

.btn-primary, .btn-ghost {
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 640;
  border-radius: 11px;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border: none; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.wide { width: 100%; }

/* --------------------------------------------------------------- detail */

.detail .sheet-body { padding-top: 8px; }

.detail-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 13px;
  background: var(--surface-2);
  margin-bottom: 13px;
}

.detail h3 { margin: 0 0 3px; font-size: 21px; letter-spacing: -0.3px; }
.detail .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }

.kv {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 7px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-all; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions a, .detail-actions button {
  flex: 1 1 45%;
  text-align: center;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 620;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}
.detail-actions a.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 60;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 620;
  animation: rise .2s ease;
}

.skeleton {
  height: 90px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}
