/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header Styles */
.header {
    text-align: center;
    padding: 3rem 0 2rem;
    color: white;
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.title i {
    margin-right: 1rem;
    color: #ffd700;
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    opacity: 0.9;
}

/* Main Content */
.main {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin: 2rem 0;
    overflow: hidden;
}

/* Search Section */
.search-section {
    padding: 3rem 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #e9ecef;
}

.search-container {
    max-width: 600px;
    margin: 0 auto;
}

.search-box {
    display: flex;
    background: white;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.search-box:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

.search-icon {
    padding: 1rem 1.5rem;
    color: #6c757d;
    font-size: 1.2rem;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 1rem 0;
    font-size: 1.1rem;
    color: #333;
}

.search-input::placeholder {
    color: #6c757d;
}

.search-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-button:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateX(-2px);
}

.search-button:active {
    transform: translateX(0);
}

/* Search History Styles */
.search-history {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

.history-header h3 {
    color: #333;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-header h3 i {
    color: #667eea;
}

.clear-history-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.clear-history-btn:hover {
    background: #c82333;
    transform: scale(1.05);
}

.history-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.history-button {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #333;
    border: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.history-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.history-button:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.history-button:hover::before {
    left: 100%;
}

.history-button:active {
    transform: translateY(0);
}

.history-button i {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Loading Styles */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* News Section */
.news-section {
    padding: 2rem;
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.news-header h2 {
    color: #333;
    font-size: 1.8rem;
    font-weight: 600;
}

.news-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.news-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.news-card.serendipity {
    background: linear-gradient(135deg, #eaeef1 0%, #dce1e6 100%);
    color: #333;
    border: 1px solid #dee2e6;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.news-card.serendipity:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.news-card a {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.news-card a * {
    color: inherit;
}

.news-content {
    padding: 1.5rem;
}

.news-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333 !important;
    margin-bottom: 1rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4rem;
}

.news-description {
    color: #6c757d !important;
    font-size: 0.95rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 4.5rem;
}

.news-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.85rem;
    color: #6c757d;
}

.news-source {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.85rem;
}

.news-date {
    font-weight: 500;
    color: #6c757d !important;
    font-size: 0.85rem;
}

/* セレンディピティカード専用スタイル */
.news-card.serendipity .news-title {
    color: #333 !important;
    font-weight: 600;
}

.news-card.serendipity .news-description {
    color: #6c757d !important;
    font-weight: 400;
}

.news-card.serendipity .news-source {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    font-weight: 500;
}

.news-card.serendipity .news-date {
    color: #6c757d !important;
    font-weight: 500;
}

.news-card.serendipity .news-meta {
    border-top: 1px solid #e9ecef;
}

/* セレンディピティバッジ */
.news-card.serendipity::before {
    content: "💡";
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: 0.8rem;
    z-index: 10;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* Error Section */
.error-section {
    text-align: center;
    padding: 4rem 2rem;
}

.error-message {
    max-width: 500px;
    margin: 0 auto;
}

.error-message i {
    font-size: 3rem;
    color: #dc3545;
    margin-bottom: 1rem;
}

.error-message h3 {
    color: #333;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.error-message p {
    color: #6c757d;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.retry-button {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.retry-button:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: translateY(-2px);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: white;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .search-section {
        padding: 2rem 1rem;
    }
    
    .search-box {
        flex-direction: column;
        border-radius: 15px;
    }
    
    .search-input {
        padding: 1rem 1.5rem;
    }
    
    .search-button {
        border-radius: 0 0 15px 15px;
    }
    
    .news-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .news-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .news-section {
        padding: 1.5rem 1rem;
    }
    
    .search-history {
        margin-top: 1.5rem;
        padding: 1rem;
    }
    
    .history-buttons {
        gap: 0.5rem;
    }
    
    .history-button {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* スマホ時のhover効果を無効化 */
    .search-button:hover {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        transform: none;
    }
    
    .news-card:hover {
        transform: none;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    }
    
    .news-card.serendipity:hover {
        transform: none;
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    }
    
    .retry-button:hover {
        background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
        transform: none;
    }
    
    .clear-history-btn:hover {
        background: #dc3545;
        transform: none;
    }
    
    .history-button:hover {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        color: #333;
        border-color: #dee2e6;
        transform: none;
        box-shadow: none;
    }
    
    .history-button:hover::before {
        left: -100%;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .news-content {
        padding: 1rem;
    }
    
    .news-title {
        font-size: 1.1rem;
    }
}

/* タッチデバイスでのhover効果を完全に無効化 */
@media (hover: none) and (pointer: coarse) {
    .search-button:hover {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        transform: none;
    }
    
    .news-card:hover {
        transform: none;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    }
    
    .news-card.serendipity:hover {
        transform: none;
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    }
    
    .retry-button:hover {
        background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
        transform: none;
    }
    
    .clear-history-btn:hover {
        background: #dc3545;
        transform: none;
    }
    
    .history-button:hover {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        color: #333;
        border-color: #dee2e6;
        transform: none;
        box-shadow: none;
    }
    
    .history-button:hover::before {
        left: -100%;
    }
}
