/*
 * /dev/blog Stylesheet
 *
 * Color Scheme: ef-maris-dark by Protesilaos Stavrou
 * - Repository: https://github.com/protesilaos/ef-themes
 * - License: GNU GPL v3.0
 * - A marine-inspired dark theme with blues, cyans, and greens
 *
 * Fonts:
 * - Inter (body text) - SIL Open Font License
 * - Farro (headings) - SIL Open Font License
 * - JetBrains Mono (code) - SIL Open Font License
 * - Victor Mono (retro terminal logo) - SIL Open Font License
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Farro:wght@400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Victor+Mono:wght@400;500;600&display=swap');

/* CSS Variables for Theme Switching */
:root {
  /* Base Colors */
  --bg-primary: #131c2b;
  --bg-secondary: #1d2c39;
  --bg-tertiary: #2a3644;
  --bg-hover: #243242;
  --fg-primary: #eaedef;
  --fg-secondary: #969faf;

  /* Interactive */
  --color-link: #57b0ff;
  --color-link-hover: #2fd0db;

  /* Borders */
  --border-primary: #2a3644;
  --border-accent: #57b0ff;

  /* Rainbow Headings */
  --heading-h1: #30c489;
  --heading-h2: #70a0ff;
  --heading-h3: #7fce5f;
  --heading-h4: #2fd0db;
  --heading-h5: #cf90ff;
  --heading-h6: #12b4ff;

  /* Syntax Highlighting */
  --syntax-source: #eaedef;
  --syntax-comment: #eaa4a4;
  --syntax-keyword: #70a0ff;
  --syntax-string: #30c489;
  --syntax-number: #12b4ff;
  --syntax-function: #7fce5f;
  --syntax-type: #41bf4f;
  --syntax-variable: #2fd0db;
  --syntax-inline: #cf90ff;

  /* Components */
  --copy-btn-bg: #2a3644;
  --copy-btn-fg: #969faf;
  --copy-btn-hover-bg: #57b0ff;
  --copy-btn-hover-fg: #131c2b;
  --copy-btn-success-bg: #30c489;
  --copy-btn-success-fg: #131c2b;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg-primary: #edf4f8;
  --bg-secondary: #e0e7ef;
  --bg-tertiary: #cfd8e3;
  --bg-hover: #dae5f0;
  --fg-primary: #151a27;
  --fg-secondary: #676470;

  --color-link: #375cc6;
  --color-link-hover: #1f66af;

  --border-primary: #cfd8e3;
  --border-accent: #375cc6;

  --heading-h1: #007047;
  --heading-h2: #444fcf;
  --heading-h3: #3a6f00;
  --heading-h4: #1f66af;
  --heading-h5: #5f2fba;
  --heading-h6: #003faf;

  --syntax-source: #151a27;
  --syntax-comment: #8b4052;
  --syntax-keyword: #444fcf;
  --syntax-string: #006f70;
  --syntax-number: #003faf;
  --syntax-function: #3a6f00;
  --syntax-type: #007010;
  --syntax-variable: #1f66af;
  --syntax-inline: #5f2fba;

  --copy-btn-bg: #cfd8e3;
  --copy-btn-fg: #676470;
  --copy-btn-hover-bg: #375cc6;
  --copy-btn-hover-fg: #ffffff;
  --copy-btn-success-bg: #007047;
  --copy-btn-success-fg: #ffffff;

  color-scheme: light;
}

/* Smooth transitions for theme switching */
body, header, footer, .post-list li, .post-content a, .copy-button,
.post-content table thead, .post-content table tbody tr {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 20px;
    line-height: 1.6;
    color: var(--fg-primary);
    background-color: var(--bg-primary);
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-primary);
    gap: 20px;
}

.header-controls {
    display: flex;
    align-items: stretch;
    gap: 12px;
}

header h1 {
    font-family: 'Farro', sans-serif;
    font-weight: 400;
    font-size: 2.5rem;
}

header h1 a {
    font-family: 'Victor Mono', monospace;
    color: #30c489;
    text-decoration: none;
    text-shadow:
        0 0 10px rgba(48, 196, 137, 0.8),
        0 0 20px rgba(48, 196, 137, 0.6),
        0 0 30px rgba(48, 196, 137, 0.4),
        0 0 40px rgba(48, 196, 137, 0.2);
    letter-spacing: 0.1em;
    filter: blur(0.3px);
    animation: flicker 4s infinite alternate;
}

@keyframes flicker {
    0%, 100% {
        opacity: 1;
        text-shadow:
            0 0 10px rgba(48, 196, 137, 0.8),
            0 0 20px rgba(48, 196, 137, 0.6),
            0 0 30px rgba(48, 196, 137, 0.4),
            0 0 40px rgba(48, 196, 137, 0.2);
    }
    50% {
        opacity: 0.95;
        text-shadow:
            0 0 8px rgba(48, 196, 137, 0.7),
            0 0 16px rgba(48, 196, 137, 0.5),
            0 0 24px rgba(48, 196, 137, 0.3);
    }
}

header h1 a:hover {
    color: #30c489;
    text-shadow:
        0 0 15px rgba(48, 196, 137, 1),
        0 0 25px rgba(48, 196, 137, 0.8),
        0 0 35px rgba(48, 196, 137, 0.6),
        0 0 50px rgba(48, 196, 137, 0.4);
}

main {
    margin-bottom: 40px;
}

footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-primary);
    color: var(--fg-secondary);
    font-size: 1em;
    text-align: center;
}

.post-list {
    list-style: none;
}

.post-list li {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-primary);
}

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

.post-list a {
    font-size: 1.4em;
    color: var(--color-link);
    text-decoration: none;
}

.post-list a:hover {
    text-decoration: underline;
}

.date {
    display: block;
    color: var(--fg-secondary);
    font-size: 1em;
    margin-top: 5px;
}

article h2 {
    margin-bottom: 10px;
    font-size: 3rem;
    font-family: 'Farro', sans-serif;
    font-weight: 400;
    color: var(--color-link);
    line-height: 1.2;
}

article .date {
    margin-bottom: 30px;
}

.post-content {
    margin-top: 20px;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    font-family: 'Farro', sans-serif;
    font-weight: 400;
    line-height: 1.3;
}

/* Org-mode rainbow heading colors with proportional spacing */
.post-content h1 {
    color: var(--heading-h1);
    font-size: 2.2rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}

.post-content h2 {
    color: var(--heading-h2);
    font-size: 1.8rem;
    margin-top: 2.5rem;
    margin-bottom: 1.2rem;
}

.post-content h3 {
    color: var(--heading-h3);
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.post-content h4 {
    color: var(--heading-h4);
    font-size: 1.3rem;
    margin-top: 1.75rem;
    margin-bottom: 0.875rem;
}

.post-content h5 {
    color: var(--heading-h5);
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.post-content h6 {
    color: var(--heading-h6);
    font-size: 1rem;
    margin-top: 1.25rem;
    margin-bottom: 0.625rem;
}

.post-content p {
    margin-bottom: 1.25rem;
}

.post-content a {
    color: var(--color-link);
    text-decoration: underline;
    text-decoration-style: dashed;
    transition: color 0.2s ease;
}

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

/* Code block wrapper for copy button */
.code-block-wrapper {
    position: relative;
    margin: 2rem 0;
}

.post-content pre.code {
    background-color: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 0;
}

.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    background-color: var(--copy-btn-bg);
    color: var(--copy-btn-fg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.7;
}

.copy-button:hover {
    background-color: var(--copy-btn-hover-bg);
    color: var(--copy-btn-hover-fg);
    opacity: 1;
}

.copy-button svg {
    display: block;
    width: 16px;
    height: 16px;
}

.copy-button.copied {
    background-color: var(--copy-btn-success-bg);
    color: var(--copy-btn-success-fg);
    opacity: 1;
}

.post-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1em;
    color: var(--syntax-inline);
}

.post-content ul,
.post-content ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

/* Table styling */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background-color: var(--bg-secondary);
    border-radius: 5px;
    overflow: hidden;
}

.post-content table thead {
    background-color: var(--bg-tertiary);
}

.post-content table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--heading-h2);
    border-bottom: 2px solid var(--border-accent);
}

.post-content table td {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-primary);
}

.post-content table tbody tr:hover {
    background-color: var(--bg-hover);
}

.post-content table tbody tr:last-child td {
    border-bottom: none;
}

.back-link {
    display: inline-block;
    margin-top: 30px;
    color: var(--color-link);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

/* Syntax highlighting classes */
.source { color: var(--syntax-source); }
.comment { color: var(--syntax-comment); font-style: italic; }
.keyword { color: var(--syntax-keyword); font-weight: bold; }
.string { color: var(--syntax-string); }
.number { color: var(--syntax-number); }
.function { color: var(--syntax-function); }
.type { color: var(--syntax-type); }
.variable { color: var(--syntax-variable); }

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-primary);
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    color: var(--color-link);
    border-color: var(--color-link);
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle svg {
    display: block;
    width: 20px;
    height: 20px;
}

/* Icon visibility based on theme */
[data-theme="dark"] .moon-icon,
[data-theme="light"] .sun-icon {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    header {
        flex-wrap: wrap;
        justify-content: center;
    }

    header h1 {
        font-size: 1.8rem;
        flex: 1 0 100%;
        margin-bottom: 12px;
        text-align: center;
    }

    header h1 a {
        display: block;
    }

    .header-controls {
        flex: 1 0 100%;
        justify-content: center;
    }

    .header-search-input {
        width: auto;
        flex: 1;
        min-width: 0;
    }

    .header-search-input:focus {
        width: auto;
    }
}

@media (max-width: 600px) {
    .theme-toggle {
        padding: 6px;
    }

    .theme-toggle svg {
        width: 18px;
        height: 18px;
    }

    .header-search-input {
        font-size: 0.85em;
        padding: 6px 10px;
    }

    .header-search-button {
        padding: 6px;
    }

    .header-search-button svg {
        width: 14px;
        height: 14px;
    }
}

/* Header Search Form */
.header-search-form {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.header-search-input {
    width: 180px;
    padding: 8px 12px;
    font-size: 0.9em;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--fg-primary);
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 6px;
    transition: border-color 0.2s ease, width 0.2s ease;
}

.header-search-input:focus {
    outline: none;
    border-color: var(--border-accent);
    width: 220px;
}

.header-search-input::placeholder {
    color: var(--fg-secondary);
    opacity: 0.7;
}

.header-search-button {
    padding: 8px 12px;
    background-color: var(--bg-secondary);
    color: var(--fg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    height: auto;
}

.header-search-button:hover {
    background-color: var(--color-link);
    color: var(--bg-primary);
    border-color: var(--color-link);
}

.header-search-button:active {
    transform: scale(0.95);
}

.header-search-button svg {
    display: block;
}

/* Search Results Page Search Form */
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid var(--border-primary);
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 1em;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--fg-primary);
    background-color: var(--bg-primary);
    border: 2px solid var(--border-primary);
    border-radius: 6px;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--border-accent);
}

.search-input::placeholder {
    color: var(--fg-secondary);
    opacity: 0.7;
}

.search-button {
    padding: 12px 24px;
    font-size: 1em;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--bg-primary);
    background-color: var(--color-link);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.search-button:hover {
    background-color: var(--color-link-hover);
    transform: translateY(-1px);
}

.search-button:active {
    transform: translateY(0);
}

.search-results-info {
    margin-bottom: 20px;
    color: var(--fg-secondary);
}

.search-results-info strong {
    color: var(--fg-primary);
}

.search-results li {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-title {
    font-size: 1.4em;
}

.search-excerpt {
    margin: 0;
    color: var(--fg-secondary);
    font-size: 0.95em;
    line-height: 1.5;
}

/* Responsive search form */
@media (max-width: 600px) {
    .search-form {
        flex-direction: column;
    }

    .search-button {
        width: 100%;
    }
}
