/* Prevent theme flash - set initial light theme */
:root {
    color-scheme: light;
}

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

/* Typography */
:root {
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
    --font-sans: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', Times, serif;
    
    --max-width: 900px;
    --spacing: 1.5rem;
}

/* Light theme (default) */
:root,
[data-theme="light"] {
    --color-text: #333;
    --color-text-muted: #666;
    --color-bg: #fff;
    --color-accent: #0066cc;
    --color-accent-light: #e6f3ff;
    --color-border: #e1e5e9;
    --color-code-bg: #f6f8fa;
    --color-code-text: #24292f;
}

/* Dark theme */
[data-theme="dark"] {
    --color-text: #e1e5e9;
    --color-text-muted: #8b949e;
    --color-bg: #0d1117;
    --color-accent: #58a6ff;
    --color-accent-light: #1f2937;
    --color-border: #30363d;
    --color-code-bg: #161b22;
    --color-code-text: #e1e5e9;
}

/* Removed auto dark mode media query to prevent flashing */

body {
    font-family: var(--font-serif);
    line-height: 1.7;
    color: var(--color-text);
    background-color: var(--color-bg);
    font-size: 16px;
}

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

/* Better responsive layout */
@media (min-width: 1200px) {
    :root {
        --max-width: 1100px;
    }
    .container {
        padding: 0 3rem;
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    :root {
        --max-width: 800px;
    }
}

/* Header */
header {
    padding: 2rem 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 2rem;
}

/* Remove all underlines from header links */
header a,
header a:hover,
header a:focus,
header a:active,
header a:visited {
    text-decoration: none !important;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    position: relative;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-title {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none !important;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    padding: 0.2rem 0;
}

.site-title:hover {
    color: var(--color-accent);
    transform: translateY(-3px) scale(1.05);
    text-shadow: 0 4px 16px rgba(0, 102, 204, 0.4);
    filter: brightness(1.2);
    text-decoration: none !important;
}

/* Analog Clock */
.analog-clock {
    display: flex;
    align-items: center;
    justify-content: center;
}

.clock-svg {
    transition: all 0.2s ease;
}

.analog-clock:hover .clock-svg {
    transform: scale(1.1);
}

#hour-hand, #minute-hand, #second-hand {
    transform-origin: 30px 30px;
}

#hour-hand, #minute-hand {
    transition: none;
}

#second-hand {
    transition: none;
}

/* Navigation */
nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
    margin: 0;
}

nav a {
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    position: relative;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    overflow: hidden;
}

nav a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, var(--color-accent-light), var(--color-accent));
    opacity: 0;
    transition: all 0.4s ease;
    z-index: -1;
}

nav a:hover {
    color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
    text-decoration: none !important;
}

nav a:hover::before {
    left: 0;
    opacity: 0.1;
}

nav a.active {
    color: var(--color-accent);
    background: var(--color-accent-light);
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--color-text);
}

.theme-toggle:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-light);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-icon {
    display: block;
    transition: transform 0.2s ease;
    color: var(--color-text);
}

.theme-toggle:hover .theme-icon {
    transform: scale(1.1);
}

/* SVG icon styling */
.theme-icon svg {
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
}

.sun-icon,
.moon-icon {
    transition: opacity 0.2s ease;
}

/* Main content */
main {
    min-height: 60vh;
    margin-bottom: 3rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

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

/* Ensure consistent h1 styling in all sectioned content */
section h1,
article h1,
aside h1,
nav h1,
main h1,
header h1,
footer h1 {
    font-size: 2rem !important;
    margin-bottom: 1.5rem !important;
}

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

h3 {
    font-size: 1.25rem;
    margin-top: 1.5rem;
}

p {
    margin-bottom: 1rem;
}

/* Links */
a {
    color: var(--color-accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Code */
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-code-bg);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: var(--color-code-text);
}

pre {
    background: var(--color-code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--color-border);
}

pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    color: var(--color-code-text);
}

/* Syntax highlighting overrides */
.highlight {
    background: var(--color-code-bg) !important;
    color: var(--color-code-text) !important;
}

.highlight pre {
    background: var(--color-code-bg) !important;
}

.highlight code {
    color: var(--color-code-text) !important;
}

/* Post list */
.post-list {
    list-style: none;
}

.post-item {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

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

.post-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.post-title a {
    color: var(--color-text);
    text-decoration: none;
}

.post-title a:hover {
    color: var(--color-accent);
    text-decoration: none;
}

.post-meta {
    font-family: var(--font-sans);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.post-description {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Tags */
.tags {
    margin-top: 1rem;
}

.tag {
    font-family: var(--font-sans);
    display: inline-block;
    background: var(--color-accent-light);
    color: var(--color-accent);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    border: 2px solid var(--color-accent-light);
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 32px;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
}

.tag:hover {
    background: var(--color-accent);
    color: var(--color-bg);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.3);
    border-color: var(--color-accent);
}

.tag:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.2);
}

/* Post content */
.post-content {
    margin-top: 2rem;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1rem 0;
}

.post-content blockquote {
    border-left: 4px solid var(--color-accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--color-text-muted);
}

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

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

/* Footer */
footer {
    font-family: var(--font-sans);
    border-top: 1px solid var(--color-border);
    padding: 2rem 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-top: 3rem;
}

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

.footer-content p {
    font-family: var(--font-sans);
    margin: 0;
    font-weight: 500;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: var(--color-text-muted);
    text-decoration: none;
}

.social-links a:hover {
    color: var(--color-accent);
    background: var(--color-accent-light);
    transform: translateY(-2px);
}

.social-icon {
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
}

.social-links a:hover .social-icon {
    transform: scale(1.1);
}

/* Tag highlighting */
.tag.active {
    background: var(--color-accent);
    color: var(--color-bg);
    font-weight: 600;
}

/* Terms list styling */
.terms-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.term-item {
    display: block;
    padding: 1.5rem;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--color-text);
    background: var(--color-bg);
    cursor: pointer;
}

.term-item:hover {
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: var(--color-text);
}

.term-item h3 {
    font-family: var(--font-sans);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
    color: var(--color-text);
    transition: color 0.2s ease;
}

.term-item:hover h3 {
    color: var(--color-accent);
}

.term-item .post-meta {
    font-family: var(--font-sans);
    margin-bottom: 0;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* Responsive */

/* Tablet styles */
@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }
    
    nav ul {
        gap: 1.5rem;
    }
    
    .terms-list {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
}

/* Mobile styles */
@media (max-width: 600px) {
    .container {
        padding: 0 1rem;
    }
    
    header {
        padding: 0.75rem 0;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .header-left {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        margin-bottom: 0;
    }
    
    .header-right {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        width: 100%;
    }
    
    nav {
        flex: 1;
        display: flex;
        justify-content: center;
    }
    
    nav ul {
        gap: 1rem;
        justify-content: center;
        flex-wrap: wrap;
        margin: 0;
    }
    
    nav a {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .theme-toggle {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
        flex-shrink: 0;
    }
    
    .site-title {
        font-size: 1.3rem;
        text-align: center;
    }
    
    .analog-clock .clock-svg {
        width: 45px;
        height: 45px;
    }
    
    h1 {
        font-size: 1.6rem;
        text-align: center;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    main {
        margin-bottom: 2rem;
    }
    
    .post-item {
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
    }
    
    .post-title {
        font-size: 1.2rem;
        text-align: left;
    }
    
    .post-meta {
        font-size: 0.8rem;
    }
    
    .post-description {
        font-size: 0.9rem;
    }
    
    .terms-list {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .social-links a {
        padding: 0.6rem;
        min-width: 44px;
        min-height: 44px;
    }
}

/* Small mobile styles */
@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }
    
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    header {
        padding: 0.5rem 0;
    }
    
    .header-content {
        gap: 0.75rem;
    }
    
    .header-left {
        gap: 0.5rem;
    }
    
    nav ul {
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    
    nav a {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
        min-height: 40px;
    }
    
    .site-title {
        font-size: 1.1rem;
    }
    
    .analog-clock .clock-svg {
        width: 40px;
        height: 40px;
    }
    
    .theme-toggle {
        min-width: 40px;
        min-height: 40px;
        padding: 0.4rem;
    }
    
    h1 {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
    }
    
    h2 {
        font-size: 1.2rem;
        margin-top: 1.5rem;
    }
    
    h3 {
        font-size: 1.05rem;
    }
    
    .post-item {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }
    
    .post-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .post-meta {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .post-description {
        font-size: 0.85rem;
        line-height: 1.5;
    }
    
    .post-content {
        margin-top: 1rem;
    }
    
    .post-content ul, .post-content ol {
        margin-left: 1.25rem;
    }
    
    .tag {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        margin-right: 0.3rem;
        margin-bottom: 0.3rem;
        min-height: 28px;
    }
    
    .term-item {
        padding: 0.75rem;
    }
    
    .footer-content {
        gap: 0.75rem;
    }
    
    .social-links a {
        min-width: 40px;
        min-height: 40px;
        padding: 0.5rem;
    }
}