/* 
 * Shinmun Theme - Minimalistic & Sophisticated
 * Inspired by Japanese newspaper aesthetics
 */

/* CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Custom Properties - Dark Mode */
:root {
    --ink: #e8e8e8;
    --ink-light: #b0b0b0;
    --ink-muted: #888888;
    --paper: #0d0d0d;
    --paper-warm: #1a1a1a;
    --accent: #74c0fc;
    --accent-dark: #4dabf7;
    --border: #2a2a2a;
    --border-dark: #3a3a3a;
    --code-bg: #1a1a1a;
    --max-width: 720px;
    --font-serif: "Georgia", "Times New Roman", "Hiragino Mincho ProN", serif;
    --font-sans: "Helvetica Neue", "Arial", "Hiragino Kaku Gothic ProN", sans-serif;
    --font-mono: "SF Mono", "Monaco", "Inconsolata", "Fira Code", monospace;
}

/* Base Styles */
html {
    font-size: 17px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-serif);
    line-height: 1.8;
    color: var(--ink);
    background-color: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.3;
    color: var(--ink);
    letter-spacing: -0.02em;
}

h1 { 
    font-size: 2.25rem; 
    margin: 2.5rem 0 1.25rem;
    font-weight: 700;
}

h2 { 
    font-size: 1.5rem; 
    margin: 2rem 0 1rem;
}

h3 { 
    font-size: 1.25rem; 
    margin: 1.75rem 0 0.875rem;
}

h4 { 
    font-size: 1rem; 
    margin: 1.5rem 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
}

h5, h6 { 
    font-size: 0.875rem; 
    margin: 1.25rem 0 0.625rem;
}

p {
    margin-bottom: 1.5rem;
}

a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--border-dark);
    transition: all 0.2s ease;
}

a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Lists */
ul, ol {
    margin: 0 0 1.5rem 1.25rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Code */
code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background-color: var(--paper-warm);
    color: var(--accent);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    border: 1px solid var(--border);
}

pre {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    background-color: var(--code-bg);
    color: var(--ink);
    padding: 1.5rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 2rem 0;
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    border: none;
}

/* Blockquotes */
blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--ink-light);
}

blockquote p:last-child {
    margin-bottom: 0;
}

/* Horizontal Rule */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-dark), transparent);
    margin: 3rem 0;
}

/* Images - Make responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Tables - Make responsive */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

table th,
table td {
    padding: 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}

table th {
    background-color: var(--paper-warm);
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--ink);
}

/* Table wrapper for responsive scrolling */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 2rem 0;
}

/* Layout */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Site Header */
.container > h3:first-child {
    font-family: var(--font-sans);
    font-size: 1.125rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-dark);
}

.container > h3:first-child a {
    color: var(--ink);
    border-bottom: none;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.container > h3:first-child a:hover {
    color: var(--accent);
}

/* Navigation */
.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 3rem;
    padding: 1rem 0;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.menu a {
    color: var(--ink-muted);
    border-bottom: none;
    padding: 0.25rem 0;
    position: relative;
}

.menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.menu a:hover,
.menu a.active {
    color: var(--ink);
}

.menu a:hover::after {
    width: 100%;
}

/* Articles */
.articles {
    margin-top: 2rem;
}

.article {
    margin-bottom: 3rem;
    padding-bottom: 3rem;
    border-bottom: 1px solid var(--border);
}

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

.article h1 {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.article h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.375rem;
}

.article h2 a {
    color: var(--ink);
    border-bottom: none;
    transition: color 0.2s ease;
}

.article h2 a:hover {
    color: var(--accent);
}

.article .date {
    font-family: var(--font-sans);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.article p {
    color: var(--ink-light);
}

/* Sidebar Sections */
.container > p h4 {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.container ul {
    list-style: none;
    margin-left: 0;
}

.container ul li {
    margin-bottom: 0.625rem;
}

.container ul li a {
    font-family: var(--font-sans);
    color: var(--ink-light);
    font-size: 0.9rem;
    border-bottom: none;
}

.container ul li a:hover {
    color: var(--accent);
}

/* Tags */
.tags a {
    display: inline-block;
    font-family: var(--font-sans);
    background: transparent;
    color: var(--ink-muted);
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--border-dark);
    border-radius: 2px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.tags a:hover {
    background: var(--accent);
    color: var(--paper);
    border-color: var(--accent);
}

/* Footer */
footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-family: var(--font-sans);
    color: var(--ink-muted);
    font-size: 0.8125rem;
    letter-spacing: 0.05em;
}

/* Rouge Syntax Highlighting */
.highlight {
    background-color: var(--code-bg);
    padding: 1.5rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 2rem 0;
}

.highlight pre {
    margin: 0;
    padding: 0;
    background: none;
}

/* Rouge token colors - Sophisticated palette */
.highlight .k { color: #cc99cc; font-weight: 500; } /* Keyword */
.highlight .kd { color: #cc99cc; font-weight: 500; } /* Keyword.Declaration */
.highlight .kn { color: #cc99cc; font-weight: 500; } /* Keyword.Namespace */
.highlight .kp { color: #cc99cc; font-weight: 500; } /* Keyword.Pseudo */
.highlight .kr { color: #cc99cc; font-weight: 500; } /* Keyword.Reserved */
.highlight .kt { color: #cc99cc; font-weight: 500; } /* Keyword.Type */
.highlight .nc { color: #f0c674; } /* Name.Class */
.highlight .nf { color: #81a2be; } /* Name.Function */
.highlight .s { color: #b5bd68; } /* String */
.highlight .s1 { color: #b5bd68; } /* String.Single */
.highlight .s2 { color: #b5bd68; } /* String.Double */
.highlight .si { color: #b5bd68; } /* String.Interpol */
.highlight .ss { color: #8abeb7; } /* String.Symbol */
.highlight .c { color: #969896; font-style: italic; } /* Comment */
.highlight .c1 { color: #969896; font-style: italic; } /* Comment.Single */
.highlight .cm { color: #969896; font-style: italic; } /* Comment.Multiline */
.highlight .cp { color: #969896; font-style: italic; } /* Comment.Preproc */
.highlight .mi { color: #de935f; } /* Literal.Number.Integer */
.highlight .mf { color: #de935f; } /* Literal.Number.Float */
.highlight .m { color: #de935f; } /* Literal.Number */
.highlight .no { color: #f0c674; } /* Name.Constant */
.highlight .vi { color: #cc6666; } /* Name.Variable.Instance */
.highlight .vg { color: #cc6666; } /* Name.Variable.Global */
.highlight .sr { color: #b5bd68; } /* String.Regex */
.highlight .n { color: #e8e8e8; } /* Name */
.highlight .nb { color: #81a2be; } /* Name.Builtin */
.highlight .na { color: #81a2be; } /* Name.Attribute */
.highlight .o { color: #8abeb7; } /* Operator */
.highlight .p { color: #e8e8e8; } /* Punctuation */

/* Selection */
::selection {
    background: var(--accent);
    color: var(--paper);
}

/* Responsive Design */

/* Tablet and below */
@media (max-width: 768px) {
    html { font-size: 16px; }
    
    .container {
        padding: 2rem 1.5rem;
    }
    
    h1 { 
        font-size: 1.875rem;
        margin: 2rem 0 1rem;
    }
    h2 { 
        font-size: 1.375rem;
        margin: 1.75rem 0 0.875rem;
    }
    h3 { 
        font-size: 1.125rem;
        margin: 1.5rem 0 0.75rem;
    }
    
    .menu {
        gap: 0.875rem 1.25rem;
    }
    
    .menu a {
        padding: 0.5rem 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Mobile phones */
@media (max-width: 640px) {
    html { font-size: 15px; }
    
    .container {
        padding: 1.5rem 1rem;
    }
    
    /* Better site header on mobile */
    .container > h3:first-child {
        font-size: 1rem;
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem;
        word-wrap: break-word;
    }
    
    /* Typography adjustments */
    h1 { 
        font-size: 1.75rem;
        line-height: 1.2;
        margin: 1.5rem 0 1rem;
    }
    h2 { 
        font-size: 1.25rem;
        margin: 1.5rem 0 0.75rem;
    }
    h3 { 
        font-size: 1.125rem;
        margin: 1.25rem 0 0.625rem;
    }
    
    p {
        margin-bottom: 1.25rem;
    }
    
    /* Mobile-friendly navigation */
    .menu {
        gap: 0.75rem 1rem;
        padding: 0.75rem 0;
        margin-bottom: 2rem;
    }
    
    .menu a {
        padding: 0.5rem 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        font-size: 0.875rem;
    }
    
    /* Code blocks - prevent overflow */
    pre {
        padding: 1rem;
        font-size: 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .highlight {
        padding: 1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better spacing for articles */
    .article {
        margin-bottom: 2rem;
        padding-bottom: 2rem;
    }
    
    .article h2 {
        font-size: 1.25rem;
        line-height: 1.3;
    }
    
    /* Better tag sizing for mobile */
    .tags a {
        padding: 0.375rem 0.875rem;
        margin-bottom: 0.75rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    /* Lists with better spacing */
    ul, ol {
        margin: 0 0 1.25rem 1rem;
    }
    
    li {
        margin-bottom: 0.625rem;
    }
    
    /* Footer adjustments */
    footer {
        margin-top: 3rem;
        padding-top: 1.5rem;
        font-size: 0.75rem;
    }
    
    /* Blockquote mobile friendly */
    blockquote {
        padding-left: 1rem;
        margin: 1.5rem 0;
        font-size: 0.95rem;
    }
}

/* Extra small devices */
@media (max-width: 375px) {
    html { font-size: 14px; }
    
    .container {
        padding: 1.25rem 0.875rem;
    }
    
    h1 { font-size: 1.625rem; }
    
    .menu {
        gap: 0.625rem 0.75rem;
    }
    
    .menu a {
        font-size: 0.8125rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .menu, hr {
        display: none;
    }
    
    a {
        color: black;
        border-bottom: none;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: black;
    }
}
