/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure ruby elements are not affected by reset */
ruby, rt {
    margin: unset;
    padding: unset;
    box-sizing: unset;
}

body {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans CJK JP', sans-serif;
    line-height: 1.7;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.site-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.site-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.site-description {
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.breadcrumb {
    margin-bottom: 1rem;
}

.breadcrumb a {
    color: white;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.slider {
    width: 50px;
    height: 25px;
    background: rgba(255,255,255,0.3);
    border-radius: 25px;
    position: relative;
    transition: background 0.3s;
}

.slider:before {
    content: '';
    position: absolute;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-label input:checked + .slider {
    background: rgba(255,255,255,0.6);
}

.toggle-label input:checked + .slider:before {
    transform: translateX(25px);
}

.label-text {
    font-size: 0.9rem;
}

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.article-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.article-title {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.article-title a {
    color: #333;
    text-decoration: none;
}

.article-title a:hover {
    color: #667eea;
}

.article-date {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: block;
}

/* Article Stats */
.article-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.stat {
    background: #e9ecef;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.stat.unknown {
    background: #fff3cd;
    color: #856404;
}

.stat.known {
    background: #d1ecf1;
    color: #0c5460;
}

/* Article Images */
.article-image {
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.article-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.2s;
}

.article-image img:hover {
    transform: scale(1.02);
}

.article-image-full {
    margin: 2rem 0;
    text-align: center;
}

.article-image-full img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* Article Content */
.article-preview {
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
    margin: 2rem 0;
}

.article-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.read-more, .original-link, .back-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.read-more:hover, .original-link:hover, .back-link:hover {
    background: #f8f9ff;
}

/* Furigana Styles */
ruby {
    ruby-position: over;
}

rt {
    font-size: 0.6em;
    color: #666;
    font-weight: normal;
}

/* Furigana Toggle System */
.known-version, .no-furigana-version {
    display: none;
}

.unknown-version {
    display: inline;
}

/* Hide furigana completely */
body.hide-unknown-furigana .unknown-version {
    display: none;
}

body.hide-unknown-furigana .no-furigana-version {
    display: inline;
}

/* Show all furigana */
body.show-all-furigana .unknown-version {
    display: none;
}

body.show-all-furigana .known-version {
    display: inline;
}

/* Unknown Kanji List */
.unknown-kanji-list {
    margin: 1rem 0;
}

.unknown-kanji-list summary {
    cursor: pointer;
    font-weight: 500;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.kanji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.kanji-item {
    background: #fff3cd;
    color: #856404;
    padding: 0.5rem;
    text-align: center;
    border-radius: 6px;
    font-weight: 500;
    font-size: 1.2rem;
}

/* Full Article */
.article-full {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.article-full .article-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #333;
}

/* Footer */
.site-footer {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

.site-footer a {
    color: #adb5bd;
}

.no-articles {
    text-align: center;
    color: #666;
    font-size: 1.1rem;
    padding: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .site-header h1 {
        font-size: 2rem;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .controls {
        flex-direction: column;
        gap: 1rem;
    }

    .article-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .article-full {
        padding: 1rem;
    }

    .article-full .article-title {
        font-size: 1.5rem;
    }

    .article-image img {
        height: 150px;
    }

    .article-image-full img {
        border-radius: 8px;
    }
}