/* style.css - Cleaned & Optimized */

:root {
    /* --- 1. LAYOUT & SIZING (Adjust these to change site size) --- */
    --max-width: 1200px;       /* Increased from 800px to fill modern screens */
    --body-padding: 10px;      /* Space around the very edge of the window */
    --container-padding: 25px; /* Space inside the white box */
    --border-radius: 6px;      /* Roundness of corners */

    /* --- 2. COLORS --- */
    --bg-color: #f4f4f4;       /* Background of the page */
    --container-bg: #ffffff;   /* Background of the content box */
    --primary: #2c3e50;        /* Main dark blue color */
    --accent: #A020F0;         /* Links and highlights */
    --text: #333333;           /* Main text color */

    /* --- 3. FONTS --- */
    /* UI: Menus, Sidebars, Footer (Clean Sans-Serif) */
    --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* TITLES: Blog Name, Post Headers (Distinctive) */
    --font-site-title: "Impact", "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", Tahoma, sans-serif;

    /* HEADINGS: Post Titles, h1-h4 inside articles */
    --font-headings: "Trebuchet MS", "Lucida Grande", "Lucida Sans Unicode", Tahoma, sans-serif;

    /* BODY: The actual stories (Readable Serif) */
    --font-body: Georgia, "Times New Roman", Times, serif;

    /* CODE: Snippets */
    --font-code: "Courier New", Courier, monospace;}


/* --- BOOKMARK COLLECTIONS (Single Column List) --- */
.bookmark-grid {
    display: grid;
    /* Force exactly 1 column, regardless of screen size */
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 20px 0;
}

.bookmark-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
}

.bookmark-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-color: var(--accent);
}

.bookmark-card h4 {
    /* Keep the tight spacing you liked */
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
    margin-inline-start: 0 !important;
    margin-inline-end: 0 !important;
    margin: 0 !important;

    padding: 0 !important;
    line-height: 1.1 !important;
    font-size: 1.1em;
}

.bookmark-card a {
    text-decoration: none;
    color: var(--primary);
    display: block;
}

.bookmark-card a:hover {
    color: var(--accent);
}

.bookmark-card .desc {
    margin-top: 2px !important;
    font-size: 0.9em;
    color: #666;
    line-height: 1.3;
}

/* --- BASE STYLES --- */
body {
    font-family: var(--font-ui);
    background-color: var(--bg-color);
    background-image: var(--theme-body-bg-image, none);
    background-repeat: var(--theme-body-bg-repeat, repeat);
    background-size: var(--theme-body-bg-size, auto);
    background-position: var(--theme-body-bg-position, top left);
    background-attachment: var(--theme-body-bg-attachment, scroll);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: var(--body-padding);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    background-color: var(--container-bg);
    background-image: var(--theme-container-bg-image, none);
    background-repeat: var(--theme-container-bg-repeat, repeat);
    padding: var(--container-padding);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: var(--theme-container-border-width, 0) solid transparent;
    border-image-source: var(--theme-container-border-image, none);
    border-image-slice: var(--theme-container-border-slice, 30);
    border-image-repeat: round;
    border-image-width: 1;
}

img { max-width: 100%; height: auto; }

/* --- HEADER & NAV --- */
header {
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 15px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-image: var(--theme-header-bg-image, none), var(--theme-header-bottom-edge-image, none);
    background-repeat: var(--theme-header-bg-repeat, repeat), repeat-x;
    background-position: top center, bottom center;
}

/* Site title backdrop (optional theme image behind the H1) */
header h1 {
    background-image: var(--theme-title-bg-image, none);
    background-repeat: repeat-x;
    background-position: center;
    background-size: contain;
    padding: 0 12px;
}

/* Apply Title Font to all headings */
h1, h2, h3, h4 {
    font-family: var(--font-headings);
    color: var(--primary);
    margin-top: 0;
}


/* 2. Site Title Override (The Top Header Only) */
header h1 {
    font-family: var(--font-site-title);
    font-weight: bold;
    letter-spacing: -1px; /* Optional: Makes it look more like a logo */
    /* Per-theme override; the optional text-effect (shadow/stroke/glow) is
       injected by emitThemeStyles() when a preset specifies one. */
    color: var(--site-title-color, var(--primary));
}
header h1 a { color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav-links a { margin-left: 15px; font-weight: bold; }

/* --- LAYOUT GRID SYSTEM (Sidebars) --- */
.layout-grid {
    display: flex;
    gap: 30px; /* Space between columns */
    align-items: flex-start;
}

.main-content {
    flex: 3;
    min-width: 0; /* Prevents overflow issues */
}

.sidebar {
    flex: 1;
    background-color: #f9f9f9;
    background-image: var(--theme-sidebar-bg-image, none);
    background-repeat: var(--theme-sidebar-bg-repeat, repeat);
    padding: 15px;
    border-radius: var(--border-radius);
    border: var(--theme-sidebar-border-width, 1px) solid #eee;
    border-image-source: var(--theme-sidebar-border-image, none);
    border-image-slice: var(--theme-sidebar-border-slice, 20);
    border-image-repeat: round;
    border-image-width: 1;
    font-size: 0.9em;
}

.sidebar h3 {
    margin-top: 0;
    border-bottom: 2px solid #ddd;
    padding-bottom: 8px;
    margin-bottom: 12px;
    font-size: 1.1em;
    color: var(--primary);
}

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { border-bottom: 1px solid #eee; }
.sidebar li a { display: block; padding: 6px 0; color: #555; }
.sidebar li a:hover { color: var(--primary); padding-left: 5px; transition: padding 0.2s; }

/* --- POSTS --- */
.post-preview {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

/* Status banner shown to logged-in editors when they view a hidden post
   (draft, scheduled-future, or expired). Public visitors never see this
   because they get a 404 instead. */
.post-status-banner {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 10px 14px;
    border-radius: 4px;
    margin: 0 0 20px 0;
    font-size: 0.92em;
}
.post-status-banner strong { color: #856404; }
.post-status-banner a {
    margin-left: 10px;
    color: #856404;
    text-decoration: underline;
}
.post-status-banner a:hover { color: #533f03; }

/* Archived variant — visible to everyone, slightly different palette so it
   reads as "permanent record" rather than "hidden in-progress." */
.post-status-banner.archived-banner {
    background: #f0e8d6;
    border-color: #c4b890;
    color: #5a4a1f;
}
.post-status-banner.archived-banner strong,
.post-status-banner.archived-banner a {
    color: #5a4a1f;
}
.post-status-banner.archived-banner a:hover { color: #3a2f10; }

/* Featured-image thumbnail on the index post-preview */
.post-thumb-link {
    display: block;
    float: left;
    margin: 0 18px 6px 0;
}
.post-thumb {
    display: block;
    width: 180px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    background: #ddd;
}
.post-preview::after {
    content: "";
    display: block;
    clear: both;
}
@media (max-width: 600px) {
    .post-thumb-link { float: none; margin: 0 0 10px 0; }
    .post-thumb { width: 100%; height: auto; max-height: 200px; }
}

/* --- VIDEO FACADES (click to load iframe). Shared base for YouTube + Vimeo. --- */
.yt-facade, .vimeo-facade {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    background-color: #000;
    cursor: pointer;
    margin: 20px 0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.15s;
}
.yt-facade:hover, .vimeo-facade:hover {
    box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}
.yt-fallback-link, .vimeo-fallback-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    width: 100%;
    height: 100%;
}
.yt-play, .vimeo-play {
    width: 84px;
    height: 60px;
    border: none;
    border-radius: 12px;
    background: rgba(20,20,20,0.75);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    line-height: 1;
}
.yt-facade:hover    .yt-play    { background: #cc0000; transform: scale(1.08); }
.vimeo-facade:hover .vimeo-play { background: #00adef; transform: scale(1.08); }
.yt-badge, .vimeo-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    pointer-events: none;
}
.yt-facade iframe, .vimeo-facade iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- X / TWITTER FACADE (click to load widgets.js) --- */
.x-facade {
    margin: 20px 0;
    border: 1px solid #cfd9de;
    border-radius: 14px;
    padding: 14px 18px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
    color: inherit;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.x-facade:hover {
    background: #f7f9f9;
    border-color: #b0bcc4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.x-facade.loaded { display: none; }
.x-card-body {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}
.x-logo {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
}
.x-meta { min-width: 0; }
.x-author { font-weight: 700; font-size: 0.98em; color: #0f1419; }
.x-hint { font-size: 0.82em; color: #536471; margin-top: 2px; }
.x-view-link {
    color: #1d9bf0;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
    flex-shrink: 0;
}
.x-facade:hover .x-view-link { text-decoration: underline; }
.x-loaded-tweet { margin: 20px 0; }
.x-loaded-tweet blockquote.twitter-tweet { margin: 0 auto; }

/* --- PHOTO GALLERY WIDGETS --- */

.gallery-widget {
    margin: 24px 0;
}
.gallery-widget .gallery-thumb {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #eee;
    cursor: zoom-in;
    text-decoration: none;
}
.gallery-widget .gallery-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}
.gallery-widget .gallery-thumb:hover img {
    transform: scale(1.05);
}

/* Grid style: responsive square tiles */
.gallery-widget.gallery-style-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.gallery-widget.gallery-style-grid .gallery-thumb {
    aspect-ratio: 1 / 1;
}

/* Strip style: horizontal scrollable row */
.gallery-widget.gallery-style-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0 12px;
    -webkit-overflow-scrolling: touch;
}
.gallery-widget.gallery-style-strip .gallery-thumb {
    flex: 0 0 auto;
    width: 200px;
    aspect-ratio: 4 / 3;
}

/* Mosaic style: CSS-columns masonry. Photos keep their natural aspect ratio
   and pack into vertical columns — Pinterest-style. Override the default
   .gallery-thumb img cover/fixed-aspect rules. */
.gallery-widget.gallery-style-mosaic {
    /* CSS columns naturally produce a masonry layout for items of varying
       heights. column-count can be overridden per-call via --mosaic-cols. */
    column-count: var(--mosaic-cols, 3);
    column-gap: 8px;
}
.gallery-widget.gallery-style-mosaic .gallery-thumb {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    break-inside: avoid; /* don't split a single photo across two columns */
    aspect-ratio: auto;  /* override grid's 1/1 */
    overflow: hidden;
    border-radius: 4px;
}
.gallery-widget.gallery-style-mosaic .gallery-thumb img {
    display: block;
    width: 100%;
    height: auto;          /* preserve aspect ratio */
    object-fit: initial;   /* override grid's cover */
}
@media (max-width: 800px) {
    .gallery-widget.gallery-style-mosaic { column-count: 2; }
}
@media (max-width: 480px) {
    .gallery-widget.gallery-style-mosaic { column-count: 1; }
}

/* Preview style: single hero card that launches the lightbox at image 1.
   Used as a teaser when you don't want a wall of thumbnails. */
.gallery-widget.gallery-style-preview .gallery-thumb {
    display: block;
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background-color: #222;
    background-size: cover;
    background-position: center;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.gallery-widget.gallery-style-preview .gallery-thumb:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* Gradient at the bottom for caption legibility against any image */
.gallery-widget.gallery-style-preview .preview-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.75) 0%,
        rgba(0, 0, 0, 0.35) 35%,
        rgba(0, 0, 0, 0) 65%
    );
    padding: 22px 26px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none; /* let the click hit the <a>, not the overlay */
}
.gallery-widget.gallery-style-preview .preview-title {
    font-family: var(--font-headings, sans-serif);
    font-size: 1.6em;
    font-weight: bold;
    margin: 0;
    line-height: 1.2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.gallery-widget.gallery-style-preview .preview-meta {
    font-size: 0.88em;
    opacity: 0.92;
    margin-top: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.02em;
}

/* Play affordance in the top-right corner */
.gallery-widget.gallery-style-preview .preview-play {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    transition: background 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}
.gallery-widget.gallery-style-preview .gallery-thumb:hover .preview-play {
    background: var(--accent, #c89c3b);
    transform: scale(1.08);
}

@media (max-width: 600px) {
    .gallery-widget.gallery-style-preview .preview-overlay { padding: 14px 18px; }
    .gallery-widget.gallery-style-preview .preview-title   { font-size: 1.25em; }
    .gallery-widget.gallery-style-preview .preview-play    { width: 40px; height: 40px; font-size: 18px; top: 12px; right: 12px; }
}

/* --- FULLSCREEN LIGHTBOX --- */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
.gallery-lightbox.active {
    display: flex;
}

.gallery-lightbox .image-frame {
    position: relative;
    display: inline-block;
    max-width: 92vw;
    max-height: 88vh;
}
.gallery-lightbox .lightbox-img {
    display: block;
    max-width: 92vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    /* Aspect ratio is preserved naturally — no object-fit needed since
       the img sizes to its natural dimensions, bounded by the max values. */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    user-select: none;
}

/* Close button */
.gallery-lightbox .lightbox-close {
    position: fixed;
    top: 18px;
    right: 18px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.gallery-lightbox .lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Counter (e.g. "3 / 17") */
.gallery-lightbox .lightbox-counter {
    position: fixed;
    top: 22px;
    left: 22px;
    color: rgba(255, 255, 255, 0.7);
    font: 600 0.85em/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 14px;
    border-radius: 14px;
    z-index: 10001;
}

/* Navigation zones (left 33%, right 33%) */
.gallery-lightbox .nav-zone {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 33vw;
    z-index: 10000;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s;
}
.gallery-lightbox .nav-zone:hover {
    background: rgba(255, 255, 255, 0.04);
}
.gallery-lightbox .nav-prev { left: 0;  justify-content: flex-start; padding-left: 24px; }
.gallery-lightbox .nav-next { right: 0; justify-content: flex-end;   padding-right: 24px; }

.gallery-lightbox .nav-arrow {
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    user-select: none;
}
.gallery-lightbox .nav-zone:hover .nav-arrow {
    opacity: 1;
}
.gallery-lightbox .nav-zone:hover .nav-arrow {
    transform: scale(1.05);
}
.gallery-lightbox.single-image .nav-zone {
    display: none; /* hide nav when there's only one image */
}

/* --- CAPTION (multiple styles) --- */
.gallery-lightbox .image-caption {
    position: absolute;
    left: 6%;
    right: 6%;
    bottom: 0;
    color: #fff;
    text-align: center;
    z-index: 10001;
    pointer-events: none;
    display: none; /* shown when a non-default caption style is active */
    word-wrap: break-word;
}

/* Style: frosted — 1/3 of the box overlaps the bottom of the image, 2/3 hangs below.
   Translate by 66% so the box's bottom sits 66% of its height below the image bottom. */
.gallery-lightbox.caption-frosted .image-caption {
    display: block;
    transform: translateY(66%);
    padding: 14px 22px;
    background: rgba(255, 255, 255, 0.13);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
    font-size: 0.92em;
    line-height: 1.45;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Style: overlay — classic dark bar pinned over the bottom of the image. */
.gallery-lightbox.caption-overlay .image-caption {
    display: block;
    bottom: 10px;
    padding: 10px 18px;
    background: rgba(0, 0, 0, 0.68);
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Style: none — no caption (default). Nothing to do; .image-caption stays display:none. */

/* Empty caption: hide even when style is active */
.gallery-lightbox .image-caption:empty { display: none; }

/* --- BODY-SCROLL LOCK when lightbox is open --- */
body.lightbox-open { overflow: hidden; }

/* --- Mobile tweaks --- */
@media (max-width: 600px) {
    .gallery-lightbox .nav-zone { width: 25vw; }
    .gallery-lightbox .nav-arrow { width: 44px; height: 44px; font-size: 24px; }
    .gallery-lightbox .lightbox-img { max-width: 96vw; max-height: 80vh; }
    .gallery-lightbox .image-frame  { max-width: 96vw; max-height: 80vh; }
    .gallery-lightbox.caption-frosted .image-caption { font-size: 0.85em; padding: 10px 16px; }
}

/* --- "SHARE ON X" BUTTON --- */
.post-share {
    margin: 30px 0 0;
    padding-top: 18px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.share-x {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #000;
    color: #fff !important;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88em;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    transition: opacity 0.15s;
}
.share-x:hover { opacity: 0.85; text-decoration: none !important; color: #fff !important; }
.share-x::before {
    content: "\1D54F"; /* mathematical bold X (𝕏) — clean glyph that reads as the X logo */
    font-size: 1.05em;
    font-weight: bold;
}
/* When a theme divider image is set, emitThemeStyles() also emits a body
   class + ::after rule that swaps in the image. The default border above
   keeps showing when no image is set. */
.meta { font-size: 0.85em; color: #777; margin-bottom: 8px; display: block; }
.tags span {
    background: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8em;
    margin-right: 5px;
}

/* --- FORMS & BUTTONS --- */
input, textarea, select {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

button {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
button:hover { opacity: 0.9; }

/* --- TOP NAVIGATION MENU --- */
.top-menu {
    background-color: var(--theme-menu-bg-color, #eee);
    background-image:
        var(--theme-menu-left-cap, none),
        var(--theme-menu-right-cap, none),
        var(--theme-menu-middle-tile, none);
    background-repeat: no-repeat, no-repeat, repeat-x;
    background-position: left center, right center, center;
    background-size: auto 100%, auto 100%, auto 100%;
    min-height: var(--theme-menu-height, auto);
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.top-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}
.top-menu a { font-weight: bold; color: var(--primary); }

/* Top-menu submenus: dropdown on hover/focus */
.top-menu li { position: relative; }
.top-menu .submenu-caret { font-size: 0.75em; opacity: 0.7; }
.top-menu ul.submenu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    min-width: 180px;
    padding: 5px 0;
    margin: 4px 0 0 0;
    z-index: 1000;
    flex-direction: column;
    gap: 0;
}
.top-menu li.has-submenu:hover > ul.submenu,
.top-menu li.has-submenu:focus-within > ul.submenu {
    display: flex;
}
.top-menu ul.submenu li { width: 100%; }
.top-menu ul.submenu a {
    display: block;
    padding: 8px 15px;
    font-weight: normal;
    color: #333;
    border-bottom: 1px solid #f5f5f5;
}
.top-menu ul.submenu a:hover {
    background: #f0f0f0;
    color: var(--primary);
    text-decoration: none;
}

/* Sidebar menus: submenus always visible, indented under their parent */
.sidebar ul.sidebar-menu,
.sidebar ul.sidebar-menu ul.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sidebar ul.sidebar-menu ul.submenu {
    margin-left: 14px;
    border-left: 2px solid #ddd;
    padding-left: 8px;
    margin-bottom: 4px;
}
.sidebar ul.sidebar-menu ul.submenu li a {
    padding: 4px 0;
    font-size: 0.95em;
    color: #666;
}
.sidebar ul.sidebar-menu ul.submenu li a:hover { color: var(--primary); }

/* --- TAG DROPDOWN --- */
.tag-dropdown { display: inline-block; position: relative; vertical-align: middle; }
.tag-dropdown summary {
    cursor: pointer;
    list-style: none;
    background: #f0f0f0;
    padding: 6px 10px;
    border-radius: 4px;
    user-select: none;
}
.tag-dropdown summary:hover { background: #e0e0e0; }

.tag-menu {
    position: absolute;
    top: 100%; right: 0;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-radius: 4px;
    min-width: 200px;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    padding: 5px 0;
}
.tag-menu a { display: block; padding: 8px 15px; color: #333; border-bottom: 1px solid #f9f9f9; }
.tag-menu a:hover { background-color: #f0f0f0; color: var(--primary); }

/* --- ADMIN TABLE LAYOUT --- */
.admin-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid #eee; vertical-align: middle; }
.col-title { width: 55%; }
.col-status { width: 10%; text-align: center; }
.col-date { width: 15%; white-space: nowrap; text-align: center; }
.col-actions { width: 20%; white-space: nowrap; text-align: right; }

.title-wrapper {
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}

/* Hover Preview Popup */
.preview-popup {
    visibility: hidden; opacity: 0;
    width: 300px;
    background-color: var(--primary);
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 15px;
    position: absolute;
    z-index: 1000;
    top: 100%; left: 20px;
    white-space: normal;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transition: opacity 0.3s, top 0.3s;
    pointer-events: none;
}
.title-wrapper:hover .preview-popup { visibility: visible; opacity: 1; top: 80%; }
.preview-popup::after {
    content: "";
    position: absolute; bottom: 100%; left: 20px;
    border-width: 5px; border-style: solid;
    border-color: transparent transparent var(--primary) transparent;
}

/* --- MODAL --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); }
.modal-content {
    background-color: #fff;
    margin: 15% auto;
    padding: 20px;
    border-radius: 8px;
    width: 300px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    text-align: center;
}
.modal-actions { margin-top: 20px; display: flex; justify-content: space-around; }
.btn-cancel { background: #ccc; color: #333; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
.btn-confirm { background: #d9534f; color: white; padding: 8px 16px; border-radius: 4px; cursor: pointer; text-decoration: none; }
.btn-confirm:hover { background: #c9302c; }

/* --- CONTENT TYPOGRAPHY --- */

/* --- CONTENT TYPOGRAPHY --- */
.content {
    font-family: var(--font-body); /* The main reading font */
    font-size: 1.1em;              /* Slightly larger for readability */
    line-height: 1.1;              /* More breathing room for text */
}
.content p { margin-top: 0; margin-bottom: 10px; }
.content img { max-width: 100%; height: auto; }

/* Retro Code Block */
.content pre {
    background-color: #020a02; color: #4af626;
    border: 1px solid #1f5c1f; border-left: 5px solid #000;
    text-shadow: 0 0 3px rgba(74, 246, 38, 1.0), 0 0 15px rgba(74, 246, 38, 0.8), 0 0 30px rgba(74, 246, 38, 0.4);
    transform: scaleX(0.75); transform-origin: top left; width: 133.33%;
    font-family: var(--font-code);
    font-size: 15px; line-height: 1.4;
    padding: 15px; margin-bottom: 20px;
    display: block; overflow-x: auto;
    border-radius: 4px; box-sizing: border-box;
}

/* Editor Overrides (Clean style for admin) */
.note-editable p { margin-top: 0 !important; margin-bottom: 5px !important; }
.note-editable pre {
    background: #f4f4f4; color: #333;
    border: 1px solid #ccc; border-left: 4px solid #555;
    padding: 10px; font-family: monospace; font-size: 14px;
    width: 100%; transform: none; margin-bottom: 10px; text-shadow: none;
}

/* --- FOOTER --- */
.site-footer {
    margin-top: 40px;
    border-top: 2px solid #eee;
    background-color: #f9f9f9;
    background-image: var(--theme-footer-bg-image, none), var(--theme-footer-top-edge-image, none);
    background-repeat: var(--theme-footer-bg-repeat, repeat), repeat-x;
    background-position: center, top center;
    color: #555;
    padding: 10px 20px;
    font-size: 0.8em;
}

.footer-content { display: flex; justify-content: space-between; gap: 20px; align-items: center; flex-wrap: wrap; }
.footer-col { flex: 1; }
.footer-col h3 { margin: 0 0 5px 0; color: var(--primary); font-size: 1.1em; }
.footer-col p { margin: 0; line-height: 1.4; color: #666; }

.footer-links { list-style: none; padding: 0; margin: 0; text-align: right; }
.footer-links li { display: inline-block; margin-left: 15px; }
.footer-links li a { color: #555; }
.footer-links li a:hover { color: var(--primary); text-decoration: underline; }

/* --- PAGINATION --- */
.pagination { display: flex; justify-content: space-between; margin-top: 40px; border-top: 1px solid #eee; padding-top: 20px; }

/* --- MOBILE RESPONSIVENESS (Combined) --- */
@media (max-width: 768px) {
    .layout-grid { flex-direction: column; }
    .sidebar { width: 100%; margin-bottom: 20px; }
    .main-content { order: 1; }
    .sidebar-left { order: 2; }
    .sidebar-right { order: 3; }

    .tag-menu { right: auto; left: 0; }

    .footer-content { flex-direction: column; text-align: center; }
    .footer-links { text-align: center; margin-top: 10px; }
    .footer-links li { margin: 0 8px; }

    /* Header can stack title above search/menu when cramped */
    header { flex-wrap: wrap; gap: 10px; }
}

/* --- TOUCH ERGONOMICS -----------------------------------------------------
   Larger hit areas, click-toggleable submenus, and a few small layout tweaks
   for viewers on phones and tablets. Most rules apply universally (chunky
   touch-targets don't hurt mouse users); a few are gated on (hover: none)
   when the change would meaningfully change desktop density. */

/* Tag pills — clearly tappable */
.tags span {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.82em;
    margin: 0 4px 4px 0;
    line-height: 1.5;
}

/* Sidebar links — taller hit area */
.sidebar li a {
    padding: 10px 4px;
}

/* Footer links */
.footer-links li a {
    display: inline-block;
    padding: 8px 4px;
}

/* Pagination links — more breathing room */
.pagination a {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 4px;
    background: transparent;
    transition: background 0.15s;
}
.pagination a:hover { background: #f0f0f0; text-decoration: none; }

/* Header search field — never cramped */
.nav-links input[type="text"] {
    padding: 8px 10px;
    font-size: 1em;
}

/* --- Touch-only adjustments (devices with no hover capability) --- */
@media (hover: none) {
    /* Even bigger touch targets where space allows */
    .tags span         { padding: 7px 12px; font-size: 0.88em; }
    .sidebar li a      { padding: 12px 6px; }
    .footer-links li a { padding: 10px 8px; }
    .pagination a      { padding: 12px 20px; background: #f5f5f5; }
    .pagination a:active { background: #e8e8e8; }

    /* The site title link should feel chunky to tap */
    header h1 a { display: inline-block; padding: 4px 0; }
}

/* --- Touch-driven submenu opening ---
   On hover-capable devices the existing :hover rule fires. On touch devices,
   JS toggles .submenu-open on the parent <li>. */
.top-menu li.has-submenu.submenu-open > ul.submenu {
    display: flex;
}
/* Visually indicate the parent is "expanded" on touch */
.top-menu li.has-submenu.submenu-open > a .submenu-caret {
    transform: rotate(180deg);
    display: inline-block;
}
.top-menu .submenu-caret {
    transition: transform 0.15s;
}

/* --- Narrow phones: stack the header so search/menu get full width --- */
@media (max-width: 480px) {
    header { flex-direction: column; align-items: stretch; }
    header h1 { text-align: center; }
    .nav-links { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
    .nav-links form { display: block; flex: 1 1 100%; margin: 0 0 4px 0 !important; }
    .nav-links input[type="text"] { width: 100%; box-sizing: border-box; }

    /* Tag menu spans full width inside the narrow header */
    .tag-dropdown { width: 100%; }
    .tag-dropdown summary { text-align: center; }
}

/* --- Social & profile links bar -------------------------------------------
 * Used by the footer, the sidebar widget, and the [SOCIAL] in-post macro.
 * Every icon renders in a fixed-size box so admins don't have to hand-tune
 * their uploads. The .social-bar-brand variant lets each <a>'s inline
 * color: drive the icon (one per platform, set in PHP). The .social-bar-mono
 * variant overrides everything to the theme accent for a uniform look.
 */
.social-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    line-height: 1;
}
.social-bar .social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: #444;             /* brand variant overrides this per-link via style="color:..." */
    text-decoration: none;
    transition: transform 0.12s ease, opacity 0.12s ease;
}
.social-bar .social-link:hover {
    transform: translateY(-2px);
    opacity: 0.85;
}
.social-bar .social-link svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    display: block;
}
.social-bar .social-link .social-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;     /* normalize whatever the admin uploaded */
    display: block;
}
/* Mono variant: ignore the per-link brand color, force everything to accent */
.social-bar-mono .social-link { color: var(--accent) !important; }

/* Footer placement: a quiet row centered below the existing columns */
.footer-social {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    justify-content: center;
}
.footer-social .social-bar { justify-content: center; }

/* Sidebar widget: tighter spacing so it sits well next to other widgets */
.widget-social .social-bar { gap: 8px; }
.widget-social .social-bar .social-link { width: 28px; height: 28px; }

/* In-post macro: slightly larger, centered by default */
.social-bar-macro { justify-content: center; margin: 16px 0; }
.social-bar-macro .social-link { width: 36px; height: 36px; }

