/* Theme 2.0 components. Source: 04-components.md. Needs tokens.css + base.css. */

/* ── Glass panel ─────────────────────────────────────────────── */
.t2-panel {
  background: color-mix(in srgb, var(--panel) 50%, transparent);
  border: 1px solid var(--pbd);
  border-radius: var(--rad-panel);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  padding: var(--pad);
  min-width: 0;
}
@supports not (backdrop-filter: blur(1px)) { .t2-panel { background: color-mix(in srgb, var(--panelsolid) 85%, transparent); } }
.t2-panel--tile { min-height: 380px; display: flex; flex-direction: column; }
.t2-panel--float { background: color-mix(in srgb, var(--panel) 70%, transparent); }
.t2-panel--solid { background: var(--panelsolid); }
.t2-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.t2-panel-head .t2-sub { margin-top: 2px; }

/* the single top-right affordance on a panel */
.t2-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: var(--rad-btn);
  border: 1px solid var(--grid); background: var(--ghost); color: var(--t2); cursor: pointer;
  transition: background var(--dur), color var(--dur);
}
.t2-iconbtn:hover { background: var(--seg); color: var(--tx); }
.t2-iconbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.t2-iconbtn--l { width: 42px; height: 42px; border-radius: 12px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.t2-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--rad-btn); cursor: pointer;
  border: 1px solid var(--grid); background: var(--ghost); color: var(--t2);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background var(--dur), opacity var(--dur), color var(--dur);
}
.t2-btn:hover { background: var(--seg); color: var(--tx); }
.t2-btn--ink   { height: 44px; padding: 0 20px; border-radius: var(--rad-btn-l); background: var(--ink); color: var(--inktx); border-color: var(--ink); font-size: 14px; }
.t2-btn--ink:hover { background: var(--ink); color: var(--inktx); opacity: 0.85; }
.t2-btn--glass { height: 44px; padding: 0 20px; border-radius: var(--rad-btn-l); background: var(--glass); color: #fff; border-color: var(--glassbd); font-size: 14px; }
.t2-btn--glass:hover { background: var(--glass); color: #fff; opacity: 0.85; }
.t2-btn[disabled], .t2-btn[aria-disabled="true"] { background: var(--ghost); color: var(--td); border-color: var(--grid); background-image: none; cursor: not-allowed; opacity: 1; }
.t2-link { background: none; border: 0; padding: 0; font-size: 13px; color: var(--t2); cursor: pointer; }
.t2-link:hover { text-decoration: underline; color: var(--tx); }
/* every AI action uses the same purple button with the Claude Code mark (spec: feedback_no_card_accent_edges) */
.t2-btn--ai { background: linear-gradient(135deg, #6d28d9, #7c3aed 55%, #a21caf); color: #fff; border-color: transparent; }
.t2-btn--ai:hover { background: linear-gradient(135deg, #6d28d9, #7c3aed 55%, #a21caf); color: #fff; opacity: 0.88; }

/* ── Segmented control ───────────────────────────────────────── */
.t2-seg { display: inline-flex; padding: 3px; border-radius: var(--rad-seg); background: var(--seg); border: 1px solid var(--pbd); }
.t2-seg button { padding: 6px 14px; border: 0; border-radius: var(--rad-seg-i); background: transparent; color: var(--td); font-size: 12px; font-weight: 500; cursor: pointer; transition: background var(--dur), color var(--dur); }
.t2-seg button[aria-pressed="true"], .t2-seg button[aria-selected="true"] { background: var(--panelsolid); color: var(--tx); }

/* ── Underline tabs ──────────────────────────────────────────── */
.t2-tabs { display: flex; gap: 18px; }
.t2-tabs button { background: none; border: 0; border-bottom: 1.5px solid transparent; padding: 2px 0 4px; color: var(--td); font-size: 13px; font-weight: 400; cursor: pointer; transition: color var(--dur); }
.t2-tabs button:hover { color: var(--t2); }
.t2-tabs button[aria-selected="true"], .t2-tabs button[aria-pressed="true"] { color: var(--tx); border-bottom-color: var(--tx); font-weight: 500; }
.t2-tabs small { color: var(--td); font-size: 12px; margin-left: 4px; }

/* ── Chips and badges ────────────────────────────────────────── */
.t2-chip { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: var(--rad-tile); border: 1px solid var(--grid); background: var(--seg); color: var(--t2); font-size: 12px; font-weight: 500; cursor: pointer; transition: background var(--dur), color var(--dur); }
.t2-chip:hover { background: var(--ghost); color: var(--tx); }
.t2-chip[aria-pressed="true"] { background: var(--ink); color: var(--inktx); border-color: var(--ink); }
.t2-chip--criteria { height: 30px; border-radius: var(--rad-chip); background: var(--ghost); color: var(--tx); gap: 8px; cursor: default; }
.t2-chip--criteria button { background: none; border: 0; color: var(--td); cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.t2-badge { display: inline-block; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; color: var(--tx); background: var(--ghost); }
.t2-badge--q12 { background: color-mix(in srgb, var(--r2) 24%, transparent); }
.t2-badge--active  { padding: 5px 10px; border-radius: 7px; font-weight: 500; letter-spacing: 0.08em; background: color-mix(in srgb, var(--r2) 24%, transparent); }
.t2-badge--passive { padding: 5px 10px; border-radius: 7px; font-weight: 500; letter-spacing: 0.08em; background: color-mix(in srgb, var(--r3) 24%, transparent); }
.t2-badge--sev { padding: 3px 8px; letter-spacing: 0.06em; background: var(--track); }  /* severity is the word, no red/amber */
.t2-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.t2-dot--live { width: 7px; height: 7px; background: var(--gain); animation: t2pulse 1.8s infinite; }

/* ── Inputs ──────────────────────────────────────────────────── */
.t2-input { height: 40px; padding: 0 14px; border-radius: var(--rad-tile); border: 1px solid var(--grid); background: var(--ghost); color: var(--tx); font: inherit; font-size: 14px; width: 100%; }
.t2-input::placeholder { color: var(--td); opacity: 1; }
.t2-range { width: 100%; accent-color: var(--r2); }

/* ── Tooltip (chart tooltips and glass overlays) ─────────────── */
.t2-tip { position: absolute; z-index: 5; pointer-events: none; display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-radius: var(--rad-panel);
  background: color-mix(in srgb, var(--panel) 70%, transparent); border: 1px solid var(--pbd); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow); white-space: nowrap; }
.t2-tip b { font-size: 15px; font-weight: 500; }

/* ── Modal ───────────────────────────────────────────────────── */
.t2-scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; }
.t2-scrim.is-open { display: flex; }
.t2-scrim--host { z-index: 61; }   /* a modal host: <div class="t2-scrim t2-scrim--host" id="t2Modal-NAME"><div class="t2-modal">...</div></div> */
.t2-modal { position: relative; width: min(700px, calc(100vw - 48px)); max-height: 90vh; overflow: auto; padding: 24px; border-radius: var(--rad-panel); background: var(--panelsolid); border: 1px solid var(--pbd); box-shadow: var(--shadow); animation: t2in 0.25s var(--ease) both; }
.t2-modal--wide { width: min(960px, calc(100vw - 48px)); }
.t2-modal .t2-modal-x { position: absolute; top: 16px; right: 16px; }

/* ── Drawer (sign in / register; slides from the left) ───────── */
.t2-drawer { position: fixed; top: 0; bottom: 0; left: 0; width: 480px; max-width: 100vw; z-index: 70; padding: 32px; overflow: auto; background: var(--drawer); border-right: 1px solid var(--pbd); box-shadow: var(--shadow); display: none; }
.t2-drawer.is-open { display: block; animation: t2drawer 0.3s var(--ease) both; }

/* ── Toast (top: 84px, below the nav) ────────────────────────── */
.t2-toast { position: fixed; z-index: 80; top: 84px; left: 50%; transform: translateX(-50%); padding: 14px 22px; border-radius: var(--rad-tile); background: var(--ink); color: var(--inktx); font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.t2-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── Skeleton (per module, shape set by the modifier) ────────── */
.t2-sk { border-radius: 8px; background: linear-gradient(90deg, var(--sk1), var(--sk2), var(--sk1)); background-size: 200% 100%; animation: t2sk 1.6s ease-in-out infinite; }
.t2-sk--stat  { height: 90px; }
.t2-sk--chart { height: 380px; }
.t2-sk--row   { height: 14px; margin: 12px 0; }

/* ── Chart box (any chart mounts here; skeleton shows until it does) ── */
.t2-chart { position: relative; width: 100%; }
.t2-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.t2-chart:not(.is-ready) { min-height: 120px; }
.t2-chart:not(.is-ready)::before { content: ''; position: absolute; inset: 0; border-radius: 8px; background: linear-gradient(90deg, var(--sk1), var(--sk2), var(--sk1)); background-size: 200% 100%; animation: t2sk 1.6s ease-in-out infinite; }
.t2-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.t2-legend button { display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--td); }
.t2-legend button[aria-pressed="true"] { color: var(--tx); }
.t2-legend .t2-dot { width: 10px; height: 10px; border: 1.5px solid var(--c, var(--r2)); background: transparent; }
.t2-legend button[aria-pressed="true"] .t2-dot { background: var(--c, var(--r2)); }

/* ── Allocation bar rows ─────────────────────────────────────── */
.t2-rampbar, .t2-bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.t2-rampbar > i, .t2-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--ramp); }
.t2-rampbar--4, .t2-bar--4 { height: 4px; border-radius: 2px; }

/* ── Carousel ────────────────────────────────────────────────── */
.t2-car { display: grid; grid-auto-flow: column; gap: var(--gap); overflow-x: auto; scrollbar-width: none; cursor: grab; user-select: none; }
.t2-car::-webkit-scrollbar { display: none; }

/* ── Table (compare "side by side") ──────────────────────────── */
.t2-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t2-table th, .t2-table td { padding: 13px 22px; text-align: right; font-size: 14px; border-top: 1px solid var(--grid); white-space: nowrap; }
.t2-table thead th { border-top: 0; font-size: 13px; font-weight: 400; color: var(--td); }
.t2-table th:first-child, .t2-table td:first-child { text-align: left; min-width: 150px; }
.t2-table tbody th { font-weight: 400; color: var(--t2); }
.t2-table td.is-lead { font-weight: 700; }                 /* the leading value in a row is bold; never the word "best" */
.t2-table-wrap { overflow-x: auto; }
@media (max-width: 1279px) { .t2-table-wrap .t2-table th:first-child { position: sticky; left: 0; background: var(--panelsolid); } }   /* pinned label column only where the table actually scrolls */

/* ── List row (top funds, picker) ────────────────────────────── */
.t2-list-row, .t2-li { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--grid); }
.t2-list-row:first-child, .t2-li:first-child { border-top: 0; }
.t2-list-rank, .t2-li-rank { width: 28px; height: 28px; border-radius: 8px; background: var(--ghost); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; }
.t2-ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Form field (label + input + hint + error), switch, message. Promoted for Account/Auth (owner: Menus) ── */
.t2-field { display: grid; gap: 6px; }
.t2-field > label, .t2-field .t2-field-l { font-size: 13px; font-weight: 500; color: var(--t2); }
.t2-field .t2-input { height: 48px; font-size: 14px; }
.t2-field .t2-hint { font-size: 12px; color: var(--td); }
.t2-field .t2-err { font-size: 12px; color: var(--loss); display: none; }
.t2-field.is-invalid .t2-input { border-color: var(--loss); }
.t2-field.is-invalid .t2-err { display: block; }
.t2-switch { position: relative; flex: none; width: 40px; height: 24px; padding: 0; border-radius: 12px; border: 1px solid var(--grid); background: var(--track); cursor: pointer; transition: background var(--dur); }
.t2-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--panelsolid); box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform var(--dur) var(--ease); }
.t2-switch[aria-checked="true"] { background: var(--glass); border-color: var(--glassbd); }
.t2-switch[aria-checked="true"]::after { transform: translateX(16px); }
.t2-switch[disabled] { opacity: 0.5; cursor: not-allowed; }
.t2-msg { padding: 12px 14px; border-radius: var(--rad-tile); font-size: 13px; line-height: 1.5; background: var(--ghost); border: 1px solid var(--grid); color: var(--tx); }
.t2-msg--err { border-color: var(--loss); }
.t2-msg--ok { border-color: var(--gain); }

@media (max-width: 899px) {
  .t2-panel-head { flex-wrap: wrap; }
  .t2-tabs { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; scrollbar-width: none; }
  .t2-tabs button { white-space: nowrap; }
  .t2-seg { max-width: 100%; flex-wrap: wrap; }
  .t2-modal, .t2-modal--wide { width: calc(100vw - 24px); padding: 18px; }
  .t2-drawer { width: 100vw; padding: 24px 16px; }
  .t2-table th, .t2-table td { padding: 10px 14px; }
  .t2-tip { max-width: calc(100vw - 32px); white-space: normal; }
}

@media (max-width: 899px) { .t2-chip--criteria button { min-width: 32px; min-height: 32px; } }

@media (max-width: 899px) {
  .t2-tabs button { min-width: 36px; padding-left: 6px; padding-right: 6px; }
  .t2-tabs { gap: 8px; }
  .t2-table .t2-sub { font-size: inherit; }
}

/* Chart event pins: the button itself is a 44px target (see fbcharts.js), the visible marker is 10px in the middle */
.t2-pin:focus-visible { outline: 2px solid var(--r3); outline-offset: -10px; border-radius: 50%; }
.t2-gauge-leg { background: none; border: 0; padding: 0 6px; min-height: 36px; border-radius: 8px; color: inherit; cursor: pointer; }
.t2-gauge-leg:hover, .t2-gauge-leg[aria-pressed="true"] { background: var(--ghost); }
.t2-gauge-leg:focus-visible { outline: 2px solid var(--r3); outline-offset: 2px; }
@media (max-width: 899px) { .t2-gauge-leg { min-height: 44px; min-width: 44px; padding: 0 10px; } }

/* ── Shared chart motion (fbcharts.js FBCharts.motion; spec docs/worklog/motion-spec-2026-10-12.md). Hidden start state ONLY while a chart waits to scroll into view ([data-m="pending"]),
   then the sequence ([data-m="play"]); [data-m="done"] and everything else is the plain finished chart. Transforms, opacity, clip and stroke only. 'backwards' fill: the final frame is the natural style. ── */
.tm-rise { transform-box: fill-box; transform-origin: 50% 100%; } .tm-grow { transform-box: fill-box; transform-origin: 0 50%; } .tm-pop { transform-box: fill-box; transform-origin: 50% 50%; }
.tm-arc { stroke-dasharray: 1; stroke-dashoffset: 0; }
[data-m="pending"] .tm-rise { transform: scaleY(0); } [data-m="pending"] .tm-grow { transform: scaleX(0); } [data-m="pending"] .tm-pop { opacity: 0; transform: scale(.4); }
[data-m="pending"] .tm-arc { stroke-dashoffset: 1; } [data-m="pending"].tm-fade, [data-m="pending"] .tm-fade { opacity: 0; } [data-m="pending"] svg.tm-wipe, [data-m="pending"].tm-wipe { clip-path: inset(0 100% 0 0); }
[data-m="play"] .tm-rise { animation: tmRise var(--m-bar) var(--ease-athletic) var(--tmd, 0ms) backwards; }
[data-m="play"] .tm-grow { animation: tmGrow var(--m-bar) var(--ease-athletic) var(--tmd, 0ms) backwards; }
[data-m="play"] .tm-pop { animation: tmPop var(--m-pop) var(--ease-athletic) var(--tmd, 0ms) backwards; }
[data-m="play"] .tm-arc { animation: tmArc var(--m-arc) ease-in-out var(--tmd, 0ms) backwards; }
[data-m="play"].tm-fade, [data-m="play"] .tm-fade { animation: tmFade var(--m-fade) ease-out var(--tmd, 0ms) backwards; }
[data-m="play"] svg.tm-wipe, [data-m="play"].tm-wipe { animation: tmWipe var(--m-line) ease-in-out backwards; }
@keyframes tmRise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes tmGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes tmPop { 0% { opacity: 0; transform: scale(.4); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes tmArc { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes tmFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tmWipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { [data-m] *, [data-m] { animation: none !important; } [data-m="pending"] .tm-rise, [data-m="pending"] .tm-grow, [data-m="pending"] .tm-pop, [data-m="pending"] .tm-fade, [data-m="pending"].tm-fade, [data-m="pending"] svg.tm-wipe { transform: none !important; opacity: 1 !important; clip-path: none !important; } [data-m="pending"] .tm-arc { stroke-dashoffset: 0 !important; } }
