/* css/style.css */

/* 基本スタイル */
:root {
    --primary-color: #F067A6; /* R-18版のテーマカラー */
    --secondary-color: #6c757d;
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --light-text: #ffffff;
    --border-color: #dee2e6;
    --modal-bg: rgba(0, 0, 0, 0.7);
    --danger-color: #dc3545;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.container.hidden-by-age-gate {
    visibility: hidden;
}

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

a:hover {
    text-decoration: underline;
}

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

button, .sort-button {
    cursor: pointer;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--primary-color);
    background-color: var(--primary-color);
    color: var(--light-text);
    border-radius: 4px;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover, .sort-button:hover {
    background-color: #d64a8d;
    border-color: #d64a8d;
}

input[type="text"], input[type="number"] {
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

/* ヘッダー */
.site-header {
    background-color: var(--light-text);
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; 
    gap: 1rem; 
}

.header-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap; 
}

.site-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.site-header h1 a {
    color: var(--primary-color); 
    text-decoration: none;
}
.site-header h1 a:hover {
    text-decoration: underline;
}


.site-header nav a {
    margin-left: 1rem;
}

.version-switch {
    font-size: 0.8em;
    font-weight: bold;
    padding: 0.3em 0.8em;
    border: 1px solid var(--border-color);
    border-radius: 15px; 
    color: var(--secondary-color);
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.version-switch:hover {
    background-color: var(--light-bg);
    border-color: var(--secondary-color);
    text-decoration: none;
}

/* 検索とソート */
.search-section, .sort-section {
    margin-bottom: 2rem;
    background: var(--light-text);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.search-section form {
    display: flex;
    gap: 0.5rem;
}
.search-section .tagify {
    flex-grow: 1;
}
.search-section input[type="text"] {
    flex-grow: 1;
}
.sort-section {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center; 
}
.sort-button.active {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    font-weight: bold;
}

/* ギャラリー */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    align-items: start;
}

.tweet-card {
    background-color: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
    pointer-events: auto;
}
#preview-area .tweet-card {
    cursor: default;
    pointer-events: none;
}
#preview-area .tweet-card a {
    pointer-events: auto;
}


.tweet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.tweet-author-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-grow: 1;
    min-width: 0;
}
.tweet-author-container:hover .tweet-author-name:hover { text-decoration: none; }
.tweet-author-name-link:hover{ text-decoration: underline; text-decoration-color: rgb(15, 20, 25); }
.tweet-author-screen-name-link:hover{ text-decoration: none; }

.tweet-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #e1e8ed;
    flex-shrink: 0;
    transition-duration: 0.2s;
    min-width: 0;
}
.tweet-avatar:hover{ filter: brightness(0.8); }

.tweet-author-info {
    line-height: 1.3;
    min-width: 0;
    flex-grow: 1;
    text-decoration: none;
}
.tweet-author-info:hover{ text-decoration: none; }

.tweet-author-name, .tweet-author-screen-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tweet-author-name { font-weight: bold; color: #14171a; }
.tweet-author-screen-name { color: #657786; }
.tweet-author-screen-name:hover { text-decoration: none; }

.tweet-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.tweet-body {
    font-size: 0.95rem;
    word-wrap: break-word;
}
.tweet-body p { margin: 0; }
.tweet-body a { color: #1b95e0; }
.tweet-body a:hover { text-decoration: underline; }

.tweet-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #657786;
    gap: 1rem;
}
.tweet-stats { display: flex; gap: 0.5rem; }
.tweet-meta { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }

.tweet-view-on-x { color: #657786; text-decoration: none; white-space: nowrap; }
.tweet-view-on-x:hover { text-decoration: underline; }
.tweet-timestamp { color: #657786; white-space: nowrap; }

.period-favorite-count, .total-favorite-count { font-weight: bold; color: #f5b82b; }

.favorite-icon, .tweet-x-icon {
    flex-shrink: 0;
    cursor: pointer;
    width: 32px;
    height: 32px;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}
.favorite-icon svg { width: 100%; height: 100%; fill: #cccccc; transition: all 0.2s ease; }
.favorite-icon:hover { background-color: rgba(255, 193, 7, 0.1); }
.favorite-icon:hover svg { fill: #ffdb58; }
.favorite-icon.active svg { fill: #ffc107; transform: scale(1.1); }

.tweet-x-icon { padding: 7px; }
.tweet-x-icon svg { width: 100%; height: 100%; fill: rgb(15, 20, 25); }

.no-results { grid-column: 1 / -1; text-align: center; padding: 3rem; font-size: 1.2rem; color: var(--secondary-color); }

.tweet-media-grid {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e1e8ed;
    display: grid;
    gap: 2px;
}
.grid-image-wrapper { position: relative; background-color: #f7f7f7; }
.grid-image-wrapper img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.image-count-1 { aspect-ratio: auto; }
.image-count-1 .grid-image-wrapper { position: static; }
.image-count-1 .grid-image-wrapper img { position: static; object-fit: contain; width: 100%; height: auto; }
.image-count-2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 8; }
.image-count-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 9; }
.image-count-3 .grid-image-wrapper:first-child { grid-row: span 2; }
.image-count-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 16 / 9; }

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background-color: var(--light-text);
    padding: 2rem;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
}
.modal-actions { margin-top: 1.5rem; display: flex; justify-content: center; gap: 1rem; }
.modal-actions button { min-width: 100px; }
#age-gate-no { background-color: var(--secondary-color); border-color: var(--secondary-color); }

/* 登録ページ */
.register-step { background: var(--light-text); padding: 2rem; border-radius: 8px; margin-bottom: 2rem; }
.form-group { margin-bottom: 1.5rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: bold; }
#preview-area {
    margin-bottom: 1.5rem;
    border: 1px dashed var(--border-color);
    padding: 1rem;
    border-radius: 8px;
}
#preview-area .tweet-card { max-width: 500px; margin: 0 auto; }
.notice { margin: 1.5rem 0; padding: 1rem; background-color: #fff3cd; border: 1px solid #ffeeba; border-radius: 4px; color: #856404; }
.error-message { color: var(--danger-color); font-size: 0.9em; min-height: 1.2em; }
.status-message { margin-top: 1rem; }

#parse-url-form { display: flex; gap: 0.5rem; }
#parse-url-form input[type="text"] { flex-grow: 1; }

/* ローダー */
.loader { border: 4px solid #f3f3f3; border-radius: 50%; border-top: 4px solid var(--primary-color); width: 30px; height: 30px; animation: spin 1s linear infinite; margin: 0 auto; }
.loader-container { padding: 2rem; }
.end-message { text-align: center; color: var(--secondary-color); padding: 2rem; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.status-modal-content { min-width: 300px; padding: 2.5rem; }
.status-modal-content p { margin-top: 0; margin-bottom: 1.5rem; font-size: 1.1rem; font-weight: bold; }
.status-modal-content.success { border-top: 5px solid #28a745; }
.status-modal-content.error { border-top: 5px solid #dc3545; }
#status-modal-close { min-width: 120px; }

.history-stats { background-color: #fff; padding: 1.5rem; margin-bottom: 2rem; border-radius: 8px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.stats-number { font-size: 2.5rem; font-weight: bold; color: var(--primary-color); line-height: 1.2; }
.stats-label { font-size: 1rem; color: var(--secondary-color); margin-top: 0.5rem; }
.stats-grid { display: flex; justify-content: center; gap: 3rem; }
.disclaimer { font-size: 0.85rem; color: #6c757d; margin-top: 1.5rem; border-top: 1px solid var(--border-color); padding-top: 1rem; }
.disclaimer p { margin: 0.5em 0 0; }
.favorite-count-note { text-align: right; font-size: 0.8em; color: #6c757d; margin-bottom: 1rem; }

.recommend-button-wrapper {
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent; 
    border-radius: 4px;
    transition: border-color 0.2s;
}
.recommend-button-wrapper .sort-button.active { border-color: var(--secondary-color); }
.recommend-button-wrapper .sort-button.active + .info-icon { border-color: var(--secondary-color); }
.recommend-button-wrapper:has(.sort-button.active) { border-color: var(--secondary-color); }
.recommend-button-wrapper .sort-button { border: 1px solid var(--border-color); border-right: none; border-top-left-radius: 4px; border-bottom-left-radius: 4px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.info-icon { display: inline-flex; align-items: center; justify-content: center; padding: 0 0.5rem; cursor: pointer; color: var(--secondary-color); align-self: stretch; border: 1px solid var(--border-color); border-top-right-radius: 4px; border-bottom-right-radius: 4px; background-color: transparent; transition: all 0.2s; }
.info-icon:hover { color: var(--primary-color); background-color: #e9ecef; }
.info-modal-content { max-width: 600px; text-align: left; }
.info-modal-title { margin-top: 0; border-bottom: 1px solid var(--border-color); padding-bottom: 0.75rem; margin-bottom: 1rem; font-size: 1.5rem; }
.info-modal-body h4 { margin-top: 1.5rem; margin-bottom: 0.5rem; color: var(--primary-color); }
.info-modal-body p { margin-top: 0; line-height: 1.7; }

@media (max-width: 768px) {
    .site-header { flex-direction: column; align-items: center; gap: 1rem; }
    .header-main { justify-content: center; order: 1; }
    .site-header nav { order: 2; width: 100%; display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; }
    .site-header nav a { margin-left: 0.5rem; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
    .search-section form, #parse-url-form { flex-direction: column; align-items: stretch; }
    .info-modal-content { max-width: 95vw; padding: 1.5rem; }
    .info-modal-title { font-size: 1.25rem; }
    .info-modal-body { font-size: 0.9rem; }
    .info-modal-body h4 { margin-top: 1rem; }
}

.tweet-avatar-link{
    display: flex;
}

.sub-search-section {
    margin: -1rem 0 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sub-search-button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0.7rem 1.4rem;
    background-color: #ffd700;
    color: #14171a;
    text-decoration: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    border: 1px solid #ffd700;
    transition: all 0.2s ease-in-out;
}

.sub-search-button:hover {
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.1);
    transform: translateY(-2px);
}

.sub-search-button-general {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 0.7rem 1.4rem;
    background-color: rgba(240, 103, 166, 0.15); /* テーマカラーを薄く */
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    border: none; /* 枠線はなし */
    transition: all 0.2s ease-in-out;
}

.sub-search-button-general:hover {
    text-decoration: none;
    background-color: rgba(240, 103, 166, 0.3); /* ホバー時にもう少し濃く */
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 変更開始: ブラックリストページ用のスタイル */
.blacklist-manager {
    max-width: 700px;
    margin: 2rem auto;
    background: var(--light-text);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.blacklist-manager h1 {
    margin-top: 0;
    text-align: center;
}

.blacklist-description {
    text-align: center;
    color: var(--secondary-color);
    font-size: 0.9em;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

#blacklist-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#blacklist-input {
    flex-grow: 1;
}

.blacklist-list-section {
    margin-top: 2rem;
}

#blacklist-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.blacklist-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.blacklist-item:first-child {
    border-top: 1px solid var(--border-color);
}

.blacklist-item span {
    font-family: 'Consolas', 'Monaco', monospace;
}

.blacklist-remove-btn {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
    font-size: 0.8em;
    padding: 0.3em 0.8em;
}

.blacklist-remove-btn:hover {
    background-color: #c82333;
    border-color: #bd2130;
}
/* 変更終了 */

/* 広告バナー用のスタイル */
.ad-banner-section {
    margin-bottom: 2rem;
    text-align: center;
}

.ad-banner-section a {
    display: inline-block;
    line-height: 0;
}

.ad-banner-section img {
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}