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

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

/* === BODY === */
body {
    font-family: "SF Mono", "Fira Code", Menlo, Monaco, Consolas, monospace;
    font-size: 16px;
    line-height: 1.7;
    color: #1a1a1a;
    background: #fff;
    padding: 32px 24px;
    max-width: 680px;
    margin: 0 auto;
}

/* === HEADER === */

header {
    background: #fff;
    margin-bottom: 40px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e5e5;
}

header h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

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

header nav {
    color: #666;
    font-size: 14px;
}

header nav a {
    color: #666;
    text-decoration: none;
}


header nav a:hover {
    color: #1a1a1a;
}

/* === TYPOGRAPHY === */
h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 48px 0 20px;
}

h2:first-child,
main > h2:first-child,
article > h2:first-child {
    margin-top: 12px !important;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 40px 0 16px;
}

p {
    margin-bottom: 20px;
}

a {
    color: #1a1a1a;
    text-decoration: underline;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-thickness: 2px;
}

strong {
    font-weight: 600;
}

/* === BLOCKQUOTE === */
blockquote {
    border-left: 3px solid #1a1a1a;
    padding-left: 20px;
    margin: 24px 0;
    color: #444;
}

/* === LISTS === */
ul, ol {
    margin: 20px 0;
    padding-left: 28px;
}

li {
    margin: 10px 0;
}

/* === CODE === */
code {
    font-family: inherit;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 14px;
}

pre {
    background: #f5f5f5;
    padding: 20px;
    margin: 24px 0;
    border-radius: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 14px;
}

pre code {
    padding: 0;
    background: none;
}

/* === META === */
.meta {
    color: #666;
    font-size: 14px;
    margin-bottom: 40px;
}

/* === POST LIST === */
.post-list {
    list-style: none;
    padding: 0;
}

.post-list li {
    margin: 12px 0;
    display: flex;
    gap: 16px;
    align-items: baseline;
}

.post-list .date {
    color: #999;
    font-size: 14px;
    min-width: 90px;
}

.post-list a {
    text-decoration: none;
}

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

/* === FOOTER === */
footer {
    margin-top: 80px;
    padding-top: 24px;
    border-top: 1px solid #e5e5e5;
    color: #666;
    font-size: 14px;
}

footer p {
    margin-bottom: 8px;
}

footer a {
    color: #666;
}

/* === ARTICLE === */
article ul, article ol {
    margin: 20px 0;
}

/* === MOBILE === */
@media (max-width: 600px) {
    body {
        padding: 40px 24px;
        font-size: 15px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    header nav {
        font-size: 13px;
    }
    
    h2 {
        font-size: 17px;
        margin: 32px 0 12px;
    }
    
    .post-list li {
        flex-direction: column;
        gap: 4px;
    }
    
    .post-list .date {
        min-width: auto;
    }
    
    pre {
        margin-left: 0;
        margin-right: 0;
        border-radius: 4px;
        padding: 16px;
        font-size: 13px;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        word-break: normal;
        white-space: pre;
    }
}

/* === IMAGES === */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 24px 0;
    border-radius: 4px;
}

article img {
    margin: 24px auto;
}

/* === TABLE === */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 14px;
    display: block;
}

thead {
    border-bottom: 2px solid #1a1a1a;
}

th {
    font-weight: 600;
    text-align: left;
    padding: 10px 16px;
}

td {
    padding: 8px 16px;
    border-bottom: 1px solid #e5e5e5;
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}

/* Zebra striping */
tbody tr:nth-child(even) {
    background: #fafafa;
}

/* First column bold (row headers) */
td:first-child {
    font-weight: 600;
    color: #1a1a1a;
}

/* Responsive: horizontal scroll on mobile */
@media (max-width: 600px) {
    table {
        font-size: 13px;
    }
    
    th, td {
        padding: 8px 12px;
    }
}

/* === POST DESCRIPTION === */
.post-description { color: #666; font-size: 14px; margin-top: 4px; margin-bottom: 0; }
.reading-time { color: #999; font-size: 13px; }

/* === DARK MODE === */
@media (prefers-color-scheme: dark) {
    body {
        background: #212121;
        color: #a0a4ab;
    }

    a {
        color: #a0a4ab;
    }

    a:visited {
        color: #a0a4ab;
    }

    header h1 a {
        color: #b8bcc2;
    }

    header nav, header nav a, header nav a:visited, header nav a:active {
        color: #9b9b9b;
    }


    header nav a:hover {
        color: #a0a4ab;
    }

    header {
        border-bottom-color: #3a3a3a;
        background: #212121;
    }

    h2, h3 { color: #b8bcc2; }
    .post-description { color: #9b9b9b; }
    .reading-time { color: #9b9b9b; }
    #scroll-top { color: #a0a4ab; border-color: #a0a4ab;
    }

    .meta, .post-list .date {
        color: #9b9b9b;
    }

    blockquote {
        border-left-color: #555;
        color: #9b9b9b;
    }

    code {
        background: #2f2f2f;
    }

    pre {
        background: #2f2f2f;
    }

    /* Tables */
    thead {
        border-bottom-color: #555;
    }

    td {
        border-bottom-color: #3a3a3a;
    }

    tbody tr:nth-child(even) {
        background: #2a2a2a;
    }

    td:first-child {
        color: #a0a4ab;
    }

    /* Footer */
    footer {
        border-top-color: #3a3a3a;
        color: #9b9b9b;
    }

    footer a {
        color: #9b9b9b;
    }

    /* Images — subtle border for visibility */
    img {
        border-radius: 4px;
    }

    /* Post list links */
    .post-list a {
        color: #a0a4ab;
    }

    .post-list a:hover {
        color: #a0a4ab;
    }
}


/* === FORM === */
#contact-form p {
    margin-bottom: 20px;
}

#contact-form label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

#contact-form input[type="text"],
#contact-form textarea {
    font-family: inherit;
    font-size: 16px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8f8f8;
    color: #1a1a1a;
    box-sizing: border-box;
    -webkit-appearance: none;
}

#contact-form input[type="text"]:focus,
#contact-form textarea:focus {
    outline: none;
    border-color: #1a1a1a;
    background: #fff;
}

#contact-form textarea {
    resize: vertical;
    min-height: 100px;
}

#contact-form button {
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    padding: 14px 24px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.3px;
}

#contact-form button:hover {
    background: #333;
}

#contact-form button:active {
    background: #000;
}

@media (prefers-color-scheme: dark) {
    #contact-form input[type="text"],
    #contact-form textarea {
        background: #2f2f2f;
        border-color: #4a4a4a;
        color: #a0a4ab;
    }

    #contact-form input[type="text"]:focus,
    #contact-form textarea:focus {
        border-color: #a0a4ab;
        background: #333;
    }

    #contact-form button {
        background: #d1d5db;
        color: #1a1a1a;
    }

    #contact-form button:hover {
        background: #5a9aff;
    }
}

/* === CARDS === */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.card {
    display: block;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: #1a1a1a;
    text-decoration: none;
}

.card-meta {
    display: block;
    color: #999;
    font-size: 13px;
    margin-bottom: 8px;
}

.card-meta .date {
    color: #999;
}

.card-meta .reading-time {
    color: #999;
}

.card-title {
    display: block;
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
    margin-bottom: 6px;
}

.card-desc {
    display: block;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* Cards dark mode */
@media (prefers-color-scheme: dark) {
    .card {
        border-color: #3a3a3a;
    }

    .card:hover {
        border-color: #a0a4ab;
    }

    .card-title {
        color: #b8bcc2;
    }

    .card-desc {
        color: #9b9b9b;
    }

    .card-meta, .card-meta .date, .card-meta .reading-time {
        color: #777;
    }
}

/* === SYNTAX HIGHLIGHT === */
.highlight {
    position: relative;
    max-width: 100%;
    overflow: visible;
    margin: 0;
    border-radius: 0 0 6px 6px;
}

.highlight pre {
    margin: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.6;
    padding: 16px 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    .highlight pre {
        font-size: 12px;
        padding: 14px 16px;
    }
}

/* === PREVENT CODE OVERFLOW === */
main {
    overflow-x: hidden;
}


/* === TYPOGRAPHY RULES (T-Bank style) === */
article, main {
    text-wrap: pretty;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    -webkit-hyphens: auto;
}

article p, article li, article blockquote, article td {
    hanging-punctuation: first last;
    text-wrap: pretty;
}

/* Optical margin alignment */
article h1, article h2, article h3 {
    text-wrap: balance;
    letter-spacing: -0.01em;
}

/* Better reading rhythm */
article p {
    max-width: 65ch;
}

article p + p {
    text-indent: 0;
}

/* List improvements */
article li {
    padding-left: 4px;
}

article li + li {
}

/* Emphasis */
article em {
    font-style: italic;
    color: inherit;
}

/* Better hr */
article hr, hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 40px 0;
}

@media (prefers-color-scheme: dark) {
    article hr, hr {
        border-top-color: #3a3a3a;
    }
}
