/*
 * Spacious-inspired styles for Wagtail
 * davidmessenger.co.uk & ip-life.net
 */

:root {
    color-scheme: light dark;
    --font-sans: 'Lato', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", monospace;
    --primary-color: #138440;
    --primary-dark: #00520e;
    --primary-contrast: #ffffff;
    --text-color: #666;
    --muted-color: #888;
    --subtle-color: #999;
    --title-color: #444;
    --bg-color: #ffffff;
    --content-bg: #ffffff;
    --surface-muted: #f8f8f8;
    --surface-soft: #f9f9f9;
    --tag-bg: #f2f2f2;
    --input-bg: #ffffff;
    --input-addon-bg: #f8f8f8;
    --border-color: #eaeaea;
    --border-strong: #e8e8e8;
    --shadow-color: rgba(0, 0, 0, 0.07);
    --success-bg: #eaf6ed;
    --success-border: #b6dfc0;
    --success-text: #2a6b3c;
    --error-bg: #fdf0f0;
    --error-border: #f5c0c0;
    --error-text: #8b2020;
    --code-bg: #2d2d2d;
    --code-text: #f8f8f2;
    --spacing: 1.5rem;
    --max-width: 1218px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #58d987;
        --primary-dark: #8af0aa;
        --primary-contrast: #06130a;
        --text-color: #f7f7f7;
        --muted-color: #c8c8c8;
        --subtle-color: #929292;
        --title-color: #ffffff;
        --bg-color: #1d1d1d;
        --content-bg: #262626;
        --surface-muted: #222222;
        --surface-soft: #333333;
        --tag-bg: #333333;
        --input-bg: #262626;
        --input-addon-bg: #333333;
        --border-color: #333333;
        --border-strong: #5c5c5c;
        --shadow-color: rgba(0, 0, 0, 0.5);
        --success-bg: #123522;
        --success-border: #2e7d4a;
        --success-text: #9be5ad;
        --error-bg: #3d2020;
        --error-border: #8a3a3a;
        --error-text: #ffb1b1;
        --code-bg: #1d1d1d;
        --code-text: #f7f7f7;
    }
}

html[data-theme="light"] {
    color-scheme: light;
    --primary-color: #138440;
    --primary-dark: #00520e;
    --primary-contrast: #ffffff;
    --text-color: #666;
    --muted-color: #888;
    --subtle-color: #999;
    --title-color: #444;
    --bg-color: #ffffff;
    --content-bg: #ffffff;
    --surface-muted: #f8f8f8;
    --surface-soft: #f9f9f9;
    --tag-bg: #f2f2f2;
    --input-bg: #ffffff;
    --input-addon-bg: #f8f8f8;
    --border-color: #eaeaea;
    --border-strong: #e8e8e8;
    --shadow-color: rgba(0, 0, 0, 0.07);
    --success-bg: #eaf6ed;
    --success-border: #b6dfc0;
    --success-text: #2a6b3c;
    --error-bg: #fdf0f0;
    --error-border: #f5c0c0;
    --error-text: #8b2020;
    --code-bg: #2d2d2d;
    --code-text: #f8f8f2;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --primary-color: #58d987;
    --primary-dark: #8af0aa;
    --primary-contrast: #06130a;
    --text-color: #f7f7f7;
    --muted-color: #c8c8c8;
    --subtle-color: #929292;
    --title-color: #ffffff;
    --bg-color: #1d1d1d;
    --content-bg: #262626;
    --surface-muted: #222222;
    --surface-soft: #333333;
    --tag-bg: #333333;
    --input-bg: #262626;
    --input-addon-bg: #333333;
    --border-color: #333333;
    --border-strong: #5c5c5c;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --success-bg: #123522;
    --success-border: #2e7d4a;
    --success-text: #9be5ad;
    --error-bg: #3d2020;
    --error-border: #8a3a3a;
    --error-text: #ffb1b1;
    --code-bg: #1d1d1d;
    --code-text: #f7f7f7;
}

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

html {
    overflow-y: scroll;
}

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-color);
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-dark);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--title-color);
    font-weight: 400;
    line-height: 1.3;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

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

.themed-image {
    display: inline-block;
    max-width: 100%;
}

.themed-image__image {
    display: block;
}

.themed-image__image.themed-image__image--dark {
    display: none;
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .themed-image__image--light {
        display: none;
    }

    html:not([data-theme="light"]) .themed-image__image--dark {
        display: block;
    }
}

html[data-theme="dark"] .themed-image__image--light {
    display: none;
}

html[data-theme="dark"] .themed-image__image--dark {
    display: block;
}

.inner-wrap {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 25px;
}

.site-ip-life {
    --primary-color: #007709;
    --primary-dark: #004500;
}

@media (prefers-color-scheme: dark) {
    .site-ip-life {
        --primary-color: #74e67d;
        --primary-dark: #a7f5ad;
    }
}

html[data-theme="light"] .site-ip-life {
    --primary-color: #007709;
    --primary-dark: #004500;
}

html[data-theme="dark"] .site-ip-life {
    --primary-color: #74e67d;
    --primary-dark: #a7f5ad;
}

/* Header */
.site-header {
    background-color: var(--content-bg);
    border-top: none;
}

.wp-custom-header {
    background-color: #111;
    line-height: 0;
}

.header-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 348px;
    object-fit: cover;
}

.site-header > .inner-wrap {
    padding-top: 30px;
    padding-bottom: 0;
    overflow: hidden;
}

.header-text {
    float: left;
    margin-bottom: 28px;
}

.header-actions {
    float: right;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 8px;
}

.site-title {
    font-size: 36px;
    font-weight: 400;
    line-height: 1.2;
    margin: 0;
    letter-spacing: 0;
}

.site-title a {
    color: var(--title-color);
}

.site-description {
    font-size: 16px;
    color: var(--text-color);
    margin: 4px 0 0;
}

/* Navigation */
.main-navigation {
    background-color: transparent;
}

.main-navigation ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
}

.main-navigation li a {
    display: block;
    padding: 16px 14px 28px;
    color: var(--title-color);
    font-size: 16px;
    font-weight: 400;
    text-transform: none;
}

.main-navigation li a:hover,
.main-navigation li.current_page_item a {
    background-color: transparent;
    color: var(--primary-color);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 82px;
    min-height: 38px;
    margin-top: 6px;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--title-color);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-transform: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--primary-contrast);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}

.theme-toggle__icon {
    position: relative;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.theme-toggle__icon::after {
    content: "";
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 16px;
    border-radius: 0 16px 16px 0;
    background: var(--surface-soft);
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.theme-toggle:hover .theme-toggle__icon::after,
.theme-toggle:focus-visible .theme-toggle__icon::after {
    background: var(--primary-color);
}

.theme-toggle[aria-pressed="true"] .theme-toggle__icon::after {
    opacity: 1;
}

.site-search {
    clear: both;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-bottom: 18px;
}

.site-search label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.site-search input[type="search"] {
    width: min(280px, 100%);
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
}

.site-search button {
    padding: 0.55rem 1rem;
    font-size: 12px;
}

/* Main content */
.site-main {
    clear: both;
    padding: 30px 0 40px;
}

.site-main > .inner-wrap {
    background-color: var(--content-bg);
    padding-top: 40px;
    padding-bottom: 40px;
}

/* Page content */
.home-page h1,
.blog-index h1,
.blog-post h1,
.entry-header h1 {
    font-size: 32px;
    line-height: 1.2;
    margin-top: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.rich-text {
    margin-bottom: 1.5rem;
}

.linkedin-profile-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.65rem 1rem;
    border: 1px solid #084f96;
    border-radius: 4px;
    background: #0a66c2;
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.linkedin-profile-link__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    background: #ffffff;
    color: #0a66c2;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

.linkedin-profile-link:hover,
.linkedin-profile-link:focus-visible,
.site-footer .linkedin-profile-link:hover,
.site-footer .linkedin-profile-link:focus-visible {
    border-color: #063d73;
    background: #084f96;
    color: #ffffff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
}

.linkedin-profile-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.home-page .rich-text p:has(> a[href*="linkedin.com"]:only-child) {
    display: none;
}

.content-with-sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 42px;
    align-items: start;
}

/* Blog Index */
.post-summary {
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
}

.post-summary:last-child {
    border-bottom: none;
}

.post-thumbnail {
    display: block;
    margin-bottom: 1rem;
    overflow: hidden;
}

.post-thumbnail .themed-image {
    display: block;
}

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

.post-summary h2 {
    font-size: 26px;
    line-height: 1.3;
    margin: 0 0 6px;
    font-weight: 400;
}

.post-summary time {
    display: block;
    font-size: 13px;
    color: var(--muted-color);
    margin-bottom: 12px;
}

.archive-label {
    color: var(--muted-color);
    font-size: 14px;
    margin: -0.4rem 0 2rem;
}

.terms,
.blog-post .tags {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.terms li a,
.blog-post .tags li a,
.tag-cloud a {
    display: inline-block;
    background: var(--tag-bg);
    color: var(--text-color);
    padding: 0.15rem 0.55rem;
    font-size: 0.78rem;
    border-radius: 2px;
}

.terms li a:hover,
.blog-post .tags li a:hover,
.tag-cloud a:hover {
    background: var(--primary-color);
    color: var(--primary-contrast);
}

.post-summary .read-more {
    display: inline-block;
    background-color: transparent;
    color: var(--primary-color);
    padding: 0;
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
    margin-top: 8px;
    transition: color 0.3s ease;
}

.post-summary .read-more:hover {
    background-color: transparent;
    color: var(--primary-dark);
}

/* Blog Post */
.entry-header {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border-strong);
}

.entry-header > .inner-wrap {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

.blog-post .intro {
    font-size: 18px;
    color: var(--text-color);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.blog-sidebar {
    border-left: 1px solid var(--border-color);
    padding-left: 28px;
}

.widget {
    margin-bottom: 32px;
}

.widget h2 {
    font-size: 18px;
    margin-top: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.widget ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.widget li {
    margin-bottom: 0.55rem;
}

.compact-search-form {
    display: flex;
}

.compact-search-form input[type="search"] {
    min-width: 0;
    width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border-color);
    font-family: inherit;
}

.compact-search-form button {
    padding: 0.65rem 0.9rem;
    font-size: 12px;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tag-cloud li {
    margin-bottom: 0;
}

.blog-post blockquote {
    border-left: 3px solid var(--primary-color);
    margin: 2rem 0;
    padding: 1rem 1.5rem;
    background-color: var(--surface-soft);
    font-style: italic;
    color: var(--text-color);
}

.blog-post pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1rem;
    overflow-x: auto;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* Footer */
.site-footer {
    background-color: var(--surface-muted);
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 20px 0;
    font-size: 12px;
}

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

.site-footer a:hover {
    color: var(--primary-color);
}

.footer-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.site-footer .linkedin-profile-link {
    min-height: 34px;
    padding: 0.45rem 0.7rem;
    color: #ffffff;
    font-size: 12px;
}

.site-footer .linkedin-profile-link__mark {
    flex-basis: 18px;
    width: 18px;
    height: 18px;
    font-size: 12px;
}

.footer-info p {
    margin: 0.2rem 0;
}

.footer-client-info {
    margin-left: auto;
    text-align: right;
    opacity: 0.6;
    max-width: 50%;
    overflow-wrap: anywhere;
}

@media (max-width: 600px) {
    .footer-info {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* Forms */
.form-field {
    margin-bottom: 1.5rem;
}

.form-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
}

input[type="submit"], button {
    background-color: var(--primary-color);
    color: var(--primary-contrast);
    border: none;
    padding: 0.8rem 2rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.3s ease;
}

input[type="submit"]:hover, button:hover {
    background-color: var(--primary-dark);
}

/* Search */
.search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.search-form input[type="search"] {
    flex-grow: 1;
    padding: 0.8rem;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-color);
}

.search-results {
    list-style: none;
    padding: 0;
}

.search-results li {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    padding-bottom: 1.2rem;
}

.search-results h2 {
    font-size: 22px;
    margin-bottom: 0.25rem;
}

.search-results time {
    display: block;
    color: var(--muted-color);
    font-size: 13px;
    margin-bottom: 0.5rem;
}

/* Comments */
.comment-notices {
    margin: 2rem 0 0;
}

.comment-notice {
    padding: 0.8rem 1.2rem;
    border-radius: 3px;
    margin-bottom: 0.5rem;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.comment-notice.error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

.comments-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.comments-heading {
    font-size: 22px;
    margin-top: 0;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.comment-list {
    list-style: none;
    padding: 0;
    margin: 0 0 3rem;
}

.comment {
    padding: 1.2rem 0;
    border-bottom: 1px solid var(--border-color);
}

.comment:last-child {
    border-bottom: none;
}

.comment-meta {
    display: flex;
    gap: 1rem;
    align-items: baseline;
    margin-bottom: 0.6rem;
}

.comment-author {
    font-size: 15px;
    color: var(--title-color);
}

.comment-meta time {
    font-size: 13px;
    color: var(--muted-color);
}

.comment-body {
    line-height: 1.7;
}

.comment-policy {
    font-size: 13px;
    color: var(--muted-color);
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
}

.comment-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.comment-form .form-field input,
.comment-form .form-field textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    background: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 15px;
}

.comment-form .form-field textarea {
    resize: vertical;
}

.comment-form .required {
    color: var(--error-text);
}

.field-error {
    color: var(--error-text);
    font-size: 13px;
    margin: 0.25rem 0 0;
}

@media (max-width: 600px) {
    .comment-form .form-row {
        grid-template-columns: 1fr;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .inner-wrap {
        padding-left: 18px;
        padding-right: 18px;
    }

    .header-text,
    .header-actions,
    .main-navigation {
        float: none;
    }

    .header-actions {
        align-items: flex-start;
        flex-wrap: wrap;
        margin-top: 0;
    }

    .header-image {
        min-height: 150px;
    }

    .site-main .inner-wrap {
        padding-top: 28px;
        padding-bottom: 28px;
    }

    .site-title {
        font-size: 30px;
    }

    .main-navigation li a {
        padding: 10px 12px 14px 0;
    }

    .theme-toggle {
        margin-top: 3px;
    }

    .site-search {
        justify-content: stretch;
    }

    .site-search input[type="search"] {
        width: 100%;
    }

    .content-with-sidebar {
        display: block;
    }

    .blog-sidebar {
        border-left: none;
        border-top: 1px solid var(--border-color);
        margin-top: 36px;
        padding-left: 0;
        padding-top: 28px;
    }

    .search-form,
    .compact-search-form,
    .site-search {
        flex-wrap: wrap;
    }

    .search-form button,
    .compact-search-form button,
    .site-search button {
        width: 100%;
    }
}
