/* Import Google Fonts */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@200;400;500&family=Source+Sans+Pro:wght@400;600&display=swap");

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

/* Global Styles */
:root {
    /* Light theme variables */
    --color-bg: #ffecd7;
    --color-text: #000000;
    --color-muted: rgba(0, 0, 0, 0.72);
    --color-faint: rgba(0, 0, 0, 0.48);
    --color-line: rgba(0, 0, 0, 0.36);
    --color-panel: rgba(255, 255, 255, 0.2);
    --color-panel-soft: rgba(0, 0, 0, 0.035);
    --color-code-bg: rgba(0, 0, 0, 0.035);
    --color-hover-bg: #000000;
    --color-hover-text: #ffecd7;
    --color-dot: rgba(58, 46, 33, 1);
    --background-color: var(--color-bg);
    --text-color: var(--color-text);
    --dot-color: var(--color-dot);
    --dot-active: var(--color-dot);
    color-scheme: light;
}

[data-theme="dark"] {
    /* Dark theme variables */
    --color-bg: #1d1a17;
    --color-text: #f3e6d3;
    --color-muted: rgba(243, 230, 211, 0.68);
    --color-faint: rgba(243, 230, 211, 0.46);
    --color-line: rgba(243, 230, 211, 0.34);
    --color-panel: rgba(243, 230, 211, 0.045);
    --color-panel-soft: rgba(243, 230, 211, 0.06);
    --color-code-bg: rgba(243, 230, 211, 0.06);
    --color-hover-bg: #f3e6d3;
    --color-hover-text: #1d1a17;
    --color-dot: rgba(243, 230, 211, 0.82);
    --background-color: var(--color-bg);
    --text-color: var(--color-text);
    --dot-color: var(--color-dot);
    --dot-active: var(--color-dot);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --color-bg: #1d1a17;
        --color-text: #f3e6d3;
        --color-muted: rgba(243, 230, 211, 0.68);
        --color-faint: rgba(243, 230, 211, 0.46);
        --color-line: rgba(243, 230, 211, 0.34);
        --color-panel: rgba(243, 230, 211, 0.045);
        --color-panel-soft: rgba(243, 230, 211, 0.06);
        --color-code-bg: rgba(243, 230, 211, 0.06);
        --color-hover-bg: #f3e6d3;
        --color-hover-text: #1d1a17;
        --color-dot: rgba(243, 230, 211, 0.82);
        --background-color: var(--color-bg);
        --text-color: var(--color-text);
        --dot-color: var(--color-dot);
        --dot-active: var(--color-dot);
        color-scheme: dark;
    }
}

@media print {
    :root,
    [data-theme="dark"] {
        --color-bg: #ffffff;
        --color-text: #000000;
        --color-muted: rgba(0, 0, 0, 0.72);
        --color-faint: rgba(0, 0, 0, 0.48);
        --color-line: rgba(0, 0, 0, 0.36);
        --color-panel: rgba(255, 255, 255, 0.2);
        --color-panel-soft: rgba(0, 0, 0, 0.035);
        --color-code-bg: rgba(0, 0, 0, 0.035);
        --color-hover-bg: #000000;
        --color-hover-text: #ffffff;
        --color-dot: #000000;
        color-scheme: light;
    }
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* Home page specific layout */
body.home {
    height: 100vh;
    display: grid;
    grid-template-rows: 72px 40% 1fr;
}

/* DIV1: Top section with nav */
.div1 {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
}

/* Keep the border-bottom only for non-home pages */
body:not(.home) .div1 {
    /* border-bottom: 1px solid #000; */
    align-items: center;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
}

.logo {
    font-family: "JetBrains Mono", monospace;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.nav-logo {
    display: block;
    height: 40px;
    width: 82px;
    background: currentColor;
    -webkit-mask: url("../assets/2x11.svg") center / contain no-repeat;
    mask: url("../assets/2x11.svg") center / contain no-repeat;
}

nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: transparent;
}

nav a {
    font-family: "JetBrains Mono", monospace;
    text-decoration: underline;
    color: var(--color-text);
    font-size: 0.9rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* DIV2: Middle section with logo */
.div2 {
    grid-row: 2 / 3;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    border-bottom: 1px solid var(--color-text);
}

.main-logo {
    display: block;
    max-width: 600px;
    width: 100%;
    aspect-ratio: 279 / 84;
    background: var(--color-text);
    -webkit-mask: url("../assets/main-logo.svg") center / contain no-repeat;
    mask: url("../assets/main-logo.svg") center / contain no-repeat;
}

/* DIV3: Bottom section */
.div3 {
    grid-row: 3 / 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.content {
    padding: 3rem;
    width: 100%;
    max-width: none;
}

.content p.subtitle,
.content p.info {
    font-family: "Source Sans Pro", sans-serif;
    font-size: 1.43rem;
    opacity: 0.8;
    margin-bottom: 1rem;
    line-height: 1.4;
    max-width: 95%;
}

h1,
h2 {
    font-family: "JetBrains Mono", monospace;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

h2 {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.grid-section {
    border-left: 1px solid var(--color-text);
    /* background-color: #FFECD7; */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

#grid-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: transparent;
}

.dot {
    position: absolute;
    width: 9px;
    height: 9px;
    background-color: var(--color-dot);
    border-radius: 50%;
    transition: all 0.3s ease;
    margin: 0;
    padding: 0;
    transform: translate(-50%, -50%);
}

.dot.active {
    transform: scale(3) translate(-25%, -25%);
    background-color: var(--dot-active);
}

/* About and Contact Pages */
.page-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem;
}

.page-content p {
    font-family: "Source Sans Pro", sans-serif;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Blog */
body.blog-page {
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

.article-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem;
}

.blog-index {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem;
}

.article-meta,
.post-list-date {
    font-family: "JetBrains Mono", monospace;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.article-meta {
    margin: 0 0 1rem;
}

.blog-index-header h1,
.article-title {
    margin: 0 0 2rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 2.5rem;
    font-weight: 500;
    line-height: 1.2;
}

.blog-index-header p,
.article-dek {
    font-family: "Source Sans Pro", sans-serif;
    color: var(--color-muted);
    font-size: 1.1rem;
    line-height: 1.6;
}

.post-list {
    display: grid;
    max-width: 800px;
    margin: 0 auto;
}

.post-list-item {
    padding: 0 0 2rem;
}

.post-list-item + .post-list-item::before {
    content: "";
    display: block;
    width: 100%;
    max-width: 100%;
    border-top: 1px solid var(--color-line);
    margin: 0 0 1.7rem;
}

.post-list-item h2 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.3;
}

.post-list-item h2 a {
    color: inherit;
    text-decoration: none;
}

.post-list-item h2 a:hover {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.post-list-item:hover .post-list-date,
.post-list-item:hover p {
    color: var(--color-text);
}

.post-list-inline-date {
    color: var(--color-faint);
    text-align: right;
    white-space: nowrap;
}

.post-list-item p,
.empty-post-list {
    font-family: "Source Sans Pro", sans-serif;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--color-muted);
    margin: 0;
}

.post-list-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: baseline;
}

.article-body {
    font-family: "Source Sans Pro", sans-serif;
    font-size: 1.1rem;
    line-height: 1.6;
}

.article-body h2 {
    margin: 2.5rem 0 1rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.2;
}

.article-body h3 {
    margin: 2rem 0 1rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.3;
}

.article-body p,
.article-body ul,
.article-body ol {
    margin: 0 0 1.5rem;
}

.article-body ul,
.article-body ol {
    padding-left: 1.5rem;
}

.article-body li + li {
    margin-top: 0.4rem;
}

.article-body a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

.article-body code {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.92em;
}

.article-body pre {
    overflow-x: auto;
    border: 1px solid var(--color-line);
    background: var(--color-code-bg);
    padding: 1rem;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.55;
}

.article-body blockquote {
    border-left: 1px solid var(--color-line);
    color: var(--color-muted);
    margin: 2rem 0;
    padding-left: 1.25rem;
}

.article-body img,
.article-body svg {
    max-width: 100%;
    height: auto;
}

.article-panel {
    border: 1px solid var(--color-line);
    background: var(--color-panel);
    margin: 2rem 0;
}

.article-note {
    border-left: 1px solid var(--color-line);
    color: var(--color-muted);
    margin: 2rem 0;
    padding: 0.1rem 0 0.1rem 1rem;
}

.article-component-label,
.article-panel-header {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

.article-component-label {
    margin: 0 0 0.75rem;
}

.article-panel-header {
    border-bottom: 1px solid var(--color-line);
    padding: 0.75rem 1rem;
}

.article-chart > .article-panel-header {
    border-bottom: 0;
    padding: 0;
    margin: 0 0 0.95rem;
}

.article-panel-body {
    padding: 1rem;
}

.article-panel-body > :last-child,
.article-note > :last-child {
    margin-bottom: 0;
}

.article-prompt {
    overflow-x: auto;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
    line-height: 1.55;
}

.article-prompt pre {
    border: 0;
    background: transparent;
    margin: 0;
    padding: 0;
}

.article-caption {
    color: var(--color-faint);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0.75rem 0 0;
}

.article-panel > .article-caption {
    border-top: 1px solid var(--color-line);
    margin: 0;
    padding: 0.75rem 1rem;
}

.article-chart > .article-caption {
    margin: 0.95rem 0 0;
}

.article-chart {
    background: var(--color-code-bg);
    margin: 2rem 0;
    padding: 1rem 1.1rem;
}

.article-wide {
    width: min(960px, calc(100vw - 4rem));
    max-width: none;
    margin-left: 50%;
    transform: translateX(-50%);
}

.article-chart-body {
    display: grid;
    gap: 0.7rem;
    padding: 0;
}

.article-chart-row {
    display: grid;
    grid-template-columns: minmax(7rem, 0.34fr) minmax(0, 1fr) 4.5rem;
    gap: 0.75rem;
    align-items: center;
}

.article-chart-label,
.article-chart-value {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    line-height: 1.35;
}

.article-chart-value {
    color: var(--color-faint);
    text-align: right;
}

.article-chart-track {
    height: 0.75rem;
    border-bottom: 1px solid var(--color-line);
    background: transparent;
}

.article-chart-bar {
    height: 100%;
    background: var(--color-text);
}

.article-svg-chart-wrap {
    overflow-x: auto;
}

.article-svg-chart {
    display: block;
    min-width: 560px;
    width: 100%;
    height: auto;
}

.article-chart-axis,
.article-chart-line {
    fill: none;
    stroke: var(--color-text);
    stroke-width: 1;
}

.article-chart-line {
    stroke-width: 2;
}

.article-chart-point {
    fill: var(--color-bg);
    stroke: var(--color-text);
    stroke-width: 2;
}

.article-chart-point-label,
.article-chart-axis-label {
    fill: var(--color-faint);
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
}

/* Contact Form */
.contact-form {
    margin-top: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-family: "JetBrains Mono", monospace;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    font-family: "Source Sans Pro", sans-serif;
    color: var(--color-text);
    border: 1px solid var(--color-text);
    background: transparent;
}

.form-group textarea {
    min-height: 150px;
}

button {
    font-family: "JetBrains Mono", monospace;
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-text);
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background: var(--color-hover-bg);
    color: var(--color-hover-text);
}

.theme-toggle {
    display: none;
    width: 2rem;
    height: 2rem;
    padding: 0;
    justify-content: center;
    align-items: center;
    border: 1px solid transparent;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    font-size: 1rem;
    line-height: 1;
    font-variant-emoji: text;
    transition: none;
}

.theme-js .theme-toggle {
    display: inline-flex;
}

.theme-toggle:hover {
    background: var(--color-hover-bg);
    border-color: var(--color-hover-bg);
    color: var(--color-hover-text);
}

/* Positioning the contact form container */
#contact-form-container {
    position: relative; /* Establishes a positioning context */
    min-height: 400px; /* Adjust as needed to ensure proper centering */
}

/* Styling for the thank-you message */
#form-message {
    display: none; /* Hidden by default */
    position: absolute; /* Positioned relative to the container */
    top: 50%; /* Position from the top */
    left: 50%; /* Position from the left */
    transform: translate(-50%, -50%); /* Center the div */
    width: 100%; /* Ensure it doesn't exceed the container's width */
}

#form-message > div {
    border: 1px solid var(--color-text);
    padding: 10px;
}

#form-message > div > div {
    border: 1px solid var(--color-text);
    padding: 5px;
}

#form-message p {
    text-align: center;
    margin-bottom: 24px;
    margin-top: 24px;
}

/* Responsive Styles for Mobile Devices */
@media (max-width: 768px) {
    .div1 {
        padding: 1rem;
    }

    .nav-logo {
        width: 64px;
        height: 31px;
    }

    nav {
        gap: 0.85rem;
    }

    nav a {
        font-size: 0.8rem;
    }

    .theme-toggle {
        width: 2rem;
        height: 2rem;
        flex: 0 0 auto;
    }

    /* Adjust overall layout for home page */
    body.home {
        height: auto;
        display: block;
    }

    /* Adjust the grid layout */
    body.home .div3 {
        display: flex;
        flex-direction: column;
    }

    /* Logo section adjustments */
    body.home .div2 {
        padding: 3rem 1rem;
    }

    /* Move and style grid-section */
    body.home .grid-section {
        order: -1;
        border-left: none;
        border-bottom: 1px solid var(--color-text);
        padding: 2rem 1rem;
        height: 400px; /* Set a fixed height for the grid section */
    }

    /* Content section adjustments */
    body.home .content {
        padding: 2rem 1rem;
        max-width: 100%; /* Allow content to use full width */
    }

    /* Adjust grid container */
    body.home .grid-section #grid-container {
        height: 100%;
    }

    /* Adjust font sizes for mobile */
    body.home h2 {
        font-size: 1.75rem;
    }

    body.home .subtitle {
        font-size: 1rem;
    }

    /* Adjust page content padding on mobile */
    .page-content {
        padding: 2rem 1rem;
    }

    .blog-index {
        padding: 3rem 1rem 6rem;
    }

    .blog-index-header {
        margin-bottom: 3rem;
    }

    .post-list-item {
        padding: 0 0 2rem;
    }

    .post-list-meta {
        grid-template-columns: 1fr;
        gap: 0.1rem;
    }

    .post-list-inline-date {
        text-align: left;
    }
}
