/* The Customize pull-out, a port of 1IT.my's customize.css (TP532): the edge tab and the right-side drawer, which is a
   bottom sheet below 901 px. Palette variables only. */

/* Square corners: every shared radius goes to 0; the pill radius stays so round things stay round. */
:root[data-radius="square"] {
    --radius-sm: 0px;
    --radius: 0px;
    --radius-lg: 0px;
}

/* The tab: slim, fixed on the right edge, above the sticky header (z-index 60). --customize-y on <html> is its top as a
   fraction of the viewport's height (set before the first paint); appearance.js measures --cz-min (below the header)
   and --cz-h (its own height) so the clamp keeps it inside on every resize. */
.customize-tab {
    position: fixed;
    right: 0;
    top: clamp(
        var(--cz-min, 160px),
        calc(var(--customize-y, 0.22) * 100dvh),
        calc(100dvh - var(--cz-h, 136px) - 8px)
    );
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 6px 14px;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.4px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: background 0.15s, color 0.15s, padding 0.15s, border-color 0.15s;
}
.customize-tab .look-icon {
    width: 16px;
    height: 16px;
    color: var(--primary-strong);
}
.customize-grip {
    display: grid;
    margin-bottom: -4px;
}
.customize-grip .look-icon {
    width: 14px;
    height: 14px;
    color: var(--muted);
}
.customize-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
}
.customize-tab:hover,
.customize-tab[aria-expanded="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-fill);
    padding-right: 8px;
}
.customize-tab:hover .look-icon,
.customize-tab[aria-expanded="true"] .look-icon {
    color: var(--on-fill);
}
.customize-tab.is-dragging,
.customize-tab:active {
    cursor: grabbing;
}
.customize-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* The drawer: a modal dialog in the top layer, so the page underneath never moves. */
.look-dialog {
    position: fixed;
    inset: 0 0 0 auto;
    width: 380px;
    max-width: 100vw;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.look-dialog[open] {
    animation: look-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.look-dialog::backdrop {
    background: color-mix(in srgb, var(--deep) 50%, var(--clear));
    animation: look-fade 0.2s ease-out;
}
@keyframes look-in {
    from {
        transform: translateX(100%);
    }
    to {
        transform: none;
    }
}
@keyframes look-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: none;
    }
}
@keyframes look-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
@media (prefers-reduced-motion: reduce) {
    .look-dialog[open],
    .look-dialog::backdrop {
        animation: none;
    }
}

.look-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.look-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 18px 16px 20px;
    border-bottom: 1px solid var(--border);
}
.look-head h2 {
    margin: 0 0 4px;
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: -0.3px;
    color: var(--ink);
}
.look-head p {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
}
.look-close {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}
.look-close:hover {
    border-color: var(--ink);
}
.look-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 20px 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--clear);
}
.look-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.look-section:last-child {
    border-bottom: 0;
}
.look-section h3 {
    margin: 0 0 8px;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--muted);
}

/* Segmented controls: the selected option is filled with the primary colour, its label in ink. */
.look-seg {
    display: grid;
    grid-template-columns: repeat(var(--look-cols, 2), minmax(0, 1fr));
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--page);
}
.look-seg button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 36px;
    padding: 5px 6px;
    border: 0;
    border-radius: calc(var(--radius-sm) * 0.75);
    background: var(--clear);
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    transition: background 0.12s, color 0.12s;
}
.look-seg button .look-icon {
    width: 15px;
    height: 15px;
}
.look-seg button:hover {
    background: var(--surface);
    color: var(--ink);
}
.look-seg button[aria-pressed="true"] {
    background: var(--primary);
    color: var(--on-fill);
    box-shadow: var(--shadow-sm);
}

/* Accent swatches: a round chip in each accent's colour; the chosen one is filled with it. */
.look-swatches {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}
.look-swatch {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 38px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: 12px;
    font-weight: 650;
    text-align: left;
}
.look-swatch span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.look-swatch i {
    flex: none;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-pill);
    background: var(--swatch);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 15%, var(--clear));
}
.look-swatch:hover {
    border-color: var(--primary);
}
.look-swatch[aria-pressed="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-fill);
}
.look-swatch[aria-pressed="true"] i {
    background: var(--on-fill);
    box-shadow: inset 0 0 0 4px var(--primary), 0 0 0 2px var(--on-fill);
}
.look-seg button:focus-visible,
.look-swatch:focus-visible,
.look-reset:focus-visible,
.look-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.look-hint {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
}

.look-foot {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.look-reset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--page);
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}
.look-reset .look-icon {
    width: 15px;
    height: 15px;
}
.look-reset:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.look-grab {
    display: none;
}

/* Below 901 px: no edge tab (the phone menu's "Customize the look" opens it) and the drawer is a bottom sheet. */
@media (max-width: 900px) {
    .customize-tab {
        display: none;
    }
    .look-dialog {
        inset: auto 0 0 0;
        width: 100vw;
        height: auto;
        max-height: 88dvh;
        border-left: 0;
        border-top: 1px solid var(--border);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
    .look-dialog[open] {
        animation-name: look-up;
    }
    .look-panel {
        max-height: 88dvh;
    }
    .look-grab {
        display: grid;
        place-items: center;
        flex: none;
        height: 20px;
        touch-action: none;
        cursor: grab;
    }
    .look-grab::before {
        content: "";
        width: 40px;
        height: 4px;
        border-radius: var(--radius-pill);
        background: var(--border);
    }
    .look-head {
        padding: 2px 16px 12px;
    }
    .look-body {
        padding: 2px 16px 10px;
    }
    .look-foot {
        padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
    }
}
