/* The base style is brand.css at the root of iguigova.github.io: on the live
   site that is the hub's file, and on the machine ~/src/oceanhue/brand.css, a
   symlink to it. It is imported into a layer, so every rule below wins over
   it. This file adds only what a demo needs beyond it: the device states, the
   server pane and the layout of the stage. A colour that differs by theme is
   light-dark(light, dark), which follows the theme brand.css sets. */
@import url("../../brand.css") layer(brand);

:root {
    --page: var(--bg);
    --card: var(--panel);
    --line: light-dark(#767676, #8a8a8a);
    --accent: var(--link);
    --offline: var(--muted);
    --offline-soft: light-dark(#ececec, #222222);
    --alert: light-dark(#b91c1c, #ff9a9f);
    --alert-soft: light-dark(#fdeaea, #3b1c1f);
    --server: light-dark(#111111, #000000);
    --server-ink: #f2f2f2;
    --server-muted: #a3a3a3;
    --server-line: #333333;
    --server-ok: #ff9640;
    --server-bad: #ffa4a8;
    --focus: var(--link);
    --radius: 0.75rem;
    --gap: 1rem;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font: 1rem/1.5 var(--sans);
}

a {
    color: var(--link);
    text-decoration: underline;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* --- intro and outro ---------------------------------------------------- */

.intro, .outro {
    max-width: 46rem;
    margin: 0 auto;
    padding: 2rem 1rem 1rem;
}

h1 {
    margin: 0;
    font-size: clamp(2.25rem, 6vw, 3.5rem);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.intro header {
    margin-bottom: 1rem;
}

.tour {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
}

.tour summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-weight: 700;
    cursor: pointer;
}

.tour ol {
    margin: 0.25rem 0 0.5rem;
    padding-left: 1.25rem;
}

.outro {
    padding-bottom: 3rem;
    color: var(--muted);
}

/* --- the stage ---------------------------------------------------------- */

.stage {
    display: grid;
    gap: var(--gap);
    max-width: 90rem;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 64rem) {
    .stage {
        grid-template-columns: 1fr 1.1fr 1fr;
        align-items: start;
    }
}

.device, .server {
    display: block;
    margin: 0;
    border-radius: var(--radius);
    padding: 1rem;
    min-width: 0;
}

h2 {
    margin: 0;
    font-size: 1.25rem;
}

h3 {
    margin: 1.25rem 0 0.5rem;
    font-size: 1rem;
}

/* The demo's buttons; brand.css draws the site's theme switch. */
button:not(.theme-switch) {
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--card);
    color: var(--ink);
    font: inherit;
    cursor: pointer;
}

button:not(.theme-switch):hover {
    border-color: var(--ink);
}

button:not(.theme-switch):active {
    transform: translateY(1px);
}

/* --- a device ----------------------------------------------------------- */

.device {
    background: var(--card);
    border: 2px solid var(--accent);
    box-shadow: 0 1px 0 var(--line);
}

.device:has(input[data-action="online"]:not(:checked)) {
    border-style: dashed;
    border-color: var(--offline);
    background:
        repeating-linear-gradient(-45deg, transparent 0 12px,
                                  var(--offline-soft) 12px 24px),
        var(--card);
}

.device > div {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
}

.device > div > :not(h2, .switch) {
    grid-column: 1 / -1;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    font-weight: 600;
    cursor: pointer;
}

.switch input {
    appearance: none;
    width: 2.75rem;
    height: 1.5rem;
    margin: 0;
    border-radius: 1rem;
    background: var(--muted);
    position: relative;
    cursor: pointer;
}

.switch input::after {
    content: "";
    position: absolute;
    top: 0.2rem;
    left: 0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--card);
    transition: left 0.15s;
}

.switch input:checked {
    background: var(--accent);
}

.switch input:checked::after {
    left: 1.45rem;
}

.status {
    margin: 0;
    font-weight: 600;
    color: var(--accent);
}

.device:has(input[data-action="online"]:not(:checked)) .status {
    color: var(--offline);
}

.posts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.post {
    margin: 0;
    padding: 0.5rem 0.75rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--card);
    display: grid;
    gap: 0.5rem;
}

.post legend {
    padding: 0 0.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--muted);
}

.field label {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.875rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    min-height: 44px;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 0.375rem;
    background: var(--page);
    color: var(--ink);
    font: inherit;
}

.mark {
    padding: 0 0.4rem;
    border-radius: 0.25rem;
    background: var(--offline-soft);
    color: var(--offline);
    font-size: 0.75rem;
    font-weight: 700;
}

.mark::before {
    content: "● ";
}

.delete {
    justify-self: start;
}

.add {
    justify-self: start;
    font-weight: 600;
}

.conflicts {
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--alert);
    border-radius: 0.5rem;
    background: var(--alert-soft);
}

.conflicts h3 {
    margin: 0;
    color: var(--alert);
}

.conflicts h3::before {
    content: "⚠ ";
}

.conflicts ul {
    margin: 0.25rem 0 0;
    padding-left: 1.25rem;
}

/* --- the server --------------------------------------------------------- */

.server {
    background: var(--server);
    color: var(--server-ink);
    border: 1px solid var(--server-line);
}

.server code {
    background: none;
    padding: 0;
}

.server > h2 {
    color: var(--server-ok);
    border-color: var(--server-line);
}

.server .lede {
    margin: 0.25rem 0 0.75rem;
    color: var(--server-muted);
}

.server table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.server caption {
    text-align: left;
    color: var(--server-muted);
    padding-bottom: 0.25rem;
}

.server th, .server td {
    text-align: left;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--server-line);
    overflow-wrap: anywhere;
}

.log {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.875rem;
}

.log li {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--server-line);
    animation: arrive 0.4s ease-out;
}

.log .who {
    color: var(--server-muted);
}

.log code {
    font-family: var(--mono);
}

.log .ok .code {
    color: var(--server-ok);
}

.log .bad .code {
    color: var(--server-bad);
}

.log-empty {
    margin: 0;
    color: var(--server-muted);
}

.score {
    margin: 0;
    color: var(--server-muted);
}

.score strong {
    display: block;
    font-size: 2.5rem;
    line-height: 1.1;
    color: var(--server-ok);
}

@keyframes arrive {
    from { background: #3d2a17; }
    to { background: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .log li { animation: none; }
    .switch input::after { transition: none; }
}
