/*
Theme Name: Tumblike
Description: タイムライン形式のシンプルテーマ 🧪
Author: Saitos
Version: 0.2
*/

/* 🎨 Pico.cssと統合したカスタムスタイル */
:root {
    --sidebar-link-color: #eeeeee;
    --sidebar-link-hover-color: #ffffff;
    --sidebar-background-hover-color: #2c3e50;
    --post-meta-color: #90989d;
    --sidebar-width: 280px;
    --content-max-width: 640px;
    --font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-family-mono: "JetBrains Mono", "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
}

/* 🔤 フォント設定 */
body {
    font-family: var(--font-family);
}

code,
kbd,
samp,
pre {
    font-family: var(--font-family-mono);
}

/* 🔒 reCAPTCHAバッジを非表示 */
.grecaptcha-badge {
    visibility: hidden;
}

/* 🧱 レイアウトの根幹 */
.site-wrapper {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    gap: 0;
    max-width: 960px;
    margin: 0 auto;
}

/* 📌 固定サイドバー */
.site-sidebar {
    border-right: 1px solid var(--pico-muted-border-color);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: var(--pico-spacing);
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.site-logo {
    text-align: center;
}

.site-logo a {
    display: inline-block;
    transition: opacity 0.2s ease;
}

.site-logo a:hover {
    opacity: 0.7;
}

.site-logo img {
    max-width: 100%;
    height: auto;
    max-height: 100px;
    width: auto !important;
    object-fit: contain;
}

.site-title a {
    color: var(--pico-primary);
    text-decoration: none;
    font-weight: 700;
}

.site-title a:hover {
    color: var(--pico-primary-hover);
}

.site-description {
    color: var(--pico-muted-color);
    margin-bottom: var(--pico-spacing);
}

.main-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.main-navigation li {
    margin-bottom: 0.5rem;
}

.main-navigation a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: var(--pico-border-radius);
    text-decoration: none;
    color: var(--sidebar-link-color);
    transition: background-color 0.2s ease;
    font-size: 0.85rem;
}

.main-navigation a:hover,
.main-navigation a.is-active,
.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a,
.main-navigation .current-menu-ancestor > a,
.main-navigation .current-category-ancestor > a {
    background: var(--sidebar-background-hover-color);
    color: var(--sidebar-link-hover-color);
}

.main-navigation .menu-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

.main-navigation .menu-icon-emoji {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.main-navigation small {
    opacity: 0.6;
    margin-left: 0.5rem;
}

/* � サイドバーフッター */
.sidebar-footer {
    margin-top: auto;
    padding-top: var(--pico-spacing);
    border-top: 1px solid var(--pico-muted-border-color);
    text-align: center;
}

.sidebar-footer small {
    color: var(--pico-muted-color);
    display: block;
    font-size: 0.75rem;
}

/* ☕ Buy me a coffee ウィジェットエリア */
.bmc-widget-area {
    margin-top: auto;
    padding-top: var(--pico-spacing);
    border-top: 1px solid var(--pico-muted-border-color);
}

.bmc-widget-area iframe {
    max-width: 100%;
}

/* �🔧 WordPress管理バー対応 - サイドバー */
.admin-bar .site-sidebar {
    top: 32px;
    height: calc(100vh - 32px);
}

@media screen and (max-width: 782px) {
    .admin-bar .site-sidebar {
        top: 46px;
        height: calc(100vh - 46px);
    }
}

/* 🌊 タイムライン */
.site-main {
    padding: var(--pico-spacing);
    transition: opacity 0.2s ease-in-out;
    position: relative;
}

.site-main.is-loading {
    opacity: 0.5;
}

/* 📂 サブカテゴリバー */
.subcategory-bar {
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--pico-muted-border-color);
    border-radius: 0 0 1rem 1rem;
    padding: 1rem 0;
    margin: calc(var(--pico-spacing) * -1) calc(var(--pico-spacing) * -1) var(--pico-spacing);
    z-index: 100;
    transform: translateY(0);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 🔧 WordPress管理バー対応 */
.admin-bar .subcategory-bar {
    top: 32px;
}

@media screen and (max-width: 782px) {
    .admin-bar .subcategory-bar {
        top: 46px;
    }
}

.subcategory-bar.is-hidden {
    transform: translateY(-100%);
    opacity: 0;
}

.subcategory-list {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0 var(--pico-spacing);
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.subcategory-list::-webkit-scrollbar {
    display: none;
}

.subcat-item {
    background-color: transparent !important;
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem !important;
    white-space: nowrap;
    margin-bottom: 0 !important;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.subcat-item:hover {
    opacity: 1;
}

.subcat-all {
    background-color: transparent !important;
    color: var(--pico-primary) !important;
    border-color: var(--pico-primary) !important;
}

.subcat-item.is-active {
    background: var(--pico-primary) !important;
    color: #fff !important;
    opacity: 1 !important;
}

.timeline {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* 📦 各投稿カード */
.timeline-item {
    margin-bottom: var(--pico-spacing);
}

.post-thumbnail {
    margin-bottom: var(--pico-spacing);
}

.post-thumbnail img {
    max-width: 100%;
    height: auto;
    border-radius: var(--pico-border-radius);
    display: block;
}

.entry-header {
    margin-bottom: var(--pico-typography-spacing-vertical);
}

.entry-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.entry-date {
    flex-shrink: 0;
}

/* 固定ページでは日付を非表示 */
.page .entry-date {
    display: none;
}

.entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.tag-link {
    display: inline-block;
    color: var(--pico-primary);
    text-decoration: none;
    font-size: 0.7rem;
    padding: 0.1rem;
    background: transparent !important;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.tag-link:hover {
    opacity: 1;
    background: var(--pico-primary);
    color: #fff;
}

.entry-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.entry-title a {
    color: var(--pico-color);
    text-decoration: none;
}

.entry-title a:hover {
    color: var(--pico-primary);
}

/* 固定ページではタイトルリンクを無効化 */
.page .entry-title a {
    pointer-events: none;
    cursor: default;
    color: var(--pico-color);
}

.page .entry-title a:hover {
    color: var(--pico-color);
}

/* 📝 記事コンテンツのスタイル調整 */
.entry-content {
    font-size: 0.8rem;
    line-height: 1.8;
}

/* 📝 記事コンテンツの高さ制限 */
.entry-content-wrapper {
    position: relative;
}

.entry-content-wrapper:not(.is-expanded) .entry-content {
    max-height: 400px;
    overflow: hidden;
    position: relative;
}

.entry-content-wrapper:not(.is-expanded) .entry-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    background: linear-gradient(to bottom, transparent, var(--pico-card-background-color, var(--pico-background-color)));
    pointer-events: none;
}

/* 👁️ すべて見るボタン */
.read-more-btn {
    display: none; /* JSで制御 */
    margin: 1rem auto 0;
    width: auto;
    font-size: 0.7rem;
    padding: 0.5rem 1rem;
}

/* 展開状態ではグラデーションとボタンを非表示 */
.entry-content-wrapper.is-expanded .entry-content {
    max-height: none;
}

.entry-content-wrapper.is-expanded .entry-content::after {
    display: none;
}

.entry-content-wrapper.is-expanded .read-more-btn {
    display: none;
}

/* ⏳ 無限スクロール用のローディング表示 */
.infinite-scroll-loader {
    text-align: center;
    padding: 2rem 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.infinite-scroll-loader.is-visible {
    opacity: 1;
    visibility: visible;
}

.infinite-scroll-loader.is-complete .loader-spinner {
    display: none;
}

.infinite-scroll-loader.is-complete p {
    color: var(--pico-muted-color);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 4px solid var(--pico-muted-border-color);
    border-top-color: var(--pico-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.infinite-scroll-loader p {
    color: var(--pico-muted-color);
    font-size: 0.875rem;
    margin: 0;
}

.infinite-scroll-sentinel {
    height: 1px;
    visibility: hidden;
}

/* � シングルページ用オーバーレイモーダル */
.post-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.admin-bar .post-overlay {
    top: 32px;
}
.post-overlay.active {
    display: flex;
}

.admin-bar .post-overlay {
    top: 32px;
}

.post-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.post-overlay-content {
    position: relative;
    max-width: 80vw;
    max-height: 90vh;
    width: 100%;
    background: var(--pico-background-color);
    border-radius: var(--pico-border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-overlay-close {
    position: absolute;
    top: 1rem;
    right: calc(50% - 45vw);
    width: 48px;
    height: 48px;
    background: var(--pico-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.8rem;
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s ease;
}

@media (max-width: 900px) {
    .post-overlay-close {
        right: 1rem;
    }
}

.post-overlay-close:hover {
    background: var(--pico-primary-hover);
}

.post-overlay-content {
    position: relative;
}

.post-overlay-article {
    padding: 2rem;
}

.post-overlay-article .entry-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.post-overlay-article .entry-content {
    font-size: 1rem;
    line-height: 1.7;
}

.post-overlay-loading {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--pico-muted-color);
}

/* 🍔 モバイル用ハンバーガーメニューボタン */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    width: 44px;
    height: 44px;
    background: var(--pico-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    transition: all 0.3s ease;
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.is-active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle.is-active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.is-active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.admin-bar .mobile-menu-toggle {
    top: calc(46px + 1rem);
}

.mobile-menu-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-menu-backdrop.is-active {
    opacity: 1;
}

/* 📱 レスポンシブ (モバイル時は縦並び) */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        z-index: 990;
    }
    
    .site-wrapper {
        grid-template-columns: 1fr;
    }
    
    .site-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 999;
        border-right: 1px solid var(--pico-muted-border-color);
        border-bottom: none;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        background: var(--pico-background-color);
        overflow-y: auto;
    }
    
    .site-sidebar.is-open {
        transform: translateX(0);
    }
    
    .admin-bar .site-sidebar {
        top: 46px;
        height: calc(100vh - 46px);
    }
    
    .mobile-menu-backdrop.is-active {
        display: block;
    }
    
    .subcategory-bar {
        margin: calc(var(--pico-spacing) ) calc(var(--pico-spacing) * -1) var(--pico-spacing);
    }
    
    .site-main {
        padding: 1rem;
        padding-top: calc(1rem + 3rem);
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .timeline {
        max-width: 100%;
    }
    
    .timeline-item {
        overflow: hidden;
    }
    
    .post-thumbnail img,
    .entry-content img {
        max-width: 100%;
        height: auto;
    }
    
    .entry-content {
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }
    
    .post-overlay-content {
        max-width: calc(100vw - 1rem);
        margin: 0 1rem;
    }
    
    .post-overlay-article {
        padding: 1rem;
    }
}