/* ===========================================================================
   Logbook — Ghost theme
   A typewritten personal log. IBM Plex Mono, black on white, muted green accent.
   Ported from the Chirpie Blade "logbook" theme.
   =========================================================================== */

:root {
    /* Ghost design settings inject --gh-font-heading / --gh-font-body when a
       publisher picks custom fonts; fall back to IBM Plex Mono otherwise. */
    --gh-font-heading: 'IBM Plex Mono', ui-monospace, monospace;
    --gh-font-body: 'IBM Plex Mono', ui-monospace, monospace;

    --accent: #4a7c59;
    --accent-hover: #3d6a4b;
    --bg: #ffffff;
    --text: #1a1a1a;
    --text-muted: #737373;     /* neutral-500 */
    --text-faint: #a3a3a3;     /* neutral-400 */
    --border: #e5e5e5;         /* neutral-200 */
    --surface: #fafafa;        /* neutral-50 */
    --scrollbar: #d4d4d4;
}

html.dark {
    --bg: #111111;
    --text: #e5e5e5;           /* neutral-200 */
    --text-muted: #a3a3a3;     /* neutral-400 */
    --text-faint: #737373;     /* neutral-500 */
    --border: #262626;         /* neutral-800 */
    --surface: #171717;        /* neutral-900 */
    --scrollbar: #404040;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body.log-body {
    margin: 0;
    font-family: var(--gh-font-body, 'IBM Plex Mono'), ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 15px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background-color: var(--accent);
    color: #fff;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

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

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

/* ---- Shell / layout -------------------------------------------------------- */

.log-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.log-main { flex: 1 0 auto; }

.log-container {
    max-width: 42rem;          /* max-w-2xl */
    margin-inline: auto;
    padding-inline: 1.5rem;
}

.log-feed-container,
.log-post,
.log-related {
    padding-top: 3rem;
    padding-bottom: 3rem;
}

.log-related { padding-top: 0; }

/* ---- Header / footer ------------------------------------------------------- */

.log-header { border-bottom: 1px solid var(--border); }
.log-footer { border-top: 1px solid var(--border); margin-top: auto; }

.log-nav,
.log-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: 1.5rem;
}

.log-title {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    transition: color 150ms ease;
}
.log-title:hover { color: var(--accent); }

.log-nav-links,
.log-footer-links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Ghost {{navigation}} renders a <ul class="nav"> */
.log-nav-links ul.nav,
.log-footer-links ul.nav {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.log-nav-link,
.log-nav-links a,
.log-footer-links a {
    color: var(--text-muted);
    transition: color 150ms ease;
}
.log-nav-link:hover,
.log-nav-links a:hover,
.log-footer-links a:hover {
    color: var(--text);
}

.log-footer-row {
    font-size: 0.875rem;
    color: var(--text-faint);
}
.log-footer-row p { margin: 0; }

/* ---- Feed ------------------------------------------------------------------ */

.log-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.log-empty {
    text-align: center;
    padding-block: 4rem;
    color: var(--text-faint);
}

/* Date header rows (inserted by logbook.js) */
.log-date-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
}
.log-date-header--spaced { padding-top: 2.5rem; }

.log-date-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-faint);
    flex-shrink: 0;
}
.log-date-rule {
    flex: 1;
    border-bottom: 1px solid var(--border);
}

/* ---- Entries --------------------------------------------------------------- */

.log-entry {
    padding-block: 1rem;
    opacity: 0;
    transform: translateY(8px);
    animation: logFadeIn 200ms ease-out forwards;
}
@keyframes logFadeIn {
    to { opacity: 1; transform: translateY(0); }
}
.log-feed-item:nth-child(1) .log-entry { animation-delay: 0ms; }
.log-feed-item:nth-child(2) .log-entry { animation-delay: 50ms; }
.log-feed-item:nth-child(3) .log-entry { animation-delay: 100ms; }
.log-feed-item:nth-child(4) .log-entry { animation-delay: 150ms; }
.log-feed-item:nth-child(5) .log-entry { animation-delay: 200ms; }
.log-feed-item:nth-child(6) .log-entry { animation-delay: 250ms; }
.log-feed-item:nth-child(7) .log-entry { animation-delay: 300ms; }
.log-feed-item:nth-child(8) .log-entry { animation-delay: 350ms; }
.log-feed-item:nth-child(9) .log-entry { animation-delay: 400ms; }
.log-feed-item:nth-child(10) .log-entry { animation-delay: 450ms; }

.log-row {
    display: flex;
    gap: 0.75rem;
}
.log-full-row { gap: 1rem; }

.log-marker {
    color: var(--accent);
    font-weight: 500;
    flex-shrink: 0;
    user-select: none;
    line-height: 1.6;
}
.log-marker-lg { font-size: 1.125rem; }

.link-arrow {
    display: inline-block;
    transition: transform 150ms ease;
}
a:hover .link-arrow { transform: translateX(2px); }

.log-body-col { flex: 1; min-width: 0; }

.log-time {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-faint);
}

.log-short { line-height: 1.625; color: var(--text); }

.log-excerpt {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Full */
.log-link-row,
.log-full-row { color: inherit; }

.log-thumb {
    flex-shrink: 0;
    width: 6rem;
    height: 6rem;
    overflow: hidden;
    border: 1px solid var(--border);
}
.log-thumb img { width: 100%; height: 100%; object-fit: cover; }

.log-full-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    transition: color 150ms ease;
}
.log-full-row:hover .log-full-title,
.log-link-row:hover .log-link-title,
.log-link-row:hover .log-photo-title { color: var(--accent); }

.log-meta {
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-faint);
}
.log-tag-inline { color: var(--accent); }

/* Link */
.log-link-title {
    margin: 0;
    font-weight: 500;
    color: var(--text);
    transition: color 150ms ease;
}

/* Photo */
.log-photo-title {
    margin: 0 0 0.75rem;
    font-weight: 500;
    color: var(--text);
    transition: color 150ms ease;
}
.log-photo-frame {
    overflow: hidden;
    border: 1px solid var(--border);
}
.log-photo-frame img { width: 100%; }

/* Card tags */
.log-card-tags,
.log-post-tags {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.log-post-tags { margin-top: 2rem; gap: 0.75rem; }
.log-tag {
    font-size: 0.75rem;
    color: var(--accent);
    transition: color 150ms ease;
}
.log-tag:hover { text-decoration: underline; }
.log-post-tags .log-tag { font-size: 0.875rem; }

/* Quote / video card bodies inherit the prose treatment but tighter */
.log-quote,
.log-video { margin: 0; }
.log-quote blockquote {
    margin: 0;
    font-style: italic;
    font-size: 1.125rem;
    line-height: 1.625;
}

/* ---- Archive header -------------------------------------------------------- */

.log-archive-header { margin-bottom: 2rem; }
.log-archive-label {
    font-size: 0.75rem;
    color: var(--text-faint);
}
.log-archive-title {
    margin: 0.25rem 0 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--accent);
}

/* ---- Single post ----------------------------------------------------------- */

.log-post-header { margin-bottom: 2rem; }

.log-post-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-faint);
    margin-bottom: 1rem;
}

.log-post-title {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.log-post-rule {
    width: 4rem;
    border-bottom: 2px solid var(--text);
}

.log-post-figure {
    margin: 0 0 2rem;
    border: 1px solid var(--border);
    overflow: hidden;
}
.log-post-figure img { width: 100%; }
.log-post-figure figcaption {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.log-post-footer { margin-top: 4rem; }
.log-post-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.log-author { display: flex; align-items: center; gap: 0.75rem; }
.log-author-avatar {
    width: 2rem; height: 2rem; border-radius: 9999px;
    object-fit: cover;
}
.log-author-initial {
    display: flex; align-items: center; justify-content: center;
    background: var(--surface);
    overflow: hidden;
}
/* Show just the first character of the author name as the initial. */
.log-author-initial span {
    font-size: 0.75rem;
    color: var(--text-faint);
    text-transform: uppercase;
    width: 1ch;
    overflow: hidden;
    white-space: nowrap;
}
.log-author-name { font-size: 0.875rem; color: var(--text-muted); }
.log-share {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 0.75rem; color: var(--text-faint);
}

/* Related */
.log-related-heading {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-faint);
    margin: 0 0 1rem;
}
.log-related {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: 4rem;
    margin-bottom: 3rem;
}
.log-related-list { display: flex; flex-direction: column; gap: 0.75rem; }
.log-related-item {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem;
}
.log-related-title {
    font-size: 0.875rem; color: var(--text);
    transition: color 150ms ease;
}
.log-related-item:hover .log-related-title { color: var(--accent); }
.log-related-date {
    font-size: 0.6875rem; color: var(--text-faint);
    flex-shrink: 0; font-variant-numeric: tabular-nums;
}

.log-comments { margin-top: 4rem; }

/* ---- Pagination ------------------------------------------------------------ */

.pagination {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-muted);
}
.pagination a { color: var(--accent); }
.pagination a:hover { text-decoration: underline; }

/* ---- Rendered post content (kg-prose) -------------------------------------- */
/* Equivalent of the Tailwind `prose` body used in the Blade theme. */

.kg-prose { color: var(--text); line-height: 1.8; }
.kg-prose > * { margin-top: 0; margin-bottom: 1.25em; }
.kg-prose > *:last-child { margin-bottom: 0; }

.kg-prose h1, .kg-prose h2, .kg-prose h3, .kg-prose h4 {
    font-family: var(--gh-font-heading, 'IBM Plex Mono'), ui-monospace, monospace;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    margin-top: 2em;
    margin-bottom: 0.75em;
}
.kg-prose h2 { font-size: 1.25rem; }
.kg-prose h3 { font-size: 1.1rem; }

.kg-prose a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(74, 124, 89, 0.3);
    text-underline-offset: 2px;
}
.kg-prose a:hover { text-decoration-color: var(--accent); }

.kg-prose blockquote {
    margin: 0;
    padding-left: 1rem;
    border-left: 3px solid var(--accent);
    font-style: italic;
    color: var(--text-muted);
}

.kg-prose code {
    color: var(--accent);
    font-size: 0.9em;
}
.kg-prose pre {
    background: #171717;
    border: 1px solid #262626;
    color: #e5e5e5;
    padding: 1rem;
    overflow-x: auto;
    border-radius: 4px;
}
.kg-prose pre code { color: inherit; }

.kg-prose img,
.kg-prose figure { border-radius: 4px; }
.kg-prose figure { margin: 1.5em 0; }
.kg-prose figcaption {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.kg-prose ul, .kg-prose ol { padding-left: 1.5rem; }
.kg-prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* Responsive video embeds.
   Ghost re-processes imported YouTube embeds into a .kg-embed-card holding an
   iframe at YouTube's small intrinsic width/height. Force any iframe inside a
   video card, an embed card, or our own 56.25% wrapper to fill the column at a
   16:9 ratio so it renders as a full-width player rather than a tiny thumbnail. */
.log-video,
.kg-embed-card {
    display: block;
    width: 100%;
}

.log-video .kg-embed-card,
.kg-prose .kg-embed-card,
.log-video figure,
.log-video iframe,
.kg-embed-card iframe,
.kg-prose iframe {
    width: 100% !important;
    max-width: 100%;
    margin-inline: 0;
}

/* 16:9 responsive frame for any embedded iframe. */
.log-video iframe,
.kg-embed-card iframe,
.kg-prose iframe[src*="youtube"],
.kg-prose iframe[src*="youtu.be"],
.kg-prose iframe[src*="vimeo"] {
    aspect-ratio: 16 / 9;
    height: auto;
    border: 1px solid var(--border);
    display: block;
}

/* Our exported wrapper (padding-bottom hack) already handles ratio; ensure the
   absolutely-positioned iframe inside it stays full-size. */
.log-video [style*="56.25%"] iframe,
.kg-prose [style*="56.25%"] iframe {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto;
}

/* ---- Koenig card width classes (required by Ghost) ------------------------- */

.kg-width-wide {
    position: relative;
    width: 75vw;
    min-width: 100%;
    margin-left: 50%;
    transform: translateX(-50%);
    max-width: 1000px;
}
.kg-width-full {
    position: relative;
    width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
    max-width: 100vw;
}
.kg-width-full img { width: 100%; }

.kg-image { margin-inline: auto; }
.kg-image-card img { margin-inline: auto; }

.kg-gallery-container {
    display: flex;
    flex-direction: column;
    max-width: 1000px;
    width: 100%;
}
.kg-gallery-row { display: flex; flex-direction: row; justify-content: center; }
.kg-gallery-image { margin: 4px; }
.kg-gallery-image img { display: block; width: 100%; height: 100%; }

/* Embed cards span the full column (see the responsive-video block above for
   the iframe sizing — do not center, which would shrink the player). */
.kg-embed-card {
    display: block;
    width: 100%;
}

.kg-bookmark-card { width: 100%; }
.kg-bookmark-container {
    display: flex;
    min-height: 148px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    overflow: hidden;
}
.kg-bookmark-content { flex-grow: 1; padding: 1rem; }
.kg-bookmark-title { font-weight: 600; }
.kg-bookmark-description { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.5rem; }
.kg-bookmark-thumbnail { position: relative; min-width: 33%; max-height: 100%; }
.kg-bookmark-thumbnail img { width: 100%; height: 100%; object-fit: cover; }

.kg-callout-card {
    display: flex;
    padding: 1rem 1.25rem;
    border-radius: 4px;
    background: var(--surface);
}
.kg-callout-emoji { padding-right: 0.75rem; }

.kg-button-card a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
}

/* ---- Custom font support (Ghost design settings) --------------------------- */

body.has-serif-title h1, body.has-serif-title h2,
body.has-serif-title .log-post-title { font-family: var(--font-heading, inherit); }
body.has-sans-body { font-family: var(--font-body, inherit); }

/* ---- Newsletter ------------------------------------------------------------ */

.log-newsletter {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.log-newsletter-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}
.log-newsletter form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.log-newsletter input[type="email"] {
    flex: 1;
    min-width: 12rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font: inherit;
    padding: 0.5rem 0.75rem;
}
.log-newsletter input[type="email"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
.log-newsletter button {
    background: var(--accent);
    color: #fff;
    border: none;
    font: inherit;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 150ms ease;
}
.log-newsletter button:hover { background: var(--accent-hover); }

/* Inline Ghost status messages are replaced by the toast, so keep them hidden. */
.log-newsletter-msg { display: none !important; }

/* ---- Toast ----------------------------------------------------------------- */

.log-toast {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 50;
    max-width: 22rem;
    padding: 0.75rem 1rem;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: #e5e5e5;
    background: #171717;
    border: 1px solid #262626;
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 200ms ease, transform 200ms ease;
}
.log-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.log-toast--error {
    border-left-color: #b45454;
}

@media (max-width: 640px) {
    .log-toast {
        right: 1rem;
        left: 1rem;
        bottom: 1rem;
        max-width: none;
    }
}

@media (max-width: 640px) {
    .log-post-title, .log-archive-title { font-size: 1.25rem; }
    .log-thumb { width: 4.5rem; height: 4.5rem; }
}
