/* ========================================
   Design Collection — 共通ベーススタイル
   ======================================== */

/* --- Reset --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- Base --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Container --- */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* --- Header --- */
.header {
    display: flex;
    align-items: center;
    gap: 16px;
    /* Sticky Header */
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    margin: -24px -16px 28px -16px;
    /* Container padding adjustment */
    padding: 16px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header .back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #667eea;
    padding: 6px 14px;
    border: 1px solid #667eea;
    border-radius: 20px;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.header .back:hover {
    background: #667eea;
    color: #fff;
}

.header h1 {
    font-size: 18px;
    /* Slightly smaller for header */
    font-weight: 700;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Pagination (Header) --- */
.page-nav {
    display: flex;
    gap: 12px;
    margin-left: 8px;
    margin-right: auto;
    align-items: center;
    flex-shrink: 0;
}

.page-nav-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #999;
    background: transparent;
    border: none;
    transition: color 0.2s, transform 0.2s;
    text-decoration: none;
}

.page-nav-btn:hover {
    color: #5a6fd6;
}

.page-nav-btn.prev:hover {
    transform: translateX(-3px);
}

.page-nav-btn.next:hover {
    transform: translateX(3px);
}

/* --- Pagination Tooltip --- */
.page-nav-btn::before,
.page-nav-btn::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 100;
}

.page-nav-btn::before {
    content: attr(data-tooltip);
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 11px;
    font-weight: normal;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.2;
}

.page-nav-btn::after {
    content: '';
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent #333 transparent;
}

.page-nav-btn:hover::before,
.page-nav-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* --- Social Share Buttons (Header) --- */
.share-buttons.header-share {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    border-radius: 4px;
    transition: opacity 0.2s, transform 0.2s;
    border: none;
    cursor: pointer;
    text-decoration: none;
}


/* --- Card Section --- */
.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    padding: 28px 24px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 16px;
    font-weight: 700;
    color: #555;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
    display: inline-block;
}

/* --- Demo Area --- */

/* --- Description (補足) --- */
.description {
    font-size: 13px;
    line-height: 1.7;
    color: #999;
    margin: 0 0 24px 0;
}

/* --- Code Block --- */
.code-block {
    position: relative;
    margin-bottom: 16px;
}

.code-block:last-child {
    margin-bottom: 0;
}

.code-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    height: 26px;
    line-height: 26px;
    padding: 0 10px;
    border-radius: 4px 4px 0 0;
    letter-spacing: 0.5px;
    vertical-align: bottom;
}

/* Code Label Colors */
.code-label.html {
    background: #e44d26;
}

.code-label.css {
    background: #264de4;
}

.code-label.js {
    background: #f0db4f;
    color: #333;
}

/* Pre Block */
.code-block pre {
    margin: 0;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
}

.code-block pre code {
    display: block;
    padding: 16px 20px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.55;
    background: #1e1e2e;
    color: #cdd6f4;
    tab-size: 2;
    white-space: pre;
}

/* コピー ボタン */
.copy-btn {
    display: inline-block;
    border-radius: 4px 4px 0 0;
    position: absolute;
    top: 0;
    right: 0;
    height: 26px;
    line-height: 24px;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;

    background: #555;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.copy-btn:hover {
    background: #777;
    /* Lighter on hover */
    box-shadow: none;
    /* No shadow needed for flat tab style */
}

.copy-btn.copied {
    background: #a6e3a1;
    color: #1e1e2e;
    border: none;
    box-shadow: none;
}

/* --- Collection Grid (6種サムネイル 3×2) --- */
.collection-section {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid #ddd;
}

.collection-section h2 {
    font-size: 16px;
    font-weight: 700;
    color: #555;
    margin-bottom: 20px;
    text-align: center;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.collection-grid .grid-item {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.collection-grid .grid-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.collection-grid .grid-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.collection-grid .grid-item .grid-info {
    padding: 12px 14px;
    text-align: center;
}

.collection-grid .grid-item .grid-info .grid-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.collection-grid .grid-item .grid-info .grid-btn {
    display: inline-block;
    font-size: 12px;
    padding: 5px 16px;
    background: #667eea;
    color: #fff;
    border-radius: 16px;
    transition: background 0.2s;
}

.collection-grid .grid-item .grid-info .grid-btn:hover {
    background: #5a6fd6;
}

/* --- Site Footer --- */
.site-footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: 40px;
    font-size: 13px;
    color: #999;
}

.site-footer a {
    color: #667eea;
    transition: color 0.2s;
}

.site-footer a:hover {
    color: #5a6fd6;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container {
        padding: 16px 12px 36px;
    }

    .header h1 {
        font-size: 17px;
    }

    .card {
        padding: 20px 16px;
    }

    .code-block pre code {
        font-size: 12px;
        padding: 12px 14px;
    }


    .collection-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* --- Social Share Buttons (Common) --- */
.share-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    color: #fff;
}

.share-btn.x {
    background: #000;
}

.share-btn.fb {
    background: #1877f2;
}

.share-btn.line {
    background: #06c755;
}

.share-btn.copy {
    background: #f0f2f5;
    color: #555;
    border: 1px solid #ddd;
}

.share-btn.copy:hover {
    background: #e4e6e9;
    color: #333;
}

.share-btn.copy.copied {
    background: #a6e3a1;
    color: #1e1e2e;
    border-color: #a6e3a1;
}