@font-face {
        font-family: "source-serif";
        font-style: normal;
        font-weight: 400;
        src: url("SourceSerif4-Regular.otf.woff2");
}

@font-face {
        font-family: "source-sans";
        font-style: normal;
        font-weight: 400;
        src: url("SourceSans3-Regular.otf.woff2");
}

@font-face {
        font-family: "source-sans";
        font-style: normal;
        font-weight: 700;
        src: url("SourceSans3-Bold.otf.woff2");
}

:root {
        --color-white: #eee;
        --color-black: #111
}

body {
        font-family: source-sans, sans-serif;
        font-display: swap;
        background: #345434;
        background-image: url("background.png");
        margin: 2em;
        font-size: 1.4em;
        line-height: 1.2;

        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
}

div.about {
        margin-bottom: 2em;
        padding: 0.5em;
        padding-bottom: 0;
        max-width: 800px;
        width: 100%;
        background: #fff;
        box-shadow: 0px 0px 2px 2px #fff;
        color: #345434;
        position: relative;
}

span.buttons {
        position: absolute;
        bottom: 0.5em;
        right: 0.5em;
        font-size: 70%;
}

div.post {
        margin-bottom: 2em;
        padding: 0.5em;
        max-width: 800px;
        display: flex;
        flex-direction: row;
}

div.posttext {
        flex: 1;
}

div.postimage {
        width: 320px;
        margin-bottom: 0;
        max-width: 320px;
        max-height: 320px;
        text-align: center;
        overflow: hidden;
        flex: 1;
        line-height: 0;
}

/* Full width, cropped by the box if it's tall; reset.css's max-block-size would squash it into the box instead */
div.postimage>img {
        width: 100%;
        height: auto;
        max-block-size: none;
}

/* The same as the post's padding, so the gap beside the image matches the edge */
div.positive>div.postimage, div.unknown>div.postimage {
        margin-left: 0.5em;
}

div.negative>div.postimage {
        margin-right: 0.5em;
}


div.positive {
        background: var(--color-white);
        color: var(--color-black);
        box-shadow: 0px 0px 2px 2px var(--color-white);
}

div.unknown {
        background: #bbb;
        color: var(--color-black);
        box-shadow: 0px 0px 2px 2px var(#bbb);
}

div.negative {
        background: var(--color-black);
        color: var(--color-white);
        box-shadow: 0px 0px 2px 2px var(--color-black);
        text-align: right;
}

div.description {
        font-size: 110%;
        font-weight: bold;
}

div.extended {
        font-family: source-serif, serif;
        margin-top: 1rem;
}

div.tags_and_ts {
        margin-top: 1rem;
        font-size: 70%;
        opacity: 65%;
}

span.tags {}

span.timestamp {
        padding-right: 3em;
        display: none;
}

div.archive_calendar {
        margin-bottom: 9;
        padding: 0.5em;
        max-width: 800px;
        background: var(--color-white);
        color: var(--color-black);
        box-shadow: 0px 0px 2px 2px var(--color-white);
}

div.archive_row {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
        margin-bottom: 1.0rem;
}

div.archive_year {
        font-weight: bold;
        margin-right: 2rem;
}

div.archive_month {
        text-align: center;
}

div.archive_month_hidden {
        visibility: hidden;
}

/* Timeline under the masthead on the archive page; 76px is its height plus margins */
svg.timeline {
        display: block;
        clear: both;
        width: 100%;
        height: 60px;
        margin: 8px 0;
}

div.about:has(svg.timeline) span.buttons {
        bottom: calc(0.5em + 76px);
}

svg.timeline rect {
        fill: transparent;
}

svg.timeline rect.positive, div.mood span.positive {
        fill: #5d8a4e;
        background: #5d8a4e;
}

svg.timeline rect.negative, div.mood span.negative {
        fill: var(--color-black);
        background: var(--color-black);
}

svg.timeline rect.unknown {
        fill: #bbb;
}

div.archive_stats {
        margin-top: 2em;
        margin-bottom: 2em;
        padding: 0.5em;
        max-width: 800px;
        background: var(--color-white);
        color: var(--color-black);
        box-shadow: 0px 0px 2px 2px var(--color-white);
}

div.stats_headline {
        font-size: 200%;
        font-weight: bold;
        color: #345434;
}

div.stats_sub, div.stats_row {
        font-size: 70%;
        margin-top: 0.4rem;
}

div.stats_sub {
        opacity: 65%;
        margin-top: 0;
}

div.mood {
        display: flex;
        gap: 2px;
        height: 8px;
        margin-top: 0.3rem;
}

div.mood span:first-child {
        border-radius: 4px 0 0 4px;
}

div.mood span:last-child {
        border-radius: 0 4px 4px 0;
}

@media screen and (max-width: 800px) {
        body {
                margin: 0.7rem;
        }

        div.post {
                flex-direction: column;
                margin-bottom: 1em;
        }

        div.about {
                margin-bottom: 1em;
        }

        div.negative {
                flex-direction: column-reverse;
        }

        div.postimage {
                margin: 0.5rem 0 0 0;
                width: 100%;
                max-width: 100%;
        }

        div.positive>div.postimage, div.unknown>div.postimage {
                margin: auto;
                margin-top: 0.5rem;
        }

        div.negative>div.postimage {
                margin: auto;
                margin-top: 0.5rem;
        }
}

@media screen and (max-width: 630px) {
        body {
                font-size: 1em;
        }

        div.archive_calendar {
                font-size: 0.9em;
        }

        span.headline {
                display: block;
        }

        span.buttons {
                display: block;
                position: relative;
                float: left;
                left: 0;
                top: 0;
        }
}

@media screen and (max-width: 400px) {
        div.archive_calendar {
                font-size: 0.8em;
        }
}

/* The main page, drawn by linkblog.js, and the controls under the masthead on every page */

/* One line, 32px tall, like the timeline on the archive page; 48px is its height plus margins */
.controls {
        display: flex;
        flex-wrap: nowrap;
        gap: 0.5em;
        align-items: center;
        clear: both;
        height: 32px;
        margin: 8px 0;
        font-size: 70%;
        color: var(--color-black);
        white-space: nowrap;
}

div.about:has(.controls) span.buttons {
        bottom: calc(0.5em + 48px);
}

/* The archive index has the timeline under the controls too; their 8px margins overlap */
div.about:has(.controls):has(svg.timeline) span.buttons {
        bottom: calc(0.5em + 116px);
}

.controls input, .controls select, .controls button {
        font: inherit;
}

/* reset.css takes their borders */
.controls input, .controls select {
        border: 1px solid #999;
        border-radius: 3px;
        padding: 0.1em 0.3em;
        background: #fff;
}

.controls input::placeholder {
        color: #999;
}

.controls input {
        flex: 1;
        min-width: 4em;
}

.controls select {
        flex: none;
}

.controls button {
        border: none;
        background: none;
        cursor: pointer;
        padding: 0;
}

#tag {
        overflow: hidden;
        text-overflow: ellipsis;
}

.chip {
        margin-right: 0.5em;
        white-space: nowrap;
}

/* With more than one chosen, the chips and the count go on a line of their own, which wraps; the count stays at its
   bottom right. The ::after is a break between the lines */
.controls.many {
        flex-wrap: wrap;
        height: auto;
        min-height: 32px;
}

.controls.many::after {
        content: "";
        flex-basis: 100%;
        order: 1;
}

.controls.many #tag {
        order: 2;
        flex: 1;
        white-space: normal;
}

.controls.many #summary {
        order: 3;
        align-self: flex-end;
}

/* The masthead's links are placed from the bottom, which moves when the controls take two lines: from the top instead */
@media screen and (min-width: 631px) {
        div.about:has(.controls.many) span.buttons {
                bottom: auto;
                top: 24.4px;  /* where bottom puts them with one line */
        }
}

/* Like the year menu next to it */
.controls #shelves-button {
        flex: none;
        border: 1px solid #999;
        border-radius: 3px;
        padding: 0.1em 0.5em;
        background: #fff;
}

#panel button {
        font: inherit;
        color: inherit;
        border: none;
        background: none;
        padding: 0;
        cursor: pointer;
        text-align: left;
}

.n {
        opacity: 65%;
        font-variant-numeric: tabular-nums;
}

/* The panel from the Categories button, over the posts */
#panel {
        position: absolute;
        z-index: 10;
        left: 0.5em;
        top: 100%;
        width: 24em;
        max-width: calc(100% - 1em);
        max-height: 70vh;
        overflow-y: auto;
        padding: 0.5em;
        background: #fff;
        color: var(--color-black);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        font-size: 70%;
}

#panel .head {
        display: flex;
        gap: 0.3em;
        font-weight: bold;
        padding-bottom: 0.3em;
        margin-bottom: 0.3em;
        border-bottom: 1px solid #ccc;
}

#panel .close {
        margin-left: auto;
}

#panel .row, #panel .more {
        display: flex;
        width: 100%;
        gap: 1em;
        padding: 0.2em 0.3em;
}

#panel .row span:first-child {
        flex: 1;
}

/* A column on the right for the › on rows that go down a level */
#panel .row::after {
        content: "";
        width: 0.5em;
}

#panel .row[data-browse]::after {
        content: "›";
}

#panel .row:hover, #panel .more:hover {
        background: #eee;
}

@media screen and (max-width: 630px) {
        #panel {
                left: 0;
                width: 100%;
                max-width: 100%;
                box-sizing: border-box;
        }
}

#summary {
        opacity: 65%;
}

/* The date at the far end of the tags line: left on disliked posts, which are right-aligned.
   Only on the main page; the archive pages keep the date hidden */
#posts div.tags_and_ts {
        display: flex;
        justify-content: space-between;
        align-items: last baseline;  /* when the tags take two lines, the date sits on the last */
        gap: 1.5em;
}

#posts span.timestamp {
        display: inline;
        padding-right: 0;
        white-space: nowrap;
        font-variant: small-caps;
        font-variant-numeric: tabular-nums;
        opacity: 75%;
}

#posts div.positive span.timestamp, #posts div.unknown span.timestamp {
        order: 2;
}

/* The main page without JavaScript: like a post's notes, without the space they leave under a title */
div.nojs {
        font-family: source-serif, serif;
}

div.nojs a {
        text-decoration: underline;
}

span.tag:hover {
        text-decoration: underline;
        cursor: pointer;
}

#posts {
        max-width: 800px;
}
