/* Themed controls that replace the browser's own: pickers that unroll a
   parchment list (a bottom sheet on phones), diamond seals for ticking cards,
   the search field and the confirmation scroll. */

/* Picker trigger -------------------------------------------------------------- */

.picker {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    max-width: 100%;
    padding: 4px 12px 4px 14px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: linear-gradient(to bottom, var(--paper), oklch(0.96 0.02 82));
    box-shadow: inset 0 0 0 2px oklch(0.99 0.006 85 / 0.8), 0 1px 2px oklch(0.2 0.02 40 / 0.18);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 140ms ease, box-shadow 140ms ease, transform 120ms ease;
}

.picker:hover {
    border-color: var(--gilt);
}

.picker:active {
    transform: translateY(1px);
}

.picker:focus-visible {
    outline: 2px solid var(--gilt);
    outline-offset: 2px;
}

.picker[aria-expanded="true"] {
    border-color: var(--gilt);
    box-shadow: inset 0 0 0 2px oklch(0.99 0.006 85 / 0.8), 0 0 0 3px oklch(0.7 0.085 78 / 0.28);
}

.picker-label {
    font-family: "IM Fell English SC", serif;
    font-size: 14px;
    letter-spacing: 0.05em;
    color: var(--ink-muted);
    white-space: nowrap;
}

.picker-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
    font-weight: 600;
}

.picker-chevron {
    flex: none;
    width: 7px;
    height: 7px;
    margin: -4px 2px 0 0;
    border-right: 1.5px solid var(--ink-muted);
    border-bottom: 1.5px solid var(--ink-muted);
    transform: rotate(45deg);
    transition: transform 160ms ease;
}

.picker[aria-expanded="true"] .picker-chevron {
    transform: translateY(3px) rotate(225deg);
}

.picker--field .picker-value {
    max-width: 220px;
}

/* A chip shows only its label until it filters something, then its value. */
.picker--chip:not(.is-set) .picker-value {
    display: none;
}

.picker--chip.is-set {
    border-color: oklch(0.52 0.12 32 / 0.6);
    background: linear-gradient(to bottom, oklch(0.97 0.02 40), oklch(0.93 0.035 45));
}

.picker--chip.is-set .picker-label {
    display: none;
}

.picker--chip.is-set .picker-value {
    font-size: 16px;
    color: var(--red);
}

.picker--chip.is-set::before {
    content: "";
    flex: none;
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    background: var(--red);
    box-shadow: 0 0 0 1.5px var(--paper), 0 0 0 2.5px var(--red);
}

/* The unrolled list ------------------------------------------------------------ */

.picker-panel,
.confirm-dialog {
    box-sizing: border-box;
    padding: 0;
    border: 1px solid var(--gilt);
    border-radius: 10px;
    background: linear-gradient(to bottom, var(--vellum), var(--vellum-deep));
    box-shadow: 0 18px 40px oklch(0.1 0.02 40 / 0.55), inset 0 0 0 3px oklch(0.99 0.006 85 / 0.55);
    color: var(--ink);
    font-family: "Cormorant Garamond", serif;
    font-weight: 500;
    overflow: hidden;
}

.picker-panel {
    position: fixed;
    inset: auto;
    margin: 0;
    width: max-content;
    max-width: min(420px, calc(100vw - 20px));
    animation: panel-unroll 160ms ease-out;
}

.picker-panel::backdrop,
.confirm-dialog::backdrop {
    background: oklch(0.12 0.02 40 / 0.35);
}

.picker-scroll {
    display: flex;
    flex-direction: column;
    max-height: inherit;
    box-sizing: border-box;
}

.picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 10px 6px 16px;
    border-bottom: 1px solid var(--rule);
}

.picker-title {
    margin: 0;
    display: flex;
    align-items: baseline;
    font-family: "IM Fell English SC", serif;
    font-size: 17px;
    font-weight: 400;
    letter-spacing: 0.04em;
    line-height: 1;
}

.picker-title-initial {
    font-family: "UnifrakturMaguntia", serif;
    font-size: 27px;
    color: var(--red);
}

.picker-close {
    flex: none;
    width: 32px;
    height: 32px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-muted);
    font: 600 24px/1 "Cormorant Garamond", serif;
    cursor: pointer;
}

.picker-close:hover,
.picker-close:focus-visible {
    border-color: var(--rule);
    background: var(--paper);
    outline: none;
}

.picker-filter {
    box-sizing: border-box;
    margin: 10px 12px 2px;
    padding: 7px 12px;
    border: 0;
    border-bottom: 1px solid var(--rule);
    background: oklch(0.99 0.006 85 / 0.6);
    color: var(--ink);
    font: italic 600 17px "Cormorant Garamond", serif;
    outline: none;
}

.picker-filter:focus {
    border-bottom-color: var(--gilt);
    background: var(--paper);
}

.picker-options {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 6px 0 8px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--gilt) transparent;
}

.picker-option {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 40px;
    padding: 4px 18px 4px 16px;
    font-size: 18px;
    cursor: pointer;
    outline: none;
}

.picker-option:hover,
.picker-option:focus-visible {
    background: oklch(0.99 0.006 85 / 0.75);
}

.picker-option:focus-visible {
    box-shadow: inset 3px 0 0 var(--gilt);
}

.picker-option[aria-selected="true"] {
    color: var(--red);
    font-weight: 700;
}

.picker-option-mark {
    flex: none;
    width: 9px;
    height: 9px;
    transform: rotate(45deg);
    border: 1px solid var(--ink-muted);
    box-shadow: inset 0 0 0 1.5px var(--paper);
    background: var(--paper);
}

.picker-option[aria-selected="true"] .picker-option-mark {
    border-color: var(--red);
    background: var(--red);
}

/* Phones: the list rises from the bottom edge like a sheet of vellum. */
.picker-panel.is-sheet {
    inset: auto 0 0 0;
    width: 100%;
    max-width: none;
    max-height: 78vh;
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-rise 200ms ease-out;
}

.picker-panel.is-sheet .picker-head::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 6px;
    width: 42px;
    height: 4px;
    margin-left: -21px;
    border-radius: 2px;
    background: var(--rule);
}

.picker-panel.is-sheet .picker-head {
    position: relative;
    padding-top: 18px;
}

.picker-panel.is-sheet .picker-option {
    min-height: 48px;
    font-size: 19px;
}

@keyframes panel-unroll {
    from { opacity: 0; transform: translateY(-6px) scaleY(0.96); transform-origin: top; }
}

@keyframes sheet-rise {
    from { transform: translateY(100%); }
}

/* Confirmation ----------------------------------------------------------------- */

.confirm-dialog {
    width: min(440px, calc(100vw - 32px));
    animation: panel-unroll 160ms ease-out;
}

.confirm-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 22px 18px;
}

.confirm-message {
    margin: 0;
    font-size: 19px;
    line-height: 1.35;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

/* Diamond seal for ticking a card ---------------------------------------------- */

.seal-toggle {
    flex: none;
    position: relative;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.seal-toggle::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 12px;
    height: 12px;
    margin: -7px 0 0 -7px;
    transform: rotate(45deg);
    border: 1px solid var(--ink-muted);
    background: var(--paper);
    box-shadow: inset 0 0 0 2px var(--paper);
    transition: background-color 140ms ease, border-color 140ms ease, transform 160ms ease;
}

.seal-toggle:hover::before {
    border-color: var(--red);
}

.seal-toggle[aria-checked="true"]::before {
    border-color: var(--red);
    background: var(--red);
    transform: rotate(45deg) scale(1.15);
}

.seal-toggle:focus-visible {
    outline: 2px solid var(--gilt);
    outline-offset: -4px;
    border-radius: 50%;
}

/* Search ------------------------------------------------------------------------ */

.search {
    position: relative;
    display: flex;
    align-items: center;
}

.search-glass {
    position: absolute;
    left: 13px;
    width: 11px;
    height: 11px;
    margin-top: -4px;
    border: 1.5px solid var(--ink-muted);
    border-radius: 50%;
    pointer-events: none;
}

.search-glass::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: -5px;
    width: 7px;
    height: 1.5px;
    background: var(--ink-muted);
    transform: rotate(45deg);
}

.search-input {
    box-sizing: border-box;
    width: 100%;
    min-height: 42px;
    padding: 6px 40px 6px 38px;
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--paper);
    box-shadow: inset 0 1px 3px oklch(0.4 0.04 55 / 0.15);
    color: var(--ink);
    font: italic 600 18px "Cormorant Garamond", serif;
    outline: none;
}

.search-input::placeholder {
    color: var(--ink-muted);
    opacity: 0.8;
}

.search-input:focus {
    border-color: var(--gilt);
    box-shadow: inset 0 1px 3px oklch(0.4 0.04 55 / 0.15), 0 0 0 3px oklch(0.7 0.085 78 / 0.25);
}

.search-clear {
    position: absolute;
    right: 6px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-muted);
    font: 600 22px/1 "Cormorant Garamond", serif;
    cursor: pointer;
}

.search-clear:hover,
.search-clear:focus-visible {
    background: var(--field);
    outline: none;
}

.search-clear[hidden] {
    display: none;
}

/* Scrollbars in the gilt of the frames. */
.catalog-list {
    scrollbar-width: thin;
    scrollbar-color: var(--gilt) transparent;
}

@media (pointer: coarse) {
    .button,
    .picker {
        min-height: 44px;
    }

    .seal-toggle {
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .picker-panel,
    .confirm-dialog {
        animation: none;
    }
}
