/* HoursTally — the time card is a paper punch card; everything around it stays quiet. */

:root {
  --page: #f6f5f1;
  --bar: #ffffff;
  --hair: #dedbd3;
  --ink: #1b2a41;
  --ink-soft: #5c6b7f;
  --card: #fbf6e8;
  --card-edge: #d9cfb3;
  --rule: #d6ccae;
  --rule-strong: #b9ad8a;
  --field: #fffdf7;
  --stamp: #b3372c;
  --navy: #1f3a66;
  --navy-dark: #172c4f;
  --ok: #1d6a45;
  --bad: #f5dcd8;
  --text-max: 68ch;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

html, body { overflow-x: hidden; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */

.site-head { background: var(--bar); border-bottom: 1px solid var(--hair); }
.site-head .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.wordmark .mark { width: 34px; height: 34px; display: block; }
.wordmark .wm { font-size: 24px; font-weight: 700; letter-spacing: -0.7px; line-height: 1; }
.wordmark .wm b { font-weight: 400; }
.site-head nav { display: flex; gap: 4px; margin-left: auto; }
.site-head nav a { color: var(--ink-soft); text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: 3px; }
.site-head nav a:hover { color: var(--ink); background: var(--page); }
.site-head nav a[aria-current] { color: var(--ink); font-weight: 600; }

/* ---------- type ---------- */

h1 { font-size: clamp(24px, 3.6vw, 32px); line-height: 1.2; font-weight: 600; letter-spacing: -0.4px; margin: 30px 0 8px; text-wrap: balance; }
h2 { font-size: 21px; font-weight: 600; letter-spacing: -0.2px; margin: 36px 0 10px; }
h3 { font-size: 16px; font-weight: 600; margin: 24px 0 8px; }
.lede { color: var(--ink-soft); font-size: 17px; margin: 0 0 22px; text-wrap: pretty; }
.mono, .num, input.time, input.brk, .hm, .dec, .stub-value, .conv input { font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }

/* ---------- the card ---------- */

.tc {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 4px;
  box-shadow: 0 1px 0 #fff inset, 0 1px 2px rgba(27, 42, 65, .08), 0 14px 32px -20px rgba(27, 42, 65, .35);
  padding: 0 0 18px;
  margin-bottom: 26px;
  position: relative;
}

.tc-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 18px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--rule-strong);
}
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: 13px; color: var(--ink-soft); }
.field select, .field input {
  font: inherit; font-size: 15px; color: var(--ink); height: 36px;
  background: var(--field); border: 1px solid var(--rule-strong);
  border-radius: 3px; padding: 0 9px; min-width: 0; width: 100%;
}
.field select:focus, .field input:focus, input.time:focus, input.brk:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--navy); outline-offset: 2px;
}

.tc-cols, .day {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 88px 76px 76px;
  gap: 0 12px;
  align-items: start;
  padding: 0 20px;
}
.tc-cols { padding-top: 10px; padding-bottom: 6px; font-size: 13px; color: var(--ink-soft); border-bottom: 1px solid var(--rule); }
.tc-cols .num { text-align: right; }

.day { padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
.day.bad { background: var(--bad); }
.badnote { display: none; font-weight: 400; font-size: 12px; color: var(--stamp); line-height: 1.2; }
.day.bad .badnote { display: block; }
.day-name { font-weight: 600; line-height: 34px; white-space: nowrap; }
.day-name small { font-weight: 400; color: var(--ink-soft); margin-left: 6px; }

.pairs { display: flex; flex-direction: column; gap: 6px; }
.pair { display: flex; align-items: center; gap: 8px; }
input.time {
  width: 96px; font-size: 16px; padding: 6px 8px; text-align: center;
  background: var(--field); border: 1px solid var(--rule-strong); border-radius: 3px; color: var(--ink);
}
input.time::placeholder, input.brk::placeholder, .field input::placeholder { color: #a39a80; }
.pair .to { color: var(--ink-soft); font-size: 14px; }
.pair .x { background: none; border: 0; color: var(--ink-soft); font-size: 20px; line-height: 1; padding: 0 2px; cursor: pointer; }
.pair .x:hover { color: var(--stamp); }
.pair .add {
  background: none; border: 1px dashed var(--rule-strong); color: var(--ink-soft);
  width: 34px; height: 34px; border-radius: 3px; font-size: 20px; line-height: 1; cursor: pointer;
}
.pair .add:hover { color: var(--ink); border-color: var(--ink-soft); border-style: solid; }

input.brk { width: 76px; font-size: 16px; padding: 6px 8px; text-align: right; background: var(--field); border: 1px solid var(--rule-strong); border-radius: 3px; color: var(--ink); }
.hm, .dec { text-align: right; line-height: 34px; font-size: 16px; }
.hm.empty, .dec.empty { color: #c4bca3; }

/* the tear-off stub at the bottom */
.stub { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: end; padding: 18px 20px 4px; }
.stub-total .stub-label { font-size: 13px; color: var(--ink-soft); }
.stub-total .stub-value { font-size: 40px; line-height: 1; font-weight: 500; color: var(--stamp); letter-spacing: -1px; }
.stub-total .stub-value.empty { color: #b3a98d; }
.stub-total .stub-value small { font-size: 18px; color: var(--ink-soft); font-weight: 400; margin-left: 10px; letter-spacing: 0; }
.stub-breakdown { display: grid; grid-template-columns: auto auto; gap: 2px 14px; font-size: 15px; text-align: right; }
.stub-breakdown dt { color: var(--ink-soft); }
.stub-breakdown dd { margin: 0; font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; }
.stub-breakdown .pay dd { color: var(--ok); font-weight: 600; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px 0; }
.btn {
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
  padding: 10px 16px; border-radius: 3px; border: 1px solid var(--navy);
  background: var(--navy); color: #fff;
}
.btn:hover { background: var(--navy-dark); }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.ghost:hover { background: rgba(31, 58, 102, .08); }
.btn.quiet { background: transparent; color: var(--ink-soft); border-color: var(--rule-strong); }
.btn.quiet:hover { color: var(--ink); }

.hint { font-size: 14px; color: var(--ink-soft); padding: 12px 20px 0; max-width: var(--text-max); }
.hint code, article code { font-family: "IBM Plex Mono", monospace; font-size: 13px; background: rgba(27, 42, 65, .07); padding: 1px 5px; border-radius: 3px; }

/* ---------- prose ---------- */

.body { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 48px; align-items: start; margin-top: 8px; }
article { max-width: var(--text-max); min-width: 0; }
.body:not(:has(.rail)) { grid-template-columns: 1fr; }
.body:not(:has(.rail)) article { max-width: 78ch; }
article h2:first-child { margin-top: 20px; }
article p { margin: 0 0 14px; }
article ul { margin: 0 0 14px; padding-left: 22px; }
article li { margin-bottom: 6px; }
article a { color: var(--navy); }
article table { width: 100%; border-collapse: collapse; margin: 6px 0 18px; font-size: 15px; background: var(--bar); border: 1px solid var(--hair); }
article th, article td { text-align: left; border-bottom: 1px solid var(--hair); padding: 9px 12px; vertical-align: top; }
article tr:last-child td { border-bottom: 0; }
article th { font-weight: 600; color: var(--ink-soft); background: var(--page); }

aside.rail { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 22px; padding-top: 20px; }
.rail-box { background: var(--bar); border: 1px solid var(--hair); border-radius: 4px; padding: 14px 16px; }
.rail-box h3 { margin: 0 0 8px; font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.rail-box ul { list-style: none; margin: 0; padding: 0; }
.rail-box li { padding: 5px 0; border-top: 1px solid var(--hair); font-size: 15px; }
.rail-box li:first-child { border-top: 0; }
.rail-box a { color: var(--ink); text-decoration: none; }
.rail-box a:hover { color: var(--navy); text-decoration: underline; }
.rail-box li small { display: block; color: var(--ink-soft); font-size: 13px; }
.rail-box li[aria-current] a { font-weight: 600; }

.byline { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--hair); font-size: 14px; color: var(--ink-soft); }

details { border-top: 1px solid #d3d7dd; padding: 12px 0; }
details:last-of-type { border-bottom: 1px solid #d3d7dd; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin: 10px 0 0; }

.site-foot { margin-top: 56px; background: var(--bar); border-top: 1px solid var(--hair); padding: 28px 0 36px; color: var(--ink-soft); font-size: 14px; }
.site-foot .wrap { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
.site-foot h4 { margin: 0 0 8px; font-size: 14px; color: var(--ink); font-weight: 600; }
.site-foot ul { list-style: none; margin: 0; padding: 0; }
.site-foot li { margin: 4px 0; }
.site-foot a { color: var(--ink-soft); text-decoration: none; }
.site-foot a:hover { color: var(--ink); text-decoration: underline; }
.site-foot p { margin: 0 0 8px; max-width: 40ch; }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  .body { grid-template-columns: 1fr; gap: 8px; }
  aside.rail { position: static; padding-top: 0; }
  aside.rail .rail-box:nth-child(2) { display: none; }
  .site-foot .wrap { grid-template-columns: 1fr; gap: 18px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 12px; }
  .site-head .wrap { height: 52px; gap: 12px; }
  .site-head nav a { padding: 6px 7px; font-size: 14px; }
  .tc-fields { padding: 14px 14px 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tc-cols { display: none; }
  .day, .stub, .actions, .hint { padding-left: 14px; padding-right: 14px; }
  .day {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name total"
      "pairs pairs"
      "brk brk";
    gap: 6px 10px;
  }
  .day-name { grid-area: name; line-height: 1.4; }
  .pairs { grid-area: pairs; }
  .day .brkwrap { grid-area: brk; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); }
  .day .totals { grid-area: total; display: flex; gap: 12px; align-items: baseline; line-height: 1.4; }
  .hm, .dec { line-height: 1.4; }
  .dec::before { content: "= "; color: var(--ink-soft); }
  input.time { width: 92px; }
  .stub { grid-template-columns: 1fr; }
  .stub-breakdown { text-align: left; grid-template-columns: auto 1fr; }
  .stub-total .stub-value { font-size: 34px; }
}
@media (min-width: 641px) {
  .day .brkwrap span { display: none; }
  .day .totals { display: contents; }
}

@media (prefers-reduced-motion: no-preference) {
  .stub-total .stub-value { transition: color .15s; }
}

@media print {
  body { background: #fff; }
  .site-head nav, .actions, .hint, .site-foot, article, .pair .add, .pair .x, .noprint { display: none !important; }
  .tc { box-shadow: none; border-color: #999; }
    .stub-total .stub-value { color: #000; }
}

.stub-breakdown > div { display: contents; }
.stub-breakdown > div[hidden] { display: none; }
