@font-face {
    font-family: "Roboto Local";
    src: url("../fonts/Roboto-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: "Roboto Local";
    src: url("../fonts/Roboto-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: "Roboto Mono Local";
    src: url("../fonts/RobotoMono-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

:root {
    --bg: #111828;
    --bg-box: #121826;
    --text: #a2afc1;
    --text-dim: #778293;
    --text-faint: #3d4556;
    --text-muted: #808080;
    --editor-bg: #0c101b;
    --info: #5fc97b;
    --error: #e05c5c;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Roboto Local";
    font-feature-settings:
        "liga" 0,
        "clig" 0,
        "kern" 0;
    color: var(--text);
    /*outline: 1px solid #ff4500a0;*/
}

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

html,
body {
    height: 100dvh;
    width: 100%;
    background-color: var(--bg);
}

body {
    padding: 0.5em 1em;
    display: flex;
    flex-direction: column;
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    gap: 0.5em;
}

img {
    display: block;
}

#print-url {
    display: none;
}

/* --- Header --- */
header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 2.5em;
    padding: 0 0.75em;
}

header span {
    display: flex;
    align-items: center;
    gap: 0.2em;
}

header span img {
    height: 1.6em;
}

header span h1 {
    font-size: 1.3em;
}

header div {
    display: flex;
    gap: 1em;
}

header button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25em;
    transition: opacity 0.15s;
}

header button:hover {
    opacity: 0.7;
}

header button img {
    width: 1.5em;
    height: 1.5em;
}

/* --- Editor --- */
#editor {
    flex: 1;
    overflow-y: auto;
    padding: 2em;
    outline: none;
    word-break: break-word;
    border-radius: 1em;
    background-color: var(--editor-bg);
    min-height: 0;
}

#editor div {
    min-height: 1.4em;
    position: relative;
    white-space: pre-wrap;
    line-height: 1.4em;
    padding: 0.3em;
}

/* --- Footer --- */
footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    height: 1.5em;
    padding: 0 0.75em;
    opacity: 0.8;
}

footer small {
    font-size: 0.75em;
}

footer a {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4em;
    text-decoration-color: var(--text-dim);
}

footer a:last-child {
    justify-content: flex-end;
}

footer a img {
    width: 1em;
    height: 1em;
}

#url-bar-track {
    height: 25%;
    width: 50%;
    max-width: 200px;
    background: var(--text-faint);
    border-radius: 0.4em;
    overflow: hidden;
}

#url-bar {
    height: 100%;
    width: 0%;
    background: var(--text);
    transition:
        width 0.3s,
        background 0.3s;
}

/* --- Toast --- */
#toast {
    position: fixed;
    bottom: 4em;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    padding: 0.4em 0.8em;
    border-radius: 0.4em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    background-color: var(--text);
    color: var(--bg);
}

#toast.show {
    opacity: 1;
}

#toast[data-type="info"] {
    background-color: var(--info);
}

#toast[data-type="error"] {
    background-color: var(--error);
}

/* --- QR overlay --- */
#qr-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

#qr-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

#qr-modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
}

#qr-modal button {
    display: flex;
    align-items: center;
    gap: 0.4em;
    cursor: pointer;
    background: none;
    border: none;
    font-size: inherit;
    padding: 0.25em;
    transition: opacity 0.15s;
}

#qr-modal button:hover {
    opacity: 0.7;
}

#qr-modal button img {
    width: 1.5em;
    height: 1.5em;
}

#qr-container {
    max-width: min(80vw, 80vh);
    max-height: min(80vw, 80vh);
}

#qr-container svg {
    width: 100%;
    height: 100%;
    border: solid 1em white;
    border-radius: 1em;
}

/* --- Markdown --- */
.md-h1 {
    font-size: 1.8em;
    font-weight: 700;
}
.md-h2 {
    font-size: 1.5em;
    font-weight: 700;
}
.md-h3 {
    font-size: 1.3em;
    font-weight: 700;
}
.md-h4 {
    font-size: 1.1em;
    font-weight: 700;
}
.md-h5 {
    font-size: 1em;
    font-weight: 700;
}
.md-h6 {
    font-size: 0.9em;
    font-weight: 700;
}

.md-quote {
    padding-left: 0.3em;
    border-left: solid 3px var(--text-faint);
    color: var(--text-dim);
    background-color: var(--bg-box);
}

.md-code {
    font-family: "Roboto Mono Local";
    color: var(--text-dim);
}

.md-code {
    font-family: "Roboto Mono Local";
    color: var(--text-dim);
    background-color: var(--bg-box);
}

.md-code-delim {
    font-family: "Roboto Mono Local";
    color: var(--text-faint);
}

.md-li,
.md-oli {
    padding-left: 1.2em;
}

.md-hr {
    display: flex;
    align-items: center;
    opacity: 0.3;
}

.md-hr::after {
    content: "";
    flex: 1;
    border-top: 3px solid var(--text-dim);
    margin-left: 0.2em;
}

/* --- Print --- */
@media print {
    :root {
        --bg: white;
        --bg-box: #f0f0f0;
        --text: black;
        --text-dim: #4d4d4d;
        --text-faint: #b3b3b3;
    }

    * {
        print-color-adjust: exact;
    }

    @page {
        size: A4;
        margin: 0;
    }

    header,
    footer,
    title,
    #toast {
        display: none;
    }

    #editor {
        height: auto;
        overflow: visible;
        flex: none;
    }

    html,
    body,
    #editor {
        background-color: var(--bg);
        color: var(--text);
        height: auto;
        overflow: visible;
        padding: 0;
        margin: 0;
        gap: 0;
    }

    div {
        background-color: var(--bg);
        color: var(--text);
        height: auto;
        overflow: visible;
        margin: 0;
        gap: 0;
    }

    body {
        padding: 1cm;
    }

    #print-url {
        display: flex;
        align-self: flex-end;
        align-items: center;
        font-size: 0.8em;
        color: var(--text-muted);
        text-decoration: none;
        gap: 0.3em;
        padding-bottom: 1em;
    }

    #print-url img {
        filter: invert(0.8);
        height: 1.2em;
        width: 1.2em;
    }
}
