/* Help & feedback: the person-facing support pages (/support, /support/new, /support/tickets/:id,
   /support/status, /support/grievance-officer). Built on brand/tokens.css and style.css.
   Everything is scoped to .sp so nothing leaks into the sign-in or admin pages that also load this file.
   Light only, by design. */

/* ---------- base ---------- */
.sp [hidden] { display: none !important; } /* label { display: grid } would otherwise beat the hidden attribute */
.sp .sp-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sp h3 { font-size: 1.0625rem; line-height: 1.25; letter-spacing: -.02em; margin: 0 0 var(--s-2); }
.sp .sp-back { display: inline-flex; align-items: center; gap: .4em; margin-bottom: var(--s-4); font-size: .9375rem; }
.sp .lede { margin-bottom: var(--s-5); }
.sp .card > :last-child { margin-bottom: 0; }

/* textareas, file inputs and radios: style.css only styles text inputs and selects */
.sp textarea {
  width: 100%; min-height: 9em; padding: .82em 1em; font: inherit; font-size: 1rem; line-height: 1.5; color: var(--ink);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-field); background: #fff; resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.sp textarea.short { min-height: 5em; }
.sp textarea:hover { border-color: var(--muted); }
.sp textarea:focus { outline: none; border-color: var(--violet-600); box-shadow: var(--ring-focus); }
.sp input[type=file] { padding: .65em .8em; background: var(--paper); border-style: dashed; cursor: pointer; }
.sp input[type=file]::file-selector-button {
  margin-right: var(--s-3); padding: .45em 1em; border: 1.5px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--paper); font: 600 .875rem/1.1 var(--font-body); color: var(--ink); cursor: pointer;
}
.sp input[type=radio] { width: 18px !important; height: 18px; margin: 0; padding: 0 !important; accent-color: var(--violet-600); flex: none; cursor: pointer; box-shadow: none !important; }
.sp input[type=checkbox] { accent-color: var(--violet-600); cursor: pointer; }
/* keyboard focus on radios and checkboxes: style.css removes the default ring, so draw our own */
.sp input[type=radio]:focus-visible, .sp input[type=checkbox]:focus-visible { outline: 2px solid var(--violet-600); outline-offset: 2px; }
.sp label.pill:has(input:focus-visible), .sp label.check:has(input:focus-visible) { outline: 2px solid var(--violet-600); outline-offset: 2px; border-radius: var(--r-pill); }
.sp label.check:has(input:focus-visible) { border-radius: var(--r-field); }

/* field states (brand: error = danger border + danger message under the field) */
.sp .sp-field-error { display: block; margin-top: 2px; color: var(--danger); font-size: .875rem; font-weight: 500; }
.sp .is-invalid input:not([type=radio]), .sp .is-invalid select, .sp .is-invalid textarea,
.sp input[aria-invalid=true], .sp select[aria-invalid=true], .sp textarea[aria-invalid=true] { border-color: var(--danger); }
.sp .req { color: var(--danger); font-weight: 600; }
.sp .sp-counter { justify-self: end; font-size: .8125rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.sp .sp-counter.is-near { color: var(--violet-700); font-weight: 600; }
.sp .sp-hint { display: block; font-size: .875rem; font-weight: 400; color: var(--muted); }
.sp .sp-only { display: inline-block; margin-right: .35em; padding: 1px 8px; border-radius: var(--r-pill); background: var(--violet-soft); color: var(--violet-700); font-size: .75rem; font-weight: 600; }
.sp.js .sp-only { display: none; } /* with JavaScript the section simply appears when it applies */

/* without JavaScript: browsers with :has() still show each conditional part only when it applies.
   support.js does the same with the hidden attribute (and disables the hidden fields) when it runs. */
@supports selector(:has(*)) {
  .sp .sp-only { display: none; }
  .sp form[data-sp-new]:not(:has(input[name=type][value=IS]:checked)) [data-sp-show-type="IS"],
  .sp form[data-sp-new]:not(:has(input[name=type][value=GR]:checked)) [data-sp-show-type="GR"],
  .sp form[data-sp-new]:not(:has(select[name=department_id] option[value=other]:checked)) [data-sp-show-dept="other"],
  .sp form[data-sp-new]:not(:has(input[name=preferred_contact][value=phone]:checked)) [data-sp-show-contact="phone"] { display: none; }
}

/* ---------- form layout ---------- */
.sp fieldset { margin: 0 0 var(--s-5); padding: 0; border: 0; min-width: 0; }
.sp legend { padding: 0; margin-bottom: var(--s-3); font: 500 1.125rem/1.25 var(--font-display); letter-spacing: -.02em; }
.sp .sp-step { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: var(--s-2); border-radius: 50%; background: var(--ink); color: #fff; font: 600 .8125rem/1 var(--font-body); vertical-align: 2px; }
.sp .sp-section { padding: clamp(18px, 3vw, 28px); margin-bottom: var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--paper); }
.sp .sp-section > :last-child { margin-bottom: 0; }
.sp .sp-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-4); }
@media (max-width: 640px) { .sp .sp-grid2 { grid-template-columns: 1fr; } }
.sp .sp-radios { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin-bottom: var(--s-4); }
.sp .sp-radios label.check { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.sp .sp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-4); }
.sp .sp-privacy { margin-top: var(--s-4); }

/* ---------- selectable cards (brand "Selected": border + selected fill + halo + filled tile + tick) ---------- */
.sp .sp-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-3); }
@media (max-width: 560px) { .sp .sp-pick { grid-template-columns: 1fr; } }
.sp label.sp-card {
  position: relative; display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 4px var(--s-3);
  margin: 0; padding: var(--s-4) var(--s-4) var(--s-4) var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  background: var(--paper); cursor: pointer; font-weight: 400;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast), box-shadow var(--dur-fast), translate var(--dur-fast) var(--ease);
}
.sp label.sp-card:hover { border-color: var(--line-strong); translate: 0 -2px; box-shadow: var(--shadow-sm); }
.sp label.sp-card > input { position: absolute; opacity: 0; width: 1px !important; height: 1px; pointer-events: none; }
.sp .sp-card-tile { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--violet-soft); color: var(--violet-700); font: 600 .8125rem/1 var(--font-mono); transition: background-color var(--dur-base) var(--ease), color var(--dur-base); }
.sp .sp-card-name { font: 500 1.0625rem/1.25 var(--font-display); letter-spacing: -.02em; color: var(--ink); padding-right: 30px; }
.sp .sp-card-blurb { font-size: .875rem; color: var(--muted); line-height: 1.45; }
.sp .sp-card-tick {
  position: absolute; top: var(--s-3); right: var(--s-3); display: grid; place-items: center; width: 22px; height: 22px;
  border: 1.5px solid var(--line-strong); border-radius: 50%; background: #fff; color: transparent; font-size: .75rem; font-weight: 700; line-height: 1;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-base) var(--spring);
}
/* selected: :checked sibling works everywhere; :has() and the .is-on class (set by support.js) style the card itself */
.sp label.sp-card > input:checked ~ .sp-card-tick { background: var(--violet-600); border-color: var(--violet-600); color: #fff; transform: scale(1.08); }
.sp label.sp-card > input:checked ~ .sp-card-tile { background: var(--violet-600); color: #fff; }
.sp label.sp-card:has(input:checked), .sp label.sp-card.is-on { border-color: var(--violet-600); background: var(--selected); box-shadow: var(--ring-selected); }
.sp label.sp-card:has(input:focus-visible) { outline: 2px solid var(--violet-600); outline-offset: 3px; }
.sp label.sp-card > input:focus-visible ~ .sp-card-tick { outline: 2px solid var(--violet-600); outline-offset: 2px; } /* fallback without :has() */
.sp .sp-pick.is-invalid label.sp-card { border-color: var(--danger); }

/* type cards on the home page (links, not inputs) */
.sp .sp-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-3); margin-bottom: var(--s-6); }
@media (max-width: 560px) { .sp .sp-types { grid-template-columns: 1fr; } }
.sp a.sp-card { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s-3); padding: var(--s-4); border-radius: var(--r-lg); background: var(--mist); color: var(--ink); font-weight: 400; transition: translate .4s var(--ease), box-shadow .4s var(--ease), background-color .3s; }
.sp a.sp-card:hover { translate: 0 -3px; box-shadow: var(--shadow-md); background: var(--paper); text-decoration: none; }
.sp a.sp-card .sp-card-name { padding-right: 0; }

/* ---------- hero call to action ---------- */
.sp .sp-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); }
.sp .sp-hero p { margin: 0; max-width: 34em; }
.sp .sp-hero .btn { padding: 1em 1.6em; font-size: 1rem; }

/* ---------- tables ---------- */
.sp .sp-table td:first-child { white-space: nowrap; }
.sp .sp-table .sp-subject { min-width: 14em; }
.sp .sp-chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* status chips: the word is always there; colour only supports it */
.sp .chip.st-awaiting_reply { background: var(--ink); color: #fff; }
.sp .chip.st-reopened { background: #fff4e5; color: #8a4b00; }
.sp .chip.st-closed { background: var(--mist); color: var(--ink-2); border: 1.5px solid var(--line); padding: 1.5px 9.5px; }

/* ---------- empty state ---------- */
.sp .sp-empty { padding: var(--s-6) var(--s-5); text-align: center; border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--paper); }
.sp .sp-empty p { margin-left: auto; margin-right: auto; max-width: 30em; }

/* ---------- link lists ---------- */
.sp .sp-links { list-style: none; padding: 0; margin: 0; }
.sp .sp-links li { padding: var(--s-2) 0; border-bottom: 1.5px solid var(--line); }
.sp .sp-links li:last-child { border-bottom: 0; }

/* ---------- ticket: success panel ---------- */
.sp .sp-success { text-align: left; background: var(--paper); box-shadow: var(--shadow-lg); border: 1.5px solid var(--line); overflow-wrap: anywhere; min-width: 0; }
/* long email addresses and ticket IDs must wrap rather than scroll the page sideways at 360px */
.sp .mono, .sp .eyebrow, .sp .sp-email, .sp .notice, .sp .error, .sp .sp-table td, .sp .sp-ev-head { overflow-wrap: anywhere; }
.sp .sp-success-mark { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: var(--s-4); border-radius: 50%; background: var(--ok); color: #fff; font-size: 1.25rem; font-weight: 700; }
.sp.motion .sp-success-mark { animation: sp-pop var(--dur-base) var(--spring) both; }
@keyframes sp-pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sp .sp-idrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin: var(--s-2) 0 var(--s-4); }
.sp .sp-bigid { padding: .3em .7em; border-radius: var(--r-field); background: var(--violet-soft); color: var(--violet-700); font: 600 clamp(1.4rem, 5vw, 2rem)/1.2 var(--font-mono); letter-spacing: .02em; word-break: break-all; max-width: 100%; }

/* ---------- ticket: header facts ---------- */
.sp .sp-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s-4) var(--s-5); margin: 0 0 var(--s-4); }
.sp .sp-facts div { min-width: 0; }
.sp .sp-facts dt { font-size: .8125rem; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.sp .sp-facts dd { margin: 0; overflow-wrap: anywhere; }
.sp .sp-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

/* ---------- ticket: history timeline ---------- */
.sp .sp-timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.sp .sp-timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1.5px; background: var(--line); }
.sp .sp-timeline > li { position: relative; padding: 0 0 var(--s-5) 32px; }
.sp .sp-timeline > li:last-child { padding-bottom: 0; }
.sp .sp-timeline > li::before { content: ""; position: absolute; left: 0; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--line-strong); }
.sp .sp-timeline > li.ev-reply::before { border-color: var(--violet-600); background: var(--violet-soft); }
.sp .sp-timeline > li.ev-resolved::before, .sp .sp-timeline > li.ev-closed::before { border-color: var(--ok); background: var(--ok-soft); }
.sp .sp-timeline > li.ev-reopened::before, .sp .sp-timeline > li.ev-appealed::before { border-color: #8a4b00; background: #fff4e5; }
.sp .sp-ev-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-3); margin-bottom: 4px; }
.sp .sp-ev-head strong { font-weight: 600; }
.sp .sp-ev-body { padding: var(--s-3) var(--s-4); border-radius: var(--r-field); background: var(--paper); border: 1.5px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9375rem; }
.sp .sp-ev-files { list-style: none; padding: 0; margin: var(--s-2) 0 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* attachment links */
.sp .sp-files { list-style: none; padding: 0; margin: 0; }
.sp .sp-files li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s-3); padding: var(--s-2) 0; border-bottom: 1.5px solid var(--line); }
.sp .sp-files li:last-child { border-bottom: 0; }
.sp .sp-files a, .sp .sp-ev-files a { overflow-wrap: anywhere; }
.sp .sp-file-list { list-style: none; padding: 0; margin: -4px 0 var(--s-4); font-size: .875rem; color: var(--ink-2); }

/* ---------- ticket: actions ---------- */
.sp details.sp-more { margin-top: var(--s-4); border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--paper); }
.sp details.sp-more > summary { padding: var(--s-4) var(--s-5); cursor: pointer; font-weight: 600; color: var(--violet-700); list-style-position: inside; }
.sp details.sp-more > summary:focus-visible { outline-offset: -2px; border-radius: var(--r-lg); }
.sp details.sp-more > div { padding: 0 var(--s-5) var(--s-5); }
.sp .sp-rating { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.sp .sp-rating label.pill { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* ---------- officer card ---------- */
.sp .sp-officer dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); margin: 0; }
.sp .sp-officer dt { font-size: .875rem; font-weight: 600; color: var(--muted); }
.sp .sp-officer dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.sp .sp-tbc { color: var(--muted); font-style: italic; }
@media (max-width: 480px) { .sp .sp-officer dl { grid-template-columns: 1fr; gap: 0; } .sp .sp-officer dd { margin-bottom: var(--s-3); } }
.sp ol.sp-steps { margin: 0; padding-left: 1.3em; }
.sp ol.sp-steps li { margin-bottom: var(--s-3); padding-left: 4px; }
.sp ol.sp-steps li::marker { color: var(--violet-700); font-weight: 600; }

/* ---------- loading button (brand: keeps its size, label fades to 35%, a small spinner turns) ---------- */
/* secondary buttons have a light background, so the label keeps the ink colour and the spinner is violet */
.sp .btn.is-loading { position: relative; pointer-events: none; }
.sp .btn.is-loading > * , .sp .btn.is-loading { color: var(--muted); color: color-mix(in srgb, var(--ink) 35%, transparent); }
.sp .btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border: 2px solid var(--line-strong); border-top-color: var(--violet-600); border-radius: 50%; animation: sp-spin .7s linear infinite;
}
.sp .btn.primary.is-loading > * , .sp .btn.primary.is-loading { color: rgba(255, 255, 255, .35); }
.sp .btn.primary.is-loading::after { border-color: rgba(255, 255, 255, .45); border-top-color: #fff; }
.sp .btn:disabled { opacity: .55; cursor: not-allowed; }
.sp .btn.is-loading:disabled { opacity: 1; }
@keyframes sp-spin { to { transform: rotate(360deg); } }

/* messages after an action: focused on load (support.js), so give them a visible focus ring */
.sp .notice:focus-visible, .sp .error:focus-visible { outline: 2px solid var(--violet-600); outline-offset: 2px; }
.sp .notice:focus:not(:focus-visible), .sp .error:focus:not(:focus-visible) { outline: none; }

/* the error summary at the top of a form */
.sp .error ul { margin: var(--s-2) 0 0; padding-left: 1.2em; }
.sp .error a { color: var(--danger); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .sp label.sp-card:hover, .sp a.sp-card:hover { translate: none; }
  .sp .btn.is-loading::after { animation: none; border-top-color: var(--line-strong); }
  .sp .btn.primary.is-loading::after { border-top-color: rgba(255, 255, 255, .45); }
}
.sp .sp-m0 { margin: 0 !important; }
.sp .sp-gr-note { margin: var(--s-3) 0 0; }
.sp legend.sp-legend-sm { margin-bottom: var(--s-2); font: 500 .875rem/1.4 var(--font-body); letter-spacing: 0; }
.sp .sp-officer-note { margin: var(--s-4) 0 0; }
