/*
 * One stylesheet. No framework, no build step, no preprocessor.
 *
 * The design brief was "nothing fancy", which is taken here to mean: a
 * readable column, a system font, and enough contrast that the deadline is the
 * first thing anybody sees. Everything is a plain cascade; there is nothing
 * clever to learn before editing it.
 */

:root {
  color-scheme: light dark;

  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-sunken: #efeeeb;
  --border: #d8d5cf;
  --text: #1c1b19;
  --text-dim: #5f5c56;
  --accent: #a8341a;
  --accent-text: #ffffff;
  --ok: #1f6b3a;
  --warn: #8a5a00;
  --danger: #a1231b;

  /* Every control on an order line is this tall. See .order-line. */
  --control-h: 2.5rem;

  --radius: 6px;
  --gap: 1rem;
  --measure: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --surface: #201f24;
    --surface-sunken: #2a292f;
    --border: #3b3941;
    --text: #eceaf0;
    --text-dim: #a29fa9;
    --accent: #e0714f;
    --accent-text: #1a1013;
    --ok: #6cc08a;
    --warn: #d8a657;
    --danger: #e97b70;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1rem 4rem;
}

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

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 2rem;
}

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-header a {
  color: inherit;
  text-decoration: none;
}

.brand {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.site-header nav {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  font-size: 0.9rem;
}

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

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

h1 {
  font-size: 1.7rem;
  line-height: 1.2;
  margin: 0 0 0.35rem;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 1.2rem;
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

.lede {
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.dim {
  color: var(--text-dim);
}

.small {
  font-size: 0.875rem;
}

a {
  color: var(--accent);
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
}

pre {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  white-space: pre;
}

/* --- cards and lists ---------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card h2,
.card h3 {
  margin-top: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  justify-content: space-between;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-list a {
  font-weight: 600;
  font-size: 1.05rem;
}

/* --- badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-open {
  color: var(--ok);
  border-color: currentColor;
}

.badge-locked {
  color: var(--warn);
  border-color: currentColor;
}

.badge-cancelled {
  color: var(--danger);
  border-color: currentColor;
}

/* --- forms -------------------------------------------------------------- */

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='datetime-local'],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

textarea.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  min-height: 16rem;
  white-space: pre;
}

.field {
  margin-bottom: 1rem;
}

.field-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Separates two forms that share a card. The default rule is a hairline with
 * no room around it, which reads as a mistake rather than as a divider. */
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}

legend {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0 0.4rem;
}

button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-sunken);
  color: var(--text);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--text-dim);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

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

button.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

/* --- the order form ----------------------------------------------------- */

/*
 * The three controls on a line have to be the same height, and they will not
 * be left to themselves: a select, a number input and a button each compute
 * their own from a different mix of font metrics, padding and border. So the
 * height is stated once, here, and every control on a line takes it.
 */
.order-line {
  display: grid;
  grid-template-columns: 1fr 5.5rem auto;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.5rem;
}

.order-line > select,
.order-line > input,
.order-line > button {
  height: var(--control-h);
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  line-height: calc(var(--control-h) - 2px);
}

/* The quantity is at most two digits. Centred, because a number sitting hard
 * against the left edge of its own box reads as a text field. */
.order-line > input[name='quantity'] {
  text-align: center;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

/* Its own column already sizes it, and the blanket width: 100% on inputs plus
 * a border-box would otherwise fight the grid track. */
.order-line .customization {
  grid-column: 1 / -1;
  width: 100%;
}

@media (max-width: 34rem) {
  .order-line {
    grid-template-columns: 1fr 4.5rem auto;
  }
}

.total {
  font-size: 1.15rem;
  font-weight: 650;
}

/* --- tables ------------------------------------------------------------- */

/* The delivery map. Leaflet measures its container, so the height has to come
   from here: a div with no height renders a map nobody can see. */
.map {
  height: 18rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Leaflet's own panes are absolutely positioned inside this one. */
  position: relative;
  z-index: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}

th,
td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.is-paid td {
  color: var(--text-dim);
}

/* --- disclosure --------------------------------------------------------- */

details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
}

details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.925rem;
}

details[open] > summary {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* The prompt sits inside the import card, so it should read as part of it
 * rather than as a second card stacked on top. */
.card > details {
  background: var(--surface-sunken);
  margin-top: 1rem;
  margin-bottom: 0;
}

details.prompt textarea {
  white-space: pre-wrap;
  min-height: 24rem;
}

/* --- messages ----------------------------------------------------------- */

.notice {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
}

.notice-error {
  border-left-color: var(--danger);
}

.notice-ok {
  border-left-color: var(--ok);
}

.notice-warn {
  border-left-color: var(--warn);
}

.notice p:last-child {
  margin-bottom: 0;
}

.loading {
  color: var(--text-dim);
  padding: 2rem 0;
}

[hidden] {
  display: none !important;
}

/* --- printing ----------------------------------------------------------- */

@media print {
  .site-header,
  .no-print,
  button {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    border: none;
    padding: 0;
  }

  pre {
    border: none;
    background: none;
    padding: 0;
    white-space: pre-wrap;
  }
}
