/* ─── Tokens ───────────────────────────────────────────────────────── */
:root {
  --bg: #fafaf8;
  --card: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #2d2d2d;
  --muted: #6e6e6e;
  --line: #e6e6df;
  --line-soft: #f0efe9;
  --accent: #1f5f3f;
  --accent-soft: #e6f0ea;

  /* Per-lane accents — kept subdued so the card list is the focus. */
  --lane-requested: #4a90b8;
  --lane-working: #ca8a04;
  --lane-waiting: #8b5cf6;
  --lane-done:    #1f5f3f;
  --lane-default: #6e6e6e;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card: 0 1px 0 rgba(0,0,0,0.02), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-elevated: 0 10px 30px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── Topbar ───────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 28px 32px 16px;
  border-bottom: 1px solid var(--line);
}
.title-group h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}
.meta { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }

/* ─── Lane tabs (mobile only — hidden on desktop) ──────────────────── */
.lane-tabs {
  display: none;
}

/* ─── Board layout ─────────────────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 20px 24px 40px;
  max-width: 1500px;
  margin: 0 auto;
}
.loading {
  padding: 40px 0;
  text-align: center;
  grid-column: 1 / -1;
}

/* ─── Lane (column) ────────────────────────────────────────────────── */
.lane {
  display: flex;
  flex-direction: column;
  min-width: 0; /* prevent overflow inside grid */
}
.lane-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 4px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.lane-head .name {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}
.lane-head .count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lane-head .note {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-style: italic;
}
.lane-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lane-default);
  flex: none;
}
.lane[data-lane="requested"]   .lane-dot { background: var(--lane-requested); }
.lane[data-lane="working"] .lane-dot { background: var(--lane-working); }
.lane[data-lane="waiting"] .lane-dot { background: var(--lane-waiting); }
.lane[data-lane="done"]    .lane-dot { background: var(--lane-done); }

/* Done-lane cards are visually retired: subdued so the eye reads them
   as completed without removing them. Hover restores full clarity so
   the content is still scannable on demand. */
.lane[data-lane="done"] .card {
  opacity: 0.62;
  filter: saturate(0.7);
}
.lane[data-lane="done"] .card:hover,
.lane[data-lane="done"] .card:focus-visible {
  opacity: 1;
  filter: none;
}

.lane-empty {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  padding: 8px 4px;
}

/* ─── Card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  display: block;
  position: relative;
}
.card:hover {
  border-color: #d4d4cb;
  transform: translateY(-1px);
}
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 4px;
  color: var(--ink);
}
.card-short {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
  margin: 0;
}
.card-latest {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.card-latest .date {
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.card-latest .text {
  display: block;
  margin-top: 2px;
}

/* ─── Card communications tail (last 5 inline) ──────────────────────── */
.card-comms {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px 0 0;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  line-height: 1.4;
}
.card-comms li {
  padding: 4px 0;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line-soft);
}
.card-comms li:last-child { border-bottom: none; }
.card-comms li.more {
  color: var(--muted);
  font-style: italic;
  padding-top: 6px;
}
.card-comms .date {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--muted);
  margin-right: 6px;
}
.card-comms .who {
  color: var(--accent);
  font-weight: 500;
  margin-right: 4px;
}
.card-comms .who::after { content: ":"; color: var(--muted); }
.card-comms .text {
  color: var(--ink-soft);
}

/* Click-or-tap-for-more-info affordance at the bottom of every card.
   Styled as a real-looking pill button so the affordance reads on touch. */
.card-cta {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  text-align: right;
}
.card-cta-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.card:hover .card-cta-pill,
.card:focus-visible .card-cta-pill {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}
.card:active .card-cta-pill { transform: scale(0.98); }
@media (max-width: 600px) {
  .card-cta-pill { font-size: 13px; padding: 8px 14px; }   /* easier tap target */
}

/* ─── Detail dialog ────────────────────────────────────────────────── */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 32px);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-elevated);
}
dialog::backdrop {
  background: rgba(20, 20, 20, 0.45);
  backdrop-filter: blur(2px);
}
dialog .close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  line-height: 1;
  border-radius: 50%;
}
dialog .close:hover { background: var(--line-soft); color: var(--ink); }
.detail-head {
  padding: 24px 56px 8px 28px;
}
.lane-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--lane-default);
  padding: 3px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  margin-bottom: 10px;
}
.lane-pill[data-lane="requested"]   { color: var(--lane-requested); }
.lane-pill[data-lane="working"] { color: var(--lane-working); }
.lane-pill[data-lane="waiting"] { color: var(--lane-waiting); }
.lane-pill[data-lane="done"]    { color: var(--lane-done); }
#detail-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.detail-short {
  padding: 8px 28px 0;
  color: var(--ink-soft);
  font-size: 15px;
}
.detail-description {
  padding: 16px 28px 4px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-soft);
}
.detail-description p { margin: 0 0 12px; }
.detail-description ul { margin: 0 0 12px; padding-left: 22px; }
.detail-description li { margin-bottom: 4px; }
.detail-description code {
  background: var(--line-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}
.detail-h3 {
  margin: 18px 28px 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.comms {
  list-style: none;
  padding: 0 28px 28px;
  margin: 0;
}
.comms li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
  line-height: 1.5;
}
.comms li:last-child { border-bottom: none; }
.comms .meta-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
}
.comms .who {
  color: var(--ink-soft);
  font-weight: 600;
}
.comms .date { font-variant-numeric: tabular-nums; }
.comms .text { color: var(--ink-soft); }

/* ─── Footer ───────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  font-size: 11.5px;
  padding: 20px;
  color: var(--muted);
}
.footer code {
  background: var(--line-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

/* ─── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .topbar {
    padding: 22px 20px 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* Tabs at the top — one lane visible at a time on phone. */
  .lane-tabs {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 10px 16px 0;
    margin: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    /* hide scrollbar but keep scrollability */
    scrollbar-width: none;
  }
  .lane-tabs::-webkit-scrollbar { display: none; }

  .lane-tab {
    flex: 0 0 auto;
    appearance: none;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 12px 10px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: color 100ms, border-color 100ms;
  }
  .lane-tab:hover { color: var(--ink-soft); }
  .lane-tab.active {
    color: var(--ink);
    border-bottom-color: var(--accent);
  }
  .lane-tab .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lane-default);
    flex: none;
  }
  .lane-tab[data-lane="requested"]   .dot { background: var(--lane-requested); }
  .lane-tab[data-lane="working"] .dot { background: var(--lane-working); }
  .lane-tab[data-lane="waiting"] .dot { background: var(--lane-waiting); }
  .lane-tab[data-lane="done"]    .dot { background: var(--lane-done); }
  .lane-tab .count {
    font-size: 11px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    padding: 1px 6px;
    background: var(--line-soft);
    border-radius: 999px;
  }
  .lane-tab.active .count {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .board {
    padding: 12px 16px 32px;
    grid-template-columns: 1fr;
    gap: 0;
  }
  .lane {
    display: none;   /* hide everything; tab JS toggles .active to show one */
  }
  .lane.active {
    display: flex;
  }
  .lane-head {
    /* The lane name is already in the tab; hide the duplicate header. */
    display: none;
  }

  dialog {
    max-width: 100%;
    width: 100%;
    margin: 0;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .detail-head { padding-top: 22px; padding-right: 50px; }
}

/* ─── Print (optional) ─────────────────────────────────────────────── */
@media print {
  .topbar, .footer { display: none; }
  .card { break-inside: avoid; }
  dialog { display: none; }
}
