/*
 * 記事ページ（ resources/views/articles.html ）の見た目。
 *
 * 記事ページは SPA の外にあり、 uix のテーマが CSS 変数を流し込まない。
 * そのため、 uix の既定のライトテーマ（ node_modules/uix/src/components/
 * theme/default.ts ）と、ランディングページ（ pages/front/home/landing.ts ）
 * の配色と同じ値を、同じ名前の変数としてここで定義する。テーマや
 * ランディングの色を変えたら、ここもそろえること。
 *
 * 本文（ .article-body ）は Skein が出す素の HTML （ h2 ・ p ・ ul ・ pre ・
 * table ・ blockquote ・ img ・ MathML ）で、 class はほぼ付かない。
 */

:root {
	--uix-primary: #3454d1;
	--uix-background-default: #f5f6fa;
	--uix-background-paper: #ffffff;
	--uix-text-primary: #1a1a2e;
	--uix-text-secondary: #4a4e69;
	--uix-divider: #dfe1ea;
	--uix-font-family:
		-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;
	--uix-font-family-mono:
		"Fira Code", "SF Mono", "Monaco", "Inconsolata", "Roboto Mono",
		Consolas, Menlo, monospace;
	/* ロゴの紫 → 青のグラデーションと、暗い帯の地の色（ landing.ts ） */
	--articles-brand-gradient: linear-gradient(
		120deg,
		#9b5de5 0%,
		#6366f1 45%,
		#3454d1 100%
	);
	--articles-dark-bg: #190b42;
	/* 全体の幅。本文の列はサイドバー（ 280px ）を除いた残り（約 800px ） */
	--articles-width: 1160px;
	--articles-sidebar-width: 280px;
	--articles-header-height: 60px;
}

body.articles {
	/* フッターを画面下部に寄せる（内容が短くてもビューポート下端へ）。 */
	display: flex;
	flex-direction: column;
	min-height: 100vh;
	min-height: 100dvh;
	font-family: var(--uix-font-family);
	line-height: 1.8;
	color: var(--uix-text-primary);
	background: var(--uix-background-default);
	/* reset.css のズーム抑止は SPA 向け。記事は拡大して読めるようにする */
	touch-action: auto;
}

.articles-main a,
.articles-footer a {
	color: var(--uix-primary);
}

.articles-container {
	max-width: var(--articles-width);
	margin: 0 auto;
	padding: 0 20px;
}

/* ヘッダー */
.articles-header {
	position: sticky;
	top: 0;
	z-index: 1;
	background: var(--uix-background-paper);
	border-bottom: 1px solid var(--uix-divider);
}

.articles-header-inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	height: var(--articles-header-height);
}

.articles-logo img {
	height: 36px;
	width: auto;
}

.articles-nav {
	display: flex;
	align-items: center;
	gap: 18px;
	font-size: 0.9rem;
	white-space: nowrap;
}

.articles-nav .articles-button {
	margin-top: 0;
	padding: 6px 16px;
}

/*
 * 本文とサイドバーの枠（伸びしろを持たせ、下の CTA ・フッターを下端へ
 * 押し出す）。広い画面では 2 列、狭い画面ではサイドバーを本文の下に置く。
 */
.articles-layout {
	flex: 1 0 auto;
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 32px;
	width: 100%;
	padding-top: 32px;
	padding-bottom: 48px;
}

@media (min-width: 1000px) {
	.articles-layout {
		grid-template-columns: minmax(0, 1fr) var(--articles-sidebar-width);
		gap: 40px;
	}

	/* サイドバーは画面に追従させ、長ければサイドバーの中だけ送る */
	.articles-sidebar {
		position: sticky;
		top: calc(var(--articles-header-height) + 24px);
		align-self: start;
		max-height: calc(100vh - var(--articles-header-height) - 48px);
		overflow-y: auto;
	}

	.articles-narrow-only {
		display: none;
	}
}

@media (max-width: 999px) {
	.articles-wide-only {
		display: none;
	}
}

/* 目次の飛び先が固定ヘッダーの下に隠れないようにする */
.article-body :is(h1, h2, h3) {
	scroll-margin-top: calc(var(--articles-header-height) + 16px);
}

.articles-crumb {
	margin: 0 0 4px;
	font-size: 0.85rem;
	color: var(--uix-text-secondary);
}

.articles-crumb span {
	margin: 0 6px;
}

.articles-heading {
	font-size: clamp(1.4rem, 2.8vw, 1.8rem);
	line-height: 1.5;
	margin: 0 0 8px;
}

.articles-lead,
.articles-excerpt,
.article-meta {
	color: var(--uix-text-secondary);
}

/* 一覧 */
.articles-list {
	margin: 24px 0;
}

.articles-item a {
	display: block;
	padding: 18px 22px;
	margin-bottom: 14px;
	background: var(--uix-background-paper);
	border: 1px solid var(--uix-divider);
	border-radius: 14px;
	color: inherit;
	transition: border-color 0.18s ease;
}

.articles-item a:hover {
	border-color: var(--uix-primary);
}

.articles-item h2 {
	font-size: 1.1rem;
	line-height: 1.55;
	margin: 0 0 4px;
	color: var(--uix-text-primary);
}

.articles-excerpt {
	margin: 0 0 4px;
	font-size: 0.9rem;
}

.articles-item-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 10px;
	margin: 0;
	font-size: 0.8rem;
	color: var(--uix-text-secondary);
}

/* 一覧の分類は飾り（カード全体が 1 つのリンクなので、ここはリンクにしない） */
.articles-item-meta span {
	padding: 0 10px;
	border-radius: 999px;
	background: var(--uix-background-default);
	border: 1px solid var(--uix-divider);
}

.articles-empty {
	margin: 24px 0;
	color: var(--uix-text-secondary);
}

.articles-pager {
	display: flex;
	justify-content: space-between;
	margin: 24px 0;
}

.articles-back {
	margin: 32px 0 0;
}

/* 記事 */
.article {
	background: var(--uix-background-paper);
	border: 1px solid var(--uix-divider);
	border-radius: 16px;
	padding: 32px 28px;
}

.article-title {
	font-size: clamp(1.4rem, 3vw, 1.85rem);
	line-height: 1.45;
	margin: 0 0 8px;
}

.article-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	font-size: 0.85rem;
}

.article-terms {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 12px 0 0;
}

.article-terms a {
	display: inline-block;
	padding: 2px 12px;
	border-radius: 999px;
	border: 1px solid var(--uix-divider);
	background: var(--uix-background-default);
	font-size: 0.8rem;
}

.article-body {
	margin-top: 28px;
	font-size: 1.0625rem;
	overflow-wrap: anywhere;
}

.article-body p,
.article-body ul,
.article-body ol {
	margin: 0 0 1em;
}

.article-body ul {
	padding-left: 1.5em;
	list-style: disc;
}

.article-body ol {
	padding-left: 1.5em;
	list-style: decimal;
}

.article-body h2 {
	font-size: 1.3rem;
	margin: 2em 0 0.6em;
	padding-bottom: 0.3em;
	border-bottom: 2px solid var(--uix-divider);
}

.article-body h3 {
	font-size: 1.12rem;
	margin: 1.6em 0 0.5em;
}

.article-body img {
	border-radius: 8px;
}

.article-body pre {
	overflow-x: auto;
	margin: 0 0 1em;
	padding: 12px 16px;
	background: #0f1024;
	color: #f0f0f6;
	border-radius: 10px;
	font-size: 0.85rem;
	line-height: 1.6;
}

.article-body code {
	font-family: var(--uix-font-family-mono);
}

.article-body :not(pre) > code {
	padding: 0.1em 0.4em;
	background: var(--uix-background-default);
	border-radius: 4px;
}

.article-body blockquote {
	margin: 1.2em 0;
	padding: 0.2em 1em;
	border-left: 4px solid var(--uix-primary);
	color: var(--uix-text-secondary);
}

.article-body table {
	display: block;
	overflow-x: auto;
	border-collapse: collapse;
	margin: 1.2em 0;
}

.article-body th,
.article-body td {
	padding: 6px 12px;
	border: 1px solid var(--uix-divider);
}

.article-body math[display="block"] {
	overflow-x: auto;
	margin: 1em 0;
}

.article-raw {
	white-space: pre-wrap;
	font-family: inherit;
}

/* 目次（狭い画面では本文の上に折りたたみで、広い画面ではサイドバーに出す） */
details.article-toc {
	margin-top: 24px;
	padding: 12px 18px;
	background: var(--uix-background-default);
	border: 1px solid var(--uix-divider);
	border-radius: 12px;
}

details.article-toc summary {
	cursor: pointer;
	font-weight: 600;
}

.article-toc-list {
	margin: 8px 0 0;
	font-size: 0.88rem;
	line-height: 1.6;
}

.article-toc-list li {
	margin: 4px 0;
}

.article-toc-list a {
	color: var(--uix-text-secondary);
}

.article-toc-list a:hover {
	color: var(--uix-primary);
}

.article-toc-level-2 {
	padding-left: 1em;
}

.article-toc-level-3 {
	padding-left: 2em;
}

/* サイドバー */
.articles-sidebar {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.articles-side-box {
	padding: 16px 18px;
	background: var(--uix-background-paper);
	border: 1px solid var(--uix-divider);
	border-radius: 14px;
}

.articles-side-title {
	margin: 0 0 8px;
	font-size: 0.9rem;
	font-weight: 700;
}

.articles-side-list {
	font-size: 0.88rem;
	line-height: 1.6;
}

.articles-side-list li {
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 5px 0;
	border-top: 1px solid var(--uix-divider);
}

.articles-side-list li:first-child {
	border-top: none;
}

.articles-sidebar a {
	color: var(--uix-text-primary);
}

.articles-sidebar a:hover {
	color: var(--uix-primary);
}

.articles-count {
	flex: none;
	margin-left: 4px;
	font-size: 0.75rem;
	color: var(--uix-text-secondary);
}

/* ボタン（ランディングの「無料ではじめる」） */
.articles-button {
	display: inline-block;
	margin-top: 16px;
	padding: 10px 26px;
	border-radius: 999px;
	background: var(--articles-brand-gradient);
	color: #ffffff;
	font-weight: 600;
}

/* アプリへの案内（ランディングの最後の暗い帯にそろえる） */
.articles-cta {
	padding: 56px 0;
	text-align: center;
	background: var(--articles-dark-bg);
	color: #f4f3ff;
}

.articles-cta-title {
	font-size: clamp(1.2rem, 2.6vw, 1.6rem);
	font-weight: 700;
	line-height: 1.5;
}

.articles-cta-body {
	margin-top: 8px;
	font-size: 0.94rem;
	color: rgba(244, 243, 255, 0.78);
}

/* フッター（ランディングのフッターにそろえる） */
.articles-footer {
	padding: 40px 0 56px;
	text-align: center;
	font-size: 0.8rem;
	color: var(--uix-text-secondary);
	border-top: 1px solid var(--uix-divider);
}

.articles-footer nav {
	display: flex;
	justify-content: center;
	flex-wrap: wrap;
	gap: 16px;
	margin-bottom: 8px;
}

/* 狭い画面: 見出しの導線はサインインだけ残す */
@media (max-width: 599px) {
	.articles-nav .articles-button {
		display: none;
	}

	.article {
		padding: 24px 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.articles-item a {
		transition: none;
	}
}
