/* Jolt Dance — mobile-first, hand-rolled. Brand purple from the old app. */
:root {
  --brand: rgb(99, 46, 103);
  --brand-hover: rgb(140, 42, 99);
  --bg: #fff;
  --text: #222;
  --line: #ddd;
  --yes: rgb(144, 238, 144);
  --no: pink;
  --apology: #9ecbff;
}

* { box-sizing: border-box; }

body {
  font-family: Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  margin: 0;
  font-size: 16px;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 3px solid var(--brand);
  /* Match the body column (see `main`) so the header lines up with the
     content beneath it instead of running full-width on wide screens. */
  max-width: 900px;
  margin: 0 auto;
}
.logo { max-height: 48px; display: block; }
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}
.site-nav a {
  color: var(--brand);
  text-decoration: none;
  font-weight: bold;
  padding: 8px 10px;
  border-radius: 8px;
}
.site-nav a.active, .site-nav a:hover { background: var(--brand); color: #fff; }
.site-nav a.nav-icon { display: inline-flex; align-items: center; padding: 6px 8px; }
.nav-spacer { flex: 1; }
.nav-install {
  font: inherit;
  font-weight: bold;
  color: var(--brand);
  background: none;
  border: 1px solid var(--brand);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.nav-install:hover { background: var(--brand); color: #fff; }
.install-hint {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: #f7f0f8;
  font-size: 0.92rem;
}

main { padding: 12px; max-width: 900px; margin: 0 auto; }

h2 { margin-top: 8px; }
h2 small { font-weight: normal; font-size: 0.7em; color: #555; }

/* touch-friendly buttons, the old .mybutton look */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 100px;
  min-height: 48px;
  padding: 6px 18px;
  border: none;
  border-radius: 15px;
  background: var(--brand);
  color: #fff;
  font-weight: bold;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover, .btn:focus { background: var(--brand-hover); }
/* 'secondary' now matches the primary purple (kept as a class so existing
   markup needn't change). Danger stays red to flag destructive actions. */
.btn.danger { background: #a33; }
.btn.danger:hover, .btn.danger:focus { background: #922; }
/* disabled buttons go grey, whatever their variant */
.btn:disabled, .btn[disabled] { background: #999; cursor: default; }
.btn:disabled:hover, .btn[disabled]:hover { background: #999; }
.btn.small { min-height: 34px; min-width: 0; padding: 2px 12px; font-size: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* forms */
form.stack { display: flex; flex-direction: column; gap: 10px; }
form.stack.narrow, .narrow { max-width: 420px; }
/* App-parameter table: let it grow to content so the input + Set button
   stay on one line (a 30-char box won't fit beside the button at 420px). */
table.params td { white-space: nowrap; }
table.params td form { display: inline; }
form.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: bold; }
form.stack input[type=text], form.stack input[type=email],
form.stack input[type=password], form.stack input[type=date],
form.stack input[type=time], form.stack input[type=number],
form.stack input:not([type]), form.stack select, form.stack textarea {
  font-size: 16px;
  padding: 10px;
  border: 1px solid #aaa;
  border-radius: 8px;
  font-family: inherit;
  font-weight: normal;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}
legend { font-weight: bold; color: var(--brand); padding: 0 6px; }
.radio-row { display: flex; gap: 18px; }
.radio-row label { flex-direction: row; align-items: center; gap: 6px; }
label.agree { display: flex; flex-direction: row; gap: 8px; align-items: baseline; font-weight: bold; }

/* tables */
table { border-collapse: collapse; width: 100%; margin: 10px 0; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--brand); }
tr.selected_row { background: #f3e8f4; }
td a { color: var(--brand); font-weight: bold; }

.yes { background: var(--yes); }
.no { background: var(--no); }
.apology { background: var(--apology); }

/* Cross-tab (ethnicity report): full grid, number columns centred so the
   header names line up over their counts; the first column (Age) stays left. */
table.xtab th, table.xtab td { border: 1px solid var(--line); text-align: center; }
table.xtab th:first-child, table.xtab td:first-child { text-align: left; }

.error { color: #a00; font-weight: bold; }
.warning { color: #a00; font-style: italic; }
.flash {
  background: var(--yes);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  font-weight: bold;
}
.notice {
  border-left: 4px solid var(--brand);
  background: #f7f0f8;
  padding: 10px;
  margin: 8px 0;
  white-space: pre-wrap;
}

.muted { color: #777; }
img.dancer-photo { max-width: 200px; max-height: 260px; border-radius: 10px; }

@media (min-width: 700px) {
  fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
  fieldset legend { grid-column: 1 / -1; }
  fieldset label:has(textarea), fieldset .radio-row, fieldset > .wide { grid-column: 1 / -1; }
}

/* Signup form extras */
.signup-intro { margin-bottom: 1rem; }
.signup-intro ul { margin: 0.4rem 0 0.4rem 1.2rem; }
.req { color: #c00; font-weight: bold; }
.dropzone {
  border: 2px dashed #bbb;
  border-radius: 10px;
  padding: 16px;
}
.dropzone.drag { border-color: var(--brand); background: #f7f0f8; }
.dropzone-prompt, .dropzone-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
/* keep the hidden attribute working despite the display:flex above */
.dropzone-prompt[hidden], .dropzone-preview[hidden] { display: none; }
.dropzone-preview img { max-width: 120px; max-height: 120px; border-radius: 8px; }

/* Modal dialog (T&C on the signup page) */
dialog.modal {
  max-width: 640px;
  width: calc(100% - 2rem);
  max-height: 85vh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.5); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-body h2 { margin-top: 0; }
.modal-body img { max-width: 100%; height: auto; border-radius: 6px; margin: .4rem 0; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

/* Roll present/absent/apology: stack vertically on narrow / portrait screens
   (where they'd otherwise wrap mid-column), go inline once there's width. */
.mark-opts label { display: block; white-space: nowrap; padding: 3px 0; }
@media (min-width: 700px) {
  .mark-opts label { display: inline-block; padding: 0; margin-right: 14px; }
}

/* Health & Safety admin: drag-and-drop reorder lists (pointer-events based,
   so the same code drives mouse, Android touch and iOS touch). */
.dl-list { list-style: none; margin: 0; padding: 0; }
.dl-cats > .dl-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 10px 0;
  padding: 6px 10px 10px;
  background: var(--bg);
}
.dl-q-list { margin: 4px 0 4px 8px; }
.dl-q-list > .dl-item {
  border-bottom: 1px solid var(--line);
}
.dl-q-list > .dl-item:last-child { border-bottom: 0; }
.dl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.dl-title { flex: 1 1 auto; min-width: 0; }
.dl-cat-head .dl-title { font-weight: bold; }
.dl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
/* the grab handle — touch-action:none stops the browser from scrolling/zooming
   when a drag starts on it, which is what makes touch dragging reliable */
.dl-handle {
  flex: 0 0 auto;
  touch-action: none;
  cursor: grab;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #999;
  font-size: 20px;
  line-height: 1;
  padding: 6px 10px;
  min-height: 40px;      /* comfortable touch target */
  min-width: 40px;
}
.dl-handle:hover, .dl-handle:focus { color: var(--brand); border-color: var(--line); outline: none; }
.dl-item.dragging { opacity: .6; background: #f3e8f4; }
.dl-item.dragging .dl-handle { cursor: grabbing; }
/* While a category is being dragged, collapse it to just its header row so the
   categories below rise into reach — otherwise you'd have to drag past a tall
   category's full midpoint (often off-screen) before it would move. Questions
   have no nested content, so this doesn't affect them. */
.dl-cats > .dl-item.dragging > .dl-q-list,
.dl-cats > .dl-item.dragging > .dl-add,
.dl-cats > .dl-item.dragging > p { display: none; }
.dl-cats > .dl-item.dragging { outline: 2px dashed var(--brand); }
.dl-item.inactive > .dl-row .dl-title { color: #999; }
.dl-add { margin: 4px 0 2px 8px; }
