/*! Stretch · (c) 2026 Antichaos — antichaosdata.com. All rights reserved. Proprietary. */
/* The date-range picker: a panel (presets + fields + calendar). Colours
   and sizes come from the config through CSS variables set on <html> by stretch.js. */

:root {
    --accent: #4f7cf0; --caccent: #f2b84b; --text: #151b26; --bg: #ffffff;
    --fs: 13px; --radius: 10px;
    --soft: color-mix(in srgb, var(--text) 8%, transparent);
    --line: color-mix(in srgb, var(--text) 14%, transparent);
    --muted: color-mix(in srgb, var(--text) 55%, transparent);
}
html, body {
    margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden;
    background: var(--bg);
    font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: var(--fs); color: var(--text);
}
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ---- shell ---- */
.st { position: fixed; inset: 0; box-sizing: border-box; display: flex; }
.st.is-busy { pointer-events: none; opacity: .7; }
.st-title { font-weight: 800; font-size: calc(var(--fs) * 1.05); letter-spacing: -.01em; }

/* ---- panel: presets on the left, fields + calendar on the right ---- */
.st-panel { flex-direction: row; }
.st-side {
    flex: 0 0 auto; width: clamp(150px, 30%, 230px); min-width: 0;
    display: flex; flex-direction: column; gap: 6px; padding: 12px 8px 12px 12px; box-sizing: border-box;
    border-right: 1px solid var(--line); overflow: auto;
}
.st-side .st-title { padding: 2px 10px 6px; }
.st-list { display: flex; flex-direction: column; gap: 1px; }
.st-side > .st-list { flex: 1 1 auto; min-height: 0; overflow: auto; }   /* presets scroll; the compare block stays in view */
.st-preset {
    text-align: left; border: 0; background: transparent; cursor: pointer;
    padding: 7px 10px; border-radius: calc(var(--radius) * .7); line-height: 1.3;
    color: var(--text); transition: background .12s;
}
.st-preset:hover { background: var(--soft); }
.st-preset.is-active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-weight: 700; }
.st-cmp { flex: 0 0 auto; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; max-height: 55%; overflow: auto; }
.st-cmp-head { padding: 2px 10px 4px; }
.st-cmp-label { font-weight: 700; }
.st-cpreset.is-active { background: color-mix(in srgb, var(--caccent) 22%, transparent); color: color-mix(in srgb, var(--caccent) 60%, var(--text)); }

.st-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 0; box-sizing: border-box; overflow: auto; }
.st-panel:has(.st-cal-scroll) .st-main { overflow: hidden; }   /* the calendar scrolls, not the column */

/* fields */
.st-fields { display: flex; flex-direction: column; gap: 4px; }
.st-fields-label { font-weight: 700; font-size: calc(var(--fs) * .95); }
.st-fields-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.st-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.st-field > span { font-size: calc(var(--fs) * .8); color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.st-date {
    box-sizing: border-box; height: calc(var(--fs) * 2.6); padding: 0 10px;
    border: 1px solid var(--line); border-radius: calc(var(--radius) * .7); background: var(--bg);
    min-width: 128px;
}
.st-date:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.st-cfields .st-date:focus { border-color: var(--caccent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--caccent) 32%, transparent); }
.st-dash { color: var(--muted); padding-bottom: calc(var(--fs) * .7); }

/* which range the calendar edits (compare on) */
.st-target { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.st-target-label { font-size: calc(var(--fs) * .85); color: var(--muted); }
.st-chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: calc(var(--fs) * .88); }
.st-chip.is-active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); font-weight: 700; }
.target-compare .st-chip.is-active { border-color: var(--caccent); color: color-mix(in srgb, var(--caccent) 60%, var(--text)); background: color-mix(in srgb, var(--caccent) 20%, transparent); }

/* calendar */
.st-cal { display: flex; flex-direction: column; gap: 6px; }
.st-cal-nav { display: flex; align-items: center; gap: 6px; }
.st-cal-titles { flex: 1 1 auto; display: flex; }
.st-cal-title { flex: 1 1 0; text-align: center; font-weight: 700; }
.st-nav { width: 28px; height: 28px; border: 1px solid var(--line); background: transparent; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; display: grid; place-items: center; color: var(--muted); }
.st-nav:hover { background: var(--soft); color: var(--text); }
.st-months { display: flex; gap: 18px; }
.st-month { flex: 1 1 0; min-width: 0; }
.st-wk { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 2px; }
.st-wk span { text-align: center; font-size: calc(var(--fs) * .78); color: var(--muted); font-weight: 600; padding: 2px 0; }
.st-days { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.st-day {
    position: relative; height: calc(var(--fs) * 2.05); border: 0; background: transparent; cursor: pointer;
    font-variant-numeric: tabular-nums; color: var(--text); padding: 0; z-index: 1;
}
.st-day.is-pad { cursor: default; }
.st-day:disabled { color: color-mix(in srgb, var(--text) 30%, transparent); cursor: default; }
.st-day.is-today::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); transform: translateX(-50%); }
/* main range: a band behind the days, solid circles at the ends */
.st-day.in-range { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.st-day.is-start { border-radius: 999px 0 0 999px; }
.st-day.is-end { border-radius: 0 999px 999px 0; }
.st-day.is-start.is-end { border-radius: 999px; }
.st-day.is-start::before, .st-day.is-end::before {
    content: ""; position: absolute; inset: 1px 0; left: 50%; width: calc(var(--fs) * 2.05); transform: translateX(-50%);
    border-radius: 50%; background: var(--accent); z-index: -1;
}
.st-day.is-start, .st-day.is-end { color: #fff; font-weight: 700; }
/* comparison range: a second, amber band drawn underneath */
.st-day.in-cmp:not(.in-range) { background: color-mix(in srgb, var(--caccent) 32%, transparent); }
.st-day.in-cmp.in-range { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 14%, transparent) 0 55%, color-mix(in srgb, var(--caccent) 40%, transparent) 55% 100%); }
.st-day.is-cstart:not(.is-start):not(.is-end)::before, .st-day.is-cend:not(.is-start):not(.is-end)::before {
    content: ""; position: absolute; inset: 1px 0; left: 50%; width: calc(var(--fs) * 2.05); transform: translateX(-50%);
    border-radius: 50%; background: color-mix(in srgb, var(--caccent) 75%, transparent); z-index: -1;
}
.st-day.is-cstart:not(.in-range) { border-radius: 999px 0 0 999px; }
.st-day.is-cend:not(.in-range) { border-radius: 0 999px 999px 0; }
.st-day.is-cstart:not(.is-start):not(.is-end), .st-day.is-cend:not(.is-start):not(.is-end) { font-weight: 700; }
.st-day:not(:disabled):not(.is-pad):hover { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -2px; border-radius: 999px; }
.target-compare .st-day:not(:disabled):not(.is-pad):hover { outline-color: var(--caccent); }
.st-day.is-picking { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 999px; }

/* the scrolling calendar: sticky weekday header, months stacked, wheel to navigate */
.st-cal-scroll { flex: 1 1 auto; min-height: 120px; gap: 0; }
.st-cal-scroll > .st-wk { flex: 0 0 auto; border-bottom: 1px solid var(--line); margin: 0; padding-bottom: 2px; }
.st-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 2px; }
.st-scroll::-webkit-scrollbar { width: 6px; }
.st-scroll::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text) 18%, transparent); border-radius: 6px; }
.st-month-v { padding: 6px 0 8px; }
.st-month-v + .st-month-v { border-top: 1px solid color-mix(in srgb, var(--text) 6%, transparent); }
.st-month-label { display: flex; align-items: center; padding-left: 8px; font-size: calc(var(--fs) * .8); font-weight: 700; letter-spacing: .06em; color: var(--muted); white-space: nowrap; }
.st-month-label.is-row { grid-column: 1 / -1; height: calc(var(--fs) * 1.7); }

/* actions */
.st-actions { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 0 12px; border-top: 1px solid var(--line); margin-top: auto; background: var(--bg); }
/* The period is never cut off: it wraps (the comparison on its own line), and when even one
   range does not fit beside the buttons, the buttons drop to a row of their own. */
.st-summary { flex: 1 1 auto; min-width: min-content; font-size: calc(var(--fs) * .92); color: var(--muted); display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 2px; line-height: 1.3; }
.st-summary-main, .st-summary-cmp { white-space: nowrap; }
.st-actions-btns { flex: 0 0 auto; display: flex; gap: 8px; margin-left: auto; }
.st-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 16px; cursor: pointer; font-weight: 700; transition: filter .12s, transform .12s; }
.st-btn:disabled { opacity: .45; cursor: default; }
.st-apply { background: var(--accent); border-color: var(--accent); color: #fff; }
.st-apply:not(:disabled):hover { filter: brightness(1.06); transform: translateY(-1px); }
.st-cancel:not(:disabled):hover { background: var(--soft); }
.st-icon { padding: 5px 11px; }

/* compare switch */
.st-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.st-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.st-switch-track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: color-mix(in srgb, var(--text) 22%, transparent); transition: background .15s; flex: 0 0 auto; }
.st-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
.st-switch input:checked + .st-switch-track { background: var(--caccent); }
.st-switch input:checked + .st-switch-track::after { left: 16px; }
.st-switch input:focus-visible + .st-switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--caccent) 35%, transparent); }
.st-switch-text { font-weight: 700; }

/* ---- brand line: foot of the preset column, only without a valid key (body.st-branded) ---- */
.st-brand {
    display: none; flex: 0 0 auto; margin-top: auto; align-items: center; gap: 6px;
    padding: 8px 10px 0; font-size: 10.5px; line-height: 1.2; color: var(--muted); text-decoration: none;
}
.st-branded .st-brand { display: flex; }
.st-brand svg { width: 14px; height: 14px; flex: 0 0 auto; }
.st-brand b { font-weight: 700; }
.st-brand:hover { color: var(--text); }

/* ---- narrow zones ---- */
@media (max-width: 460px) {
    .st-panel { flex-direction: column; }
    .st-side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); max-height: 38%; }
    .st-list { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .st-preset { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; }
    .st-brand { padding-top: 4px; }
}

/* ---- setup / empty states (house style) ---- */
.state { position: fixed; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 18px; box-sizing: border-box; background: var(--ac-bg, #fbfcfe); }
.state.hidden { display: none !important; }
.setup-card {
    width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 9px; padding: 26px 24px 22px;
    background: var(--ac-surface, #fff); border: 1px solid var(--ac-line, #e7ecf3); border-radius: var(--ac-radius, 16px);
    box-shadow: var(--ac-shadow, 0 4px 14px rgba(20, 28, 42, .08), 0 14px 34px rgba(20, 28, 42, .08));
}
.setup-icon { width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border-radius: 18px; background: color-mix(in srgb, #4f7cf0 12%, transparent); color: #4f7cf0; }
.setup-card h2 { margin: 2px 0 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; color: var(--ac-ink, #151b26); }
.setup-card p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ac-ink-soft, #5d6878); }
.setup-btn { margin-top: 6px; padding: 10px 22px; border: 0; border-radius: 999px; cursor: pointer; background: #4f7cf0; color: #fff; font: 700 13px "Inter", sans-serif; box-shadow: 0 2px 10px color-mix(in srgb, #4f7cf0 30%, transparent); transition: filter .15s ease, transform .15s ease; }
.setup-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.compact .state { padding: 6px; }
.compact .setup-card { max-width: none; width: auto; gap: 0; padding: 0; border: 0; background: none; box-shadow: none; }
.compact .setup-icon, .compact .setup-card h2, .compact .setup-card p, .compact .setup-brand { display: none; }
.compact .setup-btn { margin-top: 0; padding: 8px 18px; }
.credit { position: fixed; bottom: 6px; right: 10px; z-index: 1; font-size: 10px; color: color-mix(in srgb, var(--text, #151b26) 45%, transparent); display: flex; align-items: center; gap: 6px; }
.credit img { height: 16px; opacity: .7; }
#stretch:not(.hidden) ~ .credit { display: none; }

/* ---- pop-up mode (1.3): the zone holds one button; the picker opens in a Tableau pop-up ---- */
.st-popbtn { align-items: stretch; padding: 4px; }
.st-pop {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 12px;
    border: 1px solid color-mix(in srgb, var(--text) 16%, transparent); border-radius: var(--radius);
    background: var(--bg); color: var(--text); font: inherit; font-size: var(--fs); text-align: left; cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
    overflow: hidden;   /* fitButton() drops lines until nothing is cut off at the bottom */
}
.st-pop:hover, .st-pop:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); outline: none; }
.st-pop > svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--accent); }
.st-pop-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.st-pop-text > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-pop-title { font-size: .78em; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; opacity: .55; }
.st-pop-main { font-weight: 700; }
.st-pop-sub { font-size: .85em; opacity: .7; }
.st-pop-cmp { color: color-mix(in srgb, var(--caccent) 70%, var(--text)); opacity: 1; }
.st-pop-caret { flex: 0 0 auto; opacity: .5; }
.is-busy .st-pop { opacity: .6; cursor: progress; }

/* Pro limit: the summary says why Apply is off. */
.st-summary.is-warn { color: #b45309; font-weight: 600; }
