/* Aeon default theme — minimal and readable.
 * Uses CSS custom properties so themes can override without forking.
 * Respects prefers-color-scheme; no JS required.
 */

:root {
    --aeon-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --aeon-font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --aeon-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    --aeon-bg: #fafafa;
    --aeon-fg: #1a1a1a;
    --aeon-muted: #666;
    --aeon-border: #e0e0e0;
    --aeon-accent: #1a1a1a;
    --aeon-link: #0047ab;
    --aeon-max-width: 680px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --aeon-bg: #0f0f0f;
        --aeon-fg: #e8e8e8;
        --aeon-muted: #999;
        --aeon-border: #2a2a2a;
        --aeon-accent: #e8e8e8;
        --aeon-link: #8ab4ff;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--aeon-bg);
    color: var(--aeon-fg);
    font-family: var(--aeon-font-body);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.site-header {
    max-width: var(--aeon-max-width);
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem; /* added/changed by ChatGPT: keeps site icon/title and menu separated cleanly. */
    border-bottom: 1px solid var(--aeon-border);
}

/* added/changed by ChatGPT: site brand wraps optional icon plus title. */
.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--aeon-fg);
    text-decoration: none;
    min-width: 0;
}

/* added/changed by ChatGPT: header icon/logo before the site title. */
.site-icon {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 6px;
    flex: 0 0 auto;
}

.site-title {
    font-weight: 500;
    color: var(--aeon-fg);
    text-decoration: none;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.editor-bar {
    font-size: 0.85rem;
    color: var(--aeon-muted);
}

.editor-bar a { color: var(--aeon-link); text-decoration: none; }
.editor-bar a:hover { text-decoration: underline; }
.editor-indicator {
    background: #fffbcc;
    color: #1a1a1a;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-family: var(--aeon-font-mono);
    font-size: 0.8rem;
}

.content {
    max-width: var(--aeon-max-width);
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
    font-family: var(--aeon-font-heading);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

.content h1 { font-size: 2rem; margin-top: 0; }
.content h2 { font-size: 1.5rem; }
.content h3 { font-size: 1.25rem; }

.content p {
    margin: 1rem 0;
}

.content a { color: var(--aeon-link); }

.content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.content figure {
    margin: 2rem 0;
}

.content blockquote {
    margin: 1.5rem 0;
    padding-left: 1rem;
    border-left: 3px solid var(--aeon-border);
    color: var(--aeon-muted);
    font-style: italic;
}

.content pre {
    background: rgba(0, 0, 0, 0.04);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    font-family: var(--aeon-font-mono);
    font-size: 0.9rem;
    line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
    .content pre { background: rgba(255, 255, 255, 0.05); }
}

.content hr {
    border: 0;
    border-top: 1px solid var(--aeon-border);
    margin: 2.5rem 0;
}

.aeon-sealed {
    background: rgba(0, 0, 0, 0.03);
    border: 1px dashed var(--aeon-border);
    padding: 1rem 1.25rem;
    border-radius: 6px;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

@media (prefers-color-scheme: dark) {
    .aeon-sealed { background: rgba(255, 255, 255, 0.04); }
}

.aeon-sealed strong {
    display: block;
    margin-bottom: 0.25rem;
}

.aeon-sealed small {
    color: var(--aeon-muted);
    font-family: var(--aeon-font-mono);
    font-size: 0.8rem;
}

.site-footer {
    max-width: var(--aeon-max-width);
    margin: 0 auto;
    padding: 1.5rem 1rem;
    border-top: 1px solid var(--aeon-border);
    color: var(--aeon-muted);
    font-size: 0.85rem;
}

.site-footer a { color: var(--aeon-muted); }

/* Respect reduced motion. */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Aeon minimal account menu (public-safe, no JavaScript required) */
#aeon-login-widget {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1200;
    font-family: var(--aeon-font-body);
}
.aeon-login-trigger {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--aeon-border);
    background: var(--aeon-bg);
    color: var(--aeon-fg);
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.aeon-login-menu {
    position: absolute;
    display: none;
    top: 36px;
    right: 0;
    min-width: 150px;
    padding: 6px;
    border: 1px solid var(--aeon-border);
    border-radius: 8px;
    background: var(--aeon-bg);
    box-shadow: 0 8px 30px rgba(0,0,0,0.14);
}
#aeon-login-widget:hover .aeon-login-menu,
#aeon-login-widget:focus-within .aeon-login-menu { display: block; }
.aeon-login-title {
    padding: 6px 10px 4px;
    color: var(--aeon-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.aeon-login-menu a,
.aeon-login-menu button {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--aeon-fg);
    text-align: left;
    text-decoration: none;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.aeon-login-menu a:hover,
.aeon-login-menu button:hover { background: rgba(127,127,127,0.12); text-decoration: none; }

.site-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.92rem;
}
.site-menu a {
    color: var(--aeon-muted);
    text-decoration: none;
}
.site-menu a:hover { color: var(--aeon-fg); text-decoration: underline; }

/* added/changed by ChatGPT: keep header icon usable on narrow screens. */
@media (max-width: 640px) {
    .site-icon { width: 24px; height: 24px; border-radius: 5px; }
    .site-brand { gap: 0.42rem; }
}

.aeon-link-editor .aeon-inline-input { font-family: var(--aeon-font-body); }

/* Media — v0.3 */
.content figure {
    margin: 1.5rem 0;
}
.content figure img,
.content figure video {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}
.content figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--aeon-muted);
    text-align: center;
}
.aeon-video-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
}
.aeon-video-embed iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ---------------------------------------------------------------------------
 * Sidebar template — v0.4
 * -------------------------------------------------------------------------*/

.aeon-layout-sidebar {
    display: block;
    position: relative;
}

/* Hidden checkbox that drives the open/close state. */
.aeon-sidebar-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.aeon-sidebar {
    background: var(--aeon-bg);
    border-right: 1px solid var(--aeon-border);
    padding: 1.5rem 1.25rem;
    box-sizing: border-box;
}

.aeon-sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.aeon-sidebar nav li {
    margin: 0;
    padding: 0.35rem 0;
}
.aeon-sidebar nav li.current a { font-weight: 600; color: var(--aeon-fg); }
.aeon-sidebar nav a {
    color: var(--aeon-muted);
    text-decoration: none;
    display: block;
    padding: 0.35rem 0.6rem;
    border-radius: 3px;
    font-size: 0.95rem;
}
.aeon-sidebar nav a:hover {
    color: var(--aeon-fg);
    background: rgba(0, 0, 0, 0.04);
}
@media (prefers-color-scheme: dark) {
    .aeon-sidebar nav a:hover { background: rgba(255, 255, 255, 0.05); }
}
.aeon-sidebar-empty {
    color: var(--aeon-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* Close button: visible only on mobile drawer. */
.aeon-sidebar-close {
    display: none;
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--aeon-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    user-select: none;
}

/* Desktop: persistent two-column layout. */
@media (min-width: 900px) {
    .aeon-layout-sidebar {
        display: grid;
        grid-template-columns: 240px 1fr;
        gap: 0;
        align-items: start;
    }
    .aeon-sidebar {
        position: sticky;
        top: 0;
        max-height: 100vh;
        overflow-y: auto;
        transition: width 0.2s ease, padding 0.2s ease, opacity 0.2s ease;
    }
    .aeon-sidebar-main {
        padding: 2rem 2rem 4rem;
        max-width: 760px;
    }
    /* Collapse: sidebar shrinks to a thin rail, main widens. */
    .aeon-sidebar-toggle-input:checked ~ .aeon-sidebar {
        width: 0;
        padding: 0;
        overflow: hidden;
        opacity: 0;
        border-right: 0;
    }
    .aeon-sidebar-toggle-input:checked ~ .aeon-sidebar-main {
        grid-column: 1 / -1;
    }
    .aeon-sidebar-toggle-btn {
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 50;
        width: 32px;
        height: 32px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        background: rgba(255,255,255,0.85);
        border: 1px solid rgba(0,0,0,0.12);
        border-radius: 4px;
        cursor: pointer;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
    .aeon-sidebar-toggle-btn span {
        display: block;
        width: 16px;
        height: 2px;
        background: var(--aeon-fg);
    }
}
@media (prefers-color-scheme: dark) and (min-width: 900px) {
    .aeon-sidebar-toggle-btn {
        background: rgba(30,30,30,0.85);
        border-color: rgba(255,255,255,0.15);
    }
}

/* Mobile: sidebar becomes an off-canvas drawer. */
@media (max-width: 899px) {
    .aeon-sidebar-main {
        padding: 1.25rem 1rem 4rem;
    }
    .aeon-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 80%;
        max-width: 300px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 2px 0 16px rgba(0,0,0,0.15);
        overflow-y: auto;
    }
    .aeon-sidebar-close {
        display: block;
    }
    .aeon-sidebar-toggle-input:checked ~ .aeon-sidebar {
        transform: translateX(0);
    }
    /* Backdrop: pseudo-element that darkens the page when drawer is open. */
    .aeon-sidebar-toggle-input:checked ~ .aeon-sidebar-main::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 150;
    }
    /* Hamburger trigger on mobile — sits below the login icon. */
    .aeon-sidebar-toggle-btn {
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 50;
        width: 34px;
        height: 34px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        background: rgba(255,255,255,0.9);
        border: 1px solid rgba(0,0,0,0.12);
        border-radius: 4px;
        cursor: pointer;
    }
    .aeon-sidebar-toggle-btn span {
        display: block;
        width: 18px;
        height: 2px;
        background: var(--aeon-fg);
    }
}
@media (prefers-color-scheme: dark) and (max-width: 899px) {
    .aeon-sidebar-toggle-btn {
        background: rgba(30,30,30,0.9);
        border-color: rgba(255,255,255,0.15);
    }
    .aeon-sidebar { background: #1a1a1a; box-shadow: 2px 0 20px rgba(0,0,0,0.6); }
}

/* Respect reduced motion for drawer animation */
@media (prefers-reduced-motion: reduce) {
    .aeon-sidebar { transition: none; }
}

/* ---------------------------------------------------------------------------
 * Gallery template — v0.4
 * -------------------------------------------------------------------------*/

.aeon-gallery-main {
    max-width: 1200px;
    padding: 1.5rem 1rem 4rem;
}

.aeon-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.aeon-gallery-grid > .aeon-block-wrap,
.aeon-gallery-grid > figure {
    margin: 0;
}

/* Edit mode: each block sits inside .aeon-block-wrap which becomes the grid
 * item. Make it behave like the figure would in view mode so the inner
 * figure/img/video stays the same size. Without this, the block-wrap has no
 * height and the figure escapes the grid track. Reported as "edit mode shows
 * full-size images while view mode looks fine" in v0.5.0 testing. */
.aeon-gallery-grid > .aeon-block-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0; /* prevent figcaption text from forcing the grid item wider */
    /* The block controls bar sits above; give it a smidge of breathing room. */
    padding: 0.1rem;
}

.aeon-gallery-grid > .aeon-block-wrap > figure {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.aeon-gallery-grid figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.aeon-gallery-grid figure img,
.aeon-gallery-grid figure video,
.aeon-gallery-grid > .aeon-block-wrap > figure img,
.aeon-gallery-grid > .aeon-block-wrap > figure video {
    width: 100%;
    height: 240px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

/* Lightbox triggers (the <a> wrapping a thumbnail) should not show as a link. */
.aeon-gallery-grid .aeon-lb-trigger {
    display: block;
    text-decoration: none;
    color: inherit;
}

.aeon-gallery-grid figcaption {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    text-align: center;
    color: var(--aeon-muted);
}

/* YouTube/Vimeo iframes need the 16:9 wrapper which is already set elsewhere;
 * inside a gallery we constrain it to the fixed grid item height. */
.aeon-gallery-grid .aeon-video-embed {
    height: 240px;
    padding-bottom: 0;
}
.aeon-gallery-grid .aeon-video-embed iframe {
    position: absolute;
    inset: 0;
    height: 100%;
}

@media (max-width: 520px) {
    .aeon-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.5rem;
    }
    .aeon-gallery-grid figure img,
    .aeon-gallery-grid figure video,
    .aeon-gallery-grid > .aeon-block-wrap > figure img,
    .aeon-gallery-grid > .aeon-block-wrap > figure video,
    .aeon-gallery-grid .aeon-video-embed { height: 160px; }
}

.aeon-empty-hint {
    color: var(--aeon-muted);
    font-style: italic;
    text-align: center;
    padding: 3rem 1rem;
    border: 1px dashed var(--aeon-border);
    border-radius: 6px;
}

/* ---------------------------------------------------------------------------
 * Lightbox — v0.6
 * Pure CSS overlay using :target. Clicking a thumbnail wraps a link to
 * #aeon-lb-{hash}; the matching .aeon-lightbox:target gets shown. Clicking
 * the X or backdrop links to a non-existent anchor (#aeon-lb-close), which
 * clears :target and the lightbox closes.
 * Edit mode does NOT emit lightbox markup, so this never fights the editor.
 * -------------------------------------------------------------------------*/

.aeon-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw;
}
.aeon-lightbox:target {
    display: flex;
}

.aeon-lightbox img,
.aeon-lightbox video {
    max-width: min(96vw, 1400px);
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 6px 32px rgba(0, 0, 0, 0.5);
    background: #000;
}

.aeon-lightbox-backdrop {
    position: absolute;
    inset: 0;
    cursor: zoom-out;
    /* Backdrop is a real link (so :target can be cleared by clicking it),
     * but it should not show like one. */
    text-decoration: none;
    color: transparent;
    font-size: 0;
}

.aeon-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.92);
    color: #000;
    border-radius: 50%;
    text-decoration: none;
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 300;
    z-index: 1;
    transition: background 0.15s ease, transform 0.15s ease;
    /* Make sure the X stays on top of the backdrop. */
    cursor: pointer;
}
.aeon-lightbox-close:hover,
.aeon-lightbox-close:focus {
    background: #fff;
    transform: scale(1.05);
    outline: none;
}
.aeon-lightbox-close:focus-visible {
    box-shadow: 0 0 0 3px rgba(106, 160, 255, 0.6);
}

/* Trigger styling: the link wrapping the thumbnail. Show a subtle hover hint
 * outside galleries (inside galleries, the grid handles its own look). */
.aeon-lb-trigger {
    display: inline-block;
    cursor: zoom-in;
    text-decoration: none;
    color: inherit;
}
.aeon-lb-trigger:focus-visible {
    outline: 2px solid var(--aeon-link);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .aeon-lightbox-close { transition: none; }
}

/* ---------------------------------------------------------------------------
 * Search block — v0.7
 * Renders as a small inline form. Themes can override.
 * -------------------------------------------------------------------------*/

.aeon-search-form {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    max-width: 480px;
}

.aeon-search-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--aeon-border);
    border-radius: 4px;
    background: var(--aeon-bg);
    color: var(--aeon-fg);
    font-family: var(--aeon-font-body);
    font-size: 0.95rem;
    box-sizing: border-box;
}
.aeon-search-input:focus {
    outline: none;
    border-color: var(--aeon-link);
    box-shadow: 0 0 0 3px rgba(0, 71, 171, 0.15);
}

.aeon-search-button {
    flex: 0 0 auto;
    padding: 0.55rem 1.1rem;
    border-radius: 4px;
    border: 1px solid var(--aeon-fg);
    background: var(--aeon-fg);
    color: var(--aeon-bg);
    font-family: var(--aeon-font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}
.aeon-search-button:hover { opacity: 0.85; }
.aeon-search-button:disabled,
.aeon-search-input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Search results page: highlight match terms inside snippets. */
.content mark {
    background: rgba(255, 235, 100, 0.55);
    color: inherit;
    padding: 0 0.1em;
    border-radius: 2px;
}

@media (max-width: 480px) {
    .aeon-search-form { flex-wrap: wrap; }
    .aeon-search-input { width: 100%; flex: 1 1 100%; }
}

/* ---------------------------------------------------------------------------
 * Inline kbd — v0.8 (keyboard shortcuts in help page and elsewhere)
 * -------------------------------------------------------------------------*/

.content kbd {
    display: inline-block;
    padding: 1px 7px;
    font-family: var(--aeon-font-mono);
    font-size: 0.85em;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--aeon-border);
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
    vertical-align: baseline;
    line-height: 1.3;
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    .content kbd {
        background: rgba(255, 255, 255, 0.06);
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
    }
}
