/*
 * Volunteer sign-up sheet.
 *
 * Deliberately thin. The site already decides what a table and a form look like:
 *
 *   - .calendarbox / .calendar in primary.css set the table frame (#400), the header
 *     fill (#dbb8a3), the row rule (#d7b7ae) and the warm red row striping. This sheet
 *     uses the same values, so it reads as the same furniture as the events calendar
 *     and the member list rather than as a different application.
 *   - #content input / #content button in primary.css already give white fields with a
 *     #c4bfad hairline, a #604960 focus ring and purple buttons. Those are inherited,
 *     not restated. The only overrides below are the ones a dense grid genuinely needs:
 *     dropping the 32em field cap and the 6px padding.
 *   - #dac0b48e is the row hover the newsletter and gallery tables use.
 */

/* ---- headings and notices ----------------------------------------------- */

#content .vol-title {
  margin-top: 0;
  margin-bottom: 0.35em;
}

.vol-when {
  margin: 0 0 0.6em;
  font-weight: bold;
}

/*
 * The facts about the event, as a header block rather than one long line.
 *
 * Pat's Word documents both open with an Organization / Time / Event Date / Location
 * table, and those four are what a volunteer checks before signing up for anything. Same
 * fill as the table head below it, so the two read as one piece of furniture.
 */
.vol-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1px;
  margin: 0 0 1em;
  border: 1px solid #400;
  background-color: #400;
}

.vol-facts > div {
  flex: 1 1 8em;
  padding: 6px 10px;
  background-color: #dbb8a3;
}

.vol-facts dt {
  margin: 0;
  font-size: 85%;
  font-weight: normal;
  color: #7a5b3a;
}

.vol-facts dd {
  margin: 0;
  font-size: 115%;
  font-weight: bold;
  line-height: 1.25;
}

.vol-notes {
  margin: 0 0 0.8em;
  max-width: 44em;
}

.vol-count {
  margin: 0 0 1em;
}

/* The box itself is .notice in primary.css; these only say which edge colour. */
.vol-error {
  border-left-color: #a33;
}

.vol-saved {
  border-left-color: #4a7a4a;
}

.vol-closed {
  border-left-color: #604960;
}

/* ---- the list of sheets ------------------------------------------------- */

.vol-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
}

.vol-card {
  flex: 1 1 20em;
  border: 1px solid #c4bfad;
  background-color: #f0eee5;
  padding: 0.7em 0.9em;
}

.vol-card:hover {
  background-color: #dac0b48e;
}

/*
 * The #content prefix is doing real work here. primary.css gives every h3 a 12px top
 * margin and every paragraph the browser default, which inside a card stacks up as a
 * band of empty space above the title and uneven gaps below it. A bare `.vol-card h3`
 * loses to `#content h3` on specificity, so the margin has to be beaten, not just set.
 */
#content .vol-card h3,
#content .vol-card p {
  margin: 0;
}

#content .vol-card h3 {
  margin-bottom: 0.15em;
}

#content .vol-card .vol-when {
  margin-bottom: 0.35em;
}

/* ---- the sheet ---------------------------------------------------------- */

/*
 * The page is a fixed 920px table (#page in primary.css) with a 147px menu beside it, so
 * the content column is about 730px and there is nowhere for a wide table to go: left to
 * itself it stretches #page and drags the whole layout out of shape.
 *
 * table-layout: fixed is what prevents that. The column widths below are shares of the
 * content column rather than minimums asked for by the text, so the table is exactly as
 * wide as the page no matter how long a job description runs - long text wraps instead of
 * pushing. The frame is .calendarbox's.
 */
/* The 1px #400 frame comes from .calendarbox in primary.css, which the div also carries. */
.vol-scroll {
  max-width: 100%;
  overflow-x: auto;
}

table.vol-sheet {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

/*
 * Adds up to 100%, so nothing overflows. Weighted towards what has to be READ IN FULL:
 * a description can wrap over three lines and lose nothing, but a clipped email address
 * or phone number is the one thing on this page somebody has to be able to copy down.
 */
table.vol-sheet .vol-num   { width: 6%; }
table.vol-sheet .vol-pos   { width: 17%; }
table.vol-sheet .vol-desc  { width: 20%; }
table.vol-sheet .vol-field-name  { width: 17%; }
table.vol-sheet .vol-field-phone { width: 15%; }
table.vol-sheet .vol-field-email { width: 25%; }

table.vol-sheet th,
table.vol-sheet td {
  border-bottom: 1px solid #d7b7ae;
  padding: 2px 6px;
  vertical-align: middle;
  text-align: left;
  /* Long words - an email address, mostly - wrap instead of widening their column. */
  overflow-wrap: break-word;
}

/* .calendar .title's fill, so this header matches the events calendar's. */
table.vol-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #dbb8a3;
  border-bottom: 1px solid #400;
  font-weight: bold;
  padding: 5px 6px;
}

/*
 * .calendar's striping - but painted on the CELLS, not the row.
 *
 * A row's background sits behind its cells, so anything translucent on a cell composites
 * over it. The position and description cells are translucent white (below) and span
 * several rows, so with the stripe on the <tr> they picked up whichever tint their first
 * row happened to have. Painting the cells directly leaves those two free to sit over
 * the page alone, and they stay one flat colour down the whole sheet.
 */
/* Only the entry side stripes. The label column keeps its own flat wash - see below. */
.vol-row:nth-child(odd) > .vol-num,
.vol-row:nth-child(odd) > .vol-field {
  background-color: rgba(100, 0, 0, 0.05);
}

.vol-row:nth-child(even) > .vol-num,
.vol-row:nth-child(even) > .vol-field {
  background-color: rgba(255, 200, 200, 0.02);
}

.vol-num {
  position: relative;
  text-align: right;
  color: #8a6a45;
}

/*
 * Which rows are still open is the whole point of the page, so a taken row is tinted a
 * shade further into the same warm red: filled work recedes, and the gaps are what the
 * eye lands on.
 *
 * It has to keep alternating, though. A single flat tint for every taken row meant the
 * zebra striping vanished as the sheet filled up - exactly when a long column of names
 * most needs a line to follow across.
 */
.vol-row.vol-taken:nth-child(odd) > .vol-num,
.vol-row.vol-taken:nth-child(odd) > .vol-field {
  background-color: rgba(100, 0, 0, 0.16);
}

.vol-row.vol-taken:nth-child(even) > .vol-num,
.vol-row.vol-taken:nth-child(even) > .vol-field {
  background-color: rgba(100, 0, 0, 0.11);
}

/* After the taken rules, and matching their weight, so hover still reads on a full row. */
.vol-sheet .vol-row:hover > .vol-num,
.vol-sheet .vol-row:hover > .vol-field {
  background-color: #dac0b48e;
}


/*
 * Position and description carry the rowspan and align to the top of their group.
 * The selector needs the table prefix to outweigh `table.vol-sheet th` above - without
 * it a six-slot job's name floats in the vertical middle of its block, level with
 * nothing in particular.
 */
/*
 * The label column: what the job is, and what it involves.
 *
 * A wash of white over the page rather than a tint of its own, so it reads as the
 * quiet side of the sheet and the entry columns carry the colour. The selector is
 * weighted to beat the striping and taken rules above - these cells belong to the first
 * row of their group, and must not take that row's tint, or a six-slot job whose first
 * row happens to be filled reads as though the whole job were.
 */
table.vol-sheet .vol-row > th.vol-pos,
table.vol-sheet .vol-row > td.vol-desc {
  vertical-align: top;
  padding-top: 6px;
  border-right: 1px solid #d7b7ae;
  background-color: rgba(255, 255, 255, 0.2);
}

table.vol-sheet th.vol-pos {
  font-weight: bold;
}

table.vol-sheet td.vol-desc {
  color: #63492e;
}

/* A new job starts a heavier rule, so six rows of one job read as one block. */
tr.vol-first > * {
  border-top: 1px solid #400;
}

/*
 * Fields.
 *
 * primary.css gives every input a white fill, a #c4bfad hairline and a rounded corner,
 * which is right for a contact form and wrong for eighty-one cells in a grid: it turns
 * the sheet into a wall of little boxes and buries the table's own structure. So the
 * cells here are transparent and borderless, the TABLE draws the grid - the same rules
 * the events calendar uses - and a field only takes on the form look when it is being
 * used. The #604960 focus ring is still primary.css's, unchanged.
 */
table.vol-sheet td.vol-field {
  padding: 0;
  border-right: 1px solid #e3d3c6;
}

#content .vol-sheet input[data-field] {
  max-width: none;
  padding: 4px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
}

#content .vol-sheet input[data-field]:hover:not([readonly]) {
  background: #fff;
  border-color: #c4bfad;
}

#content .vol-sheet input[data-field]:focus {
  background: #fff;
}

#content .vol-sheet input[data-field][readonly] {
  color: #63492e;
}

/* ---- clear button and save state ---------------------------------------- */

/*
 * Clearing a row.
 *
 * This had a column of its own, which meant an empty gutter down the right of every
 * sheet paying for a control that only twenty-odd rows will ever show. It sits over the
 * row number instead: the number is what you look at to find a row, and the × is what
 * you want once you have found yours, so they never need to be visible at once.
 *
 * A quiet × rather than the site's purple button - there is one per row, and thirty
 * purple buttons down the page would read as the point of the page.
 */
#content .vol-clear-btn {
  position: absolute;
  inset: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  color: #a33;
  font-size: 120%;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

/*
 * Shown on hover, and on focus-within so it is reachable by keyboard - the button stays
 * in the tab order either way, and becomes visible when it gets there.
 */
.vol-row.vol-taken:hover .vol-clear-btn,
.vol-row.vol-taken:focus-within .vol-clear-btn {
  opacity: 1;
  pointer-events: auto;
}

.vol-row.vol-taken:hover .vol-num-n,
.vol-row.vol-taken:focus-within .vol-num-n {
  visibility: hidden;
}

#content .vol-clear-btn:focus {
  opacity: 1;
  pointer-events: auto;
  outline: 2px solid #604960;
}

#content .vol-clear-btn:hover {
  background: rgba(170, 51, 51, 0.12);
}

.vol-live {
  min-height: 1.2em;
  margin: 0.4em 0 0;
  font-size: 90%;
  color: #63492e;
}

.vol-row.vol-saving > * {
  opacity: 0.6;
}

.vol-sheet .vol-row.vol-saved > .vol-num,
.vol-sheet .vol-row.vol-saved > .vol-field {
  background-color: rgba(74, 122, 74, 0.18);
}

.vol-sheet .vol-row.vol-failed > .vol-num,
.vol-sheet .vol-row.vol-failed > .vol-field {
  background-color: rgba(170, 51, 51, 0.16);
}

/*
 * The note under a row: a warning, a failure, or a choice to make. Positioned out of the
 * table's flow so a two-line note does not shove every row below it down the page while
 * somebody is reading it.
 */
.vol-note {
  position: absolute;
  z-index: 3;
  right: 0;
  min-width: 18em;
  max-width: 26em;
  margin-top: 2px;
  padding: 6px 8px;
  font-size: 88%;
  line-height: 1.35;
  background: #fff;
  border: 1px solid #c4bfad;
  box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.28);
}

.vol-sheet td.vol-field {
  position: relative;
}

.vol-note-warn {
  border-left: 4px solid #8a6d1f;
}

.vol-note-error,
.vol-note-conflict {
  border-left: 4px solid #a33;
}

.vol-note-undo {
  border-left: 4px solid #604960;
}

#content .vol-choice {
  margin: 5px 6px 0 0;
  padding: 2px 8px;
  font-size: 95%;
  border-radius: 3px;
}

/*
 * A row waiting on a decision. It keeps the tint even when the pointer moves away -
 * hover must not make an unresolved collision look resolved.
 */
.vol-sheet .vol-row.vol-conflict > .vol-num,
.vol-sheet .vol-row.vol-conflict > .vol-field,
.vol-sheet .vol-row.vol-conflict:hover > .vol-num,
.vol-sheet .vol-row.vol-conflict:hover > .vol-field {
  background-color: rgba(170, 51, 51, 0.16);
}

/* Somebody else's entry, just arrived by refresh. Fades out on its own. */
.vol-sheet .vol-row.vol-fresh > .vol-num,
.vol-sheet .vol-row.vol-fresh > .vol-field {
  background-color: rgba(96, 73, 96, 0.16);
  transition: background-color 2s ease-out;
}

/* ---- actions ------------------------------------------------------------ */

/* .vol-save needs no rules: #content button in primary.css already styles it. */
.vol-actions {
  margin: 0.8em 0 0.5em;
}

.vol-export {
  margin: 0 0 1.4em;
}

/*
 * "Save all changes" is for the visitor without JavaScript, whose browser posts the whole
 * table at once. With scripting it is redundant - every cell saves on its own - so the
 * page hides it, keyed off a class set in the <head> so it never flashes into view first.
 *
 * It comes back if saving stops working (sheet.js sets data-offline), because at that
 * point posting the form really is the only way to get the sheet saved.
 */
/*
 * The #content prefix is load-bearing: primary.css styles `#content button` with an id
 * selector, so a plain `.vol-js .vol-save` loses to it and the button stayed visible.
 * Third time this file has had to outrank an id rule - it is how primary.css is written.
 */
.vol-js #content .vol-save {
  display: none;
}

.vol-js #content form[data-offline] .vol-save {
  display: inline-block;
}

.vol-hint {
  color: #63492e;
  font-size: 95%;
  margin-right: 1em;
}

.vol-hint-bad {
  color: #a33;
  font-weight: bold;
}

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

/* ---- phones ------------------------------------------------------------- */

/*
 * Six columns do not fit a phone, and members will use phones. Below this width each row
 * becomes its own card: the job as a heading, the three fields labelled underneath. Same
 * markup, different layout - the labels come from the data-label already on each cell.
 */
@media (max-width: 700px) {
  .vol-scroll {
    border: 0;
    overflow-x: visible;
  }

  table.vol-sheet,
  table.vol-sheet tbody,
  table.vol-sheet tr,
  table.vol-sheet td,
  table.vol-sheet th,
  table.vol-sheet .vol-num,
  table.vol-sheet .vol-pos,
  table.vol-sheet .vol-desc,
  table.vol-sheet .vol-field {
    display: block;
    width: auto;
  }

  table.vol-sheet thead {
    display: none;
  }

  .vol-sheet .vol-row > *,
  .vol-sheet .vol-row:nth-child(odd) > *,
  .vol-sheet .vol-row:nth-child(even) > *,
  .vol-sheet .vol-row.vol-taken:nth-child(odd) > *,
  .vol-sheet .vol-row.vol-taken:nth-child(even) > * {
    background-color: transparent;
  }

  .vol-row {
    position: relative;
    border: 1px solid #d7b7ae;
    border-left: 4px solid #dbb8a3;
    background-color: rgba(100, 0, 0, 0.05);
    margin-bottom: 0.7em;
    padding: 0.5em 0.7em;
  }

  .vol-row.vol-open {
    border-left-color: #604960;
    background-color: transparent;
  }

  .vol-row .vol-num {
    position: absolute;
    top: 0.5em;
    right: 0.6em;
    border: 0;
    padding: 0;
    text-align: right;
  }

  th.vol-pos,
  td.vol-desc {
    border: 0;
    padding: 0;
    max-width: none;
  }

  th.vol-pos {
    font-size: 105%;
    padding-right: 3.5em;
  }

  td.vol-desc {
    margin-bottom: 0.4em;
  }

  /*
   * A job's name and description exist only on its first row - they carry the rowspan -
   * so the later rows of a six-slot job would otherwise be anonymous cards.
   */
  .vol-row:not(.vol-first) .vol-num::before {
    content: "row ";
  }

  .vol-field {
    border: 0;
    padding: 0.15em 0;
  }

  .vol-field::before {
    content: attr(data-label);
    display: block;
    font-size: 85%;
    color: #63492e;
  }

  #content .vol-sheet input[data-field] {
    padding: 6px 8px;
  }

  /* A phone has no hover, so the × is always there on a row somebody is in. */
  #content .vol-clear-btn {
    position: static;
    padding: 0.1em 0.6em;
    border: 1px solid #c4bfad;
    border-radius: 3px;
    opacity: 1;
    pointer-events: auto;
  }

  .vol-row.vol-open .vol-clear-btn {
    display: none;
  }

  .vol-row.vol-taken:hover .vol-num-n,
  .vol-row.vol-taken:focus-within .vol-num-n {
    visibility: visible;
  }
}
