/* Back to the Past — ink-wash theme */

:root {
	--paper: #f3eee3;
	--paper-card: #f8f5ee;
	--ink: #1b1716;
	--ink-soft: #3a3431;
	--red: #a3222a;
	--red-deep: #7e1a20;
	--parchment-hi: #ecd9b0;
	--parchment-lo: #cfb07a;
	--wood: #5b3a1e;
	--wood-hi: #8a5a30;

	--font-display: "Shojumaru", "Patrick Hand", serif;
	--font-hand: "Patrick Hand", "Comic Sans MS", system-ui, sans-serif;

	--frame-inset: clamp(10px, 1.6vw, 30px);
	--gutter: clamp(16px, 4vw, 48px);
}

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

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

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-hand);
	font-size: clamp(1.05rem, 0.95rem + 0.35vw, 1.3rem);
	line-height: 1.45;
	overflow-x: hidden;
}

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

/* Components set their own display, which would otherwise override [hidden]. */
[hidden] { display: none !important; }

a { color: var(--red); }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------------ */
/* Fixed painted backdrop                                              */
/* ------------------------------------------------------------------ */

/* Sized to the *large* viewport so it doesn't re-scale when mobile browser
   toolbars collapse/expand while scrolling (iOS Safari). */
.backdrop {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100vh;
	height: 100lvh;
	z-index: -1;
	background: var(--paper) url("../../images/background.webp") center / cover no-repeat;
}

/* On roughly-landscape screens stretch so the painted red frame stays visible. */
@media (min-aspect-ratio: 3/2) and (max-aspect-ratio: 9/4) {
	.backdrop { background-size: 100% 100%; }
}

/* Portrait/narrow: switch to the vertical painting. It has no painted frame,
   so draw one. */
@media (max-aspect-ratio: 1/1) {
	.backdrop {
		background-image: url("../../images/background-mobile.webp");
		background-size: cover;
		background-position: center bottom;
		opacity: 0.8;
	}

	/* Place the hero against the painting itself. --art-h is the painting's
	   rendered height (cover-fit, bottom-aligned, 941x1672 source), so
	   `100lvh - (1 - f) * --art-h` is the screen y of fraction f down the art. */
	:root { --art-h: max(100lvh, 177.68vw); }
	/* Title + subtitle: bottom edge pinned just above Jack's topknot (~52%),
	   growing upward, so they never cover him whatever the text height. */
	.hero .hero__heading {
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: inherit;
		position: absolute;
		left: var(--gutter);
		right: var(--gutter);
		top: calc(100lvh - 0.50 * var(--art-h));
		transform: translateY(-100%);
	}
	/* Button: below Jack's face (~53-58%), clear of the text above. */
	.hero .scroll-plaque--button {
		position: absolute;
		top: calc(100lvh - 0.37 * var(--art-h));
		left: 0;
		right: 0;
		width: fit-content;
		margin: 0 auto;
	}
	/* Separate from .backdrop so it tracks the *visible* viewport and its
	   bottom edge stays above the toolbar. */
	body::after {
		content: "";
		position: fixed;
		z-index: -1;
		inset: var(--frame-inset);
		pointer-events: none;
		border: 2px solid var(--red);
		opacity: 0.65;
		filter: url(#rough);
	}
}

/* ------------------------------------------------------------------ */
/* Parchment scroll plaque (buttons + section tag)                     */
/* ------------------------------------------------------------------ */

.scroll-plaque {
	--rod: 12px;
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5em;
	padding: 0.55em 1.6em;
	margin-inline: var(--rod);
	color: var(--ink);
	font-family: var(--font-hand);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	text-decoration: none;
	background:
		radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(110, 70, 25, 0.25) 100%),
		linear-gradient(180deg, var(--parchment-hi), var(--parchment-lo));
	border-top: 2px solid rgba(91, 58, 30, 0.55);
	border-bottom: 2px solid rgba(91, 58, 30, 0.55);
	box-shadow: 0 6px 14px -6px rgba(40, 20, 5, 0.55);
}

.scroll-plaque::before,
.scroll-plaque::after {
	content: "";
	position: absolute;
	top: -7px;
	bottom: -7px;
	width: var(--rod);
	border-radius: 5px;
	background: linear-gradient(90deg, var(--wood) 0%, var(--wood-hi) 45%, var(--wood) 100%);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}
.scroll-plaque::before { left: calc(var(--rod) * -1); }
.scroll-plaque::after  { right: calc(var(--rod) * -1); }

.scroll-plaque--button {
	font-size: clamp(1.05rem, 0.9rem + 0.5vw, 1.45rem);
	cursor: pointer;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.scroll-plaque--button:hover,
.scroll-plaque--button:focus-visible {
	transform: translateY(-2px) rotate(-0.6deg);
	box-shadow: 0 10px 18px -6px rgba(40, 20, 5, 0.6);
}
.scroll-plaque--button:focus-visible { outline: 2px dashed var(--red); outline-offset: 10px; }

.scroll-plaque .icon { width: 1em; height: 1em; fill: currentColor; }

.section-tag {
	--rod: 9px;
	position: fixed;
	top: calc(var(--frame-inset) + 6px);
	right: calc(var(--frame-inset) + 18px);
	z-index: 20;
	padding: 0.25em 1.2em;
	font-size: 1.05rem;
	text-transform: none;
	min-width: 8.5em;
}
.section-tag span { display: inline-block; transition: opacity 0.25s ease, transform 0.25s ease; }
.section-tag.is-changing span { opacity: 0; transform: translateY(-4px); }

/* ------------------------------------------------------------------ */
/* Side navigation scroll                                              */
/* ------------------------------------------------------------------ */

.side-nav {
	position: fixed;
	right: calc(var(--frame-inset) + 6px);
	top: 50%;
	transform: translateY(-50%);
	z-index: 20;
	padding: 16px 0;
}
.side-nav::before,
.side-nav::after {
	content: "";
	position: absolute;
	left: -5px;
	right: -5px;
	height: 10px;
	border-radius: 5px;
	background: linear-gradient(180deg, var(--wood) 0%, var(--wood-hi) 45%, var(--wood) 100%);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}
.side-nav::before { top: 4px; }
.side-nav::after  { bottom: 4px; }

.side-nav ol {
	list-style: none;
	margin: 0;
	padding: 14px 9px;
	display: grid;
	gap: 14px;
	background: linear-gradient(90deg, var(--parchment-lo), var(--parchment-hi) 50%, var(--parchment-lo));
	box-shadow: 0 6px 14px -6px rgba(40, 20, 5, 0.55);
}

.side-nav a {
	position: relative;
	display: block;
	width: 15px;
	height: 15px;
	border-radius: 50%;
	border: 2px solid var(--ink-soft);
	background: rgba(255, 255, 255, 0.25);
	transition: background 0.25s ease, transform 0.25s ease;
}
.side-nav a:hover { transform: scale(1.15); }
.side-nav a.is-active { background: var(--ink); border-color: var(--ink); }
.side-nav a::after {
	content: attr(aria-label);
	position: absolute;
	right: calc(100% + 14px);
	top: 50%;
	transform: translate(6px, -50%);
	white-space: nowrap;
	font-size: 0.95rem;
	color: var(--ink);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.side-nav a:hover::after,
.side-nav a:focus-visible::after { opacity: 1; transform: translate(0, -50%); }

/* ------------------------------------------------------------------ */
/* Panels                                                              */
/* ------------------------------------------------------------------ */

.panel {
	position: relative;
	min-height: 100vh;
	min-height: 100svh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: clamp(1.25rem, 3vh, 2.25rem);
	padding: clamp(5rem, 12vh, 7.5rem) calc(var(--gutter) + 40px);
	text-align: center;
}

.section-title {
	margin: 0;
	font-family: var(--font-display);
	font-weight: 400;
	font-size: clamp(1.8rem, 1rem + 2.6vw, 3.6rem);
	text-wrap: balance;
	line-height: 1.05;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	text-shadow: 0 0 18px var(--paper), 0 0 6px var(--paper);
}

.section-sub {
	margin: -0.75rem 0 0;
	font-size: clamp(1.3rem, 1rem + 1vw, 1.9rem);
	text-transform: uppercase;
	color: var(--red);
}

.section-lede,
.section-note {
	margin: 0;
	max-width: 46ch;
	text-shadow: 0 0 10px var(--paper), 0 0 4px var(--paper);
}
.section-note { font-size: 0.95em; color: var(--ink-soft); }

/* ------------------------------------------------------------------ */
/* Hero                                                                */
/* ------------------------------------------------------------------ */

/* Only a box on portrait screens (see the backdrop media query). */
.hero__heading { display: contents; }

.hero__inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: clamp(0.5rem, 1.8vh, 1.4rem);
	max-width: min(62rem, 100%);
	margin-bottom: clamp(2rem, 6vh, 4rem);
}

.eyebrow {
	margin: 0;
	font-size: clamp(1.25rem, 0.9rem + 1.4vw, 2.3rem);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.hero__title {
	position: relative;
	margin: 0;
	font-family: var(--font-display);
	font-weight: 400;
	font-size: clamp(2.4rem, min(8vw, 14.5vh), 9.5rem);
	line-height: 1.08;
	text-transform: uppercase;
	isolation: isolate;
}
.hero__line { display: block; white-space: nowrap; }

@media (max-width: 560px) {
	.hero__title { font-size: clamp(2.2rem, 13vw, 4rem); }
	.hero__line { white-space: normal; }
}

.brush-stroke {
	position: absolute;
	z-index: -1;
	left: -6%;
	top: 4%;
	width: 112%;
	height: 92%;
	overflow: visible;
}
.brush-stroke path { fill: var(--red); opacity: 0.88; }
.brush-stroke .brush-stroke__tail { opacity: 0.6; }

.hero__tagline {
	margin: 0;
	font-size: clamp(1.15rem, 0.85rem + 1.1vw, 2rem);
	text-shadow: 0 0 12px var(--paper), 0 0 4px var(--paper);
}

.hero .scroll-plaque--button { margin-top: 0.75rem; }

.scroll-cue {
	position: absolute;
	bottom: calc(var(--frame-inset) + 2.5vh);
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	color: var(--ink);
	text-decoration: none;
	text-transform: uppercase;
	font-size: 1rem;
}
.scroll-cue svg { width: 26px; height: 40px; fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; filter: url(#rough); }
@media (max-height: 640px) { .scroll-cue { display: none; } }
.scroll-cue__wheel { animation: wheel 1.8s ease-in-out infinite; }

@keyframes wheel {
	0%   { transform: translateY(0); opacity: 1; }
	70%  { transform: translateY(9px); opacity: 0; }
	100% { transform: translateY(0); opacity: 0; }
}

/* ------------------------------------------------------------------ */
/* Paper cards                                                         */
/* ------------------------------------------------------------------ */

.paper-card {
	position: relative;
	padding: clamp(1.25rem, 2.2vw, 2rem);
	background:
		radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.7), transparent 60%),
		radial-gradient(ellipse at 80% 90%, rgba(200, 185, 155, 0.18), transparent 55%),
		var(--paper-card);
	box-shadow: 0 18px 30px -18px rgba(30, 15, 5, 0.5);
	isolation: isolate;
}
/* Hand-painted red border */
.paper-card::before {
	content: "";
	position: absolute;
	inset: 0;
	border: 3px solid var(--red);
	border-left-width: 4px;
	border-bottom-width: 2px;
	filter: url(#rough);
	pointer-events: none;
	opacity: 0.9;
}

.card-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: clamp(1rem, 2.2vw, 2rem);
	width: min(74rem, 100%);
}

.card-grid .paper-card img {
	width: 100%;
	aspect-ratio: 16 / 9;
	object-fit: contain;
	mix-blend-mode: multiply;
	margin-bottom: 0.75rem;
	-webkit-mask-image: radial-gradient(ellipse 50% 50% at center, #000 70%, transparent 100%);
	mask-image: radial-gradient(ellipse 50% 50% at center, #000 70%, transparent 100%);
}

.paper-card h3 {
	margin: 0 0 0.5rem;
	font-weight: 400;
	font-size: clamp(1.4rem, 1.1rem + 0.8vw, 1.95rem);
	text-transform: uppercase;
	line-height: 1.1;
}
.paper-card p { margin: 0; }
.paper-card p + p { margin-top: 0.9em; }

/* ------------------------------------------------------------------ */
/* Restoration / comparison                                            */
/* ------------------------------------------------------------------ */

.restoration {
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	gap: clamp(1.25rem, 2.5vw, 2.5rem);
	align-items: center;
	width: min(80rem, 100%);
	text-align: left;
}

.compare-wrap {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
}

.compare {
	--pos: 50%;
	position: relative;
	width: 100%;
	aspect-ratio: 2884 / 1928;
	overflow: hidden;
	background: var(--ink);
	box-shadow: 0 0 0 6px var(--paper-card), 0 0 0 9px var(--red), 0 22px 40px -18px rgba(30, 15, 5, 0.6);
	user-select: none;
	touch-action: pan-y;
}
.compare__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	pointer-events: none;
}
.compare__after { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }

.compare__handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--pos);
	width: 4px;
	transform: translateX(-50%);
	background: var(--paper);
	box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
	pointer-events: none;
}
.compare__handle span {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 46px;
	height: 46px;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--red);
	border: 3px solid var(--paper);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}
.compare__handle span::before,
.compare__handle span::after {
	content: "";
	position: absolute;
	top: 50%;
	width: 0;
	height: 0;
	border: 6px solid transparent;
	transform: translateY(-50%);
}
.compare__handle span::before { left: 3px; border-right-color: var(--paper); }
.compare__handle span::after { right: 3px; border-left-color: var(--paper); }

.compare__range {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: col-resize;
	-webkit-appearance: none;
	appearance: none;
}
.compare__range::-webkit-slider-thumb { -webkit-appearance: none; width: 48px; height: 100vh; }
.compare__range::-moz-range-thumb { width: 48px; height: 100vh; border: 0; }
.compare:has(.compare__range:focus-visible) { outline: 2px dashed var(--red); outline-offset: 14px; }


.compare-tabs { display: flex; gap: 0.9rem; }

/* Hanko-style seal buttons */
.seal {
	width: 2.6rem;
	height: 2.6rem;
	display: grid;
	place-items: center;
	padding: 0;
	font-family: serif;
	font-size: 1.25rem;
	color: var(--red);
	background: transparent;
	border: 2.5px solid var(--red);
	border-radius: 6px;
	cursor: pointer;
	transform: rotate(-3deg);
	transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.seal:nth-child(2) { transform: rotate(2deg); }
.seal:hover { transform: rotate(0) scale(1.06); }
.seal.is-active { background: var(--red); color: var(--paper); }
.seal:focus-visible { outline: 2px dashed var(--ink); outline-offset: 4px; }

/* ------------------------------------------------------------------ */
/* Showcase                                                            */
/* ------------------------------------------------------------------ */

.video-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(1.25rem, 2.5vw, 2.5rem);
	width: min(80rem, 100%);
}

.video-frame {
	margin: 0;
	padding: 0.75rem 0.75rem 1rem;
	background: var(--paper-card);
	box-shadow: 0 0 0 3px var(--red), 0 22px 40px -18px rgba(30, 15, 5, 0.6);
}
.video-frame figcaption {
	margin-bottom: 0.5rem;
	font-size: clamp(1.2rem, 1rem + 0.6vw, 1.6rem);
	text-transform: uppercase;
}
.video-frame__media {
	position: relative;
	aspect-ratio: 16 / 9;
	background: var(--ink);
}
.video-frame__media iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* ------------------------------------------------------------------ */
/* Legacy                                                              */
/* ------------------------------------------------------------------ */

.paper-card--story {
	width: min(72rem, 100%);
	padding: 0 0 clamp(1.5rem, 3vw, 2.75rem);
	text-align: left;
}
.story__banner {
	width: 100%;
	aspect-ratio: 3.2 / 1;
	object-fit: cover;
	object-position: center 40%;
	-webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
	mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.story__text {
	columns: 3 18rem;
	column-gap: clamp(1.5rem, 3vw, 3rem);
	column-rule: 1px solid rgba(163, 34, 42, 0.35);
	padding-inline: clamp(1.25rem, 3vw, 2.75rem);
}
.story__text p { margin: 0 0 1em; }
.story__text p:first-child::first-letter {
	float: left;
	margin: 0.08em 0.1em 0 0;
	font-family: var(--font-display);
	font-size: 3.3em;
	line-height: 0.85;
	color: var(--red);
}

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

.site-footer {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1.25rem;
	padding: 3rem var(--gutter) calc(var(--frame-inset) + 3rem);
	text-align: center;
}
.site-footer p {
	margin: 0;
	font-size: 0.95rem;
	color: var(--ink-soft);
	text-shadow: 0 0 8px var(--paper);
}

/* ------------------------------------------------------------------ */
/* Reveal animation                                                    */
/* ------------------------------------------------------------------ */

.js [data-reveal] {
	opacity: 0;
	transform: translateY(24px);
	filter: blur(6px);
	transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.9s ease;
	transition-delay: var(--delay, 0s);
}
.js [data-reveal].is-visible { opacity: 1; transform: none; filter: none; }

.js .brush-stroke path {
	clip-path: inset(0 100% 0 0);
	transition: clip-path 1.1s cubic-bezier(0.6, 0, 0.3, 1) 0.45s;
}
.js .brush-stroke .brush-stroke__tail { transition-delay: 0.85s; }
.js .hero__title.is-visible .brush-stroke path { clip-path: inset(0 0 0 0); }

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	.js [data-reveal],
	.js .brush-stroke path { opacity: 1; transform: none; filter: none; clip-path: none; transition: none; }
	@media (max-height: 640px) { .scroll-cue { display: none; } }
.scroll-cue__wheel { animation: none; }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 1100px) {
	.restoration { grid-template-columns: 1fr; }
	.restoration .paper-card--text { order: 2; }
}

@media (max-width: 860px) {
	.card-grid { grid-template-columns: 1fr; max-width: 30rem; }
	.video-grid { grid-template-columns: 1fr; }
	.side-nav { display: none; }
	.panel { padding-inline: calc(var(--gutter) + var(--frame-inset)); }
}

@media (max-width: 520px) {
	.section-tag { display: none; }
	.compare__handle span { width: 38px; height: 38px; }
}
