/* Stuck pixel fixer: the form on the page, and the fullscreen stage. */

/* ---- Form ---- */

/* Visually hidden, still there for keyboards and screen readers. */
.sp-sr {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

#sp-form legend {
    font-weight: 700;
    margin-bottom: 1rem;
}

/* A colour picker is one full-width row of swatches, each growing to share
   the width, 2px apart. The chosen one gets a 1px white border and, outside
   it, a 10px frame in the link blue that spills out over its neighbours and
   the row's edge; the row's margins leave room for that. */
.sp-swatches {
    display: flex;
    gap: 2px;
    margin: 0 10px 1.25rem;
}

.sp-swatch {
    position: relative;
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    cursor: pointer;
}

.sp-chip,
.sp-chip-unknown {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    height: 3rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background: #fff;
}

.sp-chip-unknown {
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.sp-swatch input:checked + span {
    position: relative;
    z-index: 1;
    border-color: #fff;
    box-shadow: 0 0 0 10px var(--link);
}

.sp-swatch input:focus-visible + span {
    z-index: 2;
    outline: 3px solid var(--link);
    outline-offset: 12px;
}

.sp-sub {
    margin: 0 0 0.35rem;
    font-size: 0.875em;
    color: var(--muted-color);
}

.sp-note {
    font-size: 0.875em;
    color: var(--muted-color);
}

/* The diagnosis line reads as the answer to the pixel question, so it sits
   close under that row: just the room the chosen swatch's frame needs. */
.sp-pixel-fieldset {
    margin-bottom: 0;
}

.sp-pixel-fieldset .sp-swatches {
    margin-bottom: 20px;
}

#sp-diagnosis {
    min-height: 3.2em;
}

.sp-settings {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
}

/* Button groups that behave as radio buttons: connected segments, the chosen
   one filled with the link blue. */
.sp-segments {
    display: inline-flex;
}

.sp-segments label {
    display: flex;
    margin: 0;
    cursor: pointer;
}

.sp-segments label > span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    min-height: 3.75rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border-strong);
    margin-left: -1px;
    background: var(--panel-bg);
    color: var(--text);
    font-weight: 600;
}

.sp-segments label:first-child > span {
    margin-left: 0;
    border-radius: 8px 0 0 8px;
}

.sp-segments label:last-child > span {
    border-radius: 0 8px 8px 0;
}

.sp-segments label:hover > span {
    background: #eef0f1;
}

.sp-segments input:checked + span {
    position: relative;
    z-index: 1;
    border-color: var(--link);
    background: var(--link);
    color: #fff;
}

.sp-segments input:focus-visible + span {
    position: relative;
    z-index: 2;
    outline: 3px solid var(--link);
    outline-offset: 2px;
}

/* The circle-size choices draw the circle itself, at the size it will be
   on the stage, in the stage ring's own black-and-white style. */
.sp-ring-sample {
    display: block;
    flex: none;
    box-sizing: border-box;
    border-radius: 50%;
    border: 1px solid #000;
    box-shadow: 0 0 0 1px #fff, inset 0 0 0 1px #fff;
}

/* The one call to action on the page, in the link blue like the chosen
   options, rather than the site's near-black primary. */
#sp-find {
    --background-color: var(--link);
    --border-color: var(--link);
    --color: #fff;
    display: inline-flex;
    flex-flow: row !important;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

#sp-find:is(:hover, :active, :focus):not(:disabled) {
    --background-color: var(--link-hover);
    --border-color: var(--link-hover);
}

.sp-find-icon {
    flex: none;
}

/* ---- Stage ---- */

#sp-stage {
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#sp-stage.sp-target {
    cursor: none;
}

/* Hollow, so the pixel stays visible through it, and ringed in both
   black and white so it shows on every background. */
#sp-ring,
#sp-patch {
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 50%;
    pointer-events: none;
}

#sp-ring {
    border: 1px solid #000;
    box-shadow: 0 0 0 1px #fff, inset 0 0 0 1px #fff;
}

#sp-patch {
    display: none;
}

.sp-panel {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    width: max-content;
    max-width: min(36rem, 92vw);
    max-height: 46vh;
    overflow: auto;
    padding: 0.6rem 0.9rem;
    border-radius: 0.6rem;
    background: rgba(20, 20, 20, 0.9);
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: default;
}

.sp-panel button {
    display: inline-block;
    width: auto;
    margin: 0 0 0 0.5rem;
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
}

.sp-top {
    top: 1rem;
}

.sp-bottom {
    bottom: 1rem;
}

#sp-stage.sp-target #sp-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#sp-pill button {
    flex: none;
    margin: 0;
}

/* Pico colours text through these; the panels are dark. */
.sp-panel {
    --color: #fff;
    --h2-color: #fff;
    --muted-color: #c8c8c8;
}

.sp-panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.sp-panel p {
    margin: 0 0 0.6rem;
}

.sp-panel label {
    margin: 0.2rem 0 0.75rem;
}

/* The site's primary is near-black, which vanishes on a dark panel. */
.sp-panel button:not(.secondary) {
    --background-color: #fff;
    --border-color: #fff;
    --color: #111;
}

.sp-panel [type=checkbox] {
    --background-color: #fff;
    --border-color: #fff;
}

.sp-panel [type=checkbox]:checked {
    --background-color: var(--primary);
    --border-color: #fff;
}

#sp-confirm button,
#sp-check button {
    margin: 0.2rem 0.5rem 0.6rem 0;
}

/* Only the warning text scrolls; the title, the checkbox and the buttons
   always stay in view, since a phone shows no scrollbar to hint at them. */
#sp-stage.sp-confirm #sp-confirm {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sp-confirm h2,
.sp-controls {
    flex: none;
}

.sp-controls {
    padding-top: 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.25);
}

.sp-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    touch-action: pan-y;
    margin-bottom: 0.4rem;
}

#sp-stage.sp-run #sp-run,
#sp-stage.sp-check #sp-check {
    display: block;
}

/* During a run only the circle shows anything; the rest of the screen is
   black (and on OLED, switched off). */
#sp-stage.sp-run {
    background: #000 !important;
}

#sp-stage.sp-run #sp-patch {
    display: block;
}

#sp-stage.sp-run #sp-ring {
    display: none;
}

.sp-disclaimer {
    margin: 0 0 1.25rem;
    padding: 0.85rem 1rem;
    font-size: 0.8em;
    color: var(--muted-color);
    border: 1px solid var(--muted-border-color);
    border-radius: var(--border-radius);
}
