/* The ticket forms' type, urgency and file choice (E222, #528, #502). Its own file beside portal.css, which holds
   the tokens these rules use; loaded on every page after it. */

/* The designed type choice (#528): portal-forms.js puts a button and a list beside the native
   select, which stays in the form unseen. Like the hub's select: a filled field, a raised popup,
   the open row in accent-quiet and a check at the chosen one. */
.select {
  position: relative;
}

.select--enhanced select,
.files--enhanced input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  opacity: 0;
  pointer-events: none;
}

.select__button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--control-height);
  padding: 0 2.5rem 0 0.875rem;
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  color: var(--text);
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 1.25rem) 50%,
    calc(100% - 0.9rem) 50%;
  background-size: 0.375rem 0.375rem;
  background-repeat: no-repeat;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-control);
  cursor: pointer;
  transition:
    border-color var(--motion-instant) var(--ease-standard),
    background-color var(--motion-instant) var(--ease-standard);
}

.select__button:hover {
  border-color: var(--text-muted);
}

.select__button[aria-expanded='true'],
.select__button:focus-visible {
  border-color: var(--accent);
  background-color: var(--raised);
}

.select__button[aria-describedby$='-error'] {
  border-color: var(--danger);
}

.select__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select__list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 18rem;
  margin: 0;
  padding: 0.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-5);
  box-shadow: var(--shadow-dialog);
  outline: none;
}

.select__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--control-height);
  padding: 0 0.75rem;
  font-size: 0.9375rem;
  color: var(--text);
  border-radius: var(--radius-3);
  cursor: pointer;
}

.select__option--active {
  background: var(--accent-quiet);
}

.select__option[aria-selected='true']::after {
  content: '';
  flex-shrink: 0;
  width: 0.375rem;
  height: 0.75rem;
  margin-bottom: 0.2rem;
  border: solid var(--accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* The file choice: without the script the browser's input, its button drawn as a quiet pill;
   with it a pill and the list of the chosen files, each to take out again. */
input[type='file'] {
  padding: 0.375rem 0.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 2rem;
}

input[type='file']::file-selector-button {
  margin-right: 0.875rem;
  min-height: 2rem;
  padding: 0 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

input[type='file']::file-selector-button:hover {
  color: var(--text);
  background: var(--hover);
}

.files {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem;
}

.files__list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1 1 16rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.files__empty {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.files__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding: 0 0.25rem 0 0.875rem;
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-3);
}

.files__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.files__size {
  flex-shrink: 0;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.files__remove {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.125rem 0;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.files__remove:hover {
  color: var(--text);
  background: var(--hover);
}

/* CC and BCC (H18): the addresses as cards in front of the field that takes the next one; without script
   the plain text field stands alone. */
.addresses--enhanced {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-3);
}

.addresses--enhanced:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.addresses__list {
  display: contents;
  margin: 0;
  padding: 0;
  list-style: none;
}

.addresses__item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.125rem 0 0.625rem;
  font-size: 0.875rem;
  background: var(--hover);
  border-radius: var(--radius-pill);
}

.addresses__name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.addresses__remove {
  width: 1.75rem;
  height: 1.75rem;
  font: inherit;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.addresses__remove:hover {
  color: var(--text);
}

.addresses__entry {
  flex: 1 1 10rem;
  min-width: 8rem;
  padding: 0.25rem;
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  outline: 0;
}

.addresses__entry[aria-invalid='true'] {
  color: var(--danger);
}

/* The urgency choice (#502): native radios, so it works without script; each option a filled row
   with its word and one line of help, the chosen one in accent-quiet. */
.choices {
  border: 0;
  margin: 0;
  padding: 0;
}

.choices legend {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0;
  margin-bottom: 0.4375rem;
}

.choices .hint {
  margin: 0 0 0.25rem;
}

.field .choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-3);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color var(--motion-instant) var(--ease-standard);
}

.field .choice:hover {
  border-color: var(--text-muted);
}

.field .choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-quiet);
}

.choice input[type='radio'],
.choice input[type='checkbox'] {
  width: 1.125rem;
  height: 1.125rem;
  min-height: 0;
  margin: 0.125rem 0 0;
  padding: 0;
  flex: none;
  box-shadow: none;
  accent-color: var(--accent);
}

.choice input[type='radio']:focus-visible,
.choice input[type='checkbox']:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.choice__text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.choice__label {
  font-weight: 600;
}

.choice__help {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* The demo quick login of a local run (portal/dev-logins.ts): quieter than the form, dashed so
   nobody mistakes it for part of the real portal. */
.quick-login {
  max-width: 27.5rem;
  margin-top: 1.25rem;
  padding: 1.5rem 1.75rem 1.75rem;
  background: var(--raised);
  box-shadow: none;
  border: 1px dashed var(--border);
  text-align: center;
}

.quick-login h2 {
  font-size: 1.05rem;
  margin: 0.25rem 0 1rem;
}

.quick-login__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* The date picker of the ticket forms (E222): a text field and a calendar in the portal's own colours. */
.date {
  position: relative;
}

.date__calendar {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.375rem);
  left: 0;
  width: 18.5rem;
  max-width: calc(100vw - 2rem);
  padding: 0.75rem;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-4, 1rem);
  box-shadow: var(--shadow-dialog);
}

/* The calendar lives inside a card, whose entrance animation makes it a layer of its own; the card with an open calendar stands above the cards and the footer after it, which would else paint over the calendar. */
.card:has(.date__calendar:not([hidden])) {
  position: relative;
  z-index: 30;
}

.date__calendar--up {
  top: auto;
  bottom: calc(100% + 0.375rem);
}

.date__calendar[hidden] {
  display: none;
}

.date__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.date__title {
  font-size: 0.9375rem;
  font-weight: 600;
}

.date__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  font: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.date__step:hover {
  background: var(--hover);
  color: var(--text);
}

.date__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.125rem;
  text-align: center;
}

.date__weekday {
  padding: 0.25rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.date__day {
  height: 2.25rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.date__day:hover {
  background: var(--hover);
}

.date__day--outside {
  color: var(--text-muted);
}

.date__day--today {
  background: var(--accent-quiet);
  color: var(--accent);
  font-weight: 600;
}

.date__day--focus {
  border-color: var(--focus);
}

.date__day[aria-selected='true'] {
  background: var(--selected);
  color: var(--on-selected);
  font-weight: 600;
}

.date__foot {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--hairline);
}

.date__action {
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 0;
  border-radius: var(--radius-3);
  padding: 0.375rem 0.625rem;
  cursor: pointer;
}

.date__action:hover {
  background: var(--hover);
}

/* The editor of a reply and of a description (E222): the script unhides the toolbar and the surface. */
.editor__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-radius: var(--radius-3) var(--radius-3) 0 0;
}

.editor__button,
.editor__palette summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0 0.5rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  cursor: pointer;
  list-style: none;
}

.editor__palette summary::-webkit-details-marker {
  display: none;
}

.editor__button:hover,
.editor__palette summary:hover {
  background: var(--hover);
}

.editor__button[aria-pressed='true'] {
  color: var(--on-selected);
  background: var(--selected);
}

.editor__button:focus-visible,
.editor__palette summary:focus-visible,
.editor__swatch:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.editor__palette {
  position: relative;
}

.editor__swatches {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  display: flex;
  gap: 0.25rem;
  margin-top: 0.25rem;
  padding: 0.375rem;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-control);
}

.editor__swatch {
  min-width: 2rem;
  min-height: 2rem;
  font: inherit;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-1);
  cursor: pointer;
}

.editor__swatch--none {
  color: var(--text-muted);
  text-decoration: line-through;
}

.editor__glyph {
  padding: 0 0.25rem;
  font-weight: 700;
}

.editor__surface {
  min-height: 9rem;
  overflow: auto;
  resize: vertical;
  padding: 0.75rem 0.875rem;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 0 0 var(--radius-3) var(--radius-3);
  box-shadow: var(--shadow-control);
}

.editor__surface:focus {
  border-color: var(--accent);
  background: var(--raised);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.editor__surface p {
  margin: 0 0 0.75rem;
}

.editor__surface ul,
.editor__surface ol {
  margin: 0 0 0.75rem;
  padding-left: 1.5rem;
}

.editor__image {
  position: relative;
  display: inline-block;
  vertical-align: top;
  margin: 0.125rem 0;
  max-width: 100%;
  line-height: 0;
  border-radius: var(--radius-1);
  outline: 2px solid transparent;
  outline-offset: 2px;
  user-select: none;
}

.editor__image--chosen {
  outline-color: var(--accent);
}

.editor__picture {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-1);
  cursor: grab;
}

/* The grip and the cross belong to the chosen picture only. */
.editor__handle,
.editor__remove {
  display: none;
}

.editor__image--chosen .editor__handle,
.editor__image--chosen .editor__remove {
  display: block;
}

.editor__handle {
  position: absolute;
  right: -0.4375rem;
  bottom: -0.4375rem;
  width: 0.875rem;
  height: 0.875rem;
  background: var(--accent);
  border: 2px solid var(--raised);
  border-radius: var(--radius-1);
  cursor: nwse-resize;
  touch-action: none;
}

.editor__remove {
  position: absolute;
  top: -0.625rem;
  right: -0.625rem;
  width: 1.375rem;
  height: 1.375rem;
  padding: 0;
  font: inherit;
  font-size: 1rem;
  line-height: 1.125rem;
  text-align: center;
  color: var(--raised);
  background: var(--accent);
  border: 2px solid var(--raised);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.editor__note {
  margin-top: 0.375rem;
}

/* A success message after sending (H18): a toast at the bottom that goes away by itself; without it the page stays as it is. */
.notice--toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  z-index: 50;
  max-width: min(32rem, calc(100vw - 2rem));
  margin: 0;
  transform: translateX(-50%);
  background: var(--raised);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-control);
  animation: toast-away 0.3s ease 5s forwards;
}

@keyframes toast-away {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  .notice--toast {
    animation-duration: 0.01s;
  }
}
