/* =========================================================================
   padlás — warm editorial classifieds / risograph
   Fraunces (display) · Hanken Grotesk (body) · Space Mono (labels)
   ========================================================================= */
:root {
  --paper:      #ece0cd;
  --paper-2:    #f4ebdb;
  --card:       #f7f1e6;
  --ink:        #211c17;
  --ink-soft:   #5c5245;
  --line:       #211c17;
  --sell:       #d8481f;   /* spot orange — eladó */
  --sell-ink:   #8f2b0f;
  --give:       #2f6f47;   /* spot green — elvihető */
  --give-ink:   #1d4a2e;
  --muted:      #b9ab93;
  --danger:     #a3241a;
  --shadow:     4px 4px 0 var(--ink);
  --shadow-sm:  2px 2px 0 var(--ink);
  --radius:     3px;
  --font-disp:  "Fraunces", Georgia, serif;
  --font-body:  "Hanken Grotesk", system-ui, sans-serif;
  --font-mono:  "Space Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* grain overlay for paper texture */
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

a { color: inherit; }
img { max-width: 100%; display: block; }

/* ------------------------------------------------------------------ layout */
.wrap {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 18px 80px;
}

/* ---------------------------------------------------------------- masthead */
.masthead {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 18px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 3px solid var(--line);
}
.brand { text-decoration: none; display: block; line-height: 0.9; }
.brand-mark {
  font-family: var(--font-disp);
  font-weight: 900;
  font-size: clamp(30px, 9vw, 44px);
  letter-spacing: -0.02em;
  display: block;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.masthead-actions { display: flex; align-items: center; gap: 8px; }

/* -------------------------------------------------------------------- btns */
.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  padding: 9px 14px;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn-accent { background: var(--sell); color: #fff; border-color: var(--ink); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:active { transform: translate(1px, 1px); }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 18px; font-size: 15px; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); box-shadow: none; }
.btn-copy {
  padding: 5px 10px;
  font-size: 11px;
  box-shadow: none;
  background: var(--card);
}
.btn-copy.copied { background: var(--give); color: #fff; border-color: var(--ink); }

/* ------------------------------------------------------------------ titles */
.page-title {
  font-family: var(--font-disp);
  font-weight: 900;
  font-size: clamp(28px, 7vw, 38px);
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}
.page-lede { color: var(--ink-soft); margin: 0 0 22px; font-size: 15px; }

/* ------------------------------------------------------------------ fields */
.field { display: block; margin-bottom: 16px; }
.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 6px;
}
.field-label em { font-style: normal; text-transform: none; opacity: 0.7; font-weight: 400; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 11px 12px;
  box-shadow: var(--shadow-sm);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: var(--shadow);
  background: #fffdf7;
}
textarea { resize: vertical; line-height: 1.55; min-height: 96px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field-narrow { max-width: 42%; }

/* -------------------------------------------------------------- segmented */
.segmented {
  border: none;
  padding: 0;
  margin: 0 0 16px;
}
.segmented .field-label { padding: 0; }
.seg {
  display: inline-flex;
  cursor: pointer;
  margin-right: 8px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: inline-block;
}
.seg input:checked + span { transform: translate(2px, 2px); box-shadow: none; }
.seg-sell input:checked + span { background: var(--sell); color: #fff; }
.seg-give input:checked + span { background: var(--give); color: #fff; }
.seg-both input:checked + span { background: var(--ink); color: var(--paper-2); }

/* ----------------------------------------------------------------- capture */
.dropzone {
  display: block;
  border: 3px dashed var(--ink);
  border-radius: var(--radius);
  background: var(--paper-2);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 18px;
  transition: background 0.12s;
}
.dropzone:hover { background: #fffdf7; }
.dropzone.dragover { background: #fff7e6; border-style: solid; }
.dropzone-icon { font-size: 34px; display: block; line-height: 1; }
.dropzone-text {
  font-family: var(--font-disp);
  font-weight: 600;
  font-size: 19px;
  display: block;
  margin-top: 8px;
}
.dropzone-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  display: block;
  margin-top: 4px;
}
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; justify-content: center; }
.thumbs:empty { display: none; }
.thumbs img {
  width: 72px; height: 72px; object-fit: cover;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------- inventory */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  padding: 7px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter.is-active { background: var(--ink); color: var(--paper-2); }
.filter-count {
  font-size: 10px;
  background: rgba(0,0,0,0.12);
  border-radius: 999px;
  padding: 1px 6px;
}
.filter.is-active .filter-count { background: rgba(255,255,255,0.22); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.card {
  text-decoration: none;
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.card:active { transform: translate(2px, 2px); box-shadow: none; }
.card-photo { position: relative; aspect-ratio: 4 / 3; background: var(--paper); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-photo-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft);
}
.badge-status {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 999px;
  padding: 2px 8px;
}
.status-posted .badge-status { background: var(--sell); color: #fff; }
.status-gone   .badge-status { background: var(--ink); color: var(--paper-2); }
.card-body { padding: 12px 12px 14px; border-top: 2.5px solid var(--ink); }
.card-title {
  font-family: var(--font-disp);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.15;
  margin: 0 0 8px;
}
.status-gone .card-title { text-decoration: line-through; opacity: 0.6; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 2px solid var(--ink);
}
.tag-price { background: var(--sell); color: #fff; }
.tag-give  { background: var(--give); color: #fff; }
.tag-muted { background: transparent; color: var(--ink-soft); border-color: var(--muted); }
.card-posted {
  font-family: var(--font-mono); font-size: 11px; color: var(--give-ink);
  margin: 8px 0 0;
}

/* -------------------------------------------------------------------- empty */
.empty { text-align: center; padding: 60px 20px; }
.empty-mark { font-size: 54px; margin: 0; opacity: 0.5; }
.empty-title { font-family: var(--font-disp); font-weight: 900; font-size: 26px; margin: 10px 0 2px; }
.empty-sub { color: var(--ink-soft); margin: 0 0 20px; }

/* ------------------------------------------------------------------ detail */
.back {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700; text-decoration: none;
  color: var(--ink-soft); display: inline-block; margin-bottom: 14px;
}
.photostrip {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 6px; margin-bottom: 18px;
  scroll-snap-type: x mandatory;
}
.photostrip img {
  height: 150px; width: auto; flex: 0 0 auto;
  border: 2.5px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  scroll-snap-align: start;
}
.detail-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
}
.status-control { display: flex; gap: 6px; }
.status-pill {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 7px 12px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: var(--card); color: var(--ink); cursor: pointer;
}
.status-pill-draft.is-on  { background: var(--muted); color: var(--ink); }
.status-pill-posted.is-on { background: var(--sell); color: #fff; }
.status-pill-gone.is-on   { background: var(--ink); color: var(--paper-2); }

.post-block {
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.post-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 2.5px solid var(--ink);
}
.post-sell .post-head { background: var(--sell); }
.post-give .post-head { background: var(--give); }
.post-label {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: #fff;
}
.post-block textarea {
  border: none; box-shadow: none; border-radius: 0;
  background: var(--card);
}
.post-block textarea:focus { background: #fffdf7; box-shadow: none; }

.editor-actions { margin-top: 20px; }
.danger-zone { margin-top: 40px; text-align: center; }

/* ------------------------------------------------------------------ banner */
.banner {
  padding: 10px 14px;
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 18px;
}
.banner-error { background: #f7dcd3; border-color: var(--danger); color: var(--sell-ink); }

/* ------------------------------------------------------------------- login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 28px;
  width: 100%; max-width: 360px;
  text-align: center;
}
.login-mark { font-family: var(--font-disp); font-weight: 900; font-size: 42px; letter-spacing: -0.02em; }
.login-tag {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-soft); margin: 0 0 22px;
}
.login-form .field { text-align: left; }

/* ----------------------------------------------------------------- overlay */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(33, 28, 23, 0.72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.overlay-card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 34px;
  text-align: center;
  max-width: 300px;
}
.overlay-card p { font-family: var(--font-disp); font-weight: 600; font-size: 18px; margin: 14px 0 2px; }
.overlay-sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }
.spinner {
  width: 34px; height: 34px; margin: 0 auto;
  border: 4px solid var(--muted);
  border-top-color: var(--sell);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* htmx indicator: hidden unless request in flight */
.htmx-indicator { display: none; }
.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator { display: flex; }
#gen-overlay.htmx-indicator { display: none; }
#gen-overlay.htmx-request { display: flex; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 460px) {
  .field-row { flex-direction: column; gap: 0; }
  .field-narrow { max-width: 100%; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card-title { font-size: 16px; }
}
