@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700;800&display=swap');

:root {
    --c-a-w: hsl(0, 0%, 90%);
    --c-a-l: hsl(0, 0%, 70%);
    --c-a-m: hsl(0, 0%, 50%);
    --c-a-d: hsl(0, 0%, 30%);
    --c-a-b: hsl(0, 0%, 20%);

    --c-b-w: hsl(0, 7%, 88%);
    --c-b-l: hsl(0, 7%, 68%);
    --c-b-m: hsl(0, 7%, 48%);
    --c-b-d: hsl(0, 7%, 28%);
    --c-b-b: hsl(0, 7%, 18%);

    --f-em-to-vm: 3.6vmin;

    background:
        linear-gradient(00deg, var(--c-a-w) 0.1em, transparent 0.1em),
        linear-gradient(90deg, var(--c-a-w) 0.1em, transparent 0.1em),
        var(--c-b-w);
    background-size: 1em 1em;
    color: var(--c-a-b);
    font-family: 'Baloo 2', cursive;
}

body {
    display: flex;
    position: absolute;
    inset: min(5em, calc(5 * var(--f-em-to-vm)) * 0.5);
    flex-flow: column nowrap;
    margin: 0;
    border-radius: 0.6em;
    box-shadow: 0.1em 0.1em 0.3em 0.1em var(--c-b-m);
    background-color: var(--c-a-w);
    padding: 1em;
    container: body / inline-size;
}

header {
    display: block;
}

header div {
    display: inline;
    height: 2.5em;
}

header div a {
    display: inline-block;
    transition: color 0.1s, text-decoration-color 0.1s;
    text-decoration: underline transparent 0.1em;
    color: currentColor;
}

header div a:hover {
    text-decoration-color: currentColor;
    color: var(--c-b-m) !important;
}

header div+div {
    float: right;
}

header div a h1 {
    display: block;
    margin-block: 0;
    line-height: 1.25em;
    font-size: 2em;
}

header div a h2 {
    display: block;
    margin-block: 0;
    font-size: 1.5em;
}

main {
    display: grid;
    flex-grow: 1;
    grid-template: auto 1fr auto / 1fr;
    gap: 1em;
    padding: 0;
    padding-top: 1em;
}

main a {
    transition: box-shadow 0.1s;
    border-radius: 0.5em;
    box-shadow: 0.05em 0.05em 0.15em 0.05em var(--c-a-m);
    background-color: var(--c-b-w);
    padding: 1em;
    overflow: hidden;
    text-decoration: none;
    color: currentColor;
}

main a[href]:hover {
    box-shadow: 0.05em 0.05em 0.15em 0.1em var(--c-b-m);
}

main a article {
    display: flex;
    flex-flow: column nowrap;
    justify-content: space-between;
    height: 100%;
    overflow: hidden;
}

main a article h2 {
    display: inline;
    transition: color 0.1s, text-decoration-color 0.1s;
    margin-block: 0;
    text-decoration: underline transparent 0.1em;
    word-break: break-all;
    font-size: 1.5em;
}

main a[href]:not(#bookmarkletLink):hover article h2:first-child {
    text-decoration-color: currentColor;
    color: var(--c-b-m);
}

main a article h2+h2 {
    float: right;
}

main a article p {
    transition: opacity 0.3s;
    margin-block: 0;
    font-size: 1em;
}

main a#bookmarkletLink {
    cursor: grab;
}

main a#bookmarkletLink article p::before {
    display: block;
    content: "Drag and drop this box to the bookmarks bar.";
}

main a#bookmarkletLink article p::after {
    display: block;
    color: var(--c-b-d);
    font-weight: bolder;
    content: "WARNING: Bookmarklets may contain malicious code. Never add bookmarklets from unknown sources.";
}

main a article code {
    flex-grow: 1;
    margin-block: none;
    border: 1em solid #00000020;
    border-radius: 0.4em;
    background-clip: padding-box;
    background-color: #00000020;
    overflow: scroll scroll !important;
    white-space: pre;
    flex-basis: 0;
}

main a article input {
    outline: none;
    border: 0.1em solid transparent;
    border-radius: 0.4em;
    background-color: var(--c-a-w);
    padding: 0.2em 0.5em;
    font-family: inherit;
    font-size: 1em;
}

main a article input:hover {
    border-color: var(--c-b-l);
}

main a article input:focus {
    border-color: var(--c-b-d);
}

::-webkit-scrollbar {
    background-color: transparent;
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background-color: #00000020;
}

::-webkit-scrollbar-corner {
    background-color: #00000020;
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 3px;
    background-clip: padding-box;
    background-color: var(--c-a-m);
}

@container body (width < 24em) {
    header div {
        width: 100%;
        text-align: center;
    }

    header div:first-child a {
        width: 100%;
    }

    header div a h1 {
        font-size: min(2em, 16cqw);
    }

    header div a h2 {
        font-size: min(1.5em, 12cqw);
    }

    main a article h2 {
        font-size: max(min(6.5cqw, 1.5em), 12px);
    }

    main a article p {
        font-size: max(min(4.5cqw, 1em), 12px);
    }

    main a article input {
        font-size: max(min(4.5cqw, 1em), 12px);
    }
}