/* CodeCraft interactive components: the shared stylesheet for the components that declare 'styles' => ['labs.css'].
   Independent of article.css (and of the article redesign): every rule starts with a .ccl- class that only component markup carries,
   the colours are custom properties on .ccl with fallbacks, so the component looks right on any page background that is dark-ish
   (it paints its own panel). Linked once, right before the first component that needs it (components/ArticleComponents.php).
   Component-specific blocks: one section each, prefix .ccl-<short id>-. */

.ccl {
    --ccl-bg: #0d1424;
    --ccl-surface: rgba(255, 255, 255, .045);
    --ccl-line: rgba(170, 195, 240, .22);
    --ccl-text: #dfe5f1;
    --ccl-muted: #a3aec6;                 /* 7.4:1 on --ccl-bg */
    --ccl-head: #f1f4fa;
    --ccl-accent: #5ee6f2;
    --ccl-accent-bg: rgba(94, 230, 242, .12);
    --ccl-warm: #ffd479;
    --ccl-font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
    box-sizing: border-box;
    margin: 2rem 0;
    padding: 1.25rem;
    border: 1px solid var(--ccl-line);
    border-radius: 14px;
    background: var(--ccl-bg);
    color: var(--ccl-text);
    font: 400 1rem/1.55 var(--ccl-font);
    text-align: left;
}
.ccl *, .ccl *::before, .ccl *::after { box-sizing: border-box; }
.ccl .ccl-head h3 { margin: 0; font: 650 1.125rem/1.3 var(--ccl-font); color: var(--ccl-head); }
.ccl .ccl-head p { margin: .375rem 0 0; font-size: .9375rem; color: var(--ccl-muted); }
.ccl .ccl-stage { margin-top: 1rem; padding: 1rem .75rem; border-radius: 10px; background: var(--ccl-surface); overflow: hidden; }

.ccl .ccl-controls { display: flex; flex-wrap: wrap; gap: .625rem; margin-top: 1rem; }
.ccl .ccl-btn {
    min-height: 44px; padding: 0 1.125rem; border: 1px solid var(--ccl-accent); border-radius: 999px;
    background: var(--ccl-accent-bg); color: var(--ccl-accent); font: 600 .9375rem var(--ccl-font); cursor: pointer;
    touch-action: manipulation; transition: background .15s, border-color .15s, transform .1s;
}
.ccl .ccl-btn:hover:not(:disabled) { background: rgba(94, 230, 242, .22); }
.ccl .ccl-btn:active:not(:disabled) { transform: translateY(1px); }
.ccl .ccl-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ccl .ccl-btn:disabled { opacity: .45; cursor: default; }
.ccl .ccl-btn--ghost { border-color: var(--ccl-line); background: transparent; color: var(--ccl-text); }
.ccl .ccl-btn--ghost:hover:not(:disabled) { background: var(--ccl-surface); border-color: var(--ccl-muted); }

.ccl .ccl-status { min-height: 3.1em; margin: .875rem 0 0; font-size: .9375rem; line-height: 1.5; color: var(--ccl-text); }
.ccl-warn { box-sizing: border-box; margin: .5rem 0; font-family: system-ui, "Segoe UI", Arial, sans-serif; line-height: 1.5; padding: .5rem .75rem; border-left: 3px solid #ffd479; background: rgba(255, 212, 121, .1); color: #ffd479; font-size: .9rem; }
.ccl .ccl-tablewrap { margin-top: 1rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ccl .ccl-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.ccl .ccl-table caption { caption-side: top; padding: 0 0 .5rem; text-align: left; color: var(--ccl-muted); }
.ccl .ccl-table th, .ccl .ccl-table td { padding: .4rem .625rem; border-bottom: 1px solid var(--ccl-line); text-align: left; white-space: nowrap;  text-transform: none; letter-spacing: normal; vertical-align: middle; }
.ccl .ccl-table thead th { color: var(--ccl-muted); font-weight: 600;  font-size: .8125rem; }
.ccl .ccl-table tbody th { font-weight: 600; color: var(--ccl-head); }
.ccl .ccl-table tr.is-active { background: var(--ccl-accent-bg); box-shadow: inset 3px 0 0 var(--ccl-accent); }

/* ---- turing-machine ------------------------------------------------------------------------------------------------------------------- */
.ccl.ccl-tm { --cell: 46px; }
.ccl .ccl-tm-viewport {
    position: relative; height: calc(var(--cell) + 3.25rem); overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
            mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.ccl .ccl-tm-track { position: absolute; top: 0; left: 0; display: flex; padding-top: 0; transition: transform .38s cubic-bezier(.4, 0, .2, 1); will-change: transform; }
.ccl .ccl-tm-cell {
    flex: 0 0 var(--cell); width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--ccl-line); margin-right: -1px; background: rgba(255, 255, 255, .03);
    font: 600 1.25rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ccl-text);
    transition: background .25s, border-color .25s, color .25s, transform .25s;
}
.ccl .ccl-tm-cell--blank::before { content: "␣"; color: var(--ccl-muted); opacity: .55; font-weight: 400; }
.ccl .ccl-tm-cell.is-current { background: var(--ccl-accent-bg); border-color: var(--ccl-accent); color: var(--ccl-accent); transform: translateY(-2px); box-shadow: 0 0 0 1px var(--ccl-accent); z-index: 1; }
.ccl .ccl-tm-cell.is-written { animation: ccl-tm-write .45s ease-out; }
@keyframes ccl-tm-write { 0% { background: rgba(255, 212, 121, .5); transform: scale(1.14); } 100% { background: var(--ccl-accent-bg); transform: scale(1); } }
.ccl .ccl-tm-head { position: absolute; left: 50%; top: calc(var(--cell) + .4rem); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; line-height: 1.1; }
.ccl .ccl-tm-arrow { color: var(--ccl-accent); font-size: 1.15rem; transform: rotate(180deg); }
.ccl .ccl-tm-headlabel { margin-top: .15rem; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ccl-muted); }
.ccl .ccl-tm-readout { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; justify-content: center; margin: .75rem 0 0; padding: 0; }
.ccl .ccl-tm-readout > div { text-align: center; min-width: 5.5rem; }
.ccl .ccl-tm-readout dt { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ccl-muted); font-weight: 600; }
.ccl .ccl-tm-readout dd { margin: .1rem 0 0; font: 650 1.25rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ccl-head); }

@media (max-width: 575.98px) {
    .ccl { padding: 1rem .875rem; margin: 1.5rem 0; border-radius: 12px; }
    .ccl.ccl-tm { --cell: 38px; }
    .ccl .ccl-tm-cell { font-size: 1.05rem; }
    .ccl .ccl-controls .ccl-btn { flex: 1 1 calc(50% - .625rem); padding: 0 .5rem; }
    .ccl .ccl-tm-readout { gap: .5rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ccl, .ccl *, .ccl *::before, .ccl *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
    .ccl .ccl-tm-cell.is-current { outline: 3px solid Highlight; }
    .ccl .ccl-table tr.is-active { outline: 2px solid Highlight; }
}

@media (max-width: 575.98px) {
    .ccl .ccl-table { font-size: .8125rem; }
    .ccl .ccl-table th, .ccl .ccl-table td { padding: .35rem .3rem; white-space: normal; }
    .ccl .ccl-table thead th { font-size: .7rem; }
}
