/* Boolean circuits — applet styles on top of applets/style.css: toggles, NAND circuits, the model M1,
 * decision trees and the cycle graph. Shared by the Polish page (applets/) and the English one
 * (en/applets/). Colors: value 1 = indigo (like --sym), value 0 = grey, satisfied and agreeing = green
 * (--prf), violated = red (--danger); frames of the circuit halves: indigo (A, P) and teal (B, Q). */

:root {
  --v1: #4f46e5; --v1-bg: #eef2ff; --v0: #94a3b8; --v0-txt: #64748b;
  --ok: #059669; --bad: #dc2626; --half-a: #6366f1; --half-b: #0d9488;
}

.page-container { max-width: 1240px; }
.nav-bar { flex-wrap: wrap; row-gap: 0.3rem; }
.description p + p { margin-top: 0.45rem; }
.noscript { padding: 0.8rem 1rem; color: var(--danger); background: #fef2f2; border-radius: var(--radius-sm); margin-bottom: 1rem; }
.is-hidden { display: none !important; }

/* --- legend of wire values --- */
.value-legend { display: inline-flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; white-space: nowrap; }
.swatch { display: inline-block; width: 1.7rem; height: 0.28rem; border-radius: 2px; vertical-align: middle; margin-right: 0.3rem; }
.swatch.v1 { background: var(--v1); height: 0.36rem; }
.swatch.v0 { background: var(--v0); }

/* --- topic cards --- */
.topic-card { background: white; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
              padding: 1.3rem 1.4rem 1.1rem; margin-bottom: 1.6rem; min-width: 0; }
.topic-card > h2 { display: flex; align-items: center; gap: 0.65rem; font-size: 1.22rem; font-weight: 700; color: var(--heading);
                   letter-spacing: -0.01em; line-height: 1.3; margin-bottom: 0.75rem; }
.topic-card > h2 .step-no { flex: 0 0 auto; display: inline-grid; place-items: center; width: 1.85rem; height: 1.85rem; border-radius: 50%;
                            background: var(--prf-soft); color: var(--prf); font-size: 0.95rem; font-weight: 800; }
.topic-card h3 { font-size: 0.78rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.06em;
                 margin: 1.1rem 0 0.5rem; }
.topic-card h3.subsection { font-size: 1.05rem; color: var(--heading); text-transform: none; letter-spacing: -0.005em;
                            margin-top: 1.6rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }
.topic-card p { font-size: 0.92rem; line-height: 1.65; margin-bottom: 0.6rem; max-width: 96ch; }
.topic-card p code, .model p code { font-size: 0.84em; }
.small-note { font-size: 0.8rem !important; color: var(--text-light); line-height: 1.55 !important; }

.formulas { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.1rem 0 0.85rem; min-width: 0; }
.formula-row { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: center; font-size: 0.85rem; color: var(--text-light); min-width: 0; }
code.formula { display: block; width: fit-content; max-width: 100%; overflow-x: auto; white-space: nowrap; font-size: 0.9rem;
               padding: 0.4rem 0.75rem; background: var(--bg-alt); border-left: 3px solid var(--prf);
               border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--heading); }
code.formula.secondary { border-left-color: #cbd5e1; color: #334155; }

/* --- toggles --- */
.toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 1.4rem; margin: 0.3rem 0 0.9rem; }
.toggle-group { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.toggle-group .lbl { font-size: 0.7rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.06em; margin-right: 0.1rem; }
.bit { font: 700 0.92rem var(--font-mono); min-width: 4.4rem; padding: 0.34rem 0.75rem; border-radius: 999px; border: 2px solid var(--v0);
       background: white; color: var(--v0-txt); cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s; }
.bit:hover { border-color: var(--v1); }
.bit[aria-pressed="true"] { background: var(--v1); border-color: var(--v1); color: white; }
.choice { font: 600 0.88rem var(--font-mono); min-width: 2.3rem; padding: 0.28rem 0.6rem; border: 1px solid #cbd5e1; background: white;
          color: var(--text); border-radius: var(--radius-sm); cursor: pointer; }
.choice:hover { border-color: var(--heading); }
.choice[aria-pressed="true"] { background: var(--heading); color: white; border-color: var(--heading); }
.bit:focus-visible, .choice:focus-visible, .triple:focus-visible, .truth-table tbody tr:focus-visible,
.to-boole-lab a:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 2px; }

/* --- layouts --- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.2rem; align-items: start; }
.layout.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.layout.cycle-layout { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
@media (max-width: 1080px) { .layout.two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 960px) { .layout, .layout.cycle-layout { grid-template-columns: minmax(0, 1fr); } }

.svg-wrap { border: 1px solid var(--border); border-radius: 10px; background: #fcfcfd; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.svg-wrap svg { display: block; width: 100%; height: auto; }
.svg-wrap.circuit svg { min-width: 560px; }
.scroll-hint { display: none; font-size: 0.74rem; color: var(--text-light); margin: 0.3rem 0 0; }
@media (max-width: 640px) { .scroll-hint { display: block; } }

/* --- SVG: circuits --- */
svg text { font-family: var(--font); }
.wire { fill: none; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.15s, stroke-width 0.15s; }
.wire.v1 { stroke: var(--v1); stroke-width: 3.2; }
.wire.v0 { stroke: var(--v0); stroke-width: 2.2; }
.bus.v1 { stroke: var(--v1); stroke-width: 3.6; }
.bus.v0 { stroke: var(--v0); stroke-width: 2.6; }
.dot.v1 { fill: var(--v1); } .dot.v0 { fill: var(--v0); }
.gate { fill: white; stroke: #334155; stroke-width: 1.8; }
.gate-group:hover .gate { fill: #f8fafc; }
.half-frame { stroke-width: 1.4; stroke-dasharray: 5 4; }
.half-frame.half-a { stroke: #a5b4fc; fill: rgba(99, 102, 241, 0.045); }
.half-frame.half-b { stroke: #5eead4; fill: rgba(13, 148, 136, 0.05); }
.half-name { font-weight: 800; font-size: 17px; }
.half-name.half-a { fill: var(--half-a); } .half-name.half-b { fill: var(--half-b); }
.bus-name { font: 700 15px var(--font-mono); fill: var(--heading); }
.badge rect, .badge circle { stroke-width: 1.5; }
.badge.v1 rect, .badge.v1 circle { fill: var(--v1); stroke: var(--v1); }
.badge.v0 rect, .badge.v0 circle { fill: white; stroke: var(--v0); }
.badge text { font: 700 11.5px var(--font-mono); text-anchor: middle; dominant-baseline: central; }
.badge.v1 text { fill: white; } .badge.v0 text { fill: var(--v0-txt); }
.badge.large text { font-size: 13px; }
.output-label { font: 600 12.5px var(--font); fill: var(--heading); }
.check { font: 800 15px var(--font); }
.check.ok { fill: var(--ok); } .check.bad { fill: var(--bad); }
.clickable { cursor: pointer; }

/* --- readouts and verdicts --- */
.readouts { display: flex; flex-direction: column; gap: 0.45rem; }
.readout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; padding: 0.45rem 0.6rem;
           border-radius: var(--radius-sm); background: var(--bg-alt); border-left: 3px solid #cbd5e1; }
.readout.half-a { border-left-color: var(--half-a); } .readout.half-b { border-left-color: var(--half-b); }
.readout.final { border-left-color: var(--ok); background: var(--prf-bg); }
.readout .expr { font-family: var(--font-mono); font-size: 0.8rem; color: #334155; overflow-wrap: anywhere; line-height: 1.5; }
.readout .expr b { color: var(--heading); }
.val { display: inline-grid; place-items: center; min-width: 1.75rem; height: 1.75rem; padding: 0 0.4rem; border-radius: 999px;
       font: 700 0.86rem var(--font-mono); border: 1.5px solid transparent; }
.val.v1 { background: var(--v1); color: white; border-color: var(--v1); }
.val.v0 { background: white; color: var(--v0-txt); border-color: var(--v0); }
.verdict { margin-top: 0.7rem; }
.verdict .icon { flex: 0 0 auto; }

/* --- truth tables --- */
.truth-table { width: auto; min-width: min(100%, 560px); }
.truth-table caption { caption-side: bottom; text-align: left; font-size: 0.76rem; color: var(--text-light); padding-top: 0.45rem; }
.truth-table th, .truth-table td { text-align: center; padding: 0.32rem 0.7rem; }
.truth-table th { font-family: var(--font-mono); font-size: 0.78rem; }
.truth-table td.v1 { color: var(--v1); font-weight: 700; }
.truth-table td.v0 { color: #94a3b8; }
.truth-table td.ok { color: var(--ok); font-weight: 800; font-size: 0.95rem; }
.truth-table td.bad { color: var(--bad); font-weight: 800; }
.truth-table .sep { border-left: 2px solid var(--border); }
.truth-table tbody tr { cursor: pointer; }
.truth-table tbody tr:hover td { background: #f8fafc; }
.truth-table tbody tr.current td { background: var(--v1-bg); }
.truth-table tbody tr.current td:first-child { box-shadow: inset 4px 0 0 var(--v1); }
.truth-table tbody tr.survives td.product { color: var(--ok); }

/* --- the model M1 --- */
.model { background: var(--num-bg); border: 1px dashed #f59e0b; border-radius: var(--radius); padding: 1rem 1.1rem; min-width: 0; }
.model h3 { margin-top: 0; color: #92400e; }
.model p { font-size: 0.86rem; line-height: 1.6; margin-bottom: 0.55rem; }
.m1-layout { display: flex; flex-wrap: wrap; gap: 0.9rem 1.3rem; align-items: flex-start; margin: 0.3rem 0 0.6rem; }
.m1-table { border-collapse: collapse; font-family: var(--font-mono); background: white; }
.m1-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.m1-table th, .m1-table td { width: 2.4rem; height: 2.15rem; text-align: center; border: 1px solid #e5e7eb; font-size: 0.92rem; }
.m1-table th { background: #fef3c7; color: #92400e; font-weight: 700; font-size: 0.84rem; }
.m1-table thead th:first-child { font-size: 0.72rem; font-weight: 600; }
.m1-table td.used { background: #fde68a; font-weight: 800; }
.m1-table td.last { outline: 2.5px solid var(--warn); outline-offset: -2.5px; }
.m1-choice { display: flex; flex-direction: column; gap: 0.4rem; }
.m1-choice .toggle-group .lbl { min-width: 1.1rem; font: 700 0.92rem var(--font-mono); text-transform: none; letter-spacing: 0; color: var(--heading); }
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 0.25rem; margin: 0.2rem 0 0; }
.steps li { counter-increment: step; font: 0.8rem var(--font-mono); color: #334155; overflow-wrap: anywhere; display: flex; gap: 0.5rem; }
.steps li::before { content: counter(step); flex: 0 0 auto; display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem;
                    border-radius: 50%; background: #fde68a; color: #92400e; font: 700 0.68rem var(--font); margin-top: 0.05rem; }
.steps li b { color: var(--heading); }
.facts { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; margin: 0.8rem 0 0.7rem; font-size: 0.84rem; }
.facts li { display: grid; grid-template-columns: 1.2rem minmax(0, 1fr); gap: 0.35rem; line-height: 1.5; }
.facts li::before { font-weight: 800; }
.facts li.ok::before { content: "✓"; color: var(--ok); }
.facts li.bad::before { content: "✗"; color: var(--bad); }
.facts code { font-size: 0.84em; background: white; }
.triple { font: 600 0.78rem var(--font-mono); padding: 0.12rem 0.5rem; margin: 0.15rem 0.3rem 0 0; border-radius: 999px;
          border: 1px solid #fca5a5; background: white; color: #b91c1c; cursor: pointer; }
.triple:hover { background: #fef2f2; }

/* --- decision trees --- */
.trees { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 760px) { .trees { grid-template-columns: minmax(0, 1fr); } }
.tree { margin: 0; min-width: 0; }
.tree figcaption { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.35rem; display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; }
.tree figcaption strong { color: var(--heading); font-weight: 700; }
.tree figcaption code { font-size: 0.76rem; }
.tree .svg-wrap svg { max-width: 400px; margin: 0 auto; }
.edge { stroke: #cbd5e1; stroke-width: 2; fill: none; transition: stroke 0.15s; }
.edge.zero { stroke-dasharray: 6 5; }
.edge.on-path { stroke: var(--v1); stroke-width: 3.6; }
.edge.dead { stroke: #e2e8f0; }
.edge-label { font: 600 12px var(--font-mono); fill: #94a3b8; }
.edge-label.on-path { fill: var(--v1); }
.test circle { fill: white; stroke: #475569; stroke-width: 1.8; }
.test text { font: 700 15px var(--font-mono); fill: var(--heading); text-anchor: middle; dominant-baseline: central; }
.test.on-path circle { stroke: var(--v1); stroke-width: 2.8; fill: var(--v1-bg); }
.leaf .leaf-frame { fill: white; stroke: #94a3b8; stroke-width: 1.6; }
.leaf .name { font: 700 15px var(--font-mono); fill: var(--heading); text-anchor: middle; }
.leaf.reached .leaf-frame { stroke: var(--v1); stroke-width: 3; fill: var(--v1-bg); }
.leaf.unreachable { opacity: 0.38; }
.leaf.unreachable .leaf-frame { stroke-dasharray: 4 3; }
.leaf .unreachable-label { font: 600 10.5px var(--font); fill: var(--bad); text-anchor: middle; }
.ite-bottom { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.6rem 1.6rem; align-items: start; margin-top: 0.4rem; }
@media (max-width: 760px) { .ite-bottom { grid-template-columns: minmax(0, 1fr); } }
.regions-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.regions { border-collapse: separate; border-spacing: 4px; margin-left: -4px; }
.regions th { font: 600 0.76rem var(--font-mono); color: var(--text-light); padding: 0.2rem 0.4rem; text-align: center; white-space: nowrap; }
.regions td { font: 0.8rem var(--font-mono); padding: 0.45rem 0.7rem; background: var(--bg-alt); border-radius: 6px; color: #334155; white-space: nowrap; }
.regions td.current { background: var(--v1); color: white; }
.regions td .leaf-val { font-weight: 700; }

/* --- the cycle of implications --- */
.cycle-edge { stroke-width: 3; fill: none; stroke-linecap: round; transition: stroke 0.15s; }
.cycle-edge.ok { stroke: var(--ok); } .cycle-edge.bad { stroke: var(--bad); stroke-width: 3.6; }
.arrowhead.ok { fill: var(--ok); } .arrowhead.bad { fill: var(--bad); }
.cycle-label { font: 600 12px var(--font-mono); }
.cycle-label.ok { fill: #047857; } .cycle-label.bad { fill: #b91c1c; }
.cycle-label .value { font-weight: 800; }
.vertex circle { stroke-width: 2.4; transition: fill 0.15s; }
.vertex.v1 circle { fill: var(--v1); stroke: var(--v1); }
.vertex.v0 circle { fill: white; stroke: var(--v0); }
.vertex .name { font: 700 17px var(--font-mono); text-anchor: middle; }
.vertex .value { font: 600 11.5px var(--font-mono); text-anchor: middle; }
.vertex.v1 text { fill: white; } .vertex.v0 text { fill: #475569; }
.summary { font-size: 0.86rem !important; margin-top: 0.5rem; }
.expansion { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.2rem; }
.monomial { font: 0.78rem var(--font-mono); padding: 0.22rem 0.6rem; border-radius: 999px; border: 1px solid var(--border);
            background: white; color: #94a3b8; white-space: nowrap; }
.monomial .clash { color: var(--bad); font-weight: 700; }
.monomial.remains { border-color: var(--ok); color: #047857; background: var(--prf-bg); font-weight: 700; }

/* --- link to Boole Lab and the self-check line --- */
.to-boole-lab { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center; margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--border); }
.to-boole-lab a { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 700; font-size: 0.88rem; color: var(--prf);
                  text-decoration: none; padding: 0.4rem 0.9rem; border: 1.5px solid var(--prf); border-radius: 999px; background: var(--prf-bg);
                  transition: background 0.12s, color 0.12s; }
.to-boole-lab a:hover { background: var(--prf); color: white; }
.to-boole-lab .command { font-size: 0.78rem; color: var(--text-light); }
.to-boole-lab .command code { font-size: 0.95em; }
.self-check { font-size: 0.8rem; color: var(--text-light); display: flex; align-items: center; gap: 0.5rem; margin: 0.2rem 0 0; min-height: 1.2rem; }
.self-check.ok::before { content: ""; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.self-check.bad { color: var(--bad); font-weight: 600; }

@media (max-width: 600px) {
  .regions td { white-space: normal; padding: 0.4rem 0.5rem; font-size: 0.75rem; }
  .topic-card { padding: 1rem 0.9rem 0.9rem; border-radius: 10px; }
  .topic-card > h2 { font-size: 1.05rem; }
  .bit { min-width: 3.9rem; font-size: 0.86rem; }
  code.formula { font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; } }
