/*
Theme Name: BooksPrivilege3
*/
@charset "utf-8";

/* ========================================
   基本設定 (Base Styles)
   ======================================== */
body {
    padding: 0;
    width: 900px;
    margin: auto;
    font-family: 'じゅん 201', sans-serif;
    /* 背景色 (Pattern 2) */
    background-color: #fcfbf9;
    color: #333;
}

main {
    width: 900px;
    margin: 0;
}

header {
    padding: 0;
    margin: 0;
    /* ヘッダー色 (Pattern 2) */
    background-color: #eceff1 !important;
    color: #455a64 !important;
    border-bottom: 1px solid #cfd8dc;
}

footer {
    width: 600px;
    height: 22px;
    clear: left;
    /* フッター色 (Pattern 2) */
    background-color: #eceff1 !important;
    color: #455a64 !important;
}

footer p {
    float: left;
    text-align: center;
    height: 26px;
    margin: 2px;
}

/* リンク色 (Pattern 2) */
a, a:link, a:visited, a:hover, a:active {
    text-decoration: none;
    color: #546e7a; /* 落ち着いたブルーグレー */
}
a:hover {
    color: #37474f;
    text-decoration: underline;
}

/* ヘッダー・フッター内のリンク */
header a, footer a, header .entry-title a {
    color: #37474f !important;
    text-decoration: none;
}

h1 {
    font-weight: unset;
}

/* 記事タイトル (トップページ等のリスト) */
h2.entry-title {
    font-size: 20px;
    background-color: rgb(230,230,230);
}

/* 記事タイトル (個別ページ等) */
h1.entry-title {
    font-size: 20px;
    background-color: rgb(230,230,230);
    margin: 0;
    padding: 5px;
}

/* ========================================
   記事エリア・ナビゲーション
   ======================================== */
article {
    width: 100%;
    min-height: 300px;
    float: left;
}

#articlearea {
    width: 600px;
    min-height: 700px;
    float: left;
}

.entry-content {
    margin: 0 0 0 5px;
    background-color: none;
    overflow: hidden;
}

#sidebar {
    width: 300px;
    min-height: 300px;
    float: left;
    margin: 0;
}

form {
    float: right;
}

/* メニュー */
#menu {
    width: 600px;
    height: 25px;
    margin: 5px 0 0 0;
}
#menu ul {
    list-style-type: none;
    width: 50%;
    padding: 0;
    margin: 0;
    text-align: center;
}
#menu li {
    float: left;
    width: 50%;
    min-width: 100px;
    text-align: center;
    vertical-align: middle;
    padding: 0;
    margin: 0;
}

/* ページネーション */
.nav-previous { float: left; margin: 15px 0; }
.nav-next { float: right; margin: 15px 0; }

/* ========================================
   書籍情報ボックス (shop_box)
   ======================================== */
/* Kindle版などのタブ */
.tab-label {
    max-width: 500px !important;
    width: 100% !important;
    margin: 10px auto 0 auto;
    text-align: left;
    position: relative;
    z-index: 5;
}
.tab-label span {
    display: inline-block;
    /* タブ背景 (Pattern 2) */
    background-color: #cfd8dc !important;
    color: #455a64 !important;
    font-size: 13px;
    padding: 6px 15px;
    border: none !important;
    border-radius: 4px 4px 0 0;
    position: relative;
    top: 1px;
}

.shop_box {
    float: none !important;
    display: block !important;
    height: 200px !important;
    width: 500px !important;
    margin: 0 auto 10px auto !important;
    border-right: 1px solid rgb(150, 150, 150);
    border-bottom: 1px solid rgb(150, 150, 150);
    overflow: hidden;
}

.shop_image {
    float: left;
    height: 200px !important;
    min-width: 30% !important;
    width: 140px !important;
    background-color: rgb(255,255,255) !important;
}
.shop_image img {
    max-height: 200px !important;
    max-width: 140px !important;
    margin-top: auto;
    margin-bottom: auto;
}

.shop_info {
    vertical-align: top;
    font-size: 18px !important;
    height: 200px !important;
}
.shop_title {
    overflow: hidden;
    height: 80px !important;
}
.shop_author {
    overflow: hidden;
    height: 45px !important;
    background-color: rgb(230,230,230) !important;
}
.shop_label {
    overflow: hidden;
    height: 25px !important;
}
.shop_date {
    height: 25px !important;
    background-color: rgb(230,230,230) !important;
}
.shop_page {
    height: 25px !important;
}

/* ========================================
   店舗特典リスト (shop-list)
   ======================================== */
.shop-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 500px;
    width: 96%;
    margin: 0 auto 20px auto;
    border-top: none;
    padding-top: 0;
}

.shop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #fff;
    border: 1px solid rgb(150, 150, 150);
    border-radius: 4px;
    transition: background-color 0.2s;
}
.shop-row:hover {
    background-color: #f5f5f5;
}

/* 店舗名 */
.shop-name-col {
    font-weight: bold;
    font-size: 16px;
    color: #333;
    flex: 0 0 150px;
    text-align: left;
}
.shop-name-col a {
    color: #546e7a;
    text-decoration: none;
}

/* 特典内容・ボタン */
.shop-benefit-col {
    flex: 1;
    text-align: left;
    font-size: 14px;
    line-height: 1.4;
    padding-left: 10px;
}
.shop-benefit-col a {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    /* ボタン色 (Pattern 2) */
    background-color: #cfd8dc !important;
    color: #455a64 !important;
    border: none !important;
}
.shop-benefit-col a:hover {
    background-color: #b0bec5 !important;
    color: #263238 !important;
}

/* タグエリア */
.tag-area {
    max-width: 500px;
    width: 96%;
    margin: 20px auto;
    text-align: center;
    font-size: 14px;
    color: #666;
}
.tag-area a {
    display: inline-block;
    margin: 0 5px;
    color: #546e7a;
    text-decoration: underline;
}
p.tag {
    margin: 0;
    padding: 0;
    font-size: 16px;
}

/* ========================================
   グリッド表示 (Top Page)
   ======================================== */
.book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
    width: 100%;
    box-sizing: border-box;
}

.book-item {
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    background-color: #fff;
    border-radius: 4px;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.book-item:hover { box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

.book-item-image {
    width: 100%;
    aspect-ratio: 2 / 3;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.book-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 4px;
    box-sizing: border-box;
}

.book-item-info {
    padding: 10px;
    font-size: 13px;
    line-height: 1.5;
    background-color: #fff;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.book-item-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
    display: block;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.book-item-author {
    font-size: 11px;
    color: #777;
    margin-top: auto;
}

/* ========================================
   レガシーテーブル定義 (Table Layouts)
   ======================================== */
table.shop {
    border-collapse: collapse;
    font-size: 18px;
    max-width: 560px;
    background-color: rgb(250, 250, 250);
}
table.shop td {
    border-right: 1px solid rgb(150, 150, 150);
    border-bottom: 1px solid rgb(150, 150, 150);
    min-width: 115px;
}
table.shop a:link, table.shop a:visited, table.shop a:hover, table.shop a:active {
    text-decoration: none;
    color: black;
}

table.book {
    margin-left: 20px;
    margin-right: 20px;
    border-collapse: collapse;
    max-width: 555px;
    font-size: 16px;
    border: none;
}
table.book td {
    max-width: 185px;
    vertical-align: top;
    border-left: 1px solid rgb(150, 150, 150);
    border-right: 1px solid rgb(150, 150, 150);
}
table.book img {
    max-width: 185px;
    max-height: 200px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
table.book tr:nth-child(3n+1) td { border-top: 1px solid rgb(150, 150, 150); }
table.book tr:nth-child(3n+3) td { border-bottom: 1px solid rgb(150, 150, 150); }
table.book tr:nth-child(3n+2) { background-color: rgb(230, 230, 230); }


/* ========================================
   広告・ウィジェット
   ======================================== */
#ad {
    position: relative;
    width: 100%;
    max-width: 600px;
}
#ad:before { content: ""; display: block; padding-top: 36%; }
#adtop, #adbottom { position: absolute; top: 0; left: 0; bottom: 0; right: 0; }
#adbottom { display: none; }

#adtop > .adbox { width: 50%; height: 212px; float: left; }
#adtop > .adbox img { max-width: 100%; max-height: 100%; }

#adsub {
    width: 300px !important;
    height: 480px;
    aspect-ratio: 4/3;
    float: left;
}
#adsub > .adbox { width: 100%; height: 50%; }
#adsub > .adbox img {
    width: 100% !important;
    max-height: 100%;
    display: block;
}

.popular_bar, .recent_bar, .popular-posts h2, #wpp-2 h2, h2.side_widget_title {
    font-size: 18px;
    background-color: rgb(210, 210, 210);
}
.popular, .recent, ul.wpp-list, .side_widget ul { font-size: 16px; }
ul.popular_list, ul.recent_list, ul.wpp-list, .side_widget ul { list-style: none; }
ul.wpp-list, .side_widget ul { border-bottom: 10px solid rgb(210,210,210); }
li { margin-bottom: 10px !important; }

/* カレンダーウィジェット */
.calendar-widget {
    background: #fff;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    box-sizing: border-box;
    width: 100%;
}
.calendar-header {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.cal-nav {
    display: inline-block;
    padding: 2px 10px;
    background: #eee;
    border-radius: 3px;
    color: #333;
}
.calendar-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.calendar-table th { background: #f5f5f5; text-align: center; padding: 4px 0; font-weight: normal; color: #555; }
.calendar-table td { text-align: center; padding: 6px 0; border: 1px solid #eee; background-color: #fff; }

.calendar-table th:first-child, .calendar-table td.sunday { color: #d32f2f; background-color: #ffebee !important; }
.calendar-table th:last-child, .calendar-table td.saturday { color: #1976d2; background-color: #e3f2fd !important; }
.calendar-table td.today { font-weight: bold; border: 2px solid #ff9800; }
.calendar-table td.has-book a {
    display: block; width: 100%; height: 100%;
    font-weight: bold; text-decoration: underline; color: #e65100;
}

/* ========================================
   スマホ用カレンダーボタン & モーダル
   ======================================== */
#sp-calendar-btn-top { display: none; }

#calendar-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9999;
}
#calendar-modal-content {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%; max-width: 400px; max-height: 80vh;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    display: flex; flex-direction: column;
}
#calendar-modal-header {
    background-color: #eee; padding: 10px 15px;
    display: flex; justify-content: space-between; align-items: center;
    font-weight: bold;
}
#calendar-modal-close { cursor: pointer; background: #ccc; padding: 4px 10px; border-radius: 4px; font-size: 12px; }
#calendar-modal-body { padding: 10px; overflow-y: auto; }
#calendar-modal-body .calendar-widget { display: block !important; border: none; padding: 0; margin: 0; }


/* ========================================
   メディアクエリ: タブレット・小画面PC (420px ~ 640px)
   ======================================== */
@media screen and (min-width:420px) and (max-width: 640px){
    header, body, main, #menu, article, #articlearea, footer { width: 100%; }
    .site-title { text-align: center; }
    
    .entry-header, .entry-title, .entry-content { width: 100%; }
    
    #ad, #adtop { width: 100%; margin: 0; }
    #adtop > .adbox { width: 50%; float: left; }
    #adsub { width: 100% !important; height: 215px;}
    #adsub > .adbox { width: 50%; float: left; height : 100%}


    table.book { width: 96%; margin-left: 2%; margin-right: 2%; }
    table.book td { width: 32%; }
    table.shop { max-width: 95%; }

    #sidebar { width: 100%; min-height: 120px; height: 240px; }
    #side, .calendar-widget, #menu li.top { display: none; }
    
    #changecss { display: initial; margin-left: 25%; margin-right: 25%; }
    #changecss input { width: 50%; font-size: 16px; }
}

/* ========================================
   メディアクエリ: スマホ (420px以下)
   ======================================== */
@media screen and (max-width: 420px){
    header, body, main, #menu, article, #articlearea, footer { width: 100%; }
    .entry-header, .entry-title, .entry-content { width: 100%; }

    #adtop { width: 100%; height: 125px; margin: 0; }
    #adtop > .adbox { width: 50%; height: 125px; float: left; }
    #adtop > .adbox img { max-width: 100%; max-height: 150px; }
    
    #adsub { width: 100% !important; max-height: 200px; }
    #adsub > .adbox { width: 50%; float: left; height : 100%;}
    #adsub > .adbox img { max-width: 300px; max-height: 100%;}
    #sidebar { width: 100% !important; min-height: 120px; max-height: 215px; }
    #side, .calendar-widget, #menu li.top { display: none; }

    /* shop_box スマホ最適化 */
    .shop_box {
        float: none !important;
        min-height: 240px;
        height: auto !important;
        width: 94% !important;
        margin-left: 2%; margin-right: 2%;
        border: 1px solid rgb(150, 150, 150);
    }
    .shop_image {
        float: none !important;
        height: 160px !important;
        width: 100% !important;
        border-bottom: 1px solid rgb(150, 150, 150);
    }
    .shop_image img {
        max-height: 160px !important;
        max-width: 115px !important;
        margin: 0 calc(48% - 60px) !important;
    }
    .shop_info { width: 100% !important; min-height: 80px; height: auto !important; }
    .shop_title { overflow: visible !important; min-height: 20px; width: 100% !important; height: auto !important; }
    .shop_author { overflow: visible !important; width: 100% !important; min-height: 20px; height: auto !important; background-color: rgb(230,230,230) !important; }
    .shop_label { overflow: visible !important; width: 100% !important; min-height: 20px; height: auto !important; }
    .shop_date { width: 100% !important; min-height: 20px; height: auto !important; background-color: rgb(230,230,230) !important; }
    .shop_page { display: none !important; }

    /* テーブル調整 */
    table.book { width: 96%; margin: 0 2%; }
    table.book td { min-width: 32%; width: 32%; }
    table.shop { width: 96%; margin: 5px 1%; border: 1px solid rgb(150, 150, 150); }
    table.shop tr, table.shop td { display: block; width: 100%; border: none; }
    table.shop td { border-bottom: 1px solid rgb(150, 150, 150); }
    table.shop td:nth-child(2n+1) { width: 100%; height: 30px; padding-top: 6px; text-align: center; background-color: rgb(210, 210, 210); }

    #side, #menu li.top { display: none; }
    #menu { margin-top: 20px; }
    #menu li { width: 100%; }
    #searchform, #searchform input { width: 40%; }
    #changecss { display: initial; margin-left: 25%; margin-right: 25%; }
    #changecss input { width: 50%; font-size: 16px; }
}

/* ========================================
   メディアクエリ: スマホ全般・新レイアウト (640px以下)
   ======================================== */
@media screen and (max-width: 640px) {
    .book-grid { 
        grid-template-columns: repeat(3, 1fr); 
        gap: 5px; 
    }
    
    .book-item-info { padding: 5px; }
    .book-item-title { font-size: 11px; margin-bottom: 2px; }
    .book-item-author { font-size: 10px; }

    /* コンテナ幅調整 */
    .shop_box, .tab-label, .shop-list, .tag-area {
        width: 96% !important;
        max-width: 96% !important;
    }

    /* 店舗リスト: 縦並び */
    .shop-row {
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding: 8px;
    }

    /* 店舗名 */
    .shop-name-col {
        flex: auto;
        width: 100%;
        text-align: center;
        margin-bottom: 2px;
    }

    /* 特典内容 */
    .shop-benefit-col {
        padding-left: 0;
        width: 100%;
        text-align: center;
    }
    /* ボタン幅いっぱい */
    .shop-benefit-col a {
        display: block;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
        padding: 8px 10px;
    }

    /* スマホ用カレンダー表示 */
    #sp-calendar-btn-top {
        display: block;
        width: 100%;
        padding: 10px 0;
        background-color: #fff;
        border-bottom: 1px solid #eee;
        margin-bottom: 10px;
        text-align: center;
    }
    #sp-calendar-btn-top button {
        width: 92%;
        padding: 12px;
        font-size: 15px;
        background-color: #546e7a; /* テーマ色 (Pattern 2) */
        color: #fff;
        border: none;
        border-radius: 4px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    #sidebar .calendar-widget { display: none !important; }
}
