/* Accurate Alarms: company colors are red, black, and white.
   Rules (see CLAUDE.md): neat and simple, big text and big buttons,
   and everything stays inside its border no matter how long the text is. */

:root {
  --red: #c8102e;        /* main brand red: buttons, Garland tag */
  --red-dark: #9e0c24;   /* red when pressed */
  --black: #111111;      /* text, top bar, Bud Morgan tag */
  --white: #ffffff;      /* background */
  --panel: #f2f2f2;      /* soft panels */
  --line: #d4d4d4;       /* dividers */
  --muted: #555555;      /* secondary text */
  --gray-tag: #8a8a8a;   /* "Other" client tag */
  --green: #1e7b34;      /* "it worked" messages */
  --green-bg: #e6f2e9;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { font-size: 20px; } /* larger base text than most sites */

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--white);
  color: var(--black);
  line-height: 1.4;
}

button, input, textarea { font-family: inherit; }

:focus-visible { outline: 4px solid var(--red); outline-offset: 2px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  align-items: center;
  min-height: 64px;
  padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
  background: var(--black);
  color: var(--white);
  border-bottom: 6px solid var(--red);
}

/* Home and login have no Back button, so the name gets the full width. */
.topbar.no-back { grid-template-columns: 0 1fr 0; }

.topbar-title {
  margin: 0;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.topbar-title span { color: var(--red); }

.back-button {
  min-height: 52px;
  padding: 0 6px;
  border: none;
  background: transparent;
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

/* ---------- page ---------- */

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(32px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Boxes grow to fit their text and never get squeezed; long words wrap. */
main > * { flex-shrink: 0; }
main, main * { overflow-wrap: anywhere; min-width: 0; }

h2 { font-size: 1.5rem; margin: 0; text-align: center; text-wrap: balance; }
p { margin: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */

.big-button,
.plain-button {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  white-space: normal;
}

.big-button {
  min-height: 80px;
  border: none;
  background: var(--red);
  color: var(--white);
  font-size: 1.35rem;
}
.big-button:active { background: var(--red-dark); }
.big-button:disabled { background: #d9d9d9; color: var(--muted); cursor: default; }
.big-button small { display: block; font-size: 0.8rem; font-weight: 400; }
.big-button.black { background: var(--black); }
.big-button.done { background: var(--green); }

.plain-button {
  min-height: 64px;
  border: 3px solid var(--black);
  background: var(--white);
  color: var(--black);
  font-size: 1.15rem;
}
.plain-button:active { background: var(--panel); }

/* ---------- messages ---------- */

.message { min-height: 1.6em; text-align: center; font-weight: 700; }
.message.error { color: var(--red); }
.message.ok { color: var(--green); }

.toast {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--green-bg);
  color: var(--green);
  font-weight: 800;
  text-align: center;
}

.warn { color: var(--red); font-weight: 700; }

/* ---------- "Are you sure?" box ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  background: rgba(0, 0, 0, 0.55);
}

.sheet {
  width: 100%;
  max-width: 520px;
  display: grid;
  gap: 12px;
  padding: 20px 16px 16px;
  border-radius: 20px;
  background: var(--white);
  overflow-wrap: anywhere;
}
.sheet .question { font-size: 1.25rem; font-weight: 800; text-align: center; }
.sheet .detail { color: var(--muted); text-align: center; }

/* The list of changes to review before sending (scrolls if it's long). */
.review-list {
  max-height: 45vh;
  overflow-y: auto;
  margin: 0;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  list-style: none;
  display: grid;
  gap: 6px;
  font-weight: 700;
}
.review-list .added { color: var(--green); }
.review-list .removed { color: var(--red); }

/* ---------- login: name buttons ---------- */

.name-button {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 12px 20px;
  border: 3px solid var(--black);
  border-left: 14px solid var(--red);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.name-button:active { background: var(--panel); }

/* ---------- PIN pad ---------- */

.pin-dots { display: flex; justify-content: center; gap: 18px; }
.pin-dot { width: 26px; height: 26px; border: 3px solid var(--black); border-radius: 50%; }
.pin-dot.filled { background: var(--black); }

.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-key {
  min-height: 76px;
  border: none;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--black);
  font-size: 1.8rem;
  font-weight: 700;
  cursor: pointer;
}
.pin-key:active { background: #d9d9d9; }
.pin-key:disabled { opacity: 0.4; cursor: default; }
.pin-spacer { min-height: 76px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}
.shake { animation: shake 0.25s 2; }

/* ---------- home ---------- */

.hello { font-size: 1.6rem; font-weight: 800; text-align: center; }
.role-label { text-align: center; color: var(--muted); }

/* ---------- lists (people, jobs) ---------- */

.list-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  min-height: 76px;
  padding: 14px 18px;
  border: 3px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 1rem; /* buttons don't pick up the page's text size on their own */
  text-align: left;
  cursor: pointer;
}
.list-row:active { background: var(--panel); }
.list-row.inactive { border-color: var(--line); color: var(--muted); }
.row-name { font-size: 1.25rem; font-weight: 800; }
.row-detail { color: var(--muted); }
.row-flag { color: var(--red); font-weight: 700; font-size: 0.9rem; }

.list-divider {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

/* ---------- client tags ---------- */

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  color: var(--white);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tag.garland { background: var(--red); }
.tag.bud_morgan { background: var(--black); }
.tag.other { background: var(--gray-tag); }

/* ---------- one job ---------- */

.job-address { font-size: 1.1rem; text-align: center; white-space: pre-line; }
.notes { padding: 12px 16px; border-radius: var(--radius); background: var(--panel); white-space: pre-line; }
.notes-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- forms ---------- */

.field { display: grid; gap: 6px; }
.field-label { display: block; font-weight: 800; }

.text-input {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  border: 3px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 1.25rem;
}
/* Text boxes grow to show everything typed (app.js sets the height). */
textarea.text-input { min-height: 64px; resize: none; overflow: hidden; line-height: 1.35; }
textarea.text-input.tall { min-height: 110px; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid .wide { grid-column: 1 / -1; }

.client-choice {
  min-height: 64px;
  border: 3px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  white-space: normal;
}
.client-choice.garland { border-color: var(--red); color: var(--red); }
.client-choice.garland[aria-pressed="true"] { background: var(--red); color: var(--white); }
.client-choice.bud_morgan[aria-pressed="true"] { background: var(--black); color: var(--white); }
.client-choice.other { border-color: var(--gray-tag); color: var(--muted); }
.client-choice.other[aria-pressed="true"] { background: var(--gray-tag); color: var(--white); }

/* Save button that stays at the bottom of the screen. */
.save-bar {
  position: sticky;
  bottom: 0;
  margin: 0 -16px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 2px solid var(--line);
  background: var(--white);
}

/* ---------- Manage people ---------- */

.starter-code {
  margin: 4px 0 8px;
  text-align: center;
  font-size: 3.2rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--red);
}

.panel { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--panel); }

.current-choice { background: var(--black); }

/* ---------- home: Today card ---------- */

.today-box { display: grid; gap: 12px; }
.today-box:empty { display: none; }
.today-card {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 3px solid var(--black);
  border-left: 14px solid var(--red);
  border-radius: var(--radius);
}
.today-card.quiet { border-left-color: var(--gray-tag); }
.today-label {
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.today-card.quiet .today-label { color: var(--muted); }
.today-date {
  margin-left: 10px;
  color: var(--black);
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
}
.today-job { font-size: 1.35rem; font-weight: 800; }
.today-with { font-weight: 700; }
.today-address { white-space: pre-line; }
.today-note { color: var(--red); font-weight: 700; font-size: 0.9rem; }

/* ---------- punch clock ---------- */

.punch-button {
  display: block;
  width: 100%;
  min-height: 150px;
  padding: 16px;
  border: none;
  border-radius: 20px;
  background: var(--red);
  color: var(--white);
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: normal;
}
.punch-button:active { background: var(--red-dark); }
.punch-button.out { background: var(--black); }
.punch-button.small-text { min-height: 120px; font-size: 1.35rem; letter-spacing: 0; }
.punch-button:disabled { opacity: 0.75; cursor: default; }

.punch-job { display: grid; gap: 6px; margin-top: 6px; }
.punch-state {
  display: grid;
  gap: 2px;
  padding: 16px;
  border: 3px solid var(--green);
  border-radius: var(--radius);
  background: var(--green-bg);
  text-align: center;
  font-size: 1.1rem;
}
.punch-in-at { color: var(--green); font-size: 1.3rem; font-weight: 800; }

/* What happened after a tap. */
.result { padding: 14px; border-radius: var(--radius); font-weight: 800; text-align: center; }
.result.ok { background: var(--green-bg); color: var(--green); }
.result.warn { background: #fff4d6; color: #6b4a00; border: 2px solid #e0b000; }
.result.error { background: #fde8eb; color: var(--red); border: 2px solid var(--red); }

/* Today's punches (owner/admin). */
.punch-person { width: 100%; padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--line); }
.punch-name { font-size: 1.1rem; font-weight: 800; }
.punch-line { font-weight: 600; }
.punch-ok { color: var(--green); font-weight: 900; }
.punch-note { color: var(--red); font-weight: 700; font-size: 0.9rem; }
.still-in { color: var(--green); font-weight: 800; }
.week-arrow:disabled { border-color: var(--line); color: var(--line); cursor: default; }

/* Job screen: location tools (owner/admin). */
.location-tools { gap: 10px; }
.location-ok { color: var(--green); font-weight: 800; }
.radius-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.radius-grid .client-choice[aria-pressed="true"] { background: var(--black); color: var(--white); }

/* ---------- schedule ---------- */

.info {
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
  font-weight: 700;
  text-align: center;
}

.week-nav { display: grid; grid-template-columns: 64px 1fr 64px; gap: 10px; align-items: center; }
.week-arrow {
  min-height: 64px;
  border: 3px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 1.3rem;
  cursor: pointer;
}
.week-arrow:active { background: var(--panel); }
.week-label { text-align: center; font-size: 1.2rem; font-weight: 800; }
.week-label small { display: block; min-height: 1.3em; color: var(--muted); font-size: 0.85rem; font-weight: 700; }

.banner {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
  font-weight: 700;
  text-align: center;
}
.banner.not-posted { background: var(--red); color: var(--white); font-weight: 800; }
.banner-updated { color: var(--red); }

.day-view { display: flex; flex-direction: column; gap: 14px; }
.day-view > * { flex-shrink: 0; }
.day-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.day-tab {
  min-height: 64px;
  padding: 4px 0;
  border: 3px solid var(--black);
  border-radius: 10px;
  background: var(--white);
  color: var(--black);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}
.day-tab small { display: block; font-size: 0.8rem; font-weight: 700; }
.day-tab.today { border-color: var(--red); }
.day-tab[aria-selected="true"] { background: var(--red); border-color: var(--red); color: var(--white); }
.day-heading { font-size: 1.25rem; }

.list-row.static { cursor: default; }
.list-row.static:active { background: var(--white); }

.slot-names { font-weight: 600; }
.slot-names.stacked { display: grid; gap: 4px; }
.slot-name { display: inline-block; } /* a name and its "Updated" tag stay together */
.slot-names .me { color: var(--red); font-weight: 900; }
.updated-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border: 2px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}

.sched-actions { display: grid; gap: 12px; margin-top: 6px; }

/* Tap a name to put them on (filled red with ✓) or take them off (white). */
.person-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 12px 18px;
  border: 3px solid var(--black);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--black);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.person-toggle .check {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 3px solid var(--black);
  border-radius: 8px;
  color: transparent;
}
.person-toggle[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: var(--white); }
.person-toggle[aria-pressed="true"] .check { border-color: var(--white); color: var(--white); }
.person-toggle:disabled { opacity: 0.6; }

/* The whiteboard grid: only on computers and tablets. Phones get day tabs. */
.grid-view { display: none; }
main.wide > * { width: 100%; max-width: 520px; align-self: center; }
main.wide > .grid-view { max-width: none; }

@media (min-width: 760px) {
  main.wide { max-width: 1200px; }
  .day-view { display: none; }
  .grid-view { display: block; }
}

.sched-grid { border: 3px solid var(--black); border-radius: var(--radius); overflow: hidden; }
.grid-row { display: grid; grid-template-columns: minmax(150px, 1.4fr) repeat(5, minmax(0, 1fr)); }
.grid-row + .grid-row { border-top: 2px solid var(--line); }
.grid-cell { min-height: 72px; padding: 10px; border-left: 2px solid var(--line); font-size: 0.9rem; }
.grid-cell:first-child { border-left: none; }
.grid-head .grid-cell { min-height: 0; background: var(--black); color: var(--white); font-weight: 800; border-left-color: #444; }
.grid-head .grid-cell.today { background: var(--red); }
.grid-head .grid-cell small { display: block; font-weight: 600; }
.job-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.job-cell .row-name { font-size: 1rem; }
.grid-cell:has(.job-button) { padding: 4px; }
/* Owner/admin: the job name is a button. Hover shows "✕ Take off this week". */
.job-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--black);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.job-button:hover, .job-button:focus-visible { background: var(--panel); }
.job-remove { color: var(--red); font-size: 0.8rem; font-weight: 800; visibility: hidden; }
.job-button:hover .job-remove, .job-button:focus-visible .job-remove { visibility: visible; }
@media (hover: none) { .job-remove { visibility: visible; } } /* touch screens can't hover */
.grid-cell:has(.slot-button) { padding: 4px; }
.slot-button {
  width: 100%;
  height: 100%;
  min-height: 64px;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--black);
  font: inherit;
  text-align: left;
  vertical-align: top;
  cursor: pointer;
}
.slot-button:hover, .slot-button:active { background: var(--panel); }
.slot-empty { display: block; color: var(--line); font-size: 1.5rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
