/* SPDX-License-Identifier: AGPL-3.0-only
 * SPDX-FileCopyrightText: 2021-2026 DALICC - Verein zur Foerderung der Rechtssicherheit in der Datenbewirtschaftung (ZVR 1249185710)
 */
/* DALICC site: reusable components.
 *
 * Every component here has a Jinja macro in
 * app/templates/site/_components/macros.html and, where it needs behaviour, a
 * matching entry point in components.js. See docs/WEBSITE.md for the macro
 * signatures.
 *
 * The visuals reproduce the original DALICC tool pages: full-width slate legend
 * bars on collapsible fieldsets, tri-state permission switches, two-state duty
 * switches, circular "?" info buttons and the red/white experimental-service
 * disclaimer.
 *
 * Requires the tokens declared in site.css. Load after it.
 */

/* ============================================================ flash message */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  margin: 0 0 28px;
  border: 1px solid var(--c-rule-strong);
  background: var(--c-peach);
  color: var(--c-ink);
  font-size: var(--size-body-small);
}

.flash a {
  color: inherit;
  text-decoration: underline;
}

.flash__icon {
  flex: 0 0 auto;
  line-height: 1.4;
}

.flash__body {
  min-width: 0;
  /* A file path or an address in a message is one long word; at 390 px the path of
     the shipped dependency graph pushed the viewer 4 px wider than the screen. */
  overflow-wrap: anywhere;
}

/* The drawn mark of flash_mark(): sits on the first line of the message. */
.flash__mark {
  display: block;
  margin-top: 3px;
}

/* The privacy-notice banner of base.html: the list of changes folds away. */
.notice-banner__changes {
  margin: 6px 0 10px;
}

.notice-banner__changes > summary {
  cursor: pointer;
  text-decoration: underline;
}

.notice-banner__changes[open] > summary {
  margin-bottom: 6px;
}

.flash__body > :last-child {
  margin-bottom: 0;
}

.flash--success {
  border-color: var(--c-green);
  background: var(--color-ok-surface);
}

.flash--error {
  border-color: var(--c-red);
  background: var(--color-alert-surface);
}

.flash--warning {
  border-color: var(--color-warn);
  background: var(--color-warn-surface);
}

.flash--info {
  border-color: var(--c-rule-strong);
  background: var(--c-peach);
}

/* ============================================================ info button */

.info {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
}

.info__btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--c-rule-strong);
  background: var(--c-surface-alt);
  color: var(--c-slate-muted);
  font-family: var(--font-body);
  font-size: var(--size-label);
  font-weight: 700;
  line-height: 1;
  cursor: help;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.info__btn:hover,
.info__btn:focus-visible {
  border-color: var(--c-green);
  background: var(--c-green);
  color: var(--c-white);
}

.info__bubble {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 80;
  width: max-content;
  max-width: min(340px, 70vw);
  background: var(--c-slate-dark);
  color: var(--c-white);
  font-size: var(--size-caption);
  line-height: 1.45;
  padding: 10px 13px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-drop);
  text-align: left;
  font-weight: normal;
  text-transform: none;
}

.info__bubble::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--c-slate-dark);
}

.info__btn:not(:hover):not(:focus-visible) + .info__bubble:not([data-open="true"]) {
  /* Kept in the accessibility tree for aria-describedby, hidden visually. */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  box-shadow: none;
}

/* On a phone a bubble anchored to its button ran off the left edge whenever the "?"
   sat near it (measured at -232px on the composer). There it is a sheet at the foot
   of the screen, the full width less the gutter, and the button is a 24px target. */
@media (max-width: 604px) {
  .info__btn {
    width: 24px;
    height: 24px;
  }

  .info__bubble {
    position: fixed;
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    transform: none;
    width: auto;
    max-width: none;
  }

  .info__bubble::before {
    display: none;
  }
}

/* ==================================================== collapsible fieldset */

.collapsible {
  border: 1px solid var(--c-rule-strong);
  border-top: 0;
  margin: 0 0 18px;
  background: var(--c-white);
}

.collapsible__legend {
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  background: var(--c-slate-muted);
  color: var(--c-white);
  font-family: var(--font-body);
  font-size: var(--size-body);
  font-weight: 600;
  padding: 12px 18px;
  margin: 0 -1px;
  user-select: none;
}

.collapsible__legend::-webkit-details-marker {
  display: none;
}

.collapsible__legend:hover {
  background: var(--c-slate-dark-hover);
}

.collapsible[open] > .collapsible__legend {
  background: var(--c-slate-dark);
}

.collapsible__legend:focus-visible {
  outline: var(--focus-ring);
  outline-offset: -3px;
}

.collapsible__sign {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid currentColor;
  position: relative;
}

.collapsible__sign::before,
.collapsible__sign::after {
  content: "";
  position: absolute;
  background: currentColor;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.collapsible__sign::before {
  width: 10px;
  height: 2px;
}

.collapsible__sign::after {
  width: 2px;
  height: 10px;
}

.collapsible[open] > .collapsible__legend .collapsible__sign::after {
  display: none;
}

.collapsible__body {
  padding: 20px 18px;
}

.collapsible__body > :last-child {
  margin-bottom: 0;
}

.collapsible--disabled > .collapsible__legend {
  background: var(--c-pale-blue);
  color: var(--c-slate);
  cursor: not-allowed;
}

.collapsible--disabled > .collapsible__body {
  opacity: 0.55;
}

/* Sub-heading bar used for the "Duties" blocks inside a fieldset. */
.subhead-bar {
  background: var(--c-slate-muted);
  color: var(--c-white);
  font-weight: 600;
  padding: 8px 16px;
  margin: 18px 0 0;
  font-size: var(--size-body-small);
}

.subhead-bar + .subhead-body {
  border: 1px solid var(--c-rule);
  border-top: 0;
  padding: 16px;
}

/* ====================================================== three-state switch */

.switch3 {
  display: inline-grid;
  grid-template-columns: repeat(3, 26px);
  align-items: center;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--c-rule);
  border-radius: 999px;
  flex: 0 0 auto;
}

.switch3__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.switch3__opt {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border-radius: 50%;
  font-size: var(--size-label-small);
  line-height: 1;
  color: var(--c-slate-muted);
  cursor: pointer;
  font-weight: 700;
  transition: background-color 120ms ease, color 120ms ease;
}

.switch3__opt:hover {
  color: var(--c-slate-dark);
}

.switch3__input:checked + .switch3__opt--yes {
  background: var(--c-green);
  color: var(--c-white);
}

.switch3__input:checked + .switch3__opt--na {
  background: var(--c-slate-muted);
  color: var(--c-white);
}

.switch3__input:checked + .switch3__opt--no {
  background: var(--c-slate-dark);
  color: var(--c-white);
}

.switch3__input:focus-visible + .switch3__opt {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.switch3[data-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

/* ======================================================== two-state switch */

.switch2 {
  display: inline-grid;
  grid-template-columns: 26px 26px;
  align-items: center;
  background: var(--c-rule);
  border-radius: 999px;
  flex: 0 0 auto;
  position: relative;
}

.switch2__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.switch2__track {
  display: contents;
}

.switch2__knob,
.switch2__off {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  border-radius: 50%;
  font-size: var(--size-label-small);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.switch2__knob {
  color: var(--c-slate-muted);
}

.switch2__off {
  color: transparent;
}

.switch2__input:checked ~ .switch2__track .switch2__knob {
  background: var(--c-green);
  color: var(--c-white);
}

.switch2__input:not(:checked) ~ .switch2__track .switch2__off {
  background: var(--c-white);
  box-shadow: inset 0 0 0 1px var(--c-rule-strong);
}

.switch2__input:focus-visible ~ .switch2__track .switch2__knob {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* Row that pairs a switch with its label and info button. */
.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 7px 0;
}

.switch-row__label {
  font-weight: normal;
  color: var(--c-ink);
  /* Shrink to the text so the "?" button sits right after the question, the way
     the original questionnaire had it. */
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--size-body-small);
}

.switch-row__label b,
.switch-row__label strong {
  color: var(--c-slate-dark);
}

.switch-row--nested {
  padding-left: 26px;
}

@media (max-width: 450px) {
  .switch-row--nested {
    padding-left: 14px;
  }
}

/* ========================================================== license card */

.license-card {
  border: 1px solid var(--c-rule-strong);
  background: var(--c-white);
  padding: 16px 18px;
  margin: 0 0 14px;
  box-shadow: var(--shadow-card);
}

.license-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 2px dotted var(--c-rule-strong);
}

.license-card__title {
  font-family: var(--font-display);
  font-size: var(--size-card-title);
  text-transform: uppercase;
  color: var(--c-slate);
  margin: 0;
}

.license-card__title a {
  color: inherit;
}

.license-card__title a:hover {
  color: var(--c-red);
}

.license-card__id {
  font-family: var(--font-mono);
  font-size: var(--size-label-small);
  color: var(--c-slate-muted);
  word-break: break-all;
}

.license-card__meta {
  margin: 8px 0 0;
  font-size: var(--size-ui-small);
  color: var(--c-ink-soft);
}

.license-card__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: var(--size-label-small);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-rule-strong);
  color: var(--c-slate);
}

.badge--ok {
  background: var(--color-ok-surface);
  border-color: var(--c-green);
  color: var(--c-green-active);
}

.badge--warn {
  background: var(--color-alert-surface);
  border-color: var(--c-red);
  color: var(--c-red-dark);
}

.badge--neutral {
  background: var(--c-surface-alt);
}

/* ============================================================= pagination */

.pager {
  margin: 28px 0 0;
}

.pager__list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 1px solid var(--c-green);
  width: max-content;
  max-width: 100%;
}

.pager__list li {
  margin: 0;
}

.pager__link {
  display: block;
  padding: 7px 13px;
  font-family: var(--font-display);
  font-size: var(--size-body-small);
  text-transform: uppercase;
  color: var(--c-green);
  background: var(--c-white);
  border-right: 1px solid var(--c-green);
}

.pager__list li:last-child .pager__link {
  border-right: 0;
}

.pager__link:hover,
.pager__link:focus-visible {
  background: var(--c-green-hover);
  color: var(--c-white);
  text-decoration: none;
}

.pager__link[aria-current="page"] {
  background: var(--c-green);
  color: var(--c-white);
}

.pager__gap {
  padding: 7px 10px;
  color: var(--c-slate-muted);
  border-right: 1px solid var(--c-green);
}

/* ============================================================ legal note */

/* ui.legal_note(): the info flash under the lede of a tool page. */
.legal-note p {
  margin: 0;
}

/* ======================================================= disclaimer modal */

.disclaimer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--scrim);
}

.disclaimer[hidden] {
  display: none;
}

.disclaimer__panel {
  background: var(--c-white);
  width: min(700px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-top: 26px solid var(--c-red);
  box-shadow: var(--shadow-modal);
  padding: 26px 28px 28px;
}

.disclaimer__title {
  font-size: var(--size-h3);
  margin: 0 0 12px;
}

.disclaimer__panel p {
  font-size: var(--size-body);
  color: var(--c-ink);
}

.disclaimer__panel p:last-of-type {
  margin-bottom: 22px;
}

/* ============================================================== autocomplete */

.autocomplete {
  position: relative;
}

.autocomplete__list {
  position: absolute;
  z-index: 70;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--c-white);
  border: 1px solid var(--c-rule-strong);
  border-top: 3px solid var(--c-green);
  box-shadow: var(--shadow-panel);
  max-height: 320px;
  overflow-y: auto;
}

.autocomplete__list[hidden] {
  display: none;
}

.autocomplete__list li {
  margin: 0;
}

.autocomplete__option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 9px 14px;
  font: inherit;
  font-size: var(--size-ui-small);
  color: var(--c-slate);
  cursor: pointer;
}

.autocomplete__option:hover,
.autocomplete__option[aria-selected="true"] {
  background: var(--c-surface-alt);
  color: var(--c-red);
}

.autocomplete__empty {
  padding: 9px 14px;
  font-size: var(--size-ui-small);
  color: var(--c-slate-muted);
}

/* ============================================================ empty state */

.empty-state {
  border: 1px solid var(--c-rule-strong);
  background: var(--c-surface-alt);
  padding: 28px 24px;
  text-align: center;
  color: var(--c-slate);
}

.empty-state h2 {
  margin-top: 0;
  font-size: var(--size-card-title);
}

.empty-state > :last-child {
  margin-bottom: 0;
}

/* ------------------------------------------------------------------ history */
/* The model history of a curated record: the version list on the license page,
   the archived-version banner and the library-wide changes page. */

.history-box {
  margin: 0 0 40px;
}

.history-box h2 {
  border-bottom: 2px dotted var(--c-rule-strong);
  padding-bottom: 8px;
  margin-bottom: 18px;
}

.archived-banner {
  border: 1px solid var(--c-rule-strong);
  background: var(--c-peach);
  padding: 12px 16px;
  margin: 16px 0 0;
  font-size: var(--size-ui-small);
}

.history-box__lede {
  margin: 0 0 16px;
}

.history-box__foot {
  margin: 18px 0 0;
  font-size: var(--size-caption);
}

.version-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.version {
  border: 1px solid var(--c-rule);
  background: var(--c-surface-alt);
  padding: 14px 16px;
}

.version--current {
  border-color: var(--c-rule-strong);
}

.version__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 6px;
}

.version__number {
  font-weight: 700;
}

.version__date,
.version__reviewer {
  color: var(--c-slate-mid);
  font-size: var(--size-caption);
}

.version__summary {
  margin: 0 0 10px;
}

.version__links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}

.version__changes {
  margin: 0;
}

.change-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.change {
  border-bottom: 1px dotted var(--c-rule-strong);
  padding-bottom: 12px;
}

.change:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.change__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 4px;
  font-size: var(--size-caption);
}

.change__action {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: var(--size-label-small);
  font-weight: 700;
  color: var(--c-slate-mid);
}

.change--added .change__action { color: var(--c-green-active); }
.change--removed .change__action { color: var(--c-red-dark); }

.change__statement,
.change__previous code {
  font-size: var(--size-mono);
  overflow-wrap: anywhere;
}

.change__previous {
  margin: 0 0 4px;
  font-size: var(--size-label);
  color: var(--c-slate-mid);
}

.change__reason {
  margin: 0;
  font-size: var(--size-caption);
}

.change__license {
  font-weight: 700;
}

.change__version,
.change__date {
  color: var(--c-slate-mid);
  font-size: var(--size-label);
}

.change-list--index {
  gap: 20px;
  margin: 18px 0 24px;
}

.changes-lede {
  max-width: 68ch;
}

.changes-count {
  margin: 18px 0 0;
  color: var(--c-slate-mid);
}

.changes-filter {
  margin: 20px 0 0;
}

.changes-filter__label {
  display: block;
  font-weight: 700;
  margin: 0 0 6px;
}

.changes-filter__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--c-rule-strong);
  background: var(--c-surface);
  color: var(--c-slate-dark);
  text-decoration: none;
  font-size: var(--size-caption);
}

.filter-chip:hover,
.filter-chip:focus-visible {
  background: var(--c-surface-alt);
}

.filter-chip--on {
  background: var(--c-slate-dark);
  border-color: var(--c-slate-dark);
  color: var(--c-white);
}

@media (max-width: 604px) {
  .version__links {
    gap: 6px;
  }

  .change__statement {
    font-size: var(--size-label-small);
  }
}

.library-header-links {
  margin: 0 0 20px;
  font-size: var(--size-ui-small);
}

.library-header-links .text-muted {
  display: block;
  font-size: var(--size-caption);
  margin-top: 2px;
}

/* ========================================================= sortable tables */

/* The header of a sortable column is a button set like the header text around it:
   display capitals in the on-brand colour of the slate head. A 2 px dotted rule
   under the label says the heading can be pressed; on the column the rows are
   sorted by the rule turns solid and a drawn chevron (two borders of a small square
   turned 45 degrees) points the way of the order. site.js sorts the rows and sets
   aria-sort on the header cell. */
.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  text-decoration: underline dotted var(--color-on-brand-soft);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  cursor: pointer;
}

.sort-button:hover,
[aria-sort="ascending"] > .sort-button,
[aria-sort="descending"] > .sort-button {
  text-decoration-style: solid;
  text-decoration-color: var(--color-on-brand);
}

/* The focus ring on the slate head takes the colour of the text on it, as it does
   on the other slate fields. */
.sort-button:focus-visible {
  outline: 3px solid var(--color-on-brand);
  outline-offset: 3px;
}

.sort-button::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  visibility: hidden;
  transform: translateY(-2px) rotate(45deg);
}

[aria-sort="descending"] > .sort-button::after {
  visibility: visible;
}

[aria-sort="ascending"] > .sort-button::after {
  visibility: visible;
  transform: translateY(2px) rotate(-135deg);
}

@media (forced-colors: active) {
  .sort-button::after {
    border-color: ButtonText;
  }
}
