/* ============================================================
   Device testing tools - shared presentation
   ============================================================

   BUILT ON THE SITE'S OWN PALETTE, not a fresh one. The first
   version of this file invented its own blues and greys, and
   the result was a set of pages that plainly did not belong to
   a2z.tools - correct, and visibly bolted on.

   Every colour below comes from WebsiteTemplate/assets/css/
   style.css, which is what the rest of the site is painted
   with:

     #58bae4  the accent - the same blue a homepage card border
              turns on hover
     #3f89a9  its darker partner, for hover and pressed states
     #44475a  secondary text and headings
     #212529  body text
     #f3f2f1  #f9f9f9  #e4e8f6   the neutral surfaces
     #b6b4b4  the border weight the homepage cards use

   Panels and stat cards deliberately echo .icon-box-list - 15px
   radius, a 1px #b6b4b4 border, and the same lift-and-tint on
   hover - so a tool page reads as the same furniture as the
   tool grid that led to it.

   BOTH THEMES. The layout puts theme-light or theme-dark on the
   body from the cookie, and style-dark.css repaints the site
   black with #282424 cards. Without the dark block below, these
   tools would be white rectangles on a black page. Colours are
   therefore defined once as custom properties and re-pointed
   there rather than restated.

   DIAGNOSTIC COLOURS ARE NOT BRAND COLOURS. Pass and fail stay
   green and red in both themes, because that meaning is not
   ours to restyle - and every verdict is a WORD as well as a
   colour, since a red pill means nothing to somebody who cannot
   tell it from the green one.
   ============================================================ */

:root {
    --dt-accent:        #58bae4;
    --dt-accent-strong: #3f89a9;
    --dt-accent-tint:   #e4e8f6;

    --dt-ink:    #212529;
    --dt-ink-2:  #44475a;
    --dt-ink-3:  #6c757d;

    --dt-surface:   #ffffff;
    --dt-surface-2: #f9f9f9;
    --dt-surface-3: #f3f2f1;

    --dt-border:        #d3d3d4;
    --dt-border-strong: #b6b4b4;

    --dt-ok-bg:   #e8f6ee;  --dt-ok-fg:   #1b6b45;  --dt-ok-bd:   #b7e0c9;
    --dt-warn-bg: #fdf4e3;  --dt-warn-fg: #8a5a12;  --dt-warn-bd: #f0d9a8;
    --dt-bad-bg:  #fbeceb;  --dt-bad-fg:  #98241d;  --dt-bad-bd:  #f0c2be;

    --dt-shadow: 0 10px 29px 0 rgba(68, 88, 144, .10);
}

.theme-dark {
    --dt-accent-tint: #22333c;

    --dt-ink:    #ffffff;
    --dt-ink-2:  #e9e9ea;
    --dt-ink-3:  #b1b1b1;

    /* #282424 is the card colour the site's own dark theme uses. */
    --dt-surface:   #282424;
    --dt-surface-2: #1e1c1c;
    --dt-surface-3: #201e1e;

    --dt-border:        #4a4646;
    --dt-border-strong: #6f6a6a;

    --dt-ok-bg:   #14301f;  --dt-ok-fg:   #7ee2a8;  --dt-ok-bd:   #2c6244;
    --dt-warn-bg: #33260f;  --dt-warn-fg: #f5c975;  --dt-warn-bd: #6b4f1c;
    --dt-bad-bg:  #341715;  --dt-bad-fg:  #f5a29b;  --dt-bad-bd:  #6d2f2a;

    --dt-shadow: 0 10px 29px 0 rgba(0, 0, 0, .45);
}

.dt-wrap {
    max-width: 880px;
    margin: 0 auto 28px;
}

.dt-panel {
    background: var(--dt-surface);
    border: 1px solid var(--dt-border-strong);
    border-radius: 15px;
    padding: 22px;
    box-shadow: var(--dt-shadow);
    color: var(--dt-ink);
}

/* The interactive target. Big, obviously usable, and it must not
   select text or show a caret when clicked repeatedly. */
.dt-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-height: 260px;
    border: 2px dashed var(--dt-border-strong);
    border-radius: 15px;
    background: var(--dt-surface-2);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    text-align: center;
    padding: 20px;
    transition: background .3s ease-in-out, border-color .3s ease-in-out;
}

.dt-stage:hover { background: var(--dt-surface-3); border-color: var(--dt-accent); }

.dt-stage.is-running {
    border-style: solid;
    border-color: var(--dt-accent);
    background: var(--dt-accent-tint);
}

.dt-stage:focus-visible {
    outline: 3px solid var(--dt-accent);
    outline-offset: 3px;
}

.dt-stage-hint {
    font-size: 15px;
    color: var(--dt-ink-2);
    max-width: 44ch;
}

.dt-stage-big {
    font-size: 54px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--dt-ink);
    font-variant-numeric: tabular-nums;
}

.dt-stage-sub {
    margin-top: 6px;
    font-size: 14px;
    color: var(--dt-ink-3);
}

/* Readings ------------------------------------------------- */

.dt-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

/* The same lift the homepage cards use, so these read as the
   same component family rather than a lookalike. */
.dt-stat {
    border: 1px solid var(--dt-border-strong);
    border-radius: 15px;
    padding: 14px;
    background: var(--dt-surface);
    transition: transform .3s ease-in-out, border-color .3s ease-in-out;
}

.dt-stat:hover {
    transform: translateY(-5px);
    border-color: var(--dt-accent);
}

.dt-stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--dt-ink-3);
}

.dt-stat-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--dt-ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
}

.dt-stat-note {
    font-size: 12.5px;
    color: var(--dt-ink-3);
}

/* Verdicts. Always paired with a word - see the note at the top. */

.dt-verdict {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 7px 15px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
}

.dt-verdict-ok   { background: var(--dt-ok-bg);   color: var(--dt-ok-fg);   border-color: var(--dt-ok-bd); }
.dt-verdict-warn { background: var(--dt-warn-bg); color: var(--dt-warn-fg); border-color: var(--dt-warn-bd); }
.dt-verdict-bad  { background: var(--dt-bad-bg);  color: var(--dt-bad-fg);  border-color: var(--dt-bad-bd); }
.dt-verdict-mute { background: var(--dt-surface-3); color: var(--dt-ink-2); border-color: var(--dt-border); }

/* Controls -------------------------------------------------- */

.dt-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 16px 0;
}

.dt-btn {
    border: 1px solid var(--dt-border-strong);
    background: var(--dt-surface);
    color: var(--dt-ink-2);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease-in-out;
}

.dt-btn:hover { border-color: var(--dt-accent); color: var(--dt-ink); }
.dt-btn:disabled { opacity: .55; cursor: default; }
.dt-btn:disabled:hover { border-color: var(--dt-border-strong); }

.dt-btn-primary {
    background: var(--dt-accent);
    border-color: var(--dt-accent);
    color: #fff;
}

.dt-btn-primary:hover {
    background: var(--dt-accent-strong);
    border-color: var(--dt-accent-strong);
    color: #fff;
}

.dt-seg {
    display: inline-flex;
    border: 1px solid var(--dt-border-strong);
    border-radius: 10px;
    overflow: hidden;
}

.dt-seg button {
    border: 0;
    background: var(--dt-surface);
    color: var(--dt-ink-2);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-right: 1px solid var(--dt-border);
    transition: all .3s ease-in-out;
}

.dt-seg button:last-child { border-right: 0; }
.dt-seg button:hover { background: var(--dt-surface-3); }

.dt-seg button[aria-pressed="true"] {
    background: var(--dt-accent);
    color: #fff;
}

/* Event log ------------------------------------------------- */

.dt-log {
    margin-top: 18px;
    max-height: 230px;
    overflow-y: auto;
    border: 1px solid var(--dt-border-strong);
    border-radius: 15px;
}

.dt-log table { width: 100%; margin: 0; font-size: 13.5px; color: var(--dt-ink); }

.dt-log th, .dt-log td {
    padding: 9px 13px;
    border-bottom: 1px solid var(--dt-border);
    text-align: left;
}

.dt-log th {
    background: var(--dt-surface-3);
    color: var(--dt-ink-2);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.dt-log td { font-variant-numeric: tabular-nums; }
.dt-log tr:last-child td { border-bottom: 0; }
.dt-log .is-bad { color: var(--dt-bad-fg); font-weight: 600; }

.dt-empty {
    padding: 22px;
    text-align: center;
    color: var(--dt-ink-3);
    font-size: 14px;
}

/* A device tool is used ON the device being tested, which is very
   often a phone. */
@media (max-width: 575px) {
    .dt-panel { padding: 16px; }
    .dt-stage { min-height: 210px; }
    .dt-stage-big { font-size: 42px; }
}

/* Respect the setting. Nothing here needs motion to be understood. */
@media (prefers-reduced-motion: reduce) {
    .dt-stage, .dt-stat, .dt-btn, .dt-seg button { transition: none; }
    .dt-stat:hover { transform: none; }
}

/* ============================================================
   Screen resolution readout
   ============================================================ */

.sr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.sr-hero {
    grid-column: 1 / -1;
    text-align: center;
    padding: 26px 16px;
    border: 1px solid var(--dt-accent);
    border-radius: 15px;
    background: var(--dt-accent-tint);
}

.sr-hero .dt-stat-value { font-size: 44px; }

.sr-note {
    margin-top: 10px;
    font-size: 13px;
    color: var(--dt-warn-fg);
    background: var(--dt-warn-bg);
    border: 1px solid var(--dt-warn-bd);
    border-radius: 10px;
    padding: 11px 13px;
}

/* ============================================================
   Refresh rate
   ============================================================ */

.rr-stage {
    position: relative;
    overflow: hidden;
    min-height: 200px;
}

/* Moved every frame during a run, so there is something whose
   smoothness can be judged by eye while the numbers are taken. */
.rr-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 6px;
    width: 100%;
    background: var(--dt-border);
}

.rr-bar::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--rr-progress, 0%);
    background: var(--dt-accent);
}

/* ============================================================
   Touchscreen
   ============================================================ */

.ts-surface {
    position: relative;
    border: 2px dashed var(--dt-border-strong);
    border-radius: 15px;
    background: var(--dt-surface-2);
    overflow: hidden;
}

/* LOAD-BEARING. Without touch-action:none the browser keeps the
   gestures for scrolling and pinch-zoom and the canvas receives
   almost nothing - which is why most drawing tests appear broken
   on a phone. */
#tsCanvas {
    display: block;
    width: 100%;
    height: 420px;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: crosshair;
}

.ts-pointers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ts-pointer {
    position: absolute;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    opacity: .55;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 575px) {
    #tsCanvas { height: 340px; }
}

/* ============================================================
   Gamepad
   ============================================================ */

.gp-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.gp-btn {
    min-width: 46px;
    padding: 10px 11px;
    border: 1px solid var(--dt-border-strong);
    border-radius: 10px;
    background: var(--dt-surface);
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--dt-ink-2);
    font-variant-numeric: tabular-nums;
}

.gp-btn.is-on {
    background: var(--dt-accent);
    border-color: var(--dt-accent);
    color: #fff;
}

.gp-sticks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-top: 14px;
}

.gp-stick-pad {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 190px;
    margin: 0 auto;
    border: 1px solid var(--dt-border-strong);
    border-radius: 50%;
    background: var(--dt-surface-2);
}

/* The dead zone most games apply, drawn to scale - so an offset
   inside it is visibly inside it rather than a number to trust. */
.gp-stick-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 20%;
    height: 20%;
    margin: -10% 0 0 -10%;
    border: 1px dashed var(--dt-ink-3);
    border-radius: 50%;
}

.gp-stick-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-radius: 50%;
    background: var(--dt-accent);
    left: 50%;
    top: 50%;
}

.gp-stick-read {
    margin-top: 8px;
    text-align: center;
    font-size: 12.5px;
    color: var(--dt-ink-2);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Monitor / display test
   ============================================================ */

.mt-stage {
    display: block;
    width: 100%;
    height: 420px;
    border-radius: 15px;
    border: 1px solid var(--dt-border-strong);
    cursor: pointer;
}

/* In fullscreen the field IS the screen - any rounding, border or
   margin leaves a strip of browser background along the edge,
   which is precisely where backlight bleed is judged. */
.mt-panel:fullscreen .mt-stage,
.mt-panel:-webkit-full-screen .mt-stage {
    height: 100vh;
    width: 100vw;
    border: 0;
    border-radius: 0;
}

.mt-panel:fullscreen .mt-hidden-full,
.mt-panel:-webkit-full-screen .mt-hidden-full { display: none !important; }

.mt-panel:fullscreen,
.mt-panel:-webkit-full-screen { background: #000; padding: 0; border: 0; }

.mt-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
    margin-top: 12px;
}

.mt-name { font-size: 17px; font-weight: 700; color: var(--dt-ink); }
.mt-index { font-size: 13px; color: var(--dt-ink-3); font-variant-numeric: tabular-nums; }
.mt-hint { font-size: 14px; color: var(--dt-ink-2); flex: 1 1 100%; }

/* ============================================================
   Headphone / speaker test
   ============================================================ */

.hp-channels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.hp-ch {
    padding: 22px 14px;
    border: 1px solid var(--dt-border-strong);
    border-radius: 15px;
    background: var(--dt-surface);
    font-size: 15px;
    font-weight: 600;
    color: var(--dt-ink-2);
    cursor: pointer;
    text-align: center;
    transition: transform .3s ease-in-out, border-color .3s ease-in-out;
}

.hp-ch:hover {
    transform: translateY(-5px);
    border-color: var(--dt-accent);
    color: var(--dt-ink);
}

.hp-slider { width: 100%; margin-top: 6px; accent-color: var(--dt-accent); }

.hp-quiz {
    margin-top: 14px;
    padding: 15px;
    border: 1px solid var(--dt-accent);
    background: var(--dt-accent-tint);
    border-radius: 15px;
    color: var(--dt-ink);
}

.hp-quiz-result { margin-top: 10px; font-size: 13.5px; color: var(--dt-ink-2); }

@media (prefers-reduced-motion: reduce) {
    .hp-ch:hover { transform: none; }
}

/* ============================================================
   Key rollover
   ============================================================ */

.kr-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    min-height: 48px;
}

.kr-key {
    padding: 11px 15px;
    border-radius: 10px;
    border: 1px solid var(--dt-border-strong);
    background: var(--dt-surface);
    font-size: 14px;
    font-weight: 600;
    color: var(--dt-ink-2);
}

.kr-key.is-on {
    background: var(--dt-accent);
    border-color: var(--dt-accent);
    color: #fff;
}

/* ============================================================
   Motion sensors
   ============================================================ */

.gy-scene {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    perspective: 600px;
    margin: 10px 0 4px;
}

.gy-box {
    width: 120px;
    height: 120px;
    border-radius: 15px;
    background: linear-gradient(140deg, var(--dt-accent), var(--dt-accent-strong));
    box-shadow: var(--dt-shadow);
    transition: transform .06s linear;
}

@media (prefers-reduced-motion: reduce) {
    .gy-box { transition: none; }
}

.gy-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 8px;
}

.gy-group h3 {
    font-size: 14px;
    margin: 0 0 8px;
    color: var(--dt-ink);
}

.gy-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--dt-border);
    font-size: 13.5px;
    color: var(--dt-ink-2);
}

.gy-row span:last-child {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--dt-ink);
}

/* ============================================================
   Scroll wheel
   ============================================================ */

.sw-stage { overflow: hidden; }

.sw-marker {
    width: 74px;
    height: 74px;
    border-radius: 15px;
    background: linear-gradient(140deg, var(--dt-accent), var(--dt-accent-strong));
    box-shadow: var(--dt-shadow);
    transition: transform .08s linear;
}

@media (prefers-reduced-motion: reduce) {
    .sw-marker { transition: none; }
}

/* ============================================================
   Ghosting / motion blur
   ============================================================ */

.gh-track {
    position: relative;
    overflow: hidden;
    height: 300px;
    border-radius: 15px;
    border: 1px solid var(--dt-border-strong);
    background: #ffffff;
}

.gh-row {
    position: absolute;
    left: 0;
    right: 0;
    height: 80px;
    display: flex;
    align-items: center;
}

.gh-row:nth-child(1) { top: 20px; }
.gh-row:nth-child(2) { top: 110px; }
.gh-row:nth-child(3) { top: 200px; }

/* A hard edge between object and background is what makes a slow
   pixel transition visible - a soft or gradient edge hides the
   very thing being looked for. */
.gh-object {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    will-change: transform;
}

.gh-object.is-dark  { background: #000000; }
.gh-object.is-mid   { background: #808080; }
.gh-object.is-accent{ background: var(--dt-accent); }

/* ============================================================
   Vibration
   ============================================================ */

.vb-patterns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.vb-btn {
    padding: 20px 14px;
    border: 1px solid var(--dt-border-strong);
    border-radius: 15px;
    background: var(--dt-surface);
    font-size: 15px;
    font-weight: 600;
    color: var(--dt-ink-2);
    cursor: pointer;
    text-align: center;
    transition: transform .3s ease-in-out, border-color .3s ease-in-out;
}

.vb-btn:hover:not(:disabled) {
    transform: translateY(-5px);
    border-color: var(--dt-accent);
    color: var(--dt-ink);
}

.vb-btn:disabled { opacity: .5; cursor: default; }

.vb-ask {
    margin-top: 14px;
    padding: 15px;
    border: 1px solid var(--dt-accent);
    background: var(--dt-accent-tint);
    border-radius: 15px;
    color: var(--dt-ink);
}

@media (prefers-reduced-motion: reduce) {
    .vb-btn:hover:not(:disabled) { transform: none; }
}

/* ============================================================
   Connection
   ============================================================ */

.cn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.cn-estimate-note {
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--dt-ink-3);
    border-left: 3px solid var(--dt-border);
    padding-left: 11px;
}
