/* CSS Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
	font-family: 'Roboto', sans-serif; 
	line-height: 1.6; 
	background-color: #ecf0f1; 
	color: #2c3e50;
	transition: background-color 0.4s ease;
}

/* iOSのプルダウン更新抑止（対応ブラウザ） */
html, body {
	overscroll-behavior-y: none;
}

:root {
	--primary-color: #2c3e50;
	--secondary-color: #34495e;
	--background-color: #ecf0f1;
	--card-bg-color: #ffffff;
	--card-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
	--card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
	--border-radius: 10px;
	--gap: 1rem;
	--transition-speed: 0.3s;
	--button-bg: transparent;
	--button-hover-bg: rgba(44, 62, 80, 0.15);
	--button-color: var(--primary-color);
	--button-active-color: #ffffff;
	--button-active-bg: #3498db;
	--header-height: 60px;
	
	/* アクセントカラー */
	--accent-color: #3498db;
	--success-color: #2ecc71;
	--warning-color: #f39c12;
	--danger-color: #e74c3c;
	--purple-color: #9b59b6;
	--teal-color: #1abc9c;
	
	/* カテゴリー別背景色 */
	--bg-sun: rgba(243, 156, 18, 0.12);
	--bg-train: rgba(52, 152, 219, 0.12);
	--bg-bag: rgba(155, 89, 182, 0.12);
	--bg-tool: rgba(255, 107, 129, 0.12);
	--bg-money: rgba(46, 204, 113, 0.12);
	--bg-duck: rgba(231, 76, 60, 0.12);
}

/* ヘッダー */
header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	background: rgba(236, 240, 241, 0.95);
	padding: 0.5rem 1rem;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: var(--gap);
	z-index: 1000;
	transition: padding var(--transition-speed), background-color 0.4s ease, box-shadow var(--transition-speed);
	height: var(--header-height);
}
header.scrolled {
	padding: 0.25rem 1rem;
	background: rgba(236, 240, 241, 0.9);
	box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
/* 横スクロールの有無を示す左右フェード */
header::before,
header::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 28px;
	pointer-events: none;
	opacity: 0;
	transition: opacity var(--transition-speed);
}
header::before {
	left: 0;
	background: linear-gradient(to right, currentColor, transparent);
}
header::after {
	right: 0;
	background: linear-gradient(to left, currentColor, transparent);
}

/* カテゴリ別のフェード色 */
body[data-active-category="☀️"] header::before { background: linear-gradient(to right, rgba(243, 156, 18, 0.25), transparent); }
body[data-active-category="☀️"] header::after { background: linear-gradient(to left, rgba(243, 156, 18, 0.25), transparent); }
body[data-active-category="🚃"] header::before { background: linear-gradient(to right, rgba(52, 152, 219, 0.25), transparent); }
body[data-active-category="🚃"] header::after { background: linear-gradient(to left, rgba(52, 152, 219, 0.25), transparent); }
body[data-active-category="🎒"] header::before { background: linear-gradient(to right, rgba(155, 89, 182, 0.25), transparent); }
body[data-active-category="🎒"] header::after { background: linear-gradient(to left, rgba(155, 89, 182, 0.25), transparent); }
body[data-active-category="🧰"] header::before { background: linear-gradient(to right, rgba(255, 107, 129, 0.25), transparent); }
body[data-active-category="🧰"] header::after { background: linear-gradient(to left, rgba(255, 107, 129, 0.25), transparent); }
body[data-active-category="💶"] header::before { background: linear-gradient(to right, rgba(46, 204, 113, 0.25), transparent); }
body[data-active-category="💶"] header::after { background: linear-gradient(to left, rgba(46, 204, 113, 0.25), transparent); }
body[data-active-category="🦆"] header::before { background: linear-gradient(to right, rgba(231, 76, 60, 0.25), transparent); }
body[data-active-category="🦆"] header::after { background: linear-gradient(to left, rgba(231, 76, 60, 0.25), transparent); }
header.fade-left::before { opacity: 1; }
header.fade-right::after { opacity: 1; }
nav {
	display: flex;
	gap: var(--gap);
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	flex-wrap: nowrap;
}
nav button {
	background: var(--button-bg);
	border: none;
	padding: 0.5rem 1rem;
	font-size: 1.3rem;
	color: var(--button-color);
	cursor: pointer;
	transition: background var(--transition-speed), color var(--transition-speed), transform 0.2s;
	border-radius: 8px 8px 0 0;
	flex: 0 0 auto;
	font-weight: 400;
	border-bottom: 3px solid transparent;
}
nav button:hover {
	background: var(--button-hover-bg);
	transform: translateY(-1px);
}
nav button.active {
	background: transparent;
	color: var(--button-color);
	font-weight: 500;
}
nav button:focus-visible {
	outline: 2px solid var(--accent-color);
	outline-offset: 2px;
}

/* カテゴリ別ボタンホバー */
nav button[data-filter="☀️"]:hover { background: rgba(243, 156, 18, 0.15); }
nav button[data-filter="🚃"]:hover { background: rgba(52, 152, 219, 0.15); }
nav button[data-filter="🎒"]:hover { background: rgba(155, 89, 182, 0.15); }
nav button[data-filter="🧰"]:hover { background: rgba(255, 107, 129, 0.15); }
nav button[data-filter="💶"]:hover { background: rgba(46, 204, 113, 0.15); }
nav button[data-filter="🦆"]:hover { background: rgba(231, 76, 60, 0.15); }

/* カテゴリ別アクティブ状態（下線） */
nav button[data-filter="☀️"].active { border-bottom-color: var(--warning-color); }
nav button[data-filter="🚃"].active { border-bottom-color: var(--accent-color); }
nav button[data-filter="🎒"].active { border-bottom-color: var(--purple-color); }
nav button[data-filter="🧰"].active { border-bottom-color: #ff6b81; }
nav button[data-filter="💶"].active { border-bottom-color: var(--success-color); }
nav button[data-filter="🦆"].active { border-bottom-color: var(--danger-color); }

/* カテゴリ別背景色（body） */
body[data-active-category="☀️"] { background-color: var(--bg-sun); }
body[data-active-category="🚃"] { background-color: var(--bg-train); }
body[data-active-category="🎒"] { background-color: var(--bg-bag); }
body[data-active-category="🧰"] { background-color: var(--bg-tool); }
body[data-active-category="💶"] { background-color: var(--bg-money); }
body[data-active-category="🦆"] { background-color: var(--bg-duck); }

/* カテゴリ別背景色（header） */
body[data-active-category="☀️"] header { background: rgba(243, 156, 18, 0.25); }
body[data-active-category="🚃"] header { background: rgba(52, 152, 219, 0.25); }
body[data-active-category="🎒"] header { background: rgba(155, 89, 182, 0.25); }
body[data-active-category="🧰"] header { background: rgba(255, 107, 129, 0.25); }
body[data-active-category="💶"] header { background: rgba(46, 204, 113, 0.25); }
body[data-active-category="🦆"] header { background: rgba(231, 76, 60, 0.25); }

/* スクロール時のheader背景色 */
body[data-active-category="☀️"] header.scrolled { background: rgba(243, 156, 18, 0.3); }
body[data-active-category="🚃"] header.scrolled { background: rgba(52, 152, 219, 0.3); }
body[data-active-category="🎒"] header.scrolled { background: rgba(155, 89, 182, 0.3); }
body[data-active-category="🧰"] header.scrolled { background: rgba(255, 107, 129, 0.3); }
body[data-active-category="💶"] header.scrolled { background: rgba(46, 204, 113, 0.3); }
body[data-active-category="🦆"] header.scrolled { background: rgba(231, 76, 60, 0.3); }

/* スクロールバーのカスタマイズ */
nav::-webkit-scrollbar {
	height: 4px;
}
nav::-webkit-scrollbar-track {
	background: transparent;
}
nav::-webkit-scrollbar-thumb {
	background: rgba(44, 62, 80, 0.2);
	border-radius: 2px;
}
nav::-webkit-scrollbar-thumb:hover {
	background: rgba(44, 62, 80, 0.3);
}

/* メインコンテンツ */
main {
	padding-top: calc(var(--header-height) + 1rem);
	max-width: 1200px;
	margin: 0 auto;
	padding-left: 1rem;
	padding-right: 1rem;
}
.container {
	display: grid;
	gap: var(--gap);
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	margin-bottom: 2rem;
}

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

.error-message {
	display: none;
	color: #e74c3c;
	text-align: center;
	margin-top: 1rem;
	font-weight: 500;
	background: #ffe5e5;
	padding: 1rem;
	border-radius: 8px;
	border-left: 4px solid var(--danger-color);
}

/* カード */
.card {
	position: relative;
	background-color: var(--card-bg-color);
	border-radius: var(--border-radius);
	box-shadow: var(--card-shadow);
	padding: 0.875rem 1rem;
	text-align: center;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
	            box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	animation: fadeInUp 0.5s ease-out backwards;
}
.card:hover {
	transform: translateY(-4px);
	box-shadow: var(--card-shadow-hover);
}
.card.single-column { 
	grid-column: span 1;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* カード出現アニメーション - 初回読み込み時のみ */
@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* リンクとテキストカードの区別 */
.card:not(a) {
	cursor: default;
}

a.card {
	cursor: pointer;
}

a.card::after {
	content: '';
	position: absolute;
	bottom: 8px;
	right: 8px;
	width: 12px;
	height: 12px;
	background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%232c3e50"><path d="M19 19H5V5h7V3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3h-7z"/></svg>');
	opacity: 0;
	transition: opacity var(--transition-speed);
}

a.card:hover::after {
	opacity: 0.3;
}

a.card:focus-visible {
	outline: 2px solid var(--accent-color);
	outline-offset: 2px;
	box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
}

/* カテゴリ別カラーリング（カードは白背景に戻す） */
.card[data-category] { 
	background-color: var(--card-bg-color);
}

h2 {
	font-size: 1.5rem;
	margin-bottom: 0.5rem;
	color: var(--secondary-color);
	font-weight: 600;
	letter-spacing: 0.02em;
}
p, span {
	font-size: 1rem;
	margin: 0.5rem 0;
	letter-spacing: 0.01em;
}

/* 天気カード専用 */
.weather-card h2 {
	color: var(--accent-color);
	font-size: 1.4rem;
}

.weather-card p {
	display: flex;
	justify-content: space-around;
	align-items: center;
	gap: var(--gap);
	margin: 0.5rem 0;
}
.weather-card p span {
	flex: 1;
	display: flex;
	align-items: center;
	font-weight: 500;
}
.weather-card p span::before {
	content: attr(data-icon);
	font-size: 1.2em;
	margin-right: 0.5rem;
}

/* レスポンシブ調整 */
@media (min-width: 768px) and (max-width: 1024px) {
	.container { 
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (min-width: 480px) and (max-width: 768px) {
	.container {
		grid-template-columns: repeat(2, 1fr);
	}
	.card.single-column {
		grid-column: span 2;
	}
}

@media (max-width: 768px) {
	h2 { font-size: 1.25rem; }
	p, span { font-size: 0.875rem; }
}

@media (max-width: 375px) {
	:root { --gap: 0.5rem; }
	.container { grid-template-columns: repeat(2, 1fr); }
	.card.single-column { grid-column: span 2; }
	h2 { font-size: 1.25rem; }
	p, span { font-size: 1rem; }
	.card { padding: 1rem; }
	nav button {
		padding: 0.4rem 0.8rem;
		font-size: 1.1rem;
	}
}

/* アクセシビリティ: reduced-motion */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
