/*
Theme Name:        WhatsMyRugSize
Theme URI:         https://whatsmyrugsize.com/
Description:       Block theme for WhatsMyRugSize, fully editable in the Site Editor. Hook-location blocks for the WMRS Toolkit (calculators, apps, forms), an automatic table of contents, affiliate disclosures on posts with affiliate links, per-page title hiding, author boxes, related posts, a latest-posts grid on the homepage and Rank Math breadcrumbs. Prints no schema of its own, so Rank Math stays the single source.
Author:            WhatsMyRugSize
Version:           2.1.0
Requires at least: 6.6
Tested up to:      6.9
Requires PHP:      7.4
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       wmrs-theme
Tags:              blog, one-column, block-styles, full-site-editing, editor-style, custom-logo, featured-images, threaded-comments, wide-blocks, accessibility-ready
*/

/* ==========================================================================
   Tokens. Colours come from theme.json (Appearance → Editor → Styles → Colours), so
   changing the palette there restyles the theme and the WMRS Toolkit's calculators.
   ========================================================================== */
:root {
	--wmrs-accent: var(--wp--preset--color--accent, #5b2a86);
	--wmrs-accent-hover: var(--wp--preset--color--accent-hover, #431d66);
	--wmrs-accent-ink: var(--wp--preset--color--white, #fff);
	--wmrs-accent-soft: var(--wp--preset--color--accent-soft, #efe6f6);
	--wmrs-bg: var(--wp--preset--color--white, #fff);
	--wmrs-surface: var(--wp--preset--color--surface, #f7f5f2);
	--wmrs-line: var(--wp--preset--color--line, #e4dfd8);
	--wmrs-text: var(--wp--preset--color--text, #1f1b24);
	--wmrs-muted: var(--wp--preset--color--muted, #5c5664);
	--wmrs-rug: var(--wp--preset--color--rug, #c98a3a);
	--wmrs-furn: #8b8496;
	--wmrs-ok: #1d7a4a;
	--wmrs-error: #b3261e;
	--wmrs-radius: var(--wp--custom--radius, 12px);
}

/* ==========================================================================
   Base
   ========================================================================== */
html { scroll-padding-top: 16px; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4 { text-wrap: balance; }
a { text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--wmrs-accent) 50%, transparent); outline-offset: 2px; border-radius: 3px; }
img { height: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95em; }
th, td { border: 1px solid var(--wmrs-line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--wmrs-surface); font-weight: 600; }
code { background: var(--wmrs-surface); padding: .1em .35em; border-radius: 4px; font-size: .92em; }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
	position: fixed !important; top: 8px; left: 8px; z-index: 1000; width: auto; height: auto; margin: 0;
	padding: 10px 16px; clip: auto; background: var(--wmrs-text); color: #fff; border-radius: 8px; text-decoration: none;
}

/* ==========================================================================
   Rounded images everywhere
   ========================================================================== */
.wp-block-image img,
.wp-block-post-featured-image img,
.wp-block-post-featured-image a,
.wp-block-gallery .wp-block-image img,
.wp-block-media-text__media img,
.entry-content img:not(.avatar):not(.emoji),
.card__image img,
.author-box img { border-radius: var(--wmrs-radius); }
.wp-block-post-featured-image { overflow: hidden; border-radius: var(--wmrs-radius); }
.avatar, .wp-block-avatar img, .author-box img { border-radius: 999px !important; }
.wp-block-image.is-style-square img { border-radius: 0; }
figcaption, .wp-element-caption { font-size: .88rem; color: var(--wmrs-muted); text-align: center; }

/* ==========================================================================
   Header
   ========================================================================== */
.site-header { background: var(--wmrs-bg); position: relative; z-index: 20; }
.site-header .wp-block-site-title a:hover { color: var(--wmrs-accent); }
.site-header .wp-block-site-logo img { border-radius: 8px; }
.wp-block-navigation .wp-block-navigation-item__content { padding: 8px 12px; border-radius: 8px; color: var(--wmrs-text); text-decoration: none; }
.wp-block-navigation .wp-block-navigation-item__content:hover,
.wp-block-navigation .current-menu-item > .wp-block-navigation-item__content { color: var(--wmrs-accent); background: var(--wmrs-accent-soft); }
.wp-block-navigation .wp-block-navigation__submenu-container {
	border: 1px solid var(--wmrs-line) !important; border-radius: 10px; padding: 6px;
	box-shadow: 0 12px 30px -12px rgb(31 27 36 / .25);
}
.wp-block-navigation__responsive-container.is-menu-open { padding: 24px 20px; }

/* Full-width bands around header and footer (only printed when something is placed there) */
.band { padding: 18px 20px; background: var(--wmrs-surface); border-bottom: 1px solid var(--wmrs-line); }
.band--wmrs-before-footer { border-bottom: 0; border-top: 1px solid var(--wmrs-line); padding: 32px 20px; }
.band__inner { max-width: 1140px; margin: 0 auto; }

/* Breadcrumbs (Rank Math) */
.breadcrumbs { font-size: .86rem; color: var(--wmrs-muted); padding: 14px 20px 0; }
.breadcrumbs__inner { max-width: 760px; margin: 0 auto; }
.breadcrumbs p { margin: 0; }
.breadcrumbs a { color: var(--wmrs-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--wmrs-accent); text-decoration: underline; }
.breadcrumbs .separator { margin: 0 6px; opacity: .6; }
body.archive .breadcrumbs__inner, body.search .breadcrumbs__inner, body.blog .breadcrumbs__inner,
body.page-template-page-wide .breadcrumbs__inner, body.single-post.post-template-single-sidebar .breadcrumbs__inner { max-width: 1140px; }

/* ==========================================================================
   Entry
   ========================================================================== */
.entry-kicker a {
	font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-decoration: none; color: var(--wmrs-accent);
}
.entry-kicker { margin-bottom: -.4rem !important; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--wmrs-muted); font-size: .92rem; }
.entry-meta a { color: inherit; font-weight: 600; text-decoration: none; }
.entry-meta a:hover { color: var(--wmrs-accent); text-decoration: underline; }
.entry-meta .sep { opacity: .5; }
.wmrs-updated { font-weight: 600; color: var(--wmrs-text); }
.title-hidden .entry-kicker { display: none; }

.entry-content .wp-block-table { overflow-x: auto; }
.entry-content .wp-block-details { border: 1px solid var(--wmrs-line); border-radius: 10px; padding: 12px 16px; }
.entry-content .wp-block-details summary { font-weight: 700; cursor: pointer; }
.entry-content h2[id], .entry-content h3[id] { scroll-margin-top: 16px; }

/* Affiliate disclosure under the byline */
.wmrs-disclosure {
	font-size: .85rem; line-height: 1.5; color: var(--wmrs-muted);
	padding: 10px 14px; background: var(--wmrs-surface); border-left: 3px solid var(--wmrs-rug); border-radius: 0 8px 8px 0;
}
.wmrs-disclosure p { margin: 0; }
.wmrs-disclosure a { color: inherit; font-weight: 600; }

/* Table of contents */
.wmrs-toc { border: 1px solid var(--wmrs-line); border-radius: var(--wmrs-radius); background: var(--wmrs-bg); font-size: .95rem; }
.wmrs-toc summary {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 14px 18px; cursor: pointer; list-style: none;
	font-family: var(--wp--preset--font-family--heading); font-weight: 700;
}
.wmrs-toc summary::-webkit-details-marker { display: none; }
.wmrs-toc summary::after {
	content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-2px); transition: transform .2s; opacity: .6;
}
.wmrs-toc details[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.wmrs-toc details[open] summary { border-bottom: 1px solid var(--wmrs-line); }
.wmrs-toc ol { margin: 0; padding: 10px 18px 14px 36px; counter-reset: none; }
.wmrs-toc ol ol { padding: 4px 0 2px 18px; list-style: lower-alpha; }
.wmrs-toc li { margin: 4px 0; }
.wmrs-toc li::marker { color: var(--wmrs-muted); }
.wmrs-toc a { color: var(--wmrs-text); text-decoration: none; }
.wmrs-toc a:hover { color: var(--wmrs-accent); text-decoration: underline; }
.wmrs-toc .toc-orphan { list-style: none; }

/* Tool spots */
.wmrs-hero-tool > :last-child { margin-bottom: 0; }
.home .wmrs-hero-tool .wmrs-tabs, .home .wmrs-hero-tool .wmrs-calc { box-shadow: 0 14px 34px -20px rgb(43 18 66 / .4); }
.wmrs-slot { margin: 1.8em 0; }
.wmrs-post-cta { display: grid; gap: 6px; padding: 22px 24px; background: var(--wmrs-accent-soft); border-radius: var(--wmrs-radius); }
.wmrs-post-cta p { margin: 0; }
.wmrs-post-cta .wmrs-btn { margin-top: 6px; }
.wmrs-post-cta strong { font-family: var(--wp--preset--font-family--heading); font-size: 1.15rem; }

/* Tags */
.entry-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.entry-tags a {
	display: inline-block; padding: 4px 12px; font-size: .85rem; text-decoration: none;
	color: var(--wmrs-muted); background: var(--wmrs-surface); border: 1px solid var(--wmrs-line); border-radius: 999px;
}
.entry-tags a:hover { color: var(--wmrs-accent); border-color: currentColor; }
.entry-tags .wp-block-post-terms__separator { display: none; }

/* Author box */
.author-box { display: flex; gap: 16px; align-items: flex-start; padding: 20px; margin-top: 1.5rem; border: 1px solid var(--wmrs-line); border-radius: var(--wmrs-radius); }
.author-box img { flex: none; }
.author-box p { margin: 0; }
.author-box__label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--wmrs-muted); }
.author-box__name { font-weight: 700; font-family: var(--wp--preset--font-family--heading); font-size: 1.05rem; }
.author-box__name a { color: var(--wmrs-text); text-decoration: none; }
.author-box__name a:hover { color: var(--wmrs-accent); }
.author-box__bio { color: var(--wmrs-muted); font-size: .95rem; margin-top: 4px !important; }

/* ==========================================================================
   Cards: related posts and query loops (homepage latest posts, archives, search)
   ========================================================================== */
.related { margin-top: var(--wp--preset--spacing--60) !important; }
.related__title, .section-title { font-size: 1.35rem; margin: 0 0 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.card, .wmrs-cards .wp-block-post {
	display: flex; flex-direction: column; overflow: hidden; position: relative;
	background: var(--wmrs-bg); border: 1px solid var(--wmrs-line); border-radius: var(--wmrs-radius);
	transition: box-shadow .2s, transform .2s;
}
.card:hover, .wmrs-cards .wp-block-post:hover { box-shadow: 0 14px 30px -18px rgb(31 27 36 / .35); transform: translateY(-2px); }
.card__image { display: block; aspect-ratio: 3 / 2; background: var(--wmrs-surface); }
.card__image img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0 !important; }
.wmrs-cards .wp-block-post-featured-image { margin: 0; border-radius: 0; }
.wmrs-cards .wp-block-post-featured-image img, .wmrs-cards .wp-block-post-featured-image a { border-radius: 0; }
.card__body, .wmrs-cards .card-body { padding: 16px 18px 20px; display: grid; gap: 6px; }
.card__title, .wmrs-cards .card-title { font-size: 1.1rem !important; line-height: 1.3; margin: 0; }
.card__title a, .wmrs-cards .card-title a { color: var(--wmrs-text); text-decoration: none; }
.card__title a::after, .wmrs-cards .card-title a::after { content: ""; position: absolute; inset: 0; } /* whole card is clickable */
.card__title a:hover, .wmrs-cards .card-title a:hover { color: var(--wmrs-accent); }
.card__meta { margin: 0; font-size: .88rem; color: var(--wmrs-muted); }
.wmrs-cards .wp-block-post-excerpt__excerpt { margin: 0; }
.wmrs-cards .wp-block-post-date, .wmrs-cards .wp-block-post-excerpt { margin: 0; }
.wmrs-cards .wp-block-query-pagination { margin-top: 2rem; }
.wp-block-query-pagination-numbers .page-numbers {
	display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 0 10px;
	border-radius: 999px; text-decoration: none; color: var(--wmrs-text); font-weight: 600;
}
.wp-block-query-pagination-numbers .page-numbers.current { background: var(--wmrs-accent); color: #fff; }

.home-latest .section-title { margin: 0; }
.section-head { gap: 12px 20px; }
.wmrs-view-all { margin: 0; }
.wmrs-view-all .wp-block-button__link { padding: .55rem 1.1rem; font-size: .9rem; background: transparent; color: var(--wmrs-accent); border: 1.5px solid currentColor; }
.wmrs-view-all .wp-block-button__link:hover { background: var(--wmrs-accent); border-color: var(--wmrs-accent); color: #fff; }

/* Card images: always fill the 3:2 frame; fallbacks for posts without a featured image */
.wmrs-cards .card-image { aspect-ratio: 3 / 2; background: var(--wmrs-surface); }
.wmrs-cards .card-image a, .card__image { display: block; width: 100%; height: 100%; }
.wmrs-cards .card-image img, .card__image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-fallback { background: var(--wmrs-surface); }
/* Headings the table of contents links to land with a little room above them. */
.entry-content :is(h2, h3)[id], .wp-block-post-content :is(h2, h3)[id] { scroll-margin-top: 24px; }
.wmrs-toc a { text-underline-offset: 2px; }
.wmrs-cards .card-body, .card__body { padding: 14px 16px 18px; }

/* ==========================================================================
   Comments: minimal
   ========================================================================== */
.comments-area { margin-top: var(--wp--preset--spacing--60) !important; padding-top: var(--wp--preset--spacing--50); border-top: 1px solid var(--wmrs-line); }
.wmrs-comments .wp-block-comments-title { font-size: 1rem; margin: 0 0 1rem; }
.wmrs-comments .wp-block-comment-template { list-style: none; padding: 0; margin: 0 0 2rem; }
.wmrs-comments .wp-block-comment-template ol { list-style: none; padding-left: 24px; border-left: 2px solid var(--wmrs-line); }
.wmrs-comments .comment { padding: 12px 0; }
.wmrs-comments .wp-block-comment-author-name { font-weight: 700; }
.wmrs-comments .wp-block-comment-author-name a { color: var(--wmrs-text); text-decoration: none; }
.wmrs-comments .wp-block-comment-date, .wmrs-comments .wp-block-comment-date a { color: var(--wmrs-muted); text-decoration: none; }
.wmrs-comments .wp-block-comment-content p { margin: .25rem 0; }
.wmrs-comments .wp-block-comment-reply-link a { color: var(--wmrs-muted); font-weight: 600; text-decoration: none; }
.wmrs-comments .wp-block-comment-reply-link a:hover { color: var(--wmrs-accent); }

.comment-respond { background: var(--wmrs-surface); border-radius: var(--wmrs-radius); padding: 18px 20px; }
.comment-reply-title { font-size: 1rem !important; margin: 0 0 .75rem !important; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.comment-reply-title small a { font-size: .85rem; font-weight: 600; color: var(--wmrs-muted); }
.wmrs-comment-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.wmrs-comment-form > p { margin: 0; }
.wmrs-comment-form .comment-form-comment,
.wmrs-comment-form .comment-form-cookies-consent,
.wmrs-comment-form .form-submit,
.wmrs-comment-form .logged-in-as { grid-column: 1 / -1; }
.wmrs-comment-form label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 4px; color: var(--wmrs-muted); }
.wmrs-comment-form .comment-form-hint { font-weight: 400; }
.wmrs-comment-form input[type="text"], .wmrs-comment-form input[type="email"], .wmrs-comment-form textarea {
	width: 100%; padding: 10px 12px; font: inherit; font-size: .95rem; color: var(--wmrs-text);
	background: var(--wmrs-bg); border: 1px solid var(--wmrs-line); border-radius: 10px; box-shadow: none;
}
.wmrs-comment-form textarea { min-height: 88px; resize: vertical; }
.wmrs-comment-form input:focus, .wmrs-comment-form textarea:focus { outline: 2px solid color-mix(in srgb, var(--wmrs-accent) 30%, transparent); border-color: var(--wmrs-accent); }
.wmrs-comment-form .comment-form-cookies-consent { display: flex; gap: 8px; align-items: flex-start; font-size: .82rem; color: var(--wmrs-muted); }
.wmrs-comment-form .comment-form-cookies-consent label { display: inline; font-weight: 400; margin: 0; }
.wmrs-comment-form .logged-in-as { font-size: .82rem; color: var(--wmrs-muted); }
.wmrs-comment-form .logged-in-as a { color: inherit; }
.wmrs-comment-form .form-submit .submit {
	padding: 10px 18px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
	color: #fff; background: var(--wmrs-accent); border: 0; border-radius: 999px;
}
.wmrs-comment-form .form-submit .submit:hover { background: var(--wmrs-accent-hover); }
@media (max-width: 600px) { .wmrs-comment-form { grid-template-columns: 1fr; } }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { font-size: .95rem; }
.site-footer .wp-block-site-title { font-size: 1.15rem; }
.footer-brand p { max-width: 34ch; margin-top: .75rem; }
.footer-brand .wp-block-buttons { margin-top: 1rem; }
.footer-heading { font-size: .75rem !important; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--wmrs-muted); margin: 0 0 .9rem !important; font-family: var(--wp--preset--font-family--body) !important; }
.footer-list { list-style: none; padding: 0; margin: 0; }
.footer-list li { margin: 0 0 .55rem; }
.footer-list a, .footer-legal a { color: var(--wmrs-text); text-decoration: none; }
.footer-list a:hover, .footer-legal a:hover { color: var(--wmrs-accent); text-decoration: underline; }
.footer-bottom { font-size: .82rem; }
.footer-disclosure { max-width: 90ch; line-height: 1.55; }
.wmrs-copyright { margin: 0; color: var(--wmrs-muted); }
.footer-legal { margin: 0; color: var(--wmrs-muted); }

/* Sidebar template */
.site-sidebar .wp-block-template-part { position: sticky; top: 24px; }
.sidebar-latest { padding: 0; list-style: none; }
.sidebar-latest li { padding: 8px 0; border-bottom: 1px solid var(--wmrs-line); margin: 0; }
.sidebar-latest a { color: var(--wmrs-text); text-decoration: none; font-weight: 600; }

/* ==========================================================================
   Click-to-load video
   ========================================================================== */
.wmrs-video {
	position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0;
	background: #000 center / cover no-repeat; border-radius: var(--wmrs-radius); overflow: hidden; cursor: pointer;
}
.wmrs-video::after {
	content: ""; position: absolute; inset: 50% auto auto 50%; width: 68px; height: 48px; transform: translate(-50%, -50%);
	background: rgb(0 0 0 / .72); border-radius: 12px;
}
.wmrs-video::before {
	content: ""; position: absolute; inset: 50% auto auto 50%; z-index: 1; transform: translate(-35%, -50%);
	border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff;
}
.wmrs-video:hover::after, .wmrs-video:focus-visible::after { background: var(--wmrs-accent); }
.wmrs-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Editor placeholders for theme blocks */
.wmrs-block-placeholder {
	display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
	padding: 10px 14px; font-size: 13px; font-family: system-ui, sans-serif;
	color: #5c5664; background: repeating-linear-gradient(-45deg, #faf8fc, #faf8fc 8px, #f3eef8 8px, #f3eef8 16px);
	border: 1px dashed #c8b6da; border-radius: 8px;
}
.wmrs-block-placeholder strong { color: #5b2a86; }

/* ==========================================================================
   Small screens, motion, print
   ========================================================================== */
@media (max-width: 781px) {
	.footer-columns { display: grid !important; grid-template-columns: 1fr 1fr; }
	.footer-columns .footer-brand { grid-column: 1 / -1; }
	.author-box { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media print {
	.site-header, .site-footer, .breadcrumbs, .band, .site-sidebar, .related, .comments-area, .wmrs-post-cta, .wmrs-toc { display: none !important; }
	a { color: inherit; }
}
