/* ---------------------------------------------------------------------
   Design tokens
   Palette pulled from a job-site tag: kraft-paper background, steel-grey
   ink, safety-yellow for prices (the one loud color), rust red reserved
   only for the SOLD stamp.
--------------------------------------------------------------------- */
:root {
  --paper:        #E7E2D6;
  --paper-card:   #FBF9F4;
  --ink:          #262119;
  --ink-soft:     #5B5548;
  --steel:        #45585F;
  --steel-dark:   #2E3B40;
  --yellow:       #F0B429;
  --yellow-ink:   #3A2C05;
  --rust:         #A6402C;
  --line:         #D4CDBB;
  --radius:       10px;

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'IBM Plex Mono', 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--steel-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--steel);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Header / nav
--------------------------------------------------------------------- */
.site-header {
  background: var(--steel-dark);
  border-bottom: 4px solid var(--yellow);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #F4F1E8;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 12px;
  height: 12px;
  background: var(--yellow);
  border-radius: 2px;
  transform: rotate(45deg);
  flex-shrink: 0;
}
.site-nav { display: flex; gap: 18px; }
.site-nav a { color: #D8D3C4; font-size: 0.92rem; font-weight: 500; }
.site-nav a:hover { color: #fff; }

.site-footer {
  margin-top: 60px;
  padding: 22px 0 40px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------------------------------------------------------------------
   Flash messages
--------------------------------------------------------------------- */
.flash-stack { padding-top: 18px; }
.flash {
  background: #FFF6DC;
  border: 1px solid var(--yellow);
  color: var(--yellow-ink);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------------
   Category filter
--------------------------------------------------------------------- */
.category-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 8px;
}
.category-filter label { font-size: 0.85rem; font-weight: 600; color: var(--ink-soft); }
.category-filter select {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

/* ---------------------------------------------------------------------
   Type / condition pills (reuse .pill base from admin section below)
--------------------------------------------------------------------- */
.pill-new { background: #E4F0E9; color: #2E6B4A; }
.pill-used { background: #EFEBE0; color: var(--ink-soft); }
.pill-condition { background: #F7F0DD; color: #8A6A1A; }

.tag-category { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Photo toggle button on cards with two photos */
.tag-photo { position: relative; }
.photo-toggle {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(251, 249, 244, 0.92);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  z-index: 3;
}
.photo-toggle:hover { background: #fff; }

/* ---------------------------------------------------------------------
   Quick sale calculator (admin page)
--------------------------------------------------------------------- */
.calculator-panel {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 28px;
  padding: 4px 16px;
}
.maintenance-toggle-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 16px;
  padding: 14px 18px;
}
.maintenance-toggle-panel p { margin: 0; font-size: 0.92rem; color: var(--ink-soft); }
.maintenance-toggle-panel.is-active {
  border-color: var(--yellow);
  background: #FFF6DC;
}
.maintenance-toggle-panel.is-active p { color: var(--yellow-ink); }
.calculator-panel summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  padding: 12px 0;
  font-size: 1.05rem;
}
.calculator-body { padding: 4px 0 18px; max-width: 340px; }
.calc-section-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 14px 0 6px;
}
.calc-math-row { display: flex; gap: 6px; align-items: center; }
.calc-math-row input, .calc-math-row select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 8px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-width: 0;
}
.calc-math-row input { flex: 1; }
.calc-math-row select { flex: 0 0 56px; text-align: center; }
.calc-math-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 8px 0 4px;
}
.calc-add-row { display: flex; gap: 8px; margin-bottom: 10px; }
.calc-add-row input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.calc-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.calc-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}
.calc-remove {
  border: none;
  background: none;
  color: var(--rust);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.calc-total-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  margin-bottom: 8px;
}

/* ---------------------------------------------------------------------
   Hero banner (optional - only shows if static/banner.jpg exists)
--------------------------------------------------------------------- */
.hero-banner {
  margin-top: 28px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
}
.hero-banner img {
  display: block;
  width: 100%;
  height: 320px;
  object-fit: cover;
}
@media (max-width: 640px) {
  .hero-banner img { height: 200px; }
}

/* ---------------------------------------------------------------------
   Photo grid (public catalog)
--------------------------------------------------------------------- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 14px;
  padding: 30px 0 20px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #EFEBE0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.photo-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(38,33,25,0.12);
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile-placeholder { color: var(--line); }
.photo-tile.is-sold img { filter: grayscale(70%); opacity: 0.75; }
.tile-item-number {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(34, 31, 26, 0.75);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  line-height: 1.4;
}

/* ---------------------------------------------------------------------
   Item detail overlay
--------------------------------------------------------------------- */
.item-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(34, 31, 26, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.item-overlay.is-open { display: flex; }
body.overlay-locked { overflow: hidden; }

.item-overlay-card {
  position: relative;
  background: var(--paper-card);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.item-overlay-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(251, 249, 244, 0.95);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  z-index: 4;
  color: var(--ink);
}
.item-overlay-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #EFEBE0;
}
.item-overlay-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-overlay-body { padding: 18px 20px 22px; }
.item-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--steel);
  margin: 0 0 4px;
}
.item-overlay-body h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--ink);
}

/* ---------------------------------------------------------------------
   Catalog intro
--------------------------------------------------------------------- */
.catalog-intro { padding-top: 40px; max-width: 640px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--steel);
  margin: 0 0 6px;
}
.catalog-intro h1 {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--ink);
}
.intro-text { color: var(--ink-soft); margin: 0 0 14px; }
.contact-line { font-family: var(--font-mono); font-size: 0.92rem; }
.contact-sep { margin: 0 8px; color: var(--ink-soft); }

/* ---------------------------------------------------------------------
   Tag grid (public catalog)
--------------------------------------------------------------------- */
.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  padding: 36px 0 20px;
}

.tag-card {
  position: relative;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 0 rgba(0,0,0,0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.tag-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(38,33,25,0.1);
}
.tag-hole {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--line);
  z-index: 2;
}
.tag-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #EFEBE0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tag-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag-photo-placeholder { color: var(--line); }
.sold-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-10deg);
  border: 3px solid var(--rust);
  color: var(--rust);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.12em;
  padding: 4px 14px;
  border-radius: 6px;
  background: rgba(251, 249, 244, 0.85);
}
.tag-card.is-sold .tag-photo img { filter: grayscale(70%); opacity: 0.75; }

.tag-body { padding: 14px 16px 6px; flex: 1; }
.tag-category {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--steel);
  margin: 0 0 4px;
}
.tag-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
}
.tag-field {
  font-size: 0.88rem;
  color: var(--ink);
  margin: 0 0 4px;
}
.tag-field-label {
  font-weight: 600;
  color: var(--steel);
}
.tag-desc { margin-top: 6px; color: var(--ink-soft); }

.tag-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px 16px;
}
.price-stamp {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  background: var(--yellow);
  color: var(--yellow-ink);
  padding: 4px 10px;
  border-radius: 5px;
  transform: rotate(-2deg);
}
.price-stamp-muted { background: transparent; border: 1px dashed var(--line); color: var(--ink-soft); transform: none; }
.tag-contact { font-size: 0.85rem; font-weight: 500; }

.show-sold-toggle { margin: 8px 0 40px; font-size: 0.88rem; }

.empty-state {
  padding: 60px 0;
  text-align: center;
  color: var(--ink-soft);
}
.maintenance-notice {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--yellow);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  margin: 20px 0 60px;
}
.maintenance-notice p {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  margin: 0 0 6px;
}
.maintenance-notice p:last-child { color: var(--ink-soft); font-family: var(--font-body); font-size: 0.95rem; }

/* ---------------------------------------------------------------------
   Forms (login, add/edit)
--------------------------------------------------------------------- */
.login-panel {
  max-width: 360px;
  margin: 60px auto;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.login-panel h1 { font-family: var(--font-display); font-size: 1.3rem; margin-top: 0; }

.stack-form { display: flex; flex-direction: column; gap: 6px; }
.stack-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-top: 10px;
}
.stack-form .optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-soft); }
.stack-form input[type="text"],
.stack-form input[type="password"],
.stack-form input[type="number"],
.stack-form input[type="file"],
.stack-form select,
.stack-form textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
.stack-form textarea { resize: vertical; }

.item-form { max-width: 480px; padding-bottom: 60px; }
.field-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 16px 16px;
  margin: 14px 0 4px;
}
.field-group legend {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--steel);
  padding: 0 6px;
}
.field-group label { margin-top: 12px; }
.field-group label:first-of-type { margin-top: 4px; }
.current-photo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.current-photo img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

/* ---------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: #F2EFE6; text-decoration: none; }
.btn-primary { background: var(--steel-dark); border-color: var(--steel-dark); color: #fff; margin-top: 14px; align-self: flex-start; }
.btn-primary:hover { background: var(--steel); }
.btn-small { padding: 6px 10px; font-size: 0.82rem; }
.btn-danger { color: var(--rust); border-color: var(--rust); background: #fff; }
.btn-danger:hover { background: #FBEAE6; }

/* ---------------------------------------------------------------------
   Admin listing
--------------------------------------------------------------------- */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 40px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-header h1 { font-family: var(--font-display); font-size: 1.5rem; margin: 0; }

.admin-list { padding: 24px 0 40px; display: flex; flex-direction: column; gap: 10px; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  flex-wrap: wrap;
}
.admin-row.is-sold { opacity: 0.7; }
.admin-row-photo img, .admin-row-photo-placeholder {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  background: #EFEBE0;
  display: block;
}
.admin-row-info { flex: 1; min-width: 160px; }
.admin-row-name { font-weight: 600; margin: 0 0 2px; display: flex; align-items: center; gap: 8px; }
.item-number-inline {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--steel);
  background: #EFEBE0;
  padding: 2px 6px;
  border-radius: 5px;
}
.admin-row-meta { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-soft); margin: 0; }
.admin-row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-row-actions form { display: contents; }

.pill {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
}
.pill-sold { background: #F6E5E0; color: var(--rust); }

/* ---------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------- */
@media (max-width: 520px) {
  .site-header-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .tag-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .admin-row { flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  .tag-card { transition: none; }
}
