/* Playbook styles. One file, no framework. Keep it simple. */

:root {
  /* Neutral colors for everything */
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #1c1f24;
  --muted: #5b6270;
  --border: #d9dde3;
  --focus: #1a5fd0;
  --button: #1c1f24;
  --button-text: #ffffff;

  /* Color is only for status */
  --overdue: #b3261e;
  --flagged: #9a5b00;
  --done: #1e7a3c;

  --radius: 8px;
  --space: 16px;
  --tap: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

a {
  color: inherit;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: var(--space);
  top: var(--space);
  background: var(--bg);
  padding: 8px 12px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 var(--space);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space);
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 8px 0 12px;
}

h2 {
  font-size: 1.25rem;
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  margin: var(--space) 0;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
  background: var(--bg);
}

.status-overdue {
  color: var(--overdue);
}

.status-flagged {
  color: var(--flagged);
}

.status-done {
  color: var(--done);
}

/* ----- Added in M1 ----- */

.narrow {
  max-width: 440px;
}

.stack {
  display: grid;
  gap: var(--space);
  margin: var(--space) 0;
}

.stack-top {
  margin-top: calc(var(--space) * 1.5);
}

.field .help,
.help {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  min-height: var(--tap);
}

.check input {
  width: 22px;
  min-height: 22px;
  margin: 0;
}

button.secondary,
.button.secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

button.danger {
  color: var(--overdue);
  border-color: var(--overdue);
}

.inline-form {
  display: inline-block;
  margin: 8px 8px 0 0;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.links a,
.link-list a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
}

.error {
  color: var(--overdue);
  border-left: 4px solid var(--overdue);
  padding: 8px 12px;
  background: var(--surface);
}

.notice,
.flash {
  border-left: 4px solid var(--border);
  padding: 8px 12px;
  background: var(--surface);
}

.header-icons {
  display: flex;
  gap: 4px;
}

.icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--radius);
}

.badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--overdue);
  color: #fff;
  font-size: 0.75rem;
  line-height: 18px;
  text-align: center;
}

.section-title {
  margin-top: calc(var(--space) * 2);
}

.link-list,
.rows {
  list-style: none;
  padding: 0;
  margin: 0;
}

.link-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.row.unread {
  font-weight: 600;
}

.row form {
  flex-shrink: 0;
}

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

.small {
  font-size: 0.875rem;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 8px;
  margin-left: 6px;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.code-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 480px) {
  .row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ----- Added in M2 ----- */

.site-header {
  flex-wrap: wrap;
  gap: 4px 12px;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  margin-right: auto;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 8px;
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  text-decoration: underline;
}

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

.block {
  display: block;
}

.button-big {
  font-size: 1.1rem;
  min-height: 52px;
  padding: 0 28px;
}

.search {
  display: flex;
  gap: 8px;
  margin: var(--space) 0;
}

.search input {
  flex: 1;
}

.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.turn-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-link {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  min-height: var(--tap);
}

.card-link:hover strong {
  text-decoration: underline;
}

.card-detail {
  color: var(--muted);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.timer-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chip {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 10px;
}

.chip-overdue {
  color: var(--overdue);
  border-color: var(--overdue);
}

.chip-done {
  color: var(--done);
  border-color: var(--done);
}

.chip-flagged {
  color: var(--flagged);
  border-color: var(--flagged);
}

.status-overdue {
  color: var(--overdue);
}

/* Wizard */

.progress {
  width: 100%;
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
}

.progress::-webkit-progress-bar {
  background: var(--surface);
}

.progress::-webkit-progress-value {
  background: var(--text);
}

.progress::-moz-progress-bar {
  background: var(--text);
}

.question {
  font-size: 1.35rem;
  line-height: 1.3;
  margin-bottom: 8px;
}

.choices {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 400;
  cursor: pointer;
}

.choice input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  flex-shrink: 0;
}

.choice:has(input:checked) {
  border-color: var(--text);
  background: var(--surface);
}

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

.choice-inline {
  flex: 1;
  min-width: 90px;
}

/* Next comes first in the page (so Enter means Next), but Back shows on the left. */
.wizard-buttons {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 8px;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  min-height: auto;
  min-width: 0;
  color: inherit;
  font: inherit;
  font-weight: 400;
  text-decoration: underline;
  cursor: pointer;
}

.review {
  margin: var(--space) 0;
}

.review-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.review dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.review dd {
  margin: 2px 0 0;
}

.review dd a {
  display: inline-flex;
  min-height: var(--tap);
  align-items: center;
}

/* Project page */

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.section {
  border-top: 1px solid var(--border);
  padding-top: var(--space);
  margin-top: calc(var(--space) * 1.5);
}

.pre {
  white-space: pre-line;
}

.add-box {
  margin-top: 12px;
}

.add-box summary {
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  text-decoration: underline;
}

.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.grow {
  flex: 1;
}

.tick {
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--done);
  font-size: 1.2rem;
}

.is-done .step-title {
  text-decoration: line-through;
  color: var(--muted);
}

.timer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

/* Lists and filters */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
}

.tabs a,
.pager a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
}

.tabs a[aria-current="page"] {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: flex-end;
  margin: var(--space) 0;
}

.filters .field {
  min-width: 140px;
}

.filters .grow {
  min-width: 200px;
}

.table-wrap {
  overflow-x: auto;
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.grid-table th,
.grid-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.grid-table thead th {
  font-size: 0.85rem;
  color: var(--muted);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stat {
  flex: 1;
  min-width: 100px;
  padding: var(--space);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

.two-col {
  display: grid;
  gap: var(--space);
}

@media (min-width: 720px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

/* Calendar (CSS grid, no library) */

.page:has(.calendar) {
  max-width: 1100px;
}

.calendar-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  margin-top: var(--space);
}

.cal-head {
  padding: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.cal-day {
  min-height: 96px;
  padding: 4px 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  overflow: hidden;
}

.cal-day ul {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}

.cal-weekday {
  display: none;
}

.cal-day.is-other {
  background: var(--surface);
  color: var(--muted);
}

.cal-day.is-today .cal-date {
  font-weight: 700;
  text-decoration: underline;
}

.cal-item {
  margin-bottom: 3px;
  line-height: 1.3;
  word-break: break-word;
}

.cal-item.cal-due a {
  font-weight: 600;
}

.cal-item.is-done a {
  color: var(--done);
  text-decoration: line-through;
}

.cal-item.is-overdue a {
  color: var(--overdue);
}

.calendar-week .cal-day {
  min-height: 200px;
}

/* On phones the calendar becomes a simple list of the days that have something on them. */
@media (max-width: 640px) {
  .calendar {
    display: block;
    border: 0;
  }

  .cal-head,
  .cal-day.is-empty {
    display: none;
  }

  .cal-day,
  .calendar-week .cal-day {
    min-height: 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    font-size: 1rem;
  }

  .cal-weekday {
    display: inline;
  }

  .cal-date {
    font-weight: 600;
  }

  .cal-item a {
    display: inline-flex;
    min-height: var(--tap);
    align-items: center;
  }
}

/* ----- Added in M3 (phone checks) ----- */

/* Every link in the page body is at least 44px tall, so it's easy to tap with a thumb. */
.page a:where(:not(.button, .card-link)) {
  display: inline-block;
  min-height: var(--tap);
  padding: 10px 0;
  line-height: 24px;
}

/* On phones: the name and the icons share the top row, the menu goes underneath. */
@media (max-width: 600px) {
  .header-icons {
    margin-left: auto;
  }

  .main-nav {
    order: 3;
    width: 100%;
    margin: 0 0 4px -8px;
  }
}

/* Tab and pager buttons keep their side padding. */
.page .tabs a,
.page .pager a {
  padding: 10px 14px;
  line-height: 22px;
}
