/* Form controls and small page parts that the browser drew before: checkbox, radio button, number field, search field,
   file field, slider, option list, tooltip, leave dialog and scrollbar. The layout loads this file after app.css and
   before the page styles, so a page keeps its sizes and margins.
   The CSP allows only same-origin images, so each icon is a file and not a data URI. */

/* Checkbox and radio button. The double :not() outranks page rules such as `.x input`, which set a border, a padding and
   a background for text fields. The rule sets no display and no position, so a page can still hide a box. */
:where(input[type="checkbox"], input[type="radio"]) { width: 20px; height: 20px; }
input[type="checkbox"]:not([hidden]):not([multiple]),
input[type="radio"]:not([hidden]):not([multiple]) { appearance: none; padding: 0; border: 2px solid var(--control-border); background: #eef0ec center / 100% 100% no-repeat; box-shadow: none; vertical-align: middle; cursor: pointer; }
input[type="checkbox"]:not([hidden]):not([multiple]) { border-radius: 6px; }
input[type="radio"]:not([hidden]):not([multiple]) { border-radius: 50%; }
input[type="checkbox"]:checked:not([hidden]):not([multiple]) { border-color: var(--nav-accent); background-color: var(--nav-accent); background-image: url("../images/check.svg"); }
/* "Some selected": a bar instead of the tick. */
input[type="checkbox"]:indeterminate:not([hidden]):not([multiple]) { border-color: var(--nav-accent); background-color: var(--nav-accent); background-image: linear-gradient(#eef0ec, #eef0ec); background-size: 10px 2px; }
input[type="radio"]:checked:not([hidden]):not([multiple]) { border-color: var(--nav-accent); background-color: var(--nav-accent); box-shadow: inset 0 0 0 3px #eef0ec; }
input[type="checkbox"][aria-invalid="true"]:not([hidden]):not(:checked),
input[type="radio"][aria-invalid="true"]:not([hidden]):not(:checked) { border-color: #9a3730; background-color: #e9e2e2; }
input[type="checkbox"]:disabled:not([hidden]):not([multiple]),
input[type="radio"]:disabled:not([hidden]):not([multiple]) { opacity: .55; cursor: not-allowed; }
@media (forced-colors: active) {
    input[type="checkbox"]:not([hidden]):not([multiple]),
    input[type="radio"]:not([hidden]):not([multiple]) { appearance: auto; }
}

/* Number field: no arrows of the browser. A phone still shows its number keyboard. */
input[type="number"] { appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { appearance: none; margin: 0; }

/* Search field: our icon at the start and our cross at the end. field-controls.js sets has-text and empties the field.
   The help search in the header has its own look. */
input[type="search"]:not(.help-search *):not([hidden]) { appearance: none; padding-left: 40px; background-image: url("../images/search.svg"); background-repeat: no-repeat; background-position: left 12px center; background-size: 18px 18px; }
input[type="search"].has-text:not(.help-search *):not([hidden]) { padding-right: 44px; background-image: url("../images/search.svg"), url("../images/clear.svg"); background-position: left 12px center, right 13px center; }
input[type="search"].over-clear { cursor: pointer; }
input[type="search"]:not(.help-search *)::-webkit-search-cancel-button { display: none; }

/* File field: field-controls.js puts a button and a status text before the input and adds file-native to the input.
   The input stays in the page for the focus, the label and the validation, so the rules must beat each page rule. */
input[type="file"].file-native { position: absolute !important; width: 1px !important; height: 1px !important; min-width: 0 !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border: 0 !important; clip-path: inset(50%); overflow: hidden; flex: none !important; }
.file-field { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; max-width: 100%; }
.file-field .button-link { flex: none; }
.file-status { min-width: 0; font-size: var(--text-small); color: var(--text-secondary); overflow-wrap: anywhere; }
.file-field:has(+ input:focus-visible) .button-link { outline: 3px solid #4f6d56; outline-offset: 3px; }
.file-field:has(+ input[aria-invalid="true"]) .file-status { color: var(--text-danger); }
.file-field:has(+ input:disabled) { opacity: .55; }
.file-field:has(+ input:disabled) .button-link { cursor: not-allowed; }
.file-field:has(+ input[hidden]) { display: none; }

/* Slider with its value. */
input[type="range"]:not([hidden]):not([multiple]) { appearance: none; height: 44px; min-height: 0; margin: 0; padding: 0; border: 0; background: none; box-shadow: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: var(--nav-rule); }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 4px; background: var(--nav-rule); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 24px; height: 24px; margin-top: -8px; border: 3px solid #eef0ec; border-radius: 50%; background: var(--nav-accent); box-shadow: 0 0 0 1px var(--nav-accent); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 3px solid #eef0ec; border-radius: 50%; background: var(--nav-accent); box-shadow: 0 0 0 1px var(--nav-accent); }
.range-field { display: flex; align-items: center; gap: 12px; }
.range-field input { flex: 1; min-width: 0; }
.range-field output { flex: 0 0 4ch; text-align: right; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
@media (forced-colors: active) {
    input[type="range"]:not([hidden]):not([multiple]) { appearance: auto; }
}

/* Option list of dropdown.js, for each select and each text field with suggestions. It is a popover: the script sets
   its place under or above the field. */
.option-list { position: fixed; inset: auto; flex-direction: column; gap: 6px; max-width: min(420px, calc(100vw - 16px)); margin: 0; padding: 6px; border: 1px solid var(--control-border); border-radius: var(--control-radius); background: #e7e8e5; color: var(--text-primary); box-shadow: 0 8px 24px rgb(21 35 27 / 18%); font-size: var(--text-body); overflow: hidden; }
.option-list:popover-open { display: flex; }
/* No flex: 1 here: Safari gives a 0% basis no height in a panel without a set height, and the list shows empty. */
.option-list ul { min-height: 0; margin: 0; padding: 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.option-list [role="option"] { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.option-list [role="option"]:hover, .option-list [role="option"]:focus { background: var(--button-secondary); outline: none; }
.option-list [role="option"]:focus-visible { box-shadow: inset 0 0 0 2px #4f6d56; }
.option-list [aria-selected="true"] { font-weight: var(--weight-semibold); }
.option-list [aria-selected="true"]::after { content: ""; flex: none; width: 6px; height: 12px; margin: 0 4px 3px auto; border: solid var(--nav-accent); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.option-list [aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.option-list-heading { padding: 10px 12px 4px; color: var(--text-secondary); font-size: var(--text-caption); font-weight: var(--weight-bold); letter-spacing: var(--tracking-label); }
.option-list .option-list-search { flex: none; width: 100%; min-height: 44px; margin: 0; padding: 8px 12px; border: 1px solid var(--control-border); border-radius: 8px; background: #f1f2ef; color: var(--text-primary); font-size: var(--text-body); }
.option-list-empty { margin: 0; padding: 10px 12px; color: var(--text-secondary); font-size: var(--text-small); }

/* Tooltip of tooltip.js. */
.tooltip { position: fixed; inset: auto; max-width: min(320px, calc(100vw - 16px)); margin: 0; padding: 6px 10px; border: 0; border-radius: 8px; background: var(--text-primary); color: #fff; font-size: var(--text-small); line-height: 1.4; overflow-wrap: anywhere; pointer-events: none; }

/* Dialog of leave-guard.js. */
.leave-dialog { width: min(440px, calc(100% - 24px)); max-width: calc(100% - 24px); padding: 20px; border: 1px solid var(--control-border); border-radius: 12px; background: #e7e8e5; color: var(--text-primary); }
.leave-dialog::backdrop { background: rgb(21 35 27 / 40%); }
.leave-dialog h2 { margin: 0 0 8px; font-size: var(--text-heading-3); }
.leave-dialog p { margin: 0; }
.leave-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; margin-top: 20px; }
/* Some pages stretch their buttons to the full width. */
.leave-dialog-actions button { width: auto; }

/* Scrollbars: thin, in the colors of the portal. A page can set its own colors for one scroll box. */
* { scrollbar-width: thin; scrollbar-color: var(--control-border) transparent; }
