/* Sector F Labs, drawn as a Patina window. The colours come from skins.css, which the build
   generates from Patina's skins; everything here uses only those variables. The sizes follow
   Patina's design language (docs/design.md in the patina repo). */

/* egui's own fonts: Ubuntu Light for text, Hack for code. */
@font-face {
    font-family: "Ubuntu Light";
    src: url("/fonts/Ubuntu-Light.ttf") format("truetype");
    font-weight: 100 600;
    font-display: swap;
}

@font-face {
    font-family: "Hack";
    src: url("/fonts/Hack-Regular.ttf") format("truetype");
    font-display: swap;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    height: 100vh;
    height: 100dvh;
    padding: 24px;
    display: flex;
    overflow: hidden;
    background: var(--desktop);
    color: var(--text);
    font-family: "Ubuntu Light", "Ubuntu", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

::selection {
    background: var(--accent);
    color: var(--accent-text);
}

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

/* ---- The window ---------------------------------------------------------------------- */

.window {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--win-border);
    border-radius: var(--win-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Header bar: menus on the left, the title centred on the window, the page's actions on
   the right. 12 px by 8 px padding, a 25 px row. */
.title-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    min-height: 41px;
    padding: 8px 12px;
    background: var(--title-bar);
    color: var(--bar-text);
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    line-height: 25px;
    user-select: none;
}

.menus {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.app-icon {
    flex: none;
    width: 20px;
    height: 20px;
    margin-right: 6px;
    background: var(--bar-text);
    -webkit-mask: url("/logo-transparent.png") center / contain no-repeat;
    mask: url("/logo-transparent.png") center / contain no-repeat;
}

.title {
    color: var(--title-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.actions {
    justify-self: end;
    display: flex;
    gap: 4px;
}

.bar-button,
.menu > summary {
    display: block;
    padding: 0 8px;
    border-radius: var(--radius);
    color: var(--bar-text);
    text-decoration: none;
    cursor: default;
}

.bar-button {
    background: color-mix(in srgb, var(--bar-text) 12%, transparent);
}

.bar-button:hover,
.menu > summary:hover,
.menu[open] > summary {
    background: var(--bar-hover);
    text-decoration: none;
}

/* Menus open in the skin's normal colours, even on a coloured bar. */
.menu {
    position: relative;
}

.menu > summary {
    list-style: none;
}

.menu > summary::-webkit-details-marker {
    display: none;
}

.menu-list {
    position: absolute;
    z-index: 10;
    top: calc(100% + 6px);
    left: 0;
    min-width: 190px;
    display: flex;
    flex-direction: column;
    padding: 4px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: max(var(--radius), 4px);
    box-shadow: var(--menu-shadow);
    line-height: 1.5;
}

.menu-list a,
.menu-list button {
    display: block;
    padding: 2px 8px 2px 26px;
    position: relative;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--ctl-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
}

.menu-list a:hover,
.menu-list button:hover {
    background: var(--ctl-hover);
    color: var(--ctl-text-hover);
}

.menu-list [aria-checked="true"]::before {
    content: "✓";
    position: absolute;
    left: 9px;
}

.menu-list hr {
    width: 100%;
    margin: 4px 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.menu-heading {
    padding: 0 8px;
    color: var(--text-weak);
    font-size: 13px;
}

.panels {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ---- Sidebar tree, like patina::tree ------------------------------------------------- */

.sidebar {
    flex: none;
    width: 250px;
    overflow: auto;
    padding: 8px 6px 16px;
    border-right: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.4;
}

.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree ul {
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.tree li {
    margin: 1px 0;
}

.tree summary {
    display: flex;
    align-items: center;
    list-style: none;
    cursor: default;
}

.tree summary::-webkit-details-marker {
    display: none;
}

.tree summary::before {
    content: "▶";
    flex: none;
    width: 14px;
    font-size: 8px;
    color: var(--text);
}

.tree details[open] > summary::before {
    content: "▼";
}

.tree a,
.tree summary span {
    display: block;
    min-width: 0;
    padding: 1px 6px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree li > a {
    margin-left: 14px;
}

.tree a:hover {
    background: var(--ctl-hover);
    color: var(--ctl-text-hover);
    text-decoration: none;
}

.tree a.selected {
    background: var(--accent);
    color: var(--accent-text);
}

/* ---- Content -------------------------------------------------------------------------- */

main {
    flex: 1;
    min-width: 0;
    overflow: auto;
    padding: 16px 32px 56px;
}

main:focus,
main:focus-visible {
    outline: none;
}

main > * {
    max-width: 780px;
}

h1,
h2,
h3,
h4 {
    color: var(--text-strong);
    font-weight: 300;
    line-height: 1.25;
}

h1 {
    font-size: 30px;
    margin: 8px 0 12px;
}

h2 {
    font-size: 23px;
    margin: 32px 0 8px;
}

h3 {
    font-size: 19px;
    margin: 24px 0 6px;
}

h4 {
    font-size: 16px;
    margin: 20px 0 4px;
}

p,
ul,
ol {
    margin: 0 0 12px;
}

li {
    margin: 2px 0;
}

strong {
    color: var(--text-strong);
    font-weight: 600;
}

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

a:hover {
    text-decoration: underline;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

img {
    max-width: 100%;
    height: auto;
}

#main img:not(a img) {
    cursor: zoom-in;
}

/* An image double-clicked: larger, over the page. */
.zoom {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.78);
    cursor: zoom-out;
}

.zoom img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

blockquote {
    margin: 0 0 12px;
    padding-left: 12px;
    border-left: 3px solid var(--border);
}

code {
    font-family: "Hack", ui-monospace, monospace;
    font-size: 0.86em;
    padding: 1px 4px;
    border-radius: var(--radius);
    background: var(--ctl-bg);
    color: var(--text-strong);
}

.code {
    position: relative;
    margin: 0 0 14px;
}

pre {
    margin: 0 0 14px;
    padding: 12px 14px;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.45;
}

.code pre {
    margin: 0;
}

pre code {
    padding: 0;
    background: none;
    color: var(--text);
    font-size: inherit;
}

pre.mermaid {
    text-align: center;
    font-family: inherit;
}

/* egui buttons. */
button.copy,
.button {
    display: inline-block;
    padding: 1px 8px;
    border: 0;
    border-radius: var(--radius);
    background: var(--ctl-bg);
    color: var(--ctl-text);
    font: 14px / 1.5 "Ubuntu Light", system-ui, sans-serif;
    text-decoration: none;
    cursor: default;
}

button.copy:hover,
.button:hover {
    background: var(--ctl-hover);
    color: var(--ctl-text-hover);
    text-decoration: none;
}

.button:active,
button.copy:active {
    background: var(--ctl-pressed);
}

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

button.copy {
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0;
}

.code:hover button.copy,
button.copy:focus-visible {
    opacity: 1;
}

table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    margin: 0 0 16px;
    border-collapse: collapse;
    font-size: 15px;
}

th,
td {
    padding: 4px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-strong);
    font-weight: 300;
}

tbody tr:nth-child(odd) td {
    background: var(--surface-alt);
}

.note {
    padding: 8px 12px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-weak);
}

.weak {
    color: var(--text-weak);
}

/* ---- Hand-written pages -------------------------------------------------------------- */

.lede {
    font-size: 18px;
    color: var(--text-strong);
}

main > .cards,
main > .shots {
    max-width: 1040px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
    margin: 12px 0 20px;
}

.card {
    display: block;
    padding: 12px 14px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: max(var(--radius), 4px);
    color: var(--text);
    line-height: 1.45;
}

.card:hover {
    background: var(--ctl-hover);
    text-decoration: none;
}

.card strong {
    display: block;
    margin-bottom: 2px;
    color: var(--link);
    font-weight: 300;
    font-size: 18px;
}

.card.wide {
    grid-column: span 2;
}

.shots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin: 16px 0 24px;
}

.shots figure {
    margin: 0;
}

.shots figcaption {
    margin-top: 4px;
    color: var(--text-weak);
    font-size: 14px;
    text-align: center;
}

.apps {
    list-style: none;
    padding: 0;
}

.apps li {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 2px 14px;
    align-items: start;
    margin: 0 0 14px;
}

.apps img {
    width: 40px;
    height: 40px;
}

.skin-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 16px;
}

.example {
    display: grid;
    gap: 12px;
}

@media (min-width: 900px) {
    .example {
        grid-template-columns: 1fr 1fr;
    }
}

.example p {
    margin: 0 0 4px;
    color: var(--text-weak);
    font-size: 14px;
}

/* ---- Status bar --------------------------------------------------------------------- */

.status-bar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 12px;
    border-top: 1px solid var(--border);
    color: var(--text-weak);
    font-size: 13px;
}

.status-bar a {
    color: inherit;
}

/* ---- Narrow screens: the window is maximised and the page scrolls -------------------- */

@media (max-width: 760px) {
    body {
        height: auto;
        min-height: 100vh;
        padding: 0;
        overflow: visible;
        display: block;
    }

    .window {
        min-height: 100vh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    .title-bar {
        position: sticky;
        top: 0;
        z-index: 5;
        grid-template-columns: 1fr auto;
    }

    .title {
        display: none;
    }

    .panels {
        display: block;
    }

    .sidebar {
        display: none;
    }

    main {
        overflow: visible;
        padding: 12px 16px 40px;
    }

    h1 {
        font-size: 26px;
    }

    .card.wide {
        grid-column: auto;
    }

    button.copy {
        opacity: 1;
    }
}
