/* ta.css — technical toolkit pages (/technical-screener, /market-breadth,
   /relative-strength, /candlestick-patterns, /divergences, /technical-setup,
   /portfolio-technicals, /strategy-library).
   Layers on market.css: every colour/radius/shadow comes from the ff-* tokens,
   and every class here is ta-* prefixed so nothing leaks into other pages. */

.ta-nav { margin: 0 0 14px; }
.ta-nav a { white-space: nowrap; }
.ta-crumbs { font-size: .82rem; color: var(--ff-text-soft); margin: 0 2px 10px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ta-crumbs a { color: var(--ff-accent); text-decoration: none; }
.ta-crumbs a:hover { text-decoration: underline; }
.ta-crumbs span { color: var(--ff-text-faint); }

.ta-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ta-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
/* minmax(0,1fr), not 1fr: a bare 1fr has an `auto` minimum, so a wide table
   inside a card would stretch the column past the phone's edge. */
@media (max-width: 900px) { .ta-grid2, .ta-grid3 { grid-template-columns: minmax(0, 1fr); } }
.ta-grid2 > *, .ta-grid3 > * { min-width: 0; }
/* The last row is filled: an odd last card of a two-column grid spans it, and a three-column
   grid's last one or two cards stretch to its end. A lone card left half the row empty on
   /learn/ pages (TEXT_CARD_WIDTH.md, 11 Nov 2026). */
@media (min-width: 900.02px) {
  .ta-grid2 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .ta-grid3 > :last-child:nth-child(3n+1) { grid-column: 1 / -1; }
  .ta-grid3 > :last-child:nth-child(3n+2) { grid-column: span 2; }
}
/* .ff-hero h1 is a flex row (emoji + title); a title with inline spans must flow as text */
.ff-hero h1.ta-h1 { display: block; }

.ta-card { background: var(--ff-card); border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius); box-shadow: var(--ff-shadow); padding: 14px 16px;
  margin-bottom: 14px; min-width: 0; }
.ta-card h2, .ta-card h3 { margin: 0 0 8px; font-size: 1.02rem; color: var(--ff-primary); }
.ta-card p { margin: 6px 0; line-height: 1.55; color: var(--ff-text); font-size: .92rem; }
.ta-muted { color: var(--ff-text-soft); font-size: .85rem; }
.ta-small { font-size: .78rem; color: var(--ff-text-soft); }

/* score + badges */
.ta-score { display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; padding: 2px 8px; border-radius: 999px; font-weight: 700;
  font-size: .82rem; background: var(--ff-neutral-soft); color: var(--ff-neutral-deep); }
.ta-score.s-hi { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ta-score.s-mid { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ta-score.s-lo { background: var(--ff-danger-soft); color: var(--ff-danger-deep); }
.ta-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem;
  font-weight: 600; background: var(--ff-neutral-soft); color: var(--ff-neutral-deep);
  white-space: nowrap; }
.ta-badge.b-pos { background: var(--ff-success-soft); color: var(--ff-success-deep); }
.ta-badge.b-neg { background: var(--ff-danger-soft); color: var(--ff-danger-deep); }
.ta-badge.b-warn { background: var(--ff-warning-soft); color: var(--ff-warning-deep); }
.ta-badge.b-acc { background: var(--ff-accent-soft); color: var(--ff-accent); }
.t-pos { color: var(--ff-success); }
.t-neg { color: var(--ff-danger); }

/* the big gauge on /technical-setup */
.ta-hero-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.ta-gauge { --pct: 50; width: 132px; height: 132px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--g-col, var(--ff-accent)) calc(var(--pct) * 1%), #e8edf5 0);
  display: flex; align-items: center; justify-content: center; }
.ta-gauge-in { width: 104px; height: 104px; border-radius: 50%; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ta-gauge-in b { font-size: 1.9rem; color: var(--ff-primary); line-height: 1; }
.ta-gauge-in span { font-size: .7rem; color: var(--ff-text-soft); text-transform: uppercase;
  letter-spacing: .04em; margin-top: 3px; text-align: center; }
/* auto-fit, and rows of equal length when the tiles take more than one: a full row and a stub of
   one left up to 1,000px empty (TEXT_CARD_WIDTH.md, 11 Nov 2026). The grid sits in full-width
   pages and in half-width cards, so the tiles a row holds are read off its parent's width
   (container "kv"): 170px tiles, 7 from 1,238px, 6 from 1,060, 5 from 882, 4 from 704, 3 below. */
:where(*):has(> .ta-kvgrid) { container: kv / inline-size; }
.ta-kvgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px; }
@container kv (min-width: 1238px) {
  .ta-kvgrid:has(> :nth-child(8):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ta-kvgrid:is(:has(> :nth-child(9):last-child), :has(> :nth-child(10):last-child)) {
    grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .ta-kvgrid:is(:has(> :nth-child(11):last-child), :has(> :nth-child(12):last-child)) {
    grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@container kv (min-width: 1060px) and (max-width: 1237.98px) {
  .ta-kvgrid:is(:has(> :nth-child(7):last-child), :has(> :nth-child(8):last-child)) {
    grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ta-kvgrid:is(:has(> :nth-child(9):last-child), :has(> :nth-child(10):last-child)) {
    grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@container kv (min-width: 882px) and (max-width: 1059.98px) {
  .ta-kvgrid:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ta-kvgrid:is(:has(> :nth-child(7):last-child), :has(> :nth-child(8):last-child), :has(> :nth-child(11):last-child),
                :has(> :nth-child(12):last-child)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@container kv (min-width: 704px) and (max-width: 881.98px) {
  .ta-kvgrid:is(:has(> :nth-child(5):last-child), :has(> :nth-child(6):last-child), :has(> :nth-child(9):last-child)) {
    grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@container kv (min-width: 520px) and (max-width: 703.98px) {
  .ta-kvgrid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ta-kvgrid:is(:has(> :nth-child(7):last-child), :has(> :nth-child(8):last-child)) {
    grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.ta-kv { background: var(--ff-bg); border: 1px solid var(--ff-border-soft);
  border-radius: var(--ff-radius-sm); padding: 8px 10px; min-width: 0; }
.ta-kv .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ff-text-soft); font-weight: 600; }
.ta-kv .v { font-size: .98rem; font-weight: 700; color: var(--ff-text); margin-top: 2px;
  overflow-wrap: anywhere; }
/* A signed figure keeps its colour inside a tile. `.ta-kv .v` (two classes) outranked the
   one-class .t-pos / .t-neg above, so FII/DII nets and advances/declines on /market-today/
   and every other ta-kv tile drew in plain text (operator report, 4 Nov 2026;
   US_UI_ADOPTION.md). */
.ta-kv .v.t-pos { color: var(--ff-success); }
.ta-kv .v.t-neg { color: var(--ff-danger); }

/* score breakdown */
.ta-comp { border-top: 1px solid var(--ff-border-soft); padding: 10px 0; }
.ta-comp:first-child { border-top: none; }
.ta-comp-head { display: flex; justify-content: space-between; align-items: center;
  gap: 10px; font-weight: 700; color: var(--ff-primary); }
.ta-bar { height: 8px; background: #e8edf5; border-radius: 99px; overflow: hidden;
  margin: 6px 0 4px; }
.ta-bar i { display: block; height: 100%; background: var(--ff-accent); border-radius: 99px; }
.ta-rules { list-style: none; margin: 4px 0 0; padding: 0; }
.ta-rules li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0;
  font-size: .86rem; border-bottom: 1px dashed var(--ff-border-soft); }
.ta-rules li:last-child { border-bottom: none; }
.ta-rules .ok::before { content: "✓ "; color: var(--ff-success); font-weight: 700; }
.ta-rules .no::before { content: "✗ "; color: var(--ff-danger); font-weight: 700; }
.ta-rules .pts { white-space: nowrap; font-weight: 600; color: var(--ff-text-soft); }

/* screener builder */
.ta-builder { background: var(--ff-card); border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius); box-shadow: var(--ff-shadow); padding: 14px; margin-bottom: 14px; }
.ta-group { border: 1px dashed #c9d6ea; border-radius: 10px; padding: 10px; margin: 8px 0;
  background: #fbfcfe; }
.ta-group .ta-group { background: #fff; }
.ta-group-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 6px; font-size: .84rem; color: var(--ff-text-soft); }
.ta-cond { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0;
  border-bottom: 1px solid var(--ff-border-soft); }
.ta-cond:last-child { border-bottom: none; }
.ta-builder select, .ta-builder input[type=number], .ta-builder input[type=text],
.ta-builder textarea, .ta-field {
  font: inherit; font-size: .86rem; padding: 6px 8px; border: 1px solid var(--ff-border);
  border-radius: 8px; background: #fff; color: var(--ff-text); max-width: 100%; }
.ta-builder select.ta-f { min-width: 190px; }
.ta-builder input[type=number] { width: 92px; }
.ta-builder textarea { width: 100%; min-height: 70px; font-family: ui-monospace, Consolas, monospace; }
.ta-mini { font-size: .78rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--ff-border);
  background: #fff; cursor: pointer; color: var(--ff-text-soft); }
.ta-mini:hover { border-color: var(--ff-accent); color: var(--ff-accent); }
.ta-mini.danger:hover { border-color: var(--ff-danger); color: var(--ff-danger); }
.ta-andor { display: inline-flex; border: 1px solid var(--ff-border); border-radius: 8px; overflow: hidden; }
.ta-andor button { border: 0; background: #fff; padding: 4px 10px; font-size: .78rem;
  cursor: pointer; color: var(--ff-text-soft); font-weight: 600; }
.ta-andor button.on { background: var(--ff-primary); color: #fff; }
.ta-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.ta-qtext { font-family: ui-monospace, Consolas, monospace; font-size: .82rem;
  background: var(--ff-bg); border: 1px solid var(--ff-border-soft); border-radius: 8px;
  padding: 8px 10px; overflow-wrap: anywhere; color: var(--ff-primary); }
.ta-err { color: var(--ff-danger); font-size: .86rem; margin-top: 6px; }

/* Link cards share the row (auto-fit): with auto-fill four of them ended at 65% of the page
   (12 Oct), and one or two "related" cards sat in the first sixth of an empty row (11 Nov;
   TEXT_CARD_WIDTH.md). */
.ta-preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
/* Six to twelve cards that do not fit one row go in rows of equal length, not a full row and a
   stub (six were 5 + 1 below 1,440px). Six 220px cards fit only a 1,360px page; long lists
   (the screener's 47) keep their natural last row. */
@media (min-width: 1100px) {
  .ta-preset-grid:is(:has(> :nth-child(7):last-child), :has(> :nth-child(8):last-child)) {
    grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ta-preset-grid:is(:has(> :nth-child(9):last-child), :has(> :nth-child(10):last-child)) {
    grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .ta-preset-grid:is(:has(> :nth-child(11):last-child), :has(> :nth-child(12):last-child)) {
    grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 900px) and (max-width: 1439.98px) {
  .ta-preset-grid:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1100px) and (max-width: 1439.98px) {
  .ta-preset-grid:has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 900px) and (max-width: 1099.98px) {
  .ta-preset-grid:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.ta-preset { display: block; padding: 10px 12px; background: var(--ff-card); border: 1px solid var(--ff-border);
  border-radius: var(--ff-radius-sm); text-decoration: none; color: inherit; box-shadow: var(--ff-shadow); }
.ta-preset:hover { box-shadow: var(--ff-shadow-hover); border-color: var(--ff-accent); }
.ta-preset b { display: block; color: var(--ff-primary); font-size: .9rem; }
.ta-preset span { display: block; font-size: .76rem; color: var(--ff-text-soft); margin-top: 2px; }

/* breadth */
.ta-meter { display: flex; align-items: center; gap: 8px; font-size: .84rem; }
.ta-meter .ta-bar { flex: 1 1 auto; margin: 0; min-width: 60px; }
.ta-chart { position: relative; height: 260px; }
.ta-chart.tall { height: 320px; }
.ta-heat td[data-heat] { font-weight: 600; }
.ta-alerts { list-style: none; margin: 0; padding: 0; }
.ta-alerts li { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; font-size: .88rem;
  border-left: 4px solid var(--ff-neutral); background: var(--ff-neutral-soft); }
.ta-alerts li.bad { border-left-color: var(--ff-danger); background: var(--ff-danger-soft); }
.ta-alerts li.warn { border-left-color: var(--ff-warning); background: var(--ff-warning-soft); }
.ta-alerts li.good { border-left-color: var(--ff-success); background: var(--ff-success-soft); }
.ta-alerts li small { display: block; color: var(--ff-text-soft); margin-top: 2px; }

/* portfolio editor */
.ta-hold { display: grid; grid-template-columns: 1fr 110px 34px; gap: 6px; margin-bottom: 6px; }
.ta-hold input { font: inherit; font-size: .86rem; padding: 6px 8px; border: 1px solid var(--ff-border);
  border-radius: 8px; min-width: 0; }
.ta-lists { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

.ta-disclaimer { font-size: .78rem; color: var(--ff-text-soft); border-top: 1px solid var(--ff-border);
  margin-top: 18px; padding-top: 10px; line-height: 1.5; }
.ta-prose p, .ta-prose li { line-height: 1.6; }
/* Text cards (.ta-prose, and .hb-prose of hubs.css) run the width of the page like the tables
   and tiles around them. Capped at 820 to 920px they stopped at 60% of a 1400px page and left
   the right of it empty (operator, 12 Oct 2026). So that a line still reads at about 90
   characters, text that comes as several blocks flows in two columns on a wide screen, and a
   long page (17 blocks or more) in three from 1300px. One paragraph, or one short list, stays
   one column. Questions kept in <details> sit in a two-column grid instead: a column flow
   would move them about each time one is opened. */
.ta-card:is(.ta-prose, .hb-prose) > :first-child { margin-top: 0; }
.ta-card:is(.ta-prose, .hb-prose) > :last-child { margin-bottom: 0; }
@media (min-width: 1100px) {
  .ta-card:is(.ta-prose, .hb-prose):is(:has(> :is(p, ul, ol, div) ~ :is(p, ul, ol, div)), :has(> :is(ul, ol) > :nth-child(4))) {
    columns: 2; column-gap: 44px; }
  /* a list item that holds a list of its own may break between its sub-items: kept whole,
     one long step on /embed/ left the second column a third short (11 Nov) */
  .ta-card:is(.ta-prose, .hb-prose) > :is(p, div, table), .ta-card:is(.ta-prose, .hb-prose) li:not(:has(> ul, > ol)) { break-inside: avoid; }
  .ta-card:is(.ta-prose, .hb-prose) > :is(h2, h3) { break-after: avoid; }
  .ta-card:is(.ta-prose, .hb-prose):has(> details ~ details) { display: grid; grid-template-columns: 1fr 1fr;
    gap: 0 44px; align-items: start; }
}
@media (min-width: 1300px) {
  .ta-card.ta-card:is(.ta-prose, .hb-prose):has(> :nth-child(17)) { columns: 3; column-gap: 40px; }
}

/* strategy cards */
.ta-strat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }  /* fit: a family of four fills its row */
.ta-strat { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; background: var(--ff-card);
  border: 1px solid var(--ff-border); border-radius: var(--ff-radius-sm); box-shadow: var(--ff-shadow);
  text-decoration: none; color: inherit; }
.ta-strat:hover { box-shadow: var(--ff-shadow-hover); border-color: var(--ff-accent); }
.ta-strat b { color: var(--ff-primary); }
.ta-strat .ta-rule { font-size: .8rem; color: var(--ff-text); }
.ta-strat .ta-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

@media (max-width: 600px) {
  .ta-gauge { width: 108px; height: 108px; }
  .ta-gauge-in { width: 84px; height: 84px; }
  .ta-gauge-in b { font-size: 1.5rem; }
  .ta-builder select.ta-f { min-width: 0; width: 100%; }
  .ta-cond > * { flex: 1 1 auto; }
  .ta-chart { height: 220px; }
  .ta-hold { grid-template-columns: 1fr 80px 34px; }
}

/* phones: the eight toolkit tabs become one swipeable row instead of four */
@media (max-width: 600px) {
  .ta-nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; }
  .ta-nav::-webkit-scrollbar { display: none; }
  .ta-nav a { flex: 0 0 auto; }
}
