/* Manchester Labs - public site: the instrument front panel */

.site {
    --page: min(1200px, 100% - 2 * var(--s4));
}

.topbar,
.instrument,
.module,
.rear-panel > * {
    width: var(--page);
    margin-inline: auto;
}

/* ---------------------------------------------------------------------------
   Top edge of the instrument
--------------------------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    gap: var(--s4);
    min-height: 60px;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.brand-trace {
    stroke: var(--amber);
}

.brand-name {
    white-space: nowrap;
    font-family: var(--font-label);
    font-weight: 600;
    font-size: var(--text-md);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: var(--s2);
    margin-left: auto;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    gap: var(--s2);
}

/* ---------------------------------------------------------------------------
   Nameplate
--------------------------------------------------------------------------- */
.instrument {
    padding-top: var(--s7);
}

.nameplate {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: end;
    gap: var(--s3) var(--s6);
    margin-bottom: var(--s5);
}

.nameplate-name {
    font-family: var(--font-label);
    font-weight: 700;
    font-size: var(--text-3xl);
    line-height: 0.92;
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

.nameplate-summary {
    max-width: 52ch;
    color: var(--ink-dim);
    font-size: var(--text-md);
    line-height: 1.55;
}

/* ---------------------------------------------------------------------------
   The scope: bezel, screen, softkeys. The screen shares the bezel's rows
   (subgrid) so each softkey lines up with its label on the screen.
--------------------------------------------------------------------------- */
.scope {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    grid-template-rows: auto minmax(260px, 1fr) auto auto;
    column-gap: var(--s4);
    margin: 0;
    padding: var(--s4);
    background: var(--bezel);
    border-radius: var(--radius-lg);
    box-shadow: var(--relief-raised);
}

.scope-screen {
    grid-column: 1;
    grid-row: 1 / span 3;
    display: grid;
    grid-template-rows: subgrid;
    padding: var(--s3) var(--s4);
    background: var(--scope);
    color: var(--scope-ink);
    border-radius: var(--radius);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), inset 0 0 0 1px #050607;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

.scope-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s2) var(--s5);
    padding-bottom: var(--s2);
    color: var(--scope-dim);
}

.scope-ch {
    display: inline-flex;
    align-items: center;
    gap: var(--s2);
}

/* Legend keys mirror the mark: a short line in the channel colour */
.scope-key {
    display: inline-block;
    width: 14px;
    height: 2px;
    border-radius: 1px;
}

.scope-key--ch1 { background: var(--scope-ch1); }
.scope-key--ch2 { background: var(--scope-ch2); }

.scope-now {
    color: var(--scope-ink);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.scope-timebase {
    margin-left: auto;
}

.scope-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 118px;
    min-height: 0;
    border: 1px solid var(--scope-grid-major);
    border-radius: 2px;
}

.scope-plot {
    position: relative;
    min-height: 240px;
    border-radius: 2px;
}

.scope-plot:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--amber);
}

.scope-plot svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.scope-menu {
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    row-gap: var(--s2);
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 1px solid var(--scope-grid-major);
}

.scope-menu li {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 var(--s3);
    border-bottom: 1px solid var(--scope-grid);
    transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.scope-menu li:last-child {
    border-bottom: 0;
}

.scope-menu b {
    font-family: var(--font-label);
    font-weight: 600;
    font-size: var(--text-sm);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--scope-ink);
}

.scope-menu span {
    color: var(--scope-dim);
    font-size: var(--text-2xs);
}

/* Pressing or pointing at a softkey lights its on-screen label, in inverse video */
.scope:has(.softkey[data-menu="measure"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="measure"],
.scope:has(.softkey[data-menu="build"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="build"],
.scope:has(.softkey[data-menu="host"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="host"],
.scope:has(.softkey[data-menu="contact"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="contact"] {
    background: var(--scope-ink);
}

.scope:has(.softkey[data-menu="measure"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="measure"] :is(b, span),
.scope:has(.softkey[data-menu="build"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="build"] :is(b, span),
.scope:has(.softkey[data-menu="host"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="host"] :is(b, span),
.scope:has(.softkey[data-menu="contact"]:is(:hover, :focus-visible, :active)) .scope-menu [data-menu="contact"] :is(b, span) {
    color: var(--scope);
}

.scope-foot {
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding-top: var(--s2);
}

.scope-measure {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1) var(--s5);
    margin: 0;
}

.scope-measure div {
    display: flex;
    gap: var(--s2);
}

.scope-measure dt {
    color: var(--scope-dim);
}

.scope-measure dd {
    margin: 0;
    color: var(--scope-ink);
    font-variant-numeric: tabular-nums;
}

.scope-hint {
    margin: 0 0 0 auto;
    white-space: nowrap;
    color: var(--scope-dim);
    font-size: var(--text-xs);
    visibility: hidden;
}

.scope--live .scope-hint { visibility: visible; }

/* No data: no hint; Retry sits beside Data at the right */
.scope:not(.scope--live) .scope-hint { display: none; }
#scope-retry-btn { margin-left: auto; }
#scope-retry-btn:not([hidden]) + .scope-data-btn { margin-left: 0; }

.scope-data-btn {
    min-height: 24px;
    padding: 2px var(--s3);
    background: transparent;
    color: var(--scope-ink);
    border: 1px solid var(--scope-grid-major);
    border-radius: var(--radius-sm);
    font-family: var(--font-label);
    font-weight: 600;
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}

.scope-data-btn:hover,
.scope-data-btn[aria-expanded="true"] {
    border-color: var(--scope-dim);
}

/* Plot internals (drawn by site.js) */
.scope-grid-line { stroke: var(--scope-grid); stroke-width: 1; shape-rendering: crispEdges; }
.scope-grid-axis { stroke: var(--scope-grid-major); stroke-width: 1; shape-rendering: crispEdges; }
.scope-tick { stroke: var(--scope-grid-major); stroke-width: 1; shape-rendering: crispEdges; }
.scope-trace { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.scope-trace--ch1 { stroke: var(--scope-ch1); }
.scope-trace--ch2 { stroke: var(--scope-ch2); }
.scope-axis-text { fill: var(--scope-dim); font-family: var(--font-mono); font-size: 10px; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--scope); stroke-width: 3px; stroke-linejoin: round; }
.scope-nosignal { fill: var(--scope-dim); font-family: var(--font-mono); font-size: 11px; }
.scope-nosignal-zone { fill: url(#scope-hatch); }
.scope-overrange path { fill: var(--scope-ink); }
.scope-overrange text { fill: var(--scope-ink); }
.scope-cursor { stroke: var(--scope-ink); stroke-width: 1; opacity: 0.6; shape-rendering: crispEdges; }
.scope-dot { stroke: var(--scope); stroke-width: 2; }
.scope-dot--ch1 { fill: var(--scope-ch1); }
.scope-dot--ch2 { fill: var(--scope-ch2); }

.scope-readout {
    position: absolute;
    top: var(--s2);
    padding: var(--s1) var(--s2);
    background: rgba(12, 14, 17, 0.92);
    border: 1px solid var(--scope-grid-major);
    border-radius: var(--radius-sm);
    color: var(--scope-ink);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    line-height: 1.5;
    white-space: nowrap;
    pointer-events: none;
}

.scope-readout b {
    font-weight: 600;
    font-size: var(--text-xs);
}

.scope-readout .k {
    display: inline-block;
    width: 10px;
    height: 2px;
    margin-right: var(--s1);
    vertical-align: middle;
}

/* One sweep of the trace on first draw */
.scope-sweep {
    animation: scope-sweep 1.6s var(--ease) 0.15s both;
}

@keyframes scope-sweep {
    from { clip-path: inset(0 100% 0 0); }
    to { clip-path: inset(0 0 0 0); }
}

/* Physical softkeys beside the screen */
.softkey-col {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-rows: repeat(4, 1fr);
    row-gap: var(--s2);
    /* match the screen's border inset so keys sit level with their labels */
    padding-block: 1px;
}

.softkey {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bezel);
    color: var(--ink);
    border-radius: var(--radius);
    box-shadow: inset 0 1px 0 var(--bezel-hi), 0 2px 0 var(--bezel-lo), 0 3px 6px rgba(0, 0, 0, 0.3);
    font-family: var(--font-label);
    font-weight: 600;
    font-size: var(--text-sm);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    text-decoration: none;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.softkey:hover {
    background: var(--bezel-hover);
}

.softkey:active {
    transform: translateY(2px);
    box-shadow: var(--relief-pressed);
}

.scope-caption {
    grid-column: 1 / -1;
    grid-row: 4;
    padding-top: var(--s3);
    color: var(--ink-dim);
    font-size: var(--text-sm);
}

.scope-table-wrap .unit {
    text-transform: none;
}

.scope-table-wrap {
    margin-top: var(--s3);
    max-height: 320px;
    overflow: auto;
}

/* ---------------------------------------------------------------------------
   Modules
--------------------------------------------------------------------------- */
.module {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--s5) var(--s7);
    margin-top: var(--s8);
    padding-top: var(--s5);
    border-top: 1px solid var(--line);
    scroll-margin-top: var(--s4);
}

.module-key {
    color: var(--amber-ink);
    margin-bottom: var(--s2);
}

.module-title {
    font-family: var(--font-label);
    font-weight: 600;
    font-size: var(--text-2xl);
    line-height: 1;
    margin-bottom: var(--s3);
}

.module-lead {
    color: var(--ink-dim);
    max-width: 44ch;
}

.module-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--s4);
    align-content: start;
}

.module-body--wide {
    grid-template-columns: minmax(0, 1fr);
}

.card {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    padding: var(--s5);
}

.card-title {
    font-size: var(--text-md);
    font-weight: 600;
}

.card p {
    color: var(--ink-dim);
    font-size: var(--text-sm);
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1);
    margin: auto 0 0;
    padding: var(--s3) 0 0;
    list-style: none;
}

.readouts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s4);
    margin: 0;
    padding: var(--s4) var(--s5);
}

.readouts dd {
    margin: 0;
    font-size: var(--text-lg);
}

.services {
    margin: 0;
    padding: 0;
    list-style: none;
}

.services li {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: var(--s4);
    align-items: baseline;
    padding: var(--s3) 0;
    border-bottom: 1px solid var(--line);
}

.services p {
    color: var(--ink);
    font-size: var(--text-sm);
}

.contact {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    padding: var(--s5);
    color: var(--ink);
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.contact:hover {
    background: var(--bezel-hover);
}

.contact:active {
    transform: translateY(1px);
    box-shadow: var(--relief-pressed);
}

.contact-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------
   Rear panel
--------------------------------------------------------------------------- */
.rear-panel {
    margin-top: var(--s8);
    padding: var(--s6) 0 var(--s5);
    background: var(--panel-sunk);
    border-top: 1px solid var(--line);
}

.rating-plate {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s4);
    margin: 0 auto var(--s5);
    padding: var(--s4) var(--s5);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.rating-plate dd {
    margin: var(--s1) 0 0;
    font-size: var(--text-sm);
}

.rear-meta a {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
}

.rear-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    color: var(--ink-dim);
    font-size: var(--text-sm);
}

/* ---------------------------------------------------------------------------
   Responsive
--------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .nameplate {
        grid-template-columns: minmax(0, 1fr);
    }

    .module {
        grid-template-columns: minmax(0, 1fr);
        margin-top: var(--s7);
    }

    .readouts,
    .rating-plate {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phones: the logo mark stands alone (the name is the heading just below) so the
   lab status can keep its words */
@media (max-width: 480px) {
    .topbar .brand-name {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (max-width: 720px) {
    .topbar-status-detail {
        display: none;
    }

    .instrument {
        padding-top: var(--s6);
    }

    .scope {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        padding: var(--s3);
        row-gap: var(--s3);
    }

    .scope-screen {
        grid-row: auto;
        grid-template-rows: auto minmax(200px, auto) auto;
        padding: var(--s2) var(--s3);
    }

    .scope-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .scope-plot {
        min-height: 200px;
    }

    .scope-menu {
        display: none;
    }

    .softkey-col {
        grid-column: 1;
        grid-row: auto;
        grid-template-rows: none;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--s2);
    }

    .softkey {
        min-height: 44px;
    }

    .scope-caption {
        grid-row: auto;
        padding-top: 0;
    }

    .scope-timebase {
        margin-left: 0;
    }

    .scope-foot {
        flex-wrap: wrap;
        row-gap: var(--s2);
    }

    .scope-measure {
        flex-basis: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scope-hint {
        margin-left: 0;
    }

    .scope-data-btn {
        margin-left: auto;
    }

    .services li {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--s1);
    }

    .rear-meta {
        flex-direction: column;
    }
}

/* ---------------------------------------------------------------------------
   404
--------------------------------------------------------------------------- */
.notfound {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--s4);
    width: min(560px, 100% - 2 * var(--s4));
    min-height: calc(100vh - 61px);
    padding-block: var(--s6);
    margin-inline: auto;
}

.notfound-screen {
    position: relative;
    width: 100%;
    height: 160px;
    padding: var(--s3);
    background: var(--scope);
    border-radius: var(--radius);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 0 var(--s3) var(--bezel);
    margin-bottom: var(--s5);
}

.notfound-screen svg {
    width: 100%;
    height: 100%;
}

.notfound-grid line {
    stroke: var(--scope-grid);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.notfound-trace {
    fill: none;
    stroke: var(--scope-ch1);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.notfound-code {
    position: absolute;
    top: var(--s3);
    right: var(--s4);
    color: var(--scope-dim);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

.notfound-title {
    font-family: var(--font-label);
    font-weight: 700;
    font-size: var(--text-2xl);
    line-height: 1;
    text-transform: uppercase;
}

.notfound-text {
    color: var(--ink-dim);
}

.notfound-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s2);
    margin-top: var(--s2);
}
