/* Investment Path – controls
   Segmented switches, panels, progressive disclosure, fields, sliders.
   ========================================================================== */

/* ---------- Segmented controls ---------- */

/* The track is real glass: translucent, blurred, with a light top rim. The
   blur is what sells it, so the fill has to stay see-through. */
/* Untinted glass: the same material as the primary with the brand layer
   removed, so the track recedes and the selected pane floats on it. */
/* Untinted glass: same material with the brand layer dropped, so the track
   recedes and the selected pane floats on it. */
.segmented {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: color-mix(in srgb, var(--surface-alt) 45%, transparent);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
    backdrop-filter: blur(6.4px) saturate(140%);
    -webkit-backdrop-filter: blur(6.4px) saturate(140%);
}

.segmented button {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s, color 0.25s, box-shadow 0.25s;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.segmented button:hover { color: var(--text); }

/* The selected segment is the same lit pill as the primary button: the brand
   gradient, a specular gloss fading off by the midpoint, a bright top rim and
   a coloured glow beneath. Switch and button now share one recipe, which is
   the point – they used to be a vivid gradient and a faint tint. */
.segmented button.active {
    border-color: color-mix(in srgb, var(--accent-2) 52%, transparent);
    color: var(--on-glass);
    background:
        linear-gradient(120deg,
            color-mix(in srgb, var(--accent) 34%, transparent),
            color-mix(in srgb, var(--accent-2) 30%, transparent));
    backdrop-filter: blur(6.4px) saturate(150%);
    -webkit-backdrop-filter: blur(6.4px) saturate(150%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        0 4px 30px rgba(0, 0, 0, 0.10);
}

.segmented button.active .seg-sub {
    color: var(--on-glass);
    opacity: 0.72;
}

/* Cursor-following glow: --mx/--my are set by JS on mousemove */
.segmented button::after,
.action-primary::after,
.btn-primary::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    background: radial-gradient(80px circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.28), transparent 65%);
}
.segmented button:not(.active)::after {
    background: radial-gradient(70px circle at var(--mx, 50%) var(--my, 50%),
        var(--accent-soft), transparent 70%);
}
.action-primary::after,
.btn-primary::after {
    background: radial-gradient(130px circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.32), transparent 65%);
}
.segmented button:focus-visible::after,
.action-primary:focus-visible::after,
.btn-primary:focus-visible::after { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
    .segmented button:hover::after,
    .action-primary:hover::after,
    .btn-primary:hover::after { opacity: 1; }
}
.segmented button > * { position: relative; }

.seg-mode { margin-bottom: 10px; }
.seg-mode button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 10px 8px;
}
.seg-mode .seg-title { font-size: 14px; font-weight: 700; }
.seg-mode .seg-sub { font-size: 10.5px; font-weight: 500; opacity: 0.75; }

.seg-sm button { padding: 6px 8px; font-size: 11.5px; }

.mode-hint {
    font-size: 12px;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 16px;
    min-height: 18px;
    transition: opacity 0.3s;
}

.seg-explain {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 8px;
    line-height: 1.5;
}
.seg-explain b { color: var(--text-dim); }

/* A field directly after a segmented control (e.g. "Work out" under the
   goal-type switch) needs air between the buttons and its label. */
.segmented + .field { margin-top: 14px; }

/* ---------- Panels ---------- */

.panel {
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.028), transparent 46%),
        color-mix(in srgb, var(--surface-solid) 48%, transparent);
    border: 1px solid var(--border);
    border-radius: 18px;
    margin-bottom: 13px;
    transition: border-color 0.25s, background 0.25s;
}
.panel:hover {
    border-color: var(--border-strong);
}

.panel-body { padding: 17px; min-height: 0; transition: padding 0.35s ease; }
.panel.reveal:not(.open) > .panel-body { padding-top: 0; padding-bottom: 0; }

.panel-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.panel-head h2 {
    font-size: 14px;
    font-weight: 740;
    letter-spacing: -0.012em;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
}

.panel-head-switch { justify-content: space-between; margin-bottom: 4px; }

.panel-sub { font-size: 11.5px; color: var(--text-faint); }

.panel-head-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    justify-content: space-between;
    font-family: inherit;
    margin-bottom: 0;
    text-align: left;
}
.panel-collapsible .panel-head-btn h2 { transition: color 0.2s; }
.panel-collapsible .panel-head-btn:hover h2 { color: var(--text); }

/* The current value of a folded panel, shown in its header.
   Without this an accordion is strictly worse than the list it replaced: it
   hides state and charges a click to see it again. With it, the closed
   sidebar reads as a summary of the whole plan. Hidden while open, because
   the panel is then showing the real controls a few pixels below. */
.panel-summary {
    margin-left: auto;
    color: var(--text-faint);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
}
.panel-head-btn[aria-expanded="true"] .panel-summary {
    opacity: 0;
    pointer-events: none;
}
.panel-collapsible .panel-head-btn:hover .panel-summary { color: var(--text-dim); }

/* The title must not shove the summary off the row, and the summary must
   give way first when the sidebar is narrow. */
.panel-head-btn h2 { flex: 0 1 auto; min-width: 0; }

.chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-dim);
    border-bottom: 2px solid var(--text-dim);
    transform: rotate(45deg);
    transition: transform 0.3s;
    margin-right: 3px;
    flex: none;
}
.panel-head-btn[aria-expanded="true"] .chevron { transform: rotate(225deg); }

/* Folded panels keep their header flush against the panel edge; opening one
   restores the gap the header would otherwise have carried. */
[data-accordion-body].open { margin-top: 12px; }

/* Every accordion body holds exactly one `.reveal-body`, which is not a
   stylistic choice: `.reveal` collapses with `grid-template-rows: 0fr`, and
   that sizes only the *first* row. A body with five children keeps four of
   them at their natural height and folds to 114px instead of 0. `.reveal-body`
   exists to guarantee the single child, and it is also what re-enables
   `overflow: visible` once open so tooltips are not clipped. */

/* The switch in the retirement header sits beside the fold button rather than
   inside it: a control nested in a button is invalid, and clicking the switch
   would toggle the fold. */
.panel-head-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.panel-head-row .panel-head-btn { margin-bottom: 0; }
.panel-head-row .switch { flex: none; }

/* ---------- Reveal (progressive disclosure) ---------- */

.reveal {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    transition: grid-template-rows 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                visibility 0.3s,
                margin 0.35s ease;
}
.reveal.open {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
}
.reveal > * { overflow: hidden; min-height: 0; }
.reveal.open > .reveal-body, .reveal.open > .panel-body { overflow: visible; }

.panel.reveal { border-width: 0; margin-bottom: 0; }
.panel.reveal.open { border-width: 1px; margin-bottom: 12px; }

.cond-hidden { display: none !important; }

/* ---------- Fields ---------- */

.field { margin-bottom: 12px; }

/* Rarely used inputs: one compact line instead of a full field block */
.field-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
    grid-column: 1 / -1;
}
.field-inline label { margin-bottom: 0; flex: 1; }
.field-inline .input-wrap { width: 92px; flex: none; }
.field-inline input { padding: 5px 9px; font-size: 12.5px; }
.field-inline .input-unit { right: 8px; font-size: 10px; }
.field:last-child { margin-bottom: 0; }

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10px;
}
/* Closed conditional fields must not occupy grid tracks */
.field-grid > .field.reveal:not(.open) { display: none; }
.field-grid > .field-full { grid-column: 1 / -1; }

.field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 5px;
}

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

/* The unit label is absolutely positioned over the right end of the field and
   painted on an opaque background, so without room reserved for it a long
   number slides underneath and is silently masked. `--unit-pad` is set from
   the label's measured width whenever the currency changes: "€/mo" is 24px,
   "CHF/mo" is 49px, and the field has to give up the difference. */
.input-wrap input,
.input-wrap select {
    width: 100%;
    min-height: 40px;
    padding: 9px var(--unit-pad, 12px) 9px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: color-mix(in srgb, var(--surface-solid) 84%, transparent);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-wrap input:focus,
.input-wrap select:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
}
.input-wrap input::placeholder { color: var(--text-faint); }

.input-unit {
    position: absolute;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-faint);
    pointer-events: none;
    background: var(--surface-solid);
    padding-left: 6px;
}

input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

.input-wrap select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%239299b0' d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}
.input-wrap select option, .input-wrap select optgroup {
    background: var(--surface-solid);
    color: var(--text);
}

.tax-row {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 8px;
}

/* A checkbox that sits in a field row rather than on a panel header, where
   the pill-shaped .switch would read as a mode rather than an option. */
.check {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
}
.check input {
    flex: none;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ---------- Sliders ---------- */

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.slider-row .input-sm { width: 96px; min-width: 96px; }

input[type="range"] {
    flex: 1;
    height: 34px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right,
        #6366f1 var(--fill, 33%),
        var(--border-strong) var(--fill, 33%));
}
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -6px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    cursor: pointer;
}
input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right,
        #6366f1 var(--fill, 33%),
        var(--border-strong) var(--fill, 33%));
}

/* ---------- Switch ---------- */

.switch { display: inline-flex; cursor: pointer; }
.switch input { display: none; }

.switch-track {
    width: 42px;
    height: 24px;
    border-radius: 12px;
    background: var(--border-strong);
    position: relative;
    transition: background 0.3s;
}
.switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); }
