/*
Theme Name: Forj
Theme URI: https://forj.com/
Author: Glass Onion LLC
Description: Custom block theme for forj.com. Built to replace Hello Elementor + Elementor Pro.
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.1
Version: 0.4.7
License: GPL-2.0-or-later
Text Domain: forj
*/

/* Most styling lives in theme.json. Only things theme.json can't express go here. */

:where(.wp-site-blocks) :focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

.forj-header {
	border-bottom: 1px solid var(--wp--preset--color--border);
	position: sticky;
	top: 0;
	z-index: 50;
	background: var(--wp--preset--color--base);
}
body.admin-bar .forj-header { top: var(--wp-admin--admin-bar--height, 32px); }

.forj-card {
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 10px;
	background: var(--wp--preset--color--base);
}

.forj-eyebrow {
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-weight: 600;
}

img { height: auto; }
.wp-block-image img, .wp-block-cover { border-radius: 10px; }

/* Product specs table */
.forj-specs table { border-collapse: collapse; }
.forj-specs th { text-align: left; font-weight: 600; color: var(--wp--preset--color--contrast); white-space: nowrap; padding-right: 1.5rem; }
.forj-specs th, .forj-specs td { border: 0; padding-top: 0.6rem; padding-bottom: 0.6rem; }

/* Tighter top of the product page; breadcrumbs sit close to the header */
.wc-block-breadcrumbs { margin-top: 0; }
.wp-site-blocks > .woocommerce.product { margin-block-start: 0; }

/* Switch to the hamburger menu below 900px (core default is 600px), so the menu never wraps */
@media (max-width: 899px) {
	.forj-header .wp-block-navigation__responsive-container-open:not(.always-shown) { display: flex !important; }
	.forj-header .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) { display: none !important; }
}

/* Header icons match the menu text */
.forj-header .wc-block-customer-account__link, .forj-header .wc-block-mini-cart__button { color: var(--wp--preset--color--contrast); }
.forj-header .wc-block-customer-account__link:hover, .forj-header .wc-block-mini-cart__button:hover { color: var(--wp--preset--color--accent); }

/* Checklist style for benefit lists */
.forj-checklist { list-style: none; padding-left: 0; }
.forj-checklist li { position: relative; padding-left: 2rem; margin-bottom: 0.75rem; }
.forj-checklist li::before { content: ""; position: absolute; left: 0; top: 0.35em; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--wp--preset--color--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") center/80% no-repeat; }

/* White button on red background */
.forj-btn-light .wp-block-button__link:hover { background: var(--wp--preset--color--contrast) !important; color: var(--wp--preset--color--base) !important; }

/* Gallery captions readable over photos */
.wp-block-gallery .wp-element-caption { font-weight: 600; }

/* No gap between page content and footer; sections butt against each other */
.wp-site-blocks > footer, .wp-site-blocks > .wp-block-template-part:last-child { margin-block-start: 0; }
.wp-site-blocks > * + * { margin-block-start: 0; }
.wp-block-post-content > .alignfull:last-child { margin-block-end: 0; }

/* Tight text rhythm: headings sit close to the text they introduce */
:where(.wp-site-blocks) :where(h1, h2, h3, h4) + * { margin-block-start: 0.5rem; }
:where(.wp-site-blocks) p + p { margin-block-start: 0.625rem; }
.forj-eyebrow + :where(h1, h2) { margin-block-start: 0.25rem; }

/* Jump links row */
.forj-jumplinks { font-weight: 600; line-height: 2; }
.forj-jumplinks a { text-decoration: none; white-space: nowrap; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }

/* FAQ accordion */
.forj-faq summary { cursor: pointer; font-family: var(--wp--preset--font-family--heading); font-weight: 600; font-size: 1.125rem; color: var(--wp--preset--color--contrast); list-style: none; padding-right: 2rem; position: relative; }
.forj-faq summary::-webkit-details-marker { display: none; }
.forj-faq summary::after { content: "+"; position: absolute; right: 0; top: -0.1em; font-size: 1.5rem; color: var(--wp--preset--color--accent); }
.forj-faq[open] summary::after { content: "–"; }
.forj-faq > p { margin-top: 0.5rem; }

/* Footer: smaller, quieter type */
.forj-footer { font-size: 0.875rem; }
.forj-footer h3 { font-size: 0.8125rem !important; text-transform: uppercase; letter-spacing: 0.06em; }
.forj-footer ul { line-height: 1.9 !important; }
.forj-footer a { text-decoration: none; }
.forj-footer a:hover { text-decoration: underline; }
.forj-footer a, .forj-footer a:visited { color: #E6E7E8; }
.forj-footer a:hover { color: var(--wp--preset--color--base); }

/* Buttons always use white text, even where WooCommerce wraps them in a link color */
.wp-element-button, .wp-block-button__link, .woocommerce a.button, .woocommerce button.button, .wc-block-components-button:not(.is-link) { color: var(--wp--preset--color--base); }
.wp-block-button.is-style-outline .wp-block-button__link { color: var(--wp--preset--color--contrast); }
.forj-btn-light .wp-block-button__link { color: var(--wp--preset--color--accent); }

.wp-site-blocks .forj-footer a:where(:not(.wp-element-button)) { color: #E6E7E8 !important; }
.wp-site-blocks .forj-footer a:where(:not(.wp-element-button)):hover { color: #FFFFFF !important; }

/* Timeline list */
.forj-timeline { list-style: none; padding-left: 0; border-left: 3px solid var(--wp--preset--color--accent); }
.forj-timeline li { padding-left: 1.25rem; margin-bottom: 1rem; position: relative; }
.forj-timeline li::before { content: ""; position: absolute; left: -8px; top: 0.45em; width: 13px; height: 13px; border-radius: 50%; background: var(--wp--preset--color--base); border: 3px solid var(--wp--preset--color--accent); }

/* Contact form */
.forj-form-card { padding: var(--wp--preset--spacing--50); }
.forj-hp, .forj-hp + *, .grunion-field-wrap:has(.forj-hp), .grunion-field-text-wrap:has(.forj-hp), .grunion-field-wrap:has(input[name*="leave-this-field-empty"]) { position: absolute !important; left: -9999px !important; height: 1px; overflow: hidden; }
.contact-form input[type="text"], .contact-form input[type="email"], .contact-form textarea { width: 100%; border: 1px solid var(--wp--preset--color--border); border-radius: 6px; padding: 0.7rem 0.8rem; font: inherit; }
.contact-form textarea { min-height: 9rem; }
.contact-form label { font-weight: 600; color: var(--wp--preset--color--contrast); }
.contact-form button[type="submit"], .contact-form .pushbutton-wide, .contact-form input[type="submit"] {
	background: var(--wp--preset--color--accent); color: var(--wp--preset--color--base); border: 0; border-radius: 6px;
	padding: 0.875rem 1.75rem; font-family: var(--wp--preset--font-family--heading); font-weight: 600; font-size: 1rem; cursor: pointer; width: auto;
}
.contact-form button[type="submit"]:hover { background: var(--wp--preset--color--accent-dark); }
.contact-form fieldset { border: 0; padding: 0; margin: 0; }
.contact-form fieldset legend { font-weight: 600; color: var(--wp--preset--color--contrast); padding: 0; margin-bottom: 0.25rem; }
.contact-form .grunion-radio-options, .contact-form fieldset label { font-weight: 400; }

/* Show "continue" buttons only after the contact form has been sent */
.forj-after-submit { display: none; }
.wp-block-column:has(.contact-form-submission.submission-success) .forj-after-submit,
.wp-block-column:has(.contact-form-submission:not(.contact-form-ajax-submission)) .forj-after-submit { display: block; }

/* Footer newsletter */
.forj-newsletter { display: flex; gap: 0.5rem; max-width: 26rem; }
.forj-newsletter input[type="email"] { flex: 1; min-width: 0; padding: 0.65rem 0.8rem; border-radius: 6px; border: 1px solid #3a3d40; background: #1d1f21; color: #fff; font: inherit; }
.forj-newsletter input::placeholder { color: #9A9EA2; }
.forj-newsletter button { background: var(--wp--preset--color--accent); color: #fff; border: 0; border-radius: 6px; padding: 0.65rem 1.1rem; font-family: var(--wp--preset--font-family--heading); font-weight: 600; cursor: pointer; }
.forj-newsletter button:hover { background: var(--wp--preset--color--accent-dark); }
.forj-footer .wp-block-social-links a { color: #fff !important; }
.contact-form input[type="tel"] { width: 100%; border: 1px solid var(--wp--preset--color--border); border-radius: 6px; padding: 0.7rem 0.8rem; font: inherit; }

/* Accessibility (WCAG 2.2 AA) */
/* Red text on the light-gray surface needs the darker red for 4.5:1 contrast */
.has-surface-background-color a:where(:not(.wp-element-button)),
.has-surface-background-color .has-accent-color { color: var(--wp--preset--color--accent-dark) !important; }
/* Show-password toggle: minimum 24px touch target */
.show-password-input { min-width: 24px; min-height: 24px; }

/* Click-to-play YouTube videos (no YouTube code loads until play) */
.forj-video { max-width: 800px; margin: var(--wp--preset--spacing--50) auto 0; }
.forj-video__btn { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: #000; cursor: pointer; }
.forj-video__btn img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .88; transition: opacity .2s; }
.forj-video__btn:hover img, .forj-video__btn:focus-visible img { opacity: 1; }
.forj-video__btn:focus-visible { outline: 3px solid var(--wp--preset--color--accent); outline-offset: 3px; }
.forj-video__play { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; border-radius: 50%; background: var(--wp--preset--color--accent); box-shadow: 0 4px 16px rgba(0,0,0,.35); transition: transform .2s; }
.forj-video__btn:hover .forj-video__play { transform: scale(1.08); background: var(--wp--preset--color--accent-dark); }
.forj-video__play::before { content: ""; position: absolute; left: 29px; top: 22px; border-style: solid; border-width: 14px 0 14px 22px; border-color: transparent transparent transparent #fff; }
.forj-video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; }
.forj-video figcaption { margin-top: .5rem; text-align: center; font-size: var(--wp--preset--font-size--small); color: var(--wp--preset--color--muted); }

/* Video as the last slide of the product gallery */
.forj-gallery-video .forj-video { margin: 0; max-width: none; aspect-ratio: 1 / 1; display: flex; align-items: center; background: #fff; }
.forj-gallery-video .forj-video__btn { aspect-ratio: 16 / 9; border-radius: 0; background-size: cover; background-position: center; }
.forj-gallery-video .forj-video iframe { border-radius: 0; }
.woocommerce-product-gallery .flex-control-thumbs li.forj-thumb-video { position: relative; overflow: hidden; background: #fff; }
.woocommerce-product-gallery .flex-control-thumbs li.forj-thumb-video img { aspect-ratio: 1 / 1; object-fit: cover; transform: scale(1.34); }
.woocommerce-product-gallery .flex-control-thumbs li.forj-thumb-video::after { content: ""; position: absolute; inset: 0; margin: auto; width: 32px; height: 32px; border-radius: 50%; background: var(--wp--preset--color--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9 7l8 5-8 5z'/%3E%3C/svg%3E") center / 20px no-repeat; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.woocommerce-product-gallery.forj-video-active .woocommerce-product-gallery__trigger { display: none; }

/* Gallery thumbnails: full brightness, equal gaps, red outline on the selected one */
.woocommerce div.product div.images .flex-control-thumbs { margin: 6px -3px 0; }
.woocommerce div.product div.images .flex-control-thumbs li { box-sizing: border-box; padding: 0 3px; position: relative; }
.woocommerce div.product div.images .flex-control-thumbs li img { opacity: 1; border-radius: 4px; outline: 2px solid transparent; outline-offset: -2px; transition: outline-color .15s; }
.woocommerce div.product div.images .flex-control-thumbs li img:hover { outline-color: var(--wp--preset--color--border); }
.woocommerce div.product div.images .flex-control-thumbs li img.flex-active { outline-color: var(--wp--preset--color--accent); }
/* Video thumbnail: image is zoomed to hide letterbox bars, so clip it to the same box and draw the outline on top */
.woocommerce div.product div.images .flex-control-thumbs li.forj-thumb-video { clip-path: inset(0 3px round 4px); }
.woocommerce div.product div.images .flex-control-thumbs li.forj-thumb-video::before { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; right: 3px; border: 2px solid transparent; border-radius: 4px; z-index: 2; pointer-events: none; }
.woocommerce div.product div.images .flex-control-thumbs li.forj-thumb-video:has(img.flex-active)::before { border-color: var(--wp--preset--color--accent); }
.woocommerce div.product div.images .flex-control-thumbs li.forj-thumb-video::after { z-index: 3; }
