/*
Theme Name: Manga Lovers 
Theme URI: https://example.com
Author: Your Name
Author URI: https://example.com
Description: DMM APIを使用して漫画作品のレビューを投稿・表示するWordPressテーマ
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dmm-manga-theme
Tags: blog, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* === リセット & ベーススタイル === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* One Dark Pro カラーテーマ */
    --bg-primary: #282c34;
    --bg-secondary: #21252b;
    --bg-tertiary: #2c313c;
    --bg-card: #2c313a;
    --bg-hover: #3e4451;
    
    --text-primary: #abb2bf;
    --text-secondary: #5c6370;
    --text-bright: #ffffff;
    
    --accent-blue: #61afef;
    --accent-green: #98c379;
    --accent-purple: #c678dd;
    --accent-red: #e06c75;
    --accent-yellow: #e5c07b;
    --accent-cyan: #56b6c2;
    --accent-orange: #d19a66;
    
    --star-color: #e5c07b;
    --link-color: #61afef;
    --link-hover: #528bcc;
    --border-color: #181a1f;
    --border-accent: #3e4451;
    
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-glow-blue: 0 0 20px rgba(97, 175, 239, 0.15);
    --shadow-glow-purple: 0 0 20px rgba(198, 120, 221, 0.15);
    --shadow-glow-green: 0 0 20px rgba(152, 195, 121, 0.15);
    
    --transition: all 0.3s ease;
}

body {
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
    line-height: 1.8;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    background-image: url('assets/images/heart_bg.webp');
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

/* 背景画像の上にオーバーレイを追加して読みやすさを確保 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(40, 44, 52, 0.85);
    z-index: -1;
    pointer-events: none;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--link-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* === ヘッダー === */
.site-header {
    background: linear-gradient(180deg, rgba(33, 37, 43, 0.95) 0%, rgba(44, 49, 60, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.5rem 0;
    min-height: 96px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow), 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.35s ease;
}

.site-header.header-hidden {
    transform: translateY(-100%);
}

.header-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* サイトロゴ：ヘッダー高さ固定・レスポンシブ対応 */
.site-branding {
    min-height: 72px;
    display: flex;
    align-items: center;
}

.site-branding .custom-logo-link {
    display: flex;
    align-items: center;
    line-height: 0;
    max-height: 72px;
}

.site-branding .custom-logo {
    max-height: 72px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left center;
}

.site-title {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-bright);
}

.site-title a {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: var(--transition);
}

.site-title a:hover {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ハンバーガーボタン（常時表示） */
.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border-accent);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.menu-toggle:hover {
    border-color: var(--accent-cyan);
    background-color: var(--bg-hover);
}

.hamburger-bar {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.35s ease, opacity 0.35s ease, width 0.35s ease;
    transform-origin: center;
}

.menu-toggle.active .hamburger-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .hamburger-bar:nth-child(2) {
    opacity: 0;
    width: 0;
}

.menu-toggle.active .hamburger-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.menu-toggle.active {
    border-color: var(--accent-cyan);
}

.menu-toggle.active .hamburger-bar {
    background-color: var(--accent-cyan);
}

/* 検索＋ハンバーガーのラッパー */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

/* 検索フォーム（ヘッダーバー内・常時表示） */
.header-search {
    position: relative;
}

.header-search input[type="search"] {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-accent);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    width: 200px;
    transition: var(--transition);
}

.header-search input[type="search"]:focus {
    outline: none;
    border-color: var(--accent-cyan);
    width: 240px;
    box-shadow: 0 0 15px rgba(86, 182, 194, 0.3);
}

.header-search input[type="search"]::placeholder {
    color: var(--text-secondary);
}

/* メインナビゲーション（ヘッダー外・fixed ドロップダウン）
   ヘッダー(z-index:1000)の直下レイヤー(z-index:999)でスライドイン */
.main-navigation {
    position: fixed;
    top: var(--header-height, 64px); /* JS で動的に更新 */
    left: 0;
    right: 0;
    z-index: 999; /* ヘッダー(1000)より下 → 視覚的にヘッダーが蓋をする形 */

    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.35s ease, opacity 0.2s ease;

    background: linear-gradient(180deg, rgba(28, 32, 40, 0.98) 0%, rgba(38, 43, 54, 0.98) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.main-navigation.nav-open {
    max-height: 480px;
    opacity: 1;
    pointer-events: auto;
}

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

.main-navigation ul {
    display: flex;
    flex-direction: column;
    list-style: none;
    gap: 0;
    padding: 0.25rem 0;
}

.main-navigation ul li {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.main-navigation ul li:last-child {
    border-bottom: none;
}

.main-navigation a {
    display: flex;
    align-items: center;
    color: var(--text-primary);
    padding: 0.4rem 0.5rem;
    min-height: 32px;
    transition: var(--transition);
    position: relative;
}

.main-navigation a::after { display: none; }

.main-navigation a:hover,
.main-navigation .current-menu-item a {
    background-color: var(--bg-hover);
    color: var(--accent-cyan);
    padding-left: 1rem;
}

/* === メインコンテンツエリア === */
.site-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
}

.content-area {
    min-width: 0;
}

/* === レビューカード（グリッドレイアウト） === */
.manga-reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.manga-card {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;                /* ここだけでクリッピング */
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow);
    display: block;
    /* カード全体を1枚のGPUレイヤーに昇格。
       子のスケールはこのレイヤー内で合成されるため
       overflow:hidden のクリッピングもGPU側で完結する */
    transform: translateZ(0);
    transition:
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

/* ブログ・記事カードは 4:3 横長比率 */
.manga-card--blog {
    aspect-ratio: 4 / 3;
}

/* ベース背景色 */
.manga-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--bg-secondary);
    z-index: 0;
    pointer-events: none;
}

.manga-card > * {
    position: relative;
    z-index: 1;
}

.manga-card-link {
    display: block;
    position: relative;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.manga-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-hover), var(--shadow-glow-blue);
}

.manga-card-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

.manga-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform: scale(1);
    transform-origin: center center;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* opacity の transition を明示的に "none" にして
       img[loading="lazy"] の transition: opacity と競合させない */
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0s;
}

.manga-card:hover .manga-card-image img {
    transform: scale(1.06);
}

.manga-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 0.9rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    /* 下部グラデーションオーバーレイ */
    background: linear-gradient(
        to top,
        rgba(20, 23, 30, 0.97) 0%,
        rgba(20, 23, 30, 0.82) 55%,
        transparent 100%
    );
    z-index: 2;
}

.manga-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    transition: color 0.25s ease;
}

.manga-card:hover .manga-card-title {
    color: var(--accent-cyan);
}

.manga-card-author {
    color: rgba(255,255,255,0.72);
    font-size: 0.78rem;
    margin: 0;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    transition: color 0.25s ease;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.manga-card:hover .manga-card-author {
    color: var(--accent-purple);
}

.manga-card-rating {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}

.star-rating {
    color: var(--star-color);
    font-size: 0.85rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.rating-value {
    color: rgba(255,255,255,0.85);
    font-size: 0.78rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.manga-card-meta {
    display: none; /* オーバーレイ上では非表示（スペース節約） */
}

.manga-card-price {
    color: var(--accent-green);
    font-weight: 700;
    font-size: 0.82rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    margin: 0;
}

.manga-card-tags {
    display: none; /* オーバーレイ上では非表示 */
}

/* ===== blog-card 補足スタイル ===== */
.blog-card-no-image {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    color: var(--text-secondary);
}

.blog-card-date {
    color: rgba(255,255,255,0.65);
    font-size: 0.75rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.blog-card-views {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: rgba(255,255,255,0.55);
    font-size: 0.72rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
}

.manga-tag {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    border: 1px solid var(--border-accent);
    transition: var(--transition);
}

.manga-tag:hover {
    background-color: var(--accent-purple);
    color: var(--text-bright);
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(198, 120, 221, 0.3);
}

/* === サイドバー === */
.sidebar {
    background-color: rgba(33, 37, 43, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.widget {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.widget:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.widget-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-bright);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-blue);
    position: relative;
}

.widget-title::before {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
}

/* ウィジェット内のリストスタイル */
.widget ul {
    list-style: none;
    padding-left: 0;
}

.widget ul li {
    list-style: none;
}

.widget select,
.widget input {
    list-style: none;
}

/* サイドバー検索フォーム */
.sidebar .widget_search .search-form {
    position: relative;
}

.sidebar .widget_search .search-field {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-accent);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 20px;
    transition: var(--transition);
}

.sidebar .widget_search .search-field:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(86, 182, 194, 0.3);
}

.sidebar .widget_search .search-field::placeholder {
    color: var(--text-secondary);
}

/* dynamic_sidebarから来るデフォルト検索ウィジェットを非表示 */
.sidebar .widget_search:not(:first-child) {
    display: none;
}

/* 最近のコメントウィジェットを非表示 */
.widget_recent_comments {
    display: none !important;
}

/* === フィルターバー === */
.filter-bar {
    background: linear-gradient(135deg, rgba(33, 37, 43, 0.95) 0%, rgba(44, 49, 60, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-accent);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-label {
    display: block;
    font-weight: bold;
    color: var(--accent-cyan);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select,
.filter-input {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-accent);
    color: var(--text-primary);
    padding: 0.5rem;
    border-radius: 4px;
    transition: var(--transition);
}

.filter-select:hover,
.filter-input:hover {
    border-color: var(--accent-blue);
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(86, 182, 194, 0.3);
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-cyan) 100%);
    color: var(--text-bright);
    border-color: var(--accent-blue);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(97, 175, 239, 0.4);
}

.btn-secondary {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.btn-secondary:hover {
    background-color: var(--accent-purple);
    color: var(--text-bright);
    border-color: var(--accent-purple);
    box-shadow: 0 4px 12px rgba(198, 120, 221, 0.4);
}

/* === フッター === */
.site-footer {
    background: linear-gradient(180deg, rgba(33, 37, 43, 0.95) 0%, rgba(40, 44, 52, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2rem 0 1rem;
    margin-top: 4rem;
}

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

.footer-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-widgets .widget {
    background-color: rgba(44, 49, 60, 0.5);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-accent);
    transition: var(--transition);
}

.footer-widgets .widget:hover {
    border-color: var(--accent-purple);
    box-shadow: 0 0 15px rgba(198, 120, 221, 0.2);
}

.footer-info {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-info a {
    color: var(--accent-cyan);
}

.footer-info a:hover {
    color: var(--accent-purple);
}

/* ============================================================
   レスポンシブ  —  ブレークポイント体系
   1024px : タブレット横・小型デスクトップ
    768px : タブレット縦
    480px : スマホ横・大型スマホ
   ============================================================ */

/* --- 1024px 以下 ----------------------------------------- */
@media (max-width: 1023px) {
    .site-content {
        grid-template-columns: 1fr;
        padding: 0 20px;
    }
    .sidebar { position: static; }
    .manga-reviews-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* ナビ内検索（PC では非表示、モバイルで表示） */
.nav-search { display: none; }

/* --- 768px 以下 ------------------------------------------ */
@media (max-width: 767px) {
    /* ベースフォントを 14px に — 全 rem 値がここを基準にスケール */
    html { font-size: 14px; }

    .main-navigation__inner { padding: 0 16px; }

    /* ヘッダー：レスポンシブで高さを縮小 */
    .site-header { min-height: 64px; padding: 0.4rem 0; }
    .header-container { padding: 0 16px; }
    .site-branding { min-height: 44px; }
    .site-branding .custom-logo-link { max-height: 44px; }
    .site-branding .custom-logo     { max-height: 44px; }
    .site-title        { font-size: 1.35rem; }  /* 14×1.35 ≈ 19px */
    .site-description  { font-size: 0.8rem; }   /* 14×0.8  ≈ 11px */
    .menu-toggle       { width: 36px; height: 36px; }

    /* ヘッダーバーの検索を非表示 → ナビ内へ */
    .header-actions .header-search { display: none; }

    .nav-search {
        display: block;
        padding: 0.75rem 1.25rem 1rem;
        border-top: 1px solid var(--border-color);
    }
    .nav-search input[type="search"] {
        width: 100%;
        background-color: var(--bg-primary);
        border: 1px solid var(--border-accent);
        color: var(--text-primary);
        padding: 0.65rem 1rem;
        border-radius: 20px;
        font-size: 16px; /* iOS ズーム防止（ルート 14px でも zoom しない） */
        transition: var(--transition);
    }
    .nav-search input[type="search"]:focus {
        outline: none;
        border-color: var(--accent-cyan);
        box-shadow: 0 0 12px rgba(86, 182, 194, 0.3);
    }
    .nav-search input[type="search"]::placeholder { color: var(--text-secondary); }

    /* コンテンツ */
    .site-content { margin: 0.75rem auto; }
    .manga-reviews-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .footer-widgets { grid-template-columns: 1fr; }
    .footer-info    { font-size: 0.85rem; }

    /* フッター */
    .site-footer { padding: 1.5rem 0 0.75rem; margin-top: 2rem; }

    /* カード内極小テキスト：14px 基準で読めるサイズに引き上げ */
    .manga-card-author  { font-size: 0.82rem; }   /* 元 0.78 → 11.5px */
    .rating-value       { font-size: 0.82rem; }   /* 元 0.78 → 11.5px */
    .blog-card-date     { font-size: 0.82rem; }   /* 元 0.75 → 11.5px */
    .blog-card-views    { font-size: 0.8rem; }    /* 元 0.72 → 11.2px */
    .manga-tag          { font-size: 0.82rem; }   /* 元 0.75 → 11.5px */
}

/* --- 480px 以下 ------------------------------------------ */
@media (max-width: 479px) {
    /* 極小画面でも 14px をキープ（すでに 768px で設定済み） */
    .site-header { min-height: 56px; padding: 0.35rem 0; }
    .header-container { padding: 0 12px; }
    .site-branding { min-height: 40px; }
    .site-branding .custom-logo-link { max-height: 40px; }
    .site-branding .custom-logo     { max-height: 40px; }
    .site-title { font-size: 1.15rem; }  /* 14×1.15 ≈ 16px */
    .manga-reviews-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
}

/* === ユーティリティクラス === */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
