/*
 * 共通部品：スキップリンク・ヘッダー・Contact・Footer（全ページで読み込む）
 * 値はすべて tokens.css を経由する。
 */

/* ---------- スキップリンク ---------- */
.skip-link {
	position: absolute;
	top: var(--space-8);
	left: var(--space-8);
	z-index: 10;
	padding: var(--space-8) var(--space-16);
	background: var(--color-bg);
	color: var(--color-text);
	font-size: var(--fs-14);
	line-height: var(--lh-14);
	transform: translateY(-200%);
}

.skip-link:focus {
	transform: none;
}

/* ---------- ヘッダー ---------- */
/* スマホ：名前の下にナビ。768px以上：左右に並べる */
/* スマホ：右上のメニューボタンで開く。JSが動かないときは名前の下に横ナビ。768px以上：左右に並べる */
.site-header {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: var(--space-8) var(--space-24);
	padding: var(--header-top) var(--gutter) 0;
}

.site-header__name {
	position: relative;
	z-index: calc(var(--z-menu) + 1); /* メニューを開いても名前は見せる */
	font-size: var(--fs-16);
	font-weight: var(--weight-medium);
	line-height: var(--lh-16);
	letter-spacing: var(--ls-name);
}

.site-header__home {
	color: inherit;
	text-decoration: none;
}

.site-header__list,
.site-footer__list {
	display: flex;
	flex-wrap: wrap; /* HOME を足して4つになったため、320px では CONTACT を次の行へ回す（360px以上は1行。2026-11-22） */
	gap: var(--space-8) var(--space-24);
	list-style: none;
}

.site-footer__link {
	white-space: nowrap; /* 「HOM／E」のように語の途中で折り返さない */
}

.site-header__link,
.site-footer__link {
	position: relative;
	display: inline-block;
	padding-block: var(--space-4);
	color: var(--color-text);
	font-size: var(--fs-12);
	font-weight: var(--weight-medium);
	line-height: var(--lh-12);
	letter-spacing: var(--ls-label);
	text-decoration: none;
}

/* 下線：hover で左から引かれ、離れると右へ抜ける。現在地は引いたまま
   （Motion Prompt #086 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#086）
   太さ・色は現行のまま。速さと動き方だけ #086 に合わせる */
.site-header__link::after,
.site-footer__link::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: var(--line-width);
	background: currentColor;
	transform: scaleX(0);
	transform-origin: right;
	transition: transform var(--underline-duration) var(--underline-ease);
}

.site-header__link:hover::after,
.site-footer__link:hover::after,
.site-header__link[aria-current="page"]::after,
.site-footer__link[aria-current="page"]::after {
	transform: scaleX(1);
	transform-origin: left;
}

/* メニューボタン（JSが動くスマホだけ。<html class="js"> は header.php で付ける） */
.site-header__toggle {
	display: none;
}

.js .site-header__toggle {
	position: relative;
	z-index: calc(var(--z-menu) + 1);
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: var(--space-8);
	width: var(--size-toggle);
	height: var(--size-toggle);
	margin-block: calc((var(--lh-16) - var(--size-toggle)) / 2); /* 名前の行に合わせ、名前の位置をFigmaの44pxに保つ */
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-text);
	cursor: pointer;
}

.site-header__toggle-line {
	display: block;
	width: var(--size-toggle-line);
	height: var(--line-width);
	background: currentColor;
	transition: transform var(--duration-fast) var(--ease);
}

/* 開いたら2本の線を×にする（線の間隔8px＋線1pxの半分ずつ動かす） */
.site-header.is-open .site-header__toggle-line:first-child {
	transform: translateY(calc((var(--space-8) + var(--line-width)) / 2)) rotate(45deg);
}

.site-header.is-open .site-header__toggle-line:last-child {
	transform: translateY(calc((var(--space-8) + var(--line-width)) / -2)) rotate(-45deg);
}

/* スマホでJSが動いているときだけ、ナビを全画面のメニューにする */
@media (max-width: 767px) {
	.js .site-header .site-header__nav {
		position: fixed;
		inset: 0;
		z-index: var(--z-menu);
		padding: var(--space-128) var(--gutter) var(--space-64);
		background: var(--color-bg);
		visibility: hidden;
		opacity: 0;
		transition: opacity var(--duration-base) var(--ease), visibility 0s linear var(--duration-base);
	}

	.js .site-header.is-open .site-header__nav {
		visibility: visible;
		opacity: 1;
		transition: opacity var(--duration-base) var(--ease);
	}

	.js .site-header .site-header__list {
		flex-direction: column;
		align-items: flex-start;
		gap: var(--space-32);
	}

	.js .site-header .site-header__link {
		font-size: var(--fs-20);
		line-height: var(--lh-20);
	}
}

/* メニューを開いている間は後ろのページを動かさない */
.is-menu-open {
	overflow: hidden;
}

/* ナビから同じページの #works・#contact へ移るときだけ、なめらかに移動する（クラスは site-nav.js が付ける）
   （Motion Prompt #093 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#093）
   速さはブラウザに任せる。動きを減らす設定では base.css の prefers-reduced-motion で即時移動に戻る */
.is-smooth-scroll {
	scroll-behavior: smooth;
}

@media (min-width: 768px) {
	.site-header {
		flex-wrap: nowrap;
	}

	.js .site-header__toggle {
		display: none;
	}

	.site-header__list {
		gap: var(--space-32);
	}
}

@media (min-width: 1024px) {
	.site-header {
		padding-inline: var(--gutter-wide);
	}
}

/* TOP以外は、ヘッダーも本文の外枠の端にそろえる（2026-10-21 本人決定。TOPはHeroのコピーとそろえて今の位置のまま） */
body:not(.home) .site-header {
	padding-inline: var(--frame-pad);
}

/* スマホのメニューだけに出す項目（HOME）。横に並ぶナビ・JSが動かないときのナビには出さない */
.site-header__item--menu-only {
	display: none;
}

@media (max-width: 767px) {
	.js .site-header__item--menu-only {
		display: block;
	}

	/* TOP以外は、開いたメニューの項目も外枠の端（名前の位置）にそろえる */
	.js body:not(.home) .site-header .site-header__nav {
		padding-inline: var(--frame-gutter);
	}
}

/* ---------- 本文セクションの見出し（英字ラベル＋日本語＋罫線。Works詳細・About） ---------- */
.section-heading {
	display: flex;
	align-items: center;
	gap: var(--space-16);
	margin-bottom: var(--space-32);
	font-family: var(--font-jp);
	font-size: var(--fs-12);
	font-weight: var(--weight-medium);
	line-height: var(--lh-12);
}

/* 罫線は見出しの右に残りの幅いっぱい */
.section-heading::after {
	content: "";
	flex: 1;
	height: var(--line-width);
	background: var(--color-line);
}

.section-heading__label {
	color: var(--color-accent);
	letter-spacing: var(--ls-label);
}

.section-heading__title {
	color: var(--color-muted);
	font-size: var(--fs-14);
	font-weight: var(--weight-regular);
	line-height: var(--lh-14);
	letter-spacing: var(--ls-name);
}

.section-heading--sub {
	margin-bottom: var(--space-24);
}

.section-heading--sub::after {
	content: none;
}

@media (min-width: 1024px) {
	.section-heading {
		margin-bottom: var(--space-48);
	}
}

/* ---------- Contact ---------- */
.contact {
	padding: var(--section-pad) var(--frame-pad);
	text-align: center;
}

.contact__inner {
	max-width: var(--long-max);
	margin-inline: auto;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.contact__label {
	color: var(--color-muted);
	font-size: var(--fs-12);
	font-weight: var(--weight-medium);
	line-height: var(--lh-12);
	letter-spacing: var(--ls-label);
}

.contact__title {
	margin-top: var(--space-24);
	font-family: var(--font-jp);
	font-size: var(--fs-16);
	font-weight: var(--weight-regular);
	line-height: var(--lh-16);
	letter-spacing: var(--ls-name);
}

.contact__text {
	margin-top: var(--space-16);
	color: var(--color-text); /* 補助色→本文色（2026-11-11 本人：案B。読む文章はすべて本文色） */
	font-size: var(--fs-14);
	line-height: var(--lh-14);
}

/* 狭い画面では読点の後で改行する */
.contact__phrase {
	display: inline-block;
}

.contact__mail {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	max-width: var(--size-mail-button);
	min-height: var(--space-64);
	margin-top: var(--space-48);
	padding-inline: var(--space-24);
	border: var(--line-width) solid var(--color-control-line); /* 押せる部品の枠は「詳しく見る」の丸とそろえる（2026-11-12 本人：提案1） */
	border-radius: var(--radius-pill);
	color: var(--color-text);
	font-size: var(--fs-18);
	line-height: var(--lh-18);
	letter-spacing: var(--ls-name);
	text-decoration: none;
	transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

/* カーソルを乗せたら、本文色で塗りつぶして文字を地の色に（2026-11-22 本人：b。枠の色が変わるだけでは気づきにくいため）。
   タッチの端末で押したあとに塗りが残らないよう、カーソルのある端末だけ */
@media (hover: hover) {
	a.contact__mail:hover {
		border-color: var(--color-text);
		background-color: var(--color-text);
		color: var(--color-bg);
	}
}

.contact__mail--placeholder {
	color: var(--color-muted);
	font-size: var(--fs-14);
	line-height: var(--lh-14);
	border-style: dashed;
	border-color: var(--color-line); /* 押せない表示なので、罫線の色のまま */
}

.contact__rule {
	display: block;
	width: var(--size-rule-short);
	height: var(--line-width);
	margin-top: var(--space-24);
	background: var(--color-line);
}

.contact__signature {
	width: var(--size-signature-w);
	max-width: 100%;
	height: auto;
	margin-top: var(--space-16);
}

/* ---------- Footer ---------- */
.site-footer {
	padding-inline: var(--frame-pad);
}

.site-footer__inner {
	display: flex;
	flex-direction: column;
	gap: var(--space-16);
	padding-block: var(--space-48) var(--space-56);
	border-top: var(--line-width) solid var(--color-line);
}

.site-footer__copyright {
	color: var(--color-muted);
	font-size: var(--fs-12);
	line-height: var(--lh-12);
	letter-spacing: var(--ls-label);
}

.site-footer__copyright small {
	font-size: inherit;
}

@media (min-width: 768px) {
	.site-footer__inner {
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.site-footer__list {
		gap: var(--space-48);
	}
}

/* 改行しない文字のかたまり（原稿の {{ }}・段落の末尾・かっこを含む文節。kento_phrase_units／kento_keep_tail） */
.u-nobr {
	white-space: nowrap;
}

/* 小さい文字のリンクの押せる範囲を、見た目を変えずに高さ44pxへ広げる（2026-11-10 本人：UI見直しの案1）。
   透明な ::before を文字の上下中央に重ねる。::after は下線・矢印で使っているため使わない */
.u-hit {
	position: relative;
}

.u-hit::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	top: 50%;
	height: var(--size-hit);
	transform: translateY(-50%);
}

/* スマホの本文は、行を最後まで詰めて右端をそろえる（2026-10-28 本人：iPhoneで右側がバラバラ。熟語の途中で改行してよい）。
   そのため、スマホの本文では u-nobr のかたまりも改行してよい。768px以上は今までどおり（左そろえ・かたまりは改行しない） */
.about-hero__lead,
.timeline__body,
.strengths__body,
.skills__desc,
.future__body,
.top-about__text,
.works-card__text,
.works-kv__lead,
.works-rows__desc,
.works-concept__text,
.works-site__text,
.works-point__body,
.works-process__body,
.works-ai__table td,
.works-ai__note {
	text-align: justify;
	hanging-punctuation: allow-end; /* 行末の「。」「、」は行の外へぶら下げる（Safari。追い出しで行の字間が開くのを防ぐ） */
	-webkit-hyphens: auto; /* 英単語（lang="en"。kento_phrase_html）はハイフンを付けて改行してよい。長い英単語が次の行へ送られて、字間が大きく開くのを防ぐ（2026-10-29 本人） */
	hyphens: auto;
}

.about-hero__lead .u-nobr,
.timeline__body .u-nobr,
.strengths__body .u-nobr,
.skills__desc .u-nobr,
.future__body .u-nobr,
.top-about__text .u-nobr,
.works-card__text .u-nobr,
.works-kv__lead .u-nobr,
.works-rows__desc .u-nobr,
.works-concept__text .u-nobr,
.works-site__text .u-nobr,
.works-point__body .u-nobr,
.works-process__body .u-nobr,
.works-ai__table td .u-nobr,
.works-ai__note .u-nobr {
	white-space: normal;
}

/* 製品名（Photoshop など。kento_phrase_html）は、語のつなぎ目に入れた soft hyphen でだけ切る（2026-11-11 本人）。768px以上は今までどおり切らない */
.u-joint {
	-webkit-hyphens: manual;
	hyphens: manual;
}

@media (min-width: 768px) {
	.about-hero__lead,
	.timeline__body,
	.strengths__body,
	.skills__desc,
	.future__body,
	.top-about__text,
	.works-card__text,
	.works-kv__lead,
	.works-rows__desc,
	.works-concept__text,
	.works-site__text,
	.works-point__body,
	.works-process__body,
	.works-ai__table td,
	.works-ai__note {
		text-align: start;
		hanging-punctuation: none;
		-webkit-hyphens: manual;
		hyphens: manual;
	}

	.about-hero__lead .u-nobr,
	.timeline__body .u-nobr,
	.strengths__body .u-nobr,
	.skills__desc .u-nobr,
	.future__body .u-nobr,
	.top-about__text .u-nobr,
	.works-card__text .u-nobr,
	.works-kv__lead .u-nobr,
	.works-rows__desc .u-nobr,
	.works-concept__text .u-nobr,
	.works-site__text .u-nobr,
	.works-point__body .u-nobr,
	.works-process__body .u-nobr,
	.works-ai__table td .u-nobr,
	.works-ai__note .u-nobr {
		white-space: nowrap;
	}

	.u-joint {
		-webkit-hyphens: none;
		hyphens: none;
	}
}

/* ---------- #161 TOPの作品カード・ABOUTの写真 → 下層ページのページ移動（2026-10-25 比較用に入れ、採用。view-transition.js が対象の写真に名前を付ける） ---------- */
/* 動きを減らす設定のときは view-transition.js が動きを取りやめる */
@view-transition {
	navigation: auto;
}

/* 押した写真：0.6秒・easeInOut 3乗で、一覧の位置と大きさから詳細上部の写真まで連続して変える */
::view-transition-group(kento-work) {
	animation-duration: 0.6s;
	animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
}

/* 縦横比の違う写真どうしでも、2枚とも枠いっぱいに広げて1枚に見せる。
   枠からはみ出した部分は切り取る（切り取らないと、はみ出した部分が枠の外に見えて二重に見える） */
::view-transition-old(kento-work),
::view-transition-new(kento-work) {
	width: 100%;
	height: 100%;
	overflow: clip;
	object-fit: cover;
}

/* 写真は1枚のまま移す（#161）。移る前と後の写真を重ねて切り替えると、切り取り方の違い（TOPは上端、詳細は中央）で文字が二重に見えるため、移動先の写真だけを動かす */
::view-transition-old(kento-work) {
	animation: none;
	opacity: 0;
}

::view-transition-new(kento-work) {
	animation: none;
}

/* 移動先の写真がまだ描けないとき（初めて開くときなど）は、押した写真のほうを広げる。
   移動先の写真だけを動かすと、空の枠が広がって、パッと切り替わったように見えるため（2026-11-08 本人「一発目の挙動が不安定」。view-transition.js） */
html.is-vt-late::view-transition-old(kento-work) {
	opacity: 1;
}

html.is-vt-late::view-transition-new(kento-work) {
	opacity: 0;
}

/* ほかの部分：前のページは進み0〜62%で消え、次のページは60〜100%で現れる */
::view-transition-old(root) {
	animation: 0.6s linear both kento-vt-out;
}

::view-transition-new(root) {
	animation: 0.6s linear both kento-vt-in;
}

@keyframes kento-vt-out {
	0% { opacity: 1; }
	62%, 100% { opacity: 0; }
}

@keyframes kento-vt-in {
	0%, 60% { opacity: 0; }
	100% { opacity: 1; }
}

/* ---------- スクロールで現れる（Motion Prompt #074 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#074） ----------
   2026-10-26 本人：サイト全体で採用（もとは TOPの作品カードだけ。2026-10-15 本人決定）。
   隠すのは reveal.js が is-reveal-wait を付けたものだけ。JSが動かないときは最初から見えている。
   上へ戻って判定線より下へ出たときも、同じ動きを逆向きに流して消す（2026-10-15 本人決定。#074は見えない所で戻す）。
   動きを付けるのは、開いた時点の隠し終わり（is-reveal）から。開いた瞬間に消える動きは見せない。 */
.is-reveal {
	transition:
		opacity var(--reveal-duration) var(--reveal-ease),
		transform var(--reveal-duration) var(--reveal-ease);
}

.is-reveal-wait {
	opacity: 0;
	transform: translateY(var(--reveal-rise));
}

/* ---------- マウスストーカー（Motion Prompt #083 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#083） ----------
   cursor-stalker.js が作る丸。差し色を薄く乗算で重ねるので、下の文字は読めたまま（2026-10-31 本人：色はサイトに合う色で）。
   押す操作のじゃまをしないよう、クリックは下へ通す */
.cursor-stalker {
	position: fixed;
	top: 0;
	left: 0;
	z-index: calc(var(--z-menu) + 2);
	width: var(--size-stalker);
	height: var(--size-stalker);
	margin: calc(var(--size-stalker) / -2) 0 0 calc(var(--size-stalker) / -2);
	border-radius: 50%;
	background: var(--color-accent);
	mix-blend-mode: multiply;
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--duration-fast) var(--ease);
	will-change: transform;
}

.cursor-stalker.is-visible {
	opacity: var(--stalker-opacity);
}

/* ---------- ページの先頭へ戻る（Motion Prompt #093 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#093） ----------
   右下に固定。現れ方（不透明度）は to-top.js がスクロール量で決める。JSが動かないときは出さない（2026-10-31 本人） */
.to-top {
	display: none;
}

.js .to-top {
	position: fixed;
	right: var(--to-top-offset);
	bottom: calc(var(--to-top-offset) + env(safe-area-inset-bottom));
	z-index: calc(var(--z-menu) - 1);
	display: grid;
	place-items: center;
	width: var(--size-round-button);
	height: var(--size-round-button);
	padding: 0;
	border: var(--line-width) solid var(--color-control-line); /* 2026-11-12 本人：提案1 */
	border-radius: 50%;
	background: var(--color-bg);
	color: var(--color-muted); /* 印の色。主張を抑えて補助色に（2026-10-31 本人：候補D） */
	cursor: pointer;
	opacity: 0;
	transition:
		border-color var(--duration-fast) var(--ease),
		color var(--duration-fast) var(--ease);
}

/* 消えている間は押せない・Tabで止まらない。メニューを開いている間も出さない */
.js .to-top.is-hidden,
.is-menu-open .to-top {
	visibility: hidden;
}

/* 1024px未満は、下へ読む間は隠し、上へ戻したときに出す（to-top.js。2026-11-10 本人：案A）。
   出入りは0.2秒のフェード。消えるときは、フェードが終わってから押せなくする */
@media (max-width: 1023px) {
	.js .to-top {
		transition:
			opacity var(--duration-fast) var(--ease),
			border-color var(--duration-fast) var(--ease),
			color var(--duration-fast) var(--ease);
	}

	.js .to-top.is-hidden {
		transition:
			opacity var(--duration-fast) var(--ease),
			visibility 0s linear var(--duration-fast);
	}
}

/* 中の印は本人がFigmaで描いた形（2026-10-31・Figma 949:5）。丸の上端から10px・左右の中央 */
.to-top svg {
	position: absolute;
	top: calc(var(--to-top-mark-top) - var(--line-width));
	left: calc(50% - var(--size-to-top-mark-w) / 2);
	width: var(--size-to-top-mark-w);
	height: var(--size-to-top-mark-h);
}

/* マウスを乗せたとき・キーボードで選んだときは、丸の線と印が文字の色に濃くなる。印は動かさない（2026-10-31 本人） */
.to-top:hover,
.to-top:focus-visible {
	border-color: var(--color-text);
	color: var(--color-text);
}

/* ---------- 本人写真：読み込めたら、写真の平均の色の地にふわっと重ねる（2026-11-21 本人） ---------- */
/* JS が動かないときは隠さない。読み込み済みの写真は onload ですぐ is-loaded が付く。
   ページ移動（#161）の移動先の写真は、最初の描画の前に view-transition.js が is-loaded を付ける */
.js .photo {
	opacity: 0;
	transition: opacity var(--duration-photo-in) var(--ease);
}

.js .photo.is-loaded {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.js .photo {
		transition: none;
	}
}
