/* Punchwalk — Wall-Plate Punch Board */

:root {
  --cream: #f3ebdd;
  --cream-2: #ede2cd;
  --slate: #3d5a6c;
  --slate-deep: #2e4553;
  --amber: #e07a3f;
  --amber-soft: #f0c9a8;
  --sage: #8aa08a;
  --ink: #33413a;
  --ink-soft: #6b7469;
  --paper: #fbf7ee;
  --line: #d9cdb6;
  --danger: #b3563a;
  --radius-plate: 14px;
  --tab-h: 64px;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* ---------- Screens ---------- */

.screen {
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 18px 8px;
  animation: settle 160ms ease-out;
}

@keyframes settle {
  from { opacity: 0.4; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-head { margin-bottom: 18px; }

.screen-head h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--slate-deep);
}

.screen-sub {
  margin-top: 3px;
  font-size: 13px;
  color: var(--ink-soft);
}

.block-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--ink-soft);
  margin: 0 0 8px 2px;
}

/* ---------- Wall-plate grid (Rooms) ---------- */

.wall-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.plate {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-plate);
  box-shadow: 0 2px 0 rgba(61, 90, 108, 0.10);
  padding: 18px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 92px;
  text-align: left;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.plate:active {
  box-shadow: 0 1px 1px rgba(61, 90, 108, 0.14);
  transform: translateY(1px);
}

.plate::after {
  /* clipped corner notch */
  content: "";
  position: absolute;
  top: -1px; right: -1px;
  width: 18px; height: 18px;
  background: var(--cream);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-bottom-left-radius: 6px;
}

.stat-num {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--slate);
}

.stat-num--fixed { color: var(--sage); }
.stat-num--major { color: var(--amber); }

.stat-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.fixed-plate { background: #eef0e9; }
.rooms-plate { background: #f7f2e6; }
.major-plate { background: #f9ede4; }

/* Amber capture strip */

.capture-strip {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--amber);
  color: #fff7ee;
  border-radius: var(--radius-plate);
  box-shadow: 0 2px 0 rgba(160, 84, 40, 0.35);
  padding: 0 18px 0 20px;
  margin-bottom: 20px;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.capture-strip:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(160, 84, 40, 0.35);
}

.capture-strip-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.capture-strip-dot {
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 247, 238, 0.9);
  border-radius: 50%;
  flex: none;
}

/* Recent strip */

.recent-strip {
  width: 100%;
  display: flex;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-plate);
  box-shadow: 0 2px 0 rgba(61, 90, 108, 0.10);
  overflow: hidden;
  min-height: 68px;
  text-align: left;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.recent-strip:active {
  transform: translateY(1px);
  box-shadow: 0 1px 1px rgba(61, 90, 108, 0.14);
}

.recent-body {
  flex: 1;
  min-width: 0;
  padding: 10px 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.recent-area {
  font-weight: 700;
  font-size: 15px;
  color: var(--slate-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-note {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 10px 14px 10px 8px;
  flex: none;
}

.recent-hint { font-size: 10px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--line); }

/* ---------- Priority words & edges ---------- */

.prio-word {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.prio-minor { color: var(--sage); }
.prio-watch { color: var(--slate); }
.prio-major { color: var(--amber); }

.edge {
  width: 6px;
  flex: none;
}

.edge--minor { background: var(--sage); }
.edge--watch { background: var(--slate); }
.edge--major { background: var(--amber); }

/* ---------- Status words & dots ---------- */

.status-word {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  min-width: 58px;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: none;
}

.status-open .status-dot {
  background: var(--amber);
  border: none;
}

.status-open {
  color: #8a4a20;
  border-color: #ecc9ab;
  background: #faeee3;
}

.status-fixed .status-dot {
  background: transparent;
  border: 2px solid var(--sage);
}

.status-fixed {
  color: #5c6e5c;
  border-color: #cdd8cb;
  background: #eef2ec;
}

/* ---------- Punch list rows ---------- */

.list-section { margin-bottom: 22px; }

.section-word {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #8a4a20;
  margin: 0 2px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-word::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.section-word--fixed { color: #5c6e5c; }

.rows { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: flex;
  align-items: stretch;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px 12px 12px 10px;
  box-shadow: 0 1px 0 rgba(61, 90, 108, 0.08);
  overflow: hidden;
  min-height: 56px;
  text-align: left;
  width: 100%;
}

/* clipped top-right corner for punch-card strips */
.row { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%); }

.row-main {
  flex: 1;
  min-width: 0;
  padding: 9px 6px 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
}

.row-area {
  font-weight: 700;
  font-size: 14px;
  color: var(--slate-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-note {
  font-size: 13px;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px 6px 2px;
  flex: none;
}

.icon-btn {
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--ink-soft);
}

.icon-btn:active { background: var(--cream-2); }

.icon-btn--edit { color: var(--slate); }
.icon-btn--del  { color: var(--danger); }

.row .status-word { flex: none; }

/* ---------- Capture form ---------- */

.capture-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 8px;
}

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

.field label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-soft);
}

.req { color: var(--amber); }

.field input[type="text"],
.field textarea,
.search-wrap input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  color: var(--ink);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  appearance: none;
  -webkit-appearance: none;
}

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

.field input:focus,
.field textarea:focus,
.search-wrap input:focus {
  border-color: var(--slate);
  box-shadow: 0 0 0 3px rgba(61, 90, 108, 0.12);
}

.field input.invalid,
.field textarea.invalid,
.word-choose.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(179, 86, 58, 0.12);
}

.word-choose.invalid .word-btn {
  border-color: var(--danger);
}

.field-err {
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
}

.word-choose {
  display: flex;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
}

.word-btn {
  flex: 1;
  min-height: 42px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: background 120ms ease, color 120ms ease;
}

.word-btn[aria-checked="true"] {
  background: var(--slate);
  color: #f5f1e8;
  box-shadow: 0 1px 2px rgba(46, 69, 83, 0.3);
}

.word-btn:not([aria-checked="true"]):active {
  background: var(--cream-2);
}

/* ---------- Buttons ---------- */

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  min-height: 50px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: transform 100ms ease, box-shadow 100ms ease, opacity 100ms ease;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--slate);
  color: #f5f1e8;
  box-shadow: 0 2px 0 rgba(46, 69, 83, 0.35);
}

.btn--primary:active { box-shadow: 0 1px 0 rgba(46, 69, 83, 0.35); }

.btn--ghost {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--slate);
}

.btn--danger {
  background: #fbeae4;
  border: 1px solid #e6c2b2;
  color: var(--danger);
}

.btn--small {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 10px;
}

/* ---------- Search ---------- */

.search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--slate);
  background: var(--cream-2);
  border-radius: 8px;
}

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

.empty {
  padding: 26px 18px 22px;
  text-align: center;
}

.empty p {
  font-size: 14px;
  color: var(--ink-soft);
  max-width: 260px;
  margin: 0 auto;
  line-height: 1.45;
}

.floorplan {
  width: 92px;
  height: 64px;
  margin: 0 auto 12px;
  opacity: 0.5;
  background:
    linear-gradient(var(--line), var(--line)) 0 0 / 92px 2px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 0 / 2px 64px no-repeat,
    linear-gradient(var(--line), var(--line)) 30px 0 / 2px 38px no-repeat,
    linear-gradient(var(--line), var(--line)) 30px 38px / 34px 2px no-repeat;
}

/* ---------- About / Settings ---------- */

.about { margin-top: 30px; }

.about-plate {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-plate);
  padding: 16px 16px 18px;
  box-shadow: 0 2px 0 rgba(61, 90, 108, 0.10);
}

.about-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-deep);
  margin-bottom: 6px;
}

.about-line {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.about-row { margin-bottom: 12px; }

.about-count {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--slate);
}

.about-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Bottom tab bar: flat wall-plate silhouettes ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: var(--cream-2);
  border-top: 1px solid var(--line);
}

.tab-plate {
  flex: 1;
  min-height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: transform 110ms ease, box-shadow 110ms ease, background 110ms ease;
}

.tab-shape {
  width: 22px;
  height: 16px;
  background:
    linear-gradient(var(--slate), var(--slate)) 0 0 / 22px 2px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 0 0 / 2px 16px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 20px 0 / 2px 16px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 0 14px / 22px 2px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 7px 7px / 8px 8px no-repeat;
  border-radius: 2px;
  opacity: 0.85;
}

.tab-word {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tab-plate[aria-current="page"] {
  background: var(--slate);
  border-color: var(--slate-deep);
  transform: translateY(2px);
  box-shadow: 0 3px 8px rgba(46, 69, 83, 0.35);
}

.tab-plate[aria-current="page"] .tab-shape {
  background:
    linear-gradient(#f5f1e8, #f5f1e8) 0 0 / 22px 2px no-repeat,
    linear-gradient(#f5f1e8, #f5f1e8) 0 0 / 2px 16px no-repeat,
    linear-gradient(#f5f1e8, #f5f1e8) 20px 0 / 2px 16px no-repeat,
    linear-gradient(#f5f1e8, #f5f1e8) 0 14px / 22px 2px no-repeat,
    linear-gradient(transparent, transparent) 7px 7px / 8px 8px no-repeat;
}

.tab-plate[aria-current="page"] .tab-word { color: #f5f1e8; }

.tab-plate:not([aria-current="page"]):active {
  transform: translateY(1px);
  background: var(--cream);
}

/* ---------- Small phones ---------- */

@media (max-width: 340px) {
  .wall-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .plate { min-height: 80px; padding: 14px 10px 12px; }
  .stat-num { font-size: 28px; }
  .row-actions .icon-btn--edit { display: none; }
}
