/*
Theme Name: Read to Books
Theme URI: https://readtobooks.com
Author: Read to Books
Description: Block theme for Read to Books, publisher of the Read to Spanish and Color to Spanish series. Warm, literary, Andalusian: cream paper, engraved line art, flat earthy cover colours and gold accents.
Requires at least: 6.9
Tested up to: 7.1
Requires PHP: 8.1
Version: 1.0.0
License: GPL-2.0-or-later
Text Domain: readtobooks
*/

/* ---------- Base ---------- */
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
:where(a, button, .wp-element-button):focus-visible { outline: 3px solid var(--wp--preset--color--gold); outline-offset: 2px; }
.screen-reader-text:focus { background: var(--wp--preset--color--card); }

/* ---------- Labels ---------- */
.is-style-eyebrow,
.rtb-eyebrow {
	font-family: var(--wp--preset--font-family--ui);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--wp--preset--color--gold-ink);
}
.has-cocoa-background-color .is-style-eyebrow,
.has-forest-background-color .is-style-eyebrow,
.has-slate-background-color .is-style-eyebrow { color: var(--wp--preset--color--gold); }

.is-style-lede { font-style: italic; font-size: var(--wp--preset--font-size--large); color: var(--wp--preset--color--ink-soft); }
.has-slate-background-color .is-style-lede,
.has-cocoa-background-color .is-style-lede,
.has-forest-background-color .is-style-lede { color: var(--wp--preset--color--light); opacity: .9; }

/* Term links shown as labels */
.is-style-eyebrow a { text-decoration: none; }
.is-style-eyebrow a:hover { text-decoration: underline; }

/* Section header: thin rule above eyebrow + heading */
.is-style-section-header { border-top: 1px solid var(--wp--preset--color--rule); padding-top: 1.25rem; }

/* ---------- Vocabulary highlight (inline formats) ---------- */
.vocab {
	background: var(--wp--preset--color--gold);
	color: var(--wp--preset--color--ink);
	font-weight: 600;
	padding: 0 0.3em;
	border-radius: 4px;
	white-space: nowrap;
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}
.pron { font-style: italic; font-size: 0.82em; color: var(--wp--preset--color--ink-soft); }
:is(.has-cocoa-background-color, .has-forest-background-color, .has-slate-background-color) .pron { color: var(--wp--preset--color--light); opacity: .8; }
:is(.has-cocoa-background-color, .has-forest-background-color, .has-slate-background-color) em { color: var(--wp--preset--color--gold); }

/* ---------- Buttons ---------- */
.wp-block-button.is-style-outline > .wp-block-button__link {
	background: transparent;
	color: currentColor;
	border: 1.5px solid currentColor;
}
.wp-block-button.is-style-kids > .wp-block-button__link {
	background: var(--wp--preset--color--kid-orange);
	color: #fff;
}

/* ---------- Header / footer ---------- */
.rtb-header { border-bottom: 1px solid var(--wp--preset--color--rule); }
.rtb-header .wp-block-site-logo img { border-radius: 50%; }
.rtb-footer a { color: var(--wp--preset--color--light); }
.rtb-footer .wp-block-social-links .wp-social-link { color: var(--wp--preset--color--light); }

/* Faint engraved arch watermark for dark panels and footer */
.rtb-watermark { position: relative; overflow: hidden; isolation: isolate; }
.rtb-watermark::after {
	content: "";
	position: absolute;
	inset: auto 0 -10px 0;
	height: 120px;
	background: url("assets/img/arch-line.svg") center bottom / auto 110px repeat-x;
	opacity: 0.09;
	pointer-events: none;
	z-index: -1;
}

/* ---------- Hero cover lineup ---------- */
.rtb-covers {
	display: flex;
	justify-content: center;
	gap: 1rem;
	padding: 1.75rem;
	border-radius: 6px;
}
.rtb-covers { list-style: none; margin: 0; }
.rtb-covers > li { flex: 0 1 190px; min-width: 0; transform: rotate(-3deg); }
.rtb-covers > li:nth-child(even) { transform: rotate(3deg); }
.rtb-covers .rtb-cover { font-size: 13px; }

/* ---------- Book cover (dynamic block readtobooks/book-cover) ---------- */
.rtb-cover {
	box-sizing: border-box;
	overflow: hidden; /* keeps the 2:3 shape even when a long title wraps */
	aspect-ratio: 2 / 3;
	width: 100%;
	max-width: 280px;
	padding: 8px;
	border-radius: 2px;
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
	color: #2B1B14;
	background: var(--rtb-cover, var(--wp--preset--color--terracotta));
	font-size: 15px;
	flex-shrink: 0;
}
/* Real cover images keep their own proportions (the kids cover is near-square): they sit
   centred in the same 2:3 plate as drawn covers, never cropped. */
.rtb-cover.has-image { padding: 0; background: none; box-shadow: none; display: flex; align-items: center; justify-content: center; }
.rtb-cover img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; border-radius: 2px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3); }
.rtb-cover__frame {
	box-sizing: border-box;
	height: 100%;
	border: 1.5px solid #2B1B14;
	outline: 1px solid #2B1B14;
	outline-offset: -5px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: space-between;
	padding: 1.3em 0.7em 0.9em;
	text-align: center;
}
.rtb-cover__series { font-family: var(--wp--preset--font-family--display); font-weight: 600; font-size: 1.45em; line-height: 1.05; letter-spacing: .04em; text-transform: uppercase; }
.rtb-cover__motif { height: 22%; width: auto; max-width: 72%; opacity: .85; }
.rtb-cover__title { border: 1px solid #2B1B14; padding: 0.2em 0.7em; font-family: var(--wp--preset--font-family--display); font-size: 1em; font-weight: 600; line-height: 1.2; text-transform: uppercase; background: rgba(255, 255, 255, .18); }
.rtb-cover__author { font-family: var(--wp--preset--font-family--body); font-size: 0.68em; letter-spacing: .08em; text-transform: uppercase; }
.rtb-cover.is-kids .rtb-cover__series,
.rtb-cover.is-kids .rtb-cover__title { font-family: var(--wp--preset--font-family--kids); font-weight: 400; letter-spacing: 0; }
.rtb-cover.is-dark { color: #F6E7D6; }
.rtb-cover.is-dark .rtb-cover__frame,
.rtb-cover.is-dark .rtb-cover__title { border-color: currentColor; outline-color: currentColor; }
.rtb-cover__frame, .rtb-cover__title { border-color: currentColor; outline-color: currentColor; }
a.rtb-cover-link { display: block; width: 100%; text-decoration: none; }
.rtb-book-grid .rtb-cover { font-size: 12.5px; }
.wp-block-readtobooks-book-cover.aligncenter { margin-inline: auto; }
.single-book .rtb-cover { font-size: 18px; }

/* ---------- Chapter ladder ---------- */
.rtb-ladder { border: 1px solid var(--wp--preset--color--rule); border-radius: 6px; overflow: hidden; background: var(--wp--preset--color--card); gap: 0 !important; }
.rtb-ladder > .wp-block-column { padding: 1.125rem; border-right: 1px solid var(--wp--preset--color--rule); display: flex; flex-direction: column; gap: .5rem; }
.rtb-ladder > .wp-block-column:last-child { border-right: 0; }
.rtb-ladder > .wp-block-column > * { margin: 0; }
.rtb-ladder p { font-size: 0.9375rem; line-height: 1.55; }
.rtb-ladder .rtb-chapter { font-family: var(--wp--preset--font-family--ui); font-size: 0.75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--wp--preset--color--ink-soft); }
.rtb-bar { height: 6px; border-radius: 3px; background: var(--wp--preset--color--paper); overflow: hidden; }
.rtb-bar::before { content: ""; display: block; height: 100%; width: var(--fill, 10%); background: var(--wp--preset--color--gold); }
.rtb-bar.fill-10 { --fill: 8%; } .rtb-bar.fill-30 { --fill: 30%; } .rtb-bar.fill-60 { --fill: 60%; } .rtb-bar.fill-95 { --fill: 95%; }
@media (max-width: 781px) {
	.rtb-ladder { display: grid !important; grid-template-columns: 1fr 1fr; }
	.rtb-ladder > .wp-block-column { border-bottom: 1px solid var(--wp--preset--color--rule); }
	.rtb-ladder > .wp-block-column:nth-child(2n) { border-right: 0; }
}
@media (max-width: 420px) {
	.rtb-ladder { grid-template-columns: 1fr; }
	.rtb-ladder > .wp-block-column { border-right: 0; }
}

/* ---------- Cards & panels ---------- */
.is-style-card,
.rtb-panel {
	background: var(--wp--preset--color--card);
	border: 1px solid var(--wp--preset--color--rule);
	border-radius: 6px;
	padding: 1.375rem;
}
.rtb-book-card { display: flex; flex-direction: column; gap: .75rem; height: 100%; }
.rtb-book-card .wp-block-post-title { font-family: var(--wp--preset--font-family--body); font-size: var(--wp--preset--font-size--large); margin: .25rem 0 0; }
.rtb-book-card .wp-block-post-title a { text-decoration: none; }
.rtb-book-card .wp-block-buttons { margin-top: auto; }
.rtb-book-grid .rtb-cover { margin-inline: auto; max-width: 200px; }
.rtb-meta { font-family: var(--wp--preset--font-family--ui); font-size: .8125rem; color: var(--wp--preset--color--ink-soft); }
.rtb-meta p { margin: 0; }

/* Series filter (core/categories with taxonomy=series) */
.rtb-series-filter ul, ul.rtb-series-filter { list-style: none; padding: 0; margin: var(--wp--preset--spacing--30) 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.rtb-series-filter li a {
	display: inline-block; padding: .4rem 1rem; border: 1.5px solid var(--wp--preset--color--ink); border-radius: 999px;
	font-family: var(--wp--preset--font-family--ui); font-weight: 700; font-size: .875rem; text-decoration: none;
}
.rtb-series-filter li a:hover, .rtb-series-filter li.current-cat a { background: var(--wp--preset--color--ink); color: var(--wp--preset--color--cream); }

/* ---------- Speech bubbles ---------- */
.is-style-bubble,
.is-style-bubble-right {
	width: fit-content;
	max-width: 85%;
	background: #FFFDF8;
	color: #2B1B14;
	border: 2px solid #2B1B14;
	border-radius: 16px;
	padding: .5rem .875rem;
	font-family: var(--wp--preset--font-family--ui);
	font-weight: 600;
}
.is-style-bubble-right { margin-left: auto !important; background: var(--wp--preset--color--gold); }
.is-style-bubble small, .is-style-bubble-right small { display: block; font-weight: 400; font-style: italic; color: #6B5446; font-size: .75rem; }

/* ---------- Kids sub-brand ---------- */
.rtb-kids {
	background-color: var(--wp--preset--color--kid-sky);
	background-image: radial-gradient(rgba(255, 255, 255, .35) 18%, transparent 19%);
	background-size: 34px 34px;
	border-radius: 6px;
}
.is-style-kids-headline,
.rtb-kids h1, .rtb-kids h2 {
	font-family: var(--wp--preset--font-family--kids);
	font-weight: 400;
	color: var(--wp--preset--color--kid-sun);
	-webkit-text-stroke: 1.5px #3A2410;
	paint-order: stroke fill;
	text-shadow: 0 2px 0 #3A2410;
	letter-spacing: 0;
	line-height: 1.1;
}
.is-style-pill {
	display: inline-block;
	width: fit-content;
	background: #fff;
	color: #2B1B14;
	border: 2px solid #2B1B14;
	border-radius: 999px;
	padding: .25rem .875rem;
	font-family: var(--wp--preset--font-family--ui);
	font-weight: 700;
	font-size: .8125rem;
}
.rtb-wordcard {
	display: flex !important;
	align-items: center;
	gap: 1rem;
	border: 2px solid #2B1B14;
	border-radius: 12px;
	padding: .875rem 1.125rem;
	background: #fff;
	color: #2B1B14;
	width: fit-content;
}
.rtb-wordcard > * { margin: 0 !important; }
.rtb-wordcard .rtb-word { font-family: var(--wp--preset--font-family--kids); font-size: 1.875rem; color: var(--wp--preset--color--kid-orange); -webkit-text-stroke: 1px #2B1B14; paint-order: stroke fill; }
.rtb-wordcard .rtb-gloss { font-family: var(--wp--preset--font-family--ui); font-size: .875rem; line-height: 1.4; }
.rtb-wordcard .rtb-gloss em { color: #6B5446; }

/* ---------- Word list (dynamic block readtobooks/word-list) ---------- */
.rtb-word-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .625rem; list-style: none; padding: 0; margin: 0; }
.rtb-word-list li { background: var(--wp--preset--color--card); border: 1px solid var(--wp--preset--color--rule); border-radius: 6px; padding: .625rem .875rem; font-family: var(--wp--preset--font-family--ui); font-size: .875rem; }
.rtb-word-list b { font-family: var(--wp--preset--font-family--body); font-size: 1.0625rem; display: block; }
.rtb-word-list i { color: var(--wp--preset--color--ink-soft); }

/* ---------- Sample page ---------- */
.rtb-sample { background: var(--wp--preset--color--card); border: 1px solid var(--wp--preset--color--rule); border-radius: 4px; padding: clamp(1.25rem, 4vw, 2.5rem); box-shadow: 0 1px 0 var(--wp--preset--color--rule), 0 6px 0 -2px var(--wp--preset--color--paper), 0 7px 0 -2px var(--wp--preset--color--rule); }
.rtb-sample p:first-of-type::first-letter { font-family: var(--wp--preset--font-family--display); float: left; font-size: 3.2em; line-height: .9; padding: .05em .1em 0 0; }

/* ---------- Tables ---------- */
.wp-block-table table { background: var(--wp--preset--color--card); }
.wp-block-table th { font-family: var(--wp--preset--font-family--ui); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--wp--preset--color--ink-soft); }
.wp-block-table td, .wp-block-table th { border-color: var(--wp--preset--color--rule); }

/* ---------- Post cards (blog) ---------- */
.rtb-post-card .wp-block-post-featured-image img { border-radius: 6px; }
.rtb-post-card .wp-block-post-title a { text-decoration: none; }
