/* =========================================================
   Grommet — Community Center Pegboard theme
   ========================================================= */

:root {
  --pegboard: #8a5a34;
  --pegboard-dark: #6e4527;
  --board-hole: #5a3a20;
  --steel: #b9c2c9;
  --steel-dark: #8b949c;
  --wood-shadow: rgba(40, 22, 8, 0.55);

  --card-streetlight: #f2a33c;
  --card-pothole: #20b2aa;
  --card-graffiti: #d6438a;
  --card-other: #f2d33c;

  --ink: #222;
  --pencil: #5a5f66;
  --resolved-grey: #9aa0a6;

  --tab-open: #ff8c1a;
  --tab-resolved: #2fce4f;
  --tab-report: #ffe14d;
  --tab-recent: #ff5fb0;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--pegboard);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: calc(84px + var(--safe-b));
}

/* ---- Pegboard background ---- */
.pegboard {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle, rgba(0,0,0,0.12) 1px, transparent 1.5px),
    var(--pegboard);
  background-size: 34px 34px;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.35);
  pointer-events: none;
}

.stage, .masthead, .tab-bar { position: relative; z-index: 1; }

/* ---- Masthead ---- */
.masthead {
  padding: calc(14px + var(--safe-t)) 16px 6px;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.brand {
  margin: 0;
  font-size: 26px;
  letter-spacing: 1px;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-weight: 800;
}
.brand-icon { color: #ffe14d; }
.tagline {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

/* ---- Views ---- */
.stage { padding: 10px 14px 20px; }
.view { display: none; }
.view.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.view-head h2 {
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  margin: 4px 0 8px;
  font-size: 20px;
}

/* ---- Counters (metal hooks + circular cardboard tags) ---- */
.counters {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 8px 0 14px;
}
.hook-tag {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
}
.hook {
  width: 26px;
  height: 14px;
  border: 4px solid var(--steel);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  background: transparent;
  box-shadow: 0 4px 6px var(--wood-shadow);
}
.tag {
  width: 118px;
  min-height: 132px;
  border-radius: 50% / 50%;
  background: #fdf3d8;
  border: 3px solid #efe0b6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  box-shadow: 0 6px 12px var(--wood-shadow);
  position: relative;
}
.tag::before {
  content: "";
  position: absolute;
  top: -8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #d8c9a0;
}
.tag-label {
  font-size: 11px;
  color: var(--pencil);
  text-align: center;
  line-height: 1.2;
}
.tag-num {
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-size: 40px;
  font-weight: 800;
  margin-top: 6px;
  color: var(--ink);
}

/* ---- Quick action ---- */
.quick-action {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ff8a3d, var(--pegboard-dark));
  border: none;
  border-radius: 10px;
  box-shadow: 0 5px 10px var(--wood-shadow);
  margin-bottom: 12px;
  cursor: pointer;
}

/* ---- Search ---- */
.search-wrap { margin: 0 0 12px; }
.search {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.9);
  font-size: 15px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

/* ---- Issue cards ---- */
.cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card {
  position: relative;
  border-radius: 6px;
  padding: 14px 14px 12px;
  box-shadow: 0 6px 12px var(--wood-shadow);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.card:active { transform: scale(0.98); }
.card-streetlight { background: var(--card-streetlight); }
.card-pothole     { background: var(--card-pothole); }
.card-graffiti    { background: var(--card-graffiti); }
.card-other       { background: var(--card-other); }

/* punched hole + grommet */
.card .grommet {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #d7dee4 55%, #9aa3ab);
  box-shadow: 0 3px 4px var(--wood-shadow);
  border: 2px solid #b7c0c8;
}
.card .grommet::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--pegboard-dark);
}

.card .icon-sticker {
  float: left;
  margin-right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  background: rgba(255,255,255,0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.2);
  transform: rotate(-4deg);
}

.card h3 {
  margin: 0;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-size: 17px;
  color: var(--ink);
  line-height: 1.25;
  overflow-wrap: break-word;
}
.card .location {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--pencil);
  overflow-wrap: break-word;
}

/* status sticker overlapping corner */
.status-sticker {
  position: absolute;
  top: -10px;
  right: -8px;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 7px;
  border-radius: 4px;
  transform: rotate(6deg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.status-open {
  background: #ff9d00;
  color: #fff;
  text-shadow: 0 0 6px rgba(255,255,255,0.6), 0 1px 0 rgba(0,0,0,0.2);
}
.status-open::before {
  content: "✶";
  margin-right: 3px;
}
.status-resolved {
  background: var(--resolved-grey);
  color: #f0f0f0;
}
.status-resolved::before {
  content: "✕";
  margin-right: 4px;
  color: rgba(0,0,0,0.3);
}

.card .meta-row {
  margin-top: 8px;
  font-size: 11px;
  color: rgba(0,0,0,0.6);
}

/* ---- Empty states ---- */
.empty-state {
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  padding: 30px 0;
}
.empty-hook { margin: 0 auto 12px; width: 120px; }
.blank-tag {
  margin-top: 4px;
  border: 2px dashed rgba(255,255,255,0.7);
  border-radius: 50%;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.85);
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-size: 13px;
  padding: 10px;
}
.empty-state p { margin: 0; font-size: 14px; }

/* ---- Forms ---- */
.field {
  display: block;
  margin-bottom: 14px;
}
.field-label {
  display: block;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.field-label em {
  font-style: normal;
  font-weight: 400;
  font-size: 11px;
  opacity: 0.85;
}
.field input, .field select {
  width: 100%;
  padding: 13px 12px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  background: rgba(255,255,255,0.95);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}
.field input.invalid {
  outline: 3px solid #ff5252;
  background: #fff0f0;
}
.form-error {
  color: #ffe3e3;
  background: rgba(180,40,40,0.75);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 8px var(--wood-shadow);
}
.btn.primary { background: linear-gradient(180deg, #ff8a3d, #e2602b); }
.btn.ghost { background: rgba(255,255,255,0.3); color: #fff; }
.btn.resolve { background: linear-gradient(180deg, #3ccf5c, #23943b); }
.btn.danger { background: linear-gradient(180deg, #e05555, #b12c2c); }

/* ---- Detail panel ---- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 40;
}
.detail-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 50;
  padding: 14px;
  padding-bottom: calc(96px + var(--safe-b));
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(100%);} to { transform: none;} }
.detail-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
  position: relative;
}
.detail-top { position: relative; min-height: 34px; margin-bottom: 10px; }
.detail-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--pegboard-dark);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.detail-card h3 {
  margin: 0 0 2px;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-size: 20px;
}
.detail-location { margin: 0 0 12px; color: var(--pencil); font-size: 13px; }
.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 14px;
}
.detail-meta div { background: #f4f1ea; border-radius: 8px; padding: 8px 10px; }
.detail-meta dt { font-size: 11px; color: var(--pencil); margin: 0; }
.detail-meta dd { margin: 2px 0 0; font-size: 14px; font-weight: 700; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Bottom nav: steel wire + zip ties ---- */
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 6px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, transparent 12px, var(--steel-dark) 12px, var(--steel) 13px, transparent 15px);
  background-size: 100% 60px;
  background-repeat: no-repeat;
  background-position: bottom;
}
.tab {
  background: transparent;
  border: none;
  padding: 6px 10px 2px;
  cursor: pointer;
  position: relative;
}
.tab .zip {
  display: block;
  min-width: 72px;
  padding: 12px 8px;
  border-radius: 6px 6px 2px 2px;
  font-family: "Comic Sans MS", "Chalkboard SE", "Marker Felt", system-ui, cursive;
  font-size: 12px;
  font-weight: 800;
  color: #222;
  box-shadow: 0 4px 8px var(--wood-shadow);
  text-align: center;
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}
.tab[data-view="open"] .zip     { background: var(--tab-open); }
.tab[data-view="resolved"] .zip { background: var(--tab-resolved); }
.tab[data-view="report"] .zip   { background: var(--tab-report); }
.tab[data-view="recent"] .zip   { background: var(--tab-recent); }

/* active: taut + glossy + curved */
.tab.active .zip {
  transform: translateY(-14px) rotate(-2deg);
  filter: brightness(1.05) drop-shadow(0 6px 4px rgba(0,0,0,0.35));
  background-image: linear-gradient(160deg, rgba(255,255,255,0.5), transparent 55%);
  box-shadow: 0 8px 12px rgba(0,0,0,0.35);
}
/* inactive: slack + matte */
.tab:not(.active) .zip {
  transform: translateY(2px) rotate(3deg) scale(0.94);
  filter: saturate(0.8) brightness(0.85);
  opacity: 0.9;
}

@media (min-width: 600px) {
  .stage { max-width: 520px; margin: 0 auto; }
}