@charset "UTF-8";

/* ---------- Design tokens ---------- */

:root {
	--bg: #faf8f4;
	--surface: #ffffff;
	--surface-2: #f3efe7;
	--ink: #1c2230;
	--muted: #5b6272;
	--line: #e4ddd1;
	--accent: #c53a2c;
	--accent-soft: #fbece8;
	--on-accent: #ffffff;
	--link: #26468c;
	--focus: #26468c;
	--shadow: 0 1px 2px rgba(28, 34, 48, .05), 0 2px 10px rgba(28, 34, 48, .05);

	--radius: 12px;
	--radius-sm: 8px;
	--container: 1120px;
	--gutter: 16px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
		"Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, "Noto Sans JP", sans-serif;

	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #12151c;
		--surface: #1a1f29;
		--surface-2: #222835;
		--ink: #ebe8e1;
		--muted: #a3a9b6;
		--line: #2f3646;
		--accent: #ff6f5c;
		--accent-soft: #3a2320;
		--on-accent: #1a0d0b;
		--link: #9fb8ff;
		--focus: #9fb8ff;
		--shadow: none;
	}
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font: 16px/1.6 var(--font);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

main { flex: 1; }

a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); margin: .3em 0 .5em; }
h2 { font-size: 1.35rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.4em 0 .4em; }

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

.container {
	width: 100%;
	max-width: var(--container);
	margin: 0 auto;
	padding: 0 var(--gutter);
}

main.container { padding-top: 20px; padding-bottom: 56px; }

.lead { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }

.visually-hidden {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.skip-link {
	position: absolute;
	left: 8px; top: -48px;
	padding: 8px 12px;
	background: var(--surface);
	border-radius: var(--radius-sm);
	z-index: 100;
}
.skip-link:focus { top: 8px; }

/* ---------- Header ---------- */

.site-header {
	background: var(--surface);
	border-top: 4px solid var(--accent);
	border-bottom: 1px solid var(--line);
}

.site-header__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 20px;
	padding-top: 12px;
	padding-bottom: 12px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--ink);
	text-decoration: none;
	font-weight: 700;
	font-size: 1.1rem;
	line-height: 1.2;
	min-width: 0;
}
.brand:hover { color: var(--ink); }

.brand__mark {
	flex: none;
	display: grid;
	place-items: center;
	width: 36px; height: 36px;
	border-radius: 9px;
	background: var(--accent);
	color: var(--on-accent);
	font-size: 1.35rem;
	line-height: 1;
}

.lang-switch {
	display: flex;
	gap: 2px;
	margin-left: auto;
	font-size: .85rem;
	font-weight: 600;
}
.lang-switch a, .lang-switch span {
	padding: 4px 8px;
	border-radius: 6px;
	text-decoration: none;
	color: var(--muted);
}
.lang-switch a:hover { background: var(--surface-2); color: var(--ink); }
.lang-switch [aria-current] { background: var(--surface-2); color: var(--ink); }

.site-header .search-form--header { order: 3; flex: 1 1 100%; }
.lang-switch { flex: none; }
@media (max-width: 759px) {
	/* Let a long site name (French) wrap instead of pushing the language switch down */
	.brand { flex: 1 1 0; }
}

@media (min-width: 760px) {
	.site-header .search-form--header { order: 0; flex: 0 1 420px; margin-left: auto; }
	.search-form--header + .lang-switch { margin-left: 0; }
}

/* ---------- Search form ---------- */

.search-form {
	display: flex;
	gap: 8px;
}

.search-form input {
	flex: 1;
	min-width: 0;
	padding: 9px 12px;
	font: inherit;
	color: var(--ink);
	background: var(--bg);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
}
.search-form input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }

.search-form--large { max-width: 560px; }
.search-form--large input { padding: 13px 16px; font-size: 1.1rem; background: var(--surface); }
.search-form--large .btn { padding: 0 22px; font-size: 1.05rem; }
@media (max-width: 480px) {
	.search-form--large { flex-wrap: wrap; }
	.search-form--large input { flex: 1 1 100%; }
	.search-form--large .btn { flex: 1 1 100%; padding: 12px; }
}

/* ---------- Buttons ---------- */

.btn {
	padding: 0 16px;
	font: inherit;
	font-weight: 600;
	color: var(--on-accent);
	background: var(--accent);
	border: 0;
	border-radius: var(--radius-sm);
	cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }

.copy-btn {
	padding: 3px 10px;
	font: inherit;
	font-size: .8rem;
	font-weight: 600;
	color: var(--muted);
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 999px;
	cursor: pointer;
	vertical-align: middle;
}
.copy-btn:hover { color: var(--ink); border-color: var(--muted); }
.copy-btn.is-copied { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

/* ---------- Breadcrumb ---------- */

.breadcrumb ol {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: .9rem;
	color: var(--muted);
}
.breadcrumb li + li::before { content: "›"; margin-right: 4px; color: var(--line); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--ink); }

/* ---------- Ads ---------- */

.ad { margin: 28px 0; }
.ad--banner {
	padding: 8px 0 12px;
	border-top: 1px solid var(--line);
	border-bottom: 1px solid var(--line);
	text-align: center;
}
/* Fixed sizes per screen width (Google's documented way to size a responsive unit) */
.ad__unit { display: inline-block; width: 320px; height: 100px; }
@media (min-width: 768px) {
	.ad__unit { width: 728px; height: 90px; }
}
/* No empty box when AdSense has nothing to show */
.ad--banner:has(ins[data-ad-status="unfilled"]) { display: none; }
.ad__label {
	margin: 0 0 6px;
	text-align: left;
	font-size: .7rem;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--muted);
}
.ad--sidebar { position: sticky; top: 16px; margin: 0; }

.with-sidebar { display: block; }
.with-sidebar > .sidebar { display: none; }

@media (min-width: 1100px) {
	.with-sidebar {
		display: grid;
		grid-template-columns: minmax(0, 1fr) 160px;
		gap: 40px;
		align-items: start;
	}
	.with-sidebar > .sidebar { display: block; }
}

/* ---------- A–Z jump bar and letter groups ---------- */

.az {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 20px 0 8px;
	padding: 8px 0;
	background: var(--bg);
	border-bottom: 1px solid var(--line);
}
.az a {
	display: grid;
	place-items: center;
	min-width: 32px;
	height: 32px;
	padding: 0 6px;
	border-radius: 6px;
	font-weight: 600;
	font-size: .9rem;
	text-decoration: none;
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--line);
}
.az a:hover { border-color: var(--accent); color: var(--accent); }

.letter-group { scroll-margin-top: 64px; }
.letter-group__title {
	margin: 24px 0 10px;
	font-size: 1.1rem;
	color: var(--accent);
}

.link-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.link-grid a {
	display: flex;
	flex-direction: column;
	gap: 2px;
	height: 100%;
	padding: 10px 12px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	color: var(--ink);
	text-decoration: none;
	font-weight: 500;
}
.link-grid a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.link-grid .meta { color: var(--muted); font-size: .85rem; font-weight: 400; font-variant-numeric: tabular-nums; }

/* ---------- Cards and tables ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 20px;
}

.table-scroll { overflow-x: auto; }

.data-table {
	width: 100%;
	border-collapse: collapse;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	font-variant-numeric: tabular-nums;
}
.data-table th, .data-table td {
	padding: 9px 12px;
	text-align: left;
	border-bottom: 1px solid var(--line);
}
.data-table td[lang="ja"], .data-table th[lang="ja"] { white-space: nowrap; }
.data-table th { font-size: .85rem; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: 0; }

/* ---------- Stats ---------- */

.stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 16px 0 0; }
.stats dt { font-size: .8rem; color: var(--muted); }
.stats dd { margin: 0; font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats--inline { gap: 8px 28px; margin-top: 20px; }
.stats--inline div { display: flex; flex-direction: column-reverse; }

/* ---------- Homepage ---------- */

.home-hero {
	margin: 8px 0 32px;
	padding: 32px 24px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	background-image: radial-gradient(circle at 100% 0%, var(--accent-soft), transparent 45%);
}
.home-hero h1 { margin-top: 0; }
.home-hero .lead { margin-bottom: 20px; }

.region h3 { display: flex; align-items: baseline; gap: 10px; margin: 24px 0 10px; }
.region h3 span { font-weight: 500; font-size: .95rem; color: var(--muted); }

.about { max-width: 70ch; margin-top: 40px; }

/* ---------- Prefecture page ---------- */

.pref-card { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: flex-start; justify-content: space-between; }
.pref-card__text { flex: 1 1 320px; }
.pref-card .lead { margin: 0; color: var(--ink); }
.pref-card__symbols { display: flex; gap: 16px; }
.pref-card__symbols figure { margin: 0; text-align: center; font-size: .85rem; color: var(--muted); }
.pref-card__symbols img { display: block; height: 72px; width: auto; margin: 0 auto 6px; border-radius: 4px; }

/* ---------- Town tables (city page, search) ---------- */

.town-table td.code { white-space: nowrap; font-weight: 600; }
.town-table td.code a { text-decoration: none; }
.town-table td.code a:hover { text-decoration: underline; }
@media (max-width: 600px) {
	.town-table .col-kana { display: none; }
}

/* ---------- Postcode page ---------- */

.pc-hero {
	margin: 12px 0 24px;
	padding: 24px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	border-left: 6px solid var(--accent);
}
.pc-hero__title { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.pc-hero__label {
	font-size: .8rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--accent);
}
.pc-hero__code {
	font-size: clamp(2.6rem, 2rem + 3vw, 4rem);
	font-weight: 800;
	line-height: 1.05;
	letter-spacing: -.02em;
	font-variant-numeric: tabular-nums;
}
.pc-hero__place { font-size: clamp(1.1rem, 1rem + .5vw, 1.35rem); font-weight: 600; }
.pc-hero__ja { margin: 4px 0 16px; color: var(--muted); font-size: 1.05rem; }
.pc-hero__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.copy-btn--large { padding: 8px 18px; font-size: .95rem; }

.btn-secondary {
	display: inline-flex;
	align-items: center;
	padding: 8px 18px;
	font-size: .95rem;
	font-weight: 600;
	color: var(--ink);
	background: var(--surface-2);
	border: 1px solid var(--line);
	border-radius: 999px;
	text-decoration: none;
}
.btn-secondary:hover { color: var(--ink); border-color: var(--muted); }

.pc-grid { display: grid; gap: 24px; align-items: start; }
.pc-grid h2 { margin-top: 0; }
@media (min-width: 900px) {
	.pc-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px; }
}

.details { display: grid; grid-template-columns: max-content 1fr; gap: 12px 20px; margin: 0; }
.details dt { color: var(--muted); font-size: .9rem; padding-top: 2px; }
.details dd { margin: 0; font-weight: 600; }
.details__sub { font-weight: 400; font-size: .9rem; color: var(--muted); }
.card h3 { font-size: 1rem; margin: 20px 0 10px; }

.envelopes { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 16px 0 8px; }

.envelope {
	position: relative;
	margin: 0;
	padding: 20px 20px 14px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow);
	font-size: 1.05rem;
}
.envelope p { margin: 0 0 4px; }
.envelope figcaption {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	margin-top: 16px;
	padding-top: 10px;
	border-top: 1px dashed var(--line);
	font-size: .85rem;
	font-weight: 600;
	color: var(--muted);
}
.envelope__name { margin-top: 12px !important; font-size: 1.2rem; }
.envelope .sample { color: var(--muted); font-style: italic; }

/* Seven red boxes, as printed on Japanese envelopes */
.envelope__boxes { display: flex; gap: 4px; margin: 0 0 14px auto; width: max-content; }
.envelope__boxes span {
	display: grid;
	place-items: center;
	width: 26px; height: 32px;
	border: 1.5px solid var(--accent);
	border-radius: 3px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}
.envelope__boxes i { width: 8px; align-self: center; border-top: 1.5px solid var(--accent); }

.note { font-size: .9rem; color: var(--muted); }
.more-link { margin-top: 24px; font-weight: 600; }

/* ---------- Empty / 404 ---------- */

.empty-state { padding: 32px 0; }
.empty-state__mark {
	display: grid;
	place-items: center;
	width: 64px; height: 64px;
	margin: 0 0 8px;
	border-radius: 16px;
	background: var(--accent-soft);
	color: var(--accent);
	font-size: 2.2rem;
}

/* ---------- Footer ---------- */

.site-footer {
	background: var(--surface);
	border-top: 1px solid var(--line);
	color: var(--muted);
	font-size: .9rem;
}
.site-footer__inner { padding-top: 24px; padding-bottom: 32px; }
.site-footer p { margin: 6px 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer__langs { display: flex; gap: 16px; margin-bottom: 12px; font-weight: 600; }
.site-footer__langs [aria-current] { color: var(--ink); }
