/* ==========================================================================
   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 {
    color-scheme: dark;
    --fg: #ffffff;
    --bg: #1a1a1a;
    --border-color: var(--fg);
    --fg-muted: color-mix(in srgb, var(--fg) 50%, var(--bg));
    --fg-subtle: color-mix(in srgb, var(--fg) 45%, var(--bg));
    --fg-border: color-mix(in srgb, var(--fg) 22%, var(--bg));
    --fg-faint: color-mix(in srgb, var(--fg) 15%, var(--bg));
    --fg-ghost: color-mix(in srgb, var(--fg) 7%, var(--bg));
    --icon-filter: invert(1);
    --icon-active-filter: invert(0);
}

body.theme-light {
    color-scheme: light;
    --fg: #1a1a1a;
    --bg: #ffffff;
    --border-color: var(--fg);
    --fg-muted: color-mix(in srgb, var(--fg) 50%, var(--bg));
    --fg-subtle: color-mix(in srgb, var(--fg) 45%, var(--bg));
    --fg-border: color-mix(in srgb, var(--fg) 22%, var(--bg));
    --fg-faint: color-mix(in srgb, var(--fg) 15%, var(--bg));
    --fg-ghost: color-mix(in srgb, var(--fg) 7%, var(--bg));
    --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);
}

/* System mode: let light-dark() follow the OS preference */
body.theme-system {
    color-scheme: light dark;
}

@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);
    }
}

/* ==========================================================================
   Landing theme
   ========================================================================== */

body.layout-landing figure img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-inline: auto;
}

/* ==========================================================================
   Post card preview
   ========================================================================== */

.post-preview__image {
    margin: 0;
}

.post-preview__image img {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   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;
}
.feed-filter-form {
    margin-bottom: 1rem;
}

.feed-filter-label {
    display: inline;
    margin: 0;
}

.toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
}
.toc li { padding-left: 0; }
.toc li.toc-level-2 { padding-left: 1rem; }
.toc li.toc-level-3 { padding-left: 2rem; }
.toc li.toc-level-4 { padding-left: 3rem; }
.toc li.toc-level-5 { padding-left: 4rem; }
.toc li.toc-level-6 { padding-left: 5rem; }

/* ==========================================================================
   Multilingual / Locale Editor
   ========================================================================== */

/* Locale switcher nav in editor */
.locale-switcher {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.locale-switcher a {
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--fg);
    text-decoration: none;
}
.locale-switcher a[aria-current="page"] {
    background: var(--fg);
    color: var(--bg);
}

/* Locale title input row */
.locale-title-row {
    margin-bottom: 1.5rem;
}

/* Mobile tab radios — hidden, used for CSS-only tab switching */
.locale-tab-radio {
    display: none;
}

/* Tab labels — shown as a tab bar on mobile */
.locale-tab-bar {
    display: none;
    gap: 0;
    border-bottom: 1px solid var(--fg);
    margin-bottom: 1rem;
}
.locale-tab-label {
    padding: 0.4rem 1rem;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
}

/* Widen the content area when locale editor is active */
.content:has(.locale-editor-columns) {
    max-width: 1200px;
}

/* Desktop: two-column grid */
.locale-editor-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Column headings */
.locale-col-heading {
    margin-top: 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--fg);
}

/* Read-only default text block */
.block-readonly {
    opacity: 0.75;
}
.block-readonly-text {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.95rem;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    overflow-wrap: break-word;
}

/* Language links in public site menu */
.locale-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}
.locale-links a {
    text-decoration: none;
    color: var(--fg);
    opacity: 0.7;
}
.locale-links a[aria-current="true"],
.locale-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Mobile: switch to single-column with tabs */
@media (max-width: 860px) {
    .locale-editor-columns {
        display: block;
    }
    .locale-tab-bar {
        display: flex;
    }

    /* Default: show default column, hide editing column */
    #locale-tab-default:checked ~ .locale-editor-columns .locale-col-default {
        display: block;
    }
    #locale-tab-default:checked ~ .locale-editor-columns .locale-col-editing {
        display: none;
    }
    #locale-tab-editing:checked ~ .locale-editor-columns .locale-col-default {
        display: none;
    }
    #locale-tab-editing:checked ~ .locale-editor-columns .locale-col-editing {
        display: block;
    }

    /* Active tab style */
    #locale-tab-default:checked ~ .locale-tab-bar label[for="locale-tab-default"],
    #locale-tab-editing:checked ~ .locale-tab-bar label[for="locale-tab-editing"] {
        border-color: var(--fg);
        font-weight: bold;
    }
}

/* On mobile, hide the editing column by default (default tab is pre-checked) */
@media (max-width: 860px) {
    .locale-col-editing { display: none; }
}

/* Language rows in site settings — flex layout for inline inputs */
.language-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}
.language-row input {
    margin-bottom: 0;
}
.language-row input:first-child {
    max-width: 6rem;
}
.language-row small {
    white-space: nowrap;
}

.webring-switcher ul li {
    list-style-type: none;
}

.webring-switcher a.block {
    margin-bottom: 0px;
}


nav.centered {
    display: flex;
    justify-content: center;
}

.site-name {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

.locale-links {
    align-content: center;
}

.locale-links a {
    font-size: 1rem;
}