:root {
    --bg: #efefef;
    --bg-article: #fff;
    --bg-article-unread: #f7fffa;
    --bg-button: #e0e0e0;
    --text: #333;
    --text-muted: #777;
    --text-hint: #8b7355;
    --text-button: #333;
    --link-color-content: darkorange;
    --link-color: green;
    --border-radius: 3px;
    --border-radius-article: 20px;
    --border-color-content: #ccc;
    --border-color-button: #666;
    --border-color-icon-button: #aaa;
    --border-color-error: red;
}

@media only screen and (prefers-color-scheme: dark) {
    :root {
        --bg: #000;
        --bg-article: #444;
        --bg-article-unread: #444844;
        --bg-button: #444;
        --text: #eee;
        --text-muted: #ccc;
        --text-hint: #bba385;
        --text-button: #ccc;
        --link-color-content: orange;
        --link-color: green;
        --border-radius: 3px;
        --border-color-content: #000;
        --border-color-button: #000;
        --border-color-icon-button: #000;
    }
}

* {
    border: 0;
    font-family: inherit;
    font-size: 100%;
    font-style: inherit;
    font-weight: inherit;
    margin: 0;
    outline: 0;
    padding: 0;
    vertical-align: baseline;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: none;
    overflow-x: hidden;
    overflow-y: scroll;
    scroll-behavior: smooth;
}

body {
    font: 1rem/1.7rem "Helvetica Neue", Helvetica, Arial, sans-serif;
    max-width: 54rem;
    margin: 2rem auto;
    padding: 0 1rem;
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
}

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

h2 {
    font-size: 1.3rem;
    color: var(--text-muted);
    font-weight: normal;
    margin: 2.5rem 1rem 1rem 1rem;
}

h3 {
    font-size: 1.4rem;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 0 0.8rem;
}

header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
    grid-template-areas:
            "headline navigation"
            "options options";
    margin-bottom: 2rem;
}

header h1 {
    grid-area: headline;
    margin: 0;
    font-size: 1.4rem;
    font-weight: normal;
    letter-spacing: 0.02em;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

header nav {
    grid-area: navigation;
    text-align: right;
}

header form {
    grid-area: options;
    text-align: right;
}

button, .button {
    background: var(--bg-button);
    color: var(--text-button);
    border-radius: var(--border-radius);
    padding: .3rem .5rem;
    text-decoration: none;
    cursor: pointer;
    font-size: .70rem;
    text-transform: uppercase;
    white-space: nowrap;
    font-family: sans-serif;
    border: 1px solid var(--border-color-button);
}

button.active, .button.active {
    box-shadow: 0 0 5px rgba(0,0,0,.5);
}

.icon-button {
    background: var(--bg-button);
    border: 1px solid var(--border-color-icon-button);
    padding: .35rem .45rem;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-hint);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button.favorite-toggle:hover,
.icon-button.favorite-toggle.is-favorite {
    color: darkorange;
}

section.summary {
    display: flex;
    flex-direction: row;
    gap: .5rem;
    justify-content: space-around;
    flex-wrap: wrap;
    margin: 2rem 0;
    text-align: center;
}

article {
    margin: .7rem 0;
    padding: .75rem 1rem;
    background-color: var(--bg-article);
    border-radius: var(--border-radius-article);
    transition: height .2s ease-in;
    max-width: 100%;
    overflow-x: hidden;
    text-overflow: clip;
}

article.card.is-new {
    background-color: var(--bg-article-unread);
}

article.card,
article.expanded {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    column-gap: .75rem;
    align-items: center;
}

article.card {
    grid-template-areas:
        "title    title    title"
        "feed     datetime actions"
        "excerpt  excerpt  excerpt";
    row-gap: .25rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

article.card.htmx-request::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    width: 40%;
    background: var(--text-hint);
    animation: card-loading-slide 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes card-loading-slide {
    from { transform: translateX(-100%); }
    to   { transform: translateX(250%); }
}

article.expanded {
    margin: 2rem 0;
    grid-template-areas:
        "title    title    title"
        "feed     datetime actions"
        "content  content  content"
        "footer footer footer"
    ;
    row-gap: .35rem;
    box-shadow: 0 0 25px rgba(0,0,0,.2);
}

article .title {
    grid-area: title;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.35;
    max-width: 100%;
    overflow-x: hidden;
    text-overflow: ellipsis;
}

article.card .title    { font-size: 1.15rem; }
article.expanded .title { font-size: 1.25rem; }

article.card.is-new .title::before {
    content: "• ";
    color: #3c3;
}

article .feed,
article .datetime {
    font-size: .85rem;
    color: var(--text-hint);
}

article .feed     { grid-area: feed; }
article .datetime { grid-area: datetime; }

article .feed > a {
    color: inherit;
}

article .actions {
    grid-area: actions;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: .25rem;
}

article.expanded .actions {
    gap: .35rem;
}

article.card .excerpt {
    grid-area: excerpt;
    font-size: .9rem;
    line-height: 1.45;
    color: var(--text-muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

article.expanded .footer {
    grid-area: footer;
    text-align: right;
}

article.expanded .content {
    grid-area: content;
    min-width: 0;
    margin: 0 -1rem;
    padding: .75rem 1rem;
    line-height: 1.55;
    border-top: 1px solid var(--border-color-content);
    overflow-wrap: break-word;
}

article.expanded .content h1,
article.expanded .content h2,
article.expanded .content h3 {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0 0 1em;
}

article.expanded .content img {
    max-width: 100%;
    height: auto;
}

article.expanded .content p {
    margin: 0 0 1em;
}

article.expanded .content .notice {
    border: 1px solid var(--border-color-error);
    border-radius: var(--border-radius);
    padding: 1rem;
    font-size: .9rem;
}

article.expanded .content ul,
article.expanded .content ol {
    margin: 0 0 1rem 1rem;
    padding-left: 1rem;
}

article.expanded .content a {
    color: var(--link-color-content);
    text-decoration: underline;
}

article.expanded .content pre,
article.expanded .content code {
    font-family: monospace, Mono, sans-serif;
    font-size: .9rem;
}

article.expanded .content pre {
    background: rgba(0,0,0,.05);
    border-radius: var(--border-radius);
}

article.expanded .content pre {
    padding: .5rem .75rem;
    overflow-x: auto;
}

article.expanded .content code {
    padding: 0 .25rem;
}

article.expanded .content blockquote {
    margin: 0 0 1em;
    padding-left: 1rem;
    border-left: 3px solid var(--bg-button);
    color: var(--text-muted);
}

@media (max-width: 1000px) {
    body {
        font-size: 1rem;
        padding: 0;
    }

    h3 {
        font-size: 1rem;
    }

    header {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-template-areas: "headline" "navigation" "options";
        margin: .5rem;
    }

    header h1 {
        margin-bottom: 1rem;
    }

    header form, header nav {
        text-align: center;
        margin-bottom: .7rem;
    }

    article {
        border-radius: 0;
        margin: 0;
        border-top: 1px solid var(--border-color-content);
    }

    article.card .title {
        font-size: .9rem;
    }
    article.expanded .title {
        font-size: .9rem;
    }

    .article-list article:last-child {
        border-bottom: 1px solid var(--border-color-content);
    }

    footer {
        margin: 1rem;
    }
}

.login {
    max-width: 20rem;
    margin: 4rem auto;
    padding: 0 1rem;
    text-align: center;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    align-items: stretch;
    text-align: left;
}

.login-form label {
    font-size: .8rem;
    color: var(--text-muted);
}

.login-form input[type="password"] {
    padding: .5rem;
    font-size: 1rem;
    border: 1px solid var(--border-color-button);
    border-radius: var(--border-radius);
    background: var(--bg-article);
    color: var(--text);
}

.login-error {
    color: var(--border-color-error);
    font-size: .8rem;
    margin: 0;
}
