/* ============================================
   MangaFeed - 漫画アフィリエイトサイト
   Mobile-First Design
   ============================================ */

:root {
    --bg-primary: #0f0f14;
    --bg-card: #1a1a24;
    --bg-surface: #242430;
    --text-primary: #f0f0f5;
    --text-secondary: #9090a0;
    --text-muted: #606070;
    --accent: #ff4060;
    --accent-hover: #ff2040;
    --accent-soft: rgba(255, 64, 96, 0.15);
    --border: #2a2a3a;
    --gradient-cta: linear-gradient(135deg, #ff4060, #ff6040);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

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

/* ── ヘッダー ── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 20, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo span {
    color: var(--accent);
}

.header-nav {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header-nav a {
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--text-primary);
}

.header-nav-magazine {
    color: var(--accent) !important;
    font-weight: 600;
}

/* ── ジャンルチップバー ── */
.genre-bar {
    overflow-x: auto;
    white-space: nowrap;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.genre-bar::-webkit-scrollbar {
    display: none;
}

.genre-chip {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-right: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.genre-chip:hover,
.genre-chip.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

/* ── セクションヘッダー ── */
.section-header {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.section-more {
    font-size: 0.8rem;
    color: var(--accent);
}

/* ── ランキングバッジ ── */
.rank-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-cta);
    color: white;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ── 漫画カードグリッド ── */
.manga-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 12px 24px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

@media (min-width: 640px) {
    .manga-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .manga-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 20px;
    }
}

.manga-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.manga-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.manga-card:active {
    transform: scale(0.98);
}

.manga-card-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: var(--bg-surface);
}

.manga-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.manga-card:hover .manga-card-cover img {
    transform: scale(1.05);
}

/* サンプルプレビューバッジ */
.sample-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 4px;
    backdrop-filter: blur(4px);
}

.manga-card-info {
    padding: 10px;
}

.manga-card-title {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.manga-card-author {
    font-size: 0.7rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manga-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.65rem;
    color: var(--text-muted);
}

.manga-card-rating {
    color: #ffc107;
}

/* ── ネイティブ広告カード ── */
.ad-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.ad-label {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-muted);
    font-size: 0.55rem;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 2;
}

/* ── CTA ボタン ── */
.cta-button {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 14px 24px;
    background: var(--gradient-cta);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.cta-button:hover {
    opacity: 0.9;
}

.cta-button:active {
    transform: scale(0.98);
}

/* ── フッター ── */
.footer {
    padding: 40px 16px;
    text-align: center;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.footer-links a {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.footer-copyright {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ── ローディング ── */
.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── 年齢確認モーダル ── */
.age-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.age-modal-overlay.hidden {
    display: none;
}

.age-modal {
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    padding: 32px 24px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.age-modal h2 {
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.age-modal p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.age-modal-buttons {
    display: flex;
    gap: 12px;
}

.age-modal-buttons button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.age-btn-yes {
    background: var(--gradient-cta);
    color: white;
}

.age-btn-no {
    background: var(--bg-surface);
    color: var(--text-secondary);
}

/* ── リーダーページ専用 ── */
.reader-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
}

.reader-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 20, 0.95);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.reader-back {
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.reader-title {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-pages {
    padding: 0;
}

/* 作品情報セクション */
.manga-description {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px 16px 8px;
    border-bottom: 1px solid var(--border);
}

.manga-meta-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.manga-meta-author {
    color: var(--text-primary);
    font-weight: 600;
}

.manga-meta-review {
    color: #ffb800;
}

.manga-meta-review::before {
    content: "\2605 ";
}

.manga-meta-price {
    color: var(--accent);
    font-weight: 600;
}

.manga-genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.manga-genre-tag {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
}

.manga-description-text {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-secondary);
    padding-bottom: 12px;
}

.reader-page {
    width: 100%;
    display: block;
}

.reader-page img {
    width: 100%;
    height: auto;
    display: block;
}

/* サンプル終了 CTA */
.reader-cta-section {
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(to bottom, var(--bg-primary), var(--bg-card));
}

.reader-cta-section h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}

.reader-cta-section p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* 関連漫画 */
.related-section {
    padding: 24px 12px;
}

.related-title {
    font-size: 1rem;
    font-weight: 700;
    padding: 0 4px 16px;
}

.related-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.related-scroll::-webkit-scrollbar {
    display: none;
}

.related-scroll .manga-card {
    min-width: 130px;
    max-width: 130px;
    flex-shrink: 0;
}

/* ── Sticky CTA (リーダー下部) ── */
.sticky-cta {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: rgba(15, 15, 20, 0.95);
    backdrop-filter: blur(12px);
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.sticky-cta .cta-button {
    margin: 0 auto;
}

/* ── ジャンル一覧ページ ── */
.genre-page-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.genre-page-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.genre-page-tag:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.genre-page-tag-name {
    font-weight: 500;
}

.genre-page-tag-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.genre-page-tag:hover .genre-page-tag-count {
    color: var(--accent);
    background: rgba(255, 64, 96, 0.1);
}

/* ── ユーティリティ ── */
.hidden {
    display: none !important;
}

.text-accent {
    color: var(--accent);
}

/* ── 構造化データ用（非表示） ── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
