/* Favorwright — Porch Pegboard Favor Queue */

:root {
  --cream: #f4e7cc;
  --cream-deep: #ecd9b4;
  --paper: #fffaf0;
  --green: #2e6b5b;
  --green-soft: #d8e6de;
  --marigold: #d9822b;
  --marigold-deep: #b96a1e;
  --clay: #b45a3c;
  --ink: #2b2a26;
  --ink-soft: #6b6252;
  --wood: #e9d5a8;
  --wood-deep: #dcc48d;
  --bar: #2b261e;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(43, 42, 38, 0.14);
  --tabbar-h: 66px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid var(--marigold);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */

.view {
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-h) + 26px + env(safe-area-inset-bottom));
}

.kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
  margin: 0 0 2px;
}

h1.view-title {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 4px;
  color: var(--ink);
}

.view-sub {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Pegboard rail + counters (Porch) ---------- */

.rail {
  background: var(--cream-deep);
  background-image: radial-gradient(rgba(43, 42, 38, 0.16) 1.6px, transparent 1.7px);
  background-size: 16px 16px;
  border: 1px solid var(--wood-deep);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.counters {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-bottom: 12px;
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 64px;
}

.counter-disc {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  border: 2px solid var(--ink);
  box-shadow: inset 0 -2px 0 rgba(43, 42, 38, 0.18);
}

.counter-open .counter-disc { background: var(--marigold); color: #fffaf0; }
.counter-helped .counter-disc { background: var(--paper); color: var(--green); }

.counter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.add-strip {
  display: block;
  width: 100%;
  min-height: 56px;
  border-radius: 12px;
  background: var(--marigold);
  color: #fffaf0;
  font-weight: 800;
  font-size: 17px;
  box-shadow: 0 3px 0 var(--marigold-deep);
  padding: 12px 16px;
}

.add-strip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--marigold-deep); }

/* ---------- Cards ---------- */

.pegcard {
  display: block;
  width: 100%;
  text-align: left;
  background: linear-gradient(180deg, #efddb2, var(--wood));
  border: 1px solid var(--wood-deep);
  border-radius: 12px;
  padding: 12px 14px 12px 18px;
  box-shadow: var(--shadow);
}

.pinned-label {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 8px;
}

.pegcard .pegrow-name { font-size: 17px; }
.pegcard .pegrow-need { font-size: 15px; }

.pegcard-empty {
  background: transparent;
  border: 2px dashed var(--wood-deep);
  box-shadow: none;
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
  padding: 18px 14px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- Favored rows ---------- */

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 20px 0 8px;
}

.group-title:first-of-type { margin-top: 4px; }

.group-title .dot { width: 9px; height: 9px; }
.group-title .count {
  background: var(--cream-deep);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  color: var(--ink);
}

.peglist {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pegrow {
  display: flex;
  align-items: stretch;
  gap: 8px;
  background: linear-gradient(180deg, #efddb2, var(--wood));
  border: 1px solid var(--wood-deep);
  border-left: 7px solid var(--edge, var(--green));
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(43, 42, 38, 0.12);
  overflow: hidden;
}

.edge-green { --edge: var(--green); }
.edge-marigold { --edge: var(--marigold); }
.edge-clay { --edge: var(--clay); }
.edge-ink { --edge: var(--ink); }

.pegrow-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 6px 10px 10px;
  min-height: 56px;
}

.pegrow-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pegrow-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pegrow-need {
  font-size: 14px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pegrow-timing {
  font-size: 12px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pegrow-status {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
}

.status-word.open { color: var(--marigold-deep); }
.status-word.helped { color: var(--green); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-filled { background: var(--marigold); border: 2px solid var(--marigold-deep); }
.dot-hollow { background: transparent; border: 2px solid var(--green); }

.pegrow-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px 6px 0;
  flex-shrink: 0;
}

.mini-btn {
  min-width: 44px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--paper);
  border: 1px solid var(--wood-deep);
  color: var(--green);
}

.mini-btn:active { background: var(--green-soft); }

.mini-danger { color: var(--clay); }
.mini-danger:active { background: #f3ddd3; }

/* ---------- Forms ---------- */

.favor-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.field .hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin: -2px 0 0;
}

.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--wood-deep);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 48px;
  width: 100%;
}

.field textarea { resize: vertical; min-height: 64px; }

.field input.invalid,
.field select.invalid,
.field textarea.invalid { border-color: var(--clay); background: #fdf3ec; }

.field-error {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--clay);
}

.btn-primary {
  min-height: 52px;
  border-radius: 12px;
  background: var(--green);
  color: #fffaf0;
  font-weight: 800;
  font-size: 16px;
  padding: 12px 16px;
  box-shadow: 0 3px 0 #1f5044;
}

.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #1f5044; }

.btn-danger {
  min-height: 46px;
  border-radius: 10px;
  background: var(--clay);
  color: #fffaf0;
  font-weight: 700;
  padding: 10px 16px;
}

.btn-ghost {
  min-height: 46px;
  border-radius: 10px;
  border: 2px solid var(--wood-deep);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  padding: 10px 16px;
}

.form-note {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
}

/* ---------- Find tab ---------- */

.search-wrap { margin-bottom: 12px; }

.search-input {
  font: inherit;
  font-size: 16px;
  width: 100%;
  min-height: 50px;
  border: 2px solid var(--wood-deep);
  border-radius: 12px;
  background: var(--paper);
  padding: 10px 14px;
  color: var(--ink);
}

.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--wood-deep);
  background: var(--paper);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
}

.chip.is-active {
  background: var(--green);
  border-color: var(--green);
  color: #fffaf0;
}

/* ---------- Empty states ---------- */

.empty {
  border: 2px dashed var(--wood-deep);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  background: rgba(255, 250, 240, 0.5);
}

.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- About / settings panel ---------- */

.about-panel {
  margin-top: 26px;
  border: 1px solid var(--wood-deep);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px;
}

.about-panel h2 {
  font-size: 14px;
  margin: 0 0 6px;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.about-panel p {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

/* ---------- Bottom tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  background: var(--bar);
  border-top: 3px solid #463e2f;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  color: #b7ab93;
  border-radius: 10px;
}

.tab .peg { color: #8a8070; transition: transform 0.16s ease, color 0.16s ease; }

.tab-label { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }

.tab.is-active { color: var(--cream); }
.tab.is-active .peg {
  color: var(--marigold);
  transform: translateY(-3px);
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.45));
}

/* Peg silhouette */
.peg { position: relative; display: block; width: 22px; height: 20px; }
.peg::before {
  content: "";
  position: absolute;
  top: 0;
  left: 3px;
  width: 16px;
  height: 12px;
  border-radius: 8px 8px 3px 3px;
  background: currentColor;
}
.peg::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 8px;
  width: 6px;
  height: 9px;
  border-radius: 0 0 2px 2px;
  background: currentColor;
}

/* ---------- Edit sheet ---------- */

.sheet, .modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal { align-items: center; }

.sheet-scrim, .modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(43, 42, 38, 0.5);
}

.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 88%;
  overflow-y: auto;
  background: var(--cream);
  border-radius: 18px 18px 0 0;
  border-top: 4px solid var(--green);
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(43, 42, 38, 0.3);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.sheet-head h2 { margin: 0; font-size: 19px; }

.sheet-head .btn-ghost { min-height: 40px; padding: 6px 14px; }

.sheet-danger { margin-top: 14px; text-align: center; }

.link-danger {
  color: var(--clay);
  font-weight: 700;
  font-size: 14px;
  min-height: 44px;
  padding: 10px;
}

/* ---------- Modal ---------- */

.modal-card {
  position: relative;
  width: calc(100% - 48px);
  max-width: 360px;
  background: var(--cream);
  border-radius: 14px;
  border-top: 4px solid var(--clay);
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.modal-card p { margin: 0 0 16px; font-size: 14px; color: var(--ink-soft); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn-ghost,
.modal-actions .btn-danger { min-height: 44px; padding: 8px 16px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--cream);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px);
  text-align: center;
}

.noscript-note {
  margin: 20px 16px;
  padding: 14px;
  border: 2px dashed var(--wood-deep);
  border-radius: 12px;
  text-align: center;
  color: var(--ink-soft);
}

@media (min-width: 560px) {
  .view { padding-left: 24px; padding-right: 24px; }
}
