:root {
    --line-height: 1.45rem;
    --max-post-width: 32rem;

    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    --dark-mode-color: #e8e8e8;
    --dark-mode-bg: #1b1b1c;

    --bg: white;
    --color: black;
    --theme-color: #076ad3;
    --alert-color: rgb(208, 92, 14);
    --post-bg: white;
    --post-border: lightgray;
    --normal-button-active-color: lightgray;
    --album-bg: var(--dark-mode-bg);
    --album-bubbles: var(--post-border);
    --dialog-backdrop: rgba(255, 255, 255, 0.7);
}

body,
html {
    margin: 0;
    font-family: sans-serif;
    line-height: var(--line-height);
}

body {
    background: var(--bg);
    color: var(--color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
}

.scroll-container {
    flex-grow: 1;
    overflow-y: scroll;
}

/* styling */

.grow {
    flex-grow: 1;
}

.hidden {
    display: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1em;
}

details summary {
    cursor: pointer;
    text-decoration: dotted underline;
}

dialog {
    border: 1px dotted var(--theme-color);
    color: var(--theme-color);
    padding: 1em;
    max-width: 15em;
    text-align: center;
    background: var(--bg);
}
dialog::backdrop {
    background: var(--dialog-backdrop);
}

input,
textarea,
button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    line-height: var(--line-height);
    background: var(--bg);
}

a,
a:visited {
    color: var(--theme-color);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;

    border: none;
    background: none;
    padding: 0;
}
a:hover,
a:active {
    background: var(--theme-color);
    color: var(--bg);
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

em {
    font-style: normal;
    font-weight: bold;
}

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

dialog button {
    color: var(--theme-color);
    border-color: var(--theme-color);
}
dialog button:hover {
    background: var(--theme-color);
    color: var(--bg);
}

button,
input[type="button"],
input[type="submit"],
.dialog-close-button {
    border: 1px solid var(--color);
    color: var(--color);
    padding: 0.5em;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    background: transparent;
}
button:hover,
button:active,
input[type="submit"]:hover,
input[type="submit"]:active,
input[type="button"]:hover,
input[type="button"]:active,
.dialog-close-button:hover,
.dialog-close-button:active {
    background: var(--normal-button-active-color);
    color: var(--color);
    text-decoration: none;
}

input[type="range"] {
    background: transparent;
    cursor: pointer;
    width: 100%;
}
input[type="range"]:disabled {
    cursor: default;
}

.icon-button {
    border: none;
    padding: 0;
    flex-shrink: 0;
    transition: scale 100ms;
}
.icon-button:hover,
.icon-button:active {
    background: transparent;
}
.icon-button img {
    height: 1em;
    vertical-align: middle;
}
.icon-button:active {
    scale: 0.85;
}

/* layout */

main {
    padding: clamp(var(--space-sm), 1.8vw, var(--space-md));
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    width: min(100%, calc(var(--max-post-width) + var(--space-lg)));
    max-width: calc(var(--max-post-width) + var(--space-lg));
    margin: 0 auto;
    box-sizing: border-box;
    align-items: stretch;
}

.posts-list {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    font-family: monospace;
    width: 100%;
}

/*  */

header,
footer,
nav {
    padding: var(--space-sm) var(--space-md);
}

header {
    background: var(--post-bg);
    border-bottom: 1px dotted var(--theme-color);

    display: flex;
    gap: var(--space-xs) var(--space-lg);
    flex-wrap: wrap;
    align-items: center;
}
header a {
    text-align: center;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    flex-wrap: wrap;
}

.header-logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}


footer {
    background: var(--post-bg);
    border-top: 1px dotted var(--theme-color);

    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
nav {
    display: flex;
    gap: var(--space-lg);
    padding: 0;
}
nav pre {
    margin: 0;
}
nav a {
    font-family: monospace;
}

.pager {
    align-items: center;
    gap: var(--space-md);
}

.pager-disabled {
    opacity: 0.45;
    font-family: monospace;
}

.header-actions a,
.new-post-button {
    min-height: 2.75rem;
    padding: var(--space-2xs) var(--space-xs);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
}

.header-actions a:hover,
.header-actions a:active,
.new-post-button:hover,
.new-post-button:active {
    border-color: var(--theme-color);
}

.pager a {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
}

@media (max-width: 767px) {
    :root {
        --mobile-tabbar-h: 4.25rem;
    }

    body {
        background: var(--post-bg);
    }

    header {
        position: sticky;
        top: 0;
        z-index: 20;
        border-bottom: 1px solid var(--post-border);
        padding: 0.6rem 0.85rem;
        gap: var(--space-sm);
        flex-wrap: nowrap;
    }

    header > .header-actions,
    header > .header-user,
    header > .header-logout-form,
    header > .new-post-button,
    header > .grow {
        display: none !important;
    }

    .header-brand {
        font-size: 1.05rem;
        letter-spacing: 0.01em;
    }

    .scroll-container {
        padding-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom));
    }

    main {
        width: 100%;
        max-width: 100%;
        padding: 0;
        gap: var(--space-md);
    }

    .mobile-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        height: var(--mobile-tabbar-h);
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        align-items: center;
        border-top: 1px solid var(--post-border);
        background: var(--post-bg);
        padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom));
        box-sizing: border-box;
        gap: 0.25rem;
    }

    .mobile-tabbar a {
        min-height: 2.5rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        text-decoration: none;
        color: color-mix(in oklab, var(--color) 72%, transparent);
        font-family: sans-serif;
        font-size: 1.2rem;
        line-height: 1;
        padding: 0;
    }

    .mobile-tabbar a.active {
        color: var(--theme-color);
        background: color-mix(in oklab, var(--theme-color) 14%, transparent);
        font-weight: 700;
    }

    .mobile-tabbar-new {
        background: var(--theme-color);
        color: var(--bg) !important;
        font-weight: 700;
        font-size: 1.35rem;
    }

    .mobile-tabbar-new.active {
        box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--bg) 65%, transparent);
    }

    footer {
        border-top: none;
        padding-bottom: var(--space-xl);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
footer > div {
    display: flex;
    justify-content: end;
}
footer .flex {
    gap: 0.25em 2em;
    flex-wrap: wrap;
}

.logout-button {
    color: var(--theme-color);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
}
.logout-button:hover,
.logout-button:active {
    background: var(--theme-color);
    color: var(--bg);
    text-decoration: none;
}

.header-user {
    font-family: monospace;
}

.empty-state {
    font-family: monospace;
    opacity: 0.7;
    text-align: center;
    padding: var(--space-xl) var(--space-md);
}

.mobile-tabbar {
    display: none;
}

.header-brand {
    font-weight: 700;
}
