/* Investment Path – editors
   Tooltips, one-off events, the saving-plan timeline, holdings rows.
   ========================================================================== */

/* ---------- Tooltips ---------- */

.tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    min-width: 15px;
    border-radius: 50%;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 9.5px;
    font-weight: 700;
    cursor: help;
    position: relative;
    user-select: none;
    text-transform: none;
    letter-spacing: 0;
}
.tip:hover, .tip:focus { color: var(--text); border-color: var(--border-strong); outline: none; }
.tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tip::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    /* --tip-shift (set on hover by main.js) nudges the bubble so it stays
       inside its pane; the arrow (::before) stays centered on the tip. */
    transform: translateX(calc(-50% + var(--tip-shift, 0px))) translateY(-4px);
    width: max-content;
    max-width: 230px;
    padding: 8px 11px;
    border-radius: 9px;
    background: var(--tooltip-bg);
    color: #dfe3f0;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 50;
}
.tip::before {
    content: "";
    position: absolute;
    top: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 9px;
    height: 9px;
    background: var(--tooltip-bg);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    z-index: 51;
}
.tip:hover::after, .tip:focus::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(calc(-50% + var(--tip-shift, 0px))) translateY(0);
}
.tip:hover::before, .tip:focus::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) rotate(45deg);
}

/* ---------- One-off events ---------- */

.event-row {
    display: grid;
    grid-template-columns: 118px 74px 1fr 22px;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}
.event-row input, .event-row select { padding: 8px 10px; font-size: 12.5px; }
.event-row .input-unit { right: 9px; font-size: 10px; }
.event-row select { padding-right: 24px; background-position: right 8px center; }

/* ---------- Saving-plan phase timeline ---------- */

/* The track: a horizontal bar for the whole saving timeline. Colored
   segments are the phases; draggable dots are the boundaries. */
.tl-track {
    position: relative;
    height: 26px;
    margin: 4px 0 0;
}
.tl-segs {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-solid);
}
.tl-seg {
    position: absolute;
    top: 0;
    bottom: 0;
    transition: background 0.2s;
}
.tl-dot {
    position: absolute;
    top: 50%;
    /* --tl-nudge fans out dots parked past the horizon (all at left:100%) */
    transform: translate(calc(-50% + var(--tl-nudge, 0px)), -50%);
    width: 18px;
    height: 18px;
    padding: 0;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--dot-color, var(--accent));
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    cursor: grab;
    touch-action: none;   /* pointer-drag must not scroll the page */
    transition: box-shadow 0.15s;
}
.tl-dot:active { cursor: grabbing; }
.tl-dot:hover {
    box-shadow: 0 0 0 4px var(--accent-soft), 0 1px 6px rgba(0, 0, 0, 0.35);
}
/* A real ring, not a tinted halo – the dots are arrow-key operable, so a
   keyboard user must be able to see which boundary is selected. */
.tl-dot:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
.tl-dot.tl-dot-out { border-color: var(--red); }

.tl-axis {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-faint);
    margin: 4px 2px 2px;
}

/* One card per phase: swatch · from-when · mode · value · remove */
.tl-card {
    display: grid;
    /* the mode select must fit "Amount" plus its chevron – 84px measured */
    grid-template-columns: 10px 56px 84px 1fr 22px;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}
.tl-card-base { grid-template-columns: 10px 56px 1fr 106px 22px; }
.tl-card input, .tl-card select { padding: 7px 9px; font-size: 12.5px; }
.tl-card .input-unit { right: 6px; font-size: 10px; }
.tl-card select { padding-right: 22px; background-position: right 7px center; }
.tl-card .tl-value, .tl-card .tl-raise { padding-right: 34px; }
.tl-card.tl-out { opacity: 0.55; }
.tl-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}
.tl-when {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tl-base-amount {
    font-size: 11.5px;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tl-add { margin-top: 10px; }

.event-x {
    border: none;
    background: none;
    color: var(--text-faint);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
    transition: color 0.2s;
}
.event-x:hover { color: var(--red); }

.btn-add-event {
    width: 100%;
    justify-content: center;
    padding: 8px;
    font-size: 12px;
}

/* ---------- Portfolio holdings ---------- */

.import-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    margin-bottom: 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, background 0.2s;
}
.import-block.drop-active {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.08);
}
.btn-import {
    width: 100%;
    justify-content: center;
    padding: 8px;
    font-size: 12px;
}
.import-help {
    margin: -2px 0 0;
    text-align: center;
    color: var(--text-faint);
    font-size: 10.5px;
}
.import-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    color: var(--text-dim);
    padding: 0 2px;
}
.import-status .event-x { flex: none; }

/* Each position is its own little card, so it's obvious which inputs
   belong together. */
.holding-row {
    padding: 10px;
    margin-bottom: 10px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.holding-row:last-child { margin-bottom: 0; }

.holding-line {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}
.h-asset-wrap { flex: 1; }
.h-ticker-wrap { margin-bottom: 6px; }

.h-worth {
    text-align: right;
    font-size: 11.5px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    margin: -2px 2px 6px;
}

.holding-grid {
    display: grid;
    grid-template-columns: 1.1fr 1fr;   /* 2×2: position+return / saving+raise */
    gap: 6px;
    margin-bottom: 0;
}
.h-basis-wrap { grid-column: 1 / -1; }

.assumption-note {
    margin: 10px 2px 0;
    color: var(--text-faint);
    font-size: 11px;
    line-height: 1.5;
}

.reroll-btn { margin-top: 8px; width: 100%; justify-content: center; }

.site-footer {
    margin-top: 22px;
    padding: 14px 4px 0;
    border-top: 1px solid var(--border);
}

.disclaimer {
    color: var(--text-faint);
    font-size: 11px;
    line-height: 1.55;
}

.legal-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 9px;
}

.legal-links a {
    color: var(--text-dim);
    font-size: 11.5px;
    font-weight: 700;
    text-underline-offset: 3px;
}

.legal-links a:hover,
.legal-links a:focus-visible { color: var(--text); }

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.subhead {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    margin: 14px 0 8px;
}

/* Income streams picker (left panel) */
.stream-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
}
.stream-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
}
.stream-item:hover { background: var(--surface-hover); }
.stream-item input { accent-color: var(--accent); flex: none; }
.stream-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stream-total {
    color: var(--text-faint);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.stream-hint { font-size: 12px; color: var(--text-faint); margin: 4px 2px 0; }

/* Income streams by year (dashboard card) */
.streams-card { margin-bottom: 18px; }
.streams-table-wrap { overflow-x: auto; }
.streams-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.streams-table th, .streams-table td {
    padding: 8px 12px;
    text-align: right;
    white-space: nowrap;
}
.streams-table thead th {
    color: var(--text-faint);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.streams-table tbody th {
    text-align: left;
    font-weight: 600;
    color: var(--text-dim);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.streams-table tbody tr + tr { border-top: 1px dashed var(--border); }
.streams-table .st-total { border-top: 1px solid var(--border-strong); }
.st-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.st-val.dim { color: var(--text-faint); font-weight: 400; }
.st-delta { font-size: 10.5px; color: var(--text-faint); }
.st-delta.up { color: var(--green); }
.st-delta.down { color: var(--red); }
.st-ytd { color: var(--text-faint); text-transform: none; letter-spacing: 0; }
.st-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: baseline;
}
.streams-chart-wrap { margin-bottom: 10px; }

.pfe-row {
    padding: 8px;
    margin-bottom: 8px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.pfe-row:last-child { margin-bottom: 0; }
.pfe-row input, .pfe-row select { padding: 8px 10px; font-size: 12.5px; }
.pfe-row .input-unit { right: 9px; font-size: 10px; }
.pfe-row select { padding-right: 24px; background-position: right 8px center; }
.pfe-grid {
    display: grid;
    grid-template-columns: 92px 78px 1fr;
    gap: 6px;
    margin-bottom: 0;
}
.holding-row input, .holding-row select { padding: 8px 10px; font-size: 12.5px; }
.holding-row .input-unit { right: 9px; font-size: 10px; }
.holding-row select.h-asset { padding-right: 24px; background-position: right 8px center; }

.h-unit,
.h-return-mode {
    position: absolute;
    right: 4px;
    width: auto !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-faint);
    font-size: 10.5px !important;
    font-weight: 600;
    padding: 2px 14px 2px 4px !important;
    cursor: pointer;
    background-position: right 2px center !important;
}
.h-return-mode:disabled { cursor: default; opacity: 0.6; }

/* "auto" return fields just display the historical average */
.holding-row input:disabled {
    color: var(--text-faint);
    -webkit-text-fill-color: var(--text-faint);
    border-style: dashed;
    cursor: default;
}

.badge-warn {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--amber-soft);
    border: 1px solid rgba(251, 191, 36, 0.4);
    color: var(--amber);
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.holdings-table td:first-child { white-space: normal; }

.save-status { transition: color 0.3s; }
.save-status.saving { color: var(--amber); }
.save-status.error { color: var(--red); }
