/* Truth Table and Boolean Algebra Calculator (/truth-table-calculator): the formula line, the Karnaugh map (cells,
   Gray-code headings, coloured groups), the normal forms, the truth table with its true rows, and the prime implicant
   chart. Tiles, panels, tables and buttons come from the app kit (css/app-kit, docs/app-kit.md). Loaded only on this
   app's page (StylePaths). */

.tt-landing-app .tt-results { display: flex; flex-direction: column; gap: var(--ak-space-4); min-width: 0; }
.tt-landing-app .tt-results[hidden] { display: none; }
.tt-landing-app .tt-results.is-stale { opacity: 0.5; transition: opacity 0.15s; }
.tt-landing-app .tt-where,
.tt-landing-app .tt-cube { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- Error message with the formula and the place marked --- */
.tt-landing-app .tt-message { align-items: flex-start; }
.tt-landing-app .tt-where { display: block; margin-top: 0.35rem; color: var(--ak-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.tt-landing-app .tt-where[hidden] { display: none; }
.tt-landing-app .tt-where mark { background: color-mix(in srgb, var(--ak-danger) 30%, transparent); color: inherit; border-bottom: 2px solid var(--ak-danger); border-radius: 2px; padding: 0 1px; }
.tt-landing-app .tt-where mark.is-end { display: inline-block; min-width: 0.6em; }

/* --- The formula --- */
.tt-landing-app .tt-formula-row { display: flex; align-items: flex-start; gap: var(--ak-space-2); }
.tt-landing-app .tt-expr { flex: 1; min-width: 0; font-size: 1.3rem; line-height: 1.45; overflow-wrap: anywhere; color: var(--ak-text); }
.tt-landing-app .tt-compare { margin: 0; font-size: var(--ak-fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.tt-landing-app .tt-compare.is-equal { color: var(--ak-success); }
.tt-landing-app .tt-compare.is-different { color: var(--ak-warning); }
.tt-landing-app .tt-compare.is-error { color: var(--ak-danger); }

/* --- Karnaugh map --- */
.tt-landing-app .tt-kmap-panel { align-items: center; justify-content: center; }
.tt-landing-app .tt-kmap { width: 100%; overflow-x: auto; }
.tt-landing-app .tt-kmap svg { display: block; margin: 0 auto; width: 100%; height: auto; overflow: visible; }
.tt-landing-app .tt-km-diag { stroke: var(--ak-border); stroke-width: 1.2; }
.tt-landing-app .tt-km-var { font-size: 14px; font-weight: 700; fill: var(--ak-text); }
.tt-landing-app .tt-km-code { font-size: 12.5px; font-weight: 600; fill: var(--ak-muted); }
.tt-landing-app .tt-cell { cursor: pointer; outline: none; }
.tt-landing-app .tt-cell rect { fill: var(--ak-field); stroke: var(--ak-border); stroke-width: 1; transition: fill 0.12s; }
.tt-landing-app .tt-cell.is-one rect { fill: color-mix(in srgb, var(--ak-accent) 9%, var(--ak-field)); }
.tt-landing-app .tt-cell:hover rect { fill: var(--ak-hover); }
.tt-landing-app .tt-cell:focus-visible rect { stroke: var(--ak-accent); stroke-width: 3; }
.tt-landing-app .tt-km-val { font-size: 20px; fill: var(--ak-muted); pointer-events: none; }
.tt-landing-app .tt-cell.is-one .tt-km-val { fill: var(--ak-text); font-weight: 700; }
.tt-landing-app .tt-km-m { font-size: 9.5px; fill: var(--ak-muted); opacity: 0.8; pointer-events: none; }
.tt-landing-app .tt-km-groups { pointer-events: none; }
.tt-landing-app .tt-group rect { fill: currentColor; fill-opacity: 0.13; stroke: currentColor; stroke-width: 2.6; transition: fill-opacity 0.12s, stroke-width 0.12s; }
.tt-landing-app .tt-group.is-hot rect { fill-opacity: 0.3; stroke-width: 4; }
.tt-landing-app .tt-km-frame { fill: none; stroke: var(--ak-text); stroke-opacity: 0.55; stroke-width: 1.5; pointer-events: none; }

/* --- Normal forms --- */
.tt-landing-app .tt-forms { display: flex; flex-direction: column; gap: var(--ak-space-3, 0.8rem); margin: 0; }
.tt-landing-app .tt-form { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.tt-landing-app .tt-form dt { color: var(--ak-muted); font-size: var(--ak-fs-xs, 0.78rem); font-weight: 600; font-family: inherit; }
.tt-landing-app .tt-form dd { margin: 0; min-width: 0; }
.tt-landing-app .tt-form-expr { font-size: 1.05rem; line-height: 1.5; overflow-wrap: anywhere; color: var(--ak-text); }
.tt-landing-app .tt-form--main .tt-form-expr { font-size: 1.2rem; font-weight: 600; }
.tt-landing-app .tt-form-size { color: var(--ak-muted); font-size: var(--ak-fs-xs, 0.78rem); }
.tt-landing-app .tt-term { border-radius: 4px; padding: 0 2px; outline: none; white-space: nowrap; }
.tt-landing-app .has-groups .tt-term { box-shadow: inset 0 -3px 0 var(--tt-g); cursor: default; }
.tt-landing-app .has-groups .tt-term.is-hot,
.tt-landing-app .has-groups .tt-term:focus-visible { background: color-mix(in srgb, var(--tt-g) 22%, transparent); }
.tt-landing-app .tt-written { font-size: var(--ak-fs-sm); color: var(--ak-muted); }
.tt-landing-app .tt-written summary { cursor: pointer; font-size: var(--ak-fs-xs, 0.78rem); width: max-content; }
.tt-landing-app .tt-written span { display: block; max-height: 9rem; overflow-y: auto; overflow-wrap: anywhere; color: var(--ak-text); padding-top: 0.2rem; }

/* --- Truth table --- */
.tt-landing-app .tt-table th,
.tt-landing-app .tt-table td { text-align: center; padding: 0.25rem 0.55rem; }
.tt-landing-app .tt-table .tt-m { color: var(--ak-muted); font-size: var(--ak-fs-xs, 0.78rem); text-align: end; }
.tt-landing-app .tt-table thead .tt-var { color: var(--ak-text); }
.tt-landing-app .tt-table .tt-step,
.tt-landing-app .tt-table .tt-out-h,
.tt-landing-app .tt-table .tt-cmp-h { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.tt-landing-app .tt-table td.tt-step { color: var(--ak-muted); }
.tt-landing-app .tt-table .tt-out-h,
.tt-landing-app .tt-table td.tt-out { border-inline-start: 2px solid var(--ak-border); }
.tt-landing-app .tt-table thead .tt-out-h { color: var(--ak-accent); }
.tt-landing-app .tt-table td.tt-out { cursor: pointer; font-weight: 700; color: var(--ak-muted); }
.tt-landing-app .tt-table td.tt-out:hover { outline: 2px solid var(--ak-accent); outline-offset: -2px; }
.tt-landing-app .tt-table tr.is-true { background: color-mix(in srgb, var(--ak-success) 11%, transparent); }
.tt-landing-app .tt-table tr.is-true td.tt-out { color: var(--ak-success); }
.tt-landing-app .tt-table tr.is-diff td.tt-out,
.tt-landing-app .tt-table tr.is-diff td.tt-cmp { background: color-mix(in srgb, var(--ak-warning) 22%, transparent); }

/* --- Prime implicant chart --- */
.tt-landing-app .tt-chart th,
.tt-landing-app .tt-chart td { text-align: center; padding: 0.25rem 0.45rem; }
.tt-landing-app .tt-chart tbody th { text-align: start; }
.tt-landing-app .tt-chart .tt-prime-h { text-align: start; }
.tt-landing-app .tt-chart .tt-mcol { min-width: 1.8rem; }
.tt-landing-app .tt-chart td { color: var(--ak-muted); }
.tt-landing-app .tt-chart tr.is-chosen { background: color-mix(in srgb, var(--tt-g) 12%, transparent); }
.tt-landing-app .tt-chart tr.is-chosen th { box-shadow: inset 4px 0 0 var(--tt-g); }
.tt-landing-app .tt-chart tr.is-chosen td { color: var(--ak-text); font-weight: 700; }
.tt-landing-app .tt-chart tr.is-hot { background: color-mix(in srgb, var(--tt-g) 26%, transparent); }
.tt-landing-app .tt-star { display: inline-block; width: 1.1em; color: var(--ak-warning); }
.tt-landing-app .tt-cube { color: var(--ak-muted); font-size: var(--ak-fs-xs, 0.78rem); letter-spacing: 0.08em; }

/* --- Controls: the formula fields and the symbol keys --- */
.tt-landing-app .tt-input { font-size: 1.05rem; }
.tt-landing-app .tt-keys { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0.3rem; }
.tt-landing-app .tt-keys .tt-key {
    min-width: 0;
    min-height: 2.2rem;
    padding-inline: 0;
    justify-content: center;
    border: 1px solid var(--ak-border);
    background: var(--ak-field);
    color: var(--ak-text);
    font-size: 1.15rem;
    font-weight: 600;
}
.tt-landing-app .tt-keys .tt-key:hover { border-color: var(--ak-accent); color: var(--ak-accent); }
.tt-landing-app .tt-seg-sample { opacity: 0.7; font-size: 0.85em; margin-inline-start: 0.25em; white-space: nowrap; }

/* Right-to-left pages: the formulas stay left-to-right but line up with their labels on the right. */
.tt-landing-app .tt-form:dir(rtl) > dd[dir="ltr"],
.tt-landing-app .tt-form:dir(rtl) .tt-written span[dir="ltr"] { text-align: right; }
