/**
 * SB Author Theme — front-end styles.
 *
 * theme.json owns colour, type scale, and spacing. This file owns the things
 * theme.json cannot express: component layout, the console-panel chrome, the
 * glitch treatment, and form styling.
 *
 * Everything reads from the preset custom properties so a style variation
 * recolours the whole site without touching this file.
 */

/* --------------------------------------------------------------------------
   1. Primitives
   -------------------------------------------------------------------------- */

:root {
	--sb-hairline: 1px solid var(--wp--preset--color--edge);
	--sb-ease: 180ms cubic-bezier(0.2, 0, 0, 1);
	--sb-scanline: repeating-linear-gradient(
		to bottom,
		rgba(232, 238, 249, 0.028) 0px,
		rgba(232, 238, 249, 0.028) 1px,
		transparent 1px,
		transparent 3px
	);
}

body {
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

/* A visible focus ring is non-negotiable on a dark palette. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--signal);
	outline-offset: 3px;
	border-radius: 2px;
}

::selection {
	background: var(--wp--preset--color--signal);
	color: var(--wp--preset--color--void);
}

/* --------------------------------------------------------------------------
   2. Block styles registered in inc/setup.php
   -------------------------------------------------------------------------- */

/* System label: the mono eyebrow used above headings. */
.is-style-sb-eyebrow {
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
	text-transform: uppercase;
	letter-spacing: 0.16em;
	line-height: 1.4;
	margin-block: 0;
}

.is-style-sb-eyebrow::before {
	content: "";
	display: inline-block;
	width: 1.75rem;
	height: 1px;
	margin-right: 0.6rem;
	vertical-align: 0.28em;
	background: currentColor;
	opacity: 0.65;
}

/* Console panel: hairline box with corner ticks and a faint scanline wash. */
.is-style-sb-panel {
	position: relative;
	background: color-mix(in srgb, var(--wp--preset--color--panel) 78%, transparent);
	border: var(--sb-hairline);
	border-radius: 3px;
}

.is-style-sb-panel::before,
.is-style-sb-panel::after {
	content: "";
	position: absolute;
	width: 10px;
	height: 10px;
	border: 1px solid var(--wp--preset--color--signal);
	opacity: 0.75;
	pointer-events: none;
}

.is-style-sb-panel::before {
	top: -1px;
	left: -1px;
	border-right: 0;
	border-bottom: 0;
}

.is-style-sb-panel::after {
	right: -1px;
	bottom: -1px;
	border-left: 0;
	border-top: 0;
}

/* Glitch heading: two offset chromatic copies, driven by a data attribute set
   in theme.js so the markup stays clean and screen readers see one string. */
.is-style-sb-glitch {
	position: relative;
	display: inline-block;
}

.is-style-sb-glitch::before,
.is-style-sb-glitch::after {
	content: attr(data-sb-text);
	position: absolute;
	inset: 0;
	pointer-events: none;
	opacity: 0;
}

.is-style-sb-glitch::before {
	color: var(--wp--preset--color--signal);
	transform: translate(-2px, 0);
	clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.is-style-sb-glitch::after {
	color: var(--wp--preset--color--flare);
	transform: translate(2px, 0);
	clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

.is-style-sb-glitch:hover::before,
.is-style-sb-glitch:hover::after {
	opacity: 0.55;
	animation: sb-glitch 620ms steps(3, end) infinite;
}

@keyframes sb-glitch {
	0%, 100% { transform: translate(-2px, 0); }
	50% { transform: translate(2px, -1px); }
}

/* Cover art: slight perspective lift, hard edge, no soft shadow. */
.is-style-sb-cover img {
	display: block;
	width: 100%;
	height: auto;
	border: var(--sb-hairline);
	border-radius: 2px;
	box-shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.95);
}

/* --------------------------------------------------------------------------
   3. Header / footer
   -------------------------------------------------------------------------- */

.sb-header {
	position: sticky;
	top: 0;
	z-index: 40;
	background: color-mix(in srgb, var(--wp--preset--color--void) 88%, transparent);
	backdrop-filter: saturate(140%) blur(10px);
	-webkit-backdrop-filter: saturate(140%) blur(10px);
}

.sb-header__tagline::before {
	display: none;
}

.sb-header .wp-block-navigation a:hover {
	color: var(--wp--preset--color--text);
}

.sb-header__cta .wp-block-button__link {
	padding-block: 0.55rem;
	padding-inline: 1rem;
	font-size: 0.6875rem;
}

.sb-footer a {
	text-decoration: none;
}

.sb-footer a:hover {
	text-decoration: underline;
}

/* --------------------------------------------------------------------------
   4. Hero
   -------------------------------------------------------------------------- */

.sb-hero {
	position: relative;
	overflow: hidden;
	border-bottom: var(--sb-hairline);
}

/* Scanline wash + a soft signal bloom behind the headline. */
.sb-hero::before {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--sb-scanline);
	pointer-events: none;
}

.sb-hero::after {
	content: "";
	position: absolute;
	top: -30%;
	left: -10%;
	width: 60%;
	height: 120%;
	background: radial-gradient(closest-side, rgba(34, 211, 238, 0.14), transparent 70%);
	pointer-events: none;
}

.sb-hero > * {
	position: relative;
	z-index: 1;
}

.sb-hero__title {
	text-wrap: balance;
}

/* --------------------------------------------------------------------------
   5. Book grid + cards
   -------------------------------------------------------------------------- */

.sb-book-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(var(--sb-cols, 4), minmax(0, 1fr));
	gap: clamp(1rem, 2.4vw, 2rem);
}

/* Step down, but never step *up*: a deliberate 1-column grid (the hero) must
   stay one column at every width. */
@media (max-width: 1100px) {
	.sb-book-grid { grid-template-columns: repeat(min(var(--sb-cols, 4), 4), minmax(0, 1fr)); }
}

@media (max-width: 820px) {
	.sb-book-grid { grid-template-columns: repeat(min(var(--sb-cols, 4), 3), minmax(0, 1fr)); }
}

@media (max-width: 560px) {
	.sb-book-grid { grid-template-columns: repeat(min(var(--sb-cols, 4), 2), minmax(0, 1fr)); }
}

.sb-book-card {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	min-width: 0;
}

.sb-book-card__link {
	display: flex;
	flex-direction: column;
	gap: 0.7rem;
	text-decoration: none;
	color: inherit;
}

.sb-book-card__art {
	position: relative;
	aspect-ratio: 5 / 8;
	overflow: hidden;
	border: var(--sb-hairline);
	border-radius: 2px;
	background: var(--wp--preset--color--panel);
	transition: border-color var(--sb-ease), transform var(--sb-ease), box-shadow var(--sb-ease);
}

.sb-book-card__art img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 400ms cubic-bezier(0.2, 0, 0, 1);
}

.sb-book-card__link:hover .sb-book-card__art {
	border-color: var(--wp--preset--color--signal);
	transform: translateY(-3px);
	box-shadow: 0 0 32px -10px rgba(34, 211, 238, 0.5);
}

.sb-book-card__link:hover .sb-book-card__art img {
	transform: scale(1.035);
}

/* Volume chip, bottom-left of the cover. */
.sb-book-card__vol {
	position: absolute;
	left: 0;
	bottom: 0;
	padding: 0.3rem 0.55rem;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.625rem;
	font-weight: 700;
	letter-spacing: 0.12em;
	color: var(--wp--preset--color--void);
	background: var(--wp--preset--color--signal);
}

.sb-book-card__flag {
	position: absolute;
	top: 0.5rem;
	right: 0.5rem;
	padding: 0.25rem 0.5rem;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.5625rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--wp--preset--color--void);
	background: var(--wp--preset--color--warn);
	border-radius: 2px;
}

.sb-book-card__flag--coming {
	background: var(--wp--preset--color--flare);
	color: var(--wp--preset--color--white);
}

.sb-book-card__placeholder {
	display: grid;
	place-items: center;
	height: 100%;
	background:
		var(--sb-scanline),
		linear-gradient(160deg, var(--wp--preset--color--panel), var(--wp--preset--color--hull));
	color: var(--wp--preset--color--edge);
	font-family: var(--wp--preset--font-family--display);
	font-size: 2rem;
	letter-spacing: 0.1em;
}

.sb-book-card__title {
	margin: 0;
	font-size: 1.0625rem;
	line-height: 1.25;
	letter-spacing: -0.005em;
	text-wrap: balance;
}

.sb-book-card__link:hover .sb-book-card__title {
	color: var(--wp--preset--color--signal);
}

.sb-book-card__buy {
	align-self: start;
}

/* Archive grid uses core's grid layout; align the card internals to match. */
.sb-archive-grid .sb-book-card {
	height: 100%;
}

/* --------------------------------------------------------------------------
   6. Single book
   -------------------------------------------------------------------------- */

.sb-book-hero {
	position: relative;
	overflow: hidden;
}

.sb-book-hero::before {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--sb-scanline);
	pointer-events: none;
}

.sb-book-hero > * {
	position: relative;
	z-index: 1;
}

.sb-specs {
	margin: 2rem 0 0;
	border-top: var(--sb-hairline);
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.8125rem;
}

.sb-specs__row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.6rem 0;
	border-bottom: var(--sb-hairline);
}

.sb-specs dt {
	color: var(--wp--preset--color--muted);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-size: 0.6875rem;
	margin: 0;
}

.sb-specs dd {
	margin: 0;
	color: var(--wp--preset--color--text);
	text-align: right;
}

.sb-buy {
	margin-block: 1.5rem 0;
}

/* --------------------------------------------------------------------------
   7. Buttons
   -------------------------------------------------------------------------- */

.sb-btn {
	display: inline-block;
	padding: 0.85rem 1.6rem;
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.8125rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	text-decoration: none;
	color: var(--wp--preset--color--void);
	background: var(--wp--preset--color--signal);
	border: 1px solid var(--wp--preset--color--signal);
	border-radius: 2px;
	cursor: pointer;
	transition: background var(--sb-ease), color var(--sb-ease), border-color var(--sb-ease), box-shadow var(--sb-ease);
}

.sb-btn:hover {
	background: var(--wp--preset--color--flare);
	border-color: var(--wp--preset--color--flare);
	color: var(--wp--preset--color--white);
	box-shadow: 0 0 28px -8px rgba(255, 46, 151, 0.7);
	text-decoration: none;
}

.sb-btn--lg {
	padding: 1.05rem 2rem;
	font-size: 0.875rem;
}

.sb-btn--ghost {
	background: transparent;
	color: var(--wp--preset--color--signal);
	border-color: var(--wp--preset--color--edge);
	padding: 0.55rem 1rem;
	font-size: 0.6875rem;
}

.sb-btn--ghost:hover {
	background: transparent;
	color: var(--wp--preset--color--flare);
	border-color: var(--wp--preset--color--flare);
	box-shadow: none;
}

/* Core buttons in outline style should match the ghost treatment. */
.wp-block-button.is-style-outline .wp-block-button__link {
	border-color: var(--wp--preset--color--edge);
	color: var(--wp--preset--color--signal);
	background: transparent;
}

.wp-block-button.is-style-outline .wp-block-button__link:hover {
	border-color: var(--wp--preset--color--flare);
	color: var(--wp--preset--color--flare);
	background: transparent;
}

/* --------------------------------------------------------------------------
   8. Opt-in form
   -------------------------------------------------------------------------- */

.sb-optin {
	scroll-margin-top: 6rem;
}

.sb-optin__heading {
	margin-block: 0 0.5rem;
	font-size: var(--wp--preset--font-size--x-large);
}

.sb-optin__blurb {
	color: var(--wp--preset--color--muted);
	margin-block: 0 1.5rem;
}

.sb-optin__form {
	display: grid;
	gap: 1rem;
	padding: clamp(1.25rem, 3vw, 2rem);
	background: color-mix(in srgb, var(--wp--preset--color--panel) 70%, transparent);
	border: var(--sb-hairline);
	border-radius: 3px;
}

.sb-optin--compact .sb-optin__form {
	background: transparent;
	border-color: transparent;
	padding: 0;
	max-width: 34rem;
	margin-inline: auto;
}

.sb-field {
	display: grid;
	gap: 0.35rem;
	margin: 0;
}

.sb-field label {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.6875rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--wp--preset--color--muted);
}

.sb-field input[type="text"],
.sb-field input[type="email"] {
	width: 100%;
	padding: 0.85rem 1rem;
	font-family: inherit;
	font-size: 1rem;
	color: var(--wp--preset--color--text);
	background: var(--wp--preset--color--void);
	border: var(--sb-hairline);
	border-radius: 2px;
	transition: border-color var(--sb-ease), box-shadow var(--sb-ease);
}

.sb-field input::placeholder {
	color: var(--wp--preset--color--muted);
}

.sb-field input:focus {
	border-color: var(--wp--preset--color--signal);
	box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
	outline: none;
}

/* Consent row: checkbox beside wrapping label text. */
.sb-field--check {
	grid-template-columns: auto 1fr;
	align-items: start;
	gap: 0.7rem;
}

.sb-field--check input {
	margin-top: 0.25rem;
	width: 1.05rem;
	height: 1.05rem;
	accent-color: var(--wp--preset--color--signal);
}

.sb-field--check label {
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.875rem;
	text-transform: none;
	letter-spacing: normal;
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
}

.sb-req {
	color: var(--wp--preset--color--flare);
}

.sb-optional {
	opacity: 0.65;
}

.sb-optin__legal {
	margin: 0;
	font-size: 0.75rem;
	line-height: 1.5;
	color: var(--wp--preset--color--muted);
}

.sb-optin__form .sb-btn {
	justify-self: start;
}

.sb-optin--compact .sb-optin__form .sb-btn {
	justify-self: stretch;
	text-align: center;
}

/* Honeypot: off-screen rather than display:none, which some bots detect. */
.sb-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.sb-optin__notice {
	padding: 0.9rem 1.1rem;
	margin-bottom: 1.25rem;
	border-left: 2px solid var(--wp--preset--color--signal);
	background: color-mix(in srgb, var(--wp--preset--color--panel) 80%, transparent);
	font-size: 0.9375rem;
}

.sb-optin__notice--error {
	border-left-color: var(--wp--preset--color--flare);
}

.sb-download {
	padding: clamp(1.5rem, 4vw, 2.75rem);
	text-align: center;
}

.sb-download h2 {
	margin-block: 0.5rem 0.75rem;
}

.sb-download .sb-eyebrow {
	font-family: var(--wp--preset--font-family--mono);
	font-size: 0.6875rem;
	text-transform: uppercase;
	letter-spacing: 0.16em;
	color: var(--wp--preset--color--signal);
	margin: 0;
}

/* --------------------------------------------------------------------------
   9. Post list + long-form reading
   -------------------------------------------------------------------------- */

.sb-post-list__item:last-child {
	border-bottom: 0 !important;
}

.sb-post-list__item .wp-block-post-title a {
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

.sb-post-list__item .wp-block-post-title a:hover {
	color: var(--wp--preset--color--signal);
}

.entry-content p,
.wp-block-post-content p {
	max-width: 66ch;
}

.wp-block-post-content h2,
.wp-block-post-content h3 {
	margin-top: 2.5em;
}

.sb-portrait img {
	filter: grayscale(1) contrast(1.05);
	transition: filter var(--sb-ease);
}

.sb-portrait:hover img {
	filter: grayscale(0) contrast(1);
}

/* --------------------------------------------------------------------------
   10. Motion + print
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
		scroll-behavior: auto !important;
	}

	.sb-book-card__link:hover .sb-book-card__art {
		transform: none;
	}
}

@media print {
	.sb-header,
	.sb-footer,
	.sb-cta-band,
	.sb-optin {
		display: none !important;
	}

	body {
		background: #fff;
		color: #000;
	}
}
