/* ClueLess Market — page-specific CSS layered on top of ../assets/sub.css
   (shared tokens, header/crumb/title chrome, .grid, .btn, .pill).

   Naming: new classes are prefixed "cm-" (ClueLess Market) so nothing
   collides with sub.css's own .grid/.card/.badge/.empty-note. The generic
   shell classes (.wrap, .panel, .field-group, .top-nav, footer, .modal...)
   deliberately repeat the names every other login-gated sub-site uses, so
   the Market looks like its siblings (copied from Recipe Box's style.css).

   IMPORTANT (site rule, 2026-10-22): sub.css has bare-tag rules
   `main {max-width:880px; padding:...}` and `section + section {margin-top:48px}`.
   We cancel both here with class selectors (.wrap, .wrap section + section)
   because a class beats a bare tag. */

a { color: inherit; }
body { line-height: 1.5; }

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 36px 24px 90px;
}
/* Cancel sub.css's `section + section { margin-top: 48px }` inside the page. */
.wrap section + section { margin-top: 0; }

/* ---------- header nav ---------- */
.top-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 14px;
}
.top-nav a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--cream-dim);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.top-nav a:hover { color: var(--cream); }
.top-nav a.active { color: var(--cream); border-bottom-color: var(--cream); }
/* Little number bubbles next to "Cart" and "Orders". */
.cm-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--cream-dim);
  color: var(--wine);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
.cm-count[hidden] { display: none; }
.cm-count-alert { background: var(--cream); color: var(--wine); }

/* ---------- footer ---------- */
footer {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 24px 40px;
  border-top: 1px solid var(--navy);
}
.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--wine);
}
.footer-auth { margin: 0; }

/* ---------- login modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 33, 97, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
/* Needed: the display:flex above would otherwise beat the HTML `hidden`
   attribute (author CSS wins ties over the browser default). */
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--paper);
  border: 1px solid var(--navy);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}
.modal h2 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  color: var(--wine);
  font-size: 22px;
}
.modal .actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- panels and form fields ---------- */
.panel {
  background: var(--paper);
  border: 1px solid var(--navy);
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 24px;
}
.panel h2 {
  font-family: var(--font-display);
  color: var(--wine);
  font-size: 22px;
  margin: 0 0 18px;
}
.panel h3 {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--wine);
  font-size: 18px;
  margin: 0 0 10px;
}
.field-group { margin-bottom: 16px; }
.field-group[hidden] { display: none; }
.field-group > label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  margin-bottom: 6px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.optional-tag {
  font-weight: 400;
  font-size: 11px;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-error { display: none; margin-top: 6px; font-size: 12px; color: var(--wine); font-weight: 500; }
.field-error.visible { display: block; }
.hint { margin-top: 6px; font-size: 12px; color: var(--navy); opacity: 0.7; }

input[type="text"], input[type="password"], input[type="url"], input[type="search"],
input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--navy);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-family: var(--font-ui);
  font-size: 14px;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--wine);
  outline-offset: 1px;
}
.field-group.invalid input[type="text"],
.field-group.invalid textarea { border-color: var(--wine); }
.field-group.invalid .field-error { display: block; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cm-actions { margin-top: 8px; }

/* Honeypot: pushed far off-screen (not display:none, which some bots detect). */
.cm-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* One-line messages and banners. */
.cm-banner {
  margin: 0 0 18px;
  padding: 12px 16px;
  border: 1px solid var(--navy);
  border-radius: 8px;
  background: var(--cream);
  font-size: 14px;
}
.cm-banner[hidden] { display: none; }
.cm-banner-error { border-color: var(--wine); color: var(--wine); }
.cm-banner ul { margin: 6px 0 0; padding-left: 20px; }
.cm-note {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--cream);
  font-size: 14px;
}
.cm-empty { text-align: center; padding: 36px 24px; }
.cm-empty p { margin: 0 0 16px; }
.cm-check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.cm-check input { accent-color: var(--wine); }
.cm-checks { display: flex; flex-direction: column; gap: 8px; }

/* ---------- chips (filters + tag pickers) ----------
   A chip is a <label> wrapping a real checkbox; the checkbox itself is
   visually hidden and the label is the pill. Works with no JavaScript. */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-chip {
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--navy);
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  user-select: none;
}
.cm-chip:hover { background: var(--cream-dim); }
.cm-chip input { position: absolute; opacity: 0; pointer-events: none; }
.cm-chip.on { background: var(--wine); border-color: var(--wine); color: var(--cream); }
.cm-chip:focus-within { outline: 2px solid var(--wine); outline-offset: 2px; }

/* ---------- browse: collapsible filter panel ---------- */
.filters { padding: 0; }
.filters summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 24px;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--wine);
  display: flex;
  align-items: center;
  gap: 10px;
}
.filters summary::-webkit-details-marker { display: none; }
.filters summary::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--wine);
  border-bottom: 2px solid var(--wine);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.filters[open] summary::after { transform: rotate(-135deg); }
.filters summary:focus-visible { outline: 2px solid var(--wine); outline-offset: -2px; border-radius: 12px; }
.filter-count { font-family: var(--font-ui); font-size: 12px; color: var(--navy); opacity: 0.7; }
.filters-body { padding: 4px 24px 18px; }
.filter-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.filter-row .field-group { min-width: 0; }
.cm-filter-actions { display: flex; gap: 10px; }
.results-count { margin: 0 0 14px; }

/* ---------- browse: item cards (columns come from sub.css .grid) ---------- */
.cm-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--navy);
  border-radius: 12px;
  overflow: hidden;
  color: var(--navy);
}
.cm-card-photo {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--cream);
  border-bottom: 1px solid var(--navy);
}
.cm-card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-noimg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.4;
}
/* Pending / Sold items: photo greyed out with a ribbon, like Marketplace. */
.cm-pending .cm-card-photo img, .cm-sold .cm-card-photo img { filter: grayscale(1); opacity: 0.55; }
.cm-pending .cm-card-body h2, .cm-sold .cm-card-body h2 { opacity: 0.6; }
.cm-ribbon {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--wine);
  color: var(--cream);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cm-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.cm-card-body h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1.25;
  color: var(--wine);
}
.cm-card-body h2 a { text-decoration: none; color: inherit; }
.cm-card-body h2 a:hover { text-decoration: underline; }
.cm-price { font-size: 17px; font-weight: 600; }
.cm-price-big { font-size: 26px; margin-bottom: 10px; }
.cm-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-pill-tag { background: var(--cream-dim); text-decoration: none; }
.cm-pill-pickup { background: var(--wine); color: var(--cream); }
.cm-card .cm-add { margin-top: auto; justify-content: center; }
.cm-card .hint { margin-top: 0; text-align: center; }

/* ---------- item page ---------- */
.cm-back { margin: 0 0 16px; font-size: 13px; }
.cm-back a { text-decoration: none; color: var(--wine); }
.cm-back a:hover { text-decoration: underline; }
.cm-detail { display: block; }
.cm-detail.has-photos {
  display: grid;
  grid-template-columns: minmax(0, 480px) 1fr;
  gap: 24px;
  align-items: start;
}
.cm-gallery-main {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--navy);
  border-radius: 12px;
  overflow: hidden;
}
.cm-gallery-main img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.cm-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cm-thumb {
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--navy);
  border-radius: 8px;
  overflow: hidden;
  background: var(--cream);
  cursor: pointer;
  opacity: 0.7;
}
.cm-thumb.on, .cm-thumb:hover { opacity: 1; outline: 2px solid var(--wine); outline-offset: 1px; }
.cm-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-info h2 { font-size: 30px; line-height: 1.15; margin: 0 0 8px; }
.cm-desc { margin: 16px 0; font-size: 15px; line-height: 1.65; }
.cm-buy { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 4px; }
.cm-buy label { font-size: 13px; font-weight: 500; }
.cm-buy input[type="number"] { width: 80px; }
.cm-code { margin-top: 18px; }

/* ---------- cart + checkout ---------- */
.cm-checkout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
.cm-checkout .panel { margin-bottom: 0; }
.cm-line {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--cream-dim);
}
.cm-line:first-child { border-top: none; padding-top: 0; }
.cm-line-photo {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--navy);
  background: var(--cream);
}
.cm-line-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-line-name { font-weight: 500; text-decoration: none; }
.cm-line-name:hover { text-decoration: underline; }
.cm-line-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.cm-line-side input[type="number"] { width: 70px; padding: 6px 8px; }
.cm-line-bad .cm-line-name { text-decoration: line-through; opacity: 0.6; }
.cm-line-warn { color: var(--wine); font-size: 12px; font-weight: 500; }
.cm-linkbtn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--wine);
  text-decoration: underline;
  cursor: pointer;
}
.cm-radios { display: flex; flex-direction: column; gap: 8px; }
.cm-totals { margin: 4px 0 16px; border-top: 1px solid var(--cream-dim); padding-top: 12px; }
.cm-totals div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; }
.cm-totals .cm-grand { font-weight: 600; font-size: 17px; border-top: 1px solid var(--navy); margin-top: 6px; padding-top: 8px; }

/* ---------- order-received page ---------- */
.cm-done-lines { margin: 14px 0; padding: 0; list-style: none; }
.cm-done-lines li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--cream-dim); }

/* ---------- admin: items list ---------- */
.cm-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cm-panel-head h2 { margin: 0; }
.manage-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--cream-dim);
}
.manage-thumb {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px dashed var(--navy);
  background: var(--cream);
}
.manage-thumb:has(img) { border-style: solid; }
.manage-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.manage-main { flex: 1; min-width: 0; }
.manage-title { font-family: var(--font-display); color: var(--wine); font-size: 17px; text-decoration: none; }
.manage-title:hover { text-decoration: underline; }
.manage-sub { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.manage-row-actions { display: flex; gap: 8px; flex: none; }
.manage-row-actions form { margin: 0; }
.cm-status-available { color: #1b5e20; }
.cm-status-pending { color: #8a5a00; }
.cm-status-sold { color: var(--wine); }

/* admin: tag editor and inline forms */
.cm-taggroup { margin-bottom: 20px; }
.cm-tagchip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--cream-dim);
  border-radius: 10px;
  background: #fff;
}
.cm-tagchip input[type="text"] { width: auto; padding: 6px 8px; }
.cm-tagchip .hint { margin: 0; }
.cm-tagchip .btn { padding: 5px 10px; font-size: 12px; }
.cm-tagchip .btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.cm-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.cm-inline input[type="text"] { width: auto; flex: 1 1 200px; max-width: 320px; }
.cm-inline #ship-amt { flex: none; width: 90px; }

/* admin: item form photos */
.cm-photo-edit { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.cm-photo-tile {
  width: 130px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.cm-photo-tile img { width: 130px; height: 100px; object-fit: cover; border-radius: 8px; border: 1px solid var(--navy); }
.cm-photo-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cm-photo-preview img { width: 76px; height: 76px; object-fit: cover; border-radius: 8px; border: 1px solid var(--navy); }

/* admin: orders */
.cm-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.cm-tabs a {
  padding: 7px 14px;
  border: 1px solid var(--navy);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--navy);
}
.cm-tabs a:hover { background: var(--cream-dim); }
.cm-tabs a.active { background: var(--wine); border-color: var(--wine); color: var(--cream); }
.cm-tabs a.active .cm-count { background: var(--cream); }
.cm-order { margin-bottom: 18px; }
.cm-order-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.cm-order-head h2 { margin: 0; }
.cm-order-head .hint { margin: 0; }
.cm-order-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cm-dl { margin: 0; display: grid; grid-template-columns: 100px 1fr; gap: 8px 12px; font-size: 14px; }
.cm-dl dt { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.65; padding-top: 3px; }
.cm-dl dd { margin: 0; word-break: break-word; }
.cm-dl .btn { padding: 3px 10px; font-size: 12px; margin-left: 4px; }
.cm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cm-table td { padding: 6px 0; border-bottom: 1px solid var(--cream-dim); vertical-align: top; }
.cm-table td.num { text-align: right; white-space: nowrap; }
.cm-table .cm-total td { font-weight: 600; border-bottom: none; border-top: 1px solid var(--navy); }
.cm-order-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--cream-dim); }
.cm-order-actions input[type="text"] { flex: 1 1 220px; width: auto; }
.cm-st-pending { background: #f3e0a8; }
.cm-st-accepted { background: #cfe8cf; }
.cm-st-declined, .cm-st-cancelled { background: var(--cream-dim); opacity: 0.8; }
.cm-order-declined, .cm-order-cancelled { opacity: 0.75; }

/* ---------- responsive ----------
   860px: two-column layouts (photo+info, cart+checkout, order columns)
   collapse to one. 640px is the project's mobile-portrait target:
   tighter spacing, stacked form rows. */
@media (max-width: 860px) {
  .cm-detail.has-photos { grid-template-columns: 1fr; }
  .cm-checkout { grid-template-columns: 1fr; }
  .cm-order-grid { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 640px) {
  .wrap { padding: 24px 16px 60px; }
  .field-row, .field-row.three, .filter-row { grid-template-columns: 1fr; }
  .filters summary { padding: 14px 18px; }
  .filters-body { padding: 4px 18px 18px; }
  .panel { padding: 18px; }
  .panel.filters { padding: 0; }
  .cm-card-photo { aspect-ratio: 16 / 10; }
  .cm-info h2 { font-size: 26px; }
  .manage-row { flex-wrap: wrap; }
  .manage-row-actions { width: 100%; }
  .cm-dl { grid-template-columns: 90px 1fr; }
  .cm-line { grid-template-columns: 56px 1fr; }
  .cm-line-photo { width: 56px; height: 56px; }
  .cm-line-side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
  footer { padding: 18px 16px 32px; }
}
