/* =====================================================================
   Stories Dark
   Sumi ink background, washi text, fuji (wisteria) for interaction,
   yamabuki (gold) only for likes and ranking.
   ===================================================================== */

:root {
	--sumi:      #15151f;   /* page */
	--sumi-deep: #0e0e15;   /* reader band */
	--surface:   #1e1e2b;   /* cards, inputs */
	--line:      #2b2b3b;   /* borders */
	--washi:     #ece8f4;   /* text */
	--mute:      #9a96ad;   /* secondary text */
	--fuji:      #b9a4e6;   /* accent: links, focus, primary */
	--fuji-ink:  #1a1430;   /* text on fuji */
	--yamabuki:  #f2b33d;   /* likes, ranking */

	--font-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
	--font-display: "Dela Gothic One", var(--font-ui);

	--wrap: 1240px;
	--gutter: clamp(16px, 4vw, 32px);
	--r: 6px;
	--bar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
	margin: 0;
	background: var(--sumi);
	color: var(--washi);
	font: 15px/1.75 var(--font-ui);
	font-feature-settings: "palt";
	-webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--fuji); }
:focus-visible { outline: 2px solid var(--fuji); outline-offset: 2px; border-radius: 2px; }
button, input, textarea { font: inherit; color: inherit; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.block { padding-block: 28px 8px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--fuji); color: var(--fuji-ink); padding: 8px 14px; border-radius: var(--r); }
.skip:focus { left: 8px; }
.empty { color: var(--mute); }

/* ---------- type ---------- */
.section-h {
	font: 400 20px/1.3 var(--font-display);
	letter-spacing: .02em;
	margin: 0 0 16px;
}
.brand__word {
	font: 400 22px/1 var(--font-display);
	color: #fff;
	letter-spacing: .01em;
	white-space: nowrap;
}
.brand__word--sm { font-size: 16px; }

/* ---------- header ---------- */
.site-header {
	position: sticky; top: 0; z-index: 20;
	background: color-mix(in srgb, var(--sumi) 92%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--line);
}
.site-header__inner { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { flex: none; display: flex; align-items: center; }
.brand:hover { color: inherit; }
.brand__logo { height: 32px; width: auto; }

.site-search { flex: 1; max-width: 460px; display: flex; position: relative; }
.site-search input {
	width: 100%; height: 38px; padding: 0 40px 0 14px;
	background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
	outline: none;
}
.site-search input::placeholder { color: var(--mute); }
.site-search input:focus { border-color: var(--fuji); }
.site-search button {
	position: absolute; right: 4px; top: 4px; width: 30px; height: 30px;
	border: 0; border-radius: 50%; background: transparent; color: var(--mute); cursor: pointer;
	display: grid; place-items: center;
}
.nav { display: flex; gap: 18px; margin-left: auto; font-size: 14px; }
.nav a { color: var(--mute); }
.nav a[aria-current] { color: var(--washi); }
.nav a:hover { color: var(--fuji); }

@media (max-width: 640px) {
	.site-header__inner { flex-wrap: wrap; height: auto; padding-block: 10px; gap: 10px 16px; }
	.site-search { order: 3; max-width: none; flex-basis: 100%; }
}

/* ---------- ranking: the one loud element ---------- */
.ranking { padding: 28px 0 8px; }
.ranking__list {
	list-style: none; margin: 0; padding: 4px var(--gutter) 16px;
	display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 172px);
	gap: 8px;
	overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: thin;
	max-width: var(--wrap); margin-inline: auto;   /* same left edge as .wrap */
}
.rank { scroll-snap-align: start; }
.rank__link { display: grid; grid-template-columns: 1fr; position: relative; }
.rank__no {
	position: absolute; left: 0; bottom: 34px; z-index: 1;
	font: 400 76px/0.8 var(--font-display);
	color: var(--sumi);
	-webkit-text-stroke: 2px var(--yamabuki);
	paint-order: stroke fill;
	pointer-events: none;
}
.rank:nth-child(-n+3) .rank__no { color: var(--yamabuki); -webkit-text-stroke: 3px var(--sumi); }
.rank__cover {
	margin-left: 30px;
	aspect-ratio: 5 / 7; overflow: hidden; border-radius: var(--r); background: var(--surface);
}
.rank__cover img { width: 100%; height: 100%; object-fit: cover; }
.rank__title {
	margin: 8px 0 0 30px; font-size: 13px; line-height: 1.5;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- grid + card (quiet) ---------- */
.block__head { display: flex; align-items: baseline; justify-content: space-between; }
.more { font-size: 14px; color: var(--fuji); }
.grid {
	display: grid; gap: 22px 14px;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (max-width: 480px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 18px 10px; } }

.card__link { display: block; }
.card__cover {
	position: relative; display: block;
	aspect-ratio: 5 / 7; overflow: hidden; border-radius: var(--r); background: var(--surface);
	outline: 1px solid transparent; outline-offset: 2px;
}
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__link:hover .card__cover { outline-color: var(--fuji); }
.card__pages {
	position: absolute; right: 6px; bottom: 6px;
	padding: 1px 6px; border-radius: 3px;
	background: rgb(14 14 21 / .82); color: var(--washi); font-size: 11px; line-height: 1.6;
}
.card__title {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	margin-top: 8px; font-size: 14px; line-height: 1.5;
}
.card__author { display: block; margin-top: 2px; font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-empty { display: block; width: 100%; height: 100%; background: var(--surface); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 3px 12px; border-radius: 999px;
	background: var(--surface); border: 1px solid var(--line);
	font-size: 13px; line-height: 1.6;
}
.chip:hover { border-color: var(--fuji); color: var(--washi); }
.chip--tag::before { content: "#"; color: var(--mute); }
.chip__n { color: var(--mute); font-size: 11px; }

/* ---------- list headers, sort, pager ---------- */
.list-head { margin: 8px 0 20px; }
.list-head__type { margin: 0; color: var(--fuji); font-size: 13px; }
.list-head__name { margin: 2px 0 4px; font: 400 clamp(24px, 4vw, 34px)/1.3 var(--font-display); }
.list-head__count { margin: 0; color: var(--mute); font-size: 14px; }
.list-head__sub { margin: 10px 0 0; max-width: 70ch; color: var(--mute); }

.sort { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.sort a { padding: 8px 14px; color: var(--mute); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sort a[aria-current] { color: var(--washi); border-bottom-color: var(--fuji); }

.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 36px 0 12px; }
.pager .page-numbers {
	min-width: 40px; height: 40px; padding: 0 12px;
	display: inline-grid; place-items: center;
	border: 1px solid var(--line); border-radius: var(--r); font-size: 14px;
}
.pager .current { background: var(--fuji); border-color: var(--fuji); color: var(--fuji-ink); font-weight: 700; }
.pager .dots { border-color: transparent; color: var(--mute); }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; gap: 8px;
	height: 42px; padding: 0 18px; border-radius: var(--r);
	border: 1px solid var(--line); background: var(--surface); cursor: pointer;
	font-size: 14px; font-weight: 600;
}
.btn:hover { border-color: var(--fuji); color: var(--washi); }
.btn--primary { background: var(--fuji); border-color: var(--fuji); color: var(--fuji-ink); }
.btn--primary:hover { background: #cbbaf0; color: var(--fuji-ink); }
.btn--ghost { background: transparent; }
.btn:disabled { opacity: .6; cursor: default; }

.like svg { color: var(--mute); transition: transform .2s ease, color .2s ease; }
.like[aria-pressed="true"] { border-color: var(--yamabuki); }
.like[aria-pressed="true"] svg { color: var(--yamabuki); transform: scale(1.15); }

/* ---------- story page ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 18px; font-size: 13px; color: var(--mute); }
.crumbs > * + *::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs span[aria-current] { color: var(--washi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }

.story-head { display: grid; grid-template-columns: 220px 1fr; gap: 28px; padding-block: 18px 32px; align-items: start; }
.story-head__cover { border-radius: var(--r); overflow: hidden; background: var(--surface); }
.story-head__title { margin: 0 0 14px; font: 400 clamp(22px, 3.4vw, 32px)/1.35 var(--font-display); }
@media (max-width: 640px) {
	.story-head { grid-template-columns: 110px 1fr; gap: 16px; }
	.story-head__info { display: contents; }
	.story-head__title { grid-column: 2; grid-row: 1; align-self: center; }
	.facts, .story-head .chips, .actions { grid-column: 1 / -1; }
}

.facts { margin: 0 0 16px; display: grid; gap: 8px; }
.facts > div { display: grid; grid-template-columns: 7em 1fr; gap: 12px; align-items: start; }
.facts dt { color: var(--mute); font-size: 13px; padding-top: 4px; }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.story-head .chips { margin-bottom: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- reader ---------- */
.reader { background: var(--sumi-deep); padding: 24px 0 calc(var(--bar-h) + 24px); position: relative; }
.reader__pages { max-width: 820px; margin-inline: auto; }
.rpage { margin: 0 auto 6px; }
.rpage img { width: 100%; background: #1a1a24; }

.reader[data-mode="paged"] .reader__pages { cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.reader[data-mode="paged"] .rpage { display: none; margin: 0; }
.reader[data-mode="paged"] .rpage.is-current { display: block; }
.reader[data-mode="paged"] .rpage img {
	width: auto; max-width: 100%; margin-inline: auto;
	max-height: calc(100vh - var(--bar-h) - 32px); max-height: calc(100dvh - var(--bar-h) - 32px);
}

.reader__bar {
	position: sticky; bottom: 0; z-index: 5;
	height: var(--bar-h); margin-top: 16px;
	display: flex; align-items: center; justify-content: center; gap: 18px;
	background: color-mix(in srgb, var(--sumi-deep) 94%, transparent); backdrop-filter: blur(8px);
	border-top: 1px solid var(--line); font-size: 13px;
}
.reader__pos { color: var(--mute); min-width: 5em; text-align: center; font-variant-numeric: tabular-nums; }
/* mode switch: top of story + bottom bar */
.modes { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--sumi); }
.modes button { border: 0; background: transparent; padding: 4px 14px; border-radius: 999px; cursor: pointer; color: var(--mute); font-size: 13px; }
.modes button:hover { color: var(--washi); }
.modes button[aria-pressed="true"] { background: var(--fuji); color: var(--fuji-ink); font-weight: 600; }
.actions .modes { height: 42px; align-items: center; }
@media (max-width: 640px) {
	.actions .modes { order: -1; width: 100%; }          /* display switch on its own row */
	.actions .modes button { flex: 1; height: 100%; }
	.actions .btn { flex: 1; justify-content: center; padding-inline: 10px; }
}

/* 横読み arrows (left = next, right-to-left) */
.reader__arrow {
	display: none;
	position: absolute; top: 50%; z-index: 4; transform: translateY(-50%);
	width: 52px; height: 52px; border-radius: 50%; cursor: pointer;
	border: 1px solid var(--line); background: rgb(14 14 21 / .7); color: var(--washi);
	place-items: center;
}
.reader__arrow:hover { border-color: var(--fuji); color: var(--fuji); }
.reader__arrow--next { left: max(12px, calc(50% - 470px)); }
.reader__arrow--prev { right: max(12px, calc(50% - 470px)); }
.reader[data-mode="paged"] .reader__arrow { display: grid; }
.reader.is-last .reader__arrow--next, .reader.is-first .reader__arrow--prev { visibility: hidden; }
@media (max-width: 640px) { .reader__arrow { width: 40px; height: 40px; background: rgb(14 14 21 / .55); } }
.reader__top { color: var(--mute); }

/* ---------- comments ---------- */
.comments { max-width: 760px; padding-block: 40px 8px; }
.comment-list { list-style: none; margin: 0 0 24px; padding: 0; }
.comment { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment__meta { margin: 0 0 4px; font-size: 13px; color: var(--mute); display: flex; gap: 10px; }
.comment__meta strong { color: var(--washi); font-weight: 600; }
.comment__body { overflow-wrap: anywhere; }

.comment-form { display: grid; gap: 14px; margin-top: 12px; }
.comment-form__note { margin: 0; color: var(--mute); font-size: 13px; }
.comment-form label { display: grid; gap: 6px; font-size: 13px; color: var(--mute); }
.comment-form input, .comment-form textarea {
	padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
	color: var(--washi); font-size: 15px; outline: none;
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--fuji); }
.comment-form textarea { resize: vertical; min-height: 110px; }
.comment-form .btn { justify-self: start; }
.comment-form__msg { margin: 0; min-height: 1.5em; font-size: 14px; }
.comment-form__msg[data-state="ok"] { color: #8fd6a3; }
.comment-form__msg[data-state="error"] { color: #f0a0a0; }
.hp { position: absolute !important; left: -9999px; }

/* ---------- static pages / 404 ---------- */
.prose { max-width: 760px; }
.prose a { color: var(--fuji); text-decoration: underline; }
.notfound { padding-block: 80px; }

/* ---------- footer ---------- */
.site-footer { margin-top: 56px; border-top: 1px solid var(--line); color: var(--mute); font-size: 13px; }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; padding-block: 28px; }
.footer-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer small { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
