/* ==========================================================================
   Dark Mode Bridge
   Newstalgia uses prefers-color-scheme on :root. Paperboat also supports
   explicit body.theme-dark / body.theme-light classes for user-toggled mode.
   ========================================================================== */

body.theme-dark {
    --fg: #ffffff;
    --bg: #1a1a1a;
    --icon-filter: invert(1);
    --icon-active-filter: invert(0);
}

body.theme-light {
    --fg: #1a1a1a;
    --bg: #ffffff;
    --icon-filter: invert(0);
    --icon-active-filter: invert(1);
}

/* Dark mode images: add fg-colored background so transparent PNGs remain visible */
body.theme-dark img {
    background-color: var(--fg);
}

@media (prefers-color-scheme: dark) {
    body.theme-system img {
        background-color: var(--fg);
    }
}

/* ==========================================================================
   Messages / Alerts
   ========================================================================== */

.messages {
    margin-bottom: 1rem;
}

.message {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--fg-border);
    background-color: var(--fg-ghost);
}

.message.success {
    border-left-color: #28a745;
    background-color: rgba(40, 167, 69, 0.1);
}

.message.error {
    border-left-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
}

.message.warning,
.warning {
    border-left: 4px solid #ffc107;
    background-color: rgba(255, 193, 7, 0.1);
    padding: 0.75rem 1rem;
}

.message.info {
    border-left-color: #17a2b8;
    background-color: rgba(23, 162, 184, 0.1);
}

/* ==========================================================================
   Components
   ========================================================================== */

article.distinct {
    border-left: 2px solid var(--fg-border);
    padding-left: 1em;
    margin-bottom: 2em;
}

.entry {
    border: 1px solid var(--fg-border);
    border-radius: var(--element-radius);
    padding: 1em;
    margin-bottom: var(--element-spacing);
}

span.links a:not(:last-child) {
    margin-right: 0.5em;
}

/* ==========================================================================
   Task Lists (Markdown Checkboxes)
   ========================================================================== */

ul.task-list {
    list-style: none;
    padding-left: 0;
}

li.task-list-item {
    display: flex;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

li.task-list-item input[type="checkbox"] {
    margin-right: 0.5rem;
    margin-top: 0.25rem;
    flex-shrink: 0;
}

/* ==========================================================================
   Forms (Paperboat-specific)
   ========================================================================== */

textarea {
    field-sizing: content;
    min-height: 50px;
}

/* ==========================================================================
   Gallery
   ========================================================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin: 1rem 0;
}

.gallery-grid a.gallery-thumb {
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
}

.gallery-grid a.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-single figure {
    margin: 0;
}

.gallery-single figure img {
    width: 100%;
    height: auto;
}

.gallery-single figcaption {
    margin-top: 0.5rem;
}

.gallery-nav {
    display: flex;
    justify-content: space-between;
    margin: 1rem 0;
}

.gallery-nav span {
    min-width: 6rem;
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Editor Blocks
   ========================================================================== */

.text-center {
    text-align: center;
}

.editor-blocks article {
    border: 1px solid var(--fg);
    padding: 1rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--fg) 4px 4px 0px;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.default-font-size {
    font-size: 1rem;
}

.site-name a {
    font-size: 1.3em;
    text-decoration: none;
    color: var(--fg);
}

.md-wysiwyg-editor-wrapper button {
    width: auto;
}

.block-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5em;
}