/*
Template:ystandard
Theme Name:ystandard-child
Theme URI: https://wp-ystandard.com
Author: yosiakatsuki
Author URI: https://yosiakatsuki.net
Description:「自分色に染めた、自分だけのサイトを作る楽しさ」を感じてもらうために作った一風変わったWordPressテーマ「ystandard」の子テーマ
Version: 4.0.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/

/* =============================================
   トップページ / 3カラムレイアウト
============================================= */

/* トップページ・アーカイブページのcontent__wrap */
.home .content__wrap > main,
.archive .content__wrap > main,
.search .content__wrap > main {
    min-width: 0;
    width: 100%;
    background-color: #ffffff;
    padding: var(--ystd-layout-gap);
}

.content__wrap {
    display: grid !important;
    grid-template-columns: 220px 1fr 300px;
    gap: 15px;
    align-items: start;
}

.col-left {
    order: -1;
    min-width: 0;
    background-color: var(--content-bg);
}

.content__wrap > main,
.content__wrap > aside:not(.col-left) {
    min-width: 0;
    width: 100%;
}

/* 各カラムのシャドウ */
.col-left,
.content__wrap > main,
.content__wrap > aside:not(.col-left) {
    box-shadow: 0 0 2px 0 #0000001f, 0 1px 2px 0 #0000003d;
}

/* メインコンテンツの余白リセット */
.has-sidebar .content__main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 16px 10px;
}

/* =============================================
   サイドバー共通
============================================= */

/* サイドバー背景 */
.sidebar__widget {
    background-color: #ffffff;
	
}

/* サイドバー内のテキストを小さく */
.col-left .wp-block-paragraph:not(.is-style-ystdtb-side-h2):not(.is-style-ystdtb-side-h3),
#secondary .wp-block-paragraph:not(.is-style-ystdtb-side-h2):not(.is-style-ystdtb-side-h3),
.col-left .wp-block-list,
#secondary .wp-block-list {
    font-size: 0.85em;
}

/* 上余白をなくす */
.has-background .sidebar__fixed > *,
.has-background .sidebar__widget > * {
    --sidebar-padding: 0.75rem;
    padding: 0 var(--sidebar-padding) 0;
}

.col-left {
	padding-bottom: 1.5rem;
}

/* 左サイドバーの見出し余白調整 */
.ystdtb.ystdtb-heading .is-style-ystdtb-side-h2 {
    margin-top: 0;
}

/* 見出しを横いっぱいに */
#secondary .is-style-ystdtb-side-h2,
.col-left .is-style-ystdtb-side-h2,
#secondary .is-style-ystdtb-side-h3,
.col-left .is-style-ystdtb-side-h3 {
    margin-left: calc(-1 * var(--sidebar-padding, var(--ystd-layout-gap)));
    margin-right: calc(-1 * var(--sidebar-padding, var(--ystd-layout-gap)));
}

/* =============================================
   閉じるボタン・ハンバーガー（PC非表示）
============================================= */
.left-sidebar-close {
    display: none;
}

.left-sidebar-toggle,
.left-sidebar-overlay {
    display: none;
}

/* =============================================
   タブレット
============================================= */
@media (max-width: 1024px) {
    .content__wrap {
        grid-template-columns: 1fr 240px !important;
    }
    .col-left {
        display: none;
    }
}

/* =============================================
   SP
============================================= */
@media (max-width: 768px) {
    .content__wrap {
        grid-template-columns: 1fr !important;
    }

    /* 本文エリアの背景だけ画面いっぱいに広げる */
    .container--body {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* .containerのpaddingを0にした分、archive__main/content__mainの
       負のマージン(-1rem)による左はみ出しを打ち消す */
    .archive__main,
    .content__main {
        --ystd-content-horizon-margin: 0 !important;
    }

    .content__wrap > main {
        border-left: none !important;
        border-right: none !important;
    }

    /* サイドバーウィジェット内の負のマージンを打ち消す(PCには影響なし) */
    .has-background .sidebar__widget > * {
        margin-left: 0;
        margin-right: 0;
    }

    /* 左サイドバー ドロワー */
    .col-left {
        display: block;
        order: 0;
        position: fixed;
        top: 0;
        right: -320px;
        left: auto;
        width: 320px;
        height: 100vh;
        background: #fff;
        z-index: 9999;
        overflow: visible;
        overflow-y: auto;
        padding: 20px;
        transition: right 0.6s ease;
        box-shadow: -2px 0 8px rgba(0,0,0,0.2);
        visibility: hidden;
    }

    .col-left.is-open {
        right: 0;
        visibility: visible;
    }

    /* 閉じるボタン */
    .left-sidebar-close {
        display: none;
        position: fixed;
        top: 8px;
        left: 12px;
        width: 30px;
        height: 30px;
        background: none;
        border: none;
        color: #fff;
        cursor: pointer;
        font-size: 32px;
        z-index: 10000;
        padding: 0;
    }

    .col-left.is-open .left-sidebar-close {
        display: block;
    }

    /* ハンバーガーボタン */
    .left-sidebar-toggle {
        display: flex;
        position: fixed;
        top: 6px;
        right: 10px;
        width: 33px;
        height: 33px;
        background: #36563c;
        color: #fff;
        border: none;
        cursor: pointer;
        z-index: 9997;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0;
        padding: 0;
        font-size: 12px;
    }

    .left-sidebar-toggle .hamburger-icon {
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .left-sidebar-toggle .hamburger-icon span {
        display: block;
        width: 18px;
        height: 2px;
        background: #fff;
    }

    /* オーバーレイ */
    .left-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 9998;
    }

    .left-sidebar-overlay.is-open {
        display: block;
    }
}

/* =============================================
   人気記事ランキング
============================================= */
.popular-posts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.popular-posts-item {
    margin-bottom: 12px;
}

.popular-posts-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-decoration: none;
    color: #333;
}

.popular-posts-title {
    font-size: 12px;
    line-height: 1.4;
    color: var(--link-text);
}

.popular-posts-link:hover .popular-posts-title {
    color: var(--link-text-hover);
}

.popular-posts-thumb {
    position: relative;
    width: 75px;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #eee;
}

.popular-posts-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* サムネ左上に重ねるランキング番号バッジ */
.popular-posts-rank {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    min-width: 20px;
    padding: 2px 6px;
    background-color: #aaa;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    line-height: 1.4;
}

/* 1位:ゴールド */
.popular-posts-item:nth-child(1) .popular-posts-rank {
    background-color: #d4af37;
}

/* 2位:シルバー */
.popular-posts-item:nth-child(2) .popular-posts-rank {
    background-color: #a7a7a7;
}

/* 3位:ブロンズ */
.popular-posts-item:nth-child(3) .popular-posts-rank {
    background-color: #b87333;
}

/* =============================================
   アイキャッチ画像のはみ出し修正
============================================= */
.has-background .singular-header__thumbnail {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* =============================================
   Google マイマップ レスポンシブ対応
============================================= */
.map-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.map-wrap iframe {
    display: block;
    width: 100%;
    height: 480px;
}

@media (max-width: 768px) {
    .map-wrap iframe {
        height: 260px;
    }
}

/* =============================================
   Snow Monkey Blocks
============================================= */
/* タブを均等幅に */
.smb-tabs__tabs {
    display: flex !important;
}

.smb-tabs__tab-wrapper {
    flex: 1 !important;
}

.smb-tabs__tab-wrapper button {
    width: 100% !important;
    text-align: center !important;
}

/* =============================================
   back-to-top 調整（wpd-bubble-wrapperに合わせて）
============================================= */
#back-to-top {
    width: 64px !important;
    height: 64px !important;
	right: 25px !important;
}

body:has(#wpd-bubble-wrapper) #back-to-top {
	bottom: 17vh !important;
}

@media (max-width: 768px) {
	#back-to-top {
		    width: 40px !important;
		    height: 40px !important;
			right: 25px !important;
	}
	
	body:has(#wpd-bubble-wrapper) #back-to-top {
		bottom: 12vh !important;
	}
}

/* =============================================
   画像クリック拡大
============================================= */
.js-zoom img,
.js-zoom.wp-block-image {
    cursor: zoom-in;
}

.js-zoom-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    cursor: zoom-out;
    padding: 20px;
    box-sizing: border-box;
}

.js-zoom-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* =============================================
   最近の投稿ウィジェット：サムネとタイトルを横並び固定
============================================= */
#secondary .wp-block-latest-posts__list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

#secondary .wp-block-latest-posts__list li:last-child {
  padding-bottom: 1.5rem;
}

#secondary .wp-block-latest-posts__featured-image.alignleft {
    float: none;
    margin: 0 !important;
    flex-shrink: 0;
}

#secondary .wp-block-latest-posts__post-title {
    flex: 1;
    margin: 0 !important;
    min-width: 0; /* 長いタイトルでもはみ出さず折り返すため */
}