/* Lucca's own styles on top of the DSFR (ADR 0006): plain CSS, no Bootstrap */

/* Back-office pages use the full width */
.fr-container {
    max-width: none;
}

/* A heading and its actions, e.g. the page h1 (templates/layout/base.html.twig): the DSFR grid has no auto-width column */
.heading-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.heading-row .fr-btns-group {
    margin-bottom: 0;
}

/* In a table cell (dossier cadres), the buttons' own bottom margin spaces wrapped rows, not the cell's bottom */
.fr-table td > .fr-btns-group {
    margin-bottom: -1rem;
}

/* Form theme (templates/form/dsfrLayout.html.twig): the DSFR spaces input and select groups, not these */
form .fr-checkbox-group:not(:last-child),
form .fr-upload-group:not(:last-child),
form [data-shown-by]:not(:last-child) {
    margin-bottom: 1.5rem;
}

/* Header tools dropdowns (templates/components/header.html.twig) reuse the language selector: its own icon gives way to theirs */
.header-menu .fr-translate__btn::before {
    display: none;
}

/* The Lucca logo (header and footer) has one version, drawn for a white background: kept on white in the dark theme */
.fr-header__operator img,
.fr-footer__logo {
    background-color: #fff;
    border-radius: 0.25rem;
}

/* One entry per line: the language selector lays its list out in columns */
.header-menu .fr-menu__list {
    display: block;
}

/* Colour settings (templates/setting/_settingValue.html.twig) */
.color-swatch {
    border: 1px solid var(--border-default-grey);
    display: inline-block;
    height: 1rem;
    vertical-align: middle;
    width: 1rem;
}

/* Row actions of a table (templates/components/table.html.twig): icon-only buttons side by side, right-aligned */
.table-actions {
    display: flex;
    gap: .25rem;
    justify-content: flex-end;
}

/* Tags in a table cell (templates/components/tags.html.twig) line up with the row's text: the DSFR spaces them for a block */
.fr-table__content .fr-tags-group > li {
    line-height: 1.5rem;
}

.fr-table__content .fr-tags-group .fr-tag {
    margin-bottom: .125rem;
    margin-top: .125rem;
    white-space: nowrap;
}

/* Label/value tables (components/fieldsTable, detailsTable): the labels take their own width, the values the rest */
@media (min-width: 48em) {
    .fields-table .fr-table__content tbody th[scope="row"] {
        white-space: nowrap;
        width: 1%;
    }
}

/* The row of the department the user is in (templates/department/index.html.twig) */
.fr-table__content table tbody tr[aria-current="true"] td {
    background-color: var(--background-contrast-blue-france);
    font-weight: 700;
}

/* Stored values printed as is, e.g. logs and login attempts: one width per character */
.monospace {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Stored HTML or CSS sources (document model pages and blocs): their line breaks kept */
.source-value {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* A colour code with its .color-swatch (templates/components/colorValue.html.twig), and the model form's picker */
.color-value {
    align-items: center;
    display: inline-flex;
    gap: .5rem;
}

.color-field {
    align-items: center;
    display: flex;
    gap: .5rem;
}

.color-field input[type="color"] {
    block-size: 2.5rem;
    flex: 0 0 2.5rem;
    inline-size: 2.5rem;
    padding: 0;
}

.color-field__picker--empty::-webkit-color-swatch {
    background: repeating-linear-gradient(45deg, var(--background-default-grey) 0 4px, var(--border-default-grey) 4px 5px) !important;
}

.color-field__picker--empty::-moz-color-swatch {
    background: repeating-linear-gradient(45deg, var(--background-default-grey) 0 4px, var(--border-default-grey) 4px 5px) !important;
}

/*
 * Dashboard map (templates/map/, assets/map/ign-map.js, dashboard_map_controller.js), ported from CoreBundle app.scss
 */
.ign-map {
    min-height: 300px;
    /* Leaflet panes stack up to z-index 1000: keep them under the header menus and modals */
    z-index: 0;
}

.ign-map-dashboard {
    min-height: 650px;
}

/* Same height as the plot form's map */
.ign-map-modal {
    min-height: 450px;
}

/* The DSFR underlines links and marks new-window ones: not inside the map's controls and popups */
.leaflet-container a {
    background-image: none;
}

.leaflet-container a[target="_blank"]::after {
    content: none;
}

/* Layers button with a DSFR icon, sized like Leaflet's zoom buttons; beats Leaflet's touch and retina rules */
.ign-map.leaflet-container .leaflet-control-layers-toggle {
    align-items: center;
    background-image: none;
    color: var(--text-default-grey);
    display: flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.ign-map.leaflet-container .leaflet-control-layers-expanded .leaflet-control-layers-toggle {
    display: none;
}

/* Search suggestions under the search bar (assets/map/suggestions.js) */
.map-search {
    position: relative;
}

.map-suggestions {
    background: var(--background-default-grey);
    box-shadow: 0 6px 18px 0 rgb(0 0 18 / 16%);
    left: 0;
    list-style: none;
    margin: 0;
    max-height: 16rem;
    overflow-y: auto;
    padding: 0;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 1000;
}

.map-suggestions > li {
    cursor: pointer;
    padding: .5rem 1rem;
}

.map-suggestions > li:hover,
.map-suggestions > li[aria-selected="true"] {
    background: var(--background-action-low-blue-france);
}

/* Filters panel, on the map (bottom left), styled like Leaflet's own controls */
.map-filters {
    background: rgb(255 255 255 / 95%);
    border-radius: 4px;
    box-shadow: 0 1px 5px rgb(0 0 0 / 40%);
    color: #333;
    padding: .5rem 1rem .5rem .75rem;
}

.map-filters-toggle {
    align-items: center;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: flex;
    font-weight: 700;
    gap: .25rem;
    padding: 0;
    width: 100%;
}

.map-filters-chevron {
    transition: transform .2s;
}

.map-filters-list {
    list-style: none;
    margin: .5rem 0 0;
    padding: 0;
}

/* Grid rows stretch the buttons, so the switches line up on the right */
.map-filters-list > li {
    display: grid;
    padding: 0;
}

.map-filters-list > li + li {
    margin-top: .25rem;
}

.map-filters-closed .map-filters-list {
    display: none;
}

.map-filters-closed .map-filters-chevron {
    transform: rotate(-90deg);
}

/* A filter: icon in its marker colour, label, then an on/off switch. Nothing faded: that reads as disabled */
.map-filter {
    align-items: center;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: flex;
    min-height: 1.75rem;
    padding: 0;
    white-space: nowrap;
}

/* Fixed width, not flex-basis: Firefox leaves flex-basis out of a button's width */
.map-filter-icon {
    flex: none;
    margin-right: .25rem;
    text-align: center;
    width: 1.5rem;
}

.map-filter-label {
    font-size: .875rem;
    padding-right: .75rem;
}

/* No count while the filter is off */
.map-filter .fr-badge:empty {
    display: none;
}

.map-filter:hover > .map-filter-switch,
.map-filter:focus-visible > .map-filter-switch {
    box-shadow: 0 0 0 2px rgb(0 0 0 / 15%);
}

.map-filter-switch {
    background: #adb5bd;
    border-radius: .5rem;
    flex: none;
    height: 1rem;
    margin-left: auto;
    position: relative;
    transition: background-color .2s;
    width: 1.75rem;
}

.map-filter-switch::after {
    background: #fff;
    border-radius: 50%;
    content: "";
    height: .75rem;
    left: .125rem;
    position: absolute;
    top: .125rem;
    transition: transform .2s;
    width: .75rem;
}

[aria-pressed="true"] > .map-filter-switch {
    background: #333;
}

[aria-pressed="true"] > .map-filter-switch::after {
    transform: translateX(.75rem);
}

/* Marker clusters, coloured per category like the filter icons */
.map-cluster {
    border: 3px solid rgb(255 255 255 / 80%);
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
}

/* Leaflet's stylesheet, loaded after this one, forces display: block on the icon itself */
.map-cluster > span {
    align-items: center;
    display: flex;
    height: 100%;
    justify-content: center;
}

.map-filter-controls > .map-filter-icon { color: #5b2500; }
.map-filter-decisions > .map-filter-icon { color: #25506d; }
.map-filter-folders > .map-filter-icon { color: #e34c4a; }
.map-filter-minutesClosedOther > .map-filter-icon { color: #878787; }
.map-filter-minutesClosedRegular > .map-filter-icon { color: #49c14a; }
.map-filter-minutesSpotted > .map-filter-icon { color: #f9902c; }
.map-filter-updates > .map-filter-icon { color: #00a585; }
.map-cluster-controls { background-color: #5b2500; }
.map-cluster-decisions { background-color: #25506d; }
.map-cluster-folders { background-color: #e34c4a; }
.map-cluster-minutesClosedOther { background-color: #878787; }
.map-cluster-minutesClosedRegular { background-color: #49c14a; }
.map-cluster-minutesSpotted { background-color: #f9902c; }
.map-cluster-updates { background-color: #00a585; }

.map-card a {
    display: block;
    margin-top: .25rem;
}

/* Query in progress in the map search (aria-busy, dashboard-map controller): the DSFR has no spinner. Drawn from a
   zero-width anchor between the field and its button, so it sits at the field's right end whatever the button's width */
.map-search-spinner {
    flex: none;
    position: relative;
    width: 0;
}

.fr-input[aria-busy="true"] + .map-search-spinner::after {
    animation: map-search-spin .8s linear infinite;
    border: 3px solid var(--border-default-grey);
    border-radius: 50%;
    border-top-color: var(--border-action-high-blue-france);
    content: "";
    height: 1.25rem;
    pointer-events: none;
    position: absolute;
    right: .75rem;
    top: calc(50% - .625rem);
    width: 1.25rem;
}

@keyframes map-search-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .fr-input[aria-busy="true"] + .map-search-spinner::after {
        animation: map-search-pulse 1.2s ease-in-out infinite alternate;
    }
}

@keyframes map-search-pulse {
    to {
        opacity: .3;
    }
}

/* Document model PDF preview (templates/model/show.html.twig) */
.model-preview {
    border: 1px solid var(--border-default-grey);
    height: 600px;
    width: 100%;
}

/* The blocs of a model margin (templates/model/margin/edit.html.twig): one numbered box each */
.bloc-list {
    counter-reset: bloc;
}

.bloc-list__item {
    border: 1px solid var(--border-default-grey);
    counter-increment: bloc;
    margin-bottom: 1.5rem;
    padding: 1.5rem 1rem 0;
}

.bloc-list__item > .fr-fieldset > legend::after {
    content: ' ' counter(bloc);
}

/* Key figures (templates/components/keyFigures.html.twig): a bordered box each, the number above its label */
.key-figures {
    list-style: none;
    padding-left: 0;
}

.key-figures__item {
    border: 1px solid var(--border-default-grey);
    height: 100%;
    padding: 1rem 1.5rem;
}

.key-figures__value {
    color: var(--text-title-blue-france);
    display: block;
    margin-bottom: 0;
}

/* Tom Select (long searchable lists, ADR 0006) without its own stylesheet: the structure it needs, drawn like an
   fr-select (fr-input for a text field turned into tags), picked values like small dismissible fr-tags. Plugins in use: clear_button, remove_button, virtual_scroll */
.ts-hidden-accessible {
    border: 0 !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    padding: 0 !important;
    position: absolute !important;
    white-space: nowrap !important;
    width: 1px !important;
}

/* The DSFR spaces the field from its label, but Tom Select hides the field and draws its box after it */
/* The DSFR's display: block would show a field hidden by a script, e.g. a rich-text textarea under its editor */
.fr-input[hidden] {
    display: none;
}

/* The DSFR has no read-only field: greyed like a disabled one, but still readable and copyable */
.fr-input[readonly] {
    background-color: var(--background-disabled-grey);
    box-shadow: inset 0 -2px 0 0 var(--border-disabled-grey);
    color: var(--text-mention-grey);
    cursor: default;
}

/* A row of fields keeps the gap DSFR puts after a field: its gutters cancel the last field's margin */
form .fr-grid-row--gutters:not(:last-child) {
    margin-bottom: .75rem;
}

.fr-label + .ts-hidden-accessible + .ts-wrapper {
    margin-top: .5rem;
}

.ts-wrapper.fr-select,
.ts-wrapper.fr-input {
    --ts-fr-arrow: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23161616' d='m12 13.1 5-4.9 1.4 1.4-6.4 6.3-6.4-6.4L7 8.1l5 5z'/%3E%3C/svg%3E");
    background: none;
    border: 0;
    box-shadow: none;
    height: auto;
    padding: 0;
    position: relative;
}

:root[data-fr-theme="dark"] .ts-wrapper.fr-select {
    --ts-fr-arrow: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='m12 13.1 5-4.9 1.4 1.4-6.4 6.3-6.4-6.4L7 8.1l5 5z'/%3E%3C/svg%3E");
}

.ts-wrapper.fr-select .ts-control,
.ts-wrapper.fr-input .ts-control {
    align-items: center;
    background: var(--background-contrast-grey) var(--ts-fr-arrow) no-repeat calc(100% - 1rem) 50% / 1rem 1rem;
    border-radius: .25rem .25rem 0 0;
    box-shadow: inset 0 -2px 0 0 var(--border-plain-grey);
    box-sizing: border-box;
    color: var(--text-default-grey);
    cursor: text;
    display: flex;
    flex-wrap: wrap;
    font-size: 1rem;
    line-height: 1.5rem;
    min-height: 2.5rem;
    overflow: hidden;
    padding: .375rem 2.5rem .375rem 1rem;
    position: relative;
    width: 100%;
}

.ts-wrapper.fr-select.single .ts-control,
.ts-wrapper.fr-select.single .ts-control input,
.ts-wrapper.fr-input.single .ts-control,
.ts-wrapper.fr-input.single .ts-control input {
    cursor: pointer;
}

.ts-wrapper.fr-select.focus .ts-control,
.ts-wrapper.fr-input.focus .ts-control {
    outline: 2px solid #0a76f6;
    outline-offset: 2px;
}

.ts-wrapper.fr-select.disabled .ts-control,
.ts-wrapper.fr-input.disabled .ts-control {
    background-color: var(--background-disabled-grey);
    color: var(--text-disabled-grey);
    cursor: not-allowed;
}

.fr-select-group--error .ts-wrapper.fr-select .ts-control,
.fr-input-group--error .ts-wrapper.fr-input .ts-control {
    box-shadow: inset 0 -2px 0 0 var(--border-plain-error);
}

.ts-wrapper.fr-select .ts-control > input,
.ts-wrapper.fr-input .ts-control > input {
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    color: inherit;
    flex: 1 1 auto;
    font: inherit;
    margin: 0 !important;
    min-width: 7rem;
    padding: 0 !important;
}

.ts-wrapper.fr-select .ts-control > input:focus,
.ts-wrapper.fr-input .ts-control > input:focus {
    outline: none;
}

.ts-wrapper.fr-select.has-items .ts-control > input,
.ts-wrapper.fr-input.has-items .ts-control > input {
    margin-left: .25rem !important;
}

.ts-wrapper.fr-select.input-hidden .ts-control > input,
.ts-wrapper.fr-input.input-hidden .ts-control > input {
    left: -10000px;
    opacity: 0;
    position: absolute;
}

.ts-wrapper.fr-select.multi .ts-control > .item,
.ts-wrapper.fr-input.multi .ts-control > .item {
    align-items: center;
    background-color: var(--background-action-high-blue-france);
    border-radius: 1rem;
    color: var(--text-inverted-blue-france);
    cursor: pointer;
    display: inline-flex;
    font-size: .875rem;
    line-height: 1.5rem;
    margin: .125rem .25rem .125rem 0;
    padding: 0 .25rem 0 .75rem;
}

.ts-wrapper.fr-select.multi .ts-control > .item .remove,
.ts-wrapper.fr-input.multi .ts-control > .item .remove {
    border-radius: 50%;
    color: inherit;
    margin-left: .25rem;
    padding: 0 .375rem;
    text-decoration: none;
}

/* The DSFR action hover colour, the × being the tag's only control */
.ts-wrapper.fr-select.multi .ts-control > .item .remove:hover,
.ts-wrapper.fr-input.multi .ts-control > .item .remove:hover {
    background-color: var(--background-action-high-blue-france-hover);
}

.ts-wrapper.fr-select.multi .ts-control > .item .remove:active,
.ts-wrapper.fr-input.multi .ts-control > .item .remove:active {
    background-color: var(--background-action-high-blue-france-active);
}

/* Shown as soon as a value is picked: hidden until hover, it went unnoticed (assets/dsfr/selectClear.js) */
.ts-wrapper.fr-select .clear-button,
.ts-wrapper.fr-input .clear-button {
    display: none;
    position: absolute;
    right: 2.5rem;
    top: 50%;
    transform: translateY(-50%);
}

.ts-wrapper.fr-select.has-items:not(.disabled) .clear-button,
.ts-wrapper.fr-input.has-items:not(.disabled) .clear-button {
    display: inline-flex;
}

.ts-wrapper.plugin-clear_button.has-items:not(.disabled) .ts-control {
    padding-right: 4.5rem;
}

.ts-wrapper.fr-select .ts-dropdown,
.ts-wrapper.fr-input .ts-dropdown {
    background-color: var(--background-default-grey);
    border: 1px solid var(--border-default-grey);
    box-shadow: var(--raised-shadow);
    box-sizing: border-box;
    color: var(--text-default-grey);
    left: 0;
    margin-top: .25rem;
    position: absolute;
    top: 100%;
    width: 100%;
    z-index: 1000;
}

.ts-wrapper.fr-select .ts-dropdown-content,
.ts-wrapper.fr-input .ts-dropdown-content {
    /* 8.5 options of 2.5rem: short lists (the 8 dossier statuses) show whole, longer ones show a cut one to scroll to */
    max-height: 21.25rem;
    overflow: hidden auto;
}

.ts-wrapper.fr-select .ts-dropdown .option,
.ts-wrapper.fr-select .ts-dropdown .no-results,
.ts-wrapper.fr-select .ts-dropdown .optgroup-header,
.ts-wrapper.fr-input .ts-dropdown .option,
.ts-wrapper.fr-input .ts-dropdown .no-results,
.ts-wrapper.fr-input .ts-dropdown .optgroup-header {
    padding: .5rem 1rem;
}

.ts-wrapper.fr-select .ts-dropdown .optgroup-header,
.ts-wrapper.fr-input .ts-dropdown .optgroup-header {
    color: var(--text-mention-grey);
    font-weight: 700;
}

.ts-wrapper.fr-select .ts-dropdown [data-selectable],
.ts-wrapper.fr-input .ts-dropdown [data-selectable] {
    cursor: pointer;
}

.ts-wrapper.fr-select .ts-dropdown [data-selectable] .highlight,
.ts-wrapper.fr-input .ts-dropdown [data-selectable] .highlight {
    background-color: var(--background-contrast-yellow-tournesol);
}

.ts-wrapper.fr-select .ts-dropdown .active,
.ts-wrapper.fr-input .ts-dropdown .active {
    background-color: var(--background-action-low-blue-france);
    color: var(--text-action-high-blue-france);
}

.ts-wrapper.fr-select .ts-dropdown .spinner,
.ts-wrapper.fr-input .ts-dropdown .spinner {
    animation: ts-spin 1s linear infinite;
    border: 2px solid var(--border-default-grey);
    border-radius: 50%;
    border-top-color: var(--border-plain-blue-france);
    display: block;
    height: 1.25rem;
    margin: .5rem 1rem;
    width: 1.25rem;
}

@keyframes ts-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Tool sheets (templates/tools/show.html.twig): legacy CMS images keep their width but never overflow */
.tool-sheet img {
    height: auto;
    max-width: 100%;
}

/* Accordion title with its badges below (templates/components/accordion.html.twig) */
.accordion-heading {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.accordion-heading__badges {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

/* Dossier page (templates/minute/show.html.twig): each frame a box holding its items, then its add button */
.minute-frame {
    border: 1px solid var(--border-default-grey);
    margin-bottom: 1.5rem;
    padding: 1.5rem;
}

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

.minute-frame .fr-accordions-group {
    margin-bottom: 1rem;
}

.minute-frame .fr-table {
    margin-bottom: 1rem;
}

/* Rich text in a cell (observations, decisions) at the cell's size, not the DSFR paragraph's */
.minute-frame .fr-table td p {
    font-size: inherit;
    line-height: inherit;
}

/* A text field turned into tags (the dossier form's parcels): no select arrow */
.ts-wrapper.fr-input .ts-control {
    background-image: none;
    padding-right: 1rem;
}

/* A parcel the cadastre doesn't know in the town (plot_map_controller.js) */
.ts-wrapper.fr-input.multi .ts-control > .item.parcel-not-found {
    background-color: var(--background-action-high-error);
}

/* Dossier form's plot map (templates/minute/_form.html.twig, plot_map_controller.js), ported from CoreBundle app.scss */
.plot-map-column {
    display: flex;
    flex-direction: column;
}

.ign-map-plot {
    flex-grow: 1;
    min-height: 450px;
}

/* A click places the pin or picks a parcel: a crosshair, kept while dragging */
.ign-map-plot.leaflet-grab,
.leaflet-dragging .ign-map-plot.leaflet-grab {
    cursor: crosshair;
}

/* A click is being looked up */
.ign-map-plot.map-busy,
.ign-map-plot.map-busy .leaflet-interactive {
    cursor: progress;
}

/* Shown above the point of a click being looked up, clear of the cursor */
.map-pending {
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgb(0 0 0 / 40%);
    color: #333;
    font-size: 24px;
    line-height: 40px;
    text-align: center;
}

/* Responsible persons of the dossier form (templates/minute/_humanFields.html.twig), numbered */
.human-list {
    counter-reset: human;
}

.human-item {
    border-bottom: 1px solid var(--border-default-grey);
    counter-increment: human;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.human-item__header {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.human-item__title::after {
    content: " " counter(human);
}

/* A record's files on a DSFR form (lucca_mediaBundle_dropzone_row) */
.media-field__list {
    list-style: none;
    margin-top: .75rem;
    padding-left: 0;
}

.media-field__list li {
    align-items: center;
    display: flex;
    gap: .5rem;
}

/* A letter's PDF preview (templates/minute/control/letterPage.html.twig) */
.letter-preview {
    border: 1px solid var(--border-default-grey);
    height: 80vh;
    width: 100%;
}

/* Public content pages: rich text written for Bootstrap, whose images and tables must fit the column */
.public-content img {
    height: auto;
    max-width: 100%;
}

.public-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}
