/* Parish of One. Page chrome in the house sans; the register in a serif, set like a ruled parish register page. */

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

body {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 32px 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; color: inherit; border-radius: 0; }

button {
  background: transparent;
  border: 1px solid currentColor;
  padding: 7px 14px;
  cursor: pointer;
}
button:hover:not(:disabled), button:focus-visible { background: var(--c-peach); color: var(--accent-fg); border-color: var(--accent-fg); }
button:disabled { cursor: default; opacity: 0.4; }
@media screen { :focus-visible { outline: 2px solid currentColor; outline-offset: 2px; } }

input[type="text"], select, textarea {
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 6px 2px;
  min-width: 0;
}
select { border: 1px solid currentColor; padding: 5px 6px; }
input[aria-invalid] { border-bottom: 2px solid var(--error); }

/* Title block */
.top .wm { display: block; height: 22px; width: auto; }
h1 {
  font: 700 44px/1.05 var(--font-display);
  letter-spacing: -0.01em;
  margin: 28px 0 10px;
}
.intro { margin: 0 0 32px; max-width: 58ch; font-size: 16px; }

/* Numbered sections, set like a form */
.sec {
  font: 600 13px/1 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-top: 1px solid var(--ink);
  padding-top: 12px;
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sec .num {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 20px;
  text-align: center;
  border: 1px solid currentColor;
}

.fields { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; color: var(--ink-soft); }
.field.home { flex: 1 1 320px; max-width: 420px; }
.pair { display: flex; gap: 8px; align-items: end; }
#radius { width: 9em; }

/* The register */
#register {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  font-variant-numeric: tabular-nums;
  padding: 6px 0 8px;
}
#register h2 {
  font-size: 16px;
  font-weight: 400;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.14em;
  margin: 0 0 6px;
}
#header {
  color: var(--ink);
  font-size: 27px;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 4px double currentColor;
}
#nothing { margin: 14px 0 24px; font-size: 16px; }
#register.empty .set, #register:not(.empty) #nothing { display: none; }
.line { margin: 0 0 3px; font-size: 16px; }
#last:empty { display: none; }
#last { margin-top: 8px; }

#stones { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 18px 0 14px; }
#stones th {
  font-size: 13px;
  font-weight: 600;
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-align: left;
  vertical-align: bottom;
  padding: 6px 8px;
  border-bottom: 1px solid currentColor;
}
#stones td {
  vertical-align: top;
  padding: 9px 8px 10px;
  border-bottom: 1px solid var(--ink-soft);
}
#stones th + th, #stones td + td { border-left: 1px solid var(--ink-soft); }
.c-no { width: 6%; }
.c-bearing { width: 8%; }
.c-pos { width: 15%; }
.c-leg { width: 9%; }
.c-reach { width: 20%; }
.with-last .c-what, .with-last .c-last { width: 21%; }
#stones td.no { font-weight: 700; white-space: nowrap; }
#stones td.pos { white-space: nowrap; }
@media screen { #stones tbody tr:focus-within, #stones tbody tr:focus-within * { background: var(--c-peach); color: var(--accent-fg); } }

.entry { display: flex; gap: 6px; align-items: end; }
input.reached { flex: 1; width: 100%; }
button.here { padding: 3px 9px; font-size: 13px; font-family: var(--font-body); }
.offset { font-size: 13px; font-style: italic; min-height: 1.3em; margin-top: 3px; }
.nr { display: inline-flex; align-items: center; font-family: var(--font-body); font-size: 13px; margin-top: 4px; cursor: pointer; }
.textlabel { display: block; font-family: var(--font-body); font-size: 12px; color: var(--ink-soft); margin-bottom: 2px; }
textarea.text { width: 100%; min-height: calc(2.7em + 12px); resize: vertical; font-family: inherit; line-height: 1.35; }
/* Placeholders name the fields on the phone only; the desktop has column heads and labels. */
input.reached::placeholder, textarea.text::placeholder { color: transparent; }
.last .lw { display: block; }
.last .lw + .lw { margin-top: 2px; }
.pt { display: none; }

/* Both boxes are drawn, square, with a cross when set */
input.notreached, .tick {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-block;
  flex: none;
  width: 13px;
  height: 13px;
  margin: 0 7px 0 0;
  border: 1px solid currentColor;
  background: transparent;
  vertical-align: -2px;
}
input.notreached:checked::before, input.notreached:checked::after, .tick.on::before, .tick.on::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  height: 15px;
  margin-left: -0.5px;
  border-left: 1.4px solid currentColor;
  transform: rotate(45deg);
}
input.notreached:checked::after, .tick.on::after { transform: rotate(-45deg); }

#rules { margin: 6px 0 10px; max-width: 80ch; }
#rules p { margin: 0 0 6px; }
#colophon { font-size: 13px; color: var(--ink-soft); max-width: 90ch; margin: 0; }
#colophon .wm { height: 14px; width: auto; vertical-align: -2px; margin-left: 4px; }

/* Take away */
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
details { margin-top: 8px; font-size: 14px; max-width: 70ch; }
summary { cursor: pointer; color: var(--ink-soft); }
details p { margin: 8px 0 0; }

#status {
  position: sticky;
  bottom: 0;
  margin: 24px 0 0;
  padding: 10px 0;
  min-height: 1.45em;
  background: var(--bg);
  border-top: 1px solid var(--ink);
  font-size: 14px;
}
#status:empty { position: static; border-top-color: transparent; }
#status.err { color: var(--error); }
#foot { font-size: 13px; color: var(--ink-soft); padding: 8px 0 36px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wm { background: var(--c-cream); padding: 3px 5px; box-sizing: content-box; }
}

/* Phone: each stone becomes a ruled block */
@media screen and (max-width: 700px) {
  body { padding: 20px 16px 0; }
  h1 { font-size: 34px; margin-top: 22px; }
  .field.home, .field { flex: 1 1 100%; max-width: none; }
  #radius { flex: 1; width: auto; }
  #header { font-size: 22px; }
  #stones, #stones tbody { display: block; }
  #stones thead { display: none; }
  #stones tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    padding: 8px 0 10px;
    border-top: 1px solid currentColor;
  }
  #stones tbody tr:last-child { border-bottom: 1px solid currentColor; }
  #stones td { display: block; padding: 0; border: 0; }
  #stones td + td { border-left: 0; }
  #stones td.no { font-size: 17px; }
  #stones td.no .n::before { content: "Stone "; }
  #stones td.bearing { text-align: right; }
  #stones td.bearing::before { content: "Bearing "; font-size: 13px; }
  #stones td.leg { text-align: right; }
  #stones td.leg::before { content: "To next "; font-size: 13px; }
  #stones td.reach, #stones td.what, #stones td.last { grid-column: 1 / -1; }
  /* One row: Reached at, Here, Not reached; the offset below it only when there is one */
  #stones td.reach { display: grid; grid-template-columns: 1fr auto; align-items: end; column-gap: 14px; margin-top: 2px; }
  #stones td.reach .nr { grid-row: 1; grid-column: 2; margin: 0 0 6px; }
  #stones td.reach .offset { grid-column: 1 / -1; }
  #stones td.reach .offset:empty { display: none; }
  input.reached::placeholder, textarea.text::placeholder { color: var(--ink-soft); font-family: var(--font-body); font-size: 13px; }
  textarea.text { min-height: 0; field-sizing: content; }
  .textlabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #stones td.last:empty { display: none; }
  #stones td.last::before { content: "Last walk"; display: block; font-family: var(--font-body); font-size: 12px; color: var(--ink-soft); }
  .buttons button { flex: 1 1 auto; }
}

/* The print sheet: one A4 page, black on white, controls gone */
@page { size: A4; margin: 12mm; }
@media print {
  body > *:not(#register), body > *:not(#register) * { display: none; }
  body, #register, #register * { color: #1A1A1A; background: #FFFFFF; border-color: #1A1A1A; }
  #register button, #register details, #register input[type="file"] { display: none; }
  body { margin: 0; padding: 0; max-width: none; }
  #register { padding: 0; font-size: 9pt; line-height: 1.25; }
  #register h2 { font-size: 10pt; margin: 0 0 2mm; line-height: 5mm; }
  #header { font-size: 15pt; line-height: 6mm; margin: 0 0 2mm; padding-bottom: 1.2mm; border-bottom: 0.9mm double #1A1A1A; }
  .line { font-size: 9pt; line-height: 4.5mm; margin: 0; }
  #last { margin: 0; }
  #stones { margin: 2.5mm 0 2.5mm; }
  .c-pos { width: 17.5%; }
  .c-reach { width: 19%; }
  #stones thead { display: table-header-group; }
  #stones th { font-size: 7pt; line-height: 1.15; padding: 1mm 1.5mm; height: 12mm; border-bottom: 0.25mm solid #1A1A1A; }
  #stones td { padding: 1.2mm 1.5mm; border-bottom: 0.25mm solid #1A1A1A; }
  #stones th + th, #stones td + td { border-left: 0.25mm solid #1A1A1A; }
  #stones tbody tr { height: 15mm; break-inside: avoid; page-break-inside: avoid; }
  input.reached, textarea.text, .textlabel { display: none; }
  .entry { display: block; }
  .pt { display: block; min-height: 4.5mm; line-height: 4.5mm; overflow-wrap: anywhere; }
  .pt:empty { border-bottom: 0.25mm solid #1A1A1A; }
  .offset { font-size: 7.5pt; min-height: 0; margin-top: 0.5mm; }
  .nr { font-size: 7.5pt; margin-top: 0.8mm; }
  .last { font-size: 8pt; overflow-wrap: anywhere; }
  input.notreached, .tick { width: 3mm; height: 3mm; border: 0.25mm solid #1A1A1A; margin-right: 1.5mm; vertical-align: -0.5mm; }
  input.notreached:checked::before, input.notreached:checked::after, .tick.on::before, .tick.on::after { top: -0.6mm; height: 4mm; border-left: 0.25mm solid #1A1A1A; margin-left: -0.125mm; }
  #rules, #colophon { font-size: 7.5pt; line-height: 1.3; max-width: none; }
  #rules { margin: 0 0 1.5mm; }
  #rules p { margin: 0 0 1mm; }
  #colophon .wm { height: 3mm; padding: 0; margin-left: 1mm; }
}
