/* =====================================
   Base & Typography
   ===================================== */
:root {
    /* Fluid type scales (320px–768px, cap on desktop) */
    --fs-base: clamp(15px, calc(14px + 0.5vw), 18px);
    --fs-sm: clamp(13px, calc(12px + 0.45vw), 15.5px);
    --fs-h4: clamp(1.05rem, calc(0.95rem + 0.6vw), 1.25rem);
    --fs-h3: clamp(1.25rem, calc(1.1rem + 0.9vw), 1.6rem);
    --fs-h2: clamp(1.45rem, calc(1.25rem + 1.2vw), 2rem);
    --fs-h1: clamp(1.7rem, calc(1.45rem + 1.6vw), 2.4rem);
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: #f2f2f2;
    margin: 0;
    padding: 0;
    font-family: "Yu Gothic", "ヒラギノ角ゴ ProN", "Meiryo", sans-serif;
    font-size: var(--fs-base);
    line-height: 1.7;
    color: #333;
}

p {
    line-height: 1.8;
    margin: 0 0 1em;
}

h1 {
    font-size: var(--fs-h1);
    line-height: 1.25;
}

h2 {
    font-size: var(--fs-h2);
    line-height: 1.28;
}

h3 {
    font-size: var(--fs-h3);
    line-height: 1.32;
}

h4 {
    font-size: var(--fs-h4);
    line-height: 1.36;
}

/* small text utilities */
.table-wrap,
.rating-table,
.spec-table,
.comparison-container table {
    font-size: var(--fs-sm);
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Affiliate notice */
.affiliate-notice {
    font-size: .85em;
    color: #777;
    margin: 1em;
    padding-left: 1em;
    border-left: 3px solid #ddd;
}

/* =====================================
   Layout shell
   ===================================== */
.layout {
    display: flex;
    align-items: stretch;
    min-height: 80vh;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 20px;
    background: #f2f2f2;
}

/* Main content */
.main-content {
    flex: 1;
    background: #fff;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
    max-width: 1000px;
    margin: 0;
    min-width: 0;
}

.main-content iframe {
    width: 100%;
    height: 600px;
    border: none;
}

/* =====================================
   Header (navbar)
   ===================================== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 60px;
    background: #89d66d;
    width: 100%;
    padding: 0;
    margin-bottom: 30px;
}

.header-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
}

.logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 1.5em;
}

.logo-img {
    height: 50px;
    width: auto;
    display: block;
}

/* Hamburger */
.hamburger {
    display: none;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    cursor: pointer;
    z-index: 1001;
}

.hamburger span {
    height: 3px;
    width: 25px;
    background: #fff;
    margin: 4px 0;
}

.menu-toggle {
    display: none;
}

/* =====================================
   Sidebar
   ===================================== */
.sidebar {
    width: 300px;
    background: #f2f2f2;
    padding: 20px;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar li {
    margin-bottom: 10px;
}

.sidebar a {
    text-decoration: none;
    color: #333;
}

.category-button {
    display: block;
    font-weight: 700;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 6px;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
    transition: background-color .3s ease;
}

.category-button:hover {
    background: #e0e0e0;
}

/* --- Rakuten widget 用の入れ物とサイドバー幅を安定化 --- */
.custom-sidebar {
  /* 300px系ウィジェットが確実に入るように。padding/borderの目減りも考慮 */
  width: 300px;
  box-sizing: border-box;
  overflow: visible;
}

/* ウィジェットの描画先（HTMLに <div id="rakuten_widget_sidebar"></div> を置く前提） */
#rakuten_widget_sidebar {
  width: 100%;
  display: block;
}

/* details内でスライドが切れないように */
.custom-sidebar details { overflow: visible; }

.custom-sidebar li {
    border-bottom: 1px solid #ccc;
    padding: 6px 0;
    list-style: none;
    margin: 0 6px;
    font-size: 0.8em;
}

.custom-sidebar li:last-child {
    border-bottom: none;
}

details {
    border: 1px solid #aaa;
    border-radius: 4px;
    margin-bottom: 10px;
    padding: 5px 10px;
    background: #fff;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, .1);
}

summary {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
    cursor: pointer;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 4px;
}

summary:hover {
    background: #e8e8e8;
}

summary::before {
    content: "📁 ";
    margin-right: 5px;
}

details[open] summary::before {
    content: "📂 ";
}

/* =====================================
   Post meta (tags / dates)
   ===================================== */
.post-meta-inline {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: .95rem;
    margin: 15px 0;
}

.post-meta-inline span {
    display: flex;
    align-items: center;
}

.tag {
    display: inline-block;
    background: #e0e0e0;
    color: #333;
    padding: 3px 8px;
    margin-left: 5px;
    border-radius: 4px;
    font-size: .85rem;
}

/* =====================================
   Recommended articles grid
   ===================================== */
.recommended-articles {
    max-width: 1100px;
    margin: 60px auto;
    padding: 0 20px;
}

.recommended-articles h2 {
    font-size: 1.6em;
    margin-bottom: 20px;
    color: #333;
}

.article-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.article-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1);
    overflow: hidden;
    text-decoration: none;
    color: #333;
    transition: transform .2s ease;
}

.article-card:hover {
    transform: translateY(-4px);
}

.article-card img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

.article-card p {
    padding: 12px;
    font-weight: 700;
    font-size: 1em;
    margin: 0;
}

/* =====================================
   Media blocks / images
   ===================================== */
.img-top img {
    width: 100%;
    height: auto;
    margin-bottom: 20px;
}

.image-block {
    margin: 30px 0;
    text-align: center;
}

.image-block img {
    max-width: 95%;
    height: auto;
    border-radius: 8px;
}

.caption {
    font-size: .8em;
    color: #666;
    margin-top: 8px;
}

/* =====================================
   Footer
   ===================================== */
.footer {
    background: #333;
    color: #fff;
    text-align: center;
    padding: 15px 0;
    width: 100%;
    margin-top: 20px;
}

.footer-container {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 20px;
}

.footer-box {
    flex: 1;
    padding: 20px;
    text-align: left;
    font-size: .9em;
}

.link-white {
    color: #e7e7e7;
    text-decoration: none;
}

.no-bullet {
    list-style: none;
    padding-left: 0;
    margin-left: 0;
}

/* =====================================
   Component sizing tweaks
   ===================================== */
.category-button,
.shop-buttons a.shop-btn,
.shop-buttons2 a.shop-btn,
.btn-x {
    font-size: clamp(.95rem, calc(.9rem + .3vw), 1.05rem);
}

/* =====================================
   Responsive
   ===================================== */
@media (max-width: 768px) {

    /* spacing & layout */
    .layout {
        flex-direction: column;
    }

    .main-content {
        margin: 16px 12px;
        padding: 20px;
        max-width: none;
    }

    /* navbar */
    .navbar {
        height: 56px;
    }

    .logo {
        font-size: 1.25em;
    }

    .logo-img {
        height: 40px;
    }

    .hamburger {
        display: flex;
    }

    /* sidebar as drawer */
    .sidebar {
        position: fixed;
        top: 56px;
        right: 0;
        height: calc(100% - 56px);
        width: 100vw;
        box-sizing: border-box;
        background: #fff;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform .3s ease;
        z-index: 1000;
        padding: 40px 30px;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        margin-top: 12px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar a {
        font-size: 1.2em;
        margin-bottom: 15px;
    }

    .sidebar ul{
        width: 100%;
    }

    .custom-sidebar {
    width: auto;      /* 画面幅に馴染ませる */
    max-width: none;
    
  }

    /* meta */
    .post-meta-inline {
        flex-direction: column;
        gap: 6px;
        font-size: .9rem;
    }

    /* grid */
    .article-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* media safety */
    .img-top img,
    .image-block img {
        display: block;
        margin: 0 auto;
        max-width: 100%;
        height: auto;
    }

    /* responsive iframe */
    .main-content iframe {
        width: 100%;
        aspect-ratio: 16 / 9;
        height: auto;
    }

    /* full-width safe gutters for common wrappers */
    body {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .layout,
    .container,
    .main-content,
    .content {
        width: 100% !important;
        max-width: none !important;
        margin: 0 auto !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        box-sizing: border-box;
    }

    /* cancel extra outer margins */
    .section,
    .hero,
    .lead,
    .intro,
    .article-card,
    .section-box {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* footer */
    .footer-container {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }

    .main-content {
        padding: 16px;
    }

    .logo-img {
        height: 36px;
    }

    .category-button {
        padding: 12px;
        font-size: .95rem;
    }

    .article-grid {
        grid-template-columns: 1fr;
    }

    .layout,
    .container,
    .main-content,
    .content {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* iPhone safe areas */
@supports(padding:max(0px)) {
    @media (max-width:768px) {

        .layout,
        .container,
        .main-content,
        .content {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
        }
    }
}